Metadata-Version: 2.4
Name: prosader
Version: 0.1.0
Summary: Guard AI agent tool calls with a Prosader runtime security gateway
Author: Prosader
License: Apache-2.0
Project-URL: Homepage, https://prosader.com
Keywords: ai-agents,security,audit,compliance,mcp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# Prosader Python SDK

Guard AI agent tool calls with a [Prosader](https://prosader.com) runtime
security gateway. Every guarded call is evaluated against your policy and
produces a signed, tamper-evident audit receipt — evidence you can hand to an
auditor and verify independently with `prosader-verify`.

No dependencies: the SDK uses only the Python standard library (3.9+).

## Install

```bash
pip install prosader
```

## Usage

```python
import prosader

client = prosader.Client(
    gateway_url="https://gateway.example.com:8443",
    api_key="psk-live-...",
    agent_id="billing-agent",
)

# Option 1 — explicit check before you execute a tool:
decision = client.check("bash", parameters={"command": "rm -rf /tmp/cache"})
if decision.allowed:
    run_command(...)
else:
    print(f"blocked by rule {decision.rule_id}: {decision.reason}")
    # decision.receipt_id — signed audit receipt either way

# Option 2 — wrap a function; blocked calls raise prosader.Denied:
@client.wrap("send_email")
def send_email(to, subject, body):
    ...

try:
    send_email(to="cfo@example.com", subject="Invoice", body="...")
except prosader.Denied as e:
    print(e.decision.reason)
```

Or configure once and use module-level helpers:

```python
prosader.configure(gateway_url="https://...", api_key="psk-...", agent_id="my-agent")

@prosader.wrap("bash")
def run_bash(command): ...
```

Configuration falls back to environment variables: `PROSADER_GATEWAY_URL`,
`PROSADER_API_KEY`, `PROSADER_AGENT_ID`.

## Outcomes

| Outcome   | `decision.allowed` | Meaning                                            |
|-----------|--------------------|----------------------------------------------------|
| `ALLOW`   | `True`             | Proceed.                                           |
| `DENY`    | `False`            | Blocked by policy (`rule_id`, `reason` populated). |
| `STEP_UP` | `False`            | Held for human approval in the Prosader dashboard. |

Errors:

- `prosader.Denied` — raised by wrapped functions when blocked.
- `prosader.BillingError` — subscription inactive or decision quota exhausted (HTTP 402).
- `prosader.GatewayError` — gateway unreachable. Prosader is fail-closed:
  treat this as a denial.

## Notes

- Function arguments of wrapped functions are sent as the tool call's
  `parameters` so policy rules can match on them (e.g. deny `bash` where
  `command` contains `rm -rf`).
- For development gateways with a self-signed certificate, pass
  `verify_tls=False`. Never do this in production.
- Requires a gateway new enough to support check-only mode
  (`X-Prosader-Check-Only`), July 2026 or later.

## Running tests

```bash
python -m unittest discover -s tests -v
```
