Metadata-Version: 2.4
Name: agentrust-py
Version: 0.0.1a1
Summary: AgentTrust Edge — the AI Agent Harness. One decorator, full trust enforcement.
Project-URL: Homepage, https://agentrust.io
Project-URL: Documentation, https://docs.agentrust.io
Project-URL: Repository, https://github.com/agentrust/agentrust
Project-URL: Changelog, https://github.com/agentrust/agentrust/blob/main/CHANGELOG.md
License: Apache-2.0
License-File: LICENSE
Keywords: agents,ai,audit,compliance,governance,llm,safety,trust
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software 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 :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1.0.0,>=0.27.0
Requires-Dist: pydantic<3.0.0,>=2.0.0
Requires-Dist: pyyaml<7.0,>=6.0.3
Provides-Extra: autoload
Provides-Extra: crewai
Requires-Dist: crewai<1.0.0,>=0.80.0; extra == 'crewai'
Provides-Extra: dev
Requires-Dist: fastapi>=0.137.1; extra == 'dev'
Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=9.1.0; extra == 'dev'
Requires-Dist: respx>=0.21.0; extra == 'dev'
Requires-Dist: tenacity>=8.2.0; extra == 'dev'
Requires-Dist: uvicorn>=0.29.0; extra == 'dev'
Provides-Extra: embedded
Requires-Dist: fastapi<1.0.0,>=0.137.1; extra == 'embedded'
Requires-Dist: uvicorn<1.0.0,>=0.29.0; extra == 'embedded'
Provides-Extra: full
Requires-Dist: agentrust-sdk[embedded,otel,retry]; extra == 'full'
Provides-Extra: langchain
Requires-Dist: langchain<1.0.0,>=0.2.0; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langgraph<1.0.0,>=0.2.0; extra == 'langgraph'
Provides-Extra: openai
Requires-Dist: openai<3.0.0,>=2.41.1; extra == 'openai'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.20.0; extra == 'otel'
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == 'otel'
Provides-Extra: retry
Requires-Dist: tenacity<10.0.0,>=8.2.0; extra == 'retry'
Description-Content-Type: text/markdown

# agentrust-py

[![PyPI](https://img.shields.io/pypi/v/agentrust-py)](https://pypi.org/project/agentrust-py/)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/agentrust/agentrust/blob/main/LICENSE)
[![Python](https://img.shields.io/pypi/pyversions/agentrust-py)](https://pypi.org/project/agentrust-py/)

Python SDK for [AgentTrust Edge](https://github.com/agentrust/agentrust) — runtime AI agent governance with zero-config startup and env-only rollback.

---

## Install

```bash
pip install "agentrust-py[embedded,retry]"
```

---

## 30-second quickstart

```python
from agentrust_sdk import harness, embed_gateway

# Optional: start an in-process SQLite gateway (dev / air-gap)
embed_gateway()

@harness
def my_agent(user: str, input: str) -> dict:
    """Decorated agent. Governance happens automatically after each call."""
    return {"answer": "42"}

result = my_agent(user="alice", input="What is the meaning of life?")
print(result)   # {"answer": "42"} — or BlockedError if policy rejects it
```

> **Note on imports:** The PyPI package name is `agentrust-py`; the Python module is `agentrust_sdk`.
> All imports use `from agentrust_sdk import ...`.

---

## Rollback (no code change, no image rebuild)

```bash
export AGENTRUST_ENABLED=false
# restart process — @harness becomes a no-op identity wrapper
```

---

## Configuration

Every tunable is an env var — no config file required for basic usage.

| Variable | Default | Purpose |
|----------|---------|---------|
| `AGENTRUST_ENABLED` | `true` | Master kill-switch |
| `AGENTRUST_GATEWAY_URL` | `http://localhost:8000` | Gateway URL |
| `AGENTRUST_FAILURE_MODE` | `open` | `open` \| `closed` \| `queue` |
| `AGENTRUST_TIMEOUT_SEC` | `10` | Request timeout |
| `AGENTRUST_RETRY_ATTEMPTS` | `3` | Retries (needs `[retry]`) |
| `AGENTRUST_KEY` | — | API key |

---

## Deployment ladder (env-only)

```bash
# Dev — embedded SQLite, no external services
AGENTRUST_ENABLED=true
# (call embed_gateway() at startup)

# Staging — remote gateway, fail safe
AGENTRUST_GATEWAY_URL=https://agentrust-staging.internal:8000
AGENTRUST_KEY=at_...
AGENTRUST_FAILURE_MODE=closed

# Production
AGENTRUST_GATEWAY_URL=https://agentrust.internal:8000
AGENTRUST_FAILURE_MODE=open
AGENTRUST_RETRY_ATTEMPTS=5
```

App code is **identical** across all three environments.

---

## Failure modes

| Mode | Gateway unreachable behaviour |
|------|------------------------------|
| `open` (default) | Log warning, return approve response — agent continues |
| `closed` | Raise `GatewayUnavailableError` — agent is blocked |
| `queue` | Write request to local SQLite buffer; return approve response |

> **Queue mode note:** The local buffer is written but not automatically replayed in the current release.
> Use `agentrust export` to inspect buffered records. A background drain/replay worker is on the roadmap.

---

## Extras

| Extra | Installs |
|-------|---------|
| `embedded` | `uvicorn`, `fastapi` — in-process gateway via `embed_gateway()` |
| `retry` | `tenacity` — exponential backoff |
| `otel` | `opentelemetry-sdk`, `opentelemetry-api` — traces + metrics |
| `langgraph` | LangGraph `AgentTrustNode` adapter |
| `crewai` | CrewAI `AgentTrustCallback` adapter |
| `full` | All of the above |

---

## Tiers

| Tier | Capabilities |
|------|-------------|
| OSS | Local schema validation, no API key |
| Free | Evidence, tool trust, auto-decision, local audit |
| Developer | Confidence scoring, risk engine, built-in policies |
| Team | Framework adapters, custom policies, analytics, review queue |
| Enterprise | LLM judge, trust chain, SSO, self-hosted, SOC2 export |

---

## CLI

```bash
agentrust init              # create ~/.agentrust/config.yaml
agentrust status            # tier + gateway reachability
agentrust export ./out.jsonl
agentrust purge --confirm
agentrust disable
```

---

## License

Apache-2.0. Framework adapters and enterprise features require a paid subscription.
