Metadata-Version: 2.4
Name: kontext-sdk
Version: 0.9.0
Summary: Proof of compliance Python client for AI agents making agentic stablecoin and fiat payments.
Author-email: "Legaci Labs Inc." <hello@kontext.dev>
License: MIT
Project-URL: Homepage, https://getkontext.com
Project-URL: Repository, https://github.com/Legaci-Labs/kontext
Project-URL: Documentation, https://getkontext.com/docs
Keywords: compliance,USDC,stablecoin,AI agent,audit trail,OFAC
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-httpx>=0.30; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"

# kontext-sdk

Proof of compliance Python client for AI agents making agentic stablecoin and fiat payments.

Thin HTTP client wrapping the [Kontext REST API](https://getkontext.com/docs). All compliance logic runs server-side in TypeScript — this package provides typed Python bindings with sync and async support.

## Install

```bash
pip install kontext-sdk
```

## Quick Start

```python
from kontext import Kontext

ctx = Kontext(api_key="sk_...", project_id="my-agent")

# Log a transaction
ctx.log_transaction(
    tx_hash="0xabc...",
    chain="base",
    amount="5000",
    token="USDC",
    from_address="0xsender...",
    to_address="0xrecipient...",
    agent_id="payment-agent",
)

# Flush to server
ctx.flush()

# Trust score
trust = ctx.get_trust_score("payment-agent")
print(f"Trust: {trust.score}/100 ({trust.level})")

# Human-in-the-loop
task = ctx.create_task(
    description="Approve $5K transfer",
    agent_id="payment-agent",
    required_evidence=["txHash"],
)
confirmed = ctx.confirm_task(task.id, evidence={"txHash": "0xabc..."})

# Audit export
audit = ctx.export_audit(format="json")
```

## Async

```python
from kontext import AsyncKontext

async with AsyncKontext(api_key="sk_...", project_id="my-agent") as ctx:
    await ctx.log(action="transfer", agent_id="agent-1")
    trust = await ctx.get_trust_score("agent-1")
```

## Context Manager

```python
with Kontext(api_key="sk_...", project_id="my-agent") as ctx:
    ctx.log(action="transfer", agent_id="agent-1")
# auto-flushes on exit
```

## API

| Method | Description |
|--------|-------------|
| `log(action, agent_id, ...)` | Buffer an action log |
| `log_transaction(tx_hash, chain, ...)` | Buffer a transaction log |
| `flush()` | Send buffered actions to server |
| `create_task(description, agent_id, ...)` | Create human-in-the-loop task |
| `get_task(task_id)` | Get task status |
| `confirm_task(task_id, evidence)` | Confirm task with evidence |
| `get_trust_score(agent_id)` | Get agent trust score (0-100) |
| `export_audit(format)` | Export audit trail (JSON or CSV) |
| `get_usage()` | Get usage and plan limits |
| `evaluate_anomalies(amount, agent_id, ...)` | Evaluate transaction for anomalies |
| `health()` | Check API health |

## TypeScript SDK Features (server-side)

The Python client wraps the Kontext REST API. The full TypeScript SDK (`kontext-sdk` on npm) includes:

- Pluggable multi-provider sanctions screening (OFAC, UK OFSI, OpenSanctions, Chainalysis)
- Tamper-evident digest chains (patented)
- Agent provenance and session tracking
- Compliance certificates with SHA-256 proof
- Trust scoring and anomaly detection
- MCP server mode for AI coding tools

## License

MIT
