@agentauditai/mcp-server 0.0.0-stage → 3.0.0

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,365 @@
1
+ import type { BatchCommitter, CommitBatchParams, CommitBatchResult } from "./batch";
2
+ export * from "./batch";
3
+ export * from "./attribution";
4
+ export declare const NETWORKS: {
5
+ readonly mantle: {
6
+ readonly rpc: "https://rpc.mantle.xyz";
7
+ readonly chainId: 5000;
8
+ readonly auditVault: "0xD0086f19eDb500fB9d3382f6f5EAE1C015be054b";
9
+ readonly vaultVersion: 1;
10
+ readonly incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
11
+ readonly explorer: "https://explorer.mantle.xyz";
12
+ readonly name: "Mantle Mainnet";
13
+ };
14
+ readonly base: {
15
+ readonly rpc: "https://mainnet.base.org";
16
+ readonly chainId: 8453;
17
+ readonly auditVault: "0xCeE831070aa9081422f30df5559c125aa47A75DB";
18
+ readonly vaultVersion: 2;
19
+ readonly incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
20
+ readonly explorer: "https://basescan.org";
21
+ readonly name: "Base Mainnet";
22
+ };
23
+ readonly arbitrum: {
24
+ readonly rpc: "https://arb1.arbitrum.io/rpc";
25
+ readonly chainId: 42161;
26
+ readonly auditVault: "0x30579c6bFe4401A4b07062f0cc13C08FF2D9450C";
27
+ readonly vaultVersion: any;
28
+ readonly incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
29
+ readonly explorer: "https://arbiscan.io";
30
+ readonly name: "Arbitrum One";
31
+ };
32
+ readonly optimism: {
33
+ readonly rpc: "https://mainnet.optimism.io";
34
+ readonly chainId: 10;
35
+ readonly auditVault: "0x30579c6bFe4401A4b07062f0cc13C08FF2D9450C";
36
+ readonly vaultVersion: any;
37
+ readonly incidentRegistry: "0x976b03a2417cf7926813605F427ED499fdF61e10";
38
+ readonly explorer: "https://optimistic.etherscan.io";
39
+ readonly name: "Optimism Mainnet";
40
+ };
41
+ readonly polygon: {
42
+ readonly rpc: "https://polygon-bor-rpc.publicnode.com";
43
+ readonly chainId: 137;
44
+ readonly auditVault: "0x6fC00423Df95a7caf6fFFDD93169b5C01480de02";
45
+ readonly vaultVersion: any;
46
+ readonly incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
47
+ readonly explorer: "https://polygonscan.com";
48
+ readonly name: "Polygon Mainnet";
49
+ };
50
+ };
51
+ export type NetworkName = keyof typeof NETWORKS;
52
+ export type RiskLevel = "LOW" | "MEDIUM" | "HIGH";
53
+ export type ComplianceLevel = "minimal" | "limited" | "high";
54
+ export type IncidentSeverity = "LOW" | "MEDIUM" | "HIGH" | "CRITICAL";
55
+ /** Nature of harm — Art. 73§1 qualifying conditions (IncidentRegistry.HarmType) */
56
+ export type HarmType = "DEATH" | "SERIOUS_HEALTH_HARM" | "SIGNIFICANT_PROPERTY_DAMAGE" | "FUNDAMENTAL_RIGHTS_VIOLATION" | "OTHER";
57
+ export type IncidentStatus = "OPEN" | "REPORTED" | "UNDER_INVESTIGATION" | "RESOLVED" | "CLOSED";
58
+ export type MetricType = "ERROR_RATE" | "DRIFT_SCORE" | "LATENCY_MS" | "COMPLIANCE_SCORE" | "CUSTOM";
59
+ export interface AgentAuditConfig {
60
+ /** Agent wallet private key */
61
+ privateKey: string;
62
+ /** Target network (default: base) */
63
+ network?: NetworkName;
64
+ /** Override RPC URL */
65
+ rpcUrl?: string;
66
+ /** Override the AuditVault v2 address used by commitBatch / verifyLog */
67
+ auditVaultAddress?: string;
68
+ /** AgentRegistration contract address (Mantle primary registry) */
69
+ registrationAddress?: string;
70
+ /** Override the IncidentRegistry v2 address (Art. 73); defaults per network */
71
+ incidentRegistryAddress?: string;
72
+ /** PostMarketMonitor contract address (Art. 72) */
73
+ postMarketMonitorAddress?: string;
74
+ /**
75
+ * Base Builder Code (ERC-8021) appended to the calldata of this SDK's contract
76
+ * calls on Base / Base Sepolia only. Omitted: AgentAudit's code (`bc_pd681w25`).
77
+ * `false`: no suffix. A string: your own code. See README "Base Builder Code attribution".
78
+ */
79
+ builderCode?: string | false;
80
+ }
81
+ export interface LogActionParams {
82
+ agentId: number | string;
83
+ actionType: string;
84
+ payload: string | object;
85
+ riskLevel?: RiskLevel;
86
+ }
87
+ export interface LogActionResult {
88
+ txHash: string;
89
+ logIndex?: number;
90
+ network: NetworkName;
91
+ explorerUrl: string;
92
+ }
93
+ export interface RegisterAgentResult {
94
+ agentId: number;
95
+ txHash: string;
96
+ network: string;
97
+ }
98
+ export interface IncidentResult {
99
+ incidentId: number;
100
+ txHash: string;
101
+ withinDeadline?: boolean;
102
+ }
103
+ export interface ReportIncidentParams {
104
+ /** Numeric/string agent ID (hashed with keccak256) or a bytes32 hex string (used as-is) */
105
+ agentId: string | number;
106
+ severity: IncidentSeverity;
107
+ description: string;
108
+ /** Nature of harm (Art. 73§1); default "OTHER" */
109
+ harmType?: HarmType;
110
+ /** Number of persons affected (Art. 73§3); default 0 */
111
+ affectedPersons?: number | bigint;
112
+ /** Hash or IPFS CID of evidence; default keccak256(description) */
113
+ evidenceHash?: string;
114
+ /** Unix seconds, must not be in the future; default latest block timestamp */
115
+ occurredAt?: number;
116
+ }
117
+ /** IncidentRegistry v2 `incidents(id)` record */
118
+ export interface Incident {
119
+ id: number;
120
+ agentId: string;
121
+ severity: IncidentSeverity;
122
+ harmType: HarmType;
123
+ status: IncidentStatus;
124
+ description: string;
125
+ evidenceHash: string;
126
+ affectedPersons: bigint;
127
+ reportedBy: string;
128
+ occurredAt: number;
129
+ registeredAt: number;
130
+ reportedToAuthorityAt: number;
131
+ authorityAddress: string;
132
+ authorityRef: string;
133
+ withinDeadline: boolean;
134
+ rootCauseUri: string;
135
+ correctionUri: string;
136
+ }
137
+ export declare class AgentAudit implements BatchCommitter {
138
+ private provider;
139
+ private wallet;
140
+ private network;
141
+ private networkName;
142
+ private auditVault;
143
+ private _auditVaultV2?;
144
+ private _registration?;
145
+ private _incidentRegistry?;
146
+ private _postMarketMonitor?;
147
+ private config;
148
+ private builderCode;
149
+ constructor(config: AgentAuditConfig);
150
+ private get registration();
151
+ private get auditVaultV2();
152
+ /**
153
+ * The IncidentRegistry v2 contract, after checking once per instance that the
154
+ * address has code implementing the v2 functions. A mismatch is cached (it
155
+ * will not fix itself); an RPC failure is not, so the next call retries.
156
+ */
157
+ private incidentRegistry;
158
+ private verifyIncidentRegistry;
159
+ private get postMarketMonitor();
160
+ /** Every state-changing call goes through here (Builder Code suffix on Base only). */
161
+ private send;
162
+ private hashPayload;
163
+ private riskToUint;
164
+ private enumIndex;
165
+ /** bytes32 hex is used as-is; anything else is keccak256(String(agentId)) */
166
+ private incidentAgentId;
167
+ private metricTypeToUint;
168
+ private explorerTx;
169
+ /**
170
+ * Log a single agent action on-chain (Art. 12, 19, 50)
171
+ */
172
+ log(params: LogActionParams): Promise<LogActionResult>;
173
+ /**
174
+ * Alias for log() — the name the LLM wrappers call in per_action mode
175
+ */
176
+ logAction(params: LogActionParams): Promise<LogActionResult>;
177
+ /**
178
+ * Log multiple actions in one transaction (gas efficient)
179
+ */
180
+ logBatch(agentId: number | string, actions: Array<{
181
+ actionType: string;
182
+ payload: string | object;
183
+ riskLevel?: RiskLevel;
184
+ }>): Promise<LogActionResult>;
185
+ /**
186
+ * Get total on-chain log count for an agent
187
+ */
188
+ getLogCount(agentId: number | string): Promise<number>;
189
+ /**
190
+ * Anchor a Merkle root of action_refs (docs/EVIDENCE_SCHEMA.md) in one tx.
191
+ * Usually called by BatchBuffer rather than directly.
192
+ */
193
+ commitBatch(params: CommitBatchParams): Promise<CommitBatchResult>;
194
+ /**
195
+ * Throw a descriptive error if this network/config cannot batch-anchor.
196
+ * Wrappers call it at construction so batch mode fails fast instead of on
197
+ * the first flush.
198
+ */
199
+ assertBatchAnchoring(): void;
200
+ /**
201
+ * Check an inclusion proof against a committed batch (AuditVault v2 verifyLog)
202
+ */
203
+ verifyLog(agentAddress: string, batchIndex: number, leaf: string, proof: string[]): Promise<boolean>;
204
+ /**
205
+ * Register a new AI agent on-chain (KYA standard, Art. 13, 26)
206
+ */
207
+ registerAgent(params: {
208
+ name: string;
209
+ complianceLevel?: ComplianceLevel;
210
+ spendLimit?: bigint;
211
+ auditVault?: string;
212
+ }): Promise<RegisterAgentResult>;
213
+ /**
214
+ * Revoke an agent
215
+ */
216
+ revokeAgent(agentId: number): Promise<{
217
+ txHash: string;
218
+ }>;
219
+ /**
220
+ * Check if agent is active
221
+ */
222
+ isActive(agentId: number): Promise<boolean>;
223
+ /**
224
+ * Get all agent IDs for the current wallet
225
+ */
226
+ getMyAgents(): Promise<number[]>;
227
+ /**
228
+ * Register an incident on-chain (Art. 73)
229
+ * The registry enforces the 15/10/2 day reporting timelines (Art. 73§2)
230
+ */
231
+ reportIncident(params: ReportIncidentParams): Promise<IncidentResult>;
232
+ /**
233
+ * Mark an incident as reported to the national market surveillance authority
234
+ * (Art. 73§2). Only the original reporter or the registry deployer may call it.
235
+ * @param params.authority Address (or identifier) of the notified authority
236
+ * @param params.authorityRef Authority-issued case reference
237
+ */
238
+ markReportedToAuthority(incidentId: number, params: {
239
+ authority: string;
240
+ authorityRef: string;
241
+ }): Promise<{
242
+ txHash: string;
243
+ withinDeadline: boolean;
244
+ }>;
245
+ /**
246
+ * Read an incident record (IncidentRegistry v2 `incidents(id)`)
247
+ */
248
+ getIncident(incidentId: number): Promise<Incident>;
249
+ /**
250
+ * Incident IDs registered for an agent (same agentId rules as reportIncident)
251
+ */
252
+ getAgentIncidents(agentId: string | number): Promise<number[]>;
253
+ /**
254
+ * Whether an incident is still within its Art. 73§2 reporting deadline
255
+ */
256
+ isWithinDeadline(incidentId: number): Promise<boolean>;
257
+ /**
258
+ * Enroll an agent in post-market monitoring (Art. 72)
259
+ */
260
+ enrollMonitoring(params: {
261
+ agentAddress: string;
262
+ systemName: string;
263
+ riskCategory: string;
264
+ reviewIntervalDays: number;
265
+ }): Promise<{
266
+ txHash: string;
267
+ }>;
268
+ /**
269
+ * Record a performance metric (Art. 72)
270
+ */
271
+ recordMetric(params: {
272
+ agentAddress: string;
273
+ metricType: MetricType;
274
+ metricName: string;
275
+ value: number;
276
+ threshold: number;
277
+ context?: string;
278
+ txRef?: string;
279
+ }): Promise<{
280
+ txHash: string;
281
+ }>;
282
+ /**
283
+ * Record periodic compliance review (Art. 72)
284
+ * @param complianceScore 0-10000 (e.g. 9500 = 95.00%)
285
+ */
286
+ recordReview(params: {
287
+ agentAddress: string;
288
+ complianceScore: number;
289
+ notes: string;
290
+ }): Promise<{
291
+ txHash: string;
292
+ }>;
293
+ /**
294
+ * Check if agent is overdue for review
295
+ */
296
+ isReviewDue(agentAddress: string): Promise<{
297
+ due: boolean;
298
+ overdueBySeconds: number;
299
+ }>;
300
+ /**
301
+ * Get current network info
302
+ */
303
+ getNetworkInfo(): {
304
+ rpc: "https://rpc.mantle.xyz";
305
+ chainId: 5000;
306
+ auditVault: "0xD0086f19eDb500fB9d3382f6f5EAE1C015be054b";
307
+ vaultVersion: 1;
308
+ incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
309
+ explorer: "https://explorer.mantle.xyz";
310
+ name: "Mantle Mainnet";
311
+ } | {
312
+ rpc: "https://mainnet.base.org";
313
+ chainId: 8453;
314
+ auditVault: "0xCeE831070aa9081422f30df5559c125aa47A75DB";
315
+ vaultVersion: 2;
316
+ incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
317
+ explorer: "https://basescan.org";
318
+ name: "Base Mainnet";
319
+ } | {
320
+ rpc: "https://arb1.arbitrum.io/rpc";
321
+ chainId: 42161;
322
+ auditVault: "0x30579c6bFe4401A4b07062f0cc13C08FF2D9450C";
323
+ vaultVersion: any;
324
+ incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
325
+ explorer: "https://arbiscan.io";
326
+ name: "Arbitrum One";
327
+ } | {
328
+ rpc: "https://mainnet.optimism.io";
329
+ chainId: 10;
330
+ auditVault: "0x30579c6bFe4401A4b07062f0cc13C08FF2D9450C";
331
+ vaultVersion: any;
332
+ incidentRegistry: "0x976b03a2417cf7926813605F427ED499fdF61e10";
333
+ explorer: "https://optimistic.etherscan.io";
334
+ name: "Optimism Mainnet";
335
+ } | {
336
+ rpc: "https://polygon-bor-rpc.publicnode.com";
337
+ chainId: 137;
338
+ auditVault: "0x6fC00423Df95a7caf6fFFDD93169b5C01480de02";
339
+ vaultVersion: any;
340
+ incidentRegistry: "0x6ad45a9B32e695e95492dC3796a5aC8543B2EA6F";
341
+ explorer: "https://polygonscan.com";
342
+ name: "Polygon Mainnet";
343
+ };
344
+ /**
345
+ * Base Builder Code this instance appends on Base / Base Sepolia, or null when disabled
346
+ */
347
+ getBuilderCode(): string | null;
348
+ /**
349
+ * The exact calldata suffix this instance appends on the RPC's actual chain ("0x" = none)
350
+ */
351
+ getAttributionSuffix(): Promise<string>;
352
+ /**
353
+ * Get connected wallet address
354
+ */
355
+ getAddress(): string;
356
+ /**
357
+ * Hash any payload for on-chain storage
358
+ */
359
+ hash(payload: string | object): string;
360
+ }
361
+ /**
362
+ * Create AgentAudit from environment variables
363
+ */
364
+ export declare function createAgentAudit(network?: NetworkName): AgentAudit;
365
+ export default AgentAudit;