@ai-sdk/anthropic 3.0.0-beta.14 → 3.0.0-beta.16
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/CHANGELOG.md +15 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +693 -569
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +711 -539
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -2
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +687 -563
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +710 -538
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -11,66 +11,403 @@ import {
|
|
|
11
11
|
postJsonToApi,
|
|
12
12
|
resolve
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
14
|
-
import { z as z7 } from "zod/v4";
|
|
15
14
|
|
|
16
15
|
// src/anthropic-error.ts
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
import {
|
|
17
|
+
createJsonErrorResponseHandler,
|
|
18
|
+
lazySchema,
|
|
19
|
+
zodSchema
|
|
20
|
+
} from "@ai-sdk/provider-utils";
|
|
21
|
+
import * as z from "zod/v4";
|
|
22
|
+
var anthropicErrorDataSchema = lazySchema(
|
|
23
|
+
() => zodSchema(
|
|
24
|
+
z.object({
|
|
25
|
+
type: z.literal("error"),
|
|
26
|
+
error: z.object({
|
|
27
|
+
type: z.string(),
|
|
28
|
+
message: z.string()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
);
|
|
26
33
|
var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
27
34
|
errorSchema: anthropicErrorDataSchema,
|
|
28
35
|
errorToMessage: (data) => data.error.message
|
|
29
36
|
});
|
|
30
37
|
|
|
38
|
+
// src/anthropic-messages-api.ts
|
|
39
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
40
|
+
import * as z2 from "zod/v4";
|
|
41
|
+
var anthropicMessagesResponseSchema = lazySchema2(
|
|
42
|
+
() => zodSchema2(
|
|
43
|
+
z2.object({
|
|
44
|
+
type: z2.literal("message"),
|
|
45
|
+
id: z2.string().nullish(),
|
|
46
|
+
model: z2.string().nullish(),
|
|
47
|
+
content: z2.array(
|
|
48
|
+
z2.discriminatedUnion("type", [
|
|
49
|
+
z2.object({
|
|
50
|
+
type: z2.literal("text"),
|
|
51
|
+
text: z2.string(),
|
|
52
|
+
citations: z2.array(
|
|
53
|
+
z2.discriminatedUnion("type", [
|
|
54
|
+
z2.object({
|
|
55
|
+
type: z2.literal("web_search_result_location"),
|
|
56
|
+
cited_text: z2.string(),
|
|
57
|
+
url: z2.string(),
|
|
58
|
+
title: z2.string(),
|
|
59
|
+
encrypted_index: z2.string()
|
|
60
|
+
}),
|
|
61
|
+
z2.object({
|
|
62
|
+
type: z2.literal("page_location"),
|
|
63
|
+
cited_text: z2.string(),
|
|
64
|
+
document_index: z2.number(),
|
|
65
|
+
document_title: z2.string().nullable(),
|
|
66
|
+
start_page_number: z2.number(),
|
|
67
|
+
end_page_number: z2.number()
|
|
68
|
+
}),
|
|
69
|
+
z2.object({
|
|
70
|
+
type: z2.literal("char_location"),
|
|
71
|
+
cited_text: z2.string(),
|
|
72
|
+
document_index: z2.number(),
|
|
73
|
+
document_title: z2.string().nullable(),
|
|
74
|
+
start_char_index: z2.number(),
|
|
75
|
+
end_char_index: z2.number()
|
|
76
|
+
})
|
|
77
|
+
])
|
|
78
|
+
).optional()
|
|
79
|
+
}),
|
|
80
|
+
z2.object({
|
|
81
|
+
type: z2.literal("thinking"),
|
|
82
|
+
thinking: z2.string(),
|
|
83
|
+
signature: z2.string()
|
|
84
|
+
}),
|
|
85
|
+
z2.object({
|
|
86
|
+
type: z2.literal("redacted_thinking"),
|
|
87
|
+
data: z2.string()
|
|
88
|
+
}),
|
|
89
|
+
z2.object({
|
|
90
|
+
type: z2.literal("tool_use"),
|
|
91
|
+
id: z2.string(),
|
|
92
|
+
name: z2.string(),
|
|
93
|
+
input: z2.unknown()
|
|
94
|
+
}),
|
|
95
|
+
z2.object({
|
|
96
|
+
type: z2.literal("server_tool_use"),
|
|
97
|
+
id: z2.string(),
|
|
98
|
+
name: z2.string(),
|
|
99
|
+
input: z2.record(z2.string(), z2.unknown()).nullish()
|
|
100
|
+
}),
|
|
101
|
+
z2.object({
|
|
102
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
103
|
+
tool_use_id: z2.string(),
|
|
104
|
+
content: z2.union([
|
|
105
|
+
z2.object({
|
|
106
|
+
type: z2.literal("web_fetch_result"),
|
|
107
|
+
url: z2.string(),
|
|
108
|
+
retrieved_at: z2.string(),
|
|
109
|
+
content: z2.object({
|
|
110
|
+
type: z2.literal("document"),
|
|
111
|
+
title: z2.string().nullable(),
|
|
112
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
113
|
+
source: z2.object({
|
|
114
|
+
type: z2.literal("text"),
|
|
115
|
+
media_type: z2.string(),
|
|
116
|
+
data: z2.string()
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
z2.object({
|
|
121
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
122
|
+
error_code: z2.string()
|
|
123
|
+
})
|
|
124
|
+
])
|
|
125
|
+
}),
|
|
126
|
+
z2.object({
|
|
127
|
+
type: z2.literal("web_search_tool_result"),
|
|
128
|
+
tool_use_id: z2.string(),
|
|
129
|
+
content: z2.union([
|
|
130
|
+
z2.array(
|
|
131
|
+
z2.object({
|
|
132
|
+
type: z2.literal("web_search_result"),
|
|
133
|
+
url: z2.string(),
|
|
134
|
+
title: z2.string(),
|
|
135
|
+
encrypted_content: z2.string(),
|
|
136
|
+
page_age: z2.string().nullish()
|
|
137
|
+
})
|
|
138
|
+
),
|
|
139
|
+
z2.object({
|
|
140
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
141
|
+
error_code: z2.string()
|
|
142
|
+
})
|
|
143
|
+
])
|
|
144
|
+
}),
|
|
145
|
+
z2.object({
|
|
146
|
+
type: z2.literal("code_execution_tool_result"),
|
|
147
|
+
tool_use_id: z2.string(),
|
|
148
|
+
content: z2.union([
|
|
149
|
+
z2.object({
|
|
150
|
+
type: z2.literal("code_execution_result"),
|
|
151
|
+
stdout: z2.string(),
|
|
152
|
+
stderr: z2.string(),
|
|
153
|
+
return_code: z2.number()
|
|
154
|
+
}),
|
|
155
|
+
z2.object({
|
|
156
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
157
|
+
error_code: z2.string()
|
|
158
|
+
})
|
|
159
|
+
])
|
|
160
|
+
})
|
|
161
|
+
])
|
|
162
|
+
),
|
|
163
|
+
stop_reason: z2.string().nullish(),
|
|
164
|
+
stop_sequence: z2.string().nullish(),
|
|
165
|
+
usage: z2.looseObject({
|
|
166
|
+
input_tokens: z2.number(),
|
|
167
|
+
output_tokens: z2.number(),
|
|
168
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
169
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
var anthropicMessagesChunkSchema = lazySchema2(
|
|
175
|
+
() => zodSchema2(
|
|
176
|
+
z2.discriminatedUnion("type", [
|
|
177
|
+
z2.object({
|
|
178
|
+
type: z2.literal("message_start"),
|
|
179
|
+
message: z2.object({
|
|
180
|
+
id: z2.string().nullish(),
|
|
181
|
+
model: z2.string().nullish(),
|
|
182
|
+
usage: z2.looseObject({
|
|
183
|
+
input_tokens: z2.number(),
|
|
184
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
185
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
}),
|
|
189
|
+
z2.object({
|
|
190
|
+
type: z2.literal("content_block_start"),
|
|
191
|
+
index: z2.number(),
|
|
192
|
+
content_block: z2.discriminatedUnion("type", [
|
|
193
|
+
z2.object({
|
|
194
|
+
type: z2.literal("text"),
|
|
195
|
+
text: z2.string()
|
|
196
|
+
}),
|
|
197
|
+
z2.object({
|
|
198
|
+
type: z2.literal("thinking"),
|
|
199
|
+
thinking: z2.string()
|
|
200
|
+
}),
|
|
201
|
+
z2.object({
|
|
202
|
+
type: z2.literal("tool_use"),
|
|
203
|
+
id: z2.string(),
|
|
204
|
+
name: z2.string()
|
|
205
|
+
}),
|
|
206
|
+
z2.object({
|
|
207
|
+
type: z2.literal("redacted_thinking"),
|
|
208
|
+
data: z2.string()
|
|
209
|
+
}),
|
|
210
|
+
z2.object({
|
|
211
|
+
type: z2.literal("server_tool_use"),
|
|
212
|
+
id: z2.string(),
|
|
213
|
+
name: z2.string(),
|
|
214
|
+
input: z2.record(z2.string(), z2.unknown()).nullish()
|
|
215
|
+
}),
|
|
216
|
+
z2.object({
|
|
217
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
218
|
+
tool_use_id: z2.string(),
|
|
219
|
+
content: z2.union([
|
|
220
|
+
z2.object({
|
|
221
|
+
type: z2.literal("web_fetch_result"),
|
|
222
|
+
url: z2.string(),
|
|
223
|
+
retrieved_at: z2.string(),
|
|
224
|
+
content: z2.object({
|
|
225
|
+
type: z2.literal("document"),
|
|
226
|
+
title: z2.string().nullable(),
|
|
227
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
228
|
+
source: z2.object({
|
|
229
|
+
type: z2.literal("text"),
|
|
230
|
+
media_type: z2.string(),
|
|
231
|
+
data: z2.string()
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
}),
|
|
235
|
+
z2.object({
|
|
236
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
237
|
+
error_code: z2.string()
|
|
238
|
+
})
|
|
239
|
+
])
|
|
240
|
+
}),
|
|
241
|
+
z2.object({
|
|
242
|
+
type: z2.literal("web_search_tool_result"),
|
|
243
|
+
tool_use_id: z2.string(),
|
|
244
|
+
content: z2.union([
|
|
245
|
+
z2.array(
|
|
246
|
+
z2.object({
|
|
247
|
+
type: z2.literal("web_search_result"),
|
|
248
|
+
url: z2.string(),
|
|
249
|
+
title: z2.string(),
|
|
250
|
+
encrypted_content: z2.string(),
|
|
251
|
+
page_age: z2.string().nullish()
|
|
252
|
+
})
|
|
253
|
+
),
|
|
254
|
+
z2.object({
|
|
255
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
256
|
+
error_code: z2.string()
|
|
257
|
+
})
|
|
258
|
+
])
|
|
259
|
+
}),
|
|
260
|
+
z2.object({
|
|
261
|
+
type: z2.literal("code_execution_tool_result"),
|
|
262
|
+
tool_use_id: z2.string(),
|
|
263
|
+
content: z2.union([
|
|
264
|
+
z2.object({
|
|
265
|
+
type: z2.literal("code_execution_result"),
|
|
266
|
+
stdout: z2.string(),
|
|
267
|
+
stderr: z2.string(),
|
|
268
|
+
return_code: z2.number()
|
|
269
|
+
}),
|
|
270
|
+
z2.object({
|
|
271
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
272
|
+
error_code: z2.string()
|
|
273
|
+
})
|
|
274
|
+
])
|
|
275
|
+
})
|
|
276
|
+
])
|
|
277
|
+
}),
|
|
278
|
+
z2.object({
|
|
279
|
+
type: z2.literal("content_block_delta"),
|
|
280
|
+
index: z2.number(),
|
|
281
|
+
delta: z2.discriminatedUnion("type", [
|
|
282
|
+
z2.object({
|
|
283
|
+
type: z2.literal("input_json_delta"),
|
|
284
|
+
partial_json: z2.string()
|
|
285
|
+
}),
|
|
286
|
+
z2.object({
|
|
287
|
+
type: z2.literal("text_delta"),
|
|
288
|
+
text: z2.string()
|
|
289
|
+
}),
|
|
290
|
+
z2.object({
|
|
291
|
+
type: z2.literal("thinking_delta"),
|
|
292
|
+
thinking: z2.string()
|
|
293
|
+
}),
|
|
294
|
+
z2.object({
|
|
295
|
+
type: z2.literal("signature_delta"),
|
|
296
|
+
signature: z2.string()
|
|
297
|
+
}),
|
|
298
|
+
z2.object({
|
|
299
|
+
type: z2.literal("citations_delta"),
|
|
300
|
+
citation: z2.discriminatedUnion("type", [
|
|
301
|
+
z2.object({
|
|
302
|
+
type: z2.literal("web_search_result_location"),
|
|
303
|
+
cited_text: z2.string(),
|
|
304
|
+
url: z2.string(),
|
|
305
|
+
title: z2.string(),
|
|
306
|
+
encrypted_index: z2.string()
|
|
307
|
+
}),
|
|
308
|
+
z2.object({
|
|
309
|
+
type: z2.literal("page_location"),
|
|
310
|
+
cited_text: z2.string(),
|
|
311
|
+
document_index: z2.number(),
|
|
312
|
+
document_title: z2.string().nullable(),
|
|
313
|
+
start_page_number: z2.number(),
|
|
314
|
+
end_page_number: z2.number()
|
|
315
|
+
}),
|
|
316
|
+
z2.object({
|
|
317
|
+
type: z2.literal("char_location"),
|
|
318
|
+
cited_text: z2.string(),
|
|
319
|
+
document_index: z2.number(),
|
|
320
|
+
document_title: z2.string().nullable(),
|
|
321
|
+
start_char_index: z2.number(),
|
|
322
|
+
end_char_index: z2.number()
|
|
323
|
+
})
|
|
324
|
+
])
|
|
325
|
+
})
|
|
326
|
+
])
|
|
327
|
+
}),
|
|
328
|
+
z2.object({
|
|
329
|
+
type: z2.literal("content_block_stop"),
|
|
330
|
+
index: z2.number()
|
|
331
|
+
}),
|
|
332
|
+
z2.object({
|
|
333
|
+
type: z2.literal("error"),
|
|
334
|
+
error: z2.object({
|
|
335
|
+
type: z2.string(),
|
|
336
|
+
message: z2.string()
|
|
337
|
+
})
|
|
338
|
+
}),
|
|
339
|
+
z2.object({
|
|
340
|
+
type: z2.literal("message_delta"),
|
|
341
|
+
delta: z2.object({
|
|
342
|
+
stop_reason: z2.string().nullish(),
|
|
343
|
+
stop_sequence: z2.string().nullish()
|
|
344
|
+
}),
|
|
345
|
+
usage: z2.looseObject({
|
|
346
|
+
output_tokens: z2.number(),
|
|
347
|
+
cache_creation_input_tokens: z2.number().nullish()
|
|
348
|
+
})
|
|
349
|
+
}),
|
|
350
|
+
z2.object({
|
|
351
|
+
type: z2.literal("message_stop")
|
|
352
|
+
}),
|
|
353
|
+
z2.object({
|
|
354
|
+
type: z2.literal("ping")
|
|
355
|
+
})
|
|
356
|
+
])
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
var anthropicReasoningMetadataSchema = lazySchema2(
|
|
360
|
+
() => zodSchema2(
|
|
361
|
+
z2.object({
|
|
362
|
+
signature: z2.string().optional(),
|
|
363
|
+
redactedData: z2.string().optional()
|
|
364
|
+
})
|
|
365
|
+
)
|
|
366
|
+
);
|
|
367
|
+
|
|
31
368
|
// src/anthropic-messages-options.ts
|
|
32
|
-
import
|
|
33
|
-
var anthropicFilePartProviderOptions =
|
|
369
|
+
import * as z3 from "zod/v4";
|
|
370
|
+
var anthropicFilePartProviderOptions = z3.object({
|
|
34
371
|
/**
|
|
35
372
|
* Citation configuration for this document.
|
|
36
373
|
* When enabled, this document will generate citations in the response.
|
|
37
374
|
*/
|
|
38
|
-
citations:
|
|
375
|
+
citations: z3.object({
|
|
39
376
|
/**
|
|
40
377
|
* Enable citations for this document
|
|
41
378
|
*/
|
|
42
|
-
enabled:
|
|
379
|
+
enabled: z3.boolean()
|
|
43
380
|
}).optional(),
|
|
44
381
|
/**
|
|
45
382
|
* Custom title for the document.
|
|
46
383
|
* If not provided, the filename will be used.
|
|
47
384
|
*/
|
|
48
|
-
title:
|
|
385
|
+
title: z3.string().optional(),
|
|
49
386
|
/**
|
|
50
387
|
* Context about the document that will be passed to the model
|
|
51
388
|
* but not used towards cited content.
|
|
52
389
|
* Useful for storing document metadata as text or stringified JSON.
|
|
53
390
|
*/
|
|
54
|
-
context:
|
|
391
|
+
context: z3.string().optional()
|
|
55
392
|
});
|
|
56
|
-
var anthropicProviderOptions =
|
|
57
|
-
sendReasoning:
|
|
58
|
-
thinking:
|
|
59
|
-
type:
|
|
60
|
-
budgetTokens:
|
|
393
|
+
var anthropicProviderOptions = z3.object({
|
|
394
|
+
sendReasoning: z3.boolean().optional(),
|
|
395
|
+
thinking: z3.object({
|
|
396
|
+
type: z3.union([z3.literal("enabled"), z3.literal("disabled")]),
|
|
397
|
+
budgetTokens: z3.number().optional()
|
|
61
398
|
}).optional(),
|
|
62
399
|
/**
|
|
63
400
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
64
401
|
* When set to true, Claude will use at most one tool per response.
|
|
65
402
|
*/
|
|
66
|
-
disableParallelToolUse:
|
|
403
|
+
disableParallelToolUse: z3.boolean().optional(),
|
|
67
404
|
/**
|
|
68
405
|
* Cache control settings for this message.
|
|
69
406
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
70
407
|
*/
|
|
71
|
-
cacheControl:
|
|
72
|
-
type:
|
|
73
|
-
ttl:
|
|
408
|
+
cacheControl: z3.object({
|
|
409
|
+
type: z3.literal("ephemeral"),
|
|
410
|
+
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
74
411
|
}).optional()
|
|
75
412
|
});
|
|
76
413
|
|
|
@@ -89,57 +426,84 @@ function getCacheControl(providerMetadata) {
|
|
|
89
426
|
|
|
90
427
|
// src/tool/text-editor_20250728.ts
|
|
91
428
|
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
92
|
-
import
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
429
|
+
import * as z4 from "zod/v4";
|
|
430
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
431
|
+
var textEditor_20250728ArgsSchema = lazySchema3(
|
|
432
|
+
() => zodSchema3(
|
|
433
|
+
z4.object({
|
|
434
|
+
maxCharacters: z4.number().optional()
|
|
435
|
+
})
|
|
436
|
+
)
|
|
437
|
+
);
|
|
438
|
+
var textEditor_20250728InputSchema = lazySchema3(
|
|
439
|
+
() => zodSchema3(
|
|
440
|
+
z4.object({
|
|
441
|
+
command: z4.enum(["view", "create", "str_replace", "insert"]),
|
|
442
|
+
path: z4.string(),
|
|
443
|
+
file_text: z4.string().optional(),
|
|
444
|
+
insert_line: z4.number().int().optional(),
|
|
445
|
+
new_str: z4.string().optional(),
|
|
446
|
+
old_str: z4.string().optional(),
|
|
447
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
448
|
+
})
|
|
449
|
+
)
|
|
450
|
+
);
|
|
96
451
|
var factory = createProviderDefinedToolFactory({
|
|
97
452
|
id: "anthropic.text_editor_20250728",
|
|
98
453
|
name: "str_replace_based_edit_tool",
|
|
99
|
-
inputSchema:
|
|
100
|
-
command: z3.enum(["view", "create", "str_replace", "insert"]),
|
|
101
|
-
path: z3.string(),
|
|
102
|
-
file_text: z3.string().optional(),
|
|
103
|
-
insert_line: z3.number().int().optional(),
|
|
104
|
-
new_str: z3.string().optional(),
|
|
105
|
-
old_str: z3.string().optional(),
|
|
106
|
-
view_range: z3.array(z3.number().int()).optional()
|
|
107
|
-
})
|
|
454
|
+
inputSchema: textEditor_20250728InputSchema
|
|
108
455
|
});
|
|
109
456
|
var textEditor_20250728 = (args = {}) => {
|
|
110
457
|
return factory(args);
|
|
111
458
|
};
|
|
112
459
|
|
|
113
460
|
// src/tool/web-search_20250305.ts
|
|
114
|
-
import {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
461
|
+
import {
|
|
462
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
463
|
+
lazySchema as lazySchema4,
|
|
464
|
+
zodSchema as zodSchema4
|
|
465
|
+
} from "@ai-sdk/provider-utils";
|
|
466
|
+
import * as z5 from "zod/v4";
|
|
467
|
+
var webSearch_20250305ArgsSchema = lazySchema4(
|
|
468
|
+
() => zodSchema4(
|
|
469
|
+
z5.object({
|
|
470
|
+
maxUses: z5.number().optional(),
|
|
471
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
472
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
473
|
+
userLocation: z5.object({
|
|
474
|
+
type: z5.literal("approximate"),
|
|
475
|
+
city: z5.string().optional(),
|
|
476
|
+
region: z5.string().optional(),
|
|
477
|
+
country: z5.string().optional(),
|
|
478
|
+
timezone: z5.string().optional()
|
|
479
|
+
}).optional()
|
|
480
|
+
})
|
|
481
|
+
)
|
|
482
|
+
);
|
|
483
|
+
var webSearch_20250305OutputSchema = lazySchema4(
|
|
484
|
+
() => zodSchema4(
|
|
485
|
+
z5.array(
|
|
486
|
+
z5.object({
|
|
487
|
+
url: z5.string(),
|
|
488
|
+
title: z5.string(),
|
|
489
|
+
pageAge: z5.string().nullable(),
|
|
490
|
+
encryptedContent: z5.string(),
|
|
491
|
+
type: z5.literal("web_search_result")
|
|
492
|
+
})
|
|
493
|
+
)
|
|
494
|
+
)
|
|
495
|
+
);
|
|
496
|
+
var webSearch_20250305InputSchema = lazySchema4(
|
|
497
|
+
() => zodSchema4(
|
|
498
|
+
z5.object({
|
|
499
|
+
query: z5.string()
|
|
500
|
+
})
|
|
501
|
+
)
|
|
136
502
|
);
|
|
137
503
|
var factory2 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
138
504
|
id: "anthropic.web_search_20250305",
|
|
139
505
|
name: "web_search",
|
|
140
|
-
inputSchema:
|
|
141
|
-
query: z4.string()
|
|
142
|
-
}),
|
|
506
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
143
507
|
outputSchema: webSearch_20250305OutputSchema
|
|
144
508
|
});
|
|
145
509
|
var webSearch_20250305 = (args = {}) => {
|
|
@@ -147,43 +511,60 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
147
511
|
};
|
|
148
512
|
|
|
149
513
|
// src/tool/web-fetch-20250910.ts
|
|
150
|
-
import {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
514
|
+
import {
|
|
515
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
|
|
516
|
+
lazySchema as lazySchema5,
|
|
517
|
+
zodSchema as zodSchema5
|
|
518
|
+
} from "@ai-sdk/provider-utils";
|
|
519
|
+
import * as z6 from "zod/v4";
|
|
520
|
+
var webFetch_20250910ArgsSchema = lazySchema5(
|
|
521
|
+
() => zodSchema5(
|
|
522
|
+
z6.object({
|
|
523
|
+
maxUses: z6.number().optional(),
|
|
524
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
525
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
526
|
+
citations: z6.object({ enabled: z6.boolean() }).optional(),
|
|
527
|
+
maxContentTokens: z6.number().optional()
|
|
528
|
+
})
|
|
529
|
+
)
|
|
530
|
+
);
|
|
531
|
+
var webFetch_20250910OutputSchema = lazySchema5(
|
|
532
|
+
() => zodSchema5(
|
|
533
|
+
z6.object({
|
|
534
|
+
type: z6.literal("web_fetch_result"),
|
|
535
|
+
url: z6.string(),
|
|
536
|
+
content: z6.object({
|
|
537
|
+
type: z6.literal("document"),
|
|
538
|
+
title: z6.string(),
|
|
539
|
+
citations: z6.object({ enabled: z6.boolean() }).optional(),
|
|
540
|
+
source: z6.union([
|
|
541
|
+
z6.object({
|
|
542
|
+
type: z6.literal("base64"),
|
|
543
|
+
mediaType: z6.literal("application/pdf"),
|
|
544
|
+
data: z6.string()
|
|
545
|
+
}),
|
|
546
|
+
z6.object({
|
|
547
|
+
type: z6.literal("text"),
|
|
548
|
+
mediaType: z6.literal("text/plain"),
|
|
549
|
+
data: z6.string()
|
|
550
|
+
})
|
|
551
|
+
])
|
|
171
552
|
}),
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
})
|
|
553
|
+
retrievedAt: z6.string().nullable()
|
|
554
|
+
})
|
|
555
|
+
)
|
|
556
|
+
);
|
|
557
|
+
var webFetch_20250910InputSchema = lazySchema5(
|
|
558
|
+
() => zodSchema5(
|
|
559
|
+
z6.object({
|
|
560
|
+
url: z6.string()
|
|
561
|
+
})
|
|
562
|
+
)
|
|
563
|
+
);
|
|
181
564
|
var factory3 = createProviderDefinedToolFactoryWithOutputSchema2({
|
|
182
565
|
id: "anthropic.web_fetch_20250910",
|
|
183
566
|
name: "web_fetch",
|
|
184
|
-
inputSchema:
|
|
185
|
-
url: z5.string()
|
|
186
|
-
}),
|
|
567
|
+
inputSchema: webFetch_20250910InputSchema,
|
|
187
568
|
outputSchema: webFetch_20250910OutputSchema
|
|
188
569
|
});
|
|
189
570
|
var webFetch_20250910 = (args = {}) => {
|
|
@@ -191,7 +572,8 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
191
572
|
};
|
|
192
573
|
|
|
193
574
|
// src/anthropic-prepare-tools.ts
|
|
194
|
-
|
|
575
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
576
|
+
async function prepareTools({
|
|
195
577
|
tools,
|
|
196
578
|
toolChoice,
|
|
197
579
|
disableParallelToolUse
|
|
@@ -272,7 +654,10 @@ function prepareTools({
|
|
|
272
654
|
break;
|
|
273
655
|
}
|
|
274
656
|
case "anthropic.text_editor_20250728": {
|
|
275
|
-
const args =
|
|
657
|
+
const args = await validateTypes({
|
|
658
|
+
value: tool.args,
|
|
659
|
+
schema: textEditor_20250728ArgsSchema
|
|
660
|
+
});
|
|
276
661
|
anthropicTools2.push({
|
|
277
662
|
name: "str_replace_based_edit_tool",
|
|
278
663
|
type: "text_editor_20250728",
|
|
@@ -298,7 +683,10 @@ function prepareTools({
|
|
|
298
683
|
}
|
|
299
684
|
case "anthropic.web_fetch_20250910": {
|
|
300
685
|
betas.add("web-fetch-2025-09-10");
|
|
301
|
-
const args =
|
|
686
|
+
const args = await validateTypes({
|
|
687
|
+
value: tool.args,
|
|
688
|
+
schema: webFetch_20250910ArgsSchema
|
|
689
|
+
});
|
|
302
690
|
anthropicTools2.push({
|
|
303
691
|
type: "web_fetch_20250910",
|
|
304
692
|
name: "web_fetch",
|
|
@@ -311,7 +699,10 @@ function prepareTools({
|
|
|
311
699
|
break;
|
|
312
700
|
}
|
|
313
701
|
case "anthropic.web_search_20250305": {
|
|
314
|
-
const args =
|
|
702
|
+
const args = await validateTypes({
|
|
703
|
+
value: tool.args,
|
|
704
|
+
schema: webSearch_20250305ArgsSchema
|
|
705
|
+
});
|
|
315
706
|
anthropicTools2.push({
|
|
316
707
|
type: "web_search_20250305",
|
|
317
708
|
name: "web_search",
|
|
@@ -391,23 +782,40 @@ function prepareTools({
|
|
|
391
782
|
import {
|
|
392
783
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
393
784
|
} from "@ai-sdk/provider";
|
|
394
|
-
import {
|
|
785
|
+
import {
|
|
786
|
+
convertToBase64,
|
|
787
|
+
parseProviderOptions,
|
|
788
|
+
validateTypes as validateTypes2
|
|
789
|
+
} from "@ai-sdk/provider-utils";
|
|
395
790
|
|
|
396
791
|
// src/tool/code-execution_20250522.ts
|
|
397
|
-
import {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
792
|
+
import {
|
|
793
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
|
|
794
|
+
lazySchema as lazySchema6,
|
|
795
|
+
zodSchema as zodSchema6
|
|
796
|
+
} from "@ai-sdk/provider-utils";
|
|
797
|
+
import * as z7 from "zod/v4";
|
|
798
|
+
var codeExecution_20250522OutputSchema = lazySchema6(
|
|
799
|
+
() => zodSchema6(
|
|
800
|
+
z7.object({
|
|
801
|
+
type: z7.literal("code_execution_result"),
|
|
802
|
+
stdout: z7.string(),
|
|
803
|
+
stderr: z7.string(),
|
|
804
|
+
return_code: z7.number()
|
|
805
|
+
})
|
|
806
|
+
)
|
|
807
|
+
);
|
|
808
|
+
var codeExecution_20250522InputSchema = lazySchema6(
|
|
809
|
+
() => zodSchema6(
|
|
810
|
+
z7.object({
|
|
811
|
+
code: z7.string()
|
|
812
|
+
})
|
|
813
|
+
)
|
|
814
|
+
);
|
|
405
815
|
var factory4 = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
406
816
|
id: "anthropic.code_execution_20250522",
|
|
407
817
|
name: "code_execution",
|
|
408
|
-
inputSchema:
|
|
409
|
-
code: z6.string()
|
|
410
|
-
}),
|
|
818
|
+
inputSchema: codeExecution_20250522InputSchema,
|
|
411
819
|
outputSchema: codeExecution_20250522OutputSchema
|
|
412
820
|
});
|
|
413
821
|
var codeExecution_20250522 = (args = {}) => {
|
|
@@ -742,7 +1150,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
742
1150
|
});
|
|
743
1151
|
break;
|
|
744
1152
|
}
|
|
745
|
-
const codeExecutionOutput =
|
|
1153
|
+
const codeExecutionOutput = await validateTypes2({
|
|
1154
|
+
value: output.value,
|
|
1155
|
+
schema: codeExecution_20250522OutputSchema
|
|
1156
|
+
});
|
|
746
1157
|
anthropicContent.push({
|
|
747
1158
|
type: "code_execution_tool_result",
|
|
748
1159
|
tool_use_id: part.toolCallId,
|
|
@@ -765,9 +1176,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
765
1176
|
});
|
|
766
1177
|
break;
|
|
767
1178
|
}
|
|
768
|
-
const webFetchOutput =
|
|
769
|
-
output.value
|
|
770
|
-
|
|
1179
|
+
const webFetchOutput = await validateTypes2({
|
|
1180
|
+
value: output.value,
|
|
1181
|
+
schema: webFetch_20250910OutputSchema
|
|
1182
|
+
});
|
|
771
1183
|
anthropicContent.push({
|
|
772
1184
|
type: "web_fetch_tool_result",
|
|
773
1185
|
tool_use_id: part.toolCallId,
|
|
@@ -799,9 +1211,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
799
1211
|
});
|
|
800
1212
|
break;
|
|
801
1213
|
}
|
|
802
|
-
const webSearchOutput =
|
|
803
|
-
output.value
|
|
804
|
-
|
|
1214
|
+
const webSearchOutput = await validateTypes2({
|
|
1215
|
+
value: output.value,
|
|
1216
|
+
schema: webSearch_20250305OutputSchema
|
|
1217
|
+
});
|
|
805
1218
|
anthropicContent.push({
|
|
806
1219
|
type: "web_search_tool_result",
|
|
807
1220
|
tool_use_id: part.toolCallId,
|
|
@@ -908,67 +1321,15 @@ function mapAnthropicStopReason({
|
|
|
908
1321
|
}
|
|
909
1322
|
|
|
910
1323
|
// src/anthropic-messages-language-model.ts
|
|
911
|
-
var citationSchemas = {
|
|
912
|
-
webSearchResult: z7.object({
|
|
913
|
-
type: z7.literal("web_search_result_location"),
|
|
914
|
-
cited_text: z7.string(),
|
|
915
|
-
url: z7.string(),
|
|
916
|
-
title: z7.string(),
|
|
917
|
-
encrypted_index: z7.string()
|
|
918
|
-
}),
|
|
919
|
-
pageLocation: z7.object({
|
|
920
|
-
type: z7.literal("page_location"),
|
|
921
|
-
cited_text: z7.string(),
|
|
922
|
-
document_index: z7.number(),
|
|
923
|
-
document_title: z7.string().nullable(),
|
|
924
|
-
start_page_number: z7.number(),
|
|
925
|
-
end_page_number: z7.number()
|
|
926
|
-
}),
|
|
927
|
-
charLocation: z7.object({
|
|
928
|
-
type: z7.literal("char_location"),
|
|
929
|
-
cited_text: z7.string(),
|
|
930
|
-
document_index: z7.number(),
|
|
931
|
-
document_title: z7.string().nullable(),
|
|
932
|
-
start_char_index: z7.number(),
|
|
933
|
-
end_char_index: z7.number()
|
|
934
|
-
})
|
|
935
|
-
};
|
|
936
|
-
var citationSchema = z7.discriminatedUnion("type", [
|
|
937
|
-
citationSchemas.webSearchResult,
|
|
938
|
-
citationSchemas.pageLocation,
|
|
939
|
-
citationSchemas.charLocation
|
|
940
|
-
]);
|
|
941
|
-
var documentCitationSchema = z7.discriminatedUnion("type", [
|
|
942
|
-
citationSchemas.pageLocation,
|
|
943
|
-
citationSchemas.charLocation
|
|
944
|
-
]);
|
|
945
|
-
function processCitation(citation, citationDocuments, generateId2, onSource) {
|
|
946
|
-
if (citation.type === "page_location" || citation.type === "char_location") {
|
|
947
|
-
const source = createCitationSource(
|
|
948
|
-
citation,
|
|
949
|
-
citationDocuments,
|
|
950
|
-
generateId2
|
|
951
|
-
);
|
|
952
|
-
if (source) {
|
|
953
|
-
onSource(source);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
1324
|
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
958
1325
|
var _a;
|
|
1326
|
+
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
959
1329
|
const documentInfo = citationDocuments[citation.document_index];
|
|
960
1330
|
if (!documentInfo) {
|
|
961
|
-
return
|
|
1331
|
+
return;
|
|
962
1332
|
}
|
|
963
|
-
const providerMetadata = citation.type === "page_location" ? {
|
|
964
|
-
citedText: citation.cited_text,
|
|
965
|
-
startPageNumber: citation.start_page_number,
|
|
966
|
-
endPageNumber: citation.end_page_number
|
|
967
|
-
} : {
|
|
968
|
-
citedText: citation.cited_text,
|
|
969
|
-
startCharIndex: citation.start_char_index,
|
|
970
|
-
endCharIndex: citation.end_char_index
|
|
971
|
-
};
|
|
972
1333
|
return {
|
|
973
1334
|
type: "source",
|
|
974
1335
|
sourceType: "document",
|
|
@@ -977,7 +1338,15 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
977
1338
|
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
978
1339
|
filename: documentInfo.filename,
|
|
979
1340
|
providerMetadata: {
|
|
980
|
-
anthropic:
|
|
1341
|
+
anthropic: citation.type === "page_location" ? {
|
|
1342
|
+
citedText: citation.cited_text,
|
|
1343
|
+
startPageNumber: citation.start_page_number,
|
|
1344
|
+
endPageNumber: citation.end_page_number
|
|
1345
|
+
} : {
|
|
1346
|
+
citedText: citation.cited_text,
|
|
1347
|
+
startCharIndex: citation.start_char_index,
|
|
1348
|
+
endCharIndex: citation.end_char_index
|
|
1349
|
+
}
|
|
981
1350
|
}
|
|
982
1351
|
};
|
|
983
1352
|
}
|
|
@@ -1122,7 +1491,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1122
1491
|
toolChoice: anthropicToolChoice,
|
|
1123
1492
|
toolWarnings,
|
|
1124
1493
|
betas: toolsBetas
|
|
1125
|
-
} = prepareTools(
|
|
1494
|
+
} = await prepareTools(
|
|
1126
1495
|
jsonResponseTool != null ? {
|
|
1127
1496
|
tools: [jsonResponseTool],
|
|
1128
1497
|
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
@@ -1212,12 +1581,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1212
1581
|
content.push({ type: "text", text: part.text });
|
|
1213
1582
|
if (part.citations) {
|
|
1214
1583
|
for (const citation of part.citations) {
|
|
1215
|
-
|
|
1584
|
+
const source = createCitationSource(
|
|
1216
1585
|
citation,
|
|
1217
1586
|
citationDocuments,
|
|
1218
|
-
this.generateId
|
|
1219
|
-
(source) => content.push(source)
|
|
1587
|
+
this.generateId
|
|
1220
1588
|
);
|
|
1589
|
+
if (source) {
|
|
1590
|
+
content.push(source);
|
|
1591
|
+
}
|
|
1221
1592
|
}
|
|
1222
1593
|
}
|
|
1223
1594
|
}
|
|
@@ -1754,12 +2125,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1754
2125
|
}
|
|
1755
2126
|
case "citations_delta": {
|
|
1756
2127
|
const citation = value.delta.citation;
|
|
1757
|
-
|
|
2128
|
+
const source = createCitationSource(
|
|
1758
2129
|
citation,
|
|
1759
2130
|
citationDocuments,
|
|
1760
|
-
generateId2
|
|
1761
|
-
(source) => controller.enqueue(source)
|
|
2131
|
+
generateId2
|
|
1762
2132
|
);
|
|
2133
|
+
if (source) {
|
|
2134
|
+
controller.enqueue(source);
|
|
2135
|
+
}
|
|
1763
2136
|
return;
|
|
1764
2137
|
}
|
|
1765
2138
|
default: {
|
|
@@ -1830,402 +2203,201 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1830
2203
|
};
|
|
1831
2204
|
}
|
|
1832
2205
|
};
|
|
1833
|
-
var anthropicMessagesResponseSchema = z7.object({
|
|
1834
|
-
type: z7.literal("message"),
|
|
1835
|
-
id: z7.string().nullish(),
|
|
1836
|
-
model: z7.string().nullish(),
|
|
1837
|
-
content: z7.array(
|
|
1838
|
-
z7.discriminatedUnion("type", [
|
|
1839
|
-
z7.object({
|
|
1840
|
-
type: z7.literal("text"),
|
|
1841
|
-
text: z7.string(),
|
|
1842
|
-
citations: z7.array(citationSchema).optional()
|
|
1843
|
-
}),
|
|
1844
|
-
z7.object({
|
|
1845
|
-
type: z7.literal("thinking"),
|
|
1846
|
-
thinking: z7.string(),
|
|
1847
|
-
signature: z7.string()
|
|
1848
|
-
}),
|
|
1849
|
-
z7.object({
|
|
1850
|
-
type: z7.literal("redacted_thinking"),
|
|
1851
|
-
data: z7.string()
|
|
1852
|
-
}),
|
|
1853
|
-
z7.object({
|
|
1854
|
-
type: z7.literal("tool_use"),
|
|
1855
|
-
id: z7.string(),
|
|
1856
|
-
name: z7.string(),
|
|
1857
|
-
input: z7.unknown()
|
|
1858
|
-
}),
|
|
1859
|
-
z7.object({
|
|
1860
|
-
type: z7.literal("server_tool_use"),
|
|
1861
|
-
id: z7.string(),
|
|
1862
|
-
name: z7.string(),
|
|
1863
|
-
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1864
|
-
}),
|
|
1865
|
-
z7.object({
|
|
1866
|
-
type: z7.literal("web_fetch_tool_result"),
|
|
1867
|
-
tool_use_id: z7.string(),
|
|
1868
|
-
content: z7.union([
|
|
1869
|
-
z7.object({
|
|
1870
|
-
type: z7.literal("web_fetch_result"),
|
|
1871
|
-
url: z7.string(),
|
|
1872
|
-
retrieved_at: z7.string(),
|
|
1873
|
-
content: z7.object({
|
|
1874
|
-
type: z7.literal("document"),
|
|
1875
|
-
title: z7.string().nullable(),
|
|
1876
|
-
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1877
|
-
source: z7.object({
|
|
1878
|
-
type: z7.literal("text"),
|
|
1879
|
-
media_type: z7.string(),
|
|
1880
|
-
data: z7.string()
|
|
1881
|
-
})
|
|
1882
|
-
})
|
|
1883
|
-
}),
|
|
1884
|
-
z7.object({
|
|
1885
|
-
type: z7.literal("web_fetch_tool_result_error"),
|
|
1886
|
-
error_code: z7.string()
|
|
1887
|
-
})
|
|
1888
|
-
])
|
|
1889
|
-
}),
|
|
1890
|
-
z7.object({
|
|
1891
|
-
type: z7.literal("web_search_tool_result"),
|
|
1892
|
-
tool_use_id: z7.string(),
|
|
1893
|
-
content: z7.union([
|
|
1894
|
-
z7.array(
|
|
1895
|
-
z7.object({
|
|
1896
|
-
type: z7.literal("web_search_result"),
|
|
1897
|
-
url: z7.string(),
|
|
1898
|
-
title: z7.string(),
|
|
1899
|
-
encrypted_content: z7.string(),
|
|
1900
|
-
page_age: z7.string().nullish()
|
|
1901
|
-
})
|
|
1902
|
-
),
|
|
1903
|
-
z7.object({
|
|
1904
|
-
type: z7.literal("web_search_tool_result_error"),
|
|
1905
|
-
error_code: z7.string()
|
|
1906
|
-
})
|
|
1907
|
-
])
|
|
1908
|
-
}),
|
|
1909
|
-
z7.object({
|
|
1910
|
-
type: z7.literal("code_execution_tool_result"),
|
|
1911
|
-
tool_use_id: z7.string(),
|
|
1912
|
-
content: z7.union([
|
|
1913
|
-
z7.object({
|
|
1914
|
-
type: z7.literal("code_execution_result"),
|
|
1915
|
-
stdout: z7.string(),
|
|
1916
|
-
stderr: z7.string(),
|
|
1917
|
-
return_code: z7.number()
|
|
1918
|
-
}),
|
|
1919
|
-
z7.object({
|
|
1920
|
-
type: z7.literal("code_execution_tool_result_error"),
|
|
1921
|
-
error_code: z7.string()
|
|
1922
|
-
})
|
|
1923
|
-
])
|
|
1924
|
-
})
|
|
1925
|
-
])
|
|
1926
|
-
),
|
|
1927
|
-
stop_reason: z7.string().nullish(),
|
|
1928
|
-
stop_sequence: z7.string().nullish(),
|
|
1929
|
-
usage: z7.looseObject({
|
|
1930
|
-
input_tokens: z7.number(),
|
|
1931
|
-
output_tokens: z7.number(),
|
|
1932
|
-
cache_creation_input_tokens: z7.number().nullish(),
|
|
1933
|
-
cache_read_input_tokens: z7.number().nullish()
|
|
1934
|
-
})
|
|
1935
|
-
});
|
|
1936
|
-
var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
|
|
1937
|
-
z7.object({
|
|
1938
|
-
type: z7.literal("message_start"),
|
|
1939
|
-
message: z7.object({
|
|
1940
|
-
id: z7.string().nullish(),
|
|
1941
|
-
model: z7.string().nullish(),
|
|
1942
|
-
usage: z7.looseObject({
|
|
1943
|
-
input_tokens: z7.number(),
|
|
1944
|
-
cache_creation_input_tokens: z7.number().nullish(),
|
|
1945
|
-
cache_read_input_tokens: z7.number().nullish()
|
|
1946
|
-
})
|
|
1947
|
-
})
|
|
1948
|
-
}),
|
|
1949
|
-
z7.object({
|
|
1950
|
-
type: z7.literal("content_block_start"),
|
|
1951
|
-
index: z7.number(),
|
|
1952
|
-
content_block: z7.discriminatedUnion("type", [
|
|
1953
|
-
z7.object({
|
|
1954
|
-
type: z7.literal("text"),
|
|
1955
|
-
text: z7.string()
|
|
1956
|
-
}),
|
|
1957
|
-
z7.object({
|
|
1958
|
-
type: z7.literal("thinking"),
|
|
1959
|
-
thinking: z7.string()
|
|
1960
|
-
}),
|
|
1961
|
-
z7.object({
|
|
1962
|
-
type: z7.literal("tool_use"),
|
|
1963
|
-
id: z7.string(),
|
|
1964
|
-
name: z7.string()
|
|
1965
|
-
}),
|
|
1966
|
-
z7.object({
|
|
1967
|
-
type: z7.literal("redacted_thinking"),
|
|
1968
|
-
data: z7.string()
|
|
1969
|
-
}),
|
|
1970
|
-
z7.object({
|
|
1971
|
-
type: z7.literal("server_tool_use"),
|
|
1972
|
-
id: z7.string(),
|
|
1973
|
-
name: z7.string(),
|
|
1974
|
-
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1975
|
-
}),
|
|
1976
|
-
z7.object({
|
|
1977
|
-
type: z7.literal("web_fetch_tool_result"),
|
|
1978
|
-
tool_use_id: z7.string(),
|
|
1979
|
-
content: z7.union([
|
|
1980
|
-
z7.object({
|
|
1981
|
-
type: z7.literal("web_fetch_result"),
|
|
1982
|
-
url: z7.string(),
|
|
1983
|
-
retrieved_at: z7.string(),
|
|
1984
|
-
content: z7.object({
|
|
1985
|
-
type: z7.literal("document"),
|
|
1986
|
-
title: z7.string().nullable(),
|
|
1987
|
-
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1988
|
-
source: z7.object({
|
|
1989
|
-
type: z7.literal("text"),
|
|
1990
|
-
media_type: z7.string(),
|
|
1991
|
-
data: z7.string()
|
|
1992
|
-
})
|
|
1993
|
-
})
|
|
1994
|
-
}),
|
|
1995
|
-
z7.object({
|
|
1996
|
-
type: z7.literal("web_fetch_tool_result_error"),
|
|
1997
|
-
error_code: z7.string()
|
|
1998
|
-
})
|
|
1999
|
-
])
|
|
2000
|
-
}),
|
|
2001
|
-
z7.object({
|
|
2002
|
-
type: z7.literal("web_search_tool_result"),
|
|
2003
|
-
tool_use_id: z7.string(),
|
|
2004
|
-
content: z7.union([
|
|
2005
|
-
z7.array(
|
|
2006
|
-
z7.object({
|
|
2007
|
-
type: z7.literal("web_search_result"),
|
|
2008
|
-
url: z7.string(),
|
|
2009
|
-
title: z7.string(),
|
|
2010
|
-
encrypted_content: z7.string(),
|
|
2011
|
-
page_age: z7.string().nullish()
|
|
2012
|
-
})
|
|
2013
|
-
),
|
|
2014
|
-
z7.object({
|
|
2015
|
-
type: z7.literal("web_search_tool_result_error"),
|
|
2016
|
-
error_code: z7.string()
|
|
2017
|
-
})
|
|
2018
|
-
])
|
|
2019
|
-
}),
|
|
2020
|
-
z7.object({
|
|
2021
|
-
type: z7.literal("code_execution_tool_result"),
|
|
2022
|
-
tool_use_id: z7.string(),
|
|
2023
|
-
content: z7.union([
|
|
2024
|
-
z7.object({
|
|
2025
|
-
type: z7.literal("code_execution_result"),
|
|
2026
|
-
stdout: z7.string(),
|
|
2027
|
-
stderr: z7.string(),
|
|
2028
|
-
return_code: z7.number()
|
|
2029
|
-
}),
|
|
2030
|
-
z7.object({
|
|
2031
|
-
type: z7.literal("code_execution_tool_result_error"),
|
|
2032
|
-
error_code: z7.string()
|
|
2033
|
-
})
|
|
2034
|
-
])
|
|
2035
|
-
})
|
|
2036
|
-
])
|
|
2037
|
-
}),
|
|
2038
|
-
z7.object({
|
|
2039
|
-
type: z7.literal("content_block_delta"),
|
|
2040
|
-
index: z7.number(),
|
|
2041
|
-
delta: z7.discriminatedUnion("type", [
|
|
2042
|
-
z7.object({
|
|
2043
|
-
type: z7.literal("input_json_delta"),
|
|
2044
|
-
partial_json: z7.string()
|
|
2045
|
-
}),
|
|
2046
|
-
z7.object({
|
|
2047
|
-
type: z7.literal("text_delta"),
|
|
2048
|
-
text: z7.string()
|
|
2049
|
-
}),
|
|
2050
|
-
z7.object({
|
|
2051
|
-
type: z7.literal("thinking_delta"),
|
|
2052
|
-
thinking: z7.string()
|
|
2053
|
-
}),
|
|
2054
|
-
z7.object({
|
|
2055
|
-
type: z7.literal("signature_delta"),
|
|
2056
|
-
signature: z7.string()
|
|
2057
|
-
}),
|
|
2058
|
-
z7.object({
|
|
2059
|
-
type: z7.literal("citations_delta"),
|
|
2060
|
-
citation: citationSchema
|
|
2061
|
-
})
|
|
2062
|
-
])
|
|
2063
|
-
}),
|
|
2064
|
-
z7.object({
|
|
2065
|
-
type: z7.literal("content_block_stop"),
|
|
2066
|
-
index: z7.number()
|
|
2067
|
-
}),
|
|
2068
|
-
z7.object({
|
|
2069
|
-
type: z7.literal("error"),
|
|
2070
|
-
error: z7.object({
|
|
2071
|
-
type: z7.string(),
|
|
2072
|
-
message: z7.string()
|
|
2073
|
-
})
|
|
2074
|
-
}),
|
|
2075
|
-
z7.object({
|
|
2076
|
-
type: z7.literal("message_delta"),
|
|
2077
|
-
delta: z7.object({
|
|
2078
|
-
stop_reason: z7.string().nullish(),
|
|
2079
|
-
stop_sequence: z7.string().nullish()
|
|
2080
|
-
}),
|
|
2081
|
-
usage: z7.looseObject({
|
|
2082
|
-
output_tokens: z7.number(),
|
|
2083
|
-
cache_creation_input_tokens: z7.number().nullish()
|
|
2084
|
-
})
|
|
2085
|
-
}),
|
|
2086
|
-
z7.object({
|
|
2087
|
-
type: z7.literal("message_stop")
|
|
2088
|
-
}),
|
|
2089
|
-
z7.object({
|
|
2090
|
-
type: z7.literal("ping")
|
|
2091
|
-
})
|
|
2092
|
-
]);
|
|
2093
|
-
var anthropicReasoningMetadataSchema = z7.object({
|
|
2094
|
-
signature: z7.string().optional(),
|
|
2095
|
-
redactedData: z7.string().optional()
|
|
2096
|
-
});
|
|
2097
2206
|
|
|
2098
2207
|
// src/tool/bash_20241022.ts
|
|
2099
|
-
import {
|
|
2100
|
-
|
|
2208
|
+
import {
|
|
2209
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
2210
|
+
lazySchema as lazySchema7,
|
|
2211
|
+
zodSchema as zodSchema7
|
|
2212
|
+
} from "@ai-sdk/provider-utils";
|
|
2213
|
+
import * as z8 from "zod/v4";
|
|
2214
|
+
var bash_20241022InputSchema = lazySchema7(
|
|
2215
|
+
() => zodSchema7(
|
|
2216
|
+
z8.object({
|
|
2217
|
+
command: z8.string(),
|
|
2218
|
+
restart: z8.boolean().optional()
|
|
2219
|
+
})
|
|
2220
|
+
)
|
|
2221
|
+
);
|
|
2101
2222
|
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
2102
2223
|
id: "anthropic.bash_20241022",
|
|
2103
2224
|
name: "bash",
|
|
2104
|
-
inputSchema:
|
|
2105
|
-
command: z8.string(),
|
|
2106
|
-
restart: z8.boolean().optional()
|
|
2107
|
-
})
|
|
2225
|
+
inputSchema: bash_20241022InputSchema
|
|
2108
2226
|
});
|
|
2109
2227
|
|
|
2110
2228
|
// src/tool/bash_20250124.ts
|
|
2111
|
-
import {
|
|
2112
|
-
|
|
2229
|
+
import {
|
|
2230
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
2231
|
+
lazySchema as lazySchema8,
|
|
2232
|
+
zodSchema as zodSchema8
|
|
2233
|
+
} from "@ai-sdk/provider-utils";
|
|
2234
|
+
import * as z9 from "zod/v4";
|
|
2235
|
+
var bash_20250124InputSchema = lazySchema8(
|
|
2236
|
+
() => zodSchema8(
|
|
2237
|
+
z9.object({
|
|
2238
|
+
command: z9.string(),
|
|
2239
|
+
restart: z9.boolean().optional()
|
|
2240
|
+
})
|
|
2241
|
+
)
|
|
2242
|
+
);
|
|
2113
2243
|
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
2114
2244
|
id: "anthropic.bash_20250124",
|
|
2115
2245
|
name: "bash",
|
|
2116
|
-
inputSchema:
|
|
2117
|
-
command: z9.string(),
|
|
2118
|
-
restart: z9.boolean().optional()
|
|
2119
|
-
})
|
|
2246
|
+
inputSchema: bash_20250124InputSchema
|
|
2120
2247
|
});
|
|
2121
2248
|
|
|
2122
2249
|
// src/tool/computer_20241022.ts
|
|
2123
|
-
import {
|
|
2124
|
-
|
|
2250
|
+
import {
|
|
2251
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
2252
|
+
lazySchema as lazySchema9,
|
|
2253
|
+
zodSchema as zodSchema9
|
|
2254
|
+
} from "@ai-sdk/provider-utils";
|
|
2255
|
+
import * as z10 from "zod/v4";
|
|
2256
|
+
var computer_20241022InputSchema = lazySchema9(
|
|
2257
|
+
() => zodSchema9(
|
|
2258
|
+
z10.object({
|
|
2259
|
+
action: z10.enum([
|
|
2260
|
+
"key",
|
|
2261
|
+
"type",
|
|
2262
|
+
"mouse_move",
|
|
2263
|
+
"left_click",
|
|
2264
|
+
"left_click_drag",
|
|
2265
|
+
"right_click",
|
|
2266
|
+
"middle_click",
|
|
2267
|
+
"double_click",
|
|
2268
|
+
"screenshot",
|
|
2269
|
+
"cursor_position"
|
|
2270
|
+
]),
|
|
2271
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2272
|
+
text: z10.string().optional()
|
|
2273
|
+
})
|
|
2274
|
+
)
|
|
2275
|
+
);
|
|
2125
2276
|
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
2126
2277
|
id: "anthropic.computer_20241022",
|
|
2127
2278
|
name: "computer",
|
|
2128
|
-
inputSchema:
|
|
2129
|
-
action: z10.enum([
|
|
2130
|
-
"key",
|
|
2131
|
-
"type",
|
|
2132
|
-
"mouse_move",
|
|
2133
|
-
"left_click",
|
|
2134
|
-
"left_click_drag",
|
|
2135
|
-
"right_click",
|
|
2136
|
-
"middle_click",
|
|
2137
|
-
"double_click",
|
|
2138
|
-
"screenshot",
|
|
2139
|
-
"cursor_position"
|
|
2140
|
-
]),
|
|
2141
|
-
coordinate: z10.array(z10.number().int()).optional(),
|
|
2142
|
-
text: z10.string().optional()
|
|
2143
|
-
})
|
|
2279
|
+
inputSchema: computer_20241022InputSchema
|
|
2144
2280
|
});
|
|
2145
2281
|
|
|
2146
2282
|
// src/tool/computer_20250124.ts
|
|
2147
|
-
import {
|
|
2148
|
-
|
|
2283
|
+
import {
|
|
2284
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
2285
|
+
lazySchema as lazySchema10,
|
|
2286
|
+
zodSchema as zodSchema10
|
|
2287
|
+
} from "@ai-sdk/provider-utils";
|
|
2288
|
+
import * as z11 from "zod/v4";
|
|
2289
|
+
var computer_20250124InputSchema = lazySchema10(
|
|
2290
|
+
() => zodSchema10(
|
|
2291
|
+
z11.object({
|
|
2292
|
+
action: z11.enum([
|
|
2293
|
+
"key",
|
|
2294
|
+
"hold_key",
|
|
2295
|
+
"type",
|
|
2296
|
+
"cursor_position",
|
|
2297
|
+
"mouse_move",
|
|
2298
|
+
"left_mouse_down",
|
|
2299
|
+
"left_mouse_up",
|
|
2300
|
+
"left_click",
|
|
2301
|
+
"left_click_drag",
|
|
2302
|
+
"right_click",
|
|
2303
|
+
"middle_click",
|
|
2304
|
+
"double_click",
|
|
2305
|
+
"triple_click",
|
|
2306
|
+
"scroll",
|
|
2307
|
+
"wait",
|
|
2308
|
+
"screenshot"
|
|
2309
|
+
]),
|
|
2310
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2311
|
+
duration: z11.number().optional(),
|
|
2312
|
+
scroll_amount: z11.number().optional(),
|
|
2313
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2314
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2315
|
+
text: z11.string().optional()
|
|
2316
|
+
})
|
|
2317
|
+
)
|
|
2318
|
+
);
|
|
2149
2319
|
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
2150
2320
|
id: "anthropic.computer_20250124",
|
|
2151
2321
|
name: "computer",
|
|
2152
|
-
inputSchema:
|
|
2153
|
-
action: z11.enum([
|
|
2154
|
-
"key",
|
|
2155
|
-
"hold_key",
|
|
2156
|
-
"type",
|
|
2157
|
-
"cursor_position",
|
|
2158
|
-
"mouse_move",
|
|
2159
|
-
"left_mouse_down",
|
|
2160
|
-
"left_mouse_up",
|
|
2161
|
-
"left_click",
|
|
2162
|
-
"left_click_drag",
|
|
2163
|
-
"right_click",
|
|
2164
|
-
"middle_click",
|
|
2165
|
-
"double_click",
|
|
2166
|
-
"triple_click",
|
|
2167
|
-
"scroll",
|
|
2168
|
-
"wait",
|
|
2169
|
-
"screenshot"
|
|
2170
|
-
]),
|
|
2171
|
-
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2172
|
-
duration: z11.number().optional(),
|
|
2173
|
-
scroll_amount: z11.number().optional(),
|
|
2174
|
-
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2175
|
-
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2176
|
-
text: z11.string().optional()
|
|
2177
|
-
})
|
|
2322
|
+
inputSchema: computer_20250124InputSchema
|
|
2178
2323
|
});
|
|
2179
2324
|
|
|
2180
2325
|
// src/tool/text-editor_20241022.ts
|
|
2181
|
-
import {
|
|
2182
|
-
|
|
2326
|
+
import {
|
|
2327
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
2328
|
+
lazySchema as lazySchema11,
|
|
2329
|
+
zodSchema as zodSchema11
|
|
2330
|
+
} from "@ai-sdk/provider-utils";
|
|
2331
|
+
import * as z12 from "zod/v4";
|
|
2332
|
+
var textEditor_20241022InputSchema = lazySchema11(
|
|
2333
|
+
() => zodSchema11(
|
|
2334
|
+
z12.object({
|
|
2335
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2336
|
+
path: z12.string(),
|
|
2337
|
+
file_text: z12.string().optional(),
|
|
2338
|
+
insert_line: z12.number().int().optional(),
|
|
2339
|
+
new_str: z12.string().optional(),
|
|
2340
|
+
old_str: z12.string().optional(),
|
|
2341
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
2342
|
+
})
|
|
2343
|
+
)
|
|
2344
|
+
);
|
|
2183
2345
|
var textEditor_20241022 = createProviderDefinedToolFactory6({
|
|
2184
2346
|
id: "anthropic.text_editor_20241022",
|
|
2185
2347
|
name: "str_replace_editor",
|
|
2186
|
-
inputSchema:
|
|
2187
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2188
|
-
path: z12.string(),
|
|
2189
|
-
file_text: z12.string().optional(),
|
|
2190
|
-
insert_line: z12.number().int().optional(),
|
|
2191
|
-
new_str: z12.string().optional(),
|
|
2192
|
-
old_str: z12.string().optional(),
|
|
2193
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2194
|
-
})
|
|
2348
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2195
2349
|
});
|
|
2196
2350
|
|
|
2197
2351
|
// src/tool/text-editor_20250124.ts
|
|
2198
|
-
import {
|
|
2199
|
-
|
|
2352
|
+
import {
|
|
2353
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
2354
|
+
lazySchema as lazySchema12,
|
|
2355
|
+
zodSchema as zodSchema12
|
|
2356
|
+
} from "@ai-sdk/provider-utils";
|
|
2357
|
+
import * as z13 from "zod/v4";
|
|
2358
|
+
var textEditor_20250124InputSchema = lazySchema12(
|
|
2359
|
+
() => zodSchema12(
|
|
2360
|
+
z13.object({
|
|
2361
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2362
|
+
path: z13.string(),
|
|
2363
|
+
file_text: z13.string().optional(),
|
|
2364
|
+
insert_line: z13.number().int().optional(),
|
|
2365
|
+
new_str: z13.string().optional(),
|
|
2366
|
+
old_str: z13.string().optional(),
|
|
2367
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
2368
|
+
})
|
|
2369
|
+
)
|
|
2370
|
+
);
|
|
2200
2371
|
var textEditor_20250124 = createProviderDefinedToolFactory7({
|
|
2201
2372
|
id: "anthropic.text_editor_20250124",
|
|
2202
2373
|
name: "str_replace_editor",
|
|
2203
|
-
inputSchema:
|
|
2204
|
-
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2205
|
-
path: z13.string(),
|
|
2206
|
-
file_text: z13.string().optional(),
|
|
2207
|
-
insert_line: z13.number().int().optional(),
|
|
2208
|
-
new_str: z13.string().optional(),
|
|
2209
|
-
old_str: z13.string().optional(),
|
|
2210
|
-
view_range: z13.array(z13.number().int()).optional()
|
|
2211
|
-
})
|
|
2374
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2212
2375
|
});
|
|
2213
2376
|
|
|
2214
2377
|
// src/tool/text-editor_20250429.ts
|
|
2215
|
-
import {
|
|
2216
|
-
|
|
2378
|
+
import {
|
|
2379
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
2380
|
+
lazySchema as lazySchema13,
|
|
2381
|
+
zodSchema as zodSchema13
|
|
2382
|
+
} from "@ai-sdk/provider-utils";
|
|
2383
|
+
import * as z14 from "zod/v4";
|
|
2384
|
+
var textEditor_20250429InputSchema = lazySchema13(
|
|
2385
|
+
() => zodSchema13(
|
|
2386
|
+
z14.object({
|
|
2387
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2388
|
+
path: z14.string(),
|
|
2389
|
+
file_text: z14.string().optional(),
|
|
2390
|
+
insert_line: z14.number().int().optional(),
|
|
2391
|
+
new_str: z14.string().optional(),
|
|
2392
|
+
old_str: z14.string().optional(),
|
|
2393
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2394
|
+
})
|
|
2395
|
+
)
|
|
2396
|
+
);
|
|
2217
2397
|
var textEditor_20250429 = createProviderDefinedToolFactory8({
|
|
2218
2398
|
id: "anthropic.text_editor_20250429",
|
|
2219
2399
|
name: "str_replace_based_edit_tool",
|
|
2220
|
-
inputSchema:
|
|
2221
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2222
|
-
path: z14.string(),
|
|
2223
|
-
file_text: z14.string().optional(),
|
|
2224
|
-
insert_line: z14.number().int().optional(),
|
|
2225
|
-
new_str: z14.string().optional(),
|
|
2226
|
-
old_str: z14.string().optional(),
|
|
2227
|
-
view_range: z14.array(z14.number().int()).optional()
|
|
2228
|
-
})
|
|
2400
|
+
inputSchema: textEditor_20250429InputSchema
|
|
2229
2401
|
});
|
|
2230
2402
|
|
|
2231
2403
|
// src/anthropic-tools.ts
|