Metadata-Version: 2.4
Name: nullbridge
Version: 1.0.1
Summary: AI Agent Identity Governance — NullBridge Python SDK
Home-page: https://nullbridge.ai
Author: Brian Dunn
Author-email: Brian Dunn <brian@nullbridge.ai>
Project-URL: Homepage, https://nullbridge.ai
Project-URL: Documentation, https://docs.nullbridge.ai
Keywords: ai,agent,governance,identity,security,llm
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# NullBridge Python SDK

AI Agent Identity Governance for Python — give your AI agents a cryptographic identity, credential vault, behavioral anomaly detection, and kill switch in three lines of code.

## Installation

```bash
pip install nullbridge
```

Requires Python 3.8+. Zero external dependencies.

## Quick Start

```python
from nullbridge import NullBridge
import os

nb = NullBridge(license_key=os.environ["NULLBRIDGE_LICENSE_KEY"])
nb.init()

# Register your agent
agent = nb.agents.register(
    name="fraud-detector",
    type="llm",
    model="gpt-4o",
    scopes=["read:transactions", "write:alerts"],
    metadata={"team": "risk", "environment": "prod"},
)

# Log actions to the audit trail
agent.log_action("analyze_transaction", {"tx_id": "TX-1234", "amount": 5000})

# Check permissions
if not agent.has_scope("write:alerts"):
    raise PermissionError("Agent not authorized")

# Graceful shutdown
nb.shutdown()
```

## Usage with LangChain

```python
from nullbridge import NullBridge
from langchain.agents import initialize_agent

nb = NullBridge(license_key=os.environ["NULLBRIDGE_LICENSE_KEY"])
nb.init()

agent_identity = nb.agents.register(
    name="langchain-research-agent",
    type="llm",
    model="gpt-4o",
    scopes=["read:web", "write:reports"],
)

# Your normal LangChain agent
lc_agent = initialize_agent(tools, llm, agent="zero-shot-react-description")

# Wrap with NullBridge audit logging
def run_with_governance(query):
    agent_identity.log_action("run_query", {"query": query})
    result = lc_agent.run(query)
    agent_identity.log_action("query_complete", {"result_length": len(result)})
    return result
```

## Usage with CrewAI

```python
from nullbridge import NullBridge
from crewai import Agent, Task, Crew

nb = NullBridge(license_key=os.environ["NULLBRIDGE_LICENSE_KEY"])
nb.init()

# Register each CrewAI agent with NullBridge
researcher_identity = nb.agents.register(
    name="researcher",
    type="llm",
    scopes=["read:web"],
)

writer_identity = nb.agents.register(
    name="writer",
    type="llm",
    scopes=["write:reports"],
)
```

## Context Manager

```python
with NullBridge(license_key="NB-XXXX-XXXX-XXXX-XXXX") as nb:
    agent = nb.agents.register(name="my-agent", type="llm")
    agent.log_action("do_something")
# Automatically shuts down and flushes audit logs
```

## Anomaly Detection

```python
nb.anomaly.on_alert(lambda alert: print(f"Anomaly: {alert['metric']} z={alert['z_score']}"))

# Record metrics — NullBridge builds a baseline and alerts on deviations
nb.anomaly.record(agent.id, "api_calls_per_minute", 14)
nb.anomaly.record(agent.id, "tokens_used", 3200)
```

## Environment Variables

```bash
export NULLBRIDGE_LICENSE_KEY=NB-XXXX-XXXX-XXXX-XXXX
```

## License

Proprietary — contact brian@nullbridge.ai for licensing.
