Metadata-Version: 2.4
Name: trustprotocol
Version: 1.0.0
Summary: Python SDK for TrustProtocol — AI agent governance and audit trail
Home-page: https://trustprotocol.tech
Author: TrustProtocol
Author-email: contact@trustprotocol.tech
Project-URL: Documentation, https://trustprotocol.tech/docs
Project-URL: Source, https://github.com/chada-hash/trustprotocol-python
Keywords: ai,governance,audit,agents,eu-ai-act,compliance
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.8
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 :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# TrustProtocol Python SDK

Governance and cryptographic audit trail for AI agents.

## Installation

```bash
pip install trustprotocol
```

## Quick Start

```python
from trustprotocol import TrustProtocol

tp = TrustProtocol("your-api-key")

result = tp.intercept(
    agent_id="finance-agent-01",
    action="Transfer 5000 EUR to supplier ACME",
    cost_eur=5000.0,
    user_id="marie@yourcompany.com"
)

if result.authorized:
    print(f"✓ Authorized — Risk score: {result.risk_score}/100")
    # Execute the action
else:
    print(f"✗ Blocked — {result.block_reason}")
```

## Raise on block

```python
from trustprotocol import TrustProtocol, TrustProtocolError

tp = TrustProtocol("your-api-key")

try:
    result = tp.intercept(
        agent_id="finance-agent-01",
        action="Transfer 150000 EUR to new beneficiary",
        cost_eur=150000.0,
        user_id="marie@yourcompany.com",
        raise_on_block=True
    )
    # Execute action
except TrustProtocolError as e:
    print(f"Blocked: {e.block_reason}")
    print(f"Risk score: {e.risk_score}/100")
    print(f"Reasons: {e.reasons}")
```

## With LangChain

```python
from trustprotocol import TrustProtocol
from langchain.tools import tool

tp = TrustProtocol("your-api-key")

@tool
def governed_payment(amount: float, recipient: str, user_id: str) -> str:
    """Execute a payment with TrustProtocol governance."""
    result = tp.intercept(
        agent_id="payment-agent",
        action=f"Transfer {amount} EUR to {recipient}",
        cost_eur=amount,
        user_id=user_id,
        raise_on_block=True
    )
    return f"Payment authorized. Attestation: {result.attestation_id}"
```

## Audit & Verification

```python
# Get audit ledger
ledger = tp.ledger(agent_id="finance-agent-01")
print(f"Total actions: {ledger['total']}")

# Verify chain integrity
verification = tp.verify_chain()
print(f"Chain valid: {verification['chain_valid']}")

# Pending approvals
approvals = tp.approvals()
print(f"Pending: {len(approvals.get('approvals', []))}")
```

## Links

- [Dashboard](https://trustprotocol.tech/dashboard)
- [Documentation](https://trustprotocol.tech/docs)
- [Trust Center](https://trustprotocol.tech/trust)
