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