trustprotocol 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: trustprotocol
3
+ Version: 1.0.0
4
+ Summary: Python SDK for TrustProtocol — AI agent governance and audit trail
5
+ Home-page: https://trustprotocol.tech
6
+ Author: TrustProtocol
7
+ Author-email: contact@trustprotocol.tech
8
+ Project-URL: Documentation, https://trustprotocol.tech/docs
9
+ Project-URL: Source, https://github.com/chada-hash/trustprotocol-python
10
+ Keywords: ai,governance,audit,agents,eu-ai-act,compliance
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.28.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # TrustProtocol Python SDK
37
+
38
+ Governance and cryptographic audit trail for AI agents.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install trustprotocol
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ ```python
49
+ from trustprotocol import TrustProtocol
50
+
51
+ tp = TrustProtocol("your-api-key")
52
+
53
+ result = tp.intercept(
54
+ agent_id="finance-agent-01",
55
+ action="Transfer 5000 EUR to supplier ACME",
56
+ cost_eur=5000.0,
57
+ user_id="marie@yourcompany.com"
58
+ )
59
+
60
+ if result.authorized:
61
+ print(f"✓ Authorized — Risk score: {result.risk_score}/100")
62
+ # Execute the action
63
+ else:
64
+ print(f"✗ Blocked — {result.block_reason}")
65
+ ```
66
+
67
+ ## Raise on block
68
+
69
+ ```python
70
+ from trustprotocol import TrustProtocol, TrustProtocolError
71
+
72
+ tp = TrustProtocol("your-api-key")
73
+
74
+ try:
75
+ result = tp.intercept(
76
+ agent_id="finance-agent-01",
77
+ action="Transfer 150000 EUR to new beneficiary",
78
+ cost_eur=150000.0,
79
+ user_id="marie@yourcompany.com",
80
+ raise_on_block=True
81
+ )
82
+ # Execute action
83
+ except TrustProtocolError as e:
84
+ print(f"Blocked: {e.block_reason}")
85
+ print(f"Risk score: {e.risk_score}/100")
86
+ print(f"Reasons: {e.reasons}")
87
+ ```
88
+
89
+ ## With LangChain
90
+
91
+ ```python
92
+ from trustprotocol import TrustProtocol
93
+ from langchain.tools import tool
94
+
95
+ tp = TrustProtocol("your-api-key")
96
+
97
+ @tool
98
+ def governed_payment(amount: float, recipient: str, user_id: str) -> str:
99
+ """Execute a payment with TrustProtocol governance."""
100
+ result = tp.intercept(
101
+ agent_id="payment-agent",
102
+ action=f"Transfer {amount} EUR to {recipient}",
103
+ cost_eur=amount,
104
+ user_id=user_id,
105
+ raise_on_block=True
106
+ )
107
+ return f"Payment authorized. Attestation: {result.attestation_id}"
108
+ ```
109
+
110
+ ## Audit & Verification
111
+
112
+ ```python
113
+ # Get audit ledger
114
+ ledger = tp.ledger(agent_id="finance-agent-01")
115
+ print(f"Total actions: {ledger['total']}")
116
+
117
+ # Verify chain integrity
118
+ verification = tp.verify_chain()
119
+ print(f"Chain valid: {verification['chain_valid']}")
120
+
121
+ # Pending approvals
122
+ approvals = tp.approvals()
123
+ print(f"Pending: {len(approvals.get('approvals', []))}")
124
+ ```
125
+
126
+ ## Links
127
+
128
+ - [Dashboard](https://trustprotocol.tech/dashboard)
129
+ - [Documentation](https://trustprotocol.tech/docs)
130
+ - [Trust Center](https://trustprotocol.tech/trust)
@@ -0,0 +1,95 @@
1
+ # TrustProtocol Python SDK
2
+
3
+ Governance and cryptographic audit trail for AI agents.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install trustprotocol
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from trustprotocol import TrustProtocol
15
+
16
+ tp = TrustProtocol("your-api-key")
17
+
18
+ result = tp.intercept(
19
+ agent_id="finance-agent-01",
20
+ action="Transfer 5000 EUR to supplier ACME",
21
+ cost_eur=5000.0,
22
+ user_id="marie@yourcompany.com"
23
+ )
24
+
25
+ if result.authorized:
26
+ print(f"✓ Authorized — Risk score: {result.risk_score}/100")
27
+ # Execute the action
28
+ else:
29
+ print(f"✗ Blocked — {result.block_reason}")
30
+ ```
31
+
32
+ ## Raise on block
33
+
34
+ ```python
35
+ from trustprotocol import TrustProtocol, TrustProtocolError
36
+
37
+ tp = TrustProtocol("your-api-key")
38
+
39
+ try:
40
+ result = tp.intercept(
41
+ agent_id="finance-agent-01",
42
+ action="Transfer 150000 EUR to new beneficiary",
43
+ cost_eur=150000.0,
44
+ user_id="marie@yourcompany.com",
45
+ raise_on_block=True
46
+ )
47
+ # Execute action
48
+ except TrustProtocolError as e:
49
+ print(f"Blocked: {e.block_reason}")
50
+ print(f"Risk score: {e.risk_score}/100")
51
+ print(f"Reasons: {e.reasons}")
52
+ ```
53
+
54
+ ## With LangChain
55
+
56
+ ```python
57
+ from trustprotocol import TrustProtocol
58
+ from langchain.tools import tool
59
+
60
+ tp = TrustProtocol("your-api-key")
61
+
62
+ @tool
63
+ def governed_payment(amount: float, recipient: str, user_id: str) -> str:
64
+ """Execute a payment with TrustProtocol governance."""
65
+ result = tp.intercept(
66
+ agent_id="payment-agent",
67
+ action=f"Transfer {amount} EUR to {recipient}",
68
+ cost_eur=amount,
69
+ user_id=user_id,
70
+ raise_on_block=True
71
+ )
72
+ return f"Payment authorized. Attestation: {result.attestation_id}"
73
+ ```
74
+
75
+ ## Audit & Verification
76
+
77
+ ```python
78
+ # Get audit ledger
79
+ ledger = tp.ledger(agent_id="finance-agent-01")
80
+ print(f"Total actions: {ledger['total']}")
81
+
82
+ # Verify chain integrity
83
+ verification = tp.verify_chain()
84
+ print(f"Chain valid: {verification['chain_valid']}")
85
+
86
+ # Pending approvals
87
+ approvals = tp.approvals()
88
+ print(f"Pending: {len(approvals.get('approvals', []))}")
89
+ ```
90
+
91
+ ## Links
92
+
93
+ - [Dashboard](https://trustprotocol.tech/dashboard)
94
+ - [Documentation](https://trustprotocol.tech/docs)
95
+ - [Trust Center](https://trustprotocol.tech/trust)
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,32 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="trustprotocol",
5
+ version="1.0.0",
6
+ description="Python SDK for TrustProtocol — AI agent governance and audit trail",
7
+ long_description=open("README.md").read(),
8
+ long_description_content_type="text/markdown",
9
+ author="TrustProtocol",
10
+ author_email="contact@trustprotocol.tech",
11
+ url="https://trustprotocol.tech",
12
+ project_urls={
13
+ "Documentation": "https://trustprotocol.tech/docs",
14
+ "Source": "https://github.com/chada-hash/trustprotocol-python",
15
+ },
16
+ packages=find_packages(),
17
+ python_requires=">=3.8",
18
+ install_requires=["requests>=2.28.0"],
19
+ keywords=["ai", "governance", "audit", "agents", "eu-ai-act", "compliance"],
20
+ classifiers=[
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Developers",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.8",
26
+ "Programming Language :: Python :: 3.9",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Topic :: Software Development :: Libraries :: Python Modules",
31
+ ],
32
+ )
@@ -0,0 +1,3 @@
1
+ from .client import TrustProtocol
2
+ __all__ = ["TrustProtocol"]
3
+ __version__ = "1.0.0"
@@ -0,0 +1,217 @@
1
+ """
2
+ TrustProtocol Python SDK
3
+ Governance and cryptographic audit trail for AI agents.
4
+ https://trustprotocol.tech
5
+ """
6
+
7
+ import requests
8
+ from typing import Optional, List
9
+
10
+
11
+ class TrustProtocolError(Exception):
12
+ """Raised when an action is blocked by TrustProtocol."""
13
+ def __init__(self, message: str, block_reason: str = "", risk_score: int = 0, reasons: List[str] = []):
14
+ super().__init__(message)
15
+ self.block_reason = block_reason
16
+ self.risk_score = risk_score
17
+ self.reasons = reasons
18
+
19
+
20
+ class AttestationResult:
21
+ """Result returned by TrustProtocol after intercepting an action."""
22
+ def __init__(self, data: dict):
23
+ self.attestation_id: str = data.get("attestation_id", "")
24
+ self.blocked: bool = data.get("blocked", False)
25
+ self.decision: str = data.get("decision", "authorized")
26
+ self.block_reason: str = data.get("block_reason", "")
27
+ self.risk_score: int = data.get("risk_score", 0)
28
+ self.risk_level: str = data.get("risk_level", "low")
29
+ self.risk_reasons: List[str] = data.get("risk_reasons", [])
30
+ self.hash_sha256: str = data.get("hash_sha256", "")
31
+ self.signature: str = data.get("signature", "")
32
+ self.timestamp: str = data.get("timestamp", "")
33
+ self.chain_height: int = data.get("chain_height", 0)
34
+ self.retained_until: str = data.get("retained_until", "")
35
+ self._raw = data
36
+
37
+ @property
38
+ def authorized(self) -> bool:
39
+ return not self.blocked
40
+
41
+ @property
42
+ def approval_required(self) -> bool:
43
+ return self.decision == "approval_required"
44
+
45
+ def __repr__(self):
46
+ return (f"AttestationResult(decision={self.decision!r}, "
47
+ f"risk_score={self.risk_score}, "
48
+ f"attestation_id={self.attestation_id!r})")
49
+
50
+
51
+ class TrustProtocol:
52
+ """
53
+ TrustProtocol client.
54
+
55
+ Usage:
56
+ from trustprotocol import TrustProtocol
57
+
58
+ tp = TrustProtocol("your-api-key")
59
+
60
+ # Intercept an AI agent action before execution
61
+ result = tp.intercept(
62
+ agent_id="finance-agent-01",
63
+ action="Transfer 5000 EUR to supplier ACME",
64
+ cost_eur=5000.0,
65
+ user_id="marie@yourcompany.com"
66
+ )
67
+
68
+ if result.authorized:
69
+ # Execute the action
70
+ pass
71
+ """
72
+
73
+ BASE_URL = "https://api.trustprotocol.tech"
74
+
75
+ def __init__(self, api_key: str, base_url: Optional[str] = None, timeout: int = 10):
76
+ """
77
+ Initialize the TrustProtocol client.
78
+
79
+ Args:
80
+ api_key: Your TrustProtocol API key (tp-...)
81
+ base_url: Custom API URL (optional, defaults to production)
82
+ timeout: Request timeout in seconds (default: 10)
83
+ """
84
+ if not api_key:
85
+ raise ValueError("TrustProtocol: api_key is required.")
86
+ self.api_key = api_key
87
+ self.base_url = (base_url or self.BASE_URL).rstrip("/")
88
+ self.timeout = timeout
89
+ self._session = requests.Session()
90
+ self._session.headers.update({
91
+ "x-api-key": self.api_key,
92
+ "Content-Type": "application/json",
93
+ "User-Agent": "trustprotocol-python/1.0.0"
94
+ })
95
+
96
+ def intercept(
97
+ self,
98
+ agent_id: str,
99
+ action: str,
100
+ cost_eur: float = 0.0,
101
+ user_id: str = "",
102
+ model_id: Optional[str] = None,
103
+ session_id: Optional[str] = None,
104
+ budget_limit: Optional[float] = None,
105
+ raise_on_block: bool = False,
106
+ ) -> AttestationResult:
107
+ """
108
+ Intercept an AI agent action before execution.
109
+
110
+ Args:
111
+ agent_id: Identifier of the AI agent
112
+ action: Description of what the agent wants to do
113
+ cost_eur: Estimated cost in euros (default: 0)
114
+ user_id: Human user responsible for this action (required for Art.12)
115
+ model_id: AI model used (e.g. "gpt-4o", "claude-sonnet-4-6")
116
+ session_id: Optional session or workflow identifier
117
+ budget_limit: Budget limit in euros for this agent
118
+ raise_on_block: If True, raises TrustProtocolError when blocked
119
+
120
+ Returns:
121
+ AttestationResult with decision, risk score, and cryptographic proof
122
+
123
+ Raises:
124
+ TrustProtocolError: If raise_on_block=True and action is blocked
125
+ requests.HTTPError: If the API returns an error
126
+ """
127
+ payload = {
128
+ "agent_id": agent_id,
129
+ "action": action,
130
+ "cost_eur": cost_eur,
131
+ "user_id": user_id,
132
+ }
133
+ if model_id:
134
+ payload["model_id"] = model_id
135
+ if session_id:
136
+ payload["session_id"] = session_id
137
+ if budget_limit is not None:
138
+ payload["budget_limit"] = budget_limit
139
+
140
+ response = self._session.post(
141
+ f"{self.base_url}/intercept",
142
+ json=payload,
143
+ timeout=self.timeout
144
+ )
145
+ response.raise_for_status()
146
+ result = AttestationResult(response.json())
147
+
148
+ if raise_on_block and result.blocked:
149
+ raise TrustProtocolError(
150
+ f"Action blocked: {result.block_reason}",
151
+ block_reason=result.block_reason,
152
+ risk_score=result.risk_score,
153
+ reasons=result.risk_reasons
154
+ )
155
+
156
+ return result
157
+
158
+ def ledger(self, agent_id: Optional[str] = None) -> dict:
159
+ """
160
+ Retrieve the audit ledger for your account.
161
+
162
+ Args:
163
+ agent_id: Filter by specific agent (optional)
164
+
165
+ Returns:
166
+ dict with 'entries' list and 'total' count
167
+ """
168
+ params = {}
169
+ if agent_id:
170
+ params["agent_id"] = agent_id
171
+ response = self._session.get(
172
+ f"{self.base_url}/ledger",
173
+ params=params,
174
+ timeout=self.timeout
175
+ )
176
+ response.raise_for_status()
177
+ return response.json()
178
+
179
+ def verify_chain(self) -> dict:
180
+ """
181
+ Verify the integrity of your attestation chain.
182
+
183
+ Returns:
184
+ dict with 'chain_valid' bool and 'chain_length' int
185
+ """
186
+ response = self._session.get(
187
+ f"{self.base_url}/verify-chain",
188
+ timeout=self.timeout
189
+ )
190
+ response.raise_for_status()
191
+ return response.json()
192
+
193
+ def approvals(self) -> dict:
194
+ """
195
+ List actions pending human approval.
196
+
197
+ Returns:
198
+ dict with 'approvals' list
199
+ """
200
+ response = self._session.get(
201
+ f"{self.base_url}/approvals",
202
+ timeout=self.timeout
203
+ )
204
+ response.raise_for_status()
205
+ return response.json()
206
+
207
+ def health(self) -> dict:
208
+ """Check API status."""
209
+ response = self._session.get(
210
+ f"{self.base_url}/health",
211
+ timeout=self.timeout
212
+ )
213
+ response.raise_for_status()
214
+ return response.json()
215
+
216
+ def __repr__(self):
217
+ return f"TrustProtocol(base_url={self.base_url!r})"
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: trustprotocol
3
+ Version: 1.0.0
4
+ Summary: Python SDK for TrustProtocol — AI agent governance and audit trail
5
+ Home-page: https://trustprotocol.tech
6
+ Author: TrustProtocol
7
+ Author-email: contact@trustprotocol.tech
8
+ Project-URL: Documentation, https://trustprotocol.tech/docs
9
+ Project-URL: Source, https://github.com/chada-hash/trustprotocol-python
10
+ Keywords: ai,governance,audit,agents,eu-ai-act,compliance
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.28.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # TrustProtocol Python SDK
37
+
38
+ Governance and cryptographic audit trail for AI agents.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install trustprotocol
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ ```python
49
+ from trustprotocol import TrustProtocol
50
+
51
+ tp = TrustProtocol("your-api-key")
52
+
53
+ result = tp.intercept(
54
+ agent_id="finance-agent-01",
55
+ action="Transfer 5000 EUR to supplier ACME",
56
+ cost_eur=5000.0,
57
+ user_id="marie@yourcompany.com"
58
+ )
59
+
60
+ if result.authorized:
61
+ print(f"✓ Authorized — Risk score: {result.risk_score}/100")
62
+ # Execute the action
63
+ else:
64
+ print(f"✗ Blocked — {result.block_reason}")
65
+ ```
66
+
67
+ ## Raise on block
68
+
69
+ ```python
70
+ from trustprotocol import TrustProtocol, TrustProtocolError
71
+
72
+ tp = TrustProtocol("your-api-key")
73
+
74
+ try:
75
+ result = tp.intercept(
76
+ agent_id="finance-agent-01",
77
+ action="Transfer 150000 EUR to new beneficiary",
78
+ cost_eur=150000.0,
79
+ user_id="marie@yourcompany.com",
80
+ raise_on_block=True
81
+ )
82
+ # Execute action
83
+ except TrustProtocolError as e:
84
+ print(f"Blocked: {e.block_reason}")
85
+ print(f"Risk score: {e.risk_score}/100")
86
+ print(f"Reasons: {e.reasons}")
87
+ ```
88
+
89
+ ## With LangChain
90
+
91
+ ```python
92
+ from trustprotocol import TrustProtocol
93
+ from langchain.tools import tool
94
+
95
+ tp = TrustProtocol("your-api-key")
96
+
97
+ @tool
98
+ def governed_payment(amount: float, recipient: str, user_id: str) -> str:
99
+ """Execute a payment with TrustProtocol governance."""
100
+ result = tp.intercept(
101
+ agent_id="payment-agent",
102
+ action=f"Transfer {amount} EUR to {recipient}",
103
+ cost_eur=amount,
104
+ user_id=user_id,
105
+ raise_on_block=True
106
+ )
107
+ return f"Payment authorized. Attestation: {result.attestation_id}"
108
+ ```
109
+
110
+ ## Audit & Verification
111
+
112
+ ```python
113
+ # Get audit ledger
114
+ ledger = tp.ledger(agent_id="finance-agent-01")
115
+ print(f"Total actions: {ledger['total']}")
116
+
117
+ # Verify chain integrity
118
+ verification = tp.verify_chain()
119
+ print(f"Chain valid: {verification['chain_valid']}")
120
+
121
+ # Pending approvals
122
+ approvals = tp.approvals()
123
+ print(f"Pending: {len(approvals.get('approvals', []))}")
124
+ ```
125
+
126
+ ## Links
127
+
128
+ - [Dashboard](https://trustprotocol.tech/dashboard)
129
+ - [Documentation](https://trustprotocol.tech/docs)
130
+ - [Trust Center](https://trustprotocol.tech/trust)
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ trustprotocol/__init__.py
4
+ trustprotocol/client.py
5
+ trustprotocol.egg-info/PKG-INFO
6
+ trustprotocol.egg-info/SOURCES.txt
7
+ trustprotocol.egg-info/dependency_links.txt
8
+ trustprotocol.egg-info/requires.txt
9
+ trustprotocol.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1 @@
1
+ trustprotocol