Metadata-Version: 2.4
Name: asqav-pydantic
Version: 0.1.1
Summary: PydanticAI integration for asqav - cryptographic audit trails for AI agent tool calls
Project-URL: Homepage, https://asqav.com
Project-URL: Documentation, https://asqav.com/docs
Project-URL: Repository, https://github.com/jagmarques/asqav-pydantic
Author-email: Asqav <hello@asqav.com>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,audit-trail,compliance,cryptographic-signing,governance,pydantic-ai,tool-calls
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
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 :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: asqav>=0.2.15
Requires-Dist: pydantic-ai>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.5.0; extra == 'dev'
Description-Content-Type: text/markdown

  Governance for AI agents. Audit trails, policy enforcement, and compliance.

  Website (https://asqav.com) |
  Docs (https://asqav.com/docs) |
  SDK Guide (https://asqav.com/docs/sdk) |
  Compliance (https://asqav.com/compliance)

# asqav-pydantic

Cryptographic audit trails for PydanticAI agent tool calls.

Uses PydanticAI's [Hooks capability](https://pydantic.dev/docs/ai/core-concepts/hooks/) to sign every tool invocation with [asqav](https://asqav.com) - producing tamper-evident records for compliance and governance.

## Install

```bash
pip install asqav-pydantic
```

## Usage

```python
import asqav
from pydantic_ai import Agent
from asqav_pydantic import AsqavHooks

asqav.init(api_key="sk_...")

hooks = AsqavHooks(agent_name="my-agent")
agent = Agent("openai:gpt-4o", capabilities=[hooks.capability()])

result = agent.run_sync("Search for the latest AI news")
```

Every tool call the agent makes will produce signed `tool:start`, `tool:end`, and `tool:error` events through the asqav API. Signatures use ML-DSA (post-quantum) cryptography server-side.

## How it works

`AsqavHooks` extends the asqav adapter base class and builds a PydanticAI `Hooks` capability with three registered hooks:

- `before_tool_execute` - signs `tool:start` with tool name and input preview
- `after_tool_execute` - signs `tool:end` with tool name and output metadata
- `on_tool_execute_error` - signs `tool:error` with tool name and error details

All signing is fail-open. If the asqav API is unreachable, a warning is logged but the tool call proceeds normally. Your agent pipeline never breaks because of governance.

## Configuration

```python
# Use an existing asqav agent by ID
hooks = AsqavHooks(agent_id="ag_abc123")

# Override the API key
hooks = AsqavHooks(api_key="sk_other", agent_name="audit-agent")
```

## License

MIT
