@ai-sdk/anthropic 3.0.0-beta.15 → 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.
@@ -38,67 +38,400 @@ module.exports = __toCommonJS(internal_exports);
38
38
 
39
39
  // src/anthropic-messages-language-model.ts
40
40
  var import_provider3 = require("@ai-sdk/provider");
41
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
42
- var z7 = __toESM(require("zod/v4"));
41
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
43
42
 
44
43
  // src/anthropic-error.ts
45
44
  var import_provider_utils = require("@ai-sdk/provider-utils");
46
45
  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
- });
46
+ var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
47
+ () => (0, import_provider_utils.zodSchema)(
48
+ z.object({
49
+ type: z.literal("error"),
50
+ error: z.object({
51
+ type: z.string(),
52
+ message: z.string()
53
+ })
54
+ })
55
+ )
56
+ );
54
57
  var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
55
58
  errorSchema: anthropicErrorDataSchema,
56
59
  errorToMessage: (data) => data.error.message
57
60
  });
58
61
 
59
- // src/anthropic-messages-options.ts
62
+ // src/anthropic-messages-api.ts
63
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
60
64
  var z2 = __toESM(require("zod/v4"));
61
- var anthropicFilePartProviderOptions = z2.object({
65
+ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
66
+ () => (0, import_provider_utils2.zodSchema)(
67
+ z2.object({
68
+ type: z2.literal("message"),
69
+ id: z2.string().nullish(),
70
+ model: z2.string().nullish(),
71
+ content: z2.array(
72
+ z2.discriminatedUnion("type", [
73
+ z2.object({
74
+ type: z2.literal("text"),
75
+ text: z2.string(),
76
+ citations: z2.array(
77
+ z2.discriminatedUnion("type", [
78
+ z2.object({
79
+ type: z2.literal("web_search_result_location"),
80
+ cited_text: z2.string(),
81
+ url: z2.string(),
82
+ title: z2.string(),
83
+ encrypted_index: z2.string()
84
+ }),
85
+ z2.object({
86
+ type: z2.literal("page_location"),
87
+ cited_text: z2.string(),
88
+ document_index: z2.number(),
89
+ document_title: z2.string().nullable(),
90
+ start_page_number: z2.number(),
91
+ end_page_number: z2.number()
92
+ }),
93
+ z2.object({
94
+ type: z2.literal("char_location"),
95
+ cited_text: z2.string(),
96
+ document_index: z2.number(),
97
+ document_title: z2.string().nullable(),
98
+ start_char_index: z2.number(),
99
+ end_char_index: z2.number()
100
+ })
101
+ ])
102
+ ).optional()
103
+ }),
104
+ z2.object({
105
+ type: z2.literal("thinking"),
106
+ thinking: z2.string(),
107
+ signature: z2.string()
108
+ }),
109
+ z2.object({
110
+ type: z2.literal("redacted_thinking"),
111
+ data: z2.string()
112
+ }),
113
+ z2.object({
114
+ type: z2.literal("tool_use"),
115
+ id: z2.string(),
116
+ name: z2.string(),
117
+ input: z2.unknown()
118
+ }),
119
+ z2.object({
120
+ type: z2.literal("server_tool_use"),
121
+ id: z2.string(),
122
+ name: z2.string(),
123
+ input: z2.record(z2.string(), z2.unknown()).nullish()
124
+ }),
125
+ z2.object({
126
+ type: z2.literal("web_fetch_tool_result"),
127
+ tool_use_id: z2.string(),
128
+ content: z2.union([
129
+ z2.object({
130
+ type: z2.literal("web_fetch_result"),
131
+ url: z2.string(),
132
+ retrieved_at: z2.string(),
133
+ content: z2.object({
134
+ type: z2.literal("document"),
135
+ title: z2.string().nullable(),
136
+ citations: z2.object({ enabled: z2.boolean() }).optional(),
137
+ source: z2.object({
138
+ type: z2.literal("text"),
139
+ media_type: z2.string(),
140
+ data: z2.string()
141
+ })
142
+ })
143
+ }),
144
+ z2.object({
145
+ type: z2.literal("web_fetch_tool_result_error"),
146
+ error_code: z2.string()
147
+ })
148
+ ])
149
+ }),
150
+ z2.object({
151
+ type: z2.literal("web_search_tool_result"),
152
+ tool_use_id: z2.string(),
153
+ content: z2.union([
154
+ z2.array(
155
+ z2.object({
156
+ type: z2.literal("web_search_result"),
157
+ url: z2.string(),
158
+ title: z2.string(),
159
+ encrypted_content: z2.string(),
160
+ page_age: z2.string().nullish()
161
+ })
162
+ ),
163
+ z2.object({
164
+ type: z2.literal("web_search_tool_result_error"),
165
+ error_code: z2.string()
166
+ })
167
+ ])
168
+ }),
169
+ z2.object({
170
+ type: z2.literal("code_execution_tool_result"),
171
+ tool_use_id: z2.string(),
172
+ content: z2.union([
173
+ z2.object({
174
+ type: z2.literal("code_execution_result"),
175
+ stdout: z2.string(),
176
+ stderr: z2.string(),
177
+ return_code: z2.number()
178
+ }),
179
+ z2.object({
180
+ type: z2.literal("code_execution_tool_result_error"),
181
+ error_code: z2.string()
182
+ })
183
+ ])
184
+ })
185
+ ])
186
+ ),
187
+ stop_reason: z2.string().nullish(),
188
+ stop_sequence: z2.string().nullish(),
189
+ usage: z2.looseObject({
190
+ input_tokens: z2.number(),
191
+ output_tokens: z2.number(),
192
+ cache_creation_input_tokens: z2.number().nullish(),
193
+ cache_read_input_tokens: z2.number().nullish()
194
+ })
195
+ })
196
+ )
197
+ );
198
+ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
199
+ () => (0, import_provider_utils2.zodSchema)(
200
+ z2.discriminatedUnion("type", [
201
+ z2.object({
202
+ type: z2.literal("message_start"),
203
+ message: z2.object({
204
+ id: z2.string().nullish(),
205
+ model: z2.string().nullish(),
206
+ usage: z2.looseObject({
207
+ input_tokens: z2.number(),
208
+ cache_creation_input_tokens: z2.number().nullish(),
209
+ cache_read_input_tokens: z2.number().nullish()
210
+ })
211
+ })
212
+ }),
213
+ z2.object({
214
+ type: z2.literal("content_block_start"),
215
+ index: z2.number(),
216
+ content_block: z2.discriminatedUnion("type", [
217
+ z2.object({
218
+ type: z2.literal("text"),
219
+ text: z2.string()
220
+ }),
221
+ z2.object({
222
+ type: z2.literal("thinking"),
223
+ thinking: z2.string()
224
+ }),
225
+ z2.object({
226
+ type: z2.literal("tool_use"),
227
+ id: z2.string(),
228
+ name: z2.string()
229
+ }),
230
+ z2.object({
231
+ type: z2.literal("redacted_thinking"),
232
+ data: z2.string()
233
+ }),
234
+ z2.object({
235
+ type: z2.literal("server_tool_use"),
236
+ id: z2.string(),
237
+ name: z2.string(),
238
+ input: z2.record(z2.string(), z2.unknown()).nullish()
239
+ }),
240
+ z2.object({
241
+ type: z2.literal("web_fetch_tool_result"),
242
+ tool_use_id: z2.string(),
243
+ content: z2.union([
244
+ z2.object({
245
+ type: z2.literal("web_fetch_result"),
246
+ url: z2.string(),
247
+ retrieved_at: z2.string(),
248
+ content: z2.object({
249
+ type: z2.literal("document"),
250
+ title: z2.string().nullable(),
251
+ citations: z2.object({ enabled: z2.boolean() }).optional(),
252
+ source: z2.object({
253
+ type: z2.literal("text"),
254
+ media_type: z2.string(),
255
+ data: z2.string()
256
+ })
257
+ })
258
+ }),
259
+ z2.object({
260
+ type: z2.literal("web_fetch_tool_result_error"),
261
+ error_code: z2.string()
262
+ })
263
+ ])
264
+ }),
265
+ z2.object({
266
+ type: z2.literal("web_search_tool_result"),
267
+ tool_use_id: z2.string(),
268
+ content: z2.union([
269
+ z2.array(
270
+ z2.object({
271
+ type: z2.literal("web_search_result"),
272
+ url: z2.string(),
273
+ title: z2.string(),
274
+ encrypted_content: z2.string(),
275
+ page_age: z2.string().nullish()
276
+ })
277
+ ),
278
+ z2.object({
279
+ type: z2.literal("web_search_tool_result_error"),
280
+ error_code: z2.string()
281
+ })
282
+ ])
283
+ }),
284
+ z2.object({
285
+ type: z2.literal("code_execution_tool_result"),
286
+ tool_use_id: z2.string(),
287
+ content: z2.union([
288
+ z2.object({
289
+ type: z2.literal("code_execution_result"),
290
+ stdout: z2.string(),
291
+ stderr: z2.string(),
292
+ return_code: z2.number()
293
+ }),
294
+ z2.object({
295
+ type: z2.literal("code_execution_tool_result_error"),
296
+ error_code: z2.string()
297
+ })
298
+ ])
299
+ })
300
+ ])
301
+ }),
302
+ z2.object({
303
+ type: z2.literal("content_block_delta"),
304
+ index: z2.number(),
305
+ delta: z2.discriminatedUnion("type", [
306
+ z2.object({
307
+ type: z2.literal("input_json_delta"),
308
+ partial_json: z2.string()
309
+ }),
310
+ z2.object({
311
+ type: z2.literal("text_delta"),
312
+ text: z2.string()
313
+ }),
314
+ z2.object({
315
+ type: z2.literal("thinking_delta"),
316
+ thinking: z2.string()
317
+ }),
318
+ z2.object({
319
+ type: z2.literal("signature_delta"),
320
+ signature: z2.string()
321
+ }),
322
+ z2.object({
323
+ type: z2.literal("citations_delta"),
324
+ citation: z2.discriminatedUnion("type", [
325
+ z2.object({
326
+ type: z2.literal("web_search_result_location"),
327
+ cited_text: z2.string(),
328
+ url: z2.string(),
329
+ title: z2.string(),
330
+ encrypted_index: z2.string()
331
+ }),
332
+ z2.object({
333
+ type: z2.literal("page_location"),
334
+ cited_text: z2.string(),
335
+ document_index: z2.number(),
336
+ document_title: z2.string().nullable(),
337
+ start_page_number: z2.number(),
338
+ end_page_number: z2.number()
339
+ }),
340
+ z2.object({
341
+ type: z2.literal("char_location"),
342
+ cited_text: z2.string(),
343
+ document_index: z2.number(),
344
+ document_title: z2.string().nullable(),
345
+ start_char_index: z2.number(),
346
+ end_char_index: z2.number()
347
+ })
348
+ ])
349
+ })
350
+ ])
351
+ }),
352
+ z2.object({
353
+ type: z2.literal("content_block_stop"),
354
+ index: z2.number()
355
+ }),
356
+ z2.object({
357
+ type: z2.literal("error"),
358
+ error: z2.object({
359
+ type: z2.string(),
360
+ message: z2.string()
361
+ })
362
+ }),
363
+ z2.object({
364
+ type: z2.literal("message_delta"),
365
+ delta: z2.object({
366
+ stop_reason: z2.string().nullish(),
367
+ stop_sequence: z2.string().nullish()
368
+ }),
369
+ usage: z2.looseObject({
370
+ output_tokens: z2.number(),
371
+ cache_creation_input_tokens: z2.number().nullish()
372
+ })
373
+ }),
374
+ z2.object({
375
+ type: z2.literal("message_stop")
376
+ }),
377
+ z2.object({
378
+ type: z2.literal("ping")
379
+ })
380
+ ])
381
+ )
382
+ );
383
+ var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
384
+ () => (0, import_provider_utils2.zodSchema)(
385
+ z2.object({
386
+ signature: z2.string().optional(),
387
+ redactedData: z2.string().optional()
388
+ })
389
+ )
390
+ );
391
+
392
+ // src/anthropic-messages-options.ts
393
+ var z3 = __toESM(require("zod/v4"));
394
+ var anthropicFilePartProviderOptions = z3.object({
62
395
  /**
63
396
  * Citation configuration for this document.
64
397
  * When enabled, this document will generate citations in the response.
65
398
  */
66
- citations: z2.object({
399
+ citations: z3.object({
67
400
  /**
68
401
  * Enable citations for this document
69
402
  */
70
- enabled: z2.boolean()
403
+ enabled: z3.boolean()
71
404
  }).optional(),
72
405
  /**
73
406
  * Custom title for the document.
74
407
  * If not provided, the filename will be used.
75
408
  */
76
- title: z2.string().optional(),
409
+ title: z3.string().optional(),
77
410
  /**
78
411
  * Context about the document that will be passed to the model
79
412
  * but not used towards cited content.
80
413
  * Useful for storing document metadata as text or stringified JSON.
81
414
  */
82
- context: z2.string().optional()
415
+ context: z3.string().optional()
83
416
  });
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()
417
+ var anthropicProviderOptions = z3.object({
418
+ sendReasoning: z3.boolean().optional(),
419
+ thinking: z3.object({
420
+ type: z3.union([z3.literal("enabled"), z3.literal("disabled")]),
421
+ budgetTokens: z3.number().optional()
89
422
  }).optional(),
90
423
  /**
91
424
  * Whether to disable parallel function calling during tool use. Default is false.
92
425
  * When set to true, Claude will use at most one tool per response.
93
426
  */
94
- disableParallelToolUse: z2.boolean().optional(),
427
+ disableParallelToolUse: z3.boolean().optional(),
95
428
  /**
96
429
  * Cache control settings for this message.
97
430
  * See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
98
431
  */
99
- cacheControl: z2.object({
100
- type: z2.literal("ephemeral"),
101
- ttl: z2.union([z2.literal("5m"), z2.literal("1h")]).optional()
432
+ cacheControl: z3.object({
433
+ type: z3.literal("ephemeral"),
434
+ ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
102
435
  }).optional()
103
436
  });
104
437
 
@@ -114,58 +447,81 @@ function getCacheControl(providerMetadata) {
114
447
  }
115
448
 
116
449
  // 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)({
450
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
451
+ var z4 = __toESM(require("zod/v4"));
452
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
453
+ var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
454
+ () => (0, import_provider_utils4.zodSchema)(
455
+ z4.object({
456
+ maxCharacters: z4.number().optional()
457
+ })
458
+ )
459
+ );
460
+ var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
461
+ () => (0, import_provider_utils4.zodSchema)(
462
+ z4.object({
463
+ command: z4.enum(["view", "create", "str_replace", "insert"]),
464
+ path: z4.string(),
465
+ file_text: z4.string().optional(),
466
+ insert_line: z4.number().int().optional(),
467
+ new_str: z4.string().optional(),
468
+ old_str: z4.string().optional(),
469
+ view_range: z4.array(z4.number().int()).optional()
470
+ })
471
+ )
472
+ );
473
+ var factory = (0, import_provider_utils3.createProviderDefinedToolFactory)({
123
474
  id: "anthropic.text_editor_20250728",
124
475
  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
- })
476
+ inputSchema: textEditor_20250728InputSchema
134
477
  });
135
478
  var textEditor_20250728 = (args = {}) => {
136
479
  return factory(args);
137
480
  };
138
481
 
139
482
  // 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
- })
483
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
484
+ var z5 = __toESM(require("zod/v4"));
485
+ var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
486
+ () => (0, import_provider_utils5.zodSchema)(
487
+ z5.object({
488
+ maxUses: z5.number().optional(),
489
+ allowedDomains: z5.array(z5.string()).optional(),
490
+ blockedDomains: z5.array(z5.string()).optional(),
491
+ userLocation: z5.object({
492
+ type: z5.literal("approximate"),
493
+ city: z5.string().optional(),
494
+ region: z5.string().optional(),
495
+ country: z5.string().optional(),
496
+ timezone: z5.string().optional()
497
+ }).optional()
498
+ })
499
+ )
162
500
  );
163
- var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
501
+ var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
502
+ () => (0, import_provider_utils5.zodSchema)(
503
+ z5.array(
504
+ z5.object({
505
+ url: z5.string(),
506
+ title: z5.string(),
507
+ pageAge: z5.string().nullable(),
508
+ encryptedContent: z5.string(),
509
+ type: z5.literal("web_search_result")
510
+ })
511
+ )
512
+ )
513
+ );
514
+ var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
515
+ () => (0, import_provider_utils5.zodSchema)(
516
+ z5.object({
517
+ query: z5.string()
518
+ })
519
+ )
520
+ );
521
+ var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
164
522
  id: "anthropic.web_search_20250305",
165
523
  name: "web_search",
166
- inputSchema: z4.object({
167
- query: z4.string()
168
- }),
524
+ inputSchema: webSearch_20250305InputSchema,
169
525
  outputSchema: webSearch_20250305OutputSchema
170
526
  });
171
527
  var webSearch_20250305 = (args = {}) => {
@@ -173,43 +529,56 @@ var webSearch_20250305 = (args = {}) => {
173
529
  };
174
530
 
175
531
  // 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()
532
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
533
+ var z6 = __toESM(require("zod/v4"));
534
+ var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
535
+ () => (0, import_provider_utils6.zodSchema)(
536
+ z6.object({
537
+ maxUses: z6.number().optional(),
538
+ allowedDomains: z6.array(z6.string()).optional(),
539
+ blockedDomains: z6.array(z6.string()).optional(),
540
+ citations: z6.object({ enabled: z6.boolean() }).optional(),
541
+ maxContentTokens: z6.number().optional()
542
+ })
543
+ )
544
+ );
545
+ var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
546
+ () => (0, import_provider_utils6.zodSchema)(
547
+ z6.object({
548
+ type: z6.literal("web_fetch_result"),
549
+ url: z6.string(),
550
+ content: z6.object({
551
+ type: z6.literal("document"),
552
+ title: z6.string(),
553
+ citations: z6.object({ enabled: z6.boolean() }).optional(),
554
+ source: z6.union([
555
+ z6.object({
556
+ type: z6.literal("base64"),
557
+ mediaType: z6.literal("application/pdf"),
558
+ data: z6.string()
559
+ }),
560
+ z6.object({
561
+ type: z6.literal("text"),
562
+ mediaType: z6.literal("text/plain"),
563
+ data: z6.string()
564
+ })
565
+ ])
197
566
  }),
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)({
567
+ retrievedAt: z6.string().nullable()
568
+ })
569
+ )
570
+ );
571
+ var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
572
+ () => (0, import_provider_utils6.zodSchema)(
573
+ z6.object({
574
+ url: z6.string()
575
+ })
576
+ )
577
+ );
578
+ var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
208
579
  id: "anthropic.web_fetch_20250910",
209
580
  name: "web_fetch",
210
- inputSchema: z5.object({
211
- url: z5.string()
212
- }),
581
+ inputSchema: webFetch_20250910InputSchema,
213
582
  outputSchema: webFetch_20250910OutputSchema
214
583
  });
215
584
  var webFetch_20250910 = (args = {}) => {
@@ -217,7 +586,8 @@ var webFetch_20250910 = (args = {}) => {
217
586
  };
218
587
 
219
588
  // src/anthropic-prepare-tools.ts
220
- function prepareTools({
589
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
590
+ async function prepareTools({
221
591
  tools,
222
592
  toolChoice,
223
593
  disableParallelToolUse
@@ -298,7 +668,10 @@ function prepareTools({
298
668
  break;
299
669
  }
300
670
  case "anthropic.text_editor_20250728": {
301
- const args = textEditor_20250728ArgsSchema.parse(tool.args);
671
+ const args = await (0, import_provider_utils7.validateTypes)({
672
+ value: tool.args,
673
+ schema: textEditor_20250728ArgsSchema
674
+ });
302
675
  anthropicTools2.push({
303
676
  name: "str_replace_based_edit_tool",
304
677
  type: "text_editor_20250728",
@@ -324,7 +697,10 @@ function prepareTools({
324
697
  }
325
698
  case "anthropic.web_fetch_20250910": {
326
699
  betas.add("web-fetch-2025-09-10");
327
- const args = webFetch_20250910ArgsSchema.parse(tool.args);
700
+ const args = await (0, import_provider_utils7.validateTypes)({
701
+ value: tool.args,
702
+ schema: webFetch_20250910ArgsSchema
703
+ });
328
704
  anthropicTools2.push({
329
705
  type: "web_fetch_20250910",
330
706
  name: "web_fetch",
@@ -337,7 +713,10 @@ function prepareTools({
337
713
  break;
338
714
  }
339
715
  case "anthropic.web_search_20250305": {
340
- const args = webSearch_20250305ArgsSchema.parse(tool.args);
716
+ const args = await (0, import_provider_utils7.validateTypes)({
717
+ value: tool.args,
718
+ schema: webSearch_20250305ArgsSchema
719
+ });
341
720
  anthropicTools2.push({
342
721
  type: "web_search_20250305",
343
722
  name: "web_search",
@@ -415,23 +794,32 @@ function prepareTools({
415
794
 
416
795
  // src/convert-to-anthropic-messages-prompt.ts
417
796
  var import_provider2 = require("@ai-sdk/provider");
418
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
797
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
419
798
 
420
799
  // 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)({
800
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
801
+ var z7 = __toESM(require("zod/v4"));
802
+ var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
803
+ () => (0, import_provider_utils8.zodSchema)(
804
+ z7.object({
805
+ type: z7.literal("code_execution_result"),
806
+ stdout: z7.string(),
807
+ stderr: z7.string(),
808
+ return_code: z7.number()
809
+ })
810
+ )
811
+ );
812
+ var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
813
+ () => (0, import_provider_utils8.zodSchema)(
814
+ z7.object({
815
+ code: z7.string()
816
+ })
817
+ )
818
+ );
819
+ var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
430
820
  id: "anthropic.code_execution_20250522",
431
821
  name: "code_execution",
432
- inputSchema: z6.object({
433
- code: z6.string()
434
- }),
822
+ inputSchema: codeExecution_20250522InputSchema,
435
823
  outputSchema: codeExecution_20250522OutputSchema
436
824
  });
437
825
  var codeExecution_20250522 = (args = {}) => {
@@ -467,7 +855,7 @@ async function convertToAnthropicMessagesPrompt({
467
855
  const messages = [];
468
856
  async function shouldEnableCitations(providerMetadata) {
469
857
  var _a2, _b2;
470
- const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
858
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
471
859
  provider: "anthropic",
472
860
  providerOptions: providerMetadata,
473
861
  schema: anthropicFilePartProviderOptions
@@ -475,7 +863,7 @@ async function convertToAnthropicMessagesPrompt({
475
863
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
476
864
  }
477
865
  async function getDocumentMetadata(providerMetadata) {
478
- const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
866
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
479
867
  provider: "anthropic",
480
868
  providerOptions: providerMetadata,
481
869
  schema: anthropicFilePartProviderOptions
@@ -532,7 +920,7 @@ async function convertToAnthropicMessagesPrompt({
532
920
  } : {
533
921
  type: "base64",
534
922
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
535
- data: (0, import_provider_utils6.convertToBase64)(part.data)
923
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
536
924
  },
537
925
  cache_control: cacheControl
538
926
  });
@@ -552,7 +940,7 @@ async function convertToAnthropicMessagesPrompt({
552
940
  } : {
553
941
  type: "base64",
554
942
  media_type: "application/pdf",
555
- data: (0, import_provider_utils6.convertToBase64)(part.data)
943
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
556
944
  },
557
945
  title: (_b = metadata.title) != null ? _b : part.filename,
558
946
  ...metadata.context && { context: metadata.context },
@@ -690,7 +1078,7 @@ async function convertToAnthropicMessagesPrompt({
690
1078
  }
691
1079
  case "reasoning": {
692
1080
  if (sendReasoning) {
693
- const reasoningMetadata = await (0, import_provider_utils6.parseProviderOptions)({
1081
+ const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
694
1082
  provider: "anthropic",
695
1083
  providerOptions: part.providerOptions,
696
1084
  schema: anthropicReasoningMetadataSchema
@@ -766,7 +1154,10 @@ async function convertToAnthropicMessagesPrompt({
766
1154
  });
767
1155
  break;
768
1156
  }
769
- const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
1157
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1158
+ value: output.value,
1159
+ schema: codeExecution_20250522OutputSchema
1160
+ });
770
1161
  anthropicContent.push({
771
1162
  type: "code_execution_tool_result",
772
1163
  tool_use_id: part.toolCallId,
@@ -789,9 +1180,10 @@ async function convertToAnthropicMessagesPrompt({
789
1180
  });
790
1181
  break;
791
1182
  }
792
- const webFetchOutput = webFetch_20250910OutputSchema.parse(
793
- output.value
794
- );
1183
+ const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1184
+ value: output.value,
1185
+ schema: webFetch_20250910OutputSchema
1186
+ });
795
1187
  anthropicContent.push({
796
1188
  type: "web_fetch_tool_result",
797
1189
  tool_use_id: part.toolCallId,
@@ -823,9 +1215,10 @@ async function convertToAnthropicMessagesPrompt({
823
1215
  });
824
1216
  break;
825
1217
  }
826
- const webSearchOutput = webSearch_20250305OutputSchema.parse(
827
- output.value
828
- );
1218
+ const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1219
+ value: output.value,
1220
+ schema: webSearch_20250305OutputSchema
1221
+ });
829
1222
  anthropicContent.push({
830
1223
  type: "web_search_tool_result",
831
1224
  tool_use_id: part.toolCallId,
@@ -932,67 +1325,15 @@ function mapAnthropicStopReason({
932
1325
  }
933
1326
 
934
1327
  // src/anthropic-messages-language-model.ts
935
- var citationSchemas = {
936
- webSearchResult: z7.object({
937
- type: z7.literal("web_search_result_location"),
938
- cited_text: z7.string(),
939
- url: z7.string(),
940
- title: z7.string(),
941
- encrypted_index: z7.string()
942
- }),
943
- pageLocation: z7.object({
944
- type: z7.literal("page_location"),
945
- cited_text: z7.string(),
946
- document_index: z7.number(),
947
- document_title: z7.string().nullable(),
948
- start_page_number: z7.number(),
949
- end_page_number: z7.number()
950
- }),
951
- charLocation: z7.object({
952
- type: z7.literal("char_location"),
953
- cited_text: z7.string(),
954
- document_index: z7.number(),
955
- document_title: z7.string().nullable(),
956
- start_char_index: z7.number(),
957
- end_char_index: z7.number()
958
- })
959
- };
960
- var citationSchema = z7.discriminatedUnion("type", [
961
- citationSchemas.webSearchResult,
962
- citationSchemas.pageLocation,
963
- citationSchemas.charLocation
964
- ]);
965
- var documentCitationSchema = z7.discriminatedUnion("type", [
966
- citationSchemas.pageLocation,
967
- citationSchemas.charLocation
968
- ]);
969
- function processCitation(citation, citationDocuments, generateId2, onSource) {
970
- if (citation.type === "page_location" || citation.type === "char_location") {
971
- const source = createCitationSource(
972
- citation,
973
- citationDocuments,
974
- generateId2
975
- );
976
- if (source) {
977
- onSource(source);
978
- }
979
- }
980
- }
981
1328
  function createCitationSource(citation, citationDocuments, generateId2) {
982
1329
  var _a;
1330
+ if (citation.type !== "page_location" && citation.type !== "char_location") {
1331
+ return;
1332
+ }
983
1333
  const documentInfo = citationDocuments[citation.document_index];
984
1334
  if (!documentInfo) {
985
- return null;
1335
+ return;
986
1336
  }
987
- const providerMetadata = citation.type === "page_location" ? {
988
- citedText: citation.cited_text,
989
- startPageNumber: citation.start_page_number,
990
- endPageNumber: citation.end_page_number
991
- } : {
992
- citedText: citation.cited_text,
993
- startCharIndex: citation.start_char_index,
994
- endCharIndex: citation.end_char_index
995
- };
996
1337
  return {
997
1338
  type: "source",
998
1339
  sourceType: "document",
@@ -1001,7 +1342,15 @@ function createCitationSource(citation, citationDocuments, generateId2) {
1001
1342
  title: (_a = citation.document_title) != null ? _a : documentInfo.title,
1002
1343
  filename: documentInfo.filename,
1003
1344
  providerMetadata: {
1004
- anthropic: providerMetadata
1345
+ anthropic: citation.type === "page_location" ? {
1346
+ citedText: citation.cited_text,
1347
+ startPageNumber: citation.start_page_number,
1348
+ endPageNumber: citation.end_page_number
1349
+ } : {
1350
+ citedText: citation.cited_text,
1351
+ startCharIndex: citation.start_char_index,
1352
+ endCharIndex: citation.end_char_index
1353
+ }
1005
1354
  }
1006
1355
  };
1007
1356
  }
@@ -1011,7 +1360,7 @@ var AnthropicMessagesLanguageModel = class {
1011
1360
  var _a;
1012
1361
  this.modelId = modelId;
1013
1362
  this.config = config;
1014
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
1363
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1015
1364
  }
1016
1365
  supportsUrl(url) {
1017
1366
  return url.protocol === "https:";
@@ -1080,7 +1429,7 @@ var AnthropicMessagesLanguageModel = class {
1080
1429
  description: "Respond with a JSON object.",
1081
1430
  inputSchema: responseFormat.schema
1082
1431
  } : void 0;
1083
- const anthropicOptions = await (0, import_provider_utils7.parseProviderOptions)({
1432
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1084
1433
  provider: "anthropic",
1085
1434
  providerOptions,
1086
1435
  schema: anthropicProviderOptions
@@ -1146,7 +1495,7 @@ var AnthropicMessagesLanguageModel = class {
1146
1495
  toolChoice: anthropicToolChoice,
1147
1496
  toolWarnings,
1148
1497
  betas: toolsBetas
1149
- } = prepareTools(
1498
+ } = await prepareTools(
1150
1499
  jsonResponseTool != null ? {
1151
1500
  tools: [jsonResponseTool],
1152
1501
  toolChoice: { type: "tool", toolName: jsonResponseTool.name },
@@ -1172,8 +1521,8 @@ var AnthropicMessagesLanguageModel = class {
1172
1521
  betas,
1173
1522
  headers
1174
1523
  }) {
1175
- return (0, import_provider_utils7.combineHeaders)(
1176
- await (0, import_provider_utils7.resolve)(this.config.headers),
1524
+ return (0, import_provider_utils10.combineHeaders)(
1525
+ await (0, import_provider_utils10.resolve)(this.config.headers),
1177
1526
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1178
1527
  headers
1179
1528
  );
@@ -1217,12 +1566,12 @@ var AnthropicMessagesLanguageModel = class {
1217
1566
  responseHeaders,
1218
1567
  value: response,
1219
1568
  rawValue: rawResponse
1220
- } = await (0, import_provider_utils7.postJsonToApi)({
1569
+ } = await (0, import_provider_utils10.postJsonToApi)({
1221
1570
  url: this.buildRequestUrl(false),
1222
1571
  headers: await this.getHeaders({ betas, headers: options.headers }),
1223
1572
  body: this.transformRequestBody(args),
1224
1573
  failedResponseHandler: anthropicFailedResponseHandler,
1225
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1574
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1226
1575
  anthropicMessagesResponseSchema
1227
1576
  ),
1228
1577
  abortSignal: options.abortSignal,
@@ -1236,12 +1585,14 @@ var AnthropicMessagesLanguageModel = class {
1236
1585
  content.push({ type: "text", text: part.text });
1237
1586
  if (part.citations) {
1238
1587
  for (const citation of part.citations) {
1239
- processCitation(
1588
+ const source = createCitationSource(
1240
1589
  citation,
1241
1590
  citationDocuments,
1242
- this.generateId,
1243
- (source) => content.push(source)
1591
+ this.generateId
1244
1592
  );
1593
+ if (source) {
1594
+ content.push(source);
1595
+ }
1245
1596
  }
1246
1597
  }
1247
1598
  }
@@ -1447,12 +1798,12 @@ var AnthropicMessagesLanguageModel = class {
1447
1798
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1448
1799
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1449
1800
  const body = { ...args, stream: true };
1450
- const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
1801
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
1451
1802
  url: this.buildRequestUrl(true),
1452
1803
  headers: await this.getHeaders({ betas, headers: options.headers }),
1453
1804
  body: this.transformRequestBody(body),
1454
1805
  failedResponseHandler: anthropicFailedResponseHandler,
1455
- successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
1806
+ successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
1456
1807
  anthropicMessagesChunkSchema
1457
1808
  ),
1458
1809
  abortSignal: options.abortSignal,
@@ -1778,12 +2129,14 @@ var AnthropicMessagesLanguageModel = class {
1778
2129
  }
1779
2130
  case "citations_delta": {
1780
2131
  const citation = value.delta.citation;
1781
- processCitation(
2132
+ const source = createCitationSource(
1782
2133
  citation,
1783
2134
  citationDocuments,
1784
- generateId2,
1785
- (source) => controller.enqueue(source)
2135
+ generateId2
1786
2136
  );
2137
+ if (source) {
2138
+ controller.enqueue(source);
2139
+ }
1787
2140
  return;
1788
2141
  }
1789
2142
  default: {
@@ -1854,402 +2207,173 @@ var AnthropicMessagesLanguageModel = class {
1854
2207
  };
1855
2208
  }
1856
2209
  };
1857
- var anthropicMessagesResponseSchema = z7.object({
1858
- type: z7.literal("message"),
1859
- id: z7.string().nullish(),
1860
- model: z7.string().nullish(),
1861
- content: z7.array(
1862
- z7.discriminatedUnion("type", [
1863
- z7.object({
1864
- type: z7.literal("text"),
1865
- text: z7.string(),
1866
- citations: z7.array(citationSchema).optional()
1867
- }),
1868
- z7.object({
1869
- type: z7.literal("thinking"),
1870
- thinking: z7.string(),
1871
- signature: z7.string()
1872
- }),
1873
- z7.object({
1874
- type: z7.literal("redacted_thinking"),
1875
- data: z7.string()
1876
- }),
1877
- z7.object({
1878
- type: z7.literal("tool_use"),
1879
- id: z7.string(),
1880
- name: z7.string(),
1881
- input: z7.unknown()
1882
- }),
1883
- z7.object({
1884
- type: z7.literal("server_tool_use"),
1885
- id: z7.string(),
1886
- name: z7.string(),
1887
- input: z7.record(z7.string(), z7.unknown()).nullish()
1888
- }),
1889
- z7.object({
1890
- type: z7.literal("web_fetch_tool_result"),
1891
- tool_use_id: z7.string(),
1892
- content: z7.union([
1893
- z7.object({
1894
- type: z7.literal("web_fetch_result"),
1895
- url: z7.string(),
1896
- retrieved_at: z7.string(),
1897
- content: z7.object({
1898
- type: z7.literal("document"),
1899
- title: z7.string().nullable(),
1900
- citations: z7.object({ enabled: z7.boolean() }).optional(),
1901
- source: z7.object({
1902
- type: z7.literal("text"),
1903
- media_type: z7.string(),
1904
- data: z7.string()
1905
- })
1906
- })
1907
- }),
1908
- z7.object({
1909
- type: z7.literal("web_fetch_tool_result_error"),
1910
- error_code: z7.string()
1911
- })
1912
- ])
1913
- }),
1914
- z7.object({
1915
- type: z7.literal("web_search_tool_result"),
1916
- tool_use_id: z7.string(),
1917
- content: z7.union([
1918
- z7.array(
1919
- z7.object({
1920
- type: z7.literal("web_search_result"),
1921
- url: z7.string(),
1922
- title: z7.string(),
1923
- encrypted_content: z7.string(),
1924
- page_age: z7.string().nullish()
1925
- })
1926
- ),
1927
- z7.object({
1928
- type: z7.literal("web_search_tool_result_error"),
1929
- error_code: z7.string()
1930
- })
1931
- ])
1932
- }),
1933
- z7.object({
1934
- type: z7.literal("code_execution_tool_result"),
1935
- tool_use_id: z7.string(),
1936
- content: z7.union([
1937
- z7.object({
1938
- type: z7.literal("code_execution_result"),
1939
- stdout: z7.string(),
1940
- stderr: z7.string(),
1941
- return_code: z7.number()
1942
- }),
1943
- z7.object({
1944
- type: z7.literal("code_execution_tool_result_error"),
1945
- error_code: z7.string()
1946
- })
1947
- ])
1948
- })
1949
- ])
1950
- ),
1951
- stop_reason: z7.string().nullish(),
1952
- stop_sequence: z7.string().nullish(),
1953
- usage: z7.looseObject({
1954
- input_tokens: z7.number(),
1955
- output_tokens: z7.number(),
1956
- cache_creation_input_tokens: z7.number().nullish(),
1957
- cache_read_input_tokens: z7.number().nullish()
1958
- })
1959
- });
1960
- var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
1961
- z7.object({
1962
- type: z7.literal("message_start"),
1963
- message: z7.object({
1964
- id: z7.string().nullish(),
1965
- model: z7.string().nullish(),
1966
- usage: z7.looseObject({
1967
- input_tokens: z7.number(),
1968
- cache_creation_input_tokens: z7.number().nullish(),
1969
- cache_read_input_tokens: z7.number().nullish()
1970
- })
1971
- })
1972
- }),
1973
- z7.object({
1974
- type: z7.literal("content_block_start"),
1975
- index: z7.number(),
1976
- content_block: z7.discriminatedUnion("type", [
1977
- z7.object({
1978
- type: z7.literal("text"),
1979
- text: z7.string()
1980
- }),
1981
- z7.object({
1982
- type: z7.literal("thinking"),
1983
- thinking: z7.string()
1984
- }),
1985
- z7.object({
1986
- type: z7.literal("tool_use"),
1987
- id: z7.string(),
1988
- name: z7.string()
1989
- }),
1990
- z7.object({
1991
- type: z7.literal("redacted_thinking"),
1992
- data: z7.string()
1993
- }),
1994
- z7.object({
1995
- type: z7.literal("server_tool_use"),
1996
- id: z7.string(),
1997
- name: z7.string(),
1998
- input: z7.record(z7.string(), z7.unknown()).nullish()
1999
- }),
2000
- z7.object({
2001
- type: z7.literal("web_fetch_tool_result"),
2002
- tool_use_id: z7.string(),
2003
- content: z7.union([
2004
- z7.object({
2005
- type: z7.literal("web_fetch_result"),
2006
- url: z7.string(),
2007
- retrieved_at: z7.string(),
2008
- content: z7.object({
2009
- type: z7.literal("document"),
2010
- title: z7.string().nullable(),
2011
- citations: z7.object({ enabled: z7.boolean() }).optional(),
2012
- source: z7.object({
2013
- type: z7.literal("text"),
2014
- media_type: z7.string(),
2015
- data: z7.string()
2016
- })
2017
- })
2018
- }),
2019
- z7.object({
2020
- type: z7.literal("web_fetch_tool_result_error"),
2021
- error_code: z7.string()
2022
- })
2023
- ])
2024
- }),
2025
- z7.object({
2026
- type: z7.literal("web_search_tool_result"),
2027
- tool_use_id: z7.string(),
2028
- content: z7.union([
2029
- z7.array(
2030
- z7.object({
2031
- type: z7.literal("web_search_result"),
2032
- url: z7.string(),
2033
- title: z7.string(),
2034
- encrypted_content: z7.string(),
2035
- page_age: z7.string().nullish()
2036
- })
2037
- ),
2038
- z7.object({
2039
- type: z7.literal("web_search_tool_result_error"),
2040
- error_code: z7.string()
2041
- })
2042
- ])
2043
- }),
2044
- z7.object({
2045
- type: z7.literal("code_execution_tool_result"),
2046
- tool_use_id: z7.string(),
2047
- content: z7.union([
2048
- z7.object({
2049
- type: z7.literal("code_execution_result"),
2050
- stdout: z7.string(),
2051
- stderr: z7.string(),
2052
- return_code: z7.number()
2053
- }),
2054
- z7.object({
2055
- type: z7.literal("code_execution_tool_result_error"),
2056
- error_code: z7.string()
2057
- })
2058
- ])
2059
- })
2060
- ])
2061
- }),
2062
- z7.object({
2063
- type: z7.literal("content_block_delta"),
2064
- index: z7.number(),
2065
- delta: z7.discriminatedUnion("type", [
2066
- z7.object({
2067
- type: z7.literal("input_json_delta"),
2068
- partial_json: z7.string()
2069
- }),
2070
- z7.object({
2071
- type: z7.literal("text_delta"),
2072
- text: z7.string()
2073
- }),
2074
- z7.object({
2075
- type: z7.literal("thinking_delta"),
2076
- thinking: z7.string()
2077
- }),
2078
- z7.object({
2079
- type: z7.literal("signature_delta"),
2080
- signature: z7.string()
2081
- }),
2082
- z7.object({
2083
- type: z7.literal("citations_delta"),
2084
- citation: citationSchema
2085
- })
2086
- ])
2087
- }),
2088
- z7.object({
2089
- type: z7.literal("content_block_stop"),
2090
- index: z7.number()
2091
- }),
2092
- z7.object({
2093
- type: z7.literal("error"),
2094
- error: z7.object({
2095
- type: z7.string(),
2096
- message: z7.string()
2097
- })
2098
- }),
2099
- z7.object({
2100
- type: z7.literal("message_delta"),
2101
- delta: z7.object({
2102
- stop_reason: z7.string().nullish(),
2103
- stop_sequence: z7.string().nullish()
2104
- }),
2105
- usage: z7.looseObject({
2106
- output_tokens: z7.number(),
2107
- cache_creation_input_tokens: z7.number().nullish()
2108
- })
2109
- }),
2110
- z7.object({
2111
- type: z7.literal("message_stop")
2112
- }),
2113
- z7.object({
2114
- type: z7.literal("ping")
2115
- })
2116
- ]);
2117
- var anthropicReasoningMetadataSchema = z7.object({
2118
- signature: z7.string().optional(),
2119
- redactedData: z7.string().optional()
2120
- });
2121
2210
 
2122
2211
  // src/tool/bash_20241022.ts
2123
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
2124
- var import_v4 = __toESM(require("zod/v4"));
2125
- var bash_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
2212
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2213
+ var z8 = __toESM(require("zod/v4"));
2214
+ var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
2215
+ () => (0, import_provider_utils11.zodSchema)(
2216
+ z8.object({
2217
+ command: z8.string(),
2218
+ restart: z8.boolean().optional()
2219
+ })
2220
+ )
2221
+ );
2222
+ var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2126
2223
  id: "anthropic.bash_20241022",
2127
2224
  name: "bash",
2128
- inputSchema: import_v4.default.object({
2129
- command: import_v4.default.string(),
2130
- restart: import_v4.default.boolean().optional()
2131
- })
2225
+ inputSchema: bash_20241022InputSchema
2132
2226
  });
2133
2227
 
2134
2228
  // src/tool/bash_20250124.ts
2135
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
2136
- var import_v42 = __toESM(require("zod/v4"));
2137
- var bash_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
2229
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2230
+ var z9 = __toESM(require("zod/v4"));
2231
+ var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
2232
+ () => (0, import_provider_utils12.zodSchema)(
2233
+ z9.object({
2234
+ command: z9.string(),
2235
+ restart: z9.boolean().optional()
2236
+ })
2237
+ )
2238
+ );
2239
+ var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2138
2240
  id: "anthropic.bash_20250124",
2139
2241
  name: "bash",
2140
- inputSchema: import_v42.default.object({
2141
- command: import_v42.default.string(),
2142
- restart: import_v42.default.boolean().optional()
2143
- })
2242
+ inputSchema: bash_20250124InputSchema
2144
2243
  });
2145
2244
 
2146
2245
  // src/tool/computer_20241022.ts
2147
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
2246
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2148
2247
  var z10 = __toESM(require("zod/v4"));
2149
- var computer_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
2248
+ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2249
+ () => (0, import_provider_utils13.zodSchema)(
2250
+ z10.object({
2251
+ action: z10.enum([
2252
+ "key",
2253
+ "type",
2254
+ "mouse_move",
2255
+ "left_click",
2256
+ "left_click_drag",
2257
+ "right_click",
2258
+ "middle_click",
2259
+ "double_click",
2260
+ "screenshot",
2261
+ "cursor_position"
2262
+ ]),
2263
+ coordinate: z10.array(z10.number().int()).optional(),
2264
+ text: z10.string().optional()
2265
+ })
2266
+ )
2267
+ );
2268
+ var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2150
2269
  id: "anthropic.computer_20241022",
2151
2270
  name: "computer",
2152
- inputSchema: z10.object({
2153
- action: z10.enum([
2154
- "key",
2155
- "type",
2156
- "mouse_move",
2157
- "left_click",
2158
- "left_click_drag",
2159
- "right_click",
2160
- "middle_click",
2161
- "double_click",
2162
- "screenshot",
2163
- "cursor_position"
2164
- ]),
2165
- coordinate: z10.array(z10.number().int()).optional(),
2166
- text: z10.string().optional()
2167
- })
2271
+ inputSchema: computer_20241022InputSchema
2168
2272
  });
2169
2273
 
2170
2274
  // src/tool/computer_20250124.ts
2171
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2275
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2172
2276
  var z11 = __toESM(require("zod/v4"));
2173
- var computer_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2277
+ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2278
+ () => (0, import_provider_utils14.zodSchema)(
2279
+ z11.object({
2280
+ action: z11.enum([
2281
+ "key",
2282
+ "hold_key",
2283
+ "type",
2284
+ "cursor_position",
2285
+ "mouse_move",
2286
+ "left_mouse_down",
2287
+ "left_mouse_up",
2288
+ "left_click",
2289
+ "left_click_drag",
2290
+ "right_click",
2291
+ "middle_click",
2292
+ "double_click",
2293
+ "triple_click",
2294
+ "scroll",
2295
+ "wait",
2296
+ "screenshot"
2297
+ ]),
2298
+ coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2299
+ duration: z11.number().optional(),
2300
+ scroll_amount: z11.number().optional(),
2301
+ scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
2302
+ start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2303
+ text: z11.string().optional()
2304
+ })
2305
+ )
2306
+ );
2307
+ var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2174
2308
  id: "anthropic.computer_20250124",
2175
2309
  name: "computer",
2176
- inputSchema: z11.object({
2177
- action: z11.enum([
2178
- "key",
2179
- "hold_key",
2180
- "type",
2181
- "cursor_position",
2182
- "mouse_move",
2183
- "left_mouse_down",
2184
- "left_mouse_up",
2185
- "left_click",
2186
- "left_click_drag",
2187
- "right_click",
2188
- "middle_click",
2189
- "double_click",
2190
- "triple_click",
2191
- "scroll",
2192
- "wait",
2193
- "screenshot"
2194
- ]),
2195
- coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2196
- duration: z11.number().optional(),
2197
- scroll_amount: z11.number().optional(),
2198
- scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
2199
- start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2200
- text: z11.string().optional()
2201
- })
2310
+ inputSchema: computer_20250124InputSchema
2202
2311
  });
2203
2312
 
2204
2313
  // src/tool/text-editor_20241022.ts
2205
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2314
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
2206
2315
  var z12 = __toESM(require("zod/v4"));
2207
- var textEditor_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2316
+ var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
2317
+ () => (0, import_provider_utils15.zodSchema)(
2318
+ z12.object({
2319
+ command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2320
+ path: z12.string(),
2321
+ file_text: z12.string().optional(),
2322
+ insert_line: z12.number().int().optional(),
2323
+ new_str: z12.string().optional(),
2324
+ old_str: z12.string().optional(),
2325
+ view_range: z12.array(z12.number().int()).optional()
2326
+ })
2327
+ )
2328
+ );
2329
+ var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2208
2330
  id: "anthropic.text_editor_20241022",
2209
2331
  name: "str_replace_editor",
2210
- inputSchema: z12.object({
2211
- command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2212
- path: z12.string(),
2213
- file_text: z12.string().optional(),
2214
- insert_line: z12.number().int().optional(),
2215
- new_str: z12.string().optional(),
2216
- old_str: z12.string().optional(),
2217
- view_range: z12.array(z12.number().int()).optional()
2218
- })
2332
+ inputSchema: textEditor_20241022InputSchema
2219
2333
  });
2220
2334
 
2221
2335
  // src/tool/text-editor_20250124.ts
2222
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2336
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
2223
2337
  var z13 = __toESM(require("zod/v4"));
2224
- var textEditor_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2338
+ var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2339
+ () => (0, import_provider_utils16.zodSchema)(
2340
+ z13.object({
2341
+ command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2342
+ path: z13.string(),
2343
+ file_text: z13.string().optional(),
2344
+ insert_line: z13.number().int().optional(),
2345
+ new_str: z13.string().optional(),
2346
+ old_str: z13.string().optional(),
2347
+ view_range: z13.array(z13.number().int()).optional()
2348
+ })
2349
+ )
2350
+ );
2351
+ var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2225
2352
  id: "anthropic.text_editor_20250124",
2226
2353
  name: "str_replace_editor",
2227
- inputSchema: z13.object({
2228
- command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2229
- path: z13.string(),
2230
- file_text: z13.string().optional(),
2231
- insert_line: z13.number().int().optional(),
2232
- new_str: z13.string().optional(),
2233
- old_str: z13.string().optional(),
2234
- view_range: z13.array(z13.number().int()).optional()
2235
- })
2354
+ inputSchema: textEditor_20250124InputSchema
2236
2355
  });
2237
2356
 
2238
2357
  // src/tool/text-editor_20250429.ts
2239
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2358
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
2240
2359
  var z14 = __toESM(require("zod/v4"));
2241
- var textEditor_20250429 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2360
+ var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2361
+ () => (0, import_provider_utils17.zodSchema)(
2362
+ z14.object({
2363
+ command: z14.enum(["view", "create", "str_replace", "insert"]),
2364
+ path: z14.string(),
2365
+ file_text: z14.string().optional(),
2366
+ insert_line: z14.number().int().optional(),
2367
+ new_str: z14.string().optional(),
2368
+ old_str: z14.string().optional(),
2369
+ view_range: z14.array(z14.number().int()).optional()
2370
+ })
2371
+ )
2372
+ );
2373
+ var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2242
2374
  id: "anthropic.text_editor_20250429",
2243
2375
  name: "str_replace_based_edit_tool",
2244
- inputSchema: z14.object({
2245
- command: z14.enum(["view", "create", "str_replace", "insert"]),
2246
- path: z14.string(),
2247
- file_text: z14.string().optional(),
2248
- insert_line: z14.number().int().optional(),
2249
- new_str: z14.string().optional(),
2250
- old_str: z14.string().optional(),
2251
- view_range: z14.array(z14.number().int()).optional()
2252
- })
2376
+ inputSchema: textEditor_20250429InputSchema
2253
2377
  });
2254
2378
 
2255
2379
  // src/anthropic-tools.ts