Metadata-Version: 2.5
Name: parapetai-agent
Version: 0.1.0
Summary: Open-source in-process governance for AI agent frameworks: Cedar-governed model/tool calls via build_middleware()/GovernedAgent, plus the Cedar engine, request/decision shapes, PEP<->control-plane protocol client, and Ed25519 PEP identity they run on.
Project-URL: Homepage, https://github.com/autonomyproof/parapetai-platform
Project-URL: Repository, https://github.com/autonomyproof/parapetai-platform
Project-URL: Issues, https://github.com/autonomyproof/parapetai-platform/issues
Author: Parapet
License-Expression: MIT
License-File: LICENSE
Keywords: agent,authorization,cedar,governance,guardrails,llm,policy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: cedarpy<5.0,>=4.0.0
Requires-Dist: cryptography<47.0,>=43.0
Requires-Dist: httpx<1.0,>=0.28
Requires-Dist: opentelemetry-api<2.0,>=1.20
Requires-Dist: structlog<26.0,>=24.4
Provides-Extra: dev
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: opentelemetry-sdk<2.0,>=1.20; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: respx>=0.22; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: maf
Requires-Dist: agent-framework<2.0,>=1.13; extra == 'maf'
Requires-Dist: mcp<2.0,>=1.24; extra == 'maf'
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0,>=1.27; extra == 'maf'
Requires-Dist: opentelemetry-sdk<2.0,>=1.27; extra == 'maf'
Provides-Extra: web
Requires-Dist: starlette<1.0,>=0.38; extra == 'web'
Description-Content-Type: text/markdown

# parapetai-agent

In-process governance for AI agent frameworks. Wrap the agent you already
have, and every model call and tool call becomes a Cedar policy decision —
default-deny, fail-closed, content-free audit.

```bash
pip install parapetai-agent
```

## Use it

```python
from parapetai_agent import GovernedAgent as Agent, GovernanceDenied

agent = Agent(
    name="support",
    instructions="Help the customer.",
    tools=[lookup_order],
    agent_id="pa-e3931c464751",
    control_plane_url="https://parapetai.example.com",
    agent_secret="...",
)

try:
    result = await agent.run("Where is order 1234?")
except GovernanceDenied as denied:
    print(denied.reason)
```

`GovernedAgent` is a drop-in replacement for `agent_framework.Agent`. If you
build your own middleware chain instead, `build_middleware()` returns the same
governance as a plain middleware you can pass to `middleware=[...]`.

Policy comes from a signed bundle the SDK pulls from the control plane and
caches locally; decisions are pushed back as content-free audit records.
Without a control plane, point `policy_dir=` at local Cedar files.

## Identity

Governance decisions are made about a caller, not just an agent. Bind one:

```python
from parapetai_agent import set_identity, use_identity

set_identity("alice", claims={"oid": "..."}, roles=["OrderViewer"])
with use_identity("alice"):
    await agent.run(...)
```

In a web app, install `parapetai-agent[web]` and add `IdentityMiddleware`, which
lifts the identity off the incoming request instead.

## Extras

| Extra | Brings in | For |
|---|---|---|
| `maf` | `agent-framework`, `mcp`, OpenTelemetry SDK + OTLP exporter | Microsoft Agent Framework integration and OTel export |
| `web` | `starlette` | `IdentityMiddleware`, `jwt_bearer_extractor` |
| _(base)_ | `cedarpy`, `httpx`, `cryptography`, `opentelemetry-api` | Cedar engine, control-plane protocol, Ed25519 PEP identity |

The base install never imports a web framework or an agent framework, so a CLI
script or background worker can depend on it without pulling either in.

## Invariants

These are security properties, not defaults you can tune away:

- **Fail closed.** An unparsed payload, an evaluation error, or a missing
  policy denies. No exception path becomes an implicit allow.
- **Cedar is default-deny.** No matching `permit` is a Deny; `forbid` always
  beats `permit`.
- **A bad bundle never empties the policy set.** Reload keeps the previous
  policies on failure.
- **Prompt content is never logged** unless you explicitly opt in. The decision
  audit record is content-free by construction, not by configuration.

## Links

- Source: https://github.com/autonomyproof/parapetai-platform
- Issues: https://github.com/autonomyproof/parapetai-platform/issues

MIT licensed.
