Metadata-Version: 2.5
Name: maigp-agent-core
Version: 1.0.1
Summary: MAIGP Agent Governance Core — shared lifecycle for all framework adapters (Mediated AI Governance Protocol)
Requires-Python: >=3.11
Requires-Dist: maigp-client>=5.0.0
Provides-Extra: evidence
Requires-Dist: amigo-bedrock>=0.2.0; extra == 'evidence'
Description-Content-Type: text/markdown

# maigp-agent-core

Shared agent-governance lifecycle for every MAIGP framework adapter.

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 AIGP agent loop itself — the primitive that all framework adapters build on.

## 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-agent-core
```

## Quick start

```python
from aigp_agent_core import AgentGovernance

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

# Start of an agent run
gov.pre_invoke(agent_name="analyst", model_id="claude-opus-4", user_id="u1")

# Agentic control points (RFC-agentic): gate tools, plans, escalations
decision = await gov.on_tool_call("search", params={"q": "..."})
await gov.plan_submit(steps=[{"tool": "search"}, {"tool": "write"}])
await gov.escalate(reason="budget exceeded", action={"type": "pause"})

# Token accounting + completion
gov.on_model_call(input_tokens=500, output_tokens=200)
await gov.step_complete(step_number=1, status="SUCCESS")
await gov.post_invoke(status="SUCCESS")
```

## Who should use this

You normally install a **framework adapter** (e.g. `maigp-crewai`, `maigp-microsoft-agent-framework`) which depends on this package. Install `maigp-agent-core` directly only when writing a custom adapter for a framework not yet covered.

## Control points

`pre_invoke` · `on_model_call` · `on_tool_call` · `plan_submit` · `escalate` · `attest_input` · `step_complete` · `post_invoke` · `on_error`.

## 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.
