inamprotocol 0.17.0 → 0.18.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 +16 -0
- package/dist/aiSdk.d.ts +735 -0
- package/dist/aiSdk.js +58 -0
- package/dist/aiSdk.js.map +1 -0
- package/dist/core/demo.d.ts +10 -0
- package/dist/core/demo.js +12 -0
- package/dist/core/demo.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/x402.d.ts +47 -0
- package/dist/x402.js +51 -0
- package/dist/x402.js.map +1 -1
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -100,6 +100,22 @@ const check = await verifyErc8004Feedback(fileText, { feedbackHash, clientAddres
|
|
|
100
100
|
// { valid, reasons, receiptId, providerDid, providerAddress }
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
## Vercel AI SDK tools
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { generateText, isStepCount } from "ai";
|
|
107
|
+
import { inamTools } from "inamprotocol/ai-sdk";
|
|
108
|
+
|
|
109
|
+
const { text } = await generateText({
|
|
110
|
+
model: "anthropic/claude-sonnet-5.5",
|
|
111
|
+
tools: inamTools(),
|
|
112
|
+
stopWhen: isStepCount(5),
|
|
113
|
+
prompt: "Find a code-review agent on INAM and tell me whether its record is strong enough to hire it.",
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`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
|
|
118
|
+
|
|
103
119
|
## What's exported
|
|
104
120
|
|
|
105
121
|
`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`, ...).
|
package/dist/aiSdk.d.ts
ADDED
|
@@ -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
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=aiSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiSdk.js","sourceRoot":"","sources":["../src/aiSdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,UAAU,SAAS,CAAC,UAAgC,EAAE;IAC1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;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/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ 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";
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ 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";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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ACxB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAuB3B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhL,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE7G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,cAAc,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) {
|
|
@@ -66,6 +112,11 @@ export function withInamX402Gate(inner, inam, policy = {}) {
|
|
|
66
112
|
const res = await inner(input, init);
|
|
67
113
|
if (res.status !== 402)
|
|
68
114
|
return res;
|
|
115
|
+
// A 402 to a request that already carries a payment is the payee rejecting it; the payee was gated before
|
|
116
|
+
// signing, so pass it through and let the payment wrapper report the real error.
|
|
117
|
+
const sent = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
118
|
+
if (sent.has("payment-signature") || sent.has("x-payment"))
|
|
119
|
+
return res;
|
|
69
120
|
const header = res.headers.get("payment-required");
|
|
70
121
|
let required;
|
|
71
122
|
try {
|
package/dist/x402.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x402.js","sourceRoot":"","sources":["../src/x402.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"x402.js","sourceRoot":"","sources":["../src/x402.ts"],"names":[],"mappings":"AAGA,O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K,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,yCAAyC,EAAE,CAAC,CAAC;QACzG,CAAC;QACD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,EAAE,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.
|
|
3
|
+
"version": "0.18.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
|
}
|