@t402/erc8004 2.7.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.
- package/dist/cjs/index.cjs +704 -0
- package/dist/cjs/index.d.ts +978 -0
- package/dist/esm/index.d.mts +978 -0
- package/dist/esm/index.mjs +647 -0
- package/package.json +73 -0
|
@@ -0,0 +1,978 @@
|
|
|
1
|
+
import { Network, ResourceServerExtension, PaymentRequired, A2ATask } from '@t402/core/types';
|
|
2
|
+
import { BeforePaymentCreationHook } from '@t402/core/client';
|
|
3
|
+
import { BeforeVerifyHook, AfterSettleHook } from '@t402/core/server';
|
|
4
|
+
|
|
5
|
+
/** Ethereum address (0x-prefixed hex string) */
|
|
6
|
+
type Address = `0x${string}`;
|
|
7
|
+
/** Hex-encoded bytes (0x-prefixed) */
|
|
8
|
+
type Hex = `0x${string}`;
|
|
9
|
+
/** 32-byte hash (0x-prefixed, 66 chars) */
|
|
10
|
+
type Bytes32 = `0x${string}`;
|
|
11
|
+
/** ERC-8004 agent registry identifier: {namespace}:{chainId}:{contractAddress} */
|
|
12
|
+
type AgentRegistryId = `${string}:${string}:${string}`;
|
|
13
|
+
/** Parsed agent registry identifier */
|
|
14
|
+
interface AgentRegistry {
|
|
15
|
+
namespace: string;
|
|
16
|
+
chainId: string;
|
|
17
|
+
address: Address;
|
|
18
|
+
/** Full registry string */
|
|
19
|
+
id: AgentRegistryId;
|
|
20
|
+
}
|
|
21
|
+
/** Metadata entry for agent registration */
|
|
22
|
+
interface MetadataEntry {
|
|
23
|
+
metadataKey: string;
|
|
24
|
+
metadataValue: Hex;
|
|
25
|
+
}
|
|
26
|
+
/** On-chain agent identity from Identity Registry */
|
|
27
|
+
interface AgentIdentity {
|
|
28
|
+
agentId: bigint;
|
|
29
|
+
owner: Address;
|
|
30
|
+
agentURI: string;
|
|
31
|
+
agentWallet: Address;
|
|
32
|
+
registry: AgentRegistry;
|
|
33
|
+
}
|
|
34
|
+
/** Resolved agent = on-chain identity + fetched registration file */
|
|
35
|
+
interface ResolvedAgent extends AgentIdentity {
|
|
36
|
+
registration: RegistrationFile;
|
|
37
|
+
}
|
|
38
|
+
/** ERC-8004 Registration File (off-chain JSON at agentURI) */
|
|
39
|
+
interface RegistrationFile {
|
|
40
|
+
type: string;
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
image?: string;
|
|
44
|
+
services: ServiceEntry[];
|
|
45
|
+
x402Support: boolean;
|
|
46
|
+
active: boolean;
|
|
47
|
+
registrations: RegistrationEntry[];
|
|
48
|
+
supportedTrust?: string[];
|
|
49
|
+
}
|
|
50
|
+
interface ServiceEntry {
|
|
51
|
+
name: string;
|
|
52
|
+
endpoint: string;
|
|
53
|
+
version?: string;
|
|
54
|
+
skills?: string[];
|
|
55
|
+
domains?: string[];
|
|
56
|
+
}
|
|
57
|
+
interface RegistrationEntry {
|
|
58
|
+
agentId: number;
|
|
59
|
+
agentRegistry: AgentRegistryId;
|
|
60
|
+
}
|
|
61
|
+
/** On-chain feedback record */
|
|
62
|
+
interface FeedbackRecord {
|
|
63
|
+
value: bigint;
|
|
64
|
+
valueDecimals: number;
|
|
65
|
+
tag1: string;
|
|
66
|
+
tag2: string;
|
|
67
|
+
isRevoked: boolean;
|
|
68
|
+
feedbackIndex: bigint;
|
|
69
|
+
clientAddress: Address;
|
|
70
|
+
}
|
|
71
|
+
/** Aggregated reputation summary */
|
|
72
|
+
interface ReputationSummary {
|
|
73
|
+
agentId: bigint;
|
|
74
|
+
count: bigint;
|
|
75
|
+
summaryValue: bigint;
|
|
76
|
+
summaryValueDecimals: number;
|
|
77
|
+
/** Normalized 0-100 score derived from summaryValue/summaryValueDecimals */
|
|
78
|
+
normalizedScore: number;
|
|
79
|
+
}
|
|
80
|
+
/** Parameters for submitting feedback */
|
|
81
|
+
interface FeedbackParams {
|
|
82
|
+
agentId: bigint;
|
|
83
|
+
value: bigint;
|
|
84
|
+
valueDecimals: number;
|
|
85
|
+
tag1: string;
|
|
86
|
+
tag2: string;
|
|
87
|
+
endpoint?: string;
|
|
88
|
+
feedbackURI?: string;
|
|
89
|
+
feedbackHash?: Bytes32;
|
|
90
|
+
}
|
|
91
|
+
/** Off-chain feedback file structure */
|
|
92
|
+
interface FeedbackFile {
|
|
93
|
+
agentRegistry: AgentRegistryId;
|
|
94
|
+
agentId: number;
|
|
95
|
+
clientAddress: string;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
value: number;
|
|
98
|
+
valueDecimals: number;
|
|
99
|
+
tag1?: string;
|
|
100
|
+
tag2?: string;
|
|
101
|
+
endpoint?: string;
|
|
102
|
+
proofOfPayment?: ProofOfPayment;
|
|
103
|
+
}
|
|
104
|
+
interface ProofOfPayment {
|
|
105
|
+
fromAddress: string;
|
|
106
|
+
toAddress: string;
|
|
107
|
+
chainId: string;
|
|
108
|
+
txHash: string;
|
|
109
|
+
}
|
|
110
|
+
/** Validation request parameters */
|
|
111
|
+
interface ValidationRequestParams {
|
|
112
|
+
validatorAddress: Address;
|
|
113
|
+
agentId: bigint;
|
|
114
|
+
requestURI: string;
|
|
115
|
+
requestHash: Bytes32;
|
|
116
|
+
}
|
|
117
|
+
/** Validation response */
|
|
118
|
+
interface ValidationStatus {
|
|
119
|
+
validatorAddress: Address;
|
|
120
|
+
agentId: bigint;
|
|
121
|
+
response: number;
|
|
122
|
+
responseHash: Bytes32;
|
|
123
|
+
tag: string;
|
|
124
|
+
lastUpdate: bigint;
|
|
125
|
+
}
|
|
126
|
+
/** Validation summary */
|
|
127
|
+
interface ValidationSummary {
|
|
128
|
+
count: bigint;
|
|
129
|
+
averageResponse: number;
|
|
130
|
+
}
|
|
131
|
+
/** ERC-8004 extension data in PaymentRequired.extensions */
|
|
132
|
+
interface ERC8004Extension {
|
|
133
|
+
/** Agent's ERC-8004 identity */
|
|
134
|
+
agentId: number;
|
|
135
|
+
/** Registry identifier: {namespace}:{chainId}:{address} */
|
|
136
|
+
agentRegistry: AgentRegistryId;
|
|
137
|
+
/** Agent's verified wallet (should match payTo) */
|
|
138
|
+
agentWallet?: string;
|
|
139
|
+
/** Reputation score (0-100, from trusted reviewers) */
|
|
140
|
+
reputationScore?: number;
|
|
141
|
+
/** Number of feedback records */
|
|
142
|
+
feedbackCount?: number;
|
|
143
|
+
/** Validation status (0-100 average) */
|
|
144
|
+
validationScore?: number;
|
|
145
|
+
}
|
|
146
|
+
/** ERC-8004 extension data echoed in PaymentPayload.extensions */
|
|
147
|
+
interface ERC8004PayloadExtension {
|
|
148
|
+
/** Whether client verified the agent identity */
|
|
149
|
+
identityVerified: boolean;
|
|
150
|
+
/** Agent ID that was verified */
|
|
151
|
+
agentId: number;
|
|
152
|
+
/** Registry used for verification */
|
|
153
|
+
agentRegistry: AgentRegistryId;
|
|
154
|
+
}
|
|
155
|
+
/** Minimal read-only client interface for ERC-8004 registry interactions */
|
|
156
|
+
interface ERC8004ReadClient {
|
|
157
|
+
readContract(args: {
|
|
158
|
+
address: Address;
|
|
159
|
+
abi: readonly unknown[];
|
|
160
|
+
functionName: string;
|
|
161
|
+
args?: readonly unknown[];
|
|
162
|
+
}): Promise<unknown>;
|
|
163
|
+
}
|
|
164
|
+
/** Write-capable client for submitting feedback and validation */
|
|
165
|
+
interface ERC8004WriteClient extends ERC8004ReadClient {
|
|
166
|
+
writeContract(args: {
|
|
167
|
+
address: Address;
|
|
168
|
+
abi: readonly unknown[];
|
|
169
|
+
functionName: string;
|
|
170
|
+
args: readonly unknown[];
|
|
171
|
+
}): Promise<Hex>;
|
|
172
|
+
waitForTransactionReceipt(args: {
|
|
173
|
+
hash: Hex;
|
|
174
|
+
}): Promise<{
|
|
175
|
+
status: string;
|
|
176
|
+
}>;
|
|
177
|
+
}
|
|
178
|
+
/** Configuration for ERC-8004 integration */
|
|
179
|
+
interface ERC8004Config {
|
|
180
|
+
/** Network for registry interactions (CAIP-2) */
|
|
181
|
+
network: Network;
|
|
182
|
+
/** Identity Registry contract address */
|
|
183
|
+
identityRegistry: Address;
|
|
184
|
+
/** Reputation Registry contract address */
|
|
185
|
+
reputationRegistry?: Address;
|
|
186
|
+
/** Validation Registry contract address */
|
|
187
|
+
validationRegistry?: Address;
|
|
188
|
+
/** Client for reading registry state */
|
|
189
|
+
client: ERC8004ReadClient;
|
|
190
|
+
/** Client for writing to registries (optional, needed for feedback/validation) */
|
|
191
|
+
writeClient?: ERC8004WriteClient;
|
|
192
|
+
}
|
|
193
|
+
/** Reputation check configuration */
|
|
194
|
+
interface ReputationCheckConfig {
|
|
195
|
+
/** Minimum normalized score (0-100) required to proceed */
|
|
196
|
+
minScore: number;
|
|
197
|
+
/** Addresses whose feedback is trusted for Sybil-resistance */
|
|
198
|
+
trustedReviewers: Address[];
|
|
199
|
+
/** Tags to filter on (optional) */
|
|
200
|
+
tag1?: string;
|
|
201
|
+
tag2?: string;
|
|
202
|
+
/** Action on score below threshold: "reject" | "warn" */
|
|
203
|
+
onBelowThreshold?: "reject" | "warn";
|
|
204
|
+
}
|
|
205
|
+
/** Feedback submission configuration */
|
|
206
|
+
interface FeedbackSubmissionConfig {
|
|
207
|
+
/** Default tag1 for payment-related feedback */
|
|
208
|
+
tag1?: string;
|
|
209
|
+
/** Default tag2 for additional classification */
|
|
210
|
+
tag2?: string;
|
|
211
|
+
/** Whether to include proofOfPayment from SettleResponse */
|
|
212
|
+
includeProofOfPayment?: boolean;
|
|
213
|
+
/** Base URI for hosting feedback files (optional, for off-chain data) */
|
|
214
|
+
feedbackBaseURI?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Known Identity Registry addresses per network.
|
|
219
|
+
* Populated as ERC-8004 deploys to each chain.
|
|
220
|
+
* Empty until mainnet deployments exist (spec is in Draft status).
|
|
221
|
+
*/
|
|
222
|
+
declare const IDENTITY_REGISTRIES: Partial<Record<Network, Address>>;
|
|
223
|
+
declare const REPUTATION_REGISTRIES: Partial<Record<Network, Address>>;
|
|
224
|
+
declare const VALIDATION_REGISTRIES: Partial<Record<Network, Address>>;
|
|
225
|
+
/** Extension key for t402 PaymentRequired/PaymentPayload.extensions */
|
|
226
|
+
declare const ERC8004_EXTENSION_KEY = "erc8004";
|
|
227
|
+
/** Standard feedback tags for t402 payment interactions */
|
|
228
|
+
declare const FEEDBACK_TAGS: {
|
|
229
|
+
/** tag1: Payment completed successfully */
|
|
230
|
+
readonly PAYMENT_SUCCESS: "paymentSuccess";
|
|
231
|
+
/** tag1: Payment verification failed */
|
|
232
|
+
readonly PAYMENT_FAILED: "paymentFailed";
|
|
233
|
+
/** tag1: Service quality rating */
|
|
234
|
+
readonly SERVICE_QUALITY: "starred";
|
|
235
|
+
/** tag2: Response time measurement */
|
|
236
|
+
readonly RESPONSE_TIME: "responseTime";
|
|
237
|
+
/** tag2: Uptime measurement */
|
|
238
|
+
readonly UPTIME: "uptime";
|
|
239
|
+
};
|
|
240
|
+
/** EIP-712 domain for setAgentWallet signature verification */
|
|
241
|
+
declare const IDENTITY_REGISTRY_DOMAIN: {
|
|
242
|
+
readonly name: "IdentityRegistry";
|
|
243
|
+
readonly version: "1";
|
|
244
|
+
};
|
|
245
|
+
/** EIP-712 typed data for setAgentWallet */
|
|
246
|
+
declare const SET_AGENT_WALLET_TYPES: {
|
|
247
|
+
readonly SetAgentWallet: readonly [{
|
|
248
|
+
readonly name: "agentId";
|
|
249
|
+
readonly type: "uint256";
|
|
250
|
+
}, {
|
|
251
|
+
readonly name: "newWallet";
|
|
252
|
+
readonly type: "address";
|
|
253
|
+
}, {
|
|
254
|
+
readonly name: "deadline";
|
|
255
|
+
readonly type: "uint256";
|
|
256
|
+
}, {
|
|
257
|
+
readonly name: "nonce";
|
|
258
|
+
readonly type: "uint256";
|
|
259
|
+
}];
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
declare const identityRegistryAbi: readonly [{
|
|
263
|
+
readonly type: "function";
|
|
264
|
+
readonly name: "register";
|
|
265
|
+
readonly inputs: readonly [{
|
|
266
|
+
readonly name: "agentURI";
|
|
267
|
+
readonly type: "string";
|
|
268
|
+
}, {
|
|
269
|
+
readonly name: "metadata";
|
|
270
|
+
readonly type: "tuple[]";
|
|
271
|
+
readonly components: readonly [{
|
|
272
|
+
readonly name: "metadataKey";
|
|
273
|
+
readonly type: "string";
|
|
274
|
+
}, {
|
|
275
|
+
readonly name: "metadataValue";
|
|
276
|
+
readonly type: "bytes";
|
|
277
|
+
}];
|
|
278
|
+
}];
|
|
279
|
+
readonly outputs: readonly [{
|
|
280
|
+
readonly type: "uint256";
|
|
281
|
+
}];
|
|
282
|
+
readonly stateMutability: "nonpayable";
|
|
283
|
+
}, {
|
|
284
|
+
readonly type: "function";
|
|
285
|
+
readonly name: "getAgentWallet";
|
|
286
|
+
readonly inputs: readonly [{
|
|
287
|
+
readonly name: "agentId";
|
|
288
|
+
readonly type: "uint256";
|
|
289
|
+
}];
|
|
290
|
+
readonly outputs: readonly [{
|
|
291
|
+
readonly type: "address";
|
|
292
|
+
}];
|
|
293
|
+
readonly stateMutability: "view";
|
|
294
|
+
}, {
|
|
295
|
+
readonly type: "function";
|
|
296
|
+
readonly name: "tokenURI";
|
|
297
|
+
readonly inputs: readonly [{
|
|
298
|
+
readonly name: "tokenId";
|
|
299
|
+
readonly type: "uint256";
|
|
300
|
+
}];
|
|
301
|
+
readonly outputs: readonly [{
|
|
302
|
+
readonly type: "string";
|
|
303
|
+
}];
|
|
304
|
+
readonly stateMutability: "view";
|
|
305
|
+
}, {
|
|
306
|
+
readonly type: "function";
|
|
307
|
+
readonly name: "ownerOf";
|
|
308
|
+
readonly inputs: readonly [{
|
|
309
|
+
readonly name: "tokenId";
|
|
310
|
+
readonly type: "uint256";
|
|
311
|
+
}];
|
|
312
|
+
readonly outputs: readonly [{
|
|
313
|
+
readonly type: "address";
|
|
314
|
+
}];
|
|
315
|
+
readonly stateMutability: "view";
|
|
316
|
+
}, {
|
|
317
|
+
readonly type: "function";
|
|
318
|
+
readonly name: "getMetadata";
|
|
319
|
+
readonly inputs: readonly [{
|
|
320
|
+
readonly name: "agentId";
|
|
321
|
+
readonly type: "uint256";
|
|
322
|
+
}, {
|
|
323
|
+
readonly name: "metadataKey";
|
|
324
|
+
readonly type: "string";
|
|
325
|
+
}];
|
|
326
|
+
readonly outputs: readonly [{
|
|
327
|
+
readonly type: "bytes";
|
|
328
|
+
}];
|
|
329
|
+
readonly stateMutability: "view";
|
|
330
|
+
}, {
|
|
331
|
+
readonly type: "function";
|
|
332
|
+
readonly name: "setAgentWallet";
|
|
333
|
+
readonly inputs: readonly [{
|
|
334
|
+
readonly name: "agentId";
|
|
335
|
+
readonly type: "uint256";
|
|
336
|
+
}, {
|
|
337
|
+
readonly name: "newWallet";
|
|
338
|
+
readonly type: "address";
|
|
339
|
+
}, {
|
|
340
|
+
readonly name: "deadline";
|
|
341
|
+
readonly type: "uint256";
|
|
342
|
+
}, {
|
|
343
|
+
readonly name: "signature";
|
|
344
|
+
readonly type: "bytes";
|
|
345
|
+
}];
|
|
346
|
+
readonly outputs: readonly [];
|
|
347
|
+
readonly stateMutability: "nonpayable";
|
|
348
|
+
}, {
|
|
349
|
+
readonly type: "event";
|
|
350
|
+
readonly name: "Registered";
|
|
351
|
+
readonly inputs: readonly [{
|
|
352
|
+
readonly name: "agentId";
|
|
353
|
+
readonly type: "uint256";
|
|
354
|
+
readonly indexed: true;
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "agentURI";
|
|
357
|
+
readonly type: "string";
|
|
358
|
+
readonly indexed: false;
|
|
359
|
+
}, {
|
|
360
|
+
readonly name: "owner";
|
|
361
|
+
readonly type: "address";
|
|
362
|
+
readonly indexed: true;
|
|
363
|
+
}];
|
|
364
|
+
}];
|
|
365
|
+
declare const reputationRegistryAbi: readonly [{
|
|
366
|
+
readonly type: "function";
|
|
367
|
+
readonly name: "giveFeedback";
|
|
368
|
+
readonly inputs: readonly [{
|
|
369
|
+
readonly name: "agentId";
|
|
370
|
+
readonly type: "uint256";
|
|
371
|
+
}, {
|
|
372
|
+
readonly name: "value";
|
|
373
|
+
readonly type: "int128";
|
|
374
|
+
}, {
|
|
375
|
+
readonly name: "valueDecimals";
|
|
376
|
+
readonly type: "uint8";
|
|
377
|
+
}, {
|
|
378
|
+
readonly name: "tag1";
|
|
379
|
+
readonly type: "string";
|
|
380
|
+
}, {
|
|
381
|
+
readonly name: "tag2";
|
|
382
|
+
readonly type: "string";
|
|
383
|
+
}, {
|
|
384
|
+
readonly name: "endpoint";
|
|
385
|
+
readonly type: "string";
|
|
386
|
+
}, {
|
|
387
|
+
readonly name: "feedbackURI";
|
|
388
|
+
readonly type: "string";
|
|
389
|
+
}, {
|
|
390
|
+
readonly name: "feedbackHash";
|
|
391
|
+
readonly type: "bytes32";
|
|
392
|
+
}];
|
|
393
|
+
readonly outputs: readonly [];
|
|
394
|
+
readonly stateMutability: "nonpayable";
|
|
395
|
+
}, {
|
|
396
|
+
readonly type: "function";
|
|
397
|
+
readonly name: "getSummary";
|
|
398
|
+
readonly inputs: readonly [{
|
|
399
|
+
readonly name: "agentId";
|
|
400
|
+
readonly type: "uint256";
|
|
401
|
+
}, {
|
|
402
|
+
readonly name: "clientAddresses";
|
|
403
|
+
readonly type: "address[]";
|
|
404
|
+
}, {
|
|
405
|
+
readonly name: "tag1";
|
|
406
|
+
readonly type: "string";
|
|
407
|
+
}, {
|
|
408
|
+
readonly name: "tag2";
|
|
409
|
+
readonly type: "string";
|
|
410
|
+
}];
|
|
411
|
+
readonly outputs: readonly [{
|
|
412
|
+
readonly name: "count";
|
|
413
|
+
readonly type: "uint64";
|
|
414
|
+
}, {
|
|
415
|
+
readonly name: "summaryValue";
|
|
416
|
+
readonly type: "int128";
|
|
417
|
+
}, {
|
|
418
|
+
readonly name: "summaryValueDecimals";
|
|
419
|
+
readonly type: "uint8";
|
|
420
|
+
}];
|
|
421
|
+
readonly stateMutability: "view";
|
|
422
|
+
}, {
|
|
423
|
+
readonly type: "function";
|
|
424
|
+
readonly name: "revokeFeedback";
|
|
425
|
+
readonly inputs: readonly [{
|
|
426
|
+
readonly name: "agentId";
|
|
427
|
+
readonly type: "uint256";
|
|
428
|
+
}, {
|
|
429
|
+
readonly name: "feedbackIndex";
|
|
430
|
+
readonly type: "uint64";
|
|
431
|
+
}];
|
|
432
|
+
readonly outputs: readonly [];
|
|
433
|
+
readonly stateMutability: "nonpayable";
|
|
434
|
+
}, {
|
|
435
|
+
readonly type: "function";
|
|
436
|
+
readonly name: "getClients";
|
|
437
|
+
readonly inputs: readonly [{
|
|
438
|
+
readonly name: "agentId";
|
|
439
|
+
readonly type: "uint256";
|
|
440
|
+
}];
|
|
441
|
+
readonly outputs: readonly [{
|
|
442
|
+
readonly type: "address[]";
|
|
443
|
+
}];
|
|
444
|
+
readonly stateMutability: "view";
|
|
445
|
+
}, {
|
|
446
|
+
readonly type: "event";
|
|
447
|
+
readonly name: "NewFeedback";
|
|
448
|
+
readonly inputs: readonly [{
|
|
449
|
+
readonly name: "agentId";
|
|
450
|
+
readonly type: "uint256";
|
|
451
|
+
readonly indexed: true;
|
|
452
|
+
}, {
|
|
453
|
+
readonly name: "clientAddress";
|
|
454
|
+
readonly type: "address";
|
|
455
|
+
readonly indexed: true;
|
|
456
|
+
}, {
|
|
457
|
+
readonly name: "feedbackIndex";
|
|
458
|
+
readonly type: "uint64";
|
|
459
|
+
readonly indexed: false;
|
|
460
|
+
}, {
|
|
461
|
+
readonly name: "value";
|
|
462
|
+
readonly type: "int128";
|
|
463
|
+
readonly indexed: false;
|
|
464
|
+
}, {
|
|
465
|
+
readonly name: "valueDecimals";
|
|
466
|
+
readonly type: "uint8";
|
|
467
|
+
readonly indexed: false;
|
|
468
|
+
}, {
|
|
469
|
+
readonly name: "indexedTag1";
|
|
470
|
+
readonly type: "string";
|
|
471
|
+
readonly indexed: true;
|
|
472
|
+
}, {
|
|
473
|
+
readonly name: "tag1";
|
|
474
|
+
readonly type: "string";
|
|
475
|
+
readonly indexed: false;
|
|
476
|
+
}, {
|
|
477
|
+
readonly name: "tag2";
|
|
478
|
+
readonly type: "string";
|
|
479
|
+
readonly indexed: false;
|
|
480
|
+
}, {
|
|
481
|
+
readonly name: "endpoint";
|
|
482
|
+
readonly type: "string";
|
|
483
|
+
readonly indexed: false;
|
|
484
|
+
}, {
|
|
485
|
+
readonly name: "feedbackURI";
|
|
486
|
+
readonly type: "string";
|
|
487
|
+
readonly indexed: false;
|
|
488
|
+
}, {
|
|
489
|
+
readonly name: "feedbackHash";
|
|
490
|
+
readonly type: "bytes32";
|
|
491
|
+
readonly indexed: false;
|
|
492
|
+
}];
|
|
493
|
+
}];
|
|
494
|
+
declare const validationRegistryAbi: readonly [{
|
|
495
|
+
readonly type: "function";
|
|
496
|
+
readonly name: "validationRequest";
|
|
497
|
+
readonly inputs: readonly [{
|
|
498
|
+
readonly name: "validatorAddress";
|
|
499
|
+
readonly type: "address";
|
|
500
|
+
}, {
|
|
501
|
+
readonly name: "agentId";
|
|
502
|
+
readonly type: "uint256";
|
|
503
|
+
}, {
|
|
504
|
+
readonly name: "requestURI";
|
|
505
|
+
readonly type: "string";
|
|
506
|
+
}, {
|
|
507
|
+
readonly name: "requestHash";
|
|
508
|
+
readonly type: "bytes32";
|
|
509
|
+
}];
|
|
510
|
+
readonly outputs: readonly [];
|
|
511
|
+
readonly stateMutability: "nonpayable";
|
|
512
|
+
}, {
|
|
513
|
+
readonly type: "function";
|
|
514
|
+
readonly name: "validationResponse";
|
|
515
|
+
readonly inputs: readonly [{
|
|
516
|
+
readonly name: "requestHash";
|
|
517
|
+
readonly type: "bytes32";
|
|
518
|
+
}, {
|
|
519
|
+
readonly name: "response";
|
|
520
|
+
readonly type: "uint8";
|
|
521
|
+
}, {
|
|
522
|
+
readonly name: "responseURI";
|
|
523
|
+
readonly type: "string";
|
|
524
|
+
}, {
|
|
525
|
+
readonly name: "responseHash";
|
|
526
|
+
readonly type: "bytes32";
|
|
527
|
+
}, {
|
|
528
|
+
readonly name: "tag";
|
|
529
|
+
readonly type: "string";
|
|
530
|
+
}];
|
|
531
|
+
readonly outputs: readonly [];
|
|
532
|
+
readonly stateMutability: "nonpayable";
|
|
533
|
+
}, {
|
|
534
|
+
readonly type: "function";
|
|
535
|
+
readonly name: "getValidationStatus";
|
|
536
|
+
readonly inputs: readonly [{
|
|
537
|
+
readonly name: "requestHash";
|
|
538
|
+
readonly type: "bytes32";
|
|
539
|
+
}];
|
|
540
|
+
readonly outputs: readonly [{
|
|
541
|
+
readonly name: "validatorAddress";
|
|
542
|
+
readonly type: "address";
|
|
543
|
+
}, {
|
|
544
|
+
readonly name: "agentId";
|
|
545
|
+
readonly type: "uint256";
|
|
546
|
+
}, {
|
|
547
|
+
readonly name: "response";
|
|
548
|
+
readonly type: "uint8";
|
|
549
|
+
}, {
|
|
550
|
+
readonly name: "responseHash";
|
|
551
|
+
readonly type: "bytes32";
|
|
552
|
+
}, {
|
|
553
|
+
readonly name: "tag";
|
|
554
|
+
readonly type: "string";
|
|
555
|
+
}, {
|
|
556
|
+
readonly name: "lastUpdate";
|
|
557
|
+
readonly type: "uint256";
|
|
558
|
+
}];
|
|
559
|
+
readonly stateMutability: "view";
|
|
560
|
+
}, {
|
|
561
|
+
readonly type: "function";
|
|
562
|
+
readonly name: "getSummary";
|
|
563
|
+
readonly inputs: readonly [{
|
|
564
|
+
readonly name: "agentId";
|
|
565
|
+
readonly type: "uint256";
|
|
566
|
+
}, {
|
|
567
|
+
readonly name: "validatorAddresses";
|
|
568
|
+
readonly type: "address[]";
|
|
569
|
+
}, {
|
|
570
|
+
readonly name: "tag";
|
|
571
|
+
readonly type: "string";
|
|
572
|
+
}];
|
|
573
|
+
readonly outputs: readonly [{
|
|
574
|
+
readonly name: "count";
|
|
575
|
+
readonly type: "uint64";
|
|
576
|
+
}, {
|
|
577
|
+
readonly name: "averageResponse";
|
|
578
|
+
readonly type: "uint8";
|
|
579
|
+
}];
|
|
580
|
+
readonly stateMutability: "view";
|
|
581
|
+
}, {
|
|
582
|
+
readonly type: "event";
|
|
583
|
+
readonly name: "ValidationRequest";
|
|
584
|
+
readonly inputs: readonly [{
|
|
585
|
+
readonly name: "validatorAddress";
|
|
586
|
+
readonly type: "address";
|
|
587
|
+
readonly indexed: true;
|
|
588
|
+
}, {
|
|
589
|
+
readonly name: "agentId";
|
|
590
|
+
readonly type: "uint256";
|
|
591
|
+
readonly indexed: true;
|
|
592
|
+
}, {
|
|
593
|
+
readonly name: "requestURI";
|
|
594
|
+
readonly type: "string";
|
|
595
|
+
readonly indexed: false;
|
|
596
|
+
}, {
|
|
597
|
+
readonly name: "requestHash";
|
|
598
|
+
readonly type: "bytes32";
|
|
599
|
+
readonly indexed: true;
|
|
600
|
+
}];
|
|
601
|
+
}, {
|
|
602
|
+
readonly type: "event";
|
|
603
|
+
readonly name: "ValidationResponse";
|
|
604
|
+
readonly inputs: readonly [{
|
|
605
|
+
readonly name: "validatorAddress";
|
|
606
|
+
readonly type: "address";
|
|
607
|
+
readonly indexed: true;
|
|
608
|
+
}, {
|
|
609
|
+
readonly name: "agentId";
|
|
610
|
+
readonly type: "uint256";
|
|
611
|
+
readonly indexed: true;
|
|
612
|
+
}, {
|
|
613
|
+
readonly name: "requestHash";
|
|
614
|
+
readonly type: "bytes32";
|
|
615
|
+
readonly indexed: true;
|
|
616
|
+
}, {
|
|
617
|
+
readonly name: "response";
|
|
618
|
+
readonly type: "uint8";
|
|
619
|
+
readonly indexed: false;
|
|
620
|
+
}, {
|
|
621
|
+
readonly name: "responseURI";
|
|
622
|
+
readonly type: "string";
|
|
623
|
+
readonly indexed: false;
|
|
624
|
+
}, {
|
|
625
|
+
readonly name: "responseHash";
|
|
626
|
+
readonly type: "bytes32";
|
|
627
|
+
readonly indexed: false;
|
|
628
|
+
}, {
|
|
629
|
+
readonly name: "tag";
|
|
630
|
+
readonly type: "string";
|
|
631
|
+
readonly indexed: false;
|
|
632
|
+
}];
|
|
633
|
+
}];
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Parse an agent registry ID string into components.
|
|
637
|
+
*
|
|
638
|
+
* @param registryId - Format: "{namespace}:{chainId}:{address}"
|
|
639
|
+
* @returns Parsed AgentRegistry
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* parseAgentRegistry("eip155:8453:0x742d35Cc...")
|
|
643
|
+
* // => { namespace: "eip155", chainId: "8453", address: "0x742d35Cc...", id: "eip155:8453:0x742d35Cc..." }
|
|
644
|
+
*/
|
|
645
|
+
declare function parseAgentRegistry(registryId: AgentRegistryId): AgentRegistry;
|
|
646
|
+
/**
|
|
647
|
+
* Resolve an agent's on-chain identity from the Identity Registry.
|
|
648
|
+
*
|
|
649
|
+
* Reads agentWallet, owner, and tokenURI from the contract.
|
|
650
|
+
*
|
|
651
|
+
* @param client - Read-only client for contract calls
|
|
652
|
+
* @param identityRegistry - Identity Registry contract address
|
|
653
|
+
* @param agentId - Agent's NFT token ID
|
|
654
|
+
* @param registryId - Full agent registry identifier
|
|
655
|
+
* @returns Agent identity with wallet, owner, and URI
|
|
656
|
+
*/
|
|
657
|
+
declare function getAgentIdentity(client: ERC8004ReadClient, identityRegistry: Address, agentId: bigint, registryId: AgentRegistryId): Promise<AgentIdentity>;
|
|
658
|
+
/**
|
|
659
|
+
* Fetch and parse the agent's registration file from their agentURI.
|
|
660
|
+
*
|
|
661
|
+
* @param agentURI - URI pointing to the registration JSON file
|
|
662
|
+
* @returns Parsed registration file
|
|
663
|
+
* @throws If the URI is not reachable or the file is malformed
|
|
664
|
+
*/
|
|
665
|
+
declare function fetchRegistrationFile(agentURI: string): Promise<RegistrationFile>;
|
|
666
|
+
/**
|
|
667
|
+
* Resolve an agent: fetch on-chain identity + off-chain registration file.
|
|
668
|
+
*
|
|
669
|
+
* @param client - Read-only client for contract calls
|
|
670
|
+
* @param identityRegistry - Identity Registry contract address
|
|
671
|
+
* @param agentId - Agent's NFT token ID
|
|
672
|
+
* @param registryId - Full agent registry identifier
|
|
673
|
+
* @returns Fully resolved agent with registration file
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* const agent = await resolveAgent(viemClient, registryAddr, 42n, "eip155:8453:0x...");
|
|
677
|
+
* if (agent.agentWallet !== paymentRequirements.payTo) {
|
|
678
|
+
* throw new Error("Payment address mismatch");
|
|
679
|
+
* }
|
|
680
|
+
*/
|
|
681
|
+
declare function resolveAgent(client: ERC8004ReadClient, identityRegistry: Address, agentId: bigint, registryId: AgentRegistryId): Promise<ResolvedAgent>;
|
|
682
|
+
/**
|
|
683
|
+
* Verify that a payTo address matches the on-chain agentWallet.
|
|
684
|
+
*
|
|
685
|
+
* @param client - Read-only client for contract calls
|
|
686
|
+
* @param identityRegistry - Identity Registry contract address
|
|
687
|
+
* @param agentId - Agent's NFT token ID
|
|
688
|
+
* @param payTo - Address from PaymentRequirements.payTo
|
|
689
|
+
* @returns Whether the payTo address matches the on-chain agentWallet
|
|
690
|
+
*/
|
|
691
|
+
declare function verifyPayToMatchesAgent(client: ERC8004ReadClient, identityRegistry: Address, agentId: bigint, payTo: string): Promise<boolean>;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Get a reputation summary for an agent from trusted reviewers.
|
|
695
|
+
*
|
|
696
|
+
* Queries the on-chain Reputation Registry and normalizes the result
|
|
697
|
+
* to a 0-100 score. Requires explicit `trustedReviewers` for Sybil resistance.
|
|
698
|
+
*
|
|
699
|
+
* @param client - Read-only client for contract calls
|
|
700
|
+
* @param reputationRegistry - Reputation Registry contract address
|
|
701
|
+
* @param agentId - Agent's on-chain ID
|
|
702
|
+
* @param trustedReviewers - Addresses whose feedback is trusted
|
|
703
|
+
* @param tag1 - Optional primary tag filter
|
|
704
|
+
* @param tag2 - Optional secondary tag filter
|
|
705
|
+
* @returns Reputation summary with normalized 0-100 score
|
|
706
|
+
*/
|
|
707
|
+
declare function getReputationSummary(client: ERC8004ReadClient, reputationRegistry: Address, agentId: bigint, trustedReviewers: Address[], tag1?: string, tag2?: string): Promise<ReputationSummary>;
|
|
708
|
+
/**
|
|
709
|
+
* Build an off-chain feedback file with optional proofOfPayment.
|
|
710
|
+
*
|
|
711
|
+
* Creates a structured feedback file object ready for JSON serialization
|
|
712
|
+
* and hosting at a feedbackURI. Used by the afterSettle hook to link
|
|
713
|
+
* on-chain feedback records to off-chain payment proof.
|
|
714
|
+
*
|
|
715
|
+
* @param agentId - Agent's numeric ID
|
|
716
|
+
* @param agentRegistry - Registry identifier
|
|
717
|
+
* @param clientAddress - Address of the feedback submitter
|
|
718
|
+
* @param value - Feedback value (e.g. 100 for positive)
|
|
719
|
+
* @param valueDecimals - Decimal precision for value
|
|
720
|
+
* @param tag1 - Primary classification tag
|
|
721
|
+
* @param tag2 - Secondary classification tag
|
|
722
|
+
* @param proofOfPayment - Optional payment proof from settlement
|
|
723
|
+
* @returns Feedback file object
|
|
724
|
+
*/
|
|
725
|
+
declare function buildFeedbackFile(agentId: number, agentRegistry: AgentRegistryId, clientAddress: string, value: number, valueDecimals: number, tag1: string, tag2: string, proofOfPayment?: ProofOfPayment): FeedbackFile;
|
|
726
|
+
/**
|
|
727
|
+
* Submit feedback for an agent to the on-chain Reputation Registry.
|
|
728
|
+
*
|
|
729
|
+
* Calls `giveFeedback` on the Reputation Registry contract.
|
|
730
|
+
* Typically used after a successful payment settlement to record
|
|
731
|
+
* positive feedback linking the agent to the transaction.
|
|
732
|
+
*
|
|
733
|
+
* @param client - Write-capable client for submitting transactions
|
|
734
|
+
* @param reputationRegistry - Reputation Registry contract address
|
|
735
|
+
* @param params - Feedback parameters (agentId, value, tags, etc.)
|
|
736
|
+
* @returns Transaction hash
|
|
737
|
+
*/
|
|
738
|
+
declare function submitFeedback(client: ERC8004WriteClient, reputationRegistry: Address, params: FeedbackParams): Promise<Hex>;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Submit a validation request for agent work.
|
|
742
|
+
*
|
|
743
|
+
* Calls `validationRequest` on the Validation Registry contract
|
|
744
|
+
* to request validation of an agent's output by a specific validator.
|
|
745
|
+
*
|
|
746
|
+
* @param client - Write-capable client
|
|
747
|
+
* @param validationRegistry - Validation Registry contract address
|
|
748
|
+
* @param params - Validation request parameters
|
|
749
|
+
* @returns Transaction hash
|
|
750
|
+
*/
|
|
751
|
+
declare function submitValidationRequest(client: ERC8004WriteClient, validationRegistry: Address, params: ValidationRequestParams): Promise<Hex>;
|
|
752
|
+
/**
|
|
753
|
+
* Get validation status for a specific request.
|
|
754
|
+
*
|
|
755
|
+
* Queries the on-chain Validation Registry for the current status
|
|
756
|
+
* of a validation request identified by its request hash.
|
|
757
|
+
*
|
|
758
|
+
* @param client - Read-only client
|
|
759
|
+
* @param validationRegistry - Validation Registry contract address
|
|
760
|
+
* @param requestHash - Keccak256 hash of the validation request
|
|
761
|
+
* @returns Validation status
|
|
762
|
+
*/
|
|
763
|
+
declare function getValidationStatus(client: ERC8004ReadClient, validationRegistry: Address, requestHash: Bytes32): Promise<ValidationStatus>;
|
|
764
|
+
/**
|
|
765
|
+
* Get aggregated validation summary for an agent.
|
|
766
|
+
*
|
|
767
|
+
* Queries the on-chain Validation Registry for the average validation
|
|
768
|
+
* score across trusted validators.
|
|
769
|
+
*
|
|
770
|
+
* @param client - Read-only client
|
|
771
|
+
* @param validationRegistry - Validation Registry contract address
|
|
772
|
+
* @param agentId - Agent's ID
|
|
773
|
+
* @param validatorAddresses - Addresses of trusted validators
|
|
774
|
+
* @param tag - Optional tag filter
|
|
775
|
+
* @returns Validation summary with count and average score
|
|
776
|
+
*/
|
|
777
|
+
declare function getValidationSummary(client: ERC8004ReadClient, validationRegistry: Address, agentId: bigint, validatorAddresses: Address[], tag?: string): Promise<ValidationSummary>;
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Declare an ERC-8004 extension for a PaymentRequired response.
|
|
781
|
+
*
|
|
782
|
+
* @param agentId - Agent's on-chain ID
|
|
783
|
+
* @param agentRegistry - Registry identifier
|
|
784
|
+
* @param agentWallet - Optional verified wallet address
|
|
785
|
+
* @returns Extension object to include in route config extensions
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* const routes = {
|
|
789
|
+
* "/api/data": {
|
|
790
|
+
* accepts: [...],
|
|
791
|
+
* extensions: {
|
|
792
|
+
* erc8004: declareERC8004Extension(42, "eip155:8453:0x...")
|
|
793
|
+
* }
|
|
794
|
+
* }
|
|
795
|
+
* };
|
|
796
|
+
*/
|
|
797
|
+
declare function declareERC8004Extension(agentId: number, agentRegistry: AgentRegistryId, agentWallet?: string): ERC8004Extension;
|
|
798
|
+
/**
|
|
799
|
+
* Extract ERC-8004 extension data from a PaymentRequired response.
|
|
800
|
+
*
|
|
801
|
+
* @param paymentRequired - The PaymentRequired response
|
|
802
|
+
* @returns ERC-8004 extension data or undefined
|
|
803
|
+
*/
|
|
804
|
+
declare function getERC8004Extension(paymentRequired: PaymentRequired): ERC8004Extension | undefined;
|
|
805
|
+
/**
|
|
806
|
+
* Create a client-side ERC-8004 payload extension after verifying identity.
|
|
807
|
+
*
|
|
808
|
+
* @param agentId - Agent ID that was verified
|
|
809
|
+
* @param agentRegistry - Registry used
|
|
810
|
+
* @param verified - Whether verification passed
|
|
811
|
+
* @returns Payload extension to echo back
|
|
812
|
+
*/
|
|
813
|
+
declare function createERC8004PayloadExtension(agentId: number, agentRegistry: AgentRegistryId, verified: boolean): ERC8004PayloadExtension;
|
|
814
|
+
/**
|
|
815
|
+
* Client-side: verify agent identity from PaymentRequired before paying.
|
|
816
|
+
*
|
|
817
|
+
* Checks that the payTo address in each PaymentRequirements entry matches
|
|
818
|
+
* the on-chain agentWallet for the declared agentId.
|
|
819
|
+
*
|
|
820
|
+
* @param client - Read-only client for contract calls
|
|
821
|
+
* @param paymentRequired - The PaymentRequired response with ERC-8004 extension
|
|
822
|
+
* @returns Whether all payTo addresses match the on-chain agent wallet
|
|
823
|
+
*/
|
|
824
|
+
declare function verifyAgentIdentity(client: ERC8004ReadClient, paymentRequired: PaymentRequired): Promise<boolean>;
|
|
825
|
+
/**
|
|
826
|
+
* Create a ResourceServerExtension that enriches ERC-8004 declarations
|
|
827
|
+
* with live reputation data from the on-chain Reputation Registry.
|
|
828
|
+
*
|
|
829
|
+
* When registered on a t402ResourceServer, this extension fetches the
|
|
830
|
+
* agent's current reputation score and feedback count at response time,
|
|
831
|
+
* including them in the PaymentRequired response for client inspection.
|
|
832
|
+
*
|
|
833
|
+
* @param config - Configuration with client and optional reputation parameters
|
|
834
|
+
* @returns ResourceServerExtension for registration on t402ResourceServer
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* ```typescript
|
|
838
|
+
* const server = new t402ResourceServer(facilitatorClient);
|
|
839
|
+
* server.registerExtension(erc8004ResourceServerExtension({
|
|
840
|
+
* client: viemPublicClient,
|
|
841
|
+
* reputationRegistry: "0x...",
|
|
842
|
+
* trustedReviewers: ["0x..."],
|
|
843
|
+
* }));
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
846
|
+
declare function erc8004ResourceServerExtension(config: {
|
|
847
|
+
client: ERC8004ReadClient;
|
|
848
|
+
reputationRegistry?: Address;
|
|
849
|
+
trustedReviewers?: Address[];
|
|
850
|
+
validationRegistry?: Address;
|
|
851
|
+
trustedValidators?: Address[];
|
|
852
|
+
}): ResourceServerExtension;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Options for the ERC-8004 identity check hook.
|
|
856
|
+
*/
|
|
857
|
+
interface IdentityCheckOptions {
|
|
858
|
+
/**
|
|
859
|
+
* Abort payment if identity verification fails.
|
|
860
|
+
* @default true
|
|
861
|
+
*/
|
|
862
|
+
abortOnFailure?: boolean;
|
|
863
|
+
/**
|
|
864
|
+
* Abort payment if no ERC-8004 extension is present.
|
|
865
|
+
* When false (default), requests without the extension pass through silently.
|
|
866
|
+
* @default false
|
|
867
|
+
*/
|
|
868
|
+
abortOnMissing?: boolean;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Create a BeforePaymentCreationHook that verifies agent identity
|
|
872
|
+
* before signing a payment.
|
|
873
|
+
*
|
|
874
|
+
* Works with `t402Client.onBeforePaymentCreation()`, which means it
|
|
875
|
+
* automatically applies to `@t402/fetch` and `@t402/axios` wrappers.
|
|
876
|
+
*
|
|
877
|
+
* @param client - Read-only client for on-chain contract calls
|
|
878
|
+
* @param options - Hook behavior options
|
|
879
|
+
* @returns A hook for registration on t402Client
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```typescript
|
|
883
|
+
* import { createPublicClient, http } from "viem";
|
|
884
|
+
* import { base } from "viem/chains";
|
|
885
|
+
* import { erc8004IdentityCheck } from "@t402/erc8004";
|
|
886
|
+
*
|
|
887
|
+
* const viemClient = createPublicClient({ chain: base, transport: http() });
|
|
888
|
+
* const client = new t402Client()
|
|
889
|
+
* .register("eip155:8453", evmScheme)
|
|
890
|
+
* .onBeforePaymentCreation(erc8004IdentityCheck(viemClient));
|
|
891
|
+
*
|
|
892
|
+
* const fetchWithPay = wrapFetchWithPayment(fetch, client);
|
|
893
|
+
* ```
|
|
894
|
+
*/
|
|
895
|
+
declare function erc8004IdentityCheck(client: ERC8004ReadClient, options?: IdentityCheckOptions): BeforePaymentCreationHook;
|
|
896
|
+
/**
|
|
897
|
+
* Verify agent identity from an A2A task's payment requirements.
|
|
898
|
+
*
|
|
899
|
+
* Convenience wrapper that extracts PaymentRequired from an A2A task
|
|
900
|
+
* and delegates to `verifyAgentIdentity()`.
|
|
901
|
+
*
|
|
902
|
+
* @param client - Read-only client for on-chain contract calls
|
|
903
|
+
* @param task - The A2A task containing payment requirements
|
|
904
|
+
* @returns Whether identity verification passed (false if no requirements or no extension)
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
* ```typescript
|
|
908
|
+
* const a2aClient = new A2APaymentClient({
|
|
909
|
+
* onPaymentRequired: async (requirements) => {
|
|
910
|
+
* const verified = await verifyAgentIdentityFromTask(viemClient, task);
|
|
911
|
+
* if (!verified) throw new Error("Agent identity not verified");
|
|
912
|
+
* },
|
|
913
|
+
* });
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
declare function verifyAgentIdentityFromTask(client: ERC8004ReadClient, task: A2ATask): Promise<boolean>;
|
|
917
|
+
/**
|
|
918
|
+
* Create a BeforeVerifyHook that checks agent reputation before verification.
|
|
919
|
+
*
|
|
920
|
+
* Queries the Reputation Registry for the agent's score from trusted
|
|
921
|
+
* reviewers. If below threshold, aborts or warns per config.
|
|
922
|
+
*
|
|
923
|
+
* @param client - Read-only client for contract calls
|
|
924
|
+
* @param reputationRegistry - Reputation Registry contract address
|
|
925
|
+
* @param config - Reputation check configuration
|
|
926
|
+
* @returns BeforeVerifyHook for registration on t402ResourceServer
|
|
927
|
+
*
|
|
928
|
+
* @example
|
|
929
|
+
* ```typescript
|
|
930
|
+
* const server = new t402ResourceServer(facilitatorClient);
|
|
931
|
+
* server.onBeforeVerify(erc8004ReputationCheck(viemClient, registryAddr, {
|
|
932
|
+
* minScore: 70,
|
|
933
|
+
* trustedReviewers: ["0x..."],
|
|
934
|
+
* onBelowThreshold: "reject",
|
|
935
|
+
* }));
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
declare function erc8004ReputationCheck(client: ERC8004ReadClient, reputationRegistry: Address, config: ReputationCheckConfig): BeforeVerifyHook;
|
|
939
|
+
/**
|
|
940
|
+
* Create a BeforeVerifyHook that verifies payTo matches the agent's
|
|
941
|
+
* on-chain agentWallet.
|
|
942
|
+
*
|
|
943
|
+
* Server-side counterpart to the client-side `erc8004IdentityCheck`.
|
|
944
|
+
* Ensures the payment recipient address in the accepted requirements
|
|
945
|
+
* matches the registered agent wallet.
|
|
946
|
+
*
|
|
947
|
+
* @param client - Read-only client for contract calls
|
|
948
|
+
* @returns BeforeVerifyHook for registration on t402ResourceServer
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* ```typescript
|
|
952
|
+
* server.onBeforeVerify(erc8004ServerIdentityCheck(viemClient));
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
declare function erc8004ServerIdentityCheck(client: ERC8004ReadClient): BeforeVerifyHook;
|
|
956
|
+
/**
|
|
957
|
+
* Create an AfterSettleHook that submits positive feedback to the
|
|
958
|
+
* Reputation Registry after a successful payment settlement.
|
|
959
|
+
*
|
|
960
|
+
* Uses fire-and-forget: the feedback submission runs asynchronously
|
|
961
|
+
* and never blocks the settlement flow. Errors are logged as warnings.
|
|
962
|
+
*
|
|
963
|
+
* @param writeClient - Write-capable client for submitting feedback tx
|
|
964
|
+
* @param reputationRegistry - Reputation Registry contract address
|
|
965
|
+
* @param config - Feedback submission configuration
|
|
966
|
+
* @returns AfterSettleHook for registration on t402ResourceServer
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* server.onAfterSettle(erc8004SubmitFeedback(viemWalletClient, registryAddr, {
|
|
971
|
+
* tag1: "paymentSuccess",
|
|
972
|
+
* includeProofOfPayment: true,
|
|
973
|
+
* }));
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
976
|
+
declare function erc8004SubmitFeedback(writeClient: ERC8004WriteClient, reputationRegistry: Address, config?: FeedbackSubmissionConfig): AfterSettleHook;
|
|
977
|
+
|
|
978
|
+
export { type Address, type AgentIdentity, type AgentRegistry, type AgentRegistryId, type Bytes32, type ERC8004Config, type ERC8004Extension, type ERC8004PayloadExtension, type ERC8004ReadClient, type ERC8004WriteClient, ERC8004_EXTENSION_KEY, FEEDBACK_TAGS, type FeedbackFile, type FeedbackParams, type FeedbackRecord, type FeedbackSubmissionConfig, type Hex, IDENTITY_REGISTRIES, IDENTITY_REGISTRY_DOMAIN, type IdentityCheckOptions, type MetadataEntry, type ProofOfPayment, REPUTATION_REGISTRIES, type RegistrationEntry, type RegistrationFile, type ReputationCheckConfig, type ReputationSummary, type ResolvedAgent, SET_AGENT_WALLET_TYPES, type ServiceEntry, VALIDATION_REGISTRIES, type ValidationRequestParams, type ValidationStatus, type ValidationSummary, buildFeedbackFile, createERC8004PayloadExtension, declareERC8004Extension, erc8004IdentityCheck, erc8004ReputationCheck, erc8004ResourceServerExtension, erc8004ServerIdentityCheck, erc8004SubmitFeedback, fetchRegistrationFile, getAgentIdentity, getERC8004Extension, getReputationSummary, getValidationStatus, getValidationSummary, identityRegistryAbi, parseAgentRegistry, reputationRegistryAbi, resolveAgent, submitFeedback, submitValidationRequest, validationRegistryAbi, verifyAgentIdentity, verifyAgentIdentityFromTask, verifyPayToMatchesAgent };
|