Metadata-Version: 2.4
Name: metamynd-client
Version: 0.1.0
Summary: MetaMynd/AgentSafe authorize-gate client for Python — the supported reference implementation of MAGP §7.3
Author: MetaMynd
License-Expression: MIT
Project-URL: Homepage, https://metamynd.ai/developers/python
Project-URL: Documentation, https://metamynd.ai/developers/spec
Project-URL: Source, https://github.com/Metamynd/agentsafe-guard
Project-URL: Issues, https://github.com/Metamynd/agentsafe-guard/issues
Keywords: metamynd,agentsafe,governance,ai-agents,magp,authorization
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
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: Topic :: Security
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography
Dynamic: license-file

# metamynd-client

The MetaMynd/AgentSafe authorize-gate client for Python — the supported reference
implementation. MAGP is language-agnostic by design: the gate verifies an Ed25519
signature over a canonical string, and nothing about that is JavaScript-specific. This
is the proof, and the shortest path for a Python team that doesn't want to read the
[Node guard](https://www.npmjs.com/package/@metamynd/agentsafe-guard) to find out what
the protocol actually expects.

```bash
pip install metamynd-client
```

```python
from metamynd_client import MetaMyndClient

client = MetaMyndClient.from_env()  # reads METAMYND_API / AGENT_DID / AGENT_KEY

verdict = client.authorize(
    "flight-purchase", 150,
    merchant="skyward-air",
    context={"tool": "book-flight", "riskLevel": "low"},
)

if verdict.decision == "escalate":
    # ESCALATE is a HOLD, not a denial — poll until resolved, act only on may_proceed.
    state = client.escalation_status(verdict.escalation_id)
elif not verdict.permitted:
    raise RuntimeError(f"refused: {verdict.reason_code}")
```

## Guard a tool

```python
from metamynd_client import MetaMyndClient, guard_tool, GovernanceBlocked

client = MetaMyndClient.from_env()

def book_flight(amount, merchant):
    ...  # your real implementation

governed_book_flight = guard_tool(
    client, "flight-purchase", book_flight,
    lambda amount, merchant: {"amount": amount, "merchant": merchant},
)

try:
    governed_book_flight(amount=150, merchant="skyward-air")
except GovernanceBlocked as refused:
    print(f"refused: {refused.verdict.reason_code}")
```

Works with any framework — LangGraph, the OpenAI Agents SDK, or a plain function call —
because the governed step is the same everywhere: ask the gate, act only on a permit. See
the [LangGraph guide](https://metamynd.ai/developers/langgraph) and the
[OpenAI Agents SDK guide](https://metamynd.ai/developers/openai-agents) for
framework-specific examples.

## Scope

This is the entry price, not a full SDK: it signs and submits authorize requests,
returns the verdict, wraps a tool (`guard_tool`), and follows up an `escalate`. Local
bundle evaluation, two-phase capture/void, and evidence inclusion-proof fetch all exist
in the protocol and in the [Node guard](https://www.npmjs.com/package/@metamynd/agentsafe-guard)
and are deliberately not reimplemented here — see
[the full comparison](https://metamynd.ai/developers/python).

## Self-test

Checks the three details that cost a Python integration a day each — key encoding,
number stringification, timestamp shape — without touching the network:

```bash
python -m metamynd_client --selftest
```

## Links

- [Full guide](https://metamynd.ai/developers/python)
- [Protocol spec](https://metamynd.ai/developers/spec)
- [Source](https://github.com/Metamynd/agentsafe-guard)

MIT licensed.
