Metadata-Version: 2.4
Name: agentguard-runtime
Version: 0.1.0
Summary: Runtime security firewall for LangChain agents — intercepts tool calls, enforces YAML policy, logs to SQLite.
Project-URL: Homepage, https://github.com/agentguard/agentguard-runtime
Project-URL: Issues, https://github.com/agentguard/agentguard-runtime/issues
License: MIT
Keywords: agents,firewall,langchain,llm,security
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.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: fastapi>=0.110.0
Requires-Dist: langchain-core>=0.2.0
Requires-Dist: langchain>=0.2.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: uvicorn[standard]>=0.29.0
Provides-Extra: dev
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: langchain-community>=0.2.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# agentguard-runtime

Runtime security firewall for LangChain agents. Intercepts every tool call, checks it against a YAML policy, blocks disallowed calls, and logs everything to SQLite.

## Install

```bash
pip install agentguard-runtime
```

## Quick start

**1. Write a policy file (`policy.yml`):**

```yaml
agent: pr-summarizer
rules:
  - tool: GitHubTool
    allow: [read]
    block: [admin, write]
  - tool: SlackTool
    allow: [write]
  - tool: "*"
    block: [exec, delete]
```

**2. Add one line to your agent:**

```python
from agentguard_runtime import AgentFirewall

agent = initialize_agent(
    tools=[GitHubTool, SlackTool, ShellTool()],
    llm=llm,
    callbacks=[AgentFirewall(policy="policy.yml")]
)
```

If `ShellTool` tries to call `exec`, the agent gets a `PolicyViolation` and the event is logged.

## CLI

```bash
# Show last 20 audit events
agentguard-runtime logs

# Start dashboard API on port 7070
agentguard-runtime dashboard
```

## Dashboard endpoints

| Endpoint | Description |
|----------|-------------|
| `GET /events` | Recent audit events (filterable by `?decision=block&agent=x`) |
| `GET /summary` | Allowed vs blocked counts per tool today |

## Policy rules

- **`allow`** list: only these actions are permitted on this tool
- **`block`** list: these actions are always rejected
- **`"*"`** tool: catch-all wildcard for unmatched tools
- **Default**: if no rule matches, the call is blocked

## Audit log

Events are stored at `~/.agentguard/audit.db` (SQLite).

```
id | timestamp | agent | tool | action | input_preview | decision | reason
```

## Dev setup

```bash
git clone <repo>
cd agentguard2
pip install -e ".[dev]"
pytest
```

## License

MIT
