@ai-sdk/anthropic 2.1.0-beta.1 → 2.1.0-beta.10

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,8 +38,8 @@ 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_utils5 = require("@ai-sdk/provider-utils");
42
- var import_v45 = require("zod/v4");
41
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
42
+ var import_v47 = require("zod/v4");
43
43
 
44
44
  // src/anthropic-error.ts
45
45
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -113,58 +113,110 @@ function getCacheControl(providerMetadata) {
113
113
  return cacheControlValue;
114
114
  }
115
115
 
116
- // src/tool/web-search_20250305.ts
116
+ // src/tool/text-editor_20250728.ts
117
117
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
118
118
  var import_v43 = require("zod/v4");
119
- var webSearch_20250305ArgsSchema = import_v43.z.object({
120
- /**
121
- * Maximum number of web searches Claude can perform during the conversation.
122
- */
123
- maxUses: import_v43.z.number().optional(),
124
- /**
125
- * Optional list of domains that Claude is allowed to search.
126
- */
127
- allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
128
- /**
129
- * Optional list of domains that Claude should avoid when searching.
130
- */
131
- blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
132
- /**
133
- * Optional user location information to provide geographically relevant search results.
134
- */
135
- userLocation: import_v43.z.object({
136
- type: import_v43.z.literal("approximate"),
137
- city: import_v43.z.string().optional(),
138
- region: import_v43.z.string().optional(),
139
- country: import_v43.z.string().optional(),
140
- timezone: import_v43.z.string().optional()
119
+ var textEditor_20250728ArgsSchema = import_v43.z.object({
120
+ maxCharacters: import_v43.z.number().optional()
121
+ });
122
+ var factory = (0, import_provider_utils2.createProviderDefinedToolFactory)({
123
+ id: "anthropic.text_editor_20250728",
124
+ name: "str_replace_based_edit_tool",
125
+ inputSchema: import_v43.z.object({
126
+ command: import_v43.z.enum(["view", "create", "str_replace", "insert"]),
127
+ path: import_v43.z.string(),
128
+ file_text: import_v43.z.string().optional(),
129
+ insert_line: import_v43.z.number().int().optional(),
130
+ new_str: import_v43.z.string().optional(),
131
+ old_str: import_v43.z.string().optional(),
132
+ view_range: import_v43.z.array(import_v43.z.number().int()).optional()
133
+ })
134
+ });
135
+ var textEditor_20250728 = (args = {}) => {
136
+ return factory(args);
137
+ };
138
+
139
+ // src/tool/web-search_20250305.ts
140
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
141
+ var import_v44 = require("zod/v4");
142
+ var webSearch_20250305ArgsSchema = import_v44.z.object({
143
+ maxUses: import_v44.z.number().optional(),
144
+ allowedDomains: import_v44.z.array(import_v44.z.string()).optional(),
145
+ blockedDomains: import_v44.z.array(import_v44.z.string()).optional(),
146
+ userLocation: import_v44.z.object({
147
+ type: import_v44.z.literal("approximate"),
148
+ city: import_v44.z.string().optional(),
149
+ region: import_v44.z.string().optional(),
150
+ country: import_v44.z.string().optional(),
151
+ timezone: import_v44.z.string().optional()
141
152
  }).optional()
142
153
  });
143
- var webSearch_20250305OutputSchema = import_v43.z.array(
144
- import_v43.z.object({
145
- url: import_v43.z.string(),
146
- title: import_v43.z.string(),
147
- pageAge: import_v43.z.string().nullable(),
148
- encryptedContent: import_v43.z.string(),
149
- type: import_v43.z.string()
154
+ var webSearch_20250305OutputSchema = import_v44.z.array(
155
+ import_v44.z.object({
156
+ url: import_v44.z.string(),
157
+ title: import_v44.z.string(),
158
+ pageAge: import_v44.z.string().nullable(),
159
+ encryptedContent: import_v44.z.string(),
160
+ type: import_v44.z.literal("web_search_result")
150
161
  })
151
162
  );
152
- var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
163
+ var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
153
164
  id: "anthropic.web_search_20250305",
154
165
  name: "web_search",
155
- inputSchema: import_v43.z.object({
156
- query: import_v43.z.string()
166
+ inputSchema: import_v44.z.object({
167
+ query: import_v44.z.string()
157
168
  }),
158
169
  outputSchema: webSearch_20250305OutputSchema
159
170
  });
160
171
  var webSearch_20250305 = (args = {}) => {
161
- return factory(args);
172
+ return factory2(args);
173
+ };
174
+
175
+ // src/tool/web-fetch-20250910.ts
176
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
177
+ var import_v45 = require("zod/v4");
178
+ var webFetch_20250910ArgsSchema = import_v45.z.object({
179
+ maxUses: import_v45.z.number().optional(),
180
+ allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
181
+ blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
182
+ citations: import_v45.z.object({ enabled: import_v45.z.boolean() }).optional(),
183
+ maxContentTokens: import_v45.z.number().optional()
184
+ });
185
+ var webFetch_20250910OutputSchema = import_v45.z.object({
186
+ type: import_v45.z.literal("web_fetch_result"),
187
+ url: import_v45.z.string(),
188
+ content: import_v45.z.object({
189
+ type: import_v45.z.literal("document"),
190
+ title: import_v45.z.string(),
191
+ citations: import_v45.z.object({ enabled: import_v45.z.boolean() }).optional(),
192
+ source: import_v45.z.union([
193
+ import_v45.z.object({
194
+ type: import_v45.z.literal("base64"),
195
+ mediaType: import_v45.z.literal("application/pdf"),
196
+ data: import_v45.z.string()
197
+ }),
198
+ import_v45.z.object({
199
+ type: import_v45.z.literal("text"),
200
+ mediaType: import_v45.z.literal("text/plain"),
201
+ data: import_v45.z.string()
202
+ })
203
+ ])
204
+ }),
205
+ retrievedAt: import_v45.z.string().nullable()
206
+ });
207
+ var factory3 = (0, import_provider_utils4.createProviderDefinedToolFactoryWithOutputSchema)({
208
+ id: "anthropic.web_fetch_20250910",
209
+ name: "web_fetch",
210
+ inputSchema: import_v45.z.object({
211
+ url: import_v45.z.string()
212
+ }),
213
+ outputSchema: webFetch_20250910OutputSchema
214
+ });
215
+ var webFetch_20250910 = (args = {}) => {
216
+ return factory3(args);
162
217
  };
163
218
 
164
219
  // src/anthropic-prepare-tools.ts
165
- function isWebSearchTool(tool) {
166
- return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
167
- }
168
220
  function prepareTools({
169
221
  tools,
170
222
  toolChoice,
@@ -178,12 +230,8 @@ function prepareTools({
178
230
  }
179
231
  const anthropicTools2 = [];
180
232
  for (const tool of tools) {
181
- if (isWebSearchTool(tool)) {
182
- anthropicTools2.push(tool);
183
- continue;
184
- }
185
233
  switch (tool.type) {
186
- case "function":
234
+ case "function": {
187
235
  const cacheControl = getCacheControl(tool.providerOptions);
188
236
  anthropicTools2.push({
189
237
  name: tool.name,
@@ -192,9 +240,18 @@ function prepareTools({
192
240
  cache_control: cacheControl
193
241
  });
194
242
  break;
195
- case "provider-defined":
243
+ }
244
+ case "provider-defined": {
196
245
  switch (tool.id) {
197
- case "anthropic.computer_20250124":
246
+ case "anthropic.code_execution_20250522": {
247
+ betas.add("code-execution-2025-05-22");
248
+ anthropicTools2.push({
249
+ type: "code_execution_20250522",
250
+ name: "code_execution"
251
+ });
252
+ break;
253
+ }
254
+ case "anthropic.computer_20250124": {
198
255
  betas.add("computer-use-2025-01-24");
199
256
  anthropicTools2.push({
200
257
  name: "computer",
@@ -204,7 +261,8 @@ function prepareTools({
204
261
  display_number: tool.args.displayNumber
205
262
  });
206
263
  break;
207
- case "anthropic.computer_20241022":
264
+ }
265
+ case "anthropic.computer_20241022": {
208
266
  betas.add("computer-use-2024-10-22");
209
267
  anthropicTools2.push({
210
268
  name: "computer",
@@ -214,41 +272,70 @@ function prepareTools({
214
272
  display_number: tool.args.displayNumber
215
273
  });
216
274
  break;
217
- case "anthropic.text_editor_20250124":
275
+ }
276
+ case "anthropic.text_editor_20250124": {
218
277
  betas.add("computer-use-2025-01-24");
219
278
  anthropicTools2.push({
220
279
  name: "str_replace_editor",
221
280
  type: "text_editor_20250124"
222
281
  });
223
282
  break;
224
- case "anthropic.text_editor_20241022":
283
+ }
284
+ case "anthropic.text_editor_20241022": {
225
285
  betas.add("computer-use-2024-10-22");
226
286
  anthropicTools2.push({
227
287
  name: "str_replace_editor",
228
288
  type: "text_editor_20241022"
229
289
  });
230
290
  break;
231
- case "anthropic.text_editor_20250429":
291
+ }
292
+ case "anthropic.text_editor_20250429": {
232
293
  betas.add("computer-use-2025-01-24");
233
294
  anthropicTools2.push({
234
295
  name: "str_replace_based_edit_tool",
235
296
  type: "text_editor_20250429"
236
297
  });
237
298
  break;
238
- case "anthropic.bash_20250124":
299
+ }
300
+ case "anthropic.text_editor_20250728": {
301
+ const args = textEditor_20250728ArgsSchema.parse(tool.args);
302
+ anthropicTools2.push({
303
+ name: "str_replace_based_edit_tool",
304
+ type: "text_editor_20250728",
305
+ max_characters: args.maxCharacters
306
+ });
307
+ break;
308
+ }
309
+ case "anthropic.bash_20250124": {
239
310
  betas.add("computer-use-2025-01-24");
240
311
  anthropicTools2.push({
241
312
  name: "bash",
242
313
  type: "bash_20250124"
243
314
  });
244
315
  break;
245
- case "anthropic.bash_20241022":
316
+ }
317
+ case "anthropic.bash_20241022": {
246
318
  betas.add("computer-use-2024-10-22");
247
319
  anthropicTools2.push({
248
320
  name: "bash",
249
321
  type: "bash_20241022"
250
322
  });
251
323
  break;
324
+ }
325
+ case "anthropic.web_fetch_20250910": {
326
+ betas.add("web-fetch-2025-09-10");
327
+ const args = webFetch_20250910ArgsSchema.parse(tool.args);
328
+ anthropicTools2.push({
329
+ type: "web_fetch_20250910",
330
+ name: "web_fetch",
331
+ max_uses: args.maxUses,
332
+ allowed_domains: args.allowedDomains,
333
+ blocked_domains: args.blockedDomains,
334
+ citations: args.citations,
335
+ max_content_tokens: args.maxContentTokens
336
+ });
337
+ break;
338
+ }
252
339
  case "anthropic.web_search_20250305": {
253
340
  const args = webSearch_20250305ArgsSchema.parse(tool.args);
254
341
  anthropicTools2.push({
@@ -261,22 +348,17 @@ function prepareTools({
261
348
  });
262
349
  break;
263
350
  }
264
- case "anthropic.code_execution_20250522": {
265
- betas.add("code-execution-2025-05-22");
266
- anthropicTools2.push({
267
- type: "code_execution_20250522",
268
- name: "code_execution"
269
- });
270
- break;
271
- }
272
- default:
351
+ default: {
273
352
  toolWarnings.push({ type: "unsupported-tool", tool });
274
353
  break;
354
+ }
275
355
  }
276
356
  break;
277
- default:
357
+ }
358
+ default: {
278
359
  toolWarnings.push({ type: "unsupported-tool", tool });
279
360
  break;
361
+ }
280
362
  }
281
363
  }
282
364
  if (toolChoice == null) {
@@ -333,27 +415,27 @@ function prepareTools({
333
415
 
334
416
  // src/convert-to-anthropic-messages-prompt.ts
335
417
  var import_provider2 = require("@ai-sdk/provider");
336
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
418
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
337
419
 
338
420
  // src/tool/code-execution_20250522.ts
339
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
340
- var import_v44 = require("zod/v4");
341
- var codeExecution_20250522OutputSchema = import_v44.z.object({
342
- type: import_v44.z.literal("code_execution_result"),
343
- stdout: import_v44.z.string(),
344
- stderr: import_v44.z.string(),
345
- return_code: import_v44.z.number()
421
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
422
+ var import_v46 = require("zod/v4");
423
+ var codeExecution_20250522OutputSchema = import_v46.z.object({
424
+ type: import_v46.z.literal("code_execution_result"),
425
+ stdout: import_v46.z.string(),
426
+ stderr: import_v46.z.string(),
427
+ return_code: import_v46.z.number()
346
428
  });
347
- var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
429
+ var factory4 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
348
430
  id: "anthropic.code_execution_20250522",
349
431
  name: "code_execution",
350
- inputSchema: import_v44.z.object({
351
- code: import_v44.z.string()
432
+ inputSchema: import_v46.z.object({
433
+ code: import_v46.z.string()
352
434
  }),
353
435
  outputSchema: codeExecution_20250522OutputSchema
354
436
  });
355
437
  var codeExecution_20250522 = (args = {}) => {
356
- return factory2(args);
438
+ return factory4(args);
357
439
  };
358
440
 
359
441
  // src/convert-to-anthropic-messages-prompt.ts
@@ -385,7 +467,7 @@ async function convertToAnthropicMessagesPrompt({
385
467
  const messages = [];
386
468
  async function shouldEnableCitations(providerMetadata) {
387
469
  var _a2, _b2;
388
- const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
470
+ const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
389
471
  provider: "anthropic",
390
472
  providerOptions: providerMetadata,
391
473
  schema: anthropicFilePartProviderOptions
@@ -393,7 +475,7 @@ async function convertToAnthropicMessagesPrompt({
393
475
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
394
476
  }
395
477
  async function getDocumentMetadata(providerMetadata) {
396
- const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
478
+ const anthropicOptions = await (0, import_provider_utils6.parseProviderOptions)({
397
479
  provider: "anthropic",
398
480
  providerOptions: providerMetadata,
399
481
  schema: anthropicFilePartProviderOptions
@@ -450,7 +532,7 @@ async function convertToAnthropicMessagesPrompt({
450
532
  } : {
451
533
  type: "base64",
452
534
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
453
- data: (0, import_provider_utils4.convertToBase64)(part.data)
535
+ data: (0, import_provider_utils6.convertToBase64)(part.data)
454
536
  },
455
537
  cache_control: cacheControl
456
538
  });
@@ -470,7 +552,7 @@ async function convertToAnthropicMessagesPrompt({
470
552
  } : {
471
553
  type: "base64",
472
554
  media_type: "application/pdf",
473
- data: (0, import_provider_utils4.convertToBase64)(part.data)
555
+ data: (0, import_provider_utils6.convertToBase64)(part.data)
474
556
  },
475
557
  title: (_b = metadata.title) != null ? _b : part.filename,
476
558
  ...metadata.context && { context: metadata.context },
@@ -605,7 +687,7 @@ async function convertToAnthropicMessagesPrompt({
605
687
  }
606
688
  case "reasoning": {
607
689
  if (sendReasoning) {
608
- const reasoningMetadata = await (0, import_provider_utils4.parseProviderOptions)({
690
+ const reasoningMetadata = await (0, import_provider_utils6.parseProviderOptions)({
609
691
  provider: "anthropic",
610
692
  providerOptions: part.providerOptions,
611
693
  schema: anthropicReasoningMetadataSchema
@@ -646,30 +728,20 @@ async function convertToAnthropicMessagesPrompt({
646
728
  }
647
729
  case "tool-call": {
648
730
  if (part.providerExecuted) {
649
- if (part.toolName === "web_search") {
731
+ if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
650
732
  anthropicContent.push({
651
733
  type: "server_tool_use",
652
734
  id: part.toolCallId,
653
- name: "web_search",
735
+ name: part.toolName,
654
736
  input: part.input,
655
737
  cache_control: cacheControl
656
738
  });
657
- break;
658
- }
659
- if (part.toolName === "code_execution") {
660
- anthropicContent.push({
661
- type: "server_tool_use",
662
- id: part.toolCallId,
663
- name: "code_execution",
664
- input: part.input,
665
- cache_control: cacheControl
739
+ } else {
740
+ warnings.push({
741
+ type: "other",
742
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
666
743
  });
667
- break;
668
744
  }
669
- warnings.push({
670
- type: "other",
671
- message: `provider executed tool call for tool ${part.toolName} is not supported`
672
- });
673
745
  break;
674
746
  }
675
747
  anthropicContent.push({
@@ -682,7 +754,7 @@ async function convertToAnthropicMessagesPrompt({
682
754
  break;
683
755
  }
684
756
  case "tool-result": {
685
- if (part.toolName === "web_search") {
757
+ if (part.toolName === "code_execution") {
686
758
  const output = part.output;
687
759
  if (output.type !== "json") {
688
760
  warnings.push({
@@ -691,24 +763,21 @@ async function convertToAnthropicMessagesPrompt({
691
763
  });
692
764
  break;
693
765
  }
694
- const webSearchOutput = webSearch_20250305OutputSchema.parse(
695
- output.value
696
- );
766
+ const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
697
767
  anthropicContent.push({
698
- type: "web_search_tool_result",
768
+ type: "code_execution_tool_result",
699
769
  tool_use_id: part.toolCallId,
700
- content: webSearchOutput.map((result) => ({
701
- url: result.url,
702
- title: result.title,
703
- page_age: result.pageAge,
704
- encrypted_content: result.encryptedContent,
705
- type: result.type
706
- })),
770
+ content: {
771
+ type: codeExecutionOutput.type,
772
+ stdout: codeExecutionOutput.stdout,
773
+ stderr: codeExecutionOutput.stderr,
774
+ return_code: codeExecutionOutput.return_code
775
+ },
707
776
  cache_control: cacheControl
708
777
  });
709
778
  break;
710
779
  }
711
- if (part.toolName === "code_execution") {
780
+ if (part.toolName === "web_fetch") {
712
781
  const output = part.output;
713
782
  if (output.type !== "json") {
714
783
  warnings.push({
@@ -717,20 +786,57 @@ async function convertToAnthropicMessagesPrompt({
717
786
  });
718
787
  break;
719
788
  }
720
- const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
789
+ const webFetchOutput = webFetch_20250910OutputSchema.parse(
790
+ output.value
791
+ );
721
792
  anthropicContent.push({
722
- type: "code_execution_tool_result",
793
+ type: "web_fetch_tool_result",
723
794
  tool_use_id: part.toolCallId,
724
795
  content: {
725
- type: codeExecutionOutput.type,
726
- stdout: codeExecutionOutput.stdout,
727
- stderr: codeExecutionOutput.stderr,
728
- return_code: codeExecutionOutput.return_code
796
+ type: "web_fetch_result",
797
+ url: webFetchOutput.url,
798
+ retrieved_at: webFetchOutput.retrievedAt,
799
+ content: {
800
+ type: "document",
801
+ title: webFetchOutput.content.title,
802
+ citations: webFetchOutput.content.citations,
803
+ source: {
804
+ type: webFetchOutput.content.source.type,
805
+ media_type: webFetchOutput.content.source.mediaType,
806
+ data: webFetchOutput.content.source.data
807
+ }
808
+ }
729
809
  },
730
810
  cache_control: cacheControl
731
811
  });
732
812
  break;
733
813
  }
814
+ if (part.toolName === "web_search") {
815
+ const output = part.output;
816
+ if (output.type !== "json") {
817
+ warnings.push({
818
+ type: "other",
819
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
820
+ });
821
+ break;
822
+ }
823
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
824
+ output.value
825
+ );
826
+ anthropicContent.push({
827
+ type: "web_search_tool_result",
828
+ tool_use_id: part.toolCallId,
829
+ content: webSearchOutput.map((result) => ({
830
+ url: result.url,
831
+ title: result.title,
832
+ page_age: result.pageAge,
833
+ encrypted_content: result.encryptedContent,
834
+ type: result.type
835
+ })),
836
+ cache_control: cacheControl
837
+ });
838
+ break;
839
+ }
734
840
  warnings.push({
735
841
  type: "other",
736
842
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -824,36 +930,36 @@ function mapAnthropicStopReason({
824
930
 
825
931
  // src/anthropic-messages-language-model.ts
826
932
  var citationSchemas = {
827
- webSearchResult: import_v45.z.object({
828
- type: import_v45.z.literal("web_search_result_location"),
829
- cited_text: import_v45.z.string(),
830
- url: import_v45.z.string(),
831
- title: import_v45.z.string(),
832
- encrypted_index: import_v45.z.string()
933
+ webSearchResult: import_v47.z.object({
934
+ type: import_v47.z.literal("web_search_result_location"),
935
+ cited_text: import_v47.z.string(),
936
+ url: import_v47.z.string(),
937
+ title: import_v47.z.string(),
938
+ encrypted_index: import_v47.z.string()
833
939
  }),
834
- pageLocation: import_v45.z.object({
835
- type: import_v45.z.literal("page_location"),
836
- cited_text: import_v45.z.string(),
837
- document_index: import_v45.z.number(),
838
- document_title: import_v45.z.string().nullable(),
839
- start_page_number: import_v45.z.number(),
840
- end_page_number: import_v45.z.number()
940
+ pageLocation: import_v47.z.object({
941
+ type: import_v47.z.literal("page_location"),
942
+ cited_text: import_v47.z.string(),
943
+ document_index: import_v47.z.number(),
944
+ document_title: import_v47.z.string().nullable(),
945
+ start_page_number: import_v47.z.number(),
946
+ end_page_number: import_v47.z.number()
841
947
  }),
842
- charLocation: import_v45.z.object({
843
- type: import_v45.z.literal("char_location"),
844
- cited_text: import_v45.z.string(),
845
- document_index: import_v45.z.number(),
846
- document_title: import_v45.z.string().nullable(),
847
- start_char_index: import_v45.z.number(),
848
- end_char_index: import_v45.z.number()
948
+ charLocation: import_v47.z.object({
949
+ type: import_v47.z.literal("char_location"),
950
+ cited_text: import_v47.z.string(),
951
+ document_index: import_v47.z.number(),
952
+ document_title: import_v47.z.string().nullable(),
953
+ start_char_index: import_v47.z.number(),
954
+ end_char_index: import_v47.z.number()
849
955
  })
850
956
  };
851
- var citationSchema = import_v45.z.discriminatedUnion("type", [
957
+ var citationSchema = import_v47.z.discriminatedUnion("type", [
852
958
  citationSchemas.webSearchResult,
853
959
  citationSchemas.pageLocation,
854
960
  citationSchemas.charLocation
855
961
  ]);
856
- var documentCitationSchema = import_v45.z.discriminatedUnion("type", [
962
+ var documentCitationSchema = import_v47.z.discriminatedUnion("type", [
857
963
  citationSchemas.pageLocation,
858
964
  citationSchemas.charLocation
859
965
  ]);
@@ -898,11 +1004,11 @@ function createCitationSource(citation, citationDocuments, generateId2) {
898
1004
  }
899
1005
  var AnthropicMessagesLanguageModel = class {
900
1006
  constructor(modelId, config) {
901
- this.specificationVersion = "v2";
1007
+ this.specificationVersion = "v3";
902
1008
  var _a;
903
1009
  this.modelId = modelId;
904
1010
  this.config = config;
905
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
1011
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
906
1012
  }
907
1013
  supportsUrl(url) {
908
1014
  return url.protocol === "https:";
@@ -971,7 +1077,7 @@ var AnthropicMessagesLanguageModel = class {
971
1077
  description: "Respond with a JSON object.",
972
1078
  inputSchema: responseFormat.schema
973
1079
  } : void 0;
974
- const anthropicOptions = await (0, import_provider_utils5.parseProviderOptions)({
1080
+ const anthropicOptions = await (0, import_provider_utils7.parseProviderOptions)({
975
1081
  provider: "anthropic",
976
1082
  providerOptions,
977
1083
  schema: anthropicProviderOptions
@@ -1063,8 +1169,8 @@ var AnthropicMessagesLanguageModel = class {
1063
1169
  betas,
1064
1170
  headers
1065
1171
  }) {
1066
- return (0, import_provider_utils5.combineHeaders)(
1067
- await (0, import_provider_utils5.resolve)(this.config.headers),
1172
+ return (0, import_provider_utils7.combineHeaders)(
1173
+ await (0, import_provider_utils7.resolve)(this.config.headers),
1068
1174
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1069
1175
  headers
1070
1176
  );
@@ -1101,19 +1207,19 @@ var AnthropicMessagesLanguageModel = class {
1101
1207
  });
1102
1208
  }
1103
1209
  async doGenerate(options) {
1104
- var _a, _b, _c, _d, _e;
1210
+ var _a, _b, _c, _d, _e, _f;
1105
1211
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1106
1212
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1107
1213
  const {
1108
1214
  responseHeaders,
1109
1215
  value: response,
1110
1216
  rawValue: rawResponse
1111
- } = await (0, import_provider_utils5.postJsonToApi)({
1217
+ } = await (0, import_provider_utils7.postJsonToApi)({
1112
1218
  url: this.buildRequestUrl(false),
1113
1219
  headers: await this.getHeaders({ betas, headers: options.headers }),
1114
1220
  body: this.transformRequestBody(args),
1115
1221
  failedResponseHandler: anthropicFailedResponseHandler,
1116
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1222
+ successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1117
1223
  anthropicMessagesResponseSchema
1118
1224
  ),
1119
1225
  abortSignal: options.abortSignal,
@@ -1178,7 +1284,7 @@ var AnthropicMessagesLanguageModel = class {
1178
1284
  break;
1179
1285
  }
1180
1286
  case "server_tool_use": {
1181
- if (part.name === "web_search" || part.name === "code_execution") {
1287
+ if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1182
1288
  content.push({
1183
1289
  type: "tool-call",
1184
1290
  toolCallId: part.id,
@@ -1189,6 +1295,44 @@ var AnthropicMessagesLanguageModel = class {
1189
1295
  }
1190
1296
  break;
1191
1297
  }
1298
+ case "web_fetch_tool_result": {
1299
+ if (part.content.type === "web_fetch_result") {
1300
+ content.push({
1301
+ type: "tool-result",
1302
+ toolCallId: part.tool_use_id,
1303
+ toolName: "web_fetch",
1304
+ result: {
1305
+ type: "web_fetch_result",
1306
+ url: part.content.url,
1307
+ retrievedAt: part.content.retrieved_at,
1308
+ content: {
1309
+ type: part.content.content.type,
1310
+ title: part.content.content.title,
1311
+ citations: part.content.content.citations,
1312
+ source: {
1313
+ type: part.content.content.source.type,
1314
+ mediaType: part.content.content.source.media_type,
1315
+ data: part.content.content.source.data
1316
+ }
1317
+ }
1318
+ },
1319
+ providerExecuted: true
1320
+ });
1321
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1322
+ content.push({
1323
+ type: "tool-result",
1324
+ toolCallId: part.tool_use_id,
1325
+ toolName: "web_fetch",
1326
+ isError: true,
1327
+ result: {
1328
+ type: "web_fetch_tool_result_error",
1329
+ errorCode: part.content.error_code
1330
+ },
1331
+ providerExecuted: true
1332
+ });
1333
+ }
1334
+ break;
1335
+ }
1192
1336
  case "web_search_tool_result": {
1193
1337
  if (Array.isArray(part.content)) {
1194
1338
  content.push({
@@ -1290,7 +1434,8 @@ var AnthropicMessagesLanguageModel = class {
1290
1434
  providerMetadata: {
1291
1435
  anthropic: {
1292
1436
  usage: response.usage,
1293
- cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1437
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
1438
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null
1294
1439
  }
1295
1440
  }
1296
1441
  };
@@ -1299,12 +1444,12 @@ var AnthropicMessagesLanguageModel = class {
1299
1444
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1300
1445
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1301
1446
  const body = { ...args, stream: true };
1302
- const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
1447
+ const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
1303
1448
  url: this.buildRequestUrl(true),
1304
1449
  headers: await this.getHeaders({ betas, headers: options.headers }),
1305
1450
  body: this.transformRequestBody(body),
1306
1451
  failedResponseHandler: anthropicFailedResponseHandler,
1307
- successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
1452
+ successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
1308
1453
  anthropicMessagesChunkSchema
1309
1454
  ),
1310
1455
  abortSignal: options.abortSignal,
@@ -1317,7 +1462,9 @@ var AnthropicMessagesLanguageModel = class {
1317
1462
  totalTokens: void 0
1318
1463
  };
1319
1464
  const contentBlocks = {};
1320
- let providerMetadata = void 0;
1465
+ let rawUsage = void 0;
1466
+ let cacheCreationInputTokens = null;
1467
+ let stopSequence = null;
1321
1468
  let blockType = void 0;
1322
1469
  const generateId2 = this.generateId;
1323
1470
  return {
@@ -1327,7 +1474,7 @@ var AnthropicMessagesLanguageModel = class {
1327
1474
  controller.enqueue({ type: "stream-start", warnings });
1328
1475
  },
1329
1476
  transform(chunk, controller) {
1330
- var _a, _b, _c, _d, _e, _f, _g;
1477
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1331
1478
  if (options.includeRawChunks) {
1332
1479
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1333
1480
  }
@@ -1390,7 +1537,7 @@ var AnthropicMessagesLanguageModel = class {
1390
1537
  return;
1391
1538
  }
1392
1539
  case "server_tool_use": {
1393
- if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1540
+ if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1394
1541
  contentBlocks[value.index] = {
1395
1542
  type: "tool-call",
1396
1543
  toolCallId: value.content_block.id,
@@ -1407,6 +1554,44 @@ var AnthropicMessagesLanguageModel = class {
1407
1554
  }
1408
1555
  return;
1409
1556
  }
1557
+ case "web_fetch_tool_result": {
1558
+ const part = value.content_block;
1559
+ if (part.content.type === "web_fetch_result") {
1560
+ controller.enqueue({
1561
+ type: "tool-result",
1562
+ toolCallId: part.tool_use_id,
1563
+ toolName: "web_fetch",
1564
+ result: {
1565
+ type: "web_fetch_result",
1566
+ url: part.content.url,
1567
+ retrievedAt: part.content.retrieved_at,
1568
+ content: {
1569
+ type: part.content.content.type,
1570
+ title: part.content.content.title,
1571
+ citations: part.content.content.citations,
1572
+ source: {
1573
+ type: part.content.content.source.type,
1574
+ mediaType: part.content.content.source.media_type,
1575
+ data: part.content.content.source.data
1576
+ }
1577
+ }
1578
+ }
1579
+ });
1580
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1581
+ controller.enqueue({
1582
+ type: "tool-result",
1583
+ toolCallId: part.tool_use_id,
1584
+ toolName: "web_fetch",
1585
+ isError: true,
1586
+ result: {
1587
+ type: "web_fetch_tool_result_error",
1588
+ errorCode: part.content.error_code
1589
+ },
1590
+ providerExecuted: true
1591
+ });
1592
+ }
1593
+ return;
1594
+ }
1410
1595
  case "web_search_tool_result": {
1411
1596
  const part = value.content_block;
1412
1597
  if (Array.isArray(part.content)) {
@@ -1609,12 +1794,10 @@ var AnthropicMessagesLanguageModel = class {
1609
1794
  case "message_start": {
1610
1795
  usage.inputTokens = value.message.usage.input_tokens;
1611
1796
  usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1612
- providerMetadata = {
1613
- anthropic: {
1614
- usage: value.message.usage,
1615
- cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1616
- }
1797
+ rawUsage = {
1798
+ ...value.message.usage
1617
1799
  };
1800
+ cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
1618
1801
  controller.enqueue({
1619
1802
  type: "response-metadata",
1620
1803
  id: (_d = value.message.id) != null ? _d : void 0,
@@ -1629,6 +1812,11 @@ var AnthropicMessagesLanguageModel = class {
1629
1812
  finishReason: value.delta.stop_reason,
1630
1813
  isJsonResponseFromTool: usesJsonResponseTool
1631
1814
  });
1815
+ stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
1816
+ rawUsage = {
1817
+ ...rawUsage,
1818
+ ...value.usage
1819
+ };
1632
1820
  return;
1633
1821
  }
1634
1822
  case "message_stop": {
@@ -1636,7 +1824,13 @@ var AnthropicMessagesLanguageModel = class {
1636
1824
  type: "finish",
1637
1825
  finishReason,
1638
1826
  usage,
1639
- providerMetadata
1827
+ providerMetadata: {
1828
+ anthropic: {
1829
+ usage: rawUsage != null ? rawUsage : null,
1830
+ cacheCreationInputTokens,
1831
+ stopSequence
1832
+ }
1833
+ }
1640
1834
  });
1641
1835
  return;
1642
1836
  }
@@ -1657,247 +1851,303 @@ var AnthropicMessagesLanguageModel = class {
1657
1851
  };
1658
1852
  }
1659
1853
  };
1660
- var anthropicMessagesResponseSchema = import_v45.z.object({
1661
- type: import_v45.z.literal("message"),
1662
- id: import_v45.z.string().nullish(),
1663
- model: import_v45.z.string().nullish(),
1664
- content: import_v45.z.array(
1665
- import_v45.z.discriminatedUnion("type", [
1666
- import_v45.z.object({
1667
- type: import_v45.z.literal("text"),
1668
- text: import_v45.z.string(),
1669
- citations: import_v45.z.array(citationSchema).optional()
1854
+ var anthropicMessagesResponseSchema = import_v47.z.object({
1855
+ type: import_v47.z.literal("message"),
1856
+ id: import_v47.z.string().nullish(),
1857
+ model: import_v47.z.string().nullish(),
1858
+ content: import_v47.z.array(
1859
+ import_v47.z.discriminatedUnion("type", [
1860
+ import_v47.z.object({
1861
+ type: import_v47.z.literal("text"),
1862
+ text: import_v47.z.string(),
1863
+ citations: import_v47.z.array(citationSchema).optional()
1670
1864
  }),
1671
- import_v45.z.object({
1672
- type: import_v45.z.literal("thinking"),
1673
- thinking: import_v45.z.string(),
1674
- signature: import_v45.z.string()
1865
+ import_v47.z.object({
1866
+ type: import_v47.z.literal("thinking"),
1867
+ thinking: import_v47.z.string(),
1868
+ signature: import_v47.z.string()
1675
1869
  }),
1676
- import_v45.z.object({
1677
- type: import_v45.z.literal("redacted_thinking"),
1678
- data: import_v45.z.string()
1870
+ import_v47.z.object({
1871
+ type: import_v47.z.literal("redacted_thinking"),
1872
+ data: import_v47.z.string()
1679
1873
  }),
1680
- import_v45.z.object({
1681
- type: import_v45.z.literal("tool_use"),
1682
- id: import_v45.z.string(),
1683
- name: import_v45.z.string(),
1684
- input: import_v45.z.unknown()
1874
+ import_v47.z.object({
1875
+ type: import_v47.z.literal("tool_use"),
1876
+ id: import_v47.z.string(),
1877
+ name: import_v47.z.string(),
1878
+ input: import_v47.z.unknown()
1685
1879
  }),
1686
- import_v45.z.object({
1687
- type: import_v45.z.literal("server_tool_use"),
1688
- id: import_v45.z.string(),
1689
- name: import_v45.z.string(),
1690
- input: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish()
1880
+ import_v47.z.object({
1881
+ type: import_v47.z.literal("server_tool_use"),
1882
+ id: import_v47.z.string(),
1883
+ name: import_v47.z.string(),
1884
+ input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
1691
1885
  }),
1692
- import_v45.z.object({
1693
- type: import_v45.z.literal("web_search_tool_result"),
1694
- tool_use_id: import_v45.z.string(),
1695
- content: import_v45.z.union([
1696
- import_v45.z.array(
1697
- import_v45.z.object({
1698
- type: import_v45.z.literal("web_search_result"),
1699
- url: import_v45.z.string(),
1700
- title: import_v45.z.string(),
1701
- encrypted_content: import_v45.z.string(),
1702
- page_age: import_v45.z.string().nullish()
1886
+ import_v47.z.object({
1887
+ type: import_v47.z.literal("web_fetch_tool_result"),
1888
+ tool_use_id: import_v47.z.string(),
1889
+ content: import_v47.z.union([
1890
+ import_v47.z.object({
1891
+ type: import_v47.z.literal("web_fetch_result"),
1892
+ url: import_v47.z.string(),
1893
+ retrieved_at: import_v47.z.string(),
1894
+ content: import_v47.z.object({
1895
+ type: import_v47.z.literal("document"),
1896
+ title: import_v47.z.string().nullable(),
1897
+ citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1898
+ source: import_v47.z.object({
1899
+ type: import_v47.z.literal("text"),
1900
+ media_type: import_v47.z.string(),
1901
+ data: import_v47.z.string()
1902
+ })
1903
+ })
1904
+ }),
1905
+ import_v47.z.object({
1906
+ type: import_v47.z.literal("web_fetch_tool_result_error"),
1907
+ error_code: import_v47.z.string()
1908
+ })
1909
+ ])
1910
+ }),
1911
+ import_v47.z.object({
1912
+ type: import_v47.z.literal("web_search_tool_result"),
1913
+ tool_use_id: import_v47.z.string(),
1914
+ content: import_v47.z.union([
1915
+ import_v47.z.array(
1916
+ import_v47.z.object({
1917
+ type: import_v47.z.literal("web_search_result"),
1918
+ url: import_v47.z.string(),
1919
+ title: import_v47.z.string(),
1920
+ encrypted_content: import_v47.z.string(),
1921
+ page_age: import_v47.z.string().nullish()
1703
1922
  })
1704
1923
  ),
1705
- import_v45.z.object({
1706
- type: import_v45.z.literal("web_search_tool_result_error"),
1707
- error_code: import_v45.z.string()
1924
+ import_v47.z.object({
1925
+ type: import_v47.z.literal("web_search_tool_result_error"),
1926
+ error_code: import_v47.z.string()
1708
1927
  })
1709
1928
  ])
1710
1929
  }),
1711
- import_v45.z.object({
1712
- type: import_v45.z.literal("code_execution_tool_result"),
1713
- tool_use_id: import_v45.z.string(),
1714
- content: import_v45.z.union([
1715
- import_v45.z.object({
1716
- type: import_v45.z.literal("code_execution_result"),
1717
- stdout: import_v45.z.string(),
1718
- stderr: import_v45.z.string(),
1719
- return_code: import_v45.z.number()
1930
+ import_v47.z.object({
1931
+ type: import_v47.z.literal("code_execution_tool_result"),
1932
+ tool_use_id: import_v47.z.string(),
1933
+ content: import_v47.z.union([
1934
+ import_v47.z.object({
1935
+ type: import_v47.z.literal("code_execution_result"),
1936
+ stdout: import_v47.z.string(),
1937
+ stderr: import_v47.z.string(),
1938
+ return_code: import_v47.z.number()
1720
1939
  }),
1721
- import_v45.z.object({
1722
- type: import_v45.z.literal("code_execution_tool_result_error"),
1723
- error_code: import_v45.z.string()
1940
+ import_v47.z.object({
1941
+ type: import_v47.z.literal("code_execution_tool_result_error"),
1942
+ error_code: import_v47.z.string()
1724
1943
  })
1725
1944
  ])
1726
1945
  })
1727
1946
  ])
1728
1947
  ),
1729
- stop_reason: import_v45.z.string().nullish(),
1730
- usage: import_v45.z.looseObject({
1731
- input_tokens: import_v45.z.number(),
1732
- output_tokens: import_v45.z.number(),
1733
- cache_creation_input_tokens: import_v45.z.number().nullish(),
1734
- cache_read_input_tokens: import_v45.z.number().nullish()
1948
+ stop_reason: import_v47.z.string().nullish(),
1949
+ stop_sequence: import_v47.z.string().nullish(),
1950
+ usage: import_v47.z.looseObject({
1951
+ input_tokens: import_v47.z.number(),
1952
+ output_tokens: import_v47.z.number(),
1953
+ cache_creation_input_tokens: import_v47.z.number().nullish(),
1954
+ cache_read_input_tokens: import_v47.z.number().nullish()
1735
1955
  })
1736
1956
  });
1737
- var anthropicMessagesChunkSchema = import_v45.z.discriminatedUnion("type", [
1738
- import_v45.z.object({
1739
- type: import_v45.z.literal("message_start"),
1740
- message: import_v45.z.object({
1741
- id: import_v45.z.string().nullish(),
1742
- model: import_v45.z.string().nullish(),
1743
- usage: import_v45.z.looseObject({
1744
- input_tokens: import_v45.z.number(),
1745
- output_tokens: import_v45.z.number(),
1746
- cache_creation_input_tokens: import_v45.z.number().nullish(),
1747
- cache_read_input_tokens: import_v45.z.number().nullish()
1957
+ var anthropicMessagesChunkSchema = import_v47.z.discriminatedUnion("type", [
1958
+ import_v47.z.object({
1959
+ type: import_v47.z.literal("message_start"),
1960
+ message: import_v47.z.object({
1961
+ id: import_v47.z.string().nullish(),
1962
+ model: import_v47.z.string().nullish(),
1963
+ usage: import_v47.z.looseObject({
1964
+ input_tokens: import_v47.z.number(),
1965
+ cache_creation_input_tokens: import_v47.z.number().nullish(),
1966
+ cache_read_input_tokens: import_v47.z.number().nullish()
1748
1967
  })
1749
1968
  })
1750
1969
  }),
1751
- import_v45.z.object({
1752
- type: import_v45.z.literal("content_block_start"),
1753
- index: import_v45.z.number(),
1754
- content_block: import_v45.z.discriminatedUnion("type", [
1755
- import_v45.z.object({
1756
- type: import_v45.z.literal("text"),
1757
- text: import_v45.z.string()
1970
+ import_v47.z.object({
1971
+ type: import_v47.z.literal("content_block_start"),
1972
+ index: import_v47.z.number(),
1973
+ content_block: import_v47.z.discriminatedUnion("type", [
1974
+ import_v47.z.object({
1975
+ type: import_v47.z.literal("text"),
1976
+ text: import_v47.z.string()
1758
1977
  }),
1759
- import_v45.z.object({
1760
- type: import_v45.z.literal("thinking"),
1761
- thinking: import_v45.z.string()
1978
+ import_v47.z.object({
1979
+ type: import_v47.z.literal("thinking"),
1980
+ thinking: import_v47.z.string()
1762
1981
  }),
1763
- import_v45.z.object({
1764
- type: import_v45.z.literal("tool_use"),
1765
- id: import_v45.z.string(),
1766
- name: import_v45.z.string()
1982
+ import_v47.z.object({
1983
+ type: import_v47.z.literal("tool_use"),
1984
+ id: import_v47.z.string(),
1985
+ name: import_v47.z.string()
1767
1986
  }),
1768
- import_v45.z.object({
1769
- type: import_v45.z.literal("redacted_thinking"),
1770
- data: import_v45.z.string()
1987
+ import_v47.z.object({
1988
+ type: import_v47.z.literal("redacted_thinking"),
1989
+ data: import_v47.z.string()
1771
1990
  }),
1772
- import_v45.z.object({
1773
- type: import_v45.z.literal("server_tool_use"),
1774
- id: import_v45.z.string(),
1775
- name: import_v45.z.string(),
1776
- input: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish()
1991
+ import_v47.z.object({
1992
+ type: import_v47.z.literal("server_tool_use"),
1993
+ id: import_v47.z.string(),
1994
+ name: import_v47.z.string(),
1995
+ input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
1777
1996
  }),
1778
- import_v45.z.object({
1779
- type: import_v45.z.literal("web_search_tool_result"),
1780
- tool_use_id: import_v45.z.string(),
1781
- content: import_v45.z.union([
1782
- import_v45.z.array(
1783
- import_v45.z.object({
1784
- type: import_v45.z.literal("web_search_result"),
1785
- url: import_v45.z.string(),
1786
- title: import_v45.z.string(),
1787
- encrypted_content: import_v45.z.string(),
1788
- page_age: import_v45.z.string().nullish()
1997
+ import_v47.z.object({
1998
+ type: import_v47.z.literal("web_fetch_tool_result"),
1999
+ tool_use_id: import_v47.z.string(),
2000
+ content: import_v47.z.union([
2001
+ import_v47.z.object({
2002
+ type: import_v47.z.literal("web_fetch_result"),
2003
+ url: import_v47.z.string(),
2004
+ retrieved_at: import_v47.z.string(),
2005
+ content: import_v47.z.object({
2006
+ type: import_v47.z.literal("document"),
2007
+ title: import_v47.z.string().nullable(),
2008
+ citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
2009
+ source: import_v47.z.object({
2010
+ type: import_v47.z.literal("text"),
2011
+ media_type: import_v47.z.string(),
2012
+ data: import_v47.z.string()
2013
+ })
2014
+ })
2015
+ }),
2016
+ import_v47.z.object({
2017
+ type: import_v47.z.literal("web_fetch_tool_result_error"),
2018
+ error_code: import_v47.z.string()
2019
+ })
2020
+ ])
2021
+ }),
2022
+ import_v47.z.object({
2023
+ type: import_v47.z.literal("web_search_tool_result"),
2024
+ tool_use_id: import_v47.z.string(),
2025
+ content: import_v47.z.union([
2026
+ import_v47.z.array(
2027
+ import_v47.z.object({
2028
+ type: import_v47.z.literal("web_search_result"),
2029
+ url: import_v47.z.string(),
2030
+ title: import_v47.z.string(),
2031
+ encrypted_content: import_v47.z.string(),
2032
+ page_age: import_v47.z.string().nullish()
1789
2033
  })
1790
2034
  ),
1791
- import_v45.z.object({
1792
- type: import_v45.z.literal("web_search_tool_result_error"),
1793
- error_code: import_v45.z.string()
2035
+ import_v47.z.object({
2036
+ type: import_v47.z.literal("web_search_tool_result_error"),
2037
+ error_code: import_v47.z.string()
1794
2038
  })
1795
2039
  ])
1796
2040
  }),
1797
- import_v45.z.object({
1798
- type: import_v45.z.literal("code_execution_tool_result"),
1799
- tool_use_id: import_v45.z.string(),
1800
- content: import_v45.z.union([
1801
- import_v45.z.object({
1802
- type: import_v45.z.literal("code_execution_result"),
1803
- stdout: import_v45.z.string(),
1804
- stderr: import_v45.z.string(),
1805
- return_code: import_v45.z.number()
2041
+ import_v47.z.object({
2042
+ type: import_v47.z.literal("code_execution_tool_result"),
2043
+ tool_use_id: import_v47.z.string(),
2044
+ content: import_v47.z.union([
2045
+ import_v47.z.object({
2046
+ type: import_v47.z.literal("code_execution_result"),
2047
+ stdout: import_v47.z.string(),
2048
+ stderr: import_v47.z.string(),
2049
+ return_code: import_v47.z.number()
1806
2050
  }),
1807
- import_v45.z.object({
1808
- type: import_v45.z.literal("code_execution_tool_result_error"),
1809
- error_code: import_v45.z.string()
2051
+ import_v47.z.object({
2052
+ type: import_v47.z.literal("code_execution_tool_result_error"),
2053
+ error_code: import_v47.z.string()
1810
2054
  })
1811
2055
  ])
1812
2056
  })
1813
2057
  ])
1814
2058
  }),
1815
- import_v45.z.object({
1816
- type: import_v45.z.literal("content_block_delta"),
1817
- index: import_v45.z.number(),
1818
- delta: import_v45.z.discriminatedUnion("type", [
1819
- import_v45.z.object({
1820
- type: import_v45.z.literal("input_json_delta"),
1821
- partial_json: import_v45.z.string()
2059
+ import_v47.z.object({
2060
+ type: import_v47.z.literal("content_block_delta"),
2061
+ index: import_v47.z.number(),
2062
+ delta: import_v47.z.discriminatedUnion("type", [
2063
+ import_v47.z.object({
2064
+ type: import_v47.z.literal("input_json_delta"),
2065
+ partial_json: import_v47.z.string()
1822
2066
  }),
1823
- import_v45.z.object({
1824
- type: import_v45.z.literal("text_delta"),
1825
- text: import_v45.z.string()
2067
+ import_v47.z.object({
2068
+ type: import_v47.z.literal("text_delta"),
2069
+ text: import_v47.z.string()
1826
2070
  }),
1827
- import_v45.z.object({
1828
- type: import_v45.z.literal("thinking_delta"),
1829
- thinking: import_v45.z.string()
2071
+ import_v47.z.object({
2072
+ type: import_v47.z.literal("thinking_delta"),
2073
+ thinking: import_v47.z.string()
1830
2074
  }),
1831
- import_v45.z.object({
1832
- type: import_v45.z.literal("signature_delta"),
1833
- signature: import_v45.z.string()
2075
+ import_v47.z.object({
2076
+ type: import_v47.z.literal("signature_delta"),
2077
+ signature: import_v47.z.string()
1834
2078
  }),
1835
- import_v45.z.object({
1836
- type: import_v45.z.literal("citations_delta"),
2079
+ import_v47.z.object({
2080
+ type: import_v47.z.literal("citations_delta"),
1837
2081
  citation: citationSchema
1838
2082
  })
1839
2083
  ])
1840
2084
  }),
1841
- import_v45.z.object({
1842
- type: import_v45.z.literal("content_block_stop"),
1843
- index: import_v45.z.number()
2085
+ import_v47.z.object({
2086
+ type: import_v47.z.literal("content_block_stop"),
2087
+ index: import_v47.z.number()
1844
2088
  }),
1845
- import_v45.z.object({
1846
- type: import_v45.z.literal("error"),
1847
- error: import_v45.z.object({
1848
- type: import_v45.z.string(),
1849
- message: import_v45.z.string()
2089
+ import_v47.z.object({
2090
+ type: import_v47.z.literal("error"),
2091
+ error: import_v47.z.object({
2092
+ type: import_v47.z.string(),
2093
+ message: import_v47.z.string()
1850
2094
  })
1851
2095
  }),
1852
- import_v45.z.object({
1853
- type: import_v45.z.literal("message_delta"),
1854
- delta: import_v45.z.object({ stop_reason: import_v45.z.string().nullish() }),
1855
- usage: import_v45.z.object({ output_tokens: import_v45.z.number() })
2096
+ import_v47.z.object({
2097
+ type: import_v47.z.literal("message_delta"),
2098
+ delta: import_v47.z.object({
2099
+ stop_reason: import_v47.z.string().nullish(),
2100
+ stop_sequence: import_v47.z.string().nullish()
2101
+ }),
2102
+ usage: import_v47.z.looseObject({
2103
+ output_tokens: import_v47.z.number(),
2104
+ cache_creation_input_tokens: import_v47.z.number().nullish()
2105
+ })
1856
2106
  }),
1857
- import_v45.z.object({
1858
- type: import_v45.z.literal("message_stop")
2107
+ import_v47.z.object({
2108
+ type: import_v47.z.literal("message_stop")
1859
2109
  }),
1860
- import_v45.z.object({
1861
- type: import_v45.z.literal("ping")
2110
+ import_v47.z.object({
2111
+ type: import_v47.z.literal("ping")
1862
2112
  })
1863
2113
  ]);
1864
- var anthropicReasoningMetadataSchema = import_v45.z.object({
1865
- signature: import_v45.z.string().optional(),
1866
- redactedData: import_v45.z.string().optional()
2114
+ var anthropicReasoningMetadataSchema = import_v47.z.object({
2115
+ signature: import_v47.z.string().optional(),
2116
+ redactedData: import_v47.z.string().optional()
1867
2117
  });
1868
2118
 
1869
2119
  // src/tool/bash_20241022.ts
1870
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1871
- var import_v46 = __toESM(require("zod/v4"));
1872
- var bash_20241022 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
2120
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
2121
+ var import_v48 = __toESM(require("zod/v4"));
2122
+ var bash_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1873
2123
  id: "anthropic.bash_20241022",
1874
2124
  name: "bash",
1875
- inputSchema: import_v46.default.object({
1876
- command: import_v46.default.string(),
1877
- restart: import_v46.default.boolean().optional()
2125
+ inputSchema: import_v48.default.object({
2126
+ command: import_v48.default.string(),
2127
+ restart: import_v48.default.boolean().optional()
1878
2128
  })
1879
2129
  });
1880
2130
 
1881
2131
  // src/tool/bash_20250124.ts
1882
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1883
- var import_v47 = __toESM(require("zod/v4"));
1884
- var bash_20250124 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
2132
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
2133
+ var import_v49 = __toESM(require("zod/v4"));
2134
+ var bash_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1885
2135
  id: "anthropic.bash_20250124",
1886
2136
  name: "bash",
1887
- inputSchema: import_v47.default.object({
1888
- command: import_v47.default.string(),
1889
- restart: import_v47.default.boolean().optional()
2137
+ inputSchema: import_v49.default.object({
2138
+ command: import_v49.default.string(),
2139
+ restart: import_v49.default.boolean().optional()
1890
2140
  })
1891
2141
  });
1892
2142
 
1893
2143
  // src/tool/computer_20241022.ts
1894
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1895
- var import_v48 = require("zod/v4");
1896
- var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
2144
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
2145
+ var import_v410 = require("zod/v4");
2146
+ var computer_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1897
2147
  id: "anthropic.computer_20241022",
1898
2148
  name: "computer",
1899
- inputSchema: import_v48.z.object({
1900
- action: import_v48.z.enum([
2149
+ inputSchema: import_v410.z.object({
2150
+ action: import_v410.z.enum([
1901
2151
  "key",
1902
2152
  "type",
1903
2153
  "mouse_move",
@@ -1909,19 +2159,19 @@ var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFact
1909
2159
  "screenshot",
1910
2160
  "cursor_position"
1911
2161
  ]),
1912
- coordinate: import_v48.z.array(import_v48.z.number().int()).optional(),
1913
- text: import_v48.z.string().optional()
2162
+ coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
2163
+ text: import_v410.z.string().optional()
1914
2164
  })
1915
2165
  });
1916
2166
 
1917
2167
  // src/tool/computer_20250124.ts
1918
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1919
- var import_v49 = require("zod/v4");
1920
- var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
2168
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2169
+ var import_v411 = require("zod/v4");
2170
+ var computer_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1921
2171
  id: "anthropic.computer_20250124",
1922
2172
  name: "computer",
1923
- inputSchema: import_v49.z.object({
1924
- action: import_v49.z.enum([
2173
+ inputSchema: import_v411.z.object({
2174
+ action: import_v411.z.enum([
1925
2175
  "key",
1926
2176
  "hold_key",
1927
2177
  "type",
@@ -1939,63 +2189,63 @@ var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFact
1939
2189
  "wait",
1940
2190
  "screenshot"
1941
2191
  ]),
1942
- coordinate: import_v49.z.tuple([import_v49.z.number().int(), import_v49.z.number().int()]).optional(),
1943
- duration: import_v49.z.number().optional(),
1944
- scroll_amount: import_v49.z.number().optional(),
1945
- scroll_direction: import_v49.z.enum(["up", "down", "left", "right"]).optional(),
1946
- start_coordinate: import_v49.z.tuple([import_v49.z.number().int(), import_v49.z.number().int()]).optional(),
1947
- text: import_v49.z.string().optional()
2192
+ coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2193
+ duration: import_v411.z.number().optional(),
2194
+ scroll_amount: import_v411.z.number().optional(),
2195
+ scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
2196
+ start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2197
+ text: import_v411.z.string().optional()
1948
2198
  })
1949
2199
  });
1950
2200
 
1951
2201
  // src/tool/text-editor_20241022.ts
1952
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1953
- var import_v410 = require("zod/v4");
1954
- var textEditor_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
2202
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2203
+ var import_v412 = require("zod/v4");
2204
+ var textEditor_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
1955
2205
  id: "anthropic.text_editor_20241022",
1956
2206
  name: "str_replace_editor",
1957
- inputSchema: import_v410.z.object({
1958
- command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1959
- path: import_v410.z.string(),
1960
- file_text: import_v410.z.string().optional(),
1961
- insert_line: import_v410.z.number().int().optional(),
1962
- new_str: import_v410.z.string().optional(),
1963
- old_str: import_v410.z.string().optional(),
1964
- view_range: import_v410.z.array(import_v410.z.number().int()).optional()
2207
+ inputSchema: import_v412.z.object({
2208
+ command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2209
+ path: import_v412.z.string(),
2210
+ file_text: import_v412.z.string().optional(),
2211
+ insert_line: import_v412.z.number().int().optional(),
2212
+ new_str: import_v412.z.string().optional(),
2213
+ old_str: import_v412.z.string().optional(),
2214
+ view_range: import_v412.z.array(import_v412.z.number().int()).optional()
1965
2215
  })
1966
2216
  });
1967
2217
 
1968
2218
  // src/tool/text-editor_20250124.ts
1969
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1970
- var import_v411 = require("zod/v4");
1971
- var textEditor_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2219
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2220
+ var import_v413 = require("zod/v4");
2221
+ var textEditor_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
1972
2222
  id: "anthropic.text_editor_20250124",
1973
2223
  name: "str_replace_editor",
1974
- inputSchema: import_v411.z.object({
1975
- command: import_v411.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1976
- path: import_v411.z.string(),
1977
- file_text: import_v411.z.string().optional(),
1978
- insert_line: import_v411.z.number().int().optional(),
1979
- new_str: import_v411.z.string().optional(),
1980
- old_str: import_v411.z.string().optional(),
1981
- view_range: import_v411.z.array(import_v411.z.number().int()).optional()
2224
+ inputSchema: import_v413.z.object({
2225
+ command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2226
+ path: import_v413.z.string(),
2227
+ file_text: import_v413.z.string().optional(),
2228
+ insert_line: import_v413.z.number().int().optional(),
2229
+ new_str: import_v413.z.string().optional(),
2230
+ old_str: import_v413.z.string().optional(),
2231
+ view_range: import_v413.z.array(import_v413.z.number().int()).optional()
1982
2232
  })
1983
2233
  });
1984
2234
 
1985
2235
  // src/tool/text-editor_20250429.ts
1986
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1987
- var import_v412 = require("zod/v4");
1988
- var textEditor_20250429 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2236
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2237
+ var import_v414 = require("zod/v4");
2238
+ var textEditor_20250429 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
1989
2239
  id: "anthropic.text_editor_20250429",
1990
2240
  name: "str_replace_based_edit_tool",
1991
- inputSchema: import_v412.z.object({
1992
- command: import_v412.z.enum(["view", "create", "str_replace", "insert"]),
1993
- path: import_v412.z.string(),
1994
- file_text: import_v412.z.string().optional(),
1995
- insert_line: import_v412.z.number().int().optional(),
1996
- new_str: import_v412.z.string().optional(),
1997
- old_str: import_v412.z.string().optional(),
1998
- view_range: import_v412.z.array(import_v412.z.number().int()).optional()
2241
+ inputSchema: import_v414.z.object({
2242
+ command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
2243
+ path: import_v414.z.string(),
2244
+ file_text: import_v414.z.string().optional(),
2245
+ insert_line: import_v414.z.number().int().optional(),
2246
+ new_str: import_v414.z.string().optional(),
2247
+ old_str: import_v414.z.string().optional(),
2248
+ view_range: import_v414.z.array(import_v414.z.number().int()).optional()
1999
2249
  })
2000
2250
  });
2001
2251
 
@@ -2061,6 +2311,8 @@ var anthropicTools = {
2061
2311
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2062
2312
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2063
2313
  *
2314
+ * Supported models: Claude Sonnet 3.5
2315
+ *
2064
2316
  * Tool name must be `str_replace_editor`.
2065
2317
  */
2066
2318
  textEditor_20241022,
@@ -2069,6 +2321,8 @@ var anthropicTools = {
2069
2321
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2070
2322
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2071
2323
  *
2324
+ * Supported models: Claude Sonnet 3.7
2325
+ *
2072
2326
  * Tool name must be `str_replace_editor`.
2073
2327
  */
2074
2328
  textEditor_20250124,
@@ -2080,8 +2334,36 @@ var anthropicTools = {
2080
2334
  * Note: This version does not support the "undo_edit" command.
2081
2335
  *
2082
2336
  * Tool name must be `str_replace_based_edit_tool`.
2337
+ *
2338
+ * @deprecated Use textEditor_20250728 instead
2083
2339
  */
2084
2340
  textEditor_20250429,
2341
+ /**
2342
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2343
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2344
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2345
+ *
2346
+ * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
2347
+ *
2348
+ * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
2349
+ *
2350
+ * Tool name must be `str_replace_based_edit_tool`.
2351
+ *
2352
+ * @param maxCharacters - Optional maximum number of characters to view in the file
2353
+ */
2354
+ textEditor_20250728,
2355
+ /**
2356
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
2357
+ *
2358
+ * Tool name must be `web_fetch`.
2359
+ *
2360
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
2361
+ * @param allowedDomains - Only fetch from these domains
2362
+ * @param blockedDomains - Never fetch from these domains
2363
+ * @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
2364
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
2365
+ */
2366
+ webFetch_20250910,
2085
2367
  /**
2086
2368
  * Creates a web search tool that gives Claude direct access to real-time web content.
2087
2369
  *