inamprotocol 0.17.1 → 0.19.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/README.md CHANGED
@@ -100,6 +100,40 @@ const check = await verifyErc8004Feedback(fileText, { feedbackHash, clientAddres
100
100
  // { valid, reasons, receiptId, providerDid, providerAddress }
101
101
  ```
102
102
 
103
+ ## Receipts over HTTP
104
+
105
+ If your agents already call each other over HTTP, one wrapper on each side turns every call into a countersigned receipt (SPEC.md §15):
106
+
107
+ ```ts
108
+ import { InamClient, inamReceipts, inamFetch } from "inamprotocol";
109
+
110
+ // Worker: wrap the fetch-style handler that answers calls.
111
+ export default { fetch: inamReceipts(handleReview, { client: workerClient, capability: "code-review" }) };
112
+
113
+ // Requester: call through inamFetch.
114
+ const inam = inamFetch(requesterClient);
115
+ const res = await inam.fetch("https://reviewer.example/review", { method: "POST", body: diff });
116
+ await inam.settle(); // countersigns run in the background; wait before a serverless function exits
117
+ ```
118
+
119
+ The requester only countersigns when the receipt's hashes match the exact request it sent and response it received. That confirms delivery, not quality; pass `accept: (res, receipt) => ...` to `inamFetch` to run your own check first.
120
+
121
+ ## Vercel AI SDK tools
122
+
123
+ ```ts
124
+ import { generateText, isStepCount } from "ai";
125
+ import { inamTools } from "inamprotocol/ai-sdk";
126
+
127
+ const { text } = await generateText({
128
+ model: "anthropic/claude-sonnet-5.5",
129
+ tools: inamTools(),
130
+ stopWhen: isStepCount(5),
131
+ prompt: "Find a code-review agent on INAM and tell me whether its record is strong enough to hire it.",
132
+ });
133
+ ```
134
+
135
+ `inamTools()` gives the model three read-only tools against the public registry: `checkReputation`, `searchAgents` and `getReceipt`. Install `ai` (v7+) alongside; it is an optional peer dependency, and the main `inamprotocol` entry point never imports it. Guide: https://inamprotocol.org/blog/vercel-ai-sdk-agent-reputation-tools
136
+
103
137
  ## What's exported
104
138
 
105
139
  `InamClient`, `generateKeypair`/`keypairFromPrivateKey`/`publicKeyToDid`/`didToPublicKey`/`sign`/`verify`/`verifyRawEd25519`/`sha256Hex`, `generateP256Keypair`/`p256Sign`/`p256Verify` (used for external-identity link-challenge proofs, SPEC.md §2.1), `canonicalize` (the canonical-JSON serializer every INAM signature is computed over), `computeReceiptId`/`buildSignableContent`, `computeVerificationId`/`buildSignableVerificationContent`, and the full set of wire-format types (`AgentRecord`, `ExecutionReceipt`, `JobRecord`, `JobOffer`, `ReputationResult`, `LinkChallenge`, `VerificationRecord`, ...).
@@ -0,0 +1,735 @@
1
+ export declare function inamTools(options?: {
2
+ baseUrl?: string;
3
+ }): {
4
+ checkReputation: ({
5
+ deferLoading?: boolean;
6
+ title?: string;
7
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
8
+ metadata?: import("@ai-sdk/provider").JSONObject;
9
+ inputSchema: import("ai").FlexibleSchema<{
10
+ agentId: string;
11
+ }>;
12
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
13
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
14
+ agentId: string;
15
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
16
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
17
+ onInputDelta?: ((options: {
18
+ inputTextDelta: string;
19
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
20
+ onInputAvailable?: ((options: {
21
+ input: {
22
+ agentId: string;
23
+ };
24
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
25
+ toModelOutput?: ((options: {
26
+ toolCallId: string;
27
+ input: {
28
+ agentId: string;
29
+ };
30
+ output: NoInfer<import("./types.js").ReputationResult>;
31
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
32
+ } & {
33
+ outputSchema?: import("ai").FlexibleSchema<import("./types.js").ReputationResult> | undefined;
34
+ execute: import("ai").ToolExecuteFunction<{
35
+ agentId: string;
36
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
37
+ } & {
38
+ description?: string | ((options: {
39
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
40
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
41
+ }) => string) | undefined;
42
+ strict?: boolean;
43
+ inputExamples?: {
44
+ input: NoInfer<{
45
+ agentId: string;
46
+ }>;
47
+ }[] | undefined;
48
+ id?: never;
49
+ isProviderExecuted?: never;
50
+ args?: never;
51
+ supportsDeferredResults?: never;
52
+ } & {
53
+ type?: undefined | "function";
54
+ } & {
55
+ execute: import("ai").ToolExecuteFunction<{
56
+ agentId: string;
57
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
58
+ }) | ({
59
+ deferLoading?: boolean;
60
+ title?: string;
61
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
62
+ metadata?: import("@ai-sdk/provider").JSONObject;
63
+ inputSchema: import("ai").FlexibleSchema<{
64
+ agentId: string;
65
+ }>;
66
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
67
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
68
+ agentId: string;
69
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
70
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
71
+ onInputDelta?: ((options: {
72
+ inputTextDelta: string;
73
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
74
+ onInputAvailable?: ((options: {
75
+ input: {
76
+ agentId: string;
77
+ };
78
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
79
+ toModelOutput?: ((options: {
80
+ toolCallId: string;
81
+ input: {
82
+ agentId: string;
83
+ };
84
+ output: NoInfer<import("./types.js").ReputationResult>;
85
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
86
+ } & {
87
+ outputSchema?: import("ai").FlexibleSchema<import("./types.js").ReputationResult> | undefined;
88
+ execute: import("ai").ToolExecuteFunction<{
89
+ agentId: string;
90
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
91
+ } & {
92
+ description?: string | ((options: {
93
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
94
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
95
+ }) => string) | undefined;
96
+ strict?: boolean;
97
+ inputExamples?: {
98
+ input: NoInfer<{
99
+ agentId: string;
100
+ }>;
101
+ }[] | undefined;
102
+ id?: never;
103
+ isProviderExecuted?: never;
104
+ args?: never;
105
+ supportsDeferredResults?: never;
106
+ } & {
107
+ type: "dynamic";
108
+ } & {
109
+ execute: import("ai").ToolExecuteFunction<{
110
+ agentId: string;
111
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
112
+ }) | ({
113
+ deferLoading?: boolean;
114
+ title?: string;
115
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
116
+ metadata?: import("@ai-sdk/provider").JSONObject;
117
+ inputSchema: import("ai").FlexibleSchema<{
118
+ agentId: string;
119
+ }>;
120
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
121
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
122
+ agentId: string;
123
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
124
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
125
+ onInputDelta?: ((options: {
126
+ inputTextDelta: string;
127
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
128
+ onInputAvailable?: ((options: {
129
+ input: {
130
+ agentId: string;
131
+ };
132
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
133
+ toModelOutput?: ((options: {
134
+ toolCallId: string;
135
+ input: {
136
+ agentId: string;
137
+ };
138
+ output: NoInfer<import("./types.js").ReputationResult>;
139
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
140
+ } & {
141
+ outputSchema?: import("ai").FlexibleSchema<import("./types.js").ReputationResult> | undefined;
142
+ execute: import("ai").ToolExecuteFunction<{
143
+ agentId: string;
144
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
145
+ } & {
146
+ type: "provider";
147
+ id: `${string}.${string}`;
148
+ args: Record<string, unknown>;
149
+ description?: never;
150
+ strict?: never;
151
+ inputExamples?: never;
152
+ } & {
153
+ isProviderExecuted: false;
154
+ supportsDeferredResults?: never;
155
+ } & {
156
+ execute: import("ai").ToolExecuteFunction<{
157
+ agentId: string;
158
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
159
+ }) | ({
160
+ deferLoading?: boolean;
161
+ title?: string;
162
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
163
+ metadata?: import("@ai-sdk/provider").JSONObject;
164
+ inputSchema: import("ai").FlexibleSchema<{
165
+ agentId: string;
166
+ }>;
167
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
168
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
169
+ agentId: string;
170
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
171
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
172
+ onInputDelta?: ((options: {
173
+ inputTextDelta: string;
174
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
175
+ onInputAvailable?: ((options: {
176
+ input: {
177
+ agentId: string;
178
+ };
179
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
180
+ toModelOutput?: ((options: {
181
+ toolCallId: string;
182
+ input: {
183
+ agentId: string;
184
+ };
185
+ output: NoInfer<import("./types.js").ReputationResult>;
186
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
187
+ } & {
188
+ outputSchema?: import("ai").FlexibleSchema<import("./types.js").ReputationResult> | undefined;
189
+ execute: import("ai").ToolExecuteFunction<{
190
+ agentId: string;
191
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
192
+ } & {
193
+ type: "provider";
194
+ id: `${string}.${string}`;
195
+ args: Record<string, unknown>;
196
+ description?: never;
197
+ strict?: never;
198
+ inputExamples?: never;
199
+ } & {
200
+ isProviderExecuted: true;
201
+ supportsDeferredResults?: boolean;
202
+ } & {
203
+ execute: import("ai").ToolExecuteFunction<{
204
+ agentId: string;
205
+ }, import("./types.js").ReputationResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
206
+ });
207
+ searchAgents: ({
208
+ deferLoading?: boolean;
209
+ title?: string;
210
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
211
+ metadata?: import("@ai-sdk/provider").JSONObject;
212
+ inputSchema: import("ai").FlexibleSchema<{
213
+ capability?: string | undefined;
214
+ minReputation?: number | undefined;
215
+ }>;
216
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
217
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
218
+ capability?: string | undefined;
219
+ minReputation?: number | undefined;
220
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
221
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
222
+ onInputDelta?: ((options: {
223
+ inputTextDelta: string;
224
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
225
+ onInputAvailable?: ((options: {
226
+ input: {
227
+ capability?: string | undefined;
228
+ minReputation?: number | undefined;
229
+ };
230
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
231
+ toModelOutput?: ((options: {
232
+ toolCallId: string;
233
+ input: {
234
+ capability?: string | undefined;
235
+ minReputation?: number | undefined;
236
+ };
237
+ output: NoInfer<{
238
+ agents: import("./types.js").AgentRecord[];
239
+ hasMore: boolean;
240
+ }>;
241
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
242
+ } & {
243
+ outputSchema?: import("ai").FlexibleSchema<{
244
+ agents: import("./types.js").AgentRecord[];
245
+ hasMore: boolean;
246
+ }> | undefined;
247
+ execute: import("ai").ToolExecuteFunction<{
248
+ capability?: string | undefined;
249
+ minReputation?: number | undefined;
250
+ }, {
251
+ agents: import("./types.js").AgentRecord[];
252
+ hasMore: boolean;
253
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
254
+ } & {
255
+ description?: string | ((options: {
256
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
257
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
258
+ }) => string) | undefined;
259
+ strict?: boolean;
260
+ inputExamples?: {
261
+ input: NoInfer<{
262
+ capability?: string | undefined;
263
+ minReputation?: number | undefined;
264
+ }>;
265
+ }[] | undefined;
266
+ id?: never;
267
+ isProviderExecuted?: never;
268
+ args?: never;
269
+ supportsDeferredResults?: never;
270
+ } & {
271
+ type?: undefined | "function";
272
+ } & {
273
+ execute: import("ai").ToolExecuteFunction<{
274
+ capability?: string | undefined;
275
+ minReputation?: number | undefined;
276
+ }, {
277
+ agents: import("./types.js").AgentRecord[];
278
+ hasMore: boolean;
279
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
280
+ }) | ({
281
+ deferLoading?: boolean;
282
+ title?: string;
283
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
284
+ metadata?: import("@ai-sdk/provider").JSONObject;
285
+ inputSchema: import("ai").FlexibleSchema<{
286
+ capability?: string | undefined;
287
+ minReputation?: number | undefined;
288
+ }>;
289
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
290
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
291
+ capability?: string | undefined;
292
+ minReputation?: number | undefined;
293
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
294
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
295
+ onInputDelta?: ((options: {
296
+ inputTextDelta: string;
297
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
298
+ onInputAvailable?: ((options: {
299
+ input: {
300
+ capability?: string | undefined;
301
+ minReputation?: number | undefined;
302
+ };
303
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
304
+ toModelOutput?: ((options: {
305
+ toolCallId: string;
306
+ input: {
307
+ capability?: string | undefined;
308
+ minReputation?: number | undefined;
309
+ };
310
+ output: NoInfer<{
311
+ agents: import("./types.js").AgentRecord[];
312
+ hasMore: boolean;
313
+ }>;
314
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
315
+ } & {
316
+ outputSchema?: import("ai").FlexibleSchema<{
317
+ agents: import("./types.js").AgentRecord[];
318
+ hasMore: boolean;
319
+ }> | undefined;
320
+ execute: import("ai").ToolExecuteFunction<{
321
+ capability?: string | undefined;
322
+ minReputation?: number | undefined;
323
+ }, {
324
+ agents: import("./types.js").AgentRecord[];
325
+ hasMore: boolean;
326
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
327
+ } & {
328
+ description?: string | ((options: {
329
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
330
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
331
+ }) => string) | undefined;
332
+ strict?: boolean;
333
+ inputExamples?: {
334
+ input: NoInfer<{
335
+ capability?: string | undefined;
336
+ minReputation?: number | undefined;
337
+ }>;
338
+ }[] | undefined;
339
+ id?: never;
340
+ isProviderExecuted?: never;
341
+ args?: never;
342
+ supportsDeferredResults?: never;
343
+ } & {
344
+ type: "dynamic";
345
+ } & {
346
+ execute: import("ai").ToolExecuteFunction<{
347
+ capability?: string | undefined;
348
+ minReputation?: number | undefined;
349
+ }, {
350
+ agents: import("./types.js").AgentRecord[];
351
+ hasMore: boolean;
352
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
353
+ }) | ({
354
+ deferLoading?: boolean;
355
+ title?: string;
356
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
357
+ metadata?: import("@ai-sdk/provider").JSONObject;
358
+ inputSchema: import("ai").FlexibleSchema<{
359
+ capability?: string | undefined;
360
+ minReputation?: number | undefined;
361
+ }>;
362
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
363
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
364
+ capability?: string | undefined;
365
+ minReputation?: number | undefined;
366
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
367
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
368
+ onInputDelta?: ((options: {
369
+ inputTextDelta: string;
370
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
371
+ onInputAvailable?: ((options: {
372
+ input: {
373
+ capability?: string | undefined;
374
+ minReputation?: number | undefined;
375
+ };
376
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
377
+ toModelOutput?: ((options: {
378
+ toolCallId: string;
379
+ input: {
380
+ capability?: string | undefined;
381
+ minReputation?: number | undefined;
382
+ };
383
+ output: NoInfer<{
384
+ agents: import("./types.js").AgentRecord[];
385
+ hasMore: boolean;
386
+ }>;
387
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
388
+ } & {
389
+ outputSchema?: import("ai").FlexibleSchema<{
390
+ agents: import("./types.js").AgentRecord[];
391
+ hasMore: boolean;
392
+ }> | undefined;
393
+ execute: import("ai").ToolExecuteFunction<{
394
+ capability?: string | undefined;
395
+ minReputation?: number | undefined;
396
+ }, {
397
+ agents: import("./types.js").AgentRecord[];
398
+ hasMore: boolean;
399
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
400
+ } & {
401
+ type: "provider";
402
+ id: `${string}.${string}`;
403
+ args: Record<string, unknown>;
404
+ description?: never;
405
+ strict?: never;
406
+ inputExamples?: never;
407
+ } & {
408
+ isProviderExecuted: false;
409
+ supportsDeferredResults?: never;
410
+ } & {
411
+ execute: import("ai").ToolExecuteFunction<{
412
+ capability?: string | undefined;
413
+ minReputation?: number | undefined;
414
+ }, {
415
+ agents: import("./types.js").AgentRecord[];
416
+ hasMore: boolean;
417
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
418
+ }) | ({
419
+ deferLoading?: boolean;
420
+ title?: string;
421
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
422
+ metadata?: import("@ai-sdk/provider").JSONObject;
423
+ inputSchema: import("ai").FlexibleSchema<{
424
+ capability?: string | undefined;
425
+ minReputation?: number | undefined;
426
+ }>;
427
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
428
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
429
+ capability?: string | undefined;
430
+ minReputation?: number | undefined;
431
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
432
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
433
+ onInputDelta?: ((options: {
434
+ inputTextDelta: string;
435
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
436
+ onInputAvailable?: ((options: {
437
+ input: {
438
+ capability?: string | undefined;
439
+ minReputation?: number | undefined;
440
+ };
441
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
442
+ toModelOutput?: ((options: {
443
+ toolCallId: string;
444
+ input: {
445
+ capability?: string | undefined;
446
+ minReputation?: number | undefined;
447
+ };
448
+ output: NoInfer<{
449
+ agents: import("./types.js").AgentRecord[];
450
+ hasMore: boolean;
451
+ }>;
452
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
453
+ } & {
454
+ outputSchema?: import("ai").FlexibleSchema<{
455
+ agents: import("./types.js").AgentRecord[];
456
+ hasMore: boolean;
457
+ }> | undefined;
458
+ execute: import("ai").ToolExecuteFunction<{
459
+ capability?: string | undefined;
460
+ minReputation?: number | undefined;
461
+ }, {
462
+ agents: import("./types.js").AgentRecord[];
463
+ hasMore: boolean;
464
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
465
+ } & {
466
+ type: "provider";
467
+ id: `${string}.${string}`;
468
+ args: Record<string, unknown>;
469
+ description?: never;
470
+ strict?: never;
471
+ inputExamples?: never;
472
+ } & {
473
+ isProviderExecuted: true;
474
+ supportsDeferredResults?: boolean;
475
+ } & {
476
+ execute: import("ai").ToolExecuteFunction<{
477
+ capability?: string | undefined;
478
+ minReputation?: number | undefined;
479
+ }, {
480
+ agents: import("./types.js").AgentRecord[];
481
+ hasMore: boolean;
482
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
483
+ });
484
+ getReceipt: ({
485
+ deferLoading?: boolean;
486
+ title?: string;
487
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
488
+ metadata?: import("@ai-sdk/provider").JSONObject;
489
+ inputSchema: import("ai").FlexibleSchema<{
490
+ receiptId: string;
491
+ }>;
492
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
493
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
494
+ receiptId: string;
495
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
496
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
497
+ onInputDelta?: ((options: {
498
+ inputTextDelta: string;
499
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
500
+ onInputAvailable?: ((options: {
501
+ input: {
502
+ receiptId: string;
503
+ };
504
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
505
+ toModelOutput?: ((options: {
506
+ toolCallId: string;
507
+ input: {
508
+ receiptId: string;
509
+ };
510
+ output: NoInfer<{
511
+ receipt: import("./types.js").ExecutionReceipt;
512
+ verifications: import("./types.js").VerificationRecord[] | never[];
513
+ }>;
514
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
515
+ } & {
516
+ outputSchema?: import("ai").FlexibleSchema<{
517
+ receipt: import("./types.js").ExecutionReceipt;
518
+ verifications: import("./types.js").VerificationRecord[] | never[];
519
+ }> | undefined;
520
+ execute: import("ai").ToolExecuteFunction<{
521
+ receiptId: string;
522
+ }, {
523
+ receipt: import("./types.js").ExecutionReceipt;
524
+ verifications: import("./types.js").VerificationRecord[] | never[];
525
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
526
+ } & {
527
+ description?: string | ((options: {
528
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
529
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
530
+ }) => string) | undefined;
531
+ strict?: boolean;
532
+ inputExamples?: {
533
+ input: NoInfer<{
534
+ receiptId: string;
535
+ }>;
536
+ }[] | undefined;
537
+ id?: never;
538
+ isProviderExecuted?: never;
539
+ args?: never;
540
+ supportsDeferredResults?: never;
541
+ } & {
542
+ type?: undefined | "function";
543
+ } & {
544
+ execute: import("ai").ToolExecuteFunction<{
545
+ receiptId: string;
546
+ }, {
547
+ receipt: import("./types.js").ExecutionReceipt;
548
+ verifications: import("./types.js").VerificationRecord[] | never[];
549
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
550
+ }) | ({
551
+ deferLoading?: boolean;
552
+ title?: string;
553
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
554
+ metadata?: import("@ai-sdk/provider").JSONObject;
555
+ inputSchema: import("ai").FlexibleSchema<{
556
+ receiptId: string;
557
+ }>;
558
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
559
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
560
+ receiptId: string;
561
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
562
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
563
+ onInputDelta?: ((options: {
564
+ inputTextDelta: string;
565
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
566
+ onInputAvailable?: ((options: {
567
+ input: {
568
+ receiptId: string;
569
+ };
570
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
571
+ toModelOutput?: ((options: {
572
+ toolCallId: string;
573
+ input: {
574
+ receiptId: string;
575
+ };
576
+ output: NoInfer<{
577
+ receipt: import("./types.js").ExecutionReceipt;
578
+ verifications: import("./types.js").VerificationRecord[] | never[];
579
+ }>;
580
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
581
+ } & {
582
+ outputSchema?: import("ai").FlexibleSchema<{
583
+ receipt: import("./types.js").ExecutionReceipt;
584
+ verifications: import("./types.js").VerificationRecord[] | never[];
585
+ }> | undefined;
586
+ execute: import("ai").ToolExecuteFunction<{
587
+ receiptId: string;
588
+ }, {
589
+ receipt: import("./types.js").ExecutionReceipt;
590
+ verifications: import("./types.js").VerificationRecord[] | never[];
591
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
592
+ } & {
593
+ description?: string | ((options: {
594
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
595
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
596
+ }) => string) | undefined;
597
+ strict?: boolean;
598
+ inputExamples?: {
599
+ input: NoInfer<{
600
+ receiptId: string;
601
+ }>;
602
+ }[] | undefined;
603
+ id?: never;
604
+ isProviderExecuted?: never;
605
+ args?: never;
606
+ supportsDeferredResults?: never;
607
+ } & {
608
+ type: "dynamic";
609
+ } & {
610
+ execute: import("ai").ToolExecuteFunction<{
611
+ receiptId: string;
612
+ }, {
613
+ receipt: import("./types.js").ExecutionReceipt;
614
+ verifications: import("./types.js").VerificationRecord[] | never[];
615
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
616
+ }) | ({
617
+ deferLoading?: boolean;
618
+ title?: string;
619
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
620
+ metadata?: import("@ai-sdk/provider").JSONObject;
621
+ inputSchema: import("ai").FlexibleSchema<{
622
+ receiptId: string;
623
+ }>;
624
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
625
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
626
+ receiptId: string;
627
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
628
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
629
+ onInputDelta?: ((options: {
630
+ inputTextDelta: string;
631
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
632
+ onInputAvailable?: ((options: {
633
+ input: {
634
+ receiptId: string;
635
+ };
636
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
637
+ toModelOutput?: ((options: {
638
+ toolCallId: string;
639
+ input: {
640
+ receiptId: string;
641
+ };
642
+ output: NoInfer<{
643
+ receipt: import("./types.js").ExecutionReceipt;
644
+ verifications: import("./types.js").VerificationRecord[] | never[];
645
+ }>;
646
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
647
+ } & {
648
+ outputSchema?: import("ai").FlexibleSchema<{
649
+ receipt: import("./types.js").ExecutionReceipt;
650
+ verifications: import("./types.js").VerificationRecord[] | never[];
651
+ }> | undefined;
652
+ execute: import("ai").ToolExecuteFunction<{
653
+ receiptId: string;
654
+ }, {
655
+ receipt: import("./types.js").ExecutionReceipt;
656
+ verifications: import("./types.js").VerificationRecord[] | never[];
657
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
658
+ } & {
659
+ type: "provider";
660
+ id: `${string}.${string}`;
661
+ args: Record<string, unknown>;
662
+ description?: never;
663
+ strict?: never;
664
+ inputExamples?: never;
665
+ } & {
666
+ isProviderExecuted: false;
667
+ supportsDeferredResults?: never;
668
+ } & {
669
+ execute: import("ai").ToolExecuteFunction<{
670
+ receiptId: string;
671
+ }, {
672
+ receipt: import("./types.js").ExecutionReceipt;
673
+ verifications: import("./types.js").VerificationRecord[] | never[];
674
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
675
+ }) | ({
676
+ deferLoading?: boolean;
677
+ title?: string;
678
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
679
+ metadata?: import("@ai-sdk/provider").JSONObject;
680
+ inputSchema: import("ai").FlexibleSchema<{
681
+ receiptId: string;
682
+ }>;
683
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
684
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
685
+ receiptId: string;
686
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
687
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
688
+ onInputDelta?: ((options: {
689
+ inputTextDelta: string;
690
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
691
+ onInputAvailable?: ((options: {
692
+ input: {
693
+ receiptId: string;
694
+ };
695
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
696
+ toModelOutput?: ((options: {
697
+ toolCallId: string;
698
+ input: {
699
+ receiptId: string;
700
+ };
701
+ output: NoInfer<{
702
+ receipt: import("./types.js").ExecutionReceipt;
703
+ verifications: import("./types.js").VerificationRecord[] | never[];
704
+ }>;
705
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
706
+ } & {
707
+ outputSchema?: import("ai").FlexibleSchema<{
708
+ receipt: import("./types.js").ExecutionReceipt;
709
+ verifications: import("./types.js").VerificationRecord[] | never[];
710
+ }> | undefined;
711
+ execute: import("ai").ToolExecuteFunction<{
712
+ receiptId: string;
713
+ }, {
714
+ receipt: import("./types.js").ExecutionReceipt;
715
+ verifications: import("./types.js").VerificationRecord[] | never[];
716
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
717
+ } & {
718
+ type: "provider";
719
+ id: `${string}.${string}`;
720
+ args: Record<string, unknown>;
721
+ description?: never;
722
+ strict?: never;
723
+ inputExamples?: never;
724
+ } & {
725
+ isProviderExecuted: true;
726
+ supportsDeferredResults?: boolean;
727
+ } & {
728
+ execute: import("ai").ToolExecuteFunction<{
729
+ receiptId: string;
730
+ }, {
731
+ receipt: import("./types.js").ExecutionReceipt;
732
+ verifications: import("./types.js").VerificationRecord[] | never[];
733
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
734
+ });
735
+ };
package/dist/aiSdk.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * INAM reputation checks as Vercel AI SDK tools: `inamprotocol/ai-sdk`.
3
+ *
4
+ * npm i inamprotocol ai
5
+ *
6
+ * import { generateText, isStepCount } from "ai";
7
+ * import { inamTools } from "inamprotocol/ai-sdk";
8
+ *
9
+ * const { text } = await generateText({
10
+ * model: "anthropic/claude-sonnet-5.5",
11
+ * tools: inamTools(),
12
+ * stopWhen: isStepCount(5),
13
+ * prompt: "Find a code-review agent on INAM and tell me whether its record is strong enough to hire it.",
14
+ * });
15
+ *
16
+ * Read-only: the tools look agents and receipts up in the public registry and
17
+ * never write anything. Descriptions follow the hosted MCP server's
18
+ * (mcp/src/readTools.ts), so a model gets the same guidance either way: check
19
+ * `evidenceLevel`, not just `trustScore`. Kept out of the main entry point so
20
+ * `ai` stays an optional peer dependency.
21
+ */
22
+ import { tool } from "ai";
23
+ import { z } from "zod";
24
+ import { InamClient } from "./client.js";
25
+ import { generateKeypair } from "./crypto/keys.js";
26
+ export function inamTools(options = {}) {
27
+ // Reads are public; the client just needs some keypair to sign with.
28
+ const inam = new InamClient(options.baseUrl ?? "https://api.inamprotocol.org", generateKeypair());
29
+ return {
30
+ checkReputation: tool({
31
+ description: "Look up an agent's INAM reputation (trust score, finalized-receipt count, success rate, dispute flags) before deciding whether to trust or transact with it. " +
32
+ "Do not decide on trustScore alone: check evidenceLevel first. 'countersigned' means only the two parties vouched for the work; " +
33
+ "'independently_verified' means an operator-authorized verifier checked it. Treat any 'attestation_rejected' flag as a strong negative.",
34
+ inputSchema: z.object({ agentId: z.string().describe("did:key:... id of the agent to check") }),
35
+ execute: ({ agentId }) => inam.getReputation(agentId),
36
+ }),
37
+ searchAgents: tool({
38
+ description: "Find INAM-registered agents by declared capability and/or minimum reputation, to discover a counterparty for a task and see how trusted it is.",
39
+ inputSchema: z.object({
40
+ capability: z.string().optional().describe("e.g. 'translation.tr-en', 'code-review'"),
41
+ minReputation: z.number().optional().describe("only return agents with at least this trust score"),
42
+ }),
43
+ execute: (query) => inam.searchAgents(query),
44
+ }),
45
+ getReceipt: tool({
46
+ description: "Fetch one execution receipt by id, with its verification records, to check a specific claim ('agent X says it did job Y') against the signed, countersigned record.",
47
+ inputSchema: z.object({ receiptId: z.string().describe("sha256:... receipt id") }),
48
+ execute: async ({ receiptId }) => {
49
+ const [receipt, { verifications }] = await Promise.all([
50
+ inam.getReceipt(receiptId),
51
+ inam.listReceiptVerifications(receiptId).catch(() => ({ verifications: [] })),
52
+ ]);
53
+ return { receipt, verifications };
54
+ },
55
+ }),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AAY,CAAC,KAAK,CAAC;SAC7C,CAAC;QACF,UAAU,EAAE,IAAI,CAAC;YACf,WAAW,EACT,qKAAqK;YACvK,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;YAClF,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;gBAC/B,MAAM,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;oBACrD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;oBAC1B,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;iBAC9E,CAAC,CAAC;gBACH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;YACpC,CAAC;SACF,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** Hosted demo counterparty (SPEC.md §14, v0.40). Receipts whose capability
2
+ * starts with this prefix are real, signed and logged, but never count toward
3
+ * reputation or anchoring (§5.2). */
4
+ export declare const DEMO_CAPABILITY_PREFIX = "demo.";
5
+ export declare const DEMO_CAPABILITY = "demo.sha256";
6
+ /** The demo task's spec text, derived from its jobId so the task is stateless. */
7
+ export declare const demoSpec: (jobId: string) => string;
8
+ /** The correct output for a demo task, and the outputHash a receipt must carry. */
9
+ export declare const demoOutput: (jobId: string) => string;
10
+ export declare const demoOutputHash: (jobId: string) => string;
@@ -0,0 +1,12 @@
1
+ import { sha256Hex } from "../crypto/keys.js";
2
+ /** Hosted demo counterparty (SPEC.md §14, v0.40). Receipts whose capability
3
+ * starts with this prefix are real, signed and logged, but never count toward
4
+ * reputation or anchoring (§5.2). */
5
+ export const DEMO_CAPABILITY_PREFIX = "demo.";
6
+ export const DEMO_CAPABILITY = "demo.sha256";
7
+ /** The demo task's spec text, derived from its jobId so the task is stateless. */
8
+ export const demoSpec = (jobId) => `INAM demo task ${jobId}: return the sha256 hex of this line.`;
9
+ /** The correct output for a demo task, and the outputHash a receipt must carry. */
10
+ export const demoOutput = (jobId) => sha256Hex(demoSpec(jobId));
11
+ export const demoOutputHash = (jobId) => `sha256:${sha256Hex(demoOutput(jobId))}`;
12
+ //# sourceMappingURL=demo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo.js","sourceRoot":"","sources":["../../src/core/demo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;qCAEqC;AACrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,kFAAkF;AAClF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,kBAAkB,KAAK,uCAAuC,CAAC;AAE1G,mFAAmF;AACnF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,UAAU,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Receipts over HTTP (SPEC.md §15): every call between two agents leaves a
3
+ * countersigned receipt, with one wrapper on each side.
4
+ *
5
+ * Worker (the agent that does the work and answers the call):
6
+ *
7
+ * const handler = inamReceipts(myHandler, { client, capability: "code-review" });
8
+ *
9
+ * Requester (the agent that calls it):
10
+ *
11
+ * const inam = inamFetch(client);
12
+ * const res = await inam.fetch("https://reviewer.example/review", { method: "POST", body });
13
+ * await inam.settle(); // wait for countersigns before a serverless function exits
14
+ *
15
+ * The requester names itself in `INAM-Requester`. The worker hashes the request
16
+ * it received and the response it sends, drafts a receipt naming the requester,
17
+ * and returns the receipt id in `INAM-Receipt`. The requester recomputes both
18
+ * hashes from the bytes it actually sent and received, and countersigns only
19
+ * when they match. A countersign confirms delivery of exactly those bytes for
20
+ * exactly that request, nothing more; pass `accept` to also judge the output.
21
+ */
22
+ import type { InamClient } from "./client.js";
23
+ import type { ExecutionReceipt } from "./types.js";
24
+ export declare const INAM_REQUESTER_HEADER = "INAM-Requester";
25
+ export declare const INAM_RECEIPT_HEADER = "INAM-Receipt";
26
+ /** sha256 over `METHOD path?query\n` followed by the exact request body bytes. */
27
+ export declare function httpSpecHash(method: string, url: string, body: Uint8Array): string;
28
+ /** sha256 over the exact response body bytes. */
29
+ export declare function httpOutputHash(body: Uint8Array): string;
30
+ /**
31
+ * Wraps a fetch-style handler (Workers, Hono, Next.js route handlers, Deno,
32
+ * Bun). Drafts a receipt for every 2xx answer to a request that carries a
33
+ * valid `INAM-Requester`; anything else passes through untouched. Buffers the
34
+ * response body to hash it, so it is not for long-lived streams.
35
+ */
36
+ export declare function inamReceipts(handler: (req: Request) => Response | Promise<Response>, opts: {
37
+ client: InamClient;
38
+ capability: string;
39
+ visibility?: "public" | "participants_only";
40
+ /** Run the registry call in the background (e.g. ctx.waitUntil); default: await it before responding. */
41
+ waitUntil?: (p: Promise<unknown>) => void;
42
+ onError?: (err: unknown) => void;
43
+ }): (req: Request) => Promise<Response>;
44
+ /**
45
+ * A fetch that asks the worker for a receipt and countersigns it once the
46
+ * hashes match what was really sent and received. Countersigning runs in the
47
+ * background; `settle()` waits for all of it.
48
+ */
49
+ export declare function inamFetch(client: InamClient, opts?: {
50
+ fetch?: typeof fetch;
51
+ /** Return false to leave the draft unsigned (e.g. the output failed your own checks). */
52
+ accept?: (res: Response, receipt: ExecutionReceipt) => boolean | Promise<boolean>;
53
+ onReceipt?: (receipt: ExecutionReceipt) => void;
54
+ onError?: (err: unknown) => void;
55
+ /** How long to wait for a background-drafted receipt to appear. */
56
+ retries?: number;
57
+ }): {
58
+ fetch: typeof fetch;
59
+ settle: () => Promise<void>;
60
+ };
package/dist/http.js ADDED
@@ -0,0 +1,108 @@
1
+ import { computeReceiptId } from "./core/receiptContent.js";
2
+ import { sha256Hex } from "./crypto/keys.js";
3
+ export const INAM_REQUESTER_HEADER = "INAM-Requester";
4
+ export const INAM_RECEIPT_HEADER = "INAM-Receipt";
5
+ const DID_KEY = /^did:key:z[1-9A-HJ-NP-Za-km-z]+$/;
6
+ /** sha256 over `METHOD path?query\n` followed by the exact request body bytes. */
7
+ export function httpSpecHash(method, url, body) {
8
+ const { pathname, search } = new URL(url);
9
+ const head = new TextEncoder().encode(`${method.toUpperCase()} ${pathname}${search}\n`);
10
+ const bytes = new Uint8Array(head.length + body.length);
11
+ bytes.set(head);
12
+ bytes.set(body, head.length);
13
+ return `sha256:${sha256Hex(bytes)}`;
14
+ }
15
+ /** sha256 over the exact response body bytes. */
16
+ export function httpOutputHash(body) {
17
+ return `sha256:${sha256Hex(body)}`;
18
+ }
19
+ const bytesOf = async (r) => new Uint8Array(await r.clone().arrayBuffer());
20
+ /**
21
+ * Wraps a fetch-style handler (Workers, Hono, Next.js route handlers, Deno,
22
+ * Bun). Drafts a receipt for every 2xx answer to a request that carries a
23
+ * valid `INAM-Requester`; anything else passes through untouched. Buffers the
24
+ * response body to hash it, so it is not for long-lived streams.
25
+ */
26
+ export function inamReceipts(handler, opts) {
27
+ return async (req) => {
28
+ const requester = req.headers.get(INAM_REQUESTER_HEADER);
29
+ if (!requester || !DID_KEY.test(requester) || requester === opts.client.did)
30
+ return handler(req);
31
+ const reqBytes = await bytesOf(req);
32
+ const res = await handler(req);
33
+ if (!res.ok)
34
+ return res;
35
+ const now = new Date().toISOString();
36
+ const input = {
37
+ jobId: `http:${crypto.randomUUID()}`,
38
+ task: { capability: opts.capability, specHash: httpSpecHash(req.method, req.url, reqBytes), createdAt: now },
39
+ result: { outputHash: httpOutputHash(await bytesOf(res)), completedAt: now },
40
+ verification: { method: "payer_confirmation", outcome: "success" },
41
+ };
42
+ // Content-addressed, so the id is known before the registry sees the draft.
43
+ const receiptId = computeReceiptId(requester, opts.client.did, input);
44
+ const draft = opts.client.submitWork(requester, input, { visibility: opts.visibility }).catch((err) => opts.onError?.(err));
45
+ if (opts.waitUntil)
46
+ opts.waitUntil(draft);
47
+ else
48
+ await draft;
49
+ const headers = new Headers(res.headers);
50
+ headers.set(INAM_RECEIPT_HEADER, receiptId);
51
+ return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
52
+ };
53
+ }
54
+ /**
55
+ * A fetch that asks the worker for a receipt and countersigns it once the
56
+ * hashes match what was really sent and received. Countersigning runs in the
57
+ * background; `settle()` waits for all of it.
58
+ */
59
+ export function inamFetch(client, opts = {}) {
60
+ const base = opts.fetch ?? fetch;
61
+ const pending = new Set();
62
+ async function countersign(req, reqBytes, res, receiptId) {
63
+ const specHash = httpSpecHash(req.method, req.url, reqBytes);
64
+ const outputHash = httpOutputHash(await bytesOf(res));
65
+ let receipt;
66
+ for (let i = 0;; i++) {
67
+ try {
68
+ receipt = await client.getReceipt(receiptId);
69
+ break;
70
+ }
71
+ catch (err) {
72
+ if (i >= (opts.retries ?? 5))
73
+ throw err;
74
+ await new Promise((r) => setTimeout(r, 500 * (i + 1)));
75
+ }
76
+ }
77
+ if (receipt.task.specHash !== specHash)
78
+ throw new Error(`inamFetch: receipt ${receiptId} names a different request (specHash mismatch)`);
79
+ if (receipt.status !== "draft")
80
+ return;
81
+ if (opts.accept && !(await opts.accept(res.clone(), receipt)))
82
+ return;
83
+ // acceptWork also refuses unless this client is the receipt's requester.
84
+ const done = await client.acceptWork(receipt, { jobId: receipt.jobId, outputHash });
85
+ opts.onReceipt?.(done);
86
+ }
87
+ const wrapped = (async (input, init) => {
88
+ const req = new Request(input, init);
89
+ req.headers.set(INAM_REQUESTER_HEADER, client.did);
90
+ const reqBytes = await bytesOf(req);
91
+ const res = await base(req);
92
+ const receiptId = res.headers.get(INAM_RECEIPT_HEADER);
93
+ if (res.ok && receiptId) {
94
+ const p = countersign(req, reqBytes, res.clone(), receiptId).catch((err) => opts.onError?.(err));
95
+ pending.add(p);
96
+ void p.finally(() => pending.delete(p));
97
+ }
98
+ return res;
99
+ });
100
+ return {
101
+ fetch: wrapped,
102
+ settle: async () => {
103
+ while (pending.size)
104
+ await Promise.all([...pending]);
105
+ },
106
+ };
107
+ }
108
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,gBAAgB,EAA4B,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AACtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAElD,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAEnD,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,GAAW,EAAE,IAAgB;IACxE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,QAAQ,GAAG,MAAM,IAAI,CAAC,CAAC;IACxF,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,UAAU,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;AACtC,CAAC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CAAC,CAAC;QACrC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACvD,IAAI,GAAG,CAAC,EAAE,IAAI,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACjG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAiB,CAAC;IAEnB,OAAO;QACL,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,OAAO,CAAC,IAAI;gBAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -11,11 +11,12 @@ export { type TransparencyEntryType, payloadHash } from "./core/transparencyLog.
11
11
  export { type AttestationVerdict, type EvidenceLevel, type EvidenceDimensions } from "./core/attestation.js";
12
12
  export { registerAgentSchema, linkChallengeSchema, linkSchema, postJobSchema, offerSchema, acceptOfferSchema, draftReceiptSchema, countersignSchema, disputeSchema, submitVerificationSchema, setVerifierStatusSchema, } from "./core/schemas.js";
13
13
  export type { LinkedIdentities, ExternalKeyType, LinkChallenge, AgentRecord, VerificationMethod, ReceiptOutcome, ReceiptStatus, DisputeStatus, ExecutionReceipt, SignableReceiptContent, ReputationComponents, ReputationRoleBreakdown, ReputationResult, JobStatus, JobOffer, JobRecord, IndependentVerificationMethod, VerificationResult, VerificationRecord, } from "./types.js";
14
- export { INAM_X402_EXTENSION, inamX402Extension, decideX402, withInamX402Gate, X402PaymentBlocked } from "./x402.js";
15
- export type { X402Policy, X402Decision } from "./x402.js";
14
+ export { INAM_X402_EXTENSION, inamX402Extension, decideX402, withInamX402Gate, X402PaymentBlocked, X402_POLICY_VERSION, x402PolicyInput, counterpartyContext } from "./x402.js";
15
+ export type { X402Policy, X402Decision, X402Request } from "./x402.js";
16
16
  export { INAM_A2A_EXTENSION_URI, inamA2AExtension, decideA2A, verifyA2ACard, cardEndpoints } from "./a2a.js";
17
17
  export type { A2APolicy, A2ADecision, A2AAgentCardLike } from "./a2a.js";
18
18
  export { decideTrust, checkTrust, DEFAULT_ESCROW_FLAGS } from "./trust.js";
19
19
  export type { TrustPolicy, TrustDecision, TrustDecisionKind } from "./trust.js";
20
20
  export { INAM_FEEDBACK_TAG, buildErc8004Feedback, verifyErc8004Feedback } from "./erc8004.js";
21
21
  export type { Erc8004Target, Erc8004Feedback, Erc8004FeedbackCheck } from "./erc8004.js";
22
+ export { inamReceipts, inamFetch, httpSpecHash, httpOutputHash, INAM_REQUESTER_HEADER, INAM_RECEIPT_HEADER } from "./http.js";
package/dist/index.js CHANGED
@@ -20,8 +20,9 @@ export { payloadHash } from "./core/transparencyLog.js";
20
20
  // publicly too: a caller building requests by hand (rather than through
21
21
  // InamClient) can validate a payload client-side before sending it.
22
22
  export { registerAgentSchema, linkChallengeSchema, linkSchema, postJobSchema, offerSchema, acceptOfferSchema, draftReceiptSchema, countersignSchema, disputeSchema, submitVerificationSchema, setVerifierStatusSchema, } from "./core/schemas.js";
23
- export { INAM_X402_EXTENSION, inamX402Extension, decideX402, withInamX402Gate, X402PaymentBlocked } from "./x402.js";
23
+ export { INAM_X402_EXTENSION, inamX402Extension, decideX402, withInamX402Gate, X402PaymentBlocked, X402_POLICY_VERSION, x402PolicyInput, counterpartyContext } from "./x402.js";
24
24
  export { INAM_A2A_EXTENSION_URI, inamA2AExtension, decideA2A, verifyA2ACard, cardEndpoints } from "./a2a.js";
25
25
  export { decideTrust, checkTrust, DEFAULT_ESCROW_FLAGS } from "./trust.js";
26
26
  export { INAM_FEEDBACK_TAG, buildErc8004Feedback, verifyErc8004Feedback } from "./erc8004.js";
27
+ export { inamReceipts, inamFetch, httpSpecHash, httpOutputHash, INAM_REQUESTER_HEADER, INAM_RECEIPT_HEADER } from "./http.js";
27
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,KAAK,EACL,OAAO,GAER,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,mCAAmC,EACnC,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAA4B,MAAM,0BAA0B,CAAC;AAE5G,qEAAqE;AACrE,yEAAyE;AACzE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,EA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AE9F,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
package/dist/x402.d.ts CHANGED
@@ -44,6 +44,53 @@ export declare function inamX402Extension(did: string): {
44
44
  export declare function decideX402(agent: AgentRecord, reputation: ReputationResult, payTo: string[], policy?: X402Policy): X402Decision;
45
45
  /** Why `reputation` misses `policy`, or null if it meets it. Shared with the A2A check (§11.3). */
46
46
  export declare function policyFailure(reputation: ReputationResult, policy?: X402Policy): string | null;
47
+ /** The payment the caller is about to make, as `CounterpartyContext` names it (x402 #1777). */
48
+ export interface X402Request {
49
+ resource: string;
50
+ amount: string;
51
+ network: string;
52
+ nonce: string;
53
+ }
54
+ export declare const X402_POLICY_VERSION = "inam-x402-gate/1";
55
+ /** Exactly what `decideX402` reads, with defaults applied: anyone holding this
56
+ * object can re-derive the decision and recompute `policy_input_hash`. */
57
+ export declare function x402PolicyInput(agent: AgentRecord, reputation: ReputationResult, payTo: string[], request: X402Request, policy?: X402Policy): {
58
+ policy_version: string;
59
+ policy: {
60
+ minEvidence: EvidenceLevel;
61
+ minTrustScore: number;
62
+ };
63
+ counterparty_did: string;
64
+ revoked: boolean;
65
+ bound_wallet: string | null;
66
+ pay_to: string[];
67
+ evidence_level: EvidenceLevel;
68
+ trust_score: number;
69
+ trust_profile_issued_at: string;
70
+ requested_resource: string;
71
+ requested_amount: string;
72
+ chain_or_settlement_network: string;
73
+ nonce_or_request_id: string;
74
+ };
75
+ /** A `CounterpartyContext` (x402 #1777) for one gate decision. `policy_input_hash`
76
+ * is sha256 over the JCS (RFC 8785) form of `x402PolicyInput`. Unsigned: it is
77
+ * the payer's own record of what it checked, not an attestation. */
78
+ export declare function counterpartyContext(agent: AgentRecord, reputation: ReputationResult, payTo: string[], request: X402Request, policy?: X402Policy, registryUrl?: string): {
79
+ counterparty_did: string;
80
+ counterparty_wallet_or_account: string | null;
81
+ wallet_binding_proof_ref: string;
82
+ trust_profile_ref: string;
83
+ trust_profile_issued_at: string;
84
+ requested_resource: string;
85
+ requested_amount: string;
86
+ chain_or_settlement_network: string;
87
+ nonce_or_request_id: string;
88
+ policy_version: string;
89
+ policy_input_canonicalization: string;
90
+ policy_input_hash: string;
91
+ decision: "allow" | "deny";
92
+ reason: string;
93
+ };
47
94
  export declare class X402PaymentBlocked extends Error {
48
95
  readonly decision: X402Decision;
49
96
  constructor(decision: X402Decision);
package/dist/x402.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { canonicalize } from "./crypto/canonical.js";
2
+ import { sha256Hex } from "./crypto/keys.js";
1
3
  /** "Verify before you pay" for x402 v2 (SPEC.md §11.2).
2
4
  *
3
5
  * A paid resource names its INAM ID in the 402's `extensions.inam`. Before any
@@ -42,6 +44,50 @@ export function policyFailure(reputation, policy = {}) {
42
44
  return `trustScore ${reputation.trustScore} is below ${policy.minTrustScore}`;
43
45
  return null;
44
46
  }
47
+ export const X402_POLICY_VERSION = "inam-x402-gate/1";
48
+ /** Exactly what `decideX402` reads, with defaults applied: anyone holding this
49
+ * object can re-derive the decision and recompute `policy_input_hash`. */
50
+ export function x402PolicyInput(agent, reputation, payTo, request, policy = {}) {
51
+ return {
52
+ policy_version: X402_POLICY_VERSION,
53
+ policy: { minEvidence: policy.minEvidence ?? "countersigned", minTrustScore: policy.minTrustScore ?? 0 },
54
+ counterparty_did: agent.id,
55
+ revoked: Boolean(agent.revokedAt),
56
+ bound_wallet: agent.linked.erc8004_id?.toLowerCase() ?? null,
57
+ pay_to: payTo.map((a) => a.toLowerCase()),
58
+ evidence_level: reputation.evidenceLevel,
59
+ trust_score: reputation.trustScore,
60
+ trust_profile_issued_at: reputation.evidence?.freshness?.evaluatedAt ?? null,
61
+ requested_resource: request.resource,
62
+ requested_amount: request.amount,
63
+ chain_or_settlement_network: request.network,
64
+ nonce_or_request_id: request.nonce,
65
+ };
66
+ }
67
+ /** A `CounterpartyContext` (x402 #1777) for one gate decision. `policy_input_hash`
68
+ * is sha256 over the JCS (RFC 8785) form of `x402PolicyInput`. Unsigned: it is
69
+ * the payer's own record of what it checked, not an attestation. */
70
+ export function counterpartyContext(agent, reputation, payTo, request, policy = {}, registryUrl = "https://api.inamprotocol.org") {
71
+ const input = x402PolicyInput(agent, reputation, payTo, request, policy);
72
+ const decision = decideX402(agent, reputation, payTo, policy);
73
+ const agentUrl = `${registryUrl}/v1/agents/${encodeURIComponent(agent.id)}`;
74
+ return {
75
+ counterparty_did: agent.id,
76
+ counterparty_wallet_or_account: input.bound_wallet,
77
+ wallet_binding_proof_ref: agentUrl,
78
+ trust_profile_ref: `${agentUrl}/reputation`,
79
+ trust_profile_issued_at: input.trust_profile_issued_at,
80
+ requested_resource: request.resource,
81
+ requested_amount: request.amount,
82
+ chain_or_settlement_network: request.network,
83
+ nonce_or_request_id: request.nonce,
84
+ policy_version: X402_POLICY_VERSION,
85
+ policy_input_canonicalization: "JCS (RFC 8785)",
86
+ policy_input_hash: `sha256:${sha256Hex(canonicalize(input))}`,
87
+ decision: decision.allow ? "allow" : "deny",
88
+ reason: decision.reason,
89
+ };
90
+ }
45
91
  export class X402PaymentBlocked extends Error {
46
92
  decision;
47
93
  constructor(decision) {
package/dist/x402.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"x402.js","sourceRoot":"","sources":["../src/x402.ts"],"names":[],"mappings":"AAIA;;;;;;uEAMuE;AAEvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAgB1C,MAAM,aAAa,GAAkC,EAAE,IAAI,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,sBAAsB,EAAE,CAAC,EAAE,CAAC;AAE9G,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO;QACL,CAAC,mBAAmB,CAAC,EAAE;YACrB,IAAI,EAAE,EAAE,GAAG,EAAE;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,8CAA8C;gBACvD,IAAI,EAA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AAE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,CAAC,KAAK;YAAE,MAAM,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAE5D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,UAAW,CAAC,WAAW,EAAE,CAAC;QACrD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7I,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inamprotocol",
3
- "version": "0.17.1",
3
+ "version": "0.19.0",
4
4
  "description": "Reference TypeScript/JavaScript SDK for the INAM Protocol — agent identity, execution receipts, jobs, and reputation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,6 +9,10 @@
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js"
12
+ },
13
+ "./ai-sdk": {
14
+ "types": "./dist/aiSdk.d.ts",
15
+ "import": "./dist/aiSdk.js"
12
16
  }
13
17
  },
14
18
  "files": [
@@ -26,7 +30,10 @@
26
30
  "reputation",
27
31
  "did",
28
32
  "protocol",
29
- "execution-receipt"
33
+ "execution-receipt",
34
+ "ai-sdk",
35
+ "vercel-ai",
36
+ "tools"
30
37
  ],
31
38
  "homepage": "https://inamprotocol.org",
32
39
  "repository": {
@@ -48,6 +55,15 @@
48
55
  },
49
56
  "devDependencies": {
50
57
  "@types/node": "^22.5.0",
58
+ "ai": "^7.0.135",
51
59
  "typescript": "^5.5.4"
60
+ },
61
+ "peerDependencies": {
62
+ "ai": ">=7"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "ai": {
66
+ "optional": true
67
+ }
52
68
  }
53
69
  }