Metadata-Version: 2.4
Name: zabta
Version: 0.3.0
Summary: Govern your AI agents. Policy evaluation, compliance, and audit trails for autonomous AI systems.
Author-email: Zabta <hello@zabta.ai>
License: MIT
Project-URL: Homepage, https://zabta.ai
Project-URL: Documentation, https://zabta.ai/docs
Project-URL: Repository, https://github.com/boredkash-bot/agentos
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx<1.0,>=0.25.0
Requires-Dist: pydantic<3.0,>=2.0
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
Provides-Extra: all
Requires-Dist: openai>=1.0.0; extra == "all"
Requires-Dist: anthropic>=0.18.0; extra == "all"
Requires-Dist: langchain-core>=0.1.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: respx>=0.21; extra == "dev"

# Zabta SDK

Python SDK for [Zabta](https://zabta.ai) — govern, monitor, and manage your AI agents.

## Installation

```bash
pip install zabta
```

For local development:

```bash
cd sdk/
pip install -e .
```

## Quick Start

```python
from zabta import ZabtaClient

client = ZabtaClient(
    api_key="zbt_your_key_here",
    agent_name="My Agent",
)
client.start()

# Check before acting
result = client.evaluate("send_email", "customer_data", {"has_pii": True})
if result.allowed:
    send_email(customer)
elif result.escalated:
    print(f"Needs approval: {result.reason}")
else:
    print(f"Denied: {result.reason}")

client.stop()
```

## Policy Evaluation

```python
# Full evaluation with details
result = client.evaluate("delete", "customer_record", {"is_irreversible": True})
print(result.decision)     # "allow", "deny", or "escalate"
print(result.policy)       # "Kill Switch"
print(result.citation)     # "OWASP ASI08, EU AI Act Art. 14"
print(result.layer)        # "universal"

# Quick boolean check
if client.is_allowed("read", "public_data"):
    read_data()

# Decorator — auto-checks before executing
@client.governed(action="process_refund", resource="payment")
def process_refund(order_id, amount):
    stripe.refunds.create(charge=order_id, amount=amount)
```

## Monitoring Mode

Just log what your agent does (no enforcement):

```python
client.start()
client.log_action("answered_ticket", input_summary="Resolved billing question")
client.log_action("sent_email", input_summary="Welcome email to new customer")
client.stop()
```

## LLM Middleware

Auto-log every OpenAI or Anthropic call:

```python
from zabta.middleware import wrap_openai
import openai

client = ZabtaClient(api_key="zbt_xxx")
oai = wrap_openai(openai.OpenAI(), client)

# This call is automatically logged with token usage, cost, and latency
response = oai.chat.completions.create(model="gpt-4o", messages=[...])
```

## API Reference

### `ZabtaClient`

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `api_key` | `str` | required | API key (`zbt_` or `aos_` prefix) |
| `base_url` | `str` | `https://api.zabta.ai` | API URL |
| `agent_name` | `str` | `"Unnamed Agent"` | Display name |
| `agent_type` | `str` | `"custom"` | Agent type |

**Methods:**

- `evaluate(action, resource, context) -> EvaluateResult` — check policy
- `check(action, resource, context) -> EvaluateResult` — alias for evaluate
- `is_allowed(action, resource) -> bool` — quick boolean check
- `governed(action, resource, context)` — decorator for auto-checking
- `start()` / `stop()` — lifecycle management with heartbeats
- `log_action(action_type, ...)` — fire-and-forget logging
- `request_action(action_type, ...)` — request with approval flow

### `EvaluateResult`

- `.decision` — `"allow"`, `"deny"`, or `"escalate"`
- `.allowed` / `.denied` / `.escalated` — boolean helpers
- `.reason` — human-readable explanation
- `.policy` — deciding policy name
- `.citation` — regulatory citation
- `.layer` — universal / jurisdiction / sectoral

## Backward Compatibility

`from agentos import AgentClient` still works. `aos_` API keys still work.

## License

MIT
