agentauditai-sdk 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.
- agentauditai_sdk-1.0.0/PKG-INFO +164 -0
- agentauditai_sdk-1.0.0/README.md +140 -0
- agentauditai_sdk-1.0.0/agentauditai/__init__.py +12 -0
- agentauditai_sdk-1.0.0/agentauditai/client.py +205 -0
- agentauditai_sdk-1.0.0/agentauditai/models.py +51 -0
- agentauditai_sdk-1.0.0/agentauditai_sdk.egg-info/PKG-INFO +164 -0
- agentauditai_sdk-1.0.0/agentauditai_sdk.egg-info/SOURCES.txt +11 -0
- agentauditai_sdk-1.0.0/agentauditai_sdk.egg-info/dependency_links.txt +1 -0
- agentauditai_sdk-1.0.0/agentauditai_sdk.egg-info/requires.txt +1 -0
- agentauditai_sdk-1.0.0/agentauditai_sdk.egg-info/top_level.txt +1 -0
- agentauditai_sdk-1.0.0/pyproject.toml +35 -0
- agentauditai_sdk-1.0.0/setup.cfg +4 -0
- agentauditai_sdk-1.0.0/setup.py +3 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentauditai-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: On-chain EU AI Act compliance SDK for AI agents — immutable audit logs, KYA registration, incident reporting, post-market monitoring.
|
|
5
|
+
Author: agentauditAI
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://getagentaudit.xyz
|
|
8
|
+
Project-URL: Repository, https://github.com/agentauditAI/AgentAudit
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/agentauditAI/AgentAudit/issues
|
|
10
|
+
Project-URL: npm package, https://www.npmjs.com/package/@agentauditai/sdk
|
|
11
|
+
Keywords: eu-ai-act,compliance,blockchain,audit,ai-agents,mantle,arbitrum,base,optimism,polygon
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: requests>=2.28.0
|
|
24
|
+
|
|
25
|
+
# agentauditai-sdk
|
|
26
|
+
|
|
27
|
+
On-chain EU AI Act compliance for AI agents — immutable audit logs, Know Your Agent (KYA) registration, incident reporting, and post-market monitoring across 5 EVM networks.
|
|
28
|
+
|
|
29
|
+
**Enforcement deadline: August 2, 2026.**
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/agentauditai-sdk/)
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
[](https://pypi.org/project/agentauditai-sdk/)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install agentauditai-sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
### 1. Register an AI agent (Art. 13, 26 — KYA standard)
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from agentauditai import AgentAuditClient
|
|
51
|
+
|
|
52
|
+
client = AgentAuditClient(
|
|
53
|
+
api_key="your-api-key",
|
|
54
|
+
base_url="https://your-agentaudit-api",
|
|
55
|
+
network="base",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
registration = client.register_agent(
|
|
59
|
+
agent_id="42",
|
|
60
|
+
name="customer-support-agent",
|
|
61
|
+
model="claude-sonnet-4-6",
|
|
62
|
+
network="base",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
print(f"Registered: tx={registration.tx_hash}")
|
|
66
|
+
print(f"Articles covered: {registration.articles}")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Audit an agent action (Art. 12, 19 — record-keeping)
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from agentauditai import AgentAuditClient
|
|
73
|
+
|
|
74
|
+
client = AgentAuditClient(api_key="your-api-key", network="arbitrum")
|
|
75
|
+
|
|
76
|
+
result = client.audit_action(
|
|
77
|
+
agent_id="42",
|
|
78
|
+
action="LLM_DECISION",
|
|
79
|
+
data={
|
|
80
|
+
"prompt": "Summarise the customer complaint",
|
|
81
|
+
"response": "Refund approved for order #8821",
|
|
82
|
+
"model": "claude-sonnet-4-6",
|
|
83
|
+
},
|
|
84
|
+
risk_level="HIGH",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
print(f"Logged on-chain: {result.tx_hash}")
|
|
88
|
+
print(f"Audit ID: {result.audit_id}")
|
|
89
|
+
print(f"Articles triggered: {result.articles}")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. Get compliance report (Art. 72 — post-market monitoring)
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from agentauditai import AgentAuditClient
|
|
96
|
+
|
|
97
|
+
client = AgentAuditClient(api_key="your-api-key", network="base")
|
|
98
|
+
|
|
99
|
+
# Risk score
|
|
100
|
+
risk = client.get_risk_score(agent_id="42")
|
|
101
|
+
print(f"Risk level: {risk.level} score: {risk.score}")
|
|
102
|
+
print(f"Status: {risk.compliance_status}")
|
|
103
|
+
|
|
104
|
+
# Full compliance report
|
|
105
|
+
report = client.get_compliance_report(agent_id="42")
|
|
106
|
+
print(f"Agent: {report.agent_name}")
|
|
107
|
+
print(f"Total actions logged: {report.total_actions_logged}")
|
|
108
|
+
print(f"Applicable articles: {report.applicable_articles}")
|
|
109
|
+
print(f"Compliance status: {report.compliance_status}")
|
|
110
|
+
for obligation in report.obligations:
|
|
111
|
+
status = "PASS" if obligation["met"] else "FAIL"
|
|
112
|
+
print(f" [{status}] {obligation['article']} — {obligation['obligation']}")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## EU AI Act Coverage
|
|
118
|
+
|
|
119
|
+
| Article | Obligation | Method |
|
|
120
|
+
|---------|-----------|--------|
|
|
121
|
+
| Art. 9 | Risk management system | `get_risk_score()` |
|
|
122
|
+
| Art. 11 | Technical documentation | `register_agent()` |
|
|
123
|
+
| Art. 12 | Record-keeping & audit logs | `audit_action()` |
|
|
124
|
+
| Art. 13 | Transparency to users | `register_agent()` |
|
|
125
|
+
| Art. 14 | Human oversight | `audit_action()` with action tagging |
|
|
126
|
+
| Art. 19 | Conformity assessment logging | `audit_action()` |
|
|
127
|
+
| Art. 26 | Deployer obligations (KYA) | `register_agent()` |
|
|
128
|
+
| Art. 72 | Post-market monitoring | `get_compliance_report()` |
|
|
129
|
+
| Art. 73 | Serious incident reporting | `audit_action(action="REPORT_INCIDENT")` |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Supported Networks
|
|
134
|
+
|
|
135
|
+
| Network | Chain ID |
|
|
136
|
+
|---------|----------|
|
|
137
|
+
| Base Mainnet | 8453 |
|
|
138
|
+
| Arbitrum One | 42161 |
|
|
139
|
+
| Optimism Mainnet | 10 |
|
|
140
|
+
| Polygon Mainnet | 137 |
|
|
141
|
+
| Mantle Mainnet | 5000 |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Configuration
|
|
146
|
+
|
|
147
|
+
| Parameter | Environment Variable | Default |
|
|
148
|
+
|-----------|---------------------|---------|
|
|
149
|
+
| `api_key` | `AGENTAUDIT_API_KEY` | — |
|
|
150
|
+
| `base_url` | — | `http://localhost:3000` |
|
|
151
|
+
| `network` | — | `base` |
|
|
152
|
+
| `timeout` | — | `30` |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Links
|
|
157
|
+
|
|
158
|
+
- Website: [getagentaudit.xyz](https://getagentaudit.xyz)
|
|
159
|
+
- PyPI: [pypi.org/project/agentauditai-sdk](https://pypi.org/project/agentauditai-sdk/)
|
|
160
|
+
- npm: [npmjs.com/package/@agentauditai/sdk](https://www.npmjs.com/package/@agentauditai/sdk)
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
AgentAudit AI — a [RunLockAI](https://getagentaudit.xyz) product
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# agentauditai-sdk
|
|
2
|
+
|
|
3
|
+
On-chain EU AI Act compliance for AI agents — immutable audit logs, Know Your Agent (KYA) registration, incident reporting, and post-market monitoring across 5 EVM networks.
|
|
4
|
+
|
|
5
|
+
**Enforcement deadline: August 2, 2026.**
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/agentauditai-sdk/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://pypi.org/project/agentauditai-sdk/)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install agentauditai-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### 1. Register an AI agent (Art. 13, 26 — KYA standard)
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from agentauditai import AgentAuditClient
|
|
27
|
+
|
|
28
|
+
client = AgentAuditClient(
|
|
29
|
+
api_key="your-api-key",
|
|
30
|
+
base_url="https://your-agentaudit-api",
|
|
31
|
+
network="base",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
registration = client.register_agent(
|
|
35
|
+
agent_id="42",
|
|
36
|
+
name="customer-support-agent",
|
|
37
|
+
model="claude-sonnet-4-6",
|
|
38
|
+
network="base",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
print(f"Registered: tx={registration.tx_hash}")
|
|
42
|
+
print(f"Articles covered: {registration.articles}")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Audit an agent action (Art. 12, 19 — record-keeping)
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from agentauditai import AgentAuditClient
|
|
49
|
+
|
|
50
|
+
client = AgentAuditClient(api_key="your-api-key", network="arbitrum")
|
|
51
|
+
|
|
52
|
+
result = client.audit_action(
|
|
53
|
+
agent_id="42",
|
|
54
|
+
action="LLM_DECISION",
|
|
55
|
+
data={
|
|
56
|
+
"prompt": "Summarise the customer complaint",
|
|
57
|
+
"response": "Refund approved for order #8821",
|
|
58
|
+
"model": "claude-sonnet-4-6",
|
|
59
|
+
},
|
|
60
|
+
risk_level="HIGH",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
print(f"Logged on-chain: {result.tx_hash}")
|
|
64
|
+
print(f"Audit ID: {result.audit_id}")
|
|
65
|
+
print(f"Articles triggered: {result.articles}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 3. Get compliance report (Art. 72 — post-market monitoring)
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from agentauditai import AgentAuditClient
|
|
72
|
+
|
|
73
|
+
client = AgentAuditClient(api_key="your-api-key", network="base")
|
|
74
|
+
|
|
75
|
+
# Risk score
|
|
76
|
+
risk = client.get_risk_score(agent_id="42")
|
|
77
|
+
print(f"Risk level: {risk.level} score: {risk.score}")
|
|
78
|
+
print(f"Status: {risk.compliance_status}")
|
|
79
|
+
|
|
80
|
+
# Full compliance report
|
|
81
|
+
report = client.get_compliance_report(agent_id="42")
|
|
82
|
+
print(f"Agent: {report.agent_name}")
|
|
83
|
+
print(f"Total actions logged: {report.total_actions_logged}")
|
|
84
|
+
print(f"Applicable articles: {report.applicable_articles}")
|
|
85
|
+
print(f"Compliance status: {report.compliance_status}")
|
|
86
|
+
for obligation in report.obligations:
|
|
87
|
+
status = "PASS" if obligation["met"] else "FAIL"
|
|
88
|
+
print(f" [{status}] {obligation['article']} — {obligation['obligation']}")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## EU AI Act Coverage
|
|
94
|
+
|
|
95
|
+
| Article | Obligation | Method |
|
|
96
|
+
|---------|-----------|--------|
|
|
97
|
+
| Art. 9 | Risk management system | `get_risk_score()` |
|
|
98
|
+
| Art. 11 | Technical documentation | `register_agent()` |
|
|
99
|
+
| Art. 12 | Record-keeping & audit logs | `audit_action()` |
|
|
100
|
+
| Art. 13 | Transparency to users | `register_agent()` |
|
|
101
|
+
| Art. 14 | Human oversight | `audit_action()` with action tagging |
|
|
102
|
+
| Art. 19 | Conformity assessment logging | `audit_action()` |
|
|
103
|
+
| Art. 26 | Deployer obligations (KYA) | `register_agent()` |
|
|
104
|
+
| Art. 72 | Post-market monitoring | `get_compliance_report()` |
|
|
105
|
+
| Art. 73 | Serious incident reporting | `audit_action(action="REPORT_INCIDENT")` |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Supported Networks
|
|
110
|
+
|
|
111
|
+
| Network | Chain ID |
|
|
112
|
+
|---------|----------|
|
|
113
|
+
| Base Mainnet | 8453 |
|
|
114
|
+
| Arbitrum One | 42161 |
|
|
115
|
+
| Optimism Mainnet | 10 |
|
|
116
|
+
| Polygon Mainnet | 137 |
|
|
117
|
+
| Mantle Mainnet | 5000 |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Configuration
|
|
122
|
+
|
|
123
|
+
| Parameter | Environment Variable | Default |
|
|
124
|
+
|-----------|---------------------|---------|
|
|
125
|
+
| `api_key` | `AGENTAUDIT_API_KEY` | — |
|
|
126
|
+
| `base_url` | — | `http://localhost:3000` |
|
|
127
|
+
| `network` | — | `base` |
|
|
128
|
+
| `timeout` | — | `30` |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Links
|
|
133
|
+
|
|
134
|
+
- Website: [getagentaudit.xyz](https://getagentaudit.xyz)
|
|
135
|
+
- PyPI: [pypi.org/project/agentauditai-sdk](https://pypi.org/project/agentauditai-sdk/)
|
|
136
|
+
- npm: [npmjs.com/package/@agentauditai/sdk](https://www.npmjs.com/package/@agentauditai/sdk)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
AgentAudit AI — a [RunLockAI](https://getagentaudit.xyz) product
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .client import AgentAuditClient, AgentAuditError
|
|
2
|
+
from .models import AgentRegistration, AuditAction, ComplianceReport, RiskScore
|
|
3
|
+
|
|
4
|
+
__version__ = "1.0.0"
|
|
5
|
+
__all__ = [
|
|
6
|
+
"AgentAuditClient",
|
|
7
|
+
"AgentAuditError",
|
|
8
|
+
"AgentRegistration",
|
|
9
|
+
"AuditAction",
|
|
10
|
+
"ComplianceReport",
|
|
11
|
+
"RiskScore",
|
|
12
|
+
]
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
from typing import Any, Dict, Literal, Optional
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from .models import AgentRegistration, AuditAction, ComplianceReport, RiskScore
|
|
9
|
+
|
|
10
|
+
Network = Literal["mantle", "base", "arbitrum", "optimism", "polygon"]
|
|
11
|
+
RiskLevel = Literal["HIGH", "MEDIUM", "LOW"]
|
|
12
|
+
|
|
13
|
+
NETWORKS = {
|
|
14
|
+
"mantle": {"chain_id": 5000, "explorer": "https://explorer.mantle.xyz"},
|
|
15
|
+
"base": {"chain_id": 8453, "explorer": "https://basescan.org"},
|
|
16
|
+
"arbitrum": {"chain_id": 42161, "explorer": "https://arbiscan.io"},
|
|
17
|
+
"optimism": {"chain_id": 10, "explorer": "https://optimistic.etherscan.io"},
|
|
18
|
+
"polygon": {"chain_id": 137, "explorer": "https://polygonscan.com"},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AgentAuditError(Exception):
|
|
23
|
+
"""Raised when the AgentAudit API returns an error."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AgentAuditClient:
|
|
27
|
+
"""
|
|
28
|
+
Python client for the AgentAudit REST API.
|
|
29
|
+
|
|
30
|
+
Provides EU AI Act compliance for AI agents: immutable on-chain audit logs,
|
|
31
|
+
Know Your Agent (KYA) registration, risk scoring, and compliance reporting
|
|
32
|
+
across Mantle, Base, Arbitrum, Optimism, and Polygon.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
api_key: Bearer token for the AgentAudit API. Falls back to
|
|
36
|
+
AGENTAUDIT_API_KEY environment variable.
|
|
37
|
+
base_url: Base URL of the AgentAudit API gateway (default: localhost:3000).
|
|
38
|
+
network: Default network for all operations.
|
|
39
|
+
timeout: HTTP request timeout in seconds.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def __init__(
|
|
43
|
+
self,
|
|
44
|
+
api_key: Optional[str] = None,
|
|
45
|
+
base_url: str = "http://localhost:3000",
|
|
46
|
+
network: Network = "base",
|
|
47
|
+
timeout: int = 30,
|
|
48
|
+
) -> None:
|
|
49
|
+
self._api_key = api_key or os.environ.get("AGENTAUDIT_API_KEY", "")
|
|
50
|
+
self._base_url = base_url.rstrip("/")
|
|
51
|
+
self._network = network
|
|
52
|
+
self._timeout = timeout
|
|
53
|
+
self._session = requests.Session()
|
|
54
|
+
self._session.headers.update({
|
|
55
|
+
"Authorization": f"Bearer {self._api_key}",
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
# ─── Internal ───
|
|
60
|
+
|
|
61
|
+
def _post(self, path: str, body: dict) -> dict:
|
|
62
|
+
resp = self._session.post(
|
|
63
|
+
f"{self._base_url}{path}", json=body, timeout=self._timeout
|
|
64
|
+
)
|
|
65
|
+
if not resp.ok:
|
|
66
|
+
raise AgentAuditError(f"API error {resp.status_code}: {resp.text}")
|
|
67
|
+
return resp.json()
|
|
68
|
+
|
|
69
|
+
def _get(self, path: str, params: Optional[dict] = None) -> dict:
|
|
70
|
+
resp = self._session.get(
|
|
71
|
+
f"{self._base_url}{path}", params=params, timeout=self._timeout
|
|
72
|
+
)
|
|
73
|
+
if not resp.ok:
|
|
74
|
+
raise AgentAuditError(f"API error {resp.status_code}: {resp.text}")
|
|
75
|
+
return resp.json()
|
|
76
|
+
|
|
77
|
+
# ─── Public API ───
|
|
78
|
+
|
|
79
|
+
@staticmethod
|
|
80
|
+
def hash_payload(data: Any) -> str:
|
|
81
|
+
"""SHA-256 hash of a payload. Raw content never leaves your system."""
|
|
82
|
+
raw = json.dumps(data, sort_keys=True) if not isinstance(data, str) else data
|
|
83
|
+
return "sha256:" + hashlib.sha256(raw.encode()).hexdigest()
|
|
84
|
+
|
|
85
|
+
def register_agent(
|
|
86
|
+
self,
|
|
87
|
+
agent_id: str,
|
|
88
|
+
name: str,
|
|
89
|
+
model: str,
|
|
90
|
+
network: Optional[Network] = None,
|
|
91
|
+
risk_level: RiskLevel = "HIGH",
|
|
92
|
+
) -> AgentRegistration:
|
|
93
|
+
"""
|
|
94
|
+
Register an AI agent on-chain (Art. 13, 26 — KYA standard).
|
|
95
|
+
|
|
96
|
+
Writes an immutable REGISTER_AGENT record to the audit vault,
|
|
97
|
+
establishing the agent's identity and model on the selected network.
|
|
98
|
+
"""
|
|
99
|
+
net = network or self._network
|
|
100
|
+
resp = self._post("/v1/audit", {
|
|
101
|
+
"agent_id": str(agent_id),
|
|
102
|
+
"action": "REGISTER_AGENT",
|
|
103
|
+
"decision": f"Agent '{name}' registered with model '{model}'",
|
|
104
|
+
"risk_level": risk_level,
|
|
105
|
+
"network": net,
|
|
106
|
+
"metadata": {"name": name, "model": model},
|
|
107
|
+
})
|
|
108
|
+
return AgentRegistration(
|
|
109
|
+
agent_id=str(agent_id),
|
|
110
|
+
name=name,
|
|
111
|
+
model=model,
|
|
112
|
+
network=net,
|
|
113
|
+
audit_id=resp.get("audit_id"),
|
|
114
|
+
tx_hash=resp.get("tx_hash"),
|
|
115
|
+
registered_at=resp.get("timestamp"),
|
|
116
|
+
articles=resp.get("articles", []),
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def audit_action(
|
|
120
|
+
self,
|
|
121
|
+
agent_id: str,
|
|
122
|
+
action: str,
|
|
123
|
+
data: Dict[str, Any],
|
|
124
|
+
risk_level: RiskLevel = "HIGH",
|
|
125
|
+
network: Optional[Network] = None,
|
|
126
|
+
) -> AuditAction:
|
|
127
|
+
"""
|
|
128
|
+
Log an agent action on-chain (Art. 12, 19 — record-keeping).
|
|
129
|
+
|
|
130
|
+
The raw payload is hashed client-side; only the SHA-256 digest is
|
|
131
|
+
stored on-chain so sensitive data never touches the chain.
|
|
132
|
+
"""
|
|
133
|
+
net = network or self._network
|
|
134
|
+
resp = self._post("/v1/audit", {
|
|
135
|
+
"agent_id": str(agent_id),
|
|
136
|
+
"action": action,
|
|
137
|
+
"decision": self.hash_payload(data),
|
|
138
|
+
"risk_level": risk_level,
|
|
139
|
+
"network": net,
|
|
140
|
+
"metadata": data,
|
|
141
|
+
})
|
|
142
|
+
return AuditAction(
|
|
143
|
+
audit_id=resp["audit_id"],
|
|
144
|
+
agent_id=str(agent_id),
|
|
145
|
+
action=action,
|
|
146
|
+
tx_hash=resp["tx_hash"],
|
|
147
|
+
network=net,
|
|
148
|
+
articles=resp.get("articles", []),
|
|
149
|
+
timestamp=resp["timestamp"],
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def get_risk_score(
|
|
153
|
+
self,
|
|
154
|
+
agent_id: str,
|
|
155
|
+
network: Optional[Network] = None,
|
|
156
|
+
) -> RiskScore:
|
|
157
|
+
"""
|
|
158
|
+
Return the current risk score for an agent (Art. 9 — risk management).
|
|
159
|
+
|
|
160
|
+
Score is derived from the agent's on-chain compliance level:
|
|
161
|
+
high → 1.0, limited → 0.5, minimal → 0.2.
|
|
162
|
+
"""
|
|
163
|
+
net = network or self._network
|
|
164
|
+
data = self._get(f"/v1/audit/{agent_id}/report", {"network": net})
|
|
165
|
+
compliance_level = data["agent"]["compliance_level"].upper()
|
|
166
|
+
score_map = {"HIGH": 1.0, "LIMITED": 0.5, "MINIMAL": 0.2}
|
|
167
|
+
return RiskScore(
|
|
168
|
+
agent_id=str(agent_id),
|
|
169
|
+
network=net,
|
|
170
|
+
level=compliance_level,
|
|
171
|
+
score=score_map.get(compliance_level, 0.5),
|
|
172
|
+
articles=data["eu_ai_act_compliance"]["applicable_articles"],
|
|
173
|
+
compliance_status=data["eu_ai_act_compliance"]["compliance_status"],
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
def get_compliance_report(
|
|
177
|
+
self,
|
|
178
|
+
agent_id: str,
|
|
179
|
+
network: Optional[Network] = None,
|
|
180
|
+
) -> ComplianceReport:
|
|
181
|
+
"""
|
|
182
|
+
Generate a full EU AI Act compliance report for an agent (Art. 72).
|
|
183
|
+
|
|
184
|
+
Pulls on-chain registration data and the full audit trail to produce
|
|
185
|
+
a structured report covering all applicable articles.
|
|
186
|
+
"""
|
|
187
|
+
net = network or self._network
|
|
188
|
+
data = self._get(f"/v1/audit/{agent_id}/report", {"network": net})
|
|
189
|
+
agent = data["agent"]
|
|
190
|
+
summary = data["audit_summary"]
|
|
191
|
+
compliance = data["eu_ai_act_compliance"]
|
|
192
|
+
return ComplianceReport(
|
|
193
|
+
agent_id=str(agent_id),
|
|
194
|
+
network=net,
|
|
195
|
+
generated_at=data["generated_at"],
|
|
196
|
+
agent_name=agent["name"],
|
|
197
|
+
compliance_level=agent["compliance_level"],
|
|
198
|
+
active=agent["active"],
|
|
199
|
+
total_actions_logged=summary["total_actions_logged"],
|
|
200
|
+
first_action=summary.get("first_action"),
|
|
201
|
+
last_action=summary.get("last_action"),
|
|
202
|
+
applicable_articles=compliance["applicable_articles"],
|
|
203
|
+
compliance_status=compliance["compliance_status"],
|
|
204
|
+
obligations=compliance.get("obligations", []),
|
|
205
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import Any, Dict, List, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class AgentRegistration:
|
|
7
|
+
agent_id: str
|
|
8
|
+
name: str
|
|
9
|
+
model: str
|
|
10
|
+
network: str
|
|
11
|
+
audit_id: Optional[str] = None
|
|
12
|
+
tx_hash: Optional[str] = None
|
|
13
|
+
registered_at: Optional[str] = None
|
|
14
|
+
articles: List[str] = field(default_factory=list)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class AuditAction:
|
|
19
|
+
audit_id: str
|
|
20
|
+
agent_id: str
|
|
21
|
+
action: str
|
|
22
|
+
tx_hash: str
|
|
23
|
+
network: str
|
|
24
|
+
articles: List[str]
|
|
25
|
+
timestamp: str
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class RiskScore:
|
|
30
|
+
agent_id: str
|
|
31
|
+
network: str
|
|
32
|
+
level: str
|
|
33
|
+
score: float
|
|
34
|
+
articles: List[str]
|
|
35
|
+
compliance_status: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass
|
|
39
|
+
class ComplianceReport:
|
|
40
|
+
agent_id: str
|
|
41
|
+
network: str
|
|
42
|
+
generated_at: str
|
|
43
|
+
agent_name: str
|
|
44
|
+
compliance_level: str
|
|
45
|
+
active: bool
|
|
46
|
+
total_actions_logged: int
|
|
47
|
+
first_action: Optional[str]
|
|
48
|
+
last_action: Optional[str]
|
|
49
|
+
applicable_articles: List[str]
|
|
50
|
+
compliance_status: str
|
|
51
|
+
obligations: List[Dict[str, Any]]
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentauditai-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: On-chain EU AI Act compliance SDK for AI agents — immutable audit logs, KYA registration, incident reporting, post-market monitoring.
|
|
5
|
+
Author: agentauditAI
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://getagentaudit.xyz
|
|
8
|
+
Project-URL: Repository, https://github.com/agentauditAI/AgentAudit
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/agentauditAI/AgentAudit/issues
|
|
10
|
+
Project-URL: npm package, https://www.npmjs.com/package/@agentauditai/sdk
|
|
11
|
+
Keywords: eu-ai-act,compliance,blockchain,audit,ai-agents,mantle,arbitrum,base,optimism,polygon
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: requests>=2.28.0
|
|
24
|
+
|
|
25
|
+
# agentauditai-sdk
|
|
26
|
+
|
|
27
|
+
On-chain EU AI Act compliance for AI agents — immutable audit logs, Know Your Agent (KYA) registration, incident reporting, and post-market monitoring across 5 EVM networks.
|
|
28
|
+
|
|
29
|
+
**Enforcement deadline: August 2, 2026.**
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/agentauditai-sdk/)
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
[](https://pypi.org/project/agentauditai-sdk/)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install agentauditai-sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
### 1. Register an AI agent (Art. 13, 26 — KYA standard)
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from agentauditai import AgentAuditClient
|
|
51
|
+
|
|
52
|
+
client = AgentAuditClient(
|
|
53
|
+
api_key="your-api-key",
|
|
54
|
+
base_url="https://your-agentaudit-api",
|
|
55
|
+
network="base",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
registration = client.register_agent(
|
|
59
|
+
agent_id="42",
|
|
60
|
+
name="customer-support-agent",
|
|
61
|
+
model="claude-sonnet-4-6",
|
|
62
|
+
network="base",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
print(f"Registered: tx={registration.tx_hash}")
|
|
66
|
+
print(f"Articles covered: {registration.articles}")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Audit an agent action (Art. 12, 19 — record-keeping)
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from agentauditai import AgentAuditClient
|
|
73
|
+
|
|
74
|
+
client = AgentAuditClient(api_key="your-api-key", network="arbitrum")
|
|
75
|
+
|
|
76
|
+
result = client.audit_action(
|
|
77
|
+
agent_id="42",
|
|
78
|
+
action="LLM_DECISION",
|
|
79
|
+
data={
|
|
80
|
+
"prompt": "Summarise the customer complaint",
|
|
81
|
+
"response": "Refund approved for order #8821",
|
|
82
|
+
"model": "claude-sonnet-4-6",
|
|
83
|
+
},
|
|
84
|
+
risk_level="HIGH",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
print(f"Logged on-chain: {result.tx_hash}")
|
|
88
|
+
print(f"Audit ID: {result.audit_id}")
|
|
89
|
+
print(f"Articles triggered: {result.articles}")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. Get compliance report (Art. 72 — post-market monitoring)
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from agentauditai import AgentAuditClient
|
|
96
|
+
|
|
97
|
+
client = AgentAuditClient(api_key="your-api-key", network="base")
|
|
98
|
+
|
|
99
|
+
# Risk score
|
|
100
|
+
risk = client.get_risk_score(agent_id="42")
|
|
101
|
+
print(f"Risk level: {risk.level} score: {risk.score}")
|
|
102
|
+
print(f"Status: {risk.compliance_status}")
|
|
103
|
+
|
|
104
|
+
# Full compliance report
|
|
105
|
+
report = client.get_compliance_report(agent_id="42")
|
|
106
|
+
print(f"Agent: {report.agent_name}")
|
|
107
|
+
print(f"Total actions logged: {report.total_actions_logged}")
|
|
108
|
+
print(f"Applicable articles: {report.applicable_articles}")
|
|
109
|
+
print(f"Compliance status: {report.compliance_status}")
|
|
110
|
+
for obligation in report.obligations:
|
|
111
|
+
status = "PASS" if obligation["met"] else "FAIL"
|
|
112
|
+
print(f" [{status}] {obligation['article']} — {obligation['obligation']}")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## EU AI Act Coverage
|
|
118
|
+
|
|
119
|
+
| Article | Obligation | Method |
|
|
120
|
+
|---------|-----------|--------|
|
|
121
|
+
| Art. 9 | Risk management system | `get_risk_score()` |
|
|
122
|
+
| Art. 11 | Technical documentation | `register_agent()` |
|
|
123
|
+
| Art. 12 | Record-keeping & audit logs | `audit_action()` |
|
|
124
|
+
| Art. 13 | Transparency to users | `register_agent()` |
|
|
125
|
+
| Art. 14 | Human oversight | `audit_action()` with action tagging |
|
|
126
|
+
| Art. 19 | Conformity assessment logging | `audit_action()` |
|
|
127
|
+
| Art. 26 | Deployer obligations (KYA) | `register_agent()` |
|
|
128
|
+
| Art. 72 | Post-market monitoring | `get_compliance_report()` |
|
|
129
|
+
| Art. 73 | Serious incident reporting | `audit_action(action="REPORT_INCIDENT")` |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Supported Networks
|
|
134
|
+
|
|
135
|
+
| Network | Chain ID |
|
|
136
|
+
|---------|----------|
|
|
137
|
+
| Base Mainnet | 8453 |
|
|
138
|
+
| Arbitrum One | 42161 |
|
|
139
|
+
| Optimism Mainnet | 10 |
|
|
140
|
+
| Polygon Mainnet | 137 |
|
|
141
|
+
| Mantle Mainnet | 5000 |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Configuration
|
|
146
|
+
|
|
147
|
+
| Parameter | Environment Variable | Default |
|
|
148
|
+
|-----------|---------------------|---------|
|
|
149
|
+
| `api_key` | `AGENTAUDIT_API_KEY` | — |
|
|
150
|
+
| `base_url` | — | `http://localhost:3000` |
|
|
151
|
+
| `network` | — | `base` |
|
|
152
|
+
| `timeout` | — | `30` |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Links
|
|
157
|
+
|
|
158
|
+
- Website: [getagentaudit.xyz](https://getagentaudit.xyz)
|
|
159
|
+
- PyPI: [pypi.org/project/agentauditai-sdk](https://pypi.org/project/agentauditai-sdk/)
|
|
160
|
+
- npm: [npmjs.com/package/@agentauditai/sdk](https://www.npmjs.com/package/@agentauditai/sdk)
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
AgentAudit AI — a [RunLockAI](https://getagentaudit.xyz) product
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
agentauditai/__init__.py
|
|
5
|
+
agentauditai/client.py
|
|
6
|
+
agentauditai/models.py
|
|
7
|
+
agentauditai_sdk.egg-info/PKG-INFO
|
|
8
|
+
agentauditai_sdk.egg-info/SOURCES.txt
|
|
9
|
+
agentauditai_sdk.egg-info/dependency_links.txt
|
|
10
|
+
agentauditai_sdk.egg-info/requires.txt
|
|
11
|
+
agentauditai_sdk.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.28.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agentauditai
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agentauditai-sdk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "On-chain EU AI Act compliance SDK for AI agents — immutable audit logs, KYA registration, incident reporting, post-market monitoring."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [{name = "agentauditAI"}]
|
|
12
|
+
keywords = [
|
|
13
|
+
"eu-ai-act", "compliance", "blockchain", "audit",
|
|
14
|
+
"ai-agents", "mantle", "arbitrum", "base", "optimism", "polygon",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Topic :: Security",
|
|
27
|
+
]
|
|
28
|
+
requires-python = ">=3.9"
|
|
29
|
+
dependencies = ["requests>=2.28.0"]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://getagentaudit.xyz"
|
|
33
|
+
Repository = "https://github.com/agentauditAI/AgentAudit"
|
|
34
|
+
"Bug Tracker" = "https://github.com/agentauditAI/AgentAudit/issues"
|
|
35
|
+
"npm package" = "https://www.npmjs.com/package/@agentauditai/sdk"
|