Python SDK for TrustProtocol — AI agent governance and audit trail
Project description
TrustProtocol Python SDK
Governance and cryptographic audit trail for AI agents.
Installation
pip install trustprotocol
Quick Start
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
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
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
# 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
trustprotocol-1.0.0.tar.gz
(4.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trustprotocol-1.0.0.tar.gz.
File metadata
- Download URL: trustprotocol-1.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
334dc786f5acd0a586db6deb366f5dfd5079728e4c90145312eb993796bdc1c1
|
|
| MD5 |
bfe2a944c9665f297b3e4edc10ef92ad
|
|
| BLAKE2b-256 |
4a708be9107c3441c3ee317887085fedc86af2d6b4e9c0d0a61b36fad081d40c
|
File details
Details for the file trustprotocol-1.0.0-py3-none-any.whl.
File metadata
- Download URL: trustprotocol-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9346aa52a3c6b70664c2930b75a5b0f3044e17922c64228989e15f8c9c881bf1
|
|
| MD5 |
436efc60c5eaef9861030fc3589bbb12
|
|
| BLAKE2b-256 |
10172b84576afbbfc8b3e853ea681cefe30ea3b457e007e94fe0a13ab661307a
|