Metadata-Version: 2.4
Name: agentguardproxy
Version: 0.4.0
Summary: Python SDK for AgentGuard — the firewall for AI agents
Author: AgentGuard Contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Caua-ferraz/AgentGuard
Project-URL: Repository, https://github.com/Caua-ferraz/AgentGuard
Project-URL: Documentation, https://github.com/Caua-ferraz/AgentGuard/blob/master/docs/SETUP.md
Project-URL: Issues, https://github.com/Caua-ferraz/AgentGuard/issues
Keywords: ai,agents,firewall,policy,guardrails,safety
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Provides-Extra: crewai
Requires-Dist: crewai>=0.1.0; extra == "crewai"
Provides-Extra: browser-use
Requires-Dist: browser-use>=0.1.0; extra == "browser-use"
Provides-Extra: mcp
Provides-Extra: all
Requires-Dist: langchain>=0.1.0; extra == "all"
Requires-Dist: crewai>=0.1.0; extra == "all"
Requires-Dist: browser-use>=0.1.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"

# AgentGuard Python SDK

Lightweight Python client for [AgentGuard](https://github.com/Caua-ferraz/AgentGuard) — the firewall for AI agents.

## Install

```bash
pip install agentguardproxy

# With framework adapters
pip install agentguardproxy[langchain]
pip install agentguardproxy[crewai]
pip install agentguardproxy[browser-use]
pip install agentguardproxy[all]
```

## Quick Start

```python
from agentguard import Guard

guard = Guard("http://localhost:8080", agent_id="my-agent")

# Check before executing
result = guard.check("shell", command="rm -rf ./old_data")

if result.allowed:
    execute(command)
elif result.needs_approval:
    print(f"Approve at: {result.approval_url}")
else:
    print(f"Blocked: {result.reason}")
```

## Framework Adapters

### LangChain

```python
from agentguard.adapters.langchain import GuardedToolkit

toolkit = GuardedToolkit(
    tools=my_tools,
    guard_url="http://localhost:8080",
    agent_id="langchain-agent",
)

agent = create_react_agent(llm, toolkit.tools, prompt)
```

### CrewAI

```python
from agentguard.adapters.crewai import guard_crew_tools

guarded_tools = guard_crew_tools(
    tools=my_crew_tools,
    guard_url="http://localhost:8080",
    agent_id="crew-agent",
)
```

### browser-use

```python
from agentguard.adapters.browseruse import GuardedBrowser

browser = GuardedBrowser(guard_url="http://localhost:8080")

result = browser.check_navigation("https://example.com")
if result.allowed:
    await page.goto("https://example.com")
```

### MCP

```python
from agentguard.adapters.mcp import GuardedMCPServer

server = GuardedMCPServer(guard_url="http://localhost:8080")
server.add_tool("my_tool", "Description", handler=my_handler)
server.run()  # Starts stdio MCP server
```

## API Reference

### `Guard(base_url, agent_id="")`
- `check(scope, *, action, command, path, domain, url, meta)` — Check an action against policy
- `approve(approval_id)` — Approve a pending action
- `deny(approval_id)` — Deny a pending action
- `wait_for_approval(approval_id, timeout=300)` — Block until resolved

### `CheckResult`
- `.allowed` — True if action is permitted
- `.denied` — True if action is blocked
- `.needs_approval` — True if human approval required
- `.decision` — Raw decision string
- `.reason` — Explanation
- `.approval_url` — URL to approve (when applicable)

### `@guarded(scope, guard=None)` decorator
Wraps a function so it's checked before execution.

## License

Apache 2.0
