@ai-sdk/anthropic 2.0.24 → 2.0.26

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/internal/index.ts
@@ -38,67 +28,400 @@ module.exports = __toCommonJS(internal_exports);
38
28
 
39
29
  // src/anthropic-messages-language-model.ts
40
30
  var import_provider3 = require("@ai-sdk/provider");
41
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
42
- var z7 = __toESM(require("zod/v4"));
31
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
43
32
 
44
33
  // src/anthropic-error.ts
45
34
  var import_provider_utils = require("@ai-sdk/provider-utils");
46
- var z = __toESM(require("zod/v4"));
47
- var anthropicErrorDataSchema = z.object({
48
- type: z.literal("error"),
49
- error: z.object({
50
- type: z.string(),
51
- message: z.string()
52
- })
53
- });
35
+ var import_v4 = require("zod/v4");
36
+ var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
37
+ () => (0, import_provider_utils.zodSchema)(
38
+ import_v4.z.object({
39
+ type: import_v4.z.literal("error"),
40
+ error: import_v4.z.object({
41
+ type: import_v4.z.string(),
42
+ message: import_v4.z.string()
43
+ })
44
+ })
45
+ )
46
+ );
54
47
  var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
55
48
  errorSchema: anthropicErrorDataSchema,
56
49
  errorToMessage: (data) => data.error.message
57
50
  });
58
51
 
52
+ // src/anthropic-messages-api.ts
53
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
54
+ var import_v42 = require("zod/v4");
55
+ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
56
+ () => (0, import_provider_utils2.zodSchema)(
57
+ import_v42.z.object({
58
+ type: import_v42.z.literal("message"),
59
+ id: import_v42.z.string().nullish(),
60
+ model: import_v42.z.string().nullish(),
61
+ content: import_v42.z.array(
62
+ import_v42.z.discriminatedUnion("type", [
63
+ import_v42.z.object({
64
+ type: import_v42.z.literal("text"),
65
+ text: import_v42.z.string(),
66
+ citations: import_v42.z.array(
67
+ import_v42.z.discriminatedUnion("type", [
68
+ import_v42.z.object({
69
+ type: import_v42.z.literal("web_search_result_location"),
70
+ cited_text: import_v42.z.string(),
71
+ url: import_v42.z.string(),
72
+ title: import_v42.z.string(),
73
+ encrypted_index: import_v42.z.string()
74
+ }),
75
+ import_v42.z.object({
76
+ type: import_v42.z.literal("page_location"),
77
+ cited_text: import_v42.z.string(),
78
+ document_index: import_v42.z.number(),
79
+ document_title: import_v42.z.string().nullable(),
80
+ start_page_number: import_v42.z.number(),
81
+ end_page_number: import_v42.z.number()
82
+ }),
83
+ import_v42.z.object({
84
+ type: import_v42.z.literal("char_location"),
85
+ cited_text: import_v42.z.string(),
86
+ document_index: import_v42.z.number(),
87
+ document_title: import_v42.z.string().nullable(),
88
+ start_char_index: import_v42.z.number(),
89
+ end_char_index: import_v42.z.number()
90
+ })
91
+ ])
92
+ ).optional()
93
+ }),
94
+ import_v42.z.object({
95
+ type: import_v42.z.literal("thinking"),
96
+ thinking: import_v42.z.string(),
97
+ signature: import_v42.z.string()
98
+ }),
99
+ import_v42.z.object({
100
+ type: import_v42.z.literal("redacted_thinking"),
101
+ data: import_v42.z.string()
102
+ }),
103
+ import_v42.z.object({
104
+ type: import_v42.z.literal("tool_use"),
105
+ id: import_v42.z.string(),
106
+ name: import_v42.z.string(),
107
+ input: import_v42.z.unknown()
108
+ }),
109
+ import_v42.z.object({
110
+ type: import_v42.z.literal("server_tool_use"),
111
+ id: import_v42.z.string(),
112
+ name: import_v42.z.string(),
113
+ input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish()
114
+ }),
115
+ import_v42.z.object({
116
+ type: import_v42.z.literal("web_fetch_tool_result"),
117
+ tool_use_id: import_v42.z.string(),
118
+ content: import_v42.z.union([
119
+ import_v42.z.object({
120
+ type: import_v42.z.literal("web_fetch_result"),
121
+ url: import_v42.z.string(),
122
+ retrieved_at: import_v42.z.string(),
123
+ content: import_v42.z.object({
124
+ type: import_v42.z.literal("document"),
125
+ title: import_v42.z.string().nullable(),
126
+ citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
127
+ source: import_v42.z.object({
128
+ type: import_v42.z.literal("text"),
129
+ media_type: import_v42.z.string(),
130
+ data: import_v42.z.string()
131
+ })
132
+ })
133
+ }),
134
+ import_v42.z.object({
135
+ type: import_v42.z.literal("web_fetch_tool_result_error"),
136
+ error_code: import_v42.z.string()
137
+ })
138
+ ])
139
+ }),
140
+ import_v42.z.object({
141
+ type: import_v42.z.literal("web_search_tool_result"),
142
+ tool_use_id: import_v42.z.string(),
143
+ content: import_v42.z.union([
144
+ import_v42.z.array(
145
+ import_v42.z.object({
146
+ type: import_v42.z.literal("web_search_result"),
147
+ url: import_v42.z.string(),
148
+ title: import_v42.z.string(),
149
+ encrypted_content: import_v42.z.string(),
150
+ page_age: import_v42.z.string().nullish()
151
+ })
152
+ ),
153
+ import_v42.z.object({
154
+ type: import_v42.z.literal("web_search_tool_result_error"),
155
+ error_code: import_v42.z.string()
156
+ })
157
+ ])
158
+ }),
159
+ import_v42.z.object({
160
+ type: import_v42.z.literal("code_execution_tool_result"),
161
+ tool_use_id: import_v42.z.string(),
162
+ content: import_v42.z.union([
163
+ import_v42.z.object({
164
+ type: import_v42.z.literal("code_execution_result"),
165
+ stdout: import_v42.z.string(),
166
+ stderr: import_v42.z.string(),
167
+ return_code: import_v42.z.number()
168
+ }),
169
+ import_v42.z.object({
170
+ type: import_v42.z.literal("code_execution_tool_result_error"),
171
+ error_code: import_v42.z.string()
172
+ })
173
+ ])
174
+ })
175
+ ])
176
+ ),
177
+ stop_reason: import_v42.z.string().nullish(),
178
+ stop_sequence: import_v42.z.string().nullish(),
179
+ usage: import_v42.z.looseObject({
180
+ input_tokens: import_v42.z.number(),
181
+ output_tokens: import_v42.z.number(),
182
+ cache_creation_input_tokens: import_v42.z.number().nullish(),
183
+ cache_read_input_tokens: import_v42.z.number().nullish()
184
+ })
185
+ })
186
+ )
187
+ );
188
+ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
189
+ () => (0, import_provider_utils2.zodSchema)(
190
+ import_v42.z.discriminatedUnion("type", [
191
+ import_v42.z.object({
192
+ type: import_v42.z.literal("message_start"),
193
+ message: import_v42.z.object({
194
+ id: import_v42.z.string().nullish(),
195
+ model: import_v42.z.string().nullish(),
196
+ usage: import_v42.z.looseObject({
197
+ input_tokens: import_v42.z.number(),
198
+ cache_creation_input_tokens: import_v42.z.number().nullish(),
199
+ cache_read_input_tokens: import_v42.z.number().nullish()
200
+ })
201
+ })
202
+ }),
203
+ import_v42.z.object({
204
+ type: import_v42.z.literal("content_block_start"),
205
+ index: import_v42.z.number(),
206
+ content_block: import_v42.z.discriminatedUnion("type", [
207
+ import_v42.z.object({
208
+ type: import_v42.z.literal("text"),
209
+ text: import_v42.z.string()
210
+ }),
211
+ import_v42.z.object({
212
+ type: import_v42.z.literal("thinking"),
213
+ thinking: import_v42.z.string()
214
+ }),
215
+ import_v42.z.object({
216
+ type: import_v42.z.literal("tool_use"),
217
+ id: import_v42.z.string(),
218
+ name: import_v42.z.string()
219
+ }),
220
+ import_v42.z.object({
221
+ type: import_v42.z.literal("redacted_thinking"),
222
+ data: import_v42.z.string()
223
+ }),
224
+ import_v42.z.object({
225
+ type: import_v42.z.literal("server_tool_use"),
226
+ id: import_v42.z.string(),
227
+ name: import_v42.z.string(),
228
+ input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish()
229
+ }),
230
+ import_v42.z.object({
231
+ type: import_v42.z.literal("web_fetch_tool_result"),
232
+ tool_use_id: import_v42.z.string(),
233
+ content: import_v42.z.union([
234
+ import_v42.z.object({
235
+ type: import_v42.z.literal("web_fetch_result"),
236
+ url: import_v42.z.string(),
237
+ retrieved_at: import_v42.z.string(),
238
+ content: import_v42.z.object({
239
+ type: import_v42.z.literal("document"),
240
+ title: import_v42.z.string().nullable(),
241
+ citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
242
+ source: import_v42.z.object({
243
+ type: import_v42.z.literal("text"),
244
+ media_type: import_v42.z.string(),
245
+ data: import_v42.z.string()
246
+ })
247
+ })
248
+ }),
249
+ import_v42.z.object({
250
+ type: import_v42.z.literal("web_fetch_tool_result_error"),
251
+ error_code: import_v42.z.string()
252
+ })
253
+ ])
254
+ }),
255
+ import_v42.z.object({
256
+ type: import_v42.z.literal("web_search_tool_result"),
257
+ tool_use_id: import_v42.z.string(),
258
+ content: import_v42.z.union([
259
+ import_v42.z.array(
260
+ import_v42.z.object({
261
+ type: import_v42.z.literal("web_search_result"),
262
+ url: import_v42.z.string(),
263
+ title: import_v42.z.string(),
264
+ encrypted_content: import_v42.z.string(),
265
+ page_age: import_v42.z.string().nullish()
266
+ })
267
+ ),
268
+ import_v42.z.object({
269
+ type: import_v42.z.literal("web_search_tool_result_error"),
270
+ error_code: import_v42.z.string()
271
+ })
272
+ ])
273
+ }),
274
+ import_v42.z.object({
275
+ type: import_v42.z.literal("code_execution_tool_result"),
276
+ tool_use_id: import_v42.z.string(),
277
+ content: import_v42.z.union([
278
+ import_v42.z.object({
279
+ type: import_v42.z.literal("code_execution_result"),
280
+ stdout: import_v42.z.string(),
281
+ stderr: import_v42.z.string(),
282
+ return_code: import_v42.z.number()
283
+ }),
284
+ import_v42.z.object({
285
+ type: import_v42.z.literal("code_execution_tool_result_error"),
286
+ error_code: import_v42.z.string()
287
+ })
288
+ ])
289
+ })
290
+ ])
291
+ }),
292
+ import_v42.z.object({
293
+ type: import_v42.z.literal("content_block_delta"),
294
+ index: import_v42.z.number(),
295
+ delta: import_v42.z.discriminatedUnion("type", [
296
+ import_v42.z.object({
297
+ type: import_v42.z.literal("input_json_delta"),
298
+ partial_json: import_v42.z.string()
299
+ }),
300
+ import_v42.z.object({
301
+ type: import_v42.z.literal("text_delta"),
302
+ text: import_v42.z.string()
303
+ }),
304
+ import_v42.z.object({
305
+ type: import_v42.z.literal("thinking_delta"),
306
+ thinking: import_v42.z.string()
307
+ }),
308
+ import_v42.z.object({
309
+ type: import_v42.z.literal("signature_delta"),
310
+ signature: import_v42.z.string()
311
+ }),
312
+ import_v42.z.object({
313
+ type: import_v42.z.literal("citations_delta"),
314
+ citation: import_v42.z.discriminatedUnion("type", [
315
+ import_v42.z.object({
316
+ type: import_v42.z.literal("web_search_result_location"),
317
+ cited_text: import_v42.z.string(),
318
+ url: import_v42.z.string(),
319
+ title: import_v42.z.string(),
320
+ encrypted_index: import_v42.z.string()
321
+ }),
322
+ import_v42.z.object({
323
+ type: import_v42.z.literal("page_location"),
324
+ cited_text: import_v42.z.string(),
325
+ document_index: import_v42.z.number(),
326
+ document_title: import_v42.z.string().nullable(),
327
+ start_page_number: import_v42.z.number(),
328
+ end_page_number: import_v42.z.number()
329
+ }),
330
+ import_v42.z.object({
331
+ type: import_v42.z.literal("char_location"),
332
+ cited_text: import_v42.z.string(),
333
+ document_index: import_v42.z.number(),
334
+ document_title: import_v42.z.string().nullable(),
335
+ start_char_index: import_v42.z.number(),
336
+ end_char_index: import_v42.z.number()
337
+ })
338
+ ])
339
+ })
340
+ ])
341
+ }),
342
+ import_v42.z.object({
343
+ type: import_v42.z.literal("content_block_stop"),
344
+ index: import_v42.z.number()
345
+ }),
346
+ import_v42.z.object({
347
+ type: import_v42.z.literal("error"),
348
+ error: import_v42.z.object({
349
+ type: import_v42.z.string(),
350
+ message: import_v42.z.string()
351
+ })
352
+ }),
353
+ import_v42.z.object({
354
+ type: import_v42.z.literal("message_delta"),
355
+ delta: import_v42.z.object({
356
+ stop_reason: import_v42.z.string().nullish(),
357
+ stop_sequence: import_v42.z.string().nullish()
358
+ }),
359
+ usage: import_v42.z.looseObject({
360
+ output_tokens: import_v42.z.number(),
361
+ cache_creation_input_tokens: import_v42.z.number().nullish()
362
+ })
363
+ }),
364
+ import_v42.z.object({
365
+ type: import_v42.z.literal("message_stop")
366
+ }),
367
+ import_v42.z.object({
368
+ type: import_v42.z.literal("ping")
369
+ })
370
+ ])
371
+ )
372
+ );
373
+ var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
374
+ () => (0, import_provider_utils2.zodSchema)(
375
+ import_v42.z.object({
376
+ signature: import_v42.z.string().optional(),
377
+ redactedData: import_v42.z.string().optional()
378
+ })
379
+ )
380
+ );
381
+
59
382
  // src/anthropic-messages-options.ts
60
- var z2 = __toESM(require("zod/v4"));
61
- var anthropicFilePartProviderOptions = z2.object({
383
+ var import_v43 = require("zod/v4");
384
+ var anthropicFilePartProviderOptions = import_v43.z.object({
62
385
  /**
63
386
  * Citation configuration for this document.
64
387
  * When enabled, this document will generate citations in the response.
65
388
  */
66
- citations: z2.object({
389
+ citations: import_v43.z.object({
67
390
  /**
68
391
  * Enable citations for this document
69
392
  */
70
- enabled: z2.boolean()
393
+ enabled: import_v43.z.boolean()
71
394
  }).optional(),
72
395
  /**
73
396
  * Custom title for the document.
74
397
  * If not provided, the filename will be used.
75
398
  */
76
- title: z2.string().optional(),
399
+ title: import_v43.z.string().optional(),
77
400
  /**
78
401
  * Context about the document that will be passed to the model
79
402
  * but not used towards cited content.
80
403
  * Useful for storing document metadata as text or stringified JSON.
81
404
  */
82
- context: z2.string().optional()
405
+ context: import_v43.z.string().optional()
83
406
  });
84
- var anthropicProviderOptions = z2.object({
85
- sendReasoning: z2.boolean().optional(),
86
- thinking: z2.object({
87
- type: z2.union([z2.literal("enabled"), z2.literal("disabled")]),
88
- budgetTokens: z2.number().optional()
407
+ var anthropicProviderOptions = import_v43.z.object({
408
+ sendReasoning: import_v43.z.boolean().optional(),
409
+ thinking: import_v43.z.object({
410
+ type: import_v43.z.union([import_v43.z.literal("enabled"), import_v43.z.literal("disabled")]),
411
+ budgetTokens: import_v43.z.number().optional()
89
412
  }).optional(),
90
413
  /**
91
414
  * Whether to disable parallel function calling during tool use. Default is false.
92
415
  * When set to true, Claude will use at most one tool per response.
93
416
  */
94
- disableParallelToolUse: z2.boolean().optional(),
417
+ disableParallelToolUse: import_v43.z.boolean().optional(),
95
418
  /**
96
419
  * Cache control settings for this message.
97
420
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
98
421
  */
99
- cacheControl: z2.object({
100
- type: z2.literal("ephemeral"),
101
- ttl: z2.union([z2.literal("5m"), z2.literal("1h")]).optional()
422
+ cacheControl: import_v43.z.object({
423
+ type: import_v43.z.literal("ephemeral"),
424
+ ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
102
425
  }).optional()
103
426
  });
104
427
 
@@ -114,58 +437,81 @@ function getCacheControl(providerMetadata) {
114
437
  }
115
438
 
116
439
  // src/tool/text-editor_20250728.ts
117
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
118
- var z3 = __toESM(require("zod/v4"));
119
- var textEditor_20250728ArgsSchema = z3.object({
120
- maxCharacters: z3.number().optional()
121
- });
122
- var factory = (0, import_provider_utils2.createProviderDefinedToolFactory)({
440
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
441
+ var import_v44 = require("zod/v4");
442
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
443
+ var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
444
+ () => (0, import_provider_utils4.zodSchema)(
445
+ import_v44.z.object({
446
+ maxCharacters: import_v44.z.number().optional()
447
+ })
448
+ )
449
+ );
450
+ var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
451
+ () => (0, import_provider_utils4.zodSchema)(
452
+ import_v44.z.object({
453
+ command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
454
+ path: import_v44.z.string(),
455
+ file_text: import_v44.z.string().optional(),
456
+ insert_line: import_v44.z.number().int().optional(),
457
+ new_str: import_v44.z.string().optional(),
458
+ old_str: import_v44.z.string().optional(),
459
+ view_range: import_v44.z.array(import_v44.z.number().int()).optional()
460
+ })
461
+ )
462
+ );
463
+ var factory = (0, import_provider_utils3.createProviderDefinedToolFactory)({
123
464
  id: "anthropic.text_editor_20250728",
124
465
  name: "str_replace_based_edit_tool",
125
- inputSchema: z3.object({
126
- command: z3.enum(["view", "create", "str_replace", "insert"]),
127
- path: z3.string(),
128
- file_text: z3.string().optional(),
129
- insert_line: z3.number().int().optional(),
130
- new_str: z3.string().optional(),
131
- old_str: z3.string().optional(),
132
- view_range: z3.array(z3.number().int()).optional()
133
- })
466
+ inputSchema: textEditor_20250728InputSchema
134
467
  });
135
468
  var textEditor_20250728 = (args = {}) => {
136
469
  return factory(args);
137
470
  };
138
471
 
139
472
  // src/tool/web-search_20250305.ts
140
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
141
- var z4 = __toESM(require("zod/v4"));
142
- var webSearch_20250305ArgsSchema = z4.object({
143
- maxUses: z4.number().optional(),
144
- allowedDomains: z4.array(z4.string()).optional(),
145
- blockedDomains: z4.array(z4.string()).optional(),
146
- userLocation: z4.object({
147
- type: z4.literal("approximate"),
148
- city: z4.string().optional(),
149
- region: z4.string().optional(),
150
- country: z4.string().optional(),
151
- timezone: z4.string().optional()
152
- }).optional()
153
- });
154
- var webSearch_20250305OutputSchema = z4.array(
155
- z4.object({
156
- url: z4.string(),
157
- title: z4.string(),
158
- pageAge: z4.string().nullable(),
159
- encryptedContent: z4.string(),
160
- type: z4.literal("web_search_result")
161
- })
473
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
474
+ var import_v45 = require("zod/v4");
475
+ var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
476
+ () => (0, import_provider_utils5.zodSchema)(
477
+ import_v45.z.object({
478
+ maxUses: import_v45.z.number().optional(),
479
+ allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
480
+ blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
481
+ userLocation: import_v45.z.object({
482
+ type: import_v45.z.literal("approximate"),
483
+ city: import_v45.z.string().optional(),
484
+ region: import_v45.z.string().optional(),
485
+ country: import_v45.z.string().optional(),
486
+ timezone: import_v45.z.string().optional()
487
+ }).optional()
488
+ })
489
+ )
490
+ );
491
+ var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
492
+ () => (0, import_provider_utils5.zodSchema)(
493
+ import_v45.z.array(
494
+ import_v45.z.object({
495
+ url: import_v45.z.string(),
496
+ title: import_v45.z.string(),
497
+ pageAge: import_v45.z.string().nullable(),
498
+ encryptedContent: import_v45.z.string(),
499
+ type: import_v45.z.literal("web_search_result")
500
+ })
501
+ )
502
+ )
503
+ );
504
+ var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
505
+ () => (0, import_provider_utils5.zodSchema)(
506
+ import_v45.z.object({
507
+ query: import_v45.z.string()
508
+ })
509
+ )
162
510
  );
163
- var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
511
+ var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
164
512
  id: "anthropic.web_search_20250305",
165
513
  name: "web_search",
166
- inputSchema: z4.object({
167
- query: z4.string()
168
- }),
514
+ inputSchema: webSearch_20250305InputSchema,
169
515
  outputSchema: webSearch_20250305OutputSchema
170
516
  });
171
517
  var webSearch_20250305 = (args = {}) => {
@@ -173,43 +519,56 @@ var webSearch_20250305 = (args = {}) => {
173
519
  };
174
520
 
175
521
  // src/tool/web-fetch-20250910.ts
176
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
177
- var z5 = __toESM(require("zod/v4"));
178
- var webFetch_20250910ArgsSchema = z5.object({
179
- maxUses: z5.number().optional(),
180
- allowedDomains: z5.array(z5.string()).optional(),
181
- blockedDomains: z5.array(z5.string()).optional(),
182
- citations: z5.object({ enabled: z5.boolean() }).optional(),
183
- maxContentTokens: z5.number().optional()
184
- });
185
- var webFetch_20250910OutputSchema = z5.object({
186
- type: z5.literal("web_fetch_result"),
187
- url: z5.string(),
188
- content: z5.object({
189
- type: z5.literal("document"),
190
- title: z5.string(),
191
- citations: z5.object({ enabled: z5.boolean() }).optional(),
192
- source: z5.union([
193
- z5.object({
194
- type: z5.literal("base64"),
195
- mediaType: z5.literal("application/pdf"),
196
- data: z5.string()
522
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
523
+ var import_v46 = require("zod/v4");
524
+ var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
525
+ () => (0, import_provider_utils6.zodSchema)(
526
+ import_v46.z.object({
527
+ maxUses: import_v46.z.number().optional(),
528
+ allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
529
+ blockedDomains: import_v46.z.array(import_v46.z.string()).optional(),
530
+ citations: import_v46.z.object({ enabled: import_v46.z.boolean() }).optional(),
531
+ maxContentTokens: import_v46.z.number().optional()
532
+ })
533
+ )
534
+ );
535
+ var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
536
+ () => (0, import_provider_utils6.zodSchema)(
537
+ import_v46.z.object({
538
+ type: import_v46.z.literal("web_fetch_result"),
539
+ url: import_v46.z.string(),
540
+ content: import_v46.z.object({
541
+ type: import_v46.z.literal("document"),
542
+ title: import_v46.z.string(),
543
+ citations: import_v46.z.object({ enabled: import_v46.z.boolean() }).optional(),
544
+ source: import_v46.z.union([
545
+ import_v46.z.object({
546
+ type: import_v46.z.literal("base64"),
547
+ mediaType: import_v46.z.literal("application/pdf"),
548
+ data: import_v46.z.string()
549
+ }),
550
+ import_v46.z.object({
551
+ type: import_v46.z.literal("text"),
552
+ mediaType: import_v46.z.literal("text/plain"),
553
+ data: import_v46.z.string()
554
+ })
555
+ ])
197
556
  }),
198
- z5.object({
199
- type: z5.literal("text"),
200
- mediaType: z5.literal("text/plain"),
201
- data: z5.string()
202
- })
203
- ])
204
- }),
205
- retrievedAt: z5.string().nullable()
206
- });
207
- var factory3 = (0, import_provider_utils4.createProviderDefinedToolFactoryWithOutputSchema)({
557
+ retrievedAt: import_v46.z.string().nullable()
558
+ })
559
+ )
560
+ );
561
+ var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
562
+ () => (0, import_provider_utils6.zodSchema)(
563
+ import_v46.z.object({
564
+ url: import_v46.z.string()
565
+ })
566
+ )
567
+ );
568
+ var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
208
569
  id: "anthropic.web_fetch_20250910",
209
570
  name: "web_fetch",
210
- inputSchema: z5.object({
211
- url: z5.string()
212
- }),
571
+ inputSchema: webFetch_20250910InputSchema,
213
572
  outputSchema: webFetch_20250910OutputSchema
214
573
  });
215
574
  var webFetch_20250910 = (args = {}) => {
@@ -217,7 +576,8 @@ var webFetch_20250910 = (args = {}) => {
217
576
  };
218
577
 
219
578
  // src/anthropic-prepare-tools.ts
220
- function prepareTools({
579
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
580
+ async function prepareTools({
221
581
  tools,
222
582
  toolChoice,
223
583
  disableParallelToolUse
@@ -298,7 +658,10 @@ function prepareTools({
298
658
  break;
299
659
  }
300
660
  case "anthropic.text_editor_20250728": {
301
- const args = textEditor_20250728ArgsSchema.parse(tool.args);
661
+ const args = await (0, import_provider_utils7.validateTypes)({
662
+ value: tool.args,
663
+ schema: textEditor_20250728ArgsSchema
664
+ });
302
665
  anthropicTools2.push({
303
666
  name: "str_replace_based_edit_tool",
304
667
  type: "text_editor_20250728",
@@ -324,7 +687,10 @@ function prepareTools({
324
687
  }
325
688
  case "anthropic.web_fetch_20250910": {
326
689
  betas.add("web-fetch-2025-09-10");
327
- const args = webFetch_20250910ArgsSchema.parse(tool.args);
690
+ const args = await (0, import_provider_utils7.validateTypes)({
691
+ value: tool.args,
692
+ schema: webFetch_20250910ArgsSchema
693
+ });
328
694
  anthropicTools2.push({
329
695
  type: "web_fetch_20250910",
330
696
  name: "web_fetch",
@@ -337,7 +703,10 @@ function prepareTools({
337
703
  break;
338
704
  }
339
705
  case "anthropic.web_search_20250305": {
340
- const args = webSearch_20250305ArgsSchema.parse(tool.args);
706
+ const args = await (0, import_provider_utils7.validateTypes)({
707
+ value: tool.args,
708
+ schema: webSearch_20250305ArgsSchema
709
+ });
341
710
  anthropicTools2.push({
342
711
  type: "web_search_20250305",
343
712
  name: "web_search",
@@ -415,23 +784,32 @@ function prepareTools({
415
784
 
416
785
  // src/convert-to-anthropic-messages-prompt.ts
417
786
  var import_provider2 = require("@ai-sdk/provider");
418
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
787
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
419
788
 
420
789
  // src/tool/code-execution_20250522.ts
421
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
422
- var z6 = __toESM(require("zod/v4"));
423
- var codeExecution_20250522OutputSchema = z6.object({
424
- type: z6.literal("code_execution_result"),
425
- stdout: z6.string(),
426
- stderr: z6.string(),
427
- return_code: z6.number()
428
- });
429
- var factory4 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
790
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
791
+ var import_v47 = require("zod/v4");
792
+ var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
793
+ () => (0, import_provider_utils8.zodSchema)(
794
+ import_v47.z.object({
795
+ type: import_v47.z.literal("code_execution_result"),
796
+ stdout: import_v47.z.string(),
797
+ stderr: import_v47.z.string(),
798
+ return_code: import_v47.z.number()
799
+ })
800
+ )
801
+ );
802
+ var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
803
+ () => (0, import_provider_utils8.zodSchema)(
804
+ import_v47.z.object({
805
+ code: import_v47.z.string()
806
+ })
807
+ )
808
+ );
809
+ var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
430
810
  id: "anthropic.code_execution_20250522",
431
811
  name: "code_execution",
432
- inputSchema: z6.object({
433
- code: z6.string()
434
- }),
812
+ inputSchema: codeExecution_20250522InputSchema,
435
813
  outputSchema: codeExecution_20250522OutputSchema
436
814
  });
437
815
  var codeExecution_20250522 = (args = {}) => {
@@ -467,7 +845,7 @@ async function convertToAnthropicMessagesPrompt({
467
845
  const messages = [];
468
846
  async function shouldEnableCitations(providerMetadata) {
469
847
  var _a2, _b2;
470
- const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
848
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
471
849
  provider: "anthropic",
472
850
  providerOptions: providerMetadata,
473
851
  schema: anthropicFilePartProviderOptions
@@ -475,7 +853,7 @@ async function convertToAnthropicMessagesPrompt({
475
853
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
476
854
  }
477
855
  async function getDocumentMetadata(providerMetadata) {
478
- const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
856
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
479
857
  provider: "anthropic",
480
858
  providerOptions: providerMetadata,
481
859
  schema: anthropicFilePartProviderOptions
@@ -532,7 +910,7 @@ async function convertToAnthropicMessagesPrompt({
532
910
  } : {
533
911
  type: "base64",
534
912
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
535
- data: (0, import_provider_utils6.convertToBase64)(part.data)
913
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
536
914
  },
537
915
  cache_control: cacheControl
538
916
  });
@@ -552,7 +930,7 @@ async function convertToAnthropicMessagesPrompt({
552
930
  } : {
553
931
  type: "base64",
554
932
  media_type: "application/pdf",
555
- data: (0, import_provider_utils6.convertToBase64)(part.data)
933
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
556
934
  },
557
935
  title: (_b = metadata.title) != null ? _b : part.filename,
558
936
  ...metadata.context && { context: metadata.context },
@@ -687,7 +1065,7 @@ async function convertToAnthropicMessagesPrompt({
687
1065
  }
688
1066
  case "reasoning": {
689
1067
  if (sendReasoning) {
690
- const reasoningMetadata = await (0, import_provider_utils6.parseProviderOptions)({
1068
+ const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
691
1069
  provider: "anthropic",
692
1070
  providerOptions: part.providerOptions,
693
1071
  schema: anthropicReasoningMetadataSchema
@@ -763,7 +1141,10 @@ async function convertToAnthropicMessagesPrompt({
763
1141
  });
764
1142
  break;
765
1143
  }
766
- const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
1144
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1145
+ value: output.value,
1146
+ schema: codeExecution_20250522OutputSchema
1147
+ });
767
1148
  anthropicContent.push({
768
1149
  type: "code_execution_tool_result",
769
1150
  tool_use_id: part.toolCallId,
@@ -786,9 +1167,10 @@ async function convertToAnthropicMessagesPrompt({
786
1167
  });
787
1168
  break;
788
1169
  }
789
- const webFetchOutput = webFetch_20250910OutputSchema.parse(
790
- output.value
791
- );
1170
+ const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1171
+ value: output.value,
1172
+ schema: webFetch_20250910OutputSchema
1173
+ });
792
1174
  anthropicContent.push({
793
1175
  type: "web_fetch_tool_result",
794
1176
  tool_use_id: part.toolCallId,
@@ -820,9 +1202,10 @@ async function convertToAnthropicMessagesPrompt({
820
1202
  });
821
1203
  break;
822
1204
  }
823
- const webSearchOutput = webSearch_20250305OutputSchema.parse(
824
- output.value
825
- );
1205
+ const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1206
+ value: output.value,
1207
+ schema: webSearch_20250305OutputSchema
1208
+ });
826
1209
  anthropicContent.push({
827
1210
  type: "web_search_tool_result",
828
1211
  tool_use_id: part.toolCallId,
@@ -929,67 +1312,15 @@ function mapAnthropicStopReason({
929
1312
  }
930
1313
 
931
1314
  // src/anthropic-messages-language-model.ts
932
- var citationSchemas = {
933
- webSearchResult: z7.object({
934
- type: z7.literal("web_search_result_location"),
935
- cited_text: z7.string(),
936
- url: z7.string(),
937
- title: z7.string(),
938
- encrypted_index: z7.string()
939
- }),
940
- pageLocation: z7.object({
941
- type: z7.literal("page_location"),
942
- cited_text: z7.string(),
943
- document_index: z7.number(),
944
- document_title: z7.string().nullable(),
945
- start_page_number: z7.number(),
946
- end_page_number: z7.number()
947
- }),
948
- charLocation: z7.object({
949
- type: z7.literal("char_location"),
950
- cited_text: z7.string(),
951
- document_index: z7.number(),
952
- document_title: z7.string().nullable(),
953
- start_char_index: z7.number(),
954
- end_char_index: z7.number()
955
- })
956
- };
957
- var citationSchema = z7.discriminatedUnion("type", [
958
- citationSchemas.webSearchResult,
959
- citationSchemas.pageLocation,
960
- citationSchemas.charLocation
961
- ]);
962
- var documentCitationSchema = z7.discriminatedUnion("type", [
963
- citationSchemas.pageLocation,
964
- citationSchemas.charLocation
965
- ]);
966
- function processCitation(citation, citationDocuments, generateId2, onSource) {
967
- if (citation.type === "page_location" || citation.type === "char_location") {
968
- const source = createCitationSource(
969
- citation,
970
- citationDocuments,
971
- generateId2
972
- );
973
- if (source) {
974
- onSource(source);
975
- }
976
- }
977
- }
978
1315
  function createCitationSource(citation, citationDocuments, generateId2) {
979
1316
  var _a;
1317
+ if (citation.type !== "page_location" && citation.type !== "char_location") {
1318
+ return;
1319
+ }
980
1320
  const documentInfo = citationDocuments[citation.document_index];
981
1321
  if (!documentInfo) {
982
- return null;
1322
+ return;
983
1323
  }
984
- const providerMetadata = citation.type === "page_location" ? {
985
- citedText: citation.cited_text,
986
- startPageNumber: citation.start_page_number,
987
- endPageNumber: citation.end_page_number
988
- } : {
989
- citedText: citation.cited_text,
990
- startCharIndex: citation.start_char_index,
991
- endCharIndex: citation.end_char_index
992
- };
993
1324
  return {
994
1325
  type: "source",
995
1326
  sourceType: "document",
@@ -998,7 +1329,15 @@ function createCitationSource(citation, citationDocuments, generateId2) {
998
1329
  title: (_a = citation.document_title) != null ? _a : documentInfo.title,
999
1330
  filename: documentInfo.filename,
1000
1331
  providerMetadata: {
1001
- anthropic: providerMetadata
1332
+ anthropic: citation.type === "page_location" ? {
1333
+ citedText: citation.cited_text,
1334
+ startPageNumber: citation.start_page_number,
1335
+ endPageNumber: citation.end_page_number
1336
+ } : {
1337
+ citedText: citation.cited_text,
1338
+ startCharIndex: citation.start_char_index,
1339
+ endCharIndex: citation.end_char_index
1340
+ }
1002
1341
  }
1003
1342
  };
1004
1343
  }
@@ -1008,7 +1347,7 @@ var AnthropicMessagesLanguageModel = class {
1008
1347
  var _a;
1009
1348
  this.modelId = modelId;
1010
1349
  this.config = config;
1011
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
1350
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1012
1351
  }
1013
1352
  supportsUrl(url) {
1014
1353
  return url.protocol === "https:";
@@ -1077,7 +1416,7 @@ var AnthropicMessagesLanguageModel = class {
1077
1416
  description: "Respond with a JSON object.",
1078
1417
  inputSchema: responseFormat.schema
1079
1418
  } : void 0;
1080
- const anthropicOptions = await (0, import_provider_utils7.parseProviderOptions)({
1419
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1081
1420
  provider: "anthropic",
1082
1421
  providerOptions,
1083
1422
  schema: anthropicProviderOptions
@@ -1143,7 +1482,7 @@ var AnthropicMessagesLanguageModel = class {
1143
1482
  toolChoice: anthropicToolChoice,
1144
1483
  toolWarnings,
1145
1484
  betas: toolsBetas
1146
- } = prepareTools(
1485
+ } = await prepareTools(
1147
1486
  jsonResponseTool != null ? {
1148
1487
  tools: [jsonResponseTool],
1149
1488
  toolChoice: { type: "tool", toolName: jsonResponseTool.name },
@@ -1169,8 +1508,8 @@ var AnthropicMessagesLanguageModel = class {
1169
1508
  betas,
1170
1509
  headers
1171
1510
  }) {
1172
- return (0, import_provider_utils7.combineHeaders)(
1173
- await (0, import_provider_utils7.resolve)(this.config.headers),
1511
+ return (0, import_provider_utils10.combineHeaders)(
1512
+ await (0, import_provider_utils10.resolve)(this.config.headers),
1174
1513
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1175
1514
  headers
1176
1515
  );
@@ -1214,12 +1553,12 @@ var AnthropicMessagesLanguageModel = class {
1214
1553
  responseHeaders,
1215
1554
  value: response,
1216
1555
  rawValue: rawResponse
1217
- } = await (0, import_provider_utils7.postJsonToApi)({
1556
+ } = await (0, import_provider_utils10.postJsonToApi)({
1218
1557
  url: this.buildRequestUrl(false),
1219
1558
  headers: await this.getHeaders({ betas, headers: options.headers }),
1220
1559
  body: this.transformRequestBody(args),
1221
1560
  failedResponseHandler: anthropicFailedResponseHandler,
1222
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1561
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1223
1562
  anthropicMessagesResponseSchema
1224
1563
  ),
1225
1564
  abortSignal: options.abortSignal,
@@ -1233,12 +1572,14 @@ var AnthropicMessagesLanguageModel = class {
1233
1572
  content.push({ type: "text", text: part.text });
1234
1573
  if (part.citations) {
1235
1574
  for (const citation of part.citations) {
1236
- processCitation(
1575
+ const source = createCitationSource(
1237
1576
  citation,
1238
1577
  citationDocuments,
1239
- this.generateId,
1240
- (source) => content.push(source)
1578
+ this.generateId
1241
1579
  );
1580
+ if (source) {
1581
+ content.push(source);
1582
+ }
1242
1583
  }
1243
1584
  }
1244
1585
  }
@@ -1444,12 +1785,12 @@ var AnthropicMessagesLanguageModel = class {
1444
1785
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1445
1786
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1446
1787
  const body = { ...args, stream: true };
1447
- const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
1788
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
1448
1789
  url: this.buildRequestUrl(true),
1449
1790
  headers: await this.getHeaders({ betas, headers: options.headers }),
1450
1791
  body: this.transformRequestBody(body),
1451
1792
  failedResponseHandler: anthropicFailedResponseHandler,
1452
- successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
1793
+ successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
1453
1794
  anthropicMessagesChunkSchema
1454
1795
  ),
1455
1796
  abortSignal: options.abortSignal,
@@ -1775,12 +2116,14 @@ var AnthropicMessagesLanguageModel = class {
1775
2116
  }
1776
2117
  case "citations_delta": {
1777
2118
  const citation = value.delta.citation;
1778
- processCitation(
2119
+ const source = createCitationSource(
1779
2120
  citation,
1780
2121
  citationDocuments,
1781
- generateId2,
1782
- (source) => controller.enqueue(source)
2122
+ generateId2
1783
2123
  );
2124
+ if (source) {
2125
+ controller.enqueue(source);
2126
+ }
1784
2127
  return;
1785
2128
  }
1786
2129
  default: {
@@ -1851,402 +2194,173 @@ var AnthropicMessagesLanguageModel = class {
1851
2194
  };
1852
2195
  }
1853
2196
  };
1854
- var anthropicMessagesResponseSchema = z7.object({
1855
- type: z7.literal("message"),
1856
- id: z7.string().nullish(),
1857
- model: z7.string().nullish(),
1858
- content: z7.array(
1859
- z7.discriminatedUnion("type", [
1860
- z7.object({
1861
- type: z7.literal("text"),
1862
- text: z7.string(),
1863
- citations: z7.array(citationSchema).optional()
1864
- }),
1865
- z7.object({
1866
- type: z7.literal("thinking"),
1867
- thinking: z7.string(),
1868
- signature: z7.string()
1869
- }),
1870
- z7.object({
1871
- type: z7.literal("redacted_thinking"),
1872
- data: z7.string()
1873
- }),
1874
- z7.object({
1875
- type: z7.literal("tool_use"),
1876
- id: z7.string(),
1877
- name: z7.string(),
1878
- input: z7.unknown()
1879
- }),
1880
- z7.object({
1881
- type: z7.literal("server_tool_use"),
1882
- id: z7.string(),
1883
- name: z7.string(),
1884
- input: z7.record(z7.string(), z7.unknown()).nullish()
1885
- }),
1886
- z7.object({
1887
- type: z7.literal("web_fetch_tool_result"),
1888
- tool_use_id: z7.string(),
1889
- content: z7.union([
1890
- z7.object({
1891
- type: z7.literal("web_fetch_result"),
1892
- url: z7.string(),
1893
- retrieved_at: z7.string(),
1894
- content: z7.object({
1895
- type: z7.literal("document"),
1896
- title: z7.string().nullable(),
1897
- citations: z7.object({ enabled: z7.boolean() }).optional(),
1898
- source: z7.object({
1899
- type: z7.literal("text"),
1900
- media_type: z7.string(),
1901
- data: z7.string()
1902
- })
1903
- })
1904
- }),
1905
- z7.object({
1906
- type: z7.literal("web_fetch_tool_result_error"),
1907
- error_code: z7.string()
1908
- })
1909
- ])
1910
- }),
1911
- z7.object({
1912
- type: z7.literal("web_search_tool_result"),
1913
- tool_use_id: z7.string(),
1914
- content: z7.union([
1915
- z7.array(
1916
- z7.object({
1917
- type: z7.literal("web_search_result"),
1918
- url: z7.string(),
1919
- title: z7.string(),
1920
- encrypted_content: z7.string(),
1921
- page_age: z7.string().nullish()
1922
- })
1923
- ),
1924
- z7.object({
1925
- type: z7.literal("web_search_tool_result_error"),
1926
- error_code: z7.string()
1927
- })
1928
- ])
1929
- }),
1930
- z7.object({
1931
- type: z7.literal("code_execution_tool_result"),
1932
- tool_use_id: z7.string(),
1933
- content: z7.union([
1934
- z7.object({
1935
- type: z7.literal("code_execution_result"),
1936
- stdout: z7.string(),
1937
- stderr: z7.string(),
1938
- return_code: z7.number()
1939
- }),
1940
- z7.object({
1941
- type: z7.literal("code_execution_tool_result_error"),
1942
- error_code: z7.string()
1943
- })
1944
- ])
1945
- })
1946
- ])
1947
- ),
1948
- stop_reason: z7.string().nullish(),
1949
- stop_sequence: z7.string().nullish(),
1950
- usage: z7.looseObject({
1951
- input_tokens: z7.number(),
1952
- output_tokens: z7.number(),
1953
- cache_creation_input_tokens: z7.number().nullish(),
1954
- cache_read_input_tokens: z7.number().nullish()
1955
- })
1956
- });
1957
- var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
1958
- z7.object({
1959
- type: z7.literal("message_start"),
1960
- message: z7.object({
1961
- id: z7.string().nullish(),
1962
- model: z7.string().nullish(),
1963
- usage: z7.looseObject({
1964
- input_tokens: z7.number(),
1965
- cache_creation_input_tokens: z7.number().nullish(),
1966
- cache_read_input_tokens: z7.number().nullish()
1967
- })
1968
- })
1969
- }),
1970
- z7.object({
1971
- type: z7.literal("content_block_start"),
1972
- index: z7.number(),
1973
- content_block: z7.discriminatedUnion("type", [
1974
- z7.object({
1975
- type: z7.literal("text"),
1976
- text: z7.string()
1977
- }),
1978
- z7.object({
1979
- type: z7.literal("thinking"),
1980
- thinking: z7.string()
1981
- }),
1982
- z7.object({
1983
- type: z7.literal("tool_use"),
1984
- id: z7.string(),
1985
- name: z7.string()
1986
- }),
1987
- z7.object({
1988
- type: z7.literal("redacted_thinking"),
1989
- data: z7.string()
1990
- }),
1991
- z7.object({
1992
- type: z7.literal("server_tool_use"),
1993
- id: z7.string(),
1994
- name: z7.string(),
1995
- input: z7.record(z7.string(), z7.unknown()).nullish()
1996
- }),
1997
- z7.object({
1998
- type: z7.literal("web_fetch_tool_result"),
1999
- tool_use_id: z7.string(),
2000
- content: z7.union([
2001
- z7.object({
2002
- type: z7.literal("web_fetch_result"),
2003
- url: z7.string(),
2004
- retrieved_at: z7.string(),
2005
- content: z7.object({
2006
- type: z7.literal("document"),
2007
- title: z7.string().nullable(),
2008
- citations: z7.object({ enabled: z7.boolean() }).optional(),
2009
- source: z7.object({
2010
- type: z7.literal("text"),
2011
- media_type: z7.string(),
2012
- data: z7.string()
2013
- })
2014
- })
2015
- }),
2016
- z7.object({
2017
- type: z7.literal("web_fetch_tool_result_error"),
2018
- error_code: z7.string()
2019
- })
2020
- ])
2021
- }),
2022
- z7.object({
2023
- type: z7.literal("web_search_tool_result"),
2024
- tool_use_id: z7.string(),
2025
- content: z7.union([
2026
- z7.array(
2027
- z7.object({
2028
- type: z7.literal("web_search_result"),
2029
- url: z7.string(),
2030
- title: z7.string(),
2031
- encrypted_content: z7.string(),
2032
- page_age: z7.string().nullish()
2033
- })
2034
- ),
2035
- z7.object({
2036
- type: z7.literal("web_search_tool_result_error"),
2037
- error_code: z7.string()
2038
- })
2039
- ])
2040
- }),
2041
- z7.object({
2042
- type: z7.literal("code_execution_tool_result"),
2043
- tool_use_id: z7.string(),
2044
- content: z7.union([
2045
- z7.object({
2046
- type: z7.literal("code_execution_result"),
2047
- stdout: z7.string(),
2048
- stderr: z7.string(),
2049
- return_code: z7.number()
2050
- }),
2051
- z7.object({
2052
- type: z7.literal("code_execution_tool_result_error"),
2053
- error_code: z7.string()
2054
- })
2055
- ])
2056
- })
2057
- ])
2058
- }),
2059
- z7.object({
2060
- type: z7.literal("content_block_delta"),
2061
- index: z7.number(),
2062
- delta: z7.discriminatedUnion("type", [
2063
- z7.object({
2064
- type: z7.literal("input_json_delta"),
2065
- partial_json: z7.string()
2066
- }),
2067
- z7.object({
2068
- type: z7.literal("text_delta"),
2069
- text: z7.string()
2070
- }),
2071
- z7.object({
2072
- type: z7.literal("thinking_delta"),
2073
- thinking: z7.string()
2074
- }),
2075
- z7.object({
2076
- type: z7.literal("signature_delta"),
2077
- signature: z7.string()
2078
- }),
2079
- z7.object({
2080
- type: z7.literal("citations_delta"),
2081
- citation: citationSchema
2082
- })
2083
- ])
2084
- }),
2085
- z7.object({
2086
- type: z7.literal("content_block_stop"),
2087
- index: z7.number()
2088
- }),
2089
- z7.object({
2090
- type: z7.literal("error"),
2091
- error: z7.object({
2092
- type: z7.string(),
2093
- message: z7.string()
2094
- })
2095
- }),
2096
- z7.object({
2097
- type: z7.literal("message_delta"),
2098
- delta: z7.object({
2099
- stop_reason: z7.string().nullish(),
2100
- stop_sequence: z7.string().nullish()
2101
- }),
2102
- usage: z7.looseObject({
2103
- output_tokens: z7.number(),
2104
- cache_creation_input_tokens: z7.number().nullish()
2105
- })
2106
- }),
2107
- z7.object({
2108
- type: z7.literal("message_stop")
2109
- }),
2110
- z7.object({
2111
- type: z7.literal("ping")
2112
- })
2113
- ]);
2114
- var anthropicReasoningMetadataSchema = z7.object({
2115
- signature: z7.string().optional(),
2116
- redactedData: z7.string().optional()
2117
- });
2118
2197
 
2119
2198
  // src/tool/bash_20241022.ts
2120
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
2121
- var import_v4 = __toESM(require("zod/v4"));
2122
- var bash_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
2199
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2200
+ var import_v48 = require("zod/v4");
2201
+ var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
2202
+ () => (0, import_provider_utils11.zodSchema)(
2203
+ import_v48.z.object({
2204
+ command: import_v48.z.string(),
2205
+ restart: import_v48.z.boolean().optional()
2206
+ })
2207
+ )
2208
+ );
2209
+ var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2123
2210
  id: "anthropic.bash_20241022",
2124
2211
  name: "bash",
2125
- inputSchema: import_v4.default.object({
2126
- command: import_v4.default.string(),
2127
- restart: import_v4.default.boolean().optional()
2128
- })
2212
+ inputSchema: bash_20241022InputSchema
2129
2213
  });
2130
2214
 
2131
2215
  // src/tool/bash_20250124.ts
2132
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
2133
- var import_v42 = __toESM(require("zod/v4"));
2134
- var bash_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
2216
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2217
+ var import_v49 = require("zod/v4");
2218
+ var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
2219
+ () => (0, import_provider_utils12.zodSchema)(
2220
+ import_v49.z.object({
2221
+ command: import_v49.z.string(),
2222
+ restart: import_v49.z.boolean().optional()
2223
+ })
2224
+ )
2225
+ );
2226
+ var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2135
2227
  id: "anthropic.bash_20250124",
2136
2228
  name: "bash",
2137
- inputSchema: import_v42.default.object({
2138
- command: import_v42.default.string(),
2139
- restart: import_v42.default.boolean().optional()
2140
- })
2229
+ inputSchema: bash_20250124InputSchema
2141
2230
  });
2142
2231
 
2143
2232
  // src/tool/computer_20241022.ts
2144
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
2145
- var z10 = __toESM(require("zod/v4"));
2146
- var computer_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
2233
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2234
+ var import_v410 = require("zod/v4");
2235
+ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2236
+ () => (0, import_provider_utils13.zodSchema)(
2237
+ import_v410.z.object({
2238
+ action: import_v410.z.enum([
2239
+ "key",
2240
+ "type",
2241
+ "mouse_move",
2242
+ "left_click",
2243
+ "left_click_drag",
2244
+ "right_click",
2245
+ "middle_click",
2246
+ "double_click",
2247
+ "screenshot",
2248
+ "cursor_position"
2249
+ ]),
2250
+ coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
2251
+ text: import_v410.z.string().optional()
2252
+ })
2253
+ )
2254
+ );
2255
+ var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2147
2256
  id: "anthropic.computer_20241022",
2148
2257
  name: "computer",
2149
- inputSchema: z10.object({
2150
- action: z10.enum([
2151
- "key",
2152
- "type",
2153
- "mouse_move",
2154
- "left_click",
2155
- "left_click_drag",
2156
- "right_click",
2157
- "middle_click",
2158
- "double_click",
2159
- "screenshot",
2160
- "cursor_position"
2161
- ]),
2162
- coordinate: z10.array(z10.number().int()).optional(),
2163
- text: z10.string().optional()
2164
- })
2258
+ inputSchema: computer_20241022InputSchema
2165
2259
  });
2166
2260
 
2167
2261
  // src/tool/computer_20250124.ts
2168
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2169
- var z11 = __toESM(require("zod/v4"));
2170
- var computer_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2262
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2263
+ var import_v411 = require("zod/v4");
2264
+ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2265
+ () => (0, import_provider_utils14.zodSchema)(
2266
+ import_v411.z.object({
2267
+ action: import_v411.z.enum([
2268
+ "key",
2269
+ "hold_key",
2270
+ "type",
2271
+ "cursor_position",
2272
+ "mouse_move",
2273
+ "left_mouse_down",
2274
+ "left_mouse_up",
2275
+ "left_click",
2276
+ "left_click_drag",
2277
+ "right_click",
2278
+ "middle_click",
2279
+ "double_click",
2280
+ "triple_click",
2281
+ "scroll",
2282
+ "wait",
2283
+ "screenshot"
2284
+ ]),
2285
+ coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2286
+ duration: import_v411.z.number().optional(),
2287
+ scroll_amount: import_v411.z.number().optional(),
2288
+ scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
2289
+ start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2290
+ text: import_v411.z.string().optional()
2291
+ })
2292
+ )
2293
+ );
2294
+ var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2171
2295
  id: "anthropic.computer_20250124",
2172
2296
  name: "computer",
2173
- inputSchema: z11.object({
2174
- action: z11.enum([
2175
- "key",
2176
- "hold_key",
2177
- "type",
2178
- "cursor_position",
2179
- "mouse_move",
2180
- "left_mouse_down",
2181
- "left_mouse_up",
2182
- "left_click",
2183
- "left_click_drag",
2184
- "right_click",
2185
- "middle_click",
2186
- "double_click",
2187
- "triple_click",
2188
- "scroll",
2189
- "wait",
2190
- "screenshot"
2191
- ]),
2192
- coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2193
- duration: z11.number().optional(),
2194
- scroll_amount: z11.number().optional(),
2195
- scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
2196
- start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2197
- text: z11.string().optional()
2198
- })
2297
+ inputSchema: computer_20250124InputSchema
2199
2298
  });
2200
2299
 
2201
2300
  // src/tool/text-editor_20241022.ts
2202
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2203
- var z12 = __toESM(require("zod/v4"));
2204
- var textEditor_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2301
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
2302
+ var import_v412 = require("zod/v4");
2303
+ var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
2304
+ () => (0, import_provider_utils15.zodSchema)(
2305
+ import_v412.z.object({
2306
+ command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2307
+ path: import_v412.z.string(),
2308
+ file_text: import_v412.z.string().optional(),
2309
+ insert_line: import_v412.z.number().int().optional(),
2310
+ new_str: import_v412.z.string().optional(),
2311
+ old_str: import_v412.z.string().optional(),
2312
+ view_range: import_v412.z.array(import_v412.z.number().int()).optional()
2313
+ })
2314
+ )
2315
+ );
2316
+ var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2205
2317
  id: "anthropic.text_editor_20241022",
2206
2318
  name: "str_replace_editor",
2207
- inputSchema: z12.object({
2208
- command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2209
- path: z12.string(),
2210
- file_text: z12.string().optional(),
2211
- insert_line: z12.number().int().optional(),
2212
- new_str: z12.string().optional(),
2213
- old_str: z12.string().optional(),
2214
- view_range: z12.array(z12.number().int()).optional()
2215
- })
2319
+ inputSchema: textEditor_20241022InputSchema
2216
2320
  });
2217
2321
 
2218
2322
  // src/tool/text-editor_20250124.ts
2219
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2220
- var z13 = __toESM(require("zod/v4"));
2221
- var textEditor_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2323
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
2324
+ var import_v413 = require("zod/v4");
2325
+ var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2326
+ () => (0, import_provider_utils16.zodSchema)(
2327
+ import_v413.z.object({
2328
+ command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2329
+ path: import_v413.z.string(),
2330
+ file_text: import_v413.z.string().optional(),
2331
+ insert_line: import_v413.z.number().int().optional(),
2332
+ new_str: import_v413.z.string().optional(),
2333
+ old_str: import_v413.z.string().optional(),
2334
+ view_range: import_v413.z.array(import_v413.z.number().int()).optional()
2335
+ })
2336
+ )
2337
+ );
2338
+ var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2222
2339
  id: "anthropic.text_editor_20250124",
2223
2340
  name: "str_replace_editor",
2224
- inputSchema: z13.object({
2225
- command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2226
- path: z13.string(),
2227
- file_text: z13.string().optional(),
2228
- insert_line: z13.number().int().optional(),
2229
- new_str: z13.string().optional(),
2230
- old_str: z13.string().optional(),
2231
- view_range: z13.array(z13.number().int()).optional()
2232
- })
2341
+ inputSchema: textEditor_20250124InputSchema
2233
2342
  });
2234
2343
 
2235
2344
  // src/tool/text-editor_20250429.ts
2236
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2237
- var z14 = __toESM(require("zod/v4"));
2238
- var textEditor_20250429 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2345
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
2346
+ var import_v414 = require("zod/v4");
2347
+ var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2348
+ () => (0, import_provider_utils17.zodSchema)(
2349
+ import_v414.z.object({
2350
+ command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
2351
+ path: import_v414.z.string(),
2352
+ file_text: import_v414.z.string().optional(),
2353
+ insert_line: import_v414.z.number().int().optional(),
2354
+ new_str: import_v414.z.string().optional(),
2355
+ old_str: import_v414.z.string().optional(),
2356
+ view_range: import_v414.z.array(import_v414.z.number().int()).optional()
2357
+ })
2358
+ )
2359
+ );
2360
+ var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2239
2361
  id: "anthropic.text_editor_20250429",
2240
2362
  name: "str_replace_based_edit_tool",
2241
- inputSchema: z14.object({
2242
- command: z14.enum(["view", "create", "str_replace", "insert"]),
2243
- path: z14.string(),
2244
- file_text: z14.string().optional(),
2245
- insert_line: z14.number().int().optional(),
2246
- new_str: z14.string().optional(),
2247
- old_str: z14.string().optional(),
2248
- view_range: z14.array(z14.number().int()).optional()
2249
- })
2363
+ inputSchema: textEditor_20250429InputSchema
2250
2364
  });
2251
2365
 
2252
2366
  // src/anthropic-tools.ts