Metadata-Version: 2.5
Name: maigp-claude-agent-sdk
Version: 1.0.1
Summary: AIGP governance adapter for the Claude Agent SDK (agent-loop level: query/ClaudeSDKClient, tool use). Distinct from aigp-anthropic, which wraps raw Messages API calls.
Requires-Python: >=3.11
Requires-Dist: maigp-agent-core>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Description-Content-Type: text/markdown

# maigp-claude-agent-sdk

AIGP governance for the Claude Agent SDK, at the agent-loop level.

Part of **MAIGP** — the Mediated AI Governance Protocol: a runtime consent / scope / evidence layer for AI systems. Every governed call is **CHECK**ed before it runs (policy, scope, jurisdiction, circuit-breaker) and **RECORD**ed + **TRACE**d as tamper-evident evidence after.

## What it governs

Governs the Claude Agent SDK agent loop — the `query()` / `ClaudeSDKClient` message stream, including tool-use turns.

## Governance model

This adapter maps the framework's lifecycle onto the AIGP agent-governance loop provided by [`maigp-agent-core`](https://pypi.org/project/maigp-agent-core/):

| Framework event | AIGP action |
|---|---|
| run / invocation start | **CHECK** (`pre_invoke`) — allowed? under what authority? |
| each model reply | token accounting (`on_model_call`) |
| each tool / function call | tool governance (`on_tool_call`) |
| run complete | **RECORD** + **TRACE** (`post_invoke`) |
| failure | `on_error` (recorded, then re-raised) |


## Install

```bash
pip install maigp-claude-agent-sdk
```

Pulls in [`maigp-agent-core`](https://pypi.org/project/maigp-agent-core/) (shared lifecycle) and, transitively, [`maigp-client`](https://pypi.org/project/maigp-client/).

## Quick start

```python
from aigp_claude_agent_sdk import AigpClaudeAgentGovernance

gov = AigpClaudeAgentGovernance(gov_url="https://gov.example.com",
                                app_id="my-agent", hmac_secret="secret")

async for message in gov.query("Analyze this finding",
                               agent_name="analyst",
                               model_id="claude-opus-4"):
    ...  # tool_use turns governed · usage accumulated · RECORD+TRACE at end
```

## Not to be confused with `maigp-anthropic`

This package governs the **Claude Agent SDK** agent loop. For raw `anthropic.messages.create` calls, use [`maigp-anthropic`](https://pypi.org/project/maigp-anthropic/). The SDK's `query` is injected (duck-typed), so no specific SDK version is required.

## Links

- Protocol, specs & full adapter catalog: https://github.com/owner-spec/aigp-protocol
- Issues: https://github.com/owner-spec/aigp-protocol/issues

---

License: Proprietary. © Kanjani AI Research & Causum.
