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

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
@@ -378,14 +460,14 @@ async function convertToAnthropicMessagesPrompt({
378
460
  sendReasoning,
379
461
  warnings
380
462
  }) {
381
- var _a, _b, _c, _d, _e;
463
+ var _a, _b, _c, _d, _e, _f;
382
464
  const betas = /* @__PURE__ */ new Set();
383
465
  const blocks = groupIntoBlocks(prompt);
384
466
  let system = void 0;
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 },
@@ -554,6 +636,9 @@ async function convertToAnthropicMessagesPrompt({
554
636
  case "error-text":
555
637
  contentValue = output.value;
556
638
  break;
639
+ case "execution-denied":
640
+ contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
641
+ break;
557
642
  case "json":
558
643
  case "error-json":
559
644
  default:
@@ -588,7 +673,7 @@ async function convertToAnthropicMessagesPrompt({
588
673
  for (let k = 0; k < content.length; k++) {
589
674
  const part = content[k];
590
675
  const isLastContentPart = k === content.length - 1;
591
- const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
676
+ const cacheControl = (_f = getCacheControl(part.providerOptions)) != null ? _f : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
592
677
  switch (part.type) {
593
678
  case "text": {
594
679
  anthropicContent.push({
@@ -605,7 +690,7 @@ async function convertToAnthropicMessagesPrompt({
605
690
  }
606
691
  case "reasoning": {
607
692
  if (sendReasoning) {
608
- const reasoningMetadata = await (0, import_provider_utils4.parseProviderOptions)({
693
+ const reasoningMetadata = await (0, import_provider_utils6.parseProviderOptions)({
609
694
  provider: "anthropic",
610
695
  providerOptions: part.providerOptions,
611
696
  schema: anthropicReasoningMetadataSchema
@@ -646,30 +731,20 @@ async function convertToAnthropicMessagesPrompt({
646
731
  }
647
732
  case "tool-call": {
648
733
  if (part.providerExecuted) {
649
- if (part.toolName === "web_search") {
734
+ if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
650
735
  anthropicContent.push({
651
736
  type: "server_tool_use",
652
737
  id: part.toolCallId,
653
- name: "web_search",
738
+ name: part.toolName,
654
739
  input: part.input,
655
740
  cache_control: cacheControl
656
741
  });
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
742
+ } else {
743
+ warnings.push({
744
+ type: "other",
745
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
666
746
  });
667
- break;
668
747
  }
669
- warnings.push({
670
- type: "other",
671
- message: `provider executed tool call for tool ${part.toolName} is not supported`
672
- });
673
748
  break;
674
749
  }
675
750
  anthropicContent.push({
@@ -682,7 +757,7 @@ async function convertToAnthropicMessagesPrompt({
682
757
  break;
683
758
  }
684
759
  case "tool-result": {
685
- if (part.toolName === "web_search") {
760
+ if (part.toolName === "code_execution") {
686
761
  const output = part.output;
687
762
  if (output.type !== "json") {
688
763
  warnings.push({
@@ -691,24 +766,21 @@ async function convertToAnthropicMessagesPrompt({
691
766
  });
692
767
  break;
693
768
  }
694
- const webSearchOutput = webSearch_20250305OutputSchema.parse(
695
- output.value
696
- );
769
+ const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
697
770
  anthropicContent.push({
698
- type: "web_search_tool_result",
771
+ type: "code_execution_tool_result",
699
772
  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
- })),
773
+ content: {
774
+ type: codeExecutionOutput.type,
775
+ stdout: codeExecutionOutput.stdout,
776
+ stderr: codeExecutionOutput.stderr,
777
+ return_code: codeExecutionOutput.return_code
778
+ },
707
779
  cache_control: cacheControl
708
780
  });
709
781
  break;
710
782
  }
711
- if (part.toolName === "code_execution") {
783
+ if (part.toolName === "web_fetch") {
712
784
  const output = part.output;
713
785
  if (output.type !== "json") {
714
786
  warnings.push({
@@ -717,20 +789,57 @@ async function convertToAnthropicMessagesPrompt({
717
789
  });
718
790
  break;
719
791
  }
720
- const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
792
+ const webFetchOutput = webFetch_20250910OutputSchema.parse(
793
+ output.value
794
+ );
721
795
  anthropicContent.push({
722
- type: "code_execution_tool_result",
796
+ type: "web_fetch_tool_result",
723
797
  tool_use_id: part.toolCallId,
724
798
  content: {
725
- type: codeExecutionOutput.type,
726
- stdout: codeExecutionOutput.stdout,
727
- stderr: codeExecutionOutput.stderr,
728
- return_code: codeExecutionOutput.return_code
799
+ type: "web_fetch_result",
800
+ url: webFetchOutput.url,
801
+ retrieved_at: webFetchOutput.retrievedAt,
802
+ content: {
803
+ type: "document",
804
+ title: webFetchOutput.content.title,
805
+ citations: webFetchOutput.content.citations,
806
+ source: {
807
+ type: webFetchOutput.content.source.type,
808
+ media_type: webFetchOutput.content.source.mediaType,
809
+ data: webFetchOutput.content.source.data
810
+ }
811
+ }
729
812
  },
730
813
  cache_control: cacheControl
731
814
  });
732
815
  break;
733
816
  }
817
+ if (part.toolName === "web_search") {
818
+ const output = part.output;
819
+ if (output.type !== "json") {
820
+ warnings.push({
821
+ type: "other",
822
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
823
+ });
824
+ break;
825
+ }
826
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
827
+ output.value
828
+ );
829
+ anthropicContent.push({
830
+ type: "web_search_tool_result",
831
+ tool_use_id: part.toolCallId,
832
+ content: webSearchOutput.map((result) => ({
833
+ url: result.url,
834
+ title: result.title,
835
+ page_age: result.pageAge,
836
+ encrypted_content: result.encryptedContent,
837
+ type: result.type
838
+ })),
839
+ cache_control: cacheControl
840
+ });
841
+ break;
842
+ }
734
843
  warnings.push({
735
844
  type: "other",
736
845
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -824,36 +933,36 @@ function mapAnthropicStopReason({
824
933
 
825
934
  // src/anthropic-messages-language-model.ts
826
935
  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()
936
+ webSearchResult: import_v47.z.object({
937
+ type: import_v47.z.literal("web_search_result_location"),
938
+ cited_text: import_v47.z.string(),
939
+ url: import_v47.z.string(),
940
+ title: import_v47.z.string(),
941
+ encrypted_index: import_v47.z.string()
833
942
  }),
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()
943
+ pageLocation: import_v47.z.object({
944
+ type: import_v47.z.literal("page_location"),
945
+ cited_text: import_v47.z.string(),
946
+ document_index: import_v47.z.number(),
947
+ document_title: import_v47.z.string().nullable(),
948
+ start_page_number: import_v47.z.number(),
949
+ end_page_number: import_v47.z.number()
841
950
  }),
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()
951
+ charLocation: import_v47.z.object({
952
+ type: import_v47.z.literal("char_location"),
953
+ cited_text: import_v47.z.string(),
954
+ document_index: import_v47.z.number(),
955
+ document_title: import_v47.z.string().nullable(),
956
+ start_char_index: import_v47.z.number(),
957
+ end_char_index: import_v47.z.number()
849
958
  })
850
959
  };
851
- var citationSchema = import_v45.z.discriminatedUnion("type", [
960
+ var citationSchema = import_v47.z.discriminatedUnion("type", [
852
961
  citationSchemas.webSearchResult,
853
962
  citationSchemas.pageLocation,
854
963
  citationSchemas.charLocation
855
964
  ]);
856
- var documentCitationSchema = import_v45.z.discriminatedUnion("type", [
965
+ var documentCitationSchema = import_v47.z.discriminatedUnion("type", [
857
966
  citationSchemas.pageLocation,
858
967
  citationSchemas.charLocation
859
968
  ]);
@@ -898,11 +1007,11 @@ function createCitationSource(citation, citationDocuments, generateId2) {
898
1007
  }
899
1008
  var AnthropicMessagesLanguageModel = class {
900
1009
  constructor(modelId, config) {
901
- this.specificationVersion = "v2";
1010
+ this.specificationVersion = "v3";
902
1011
  var _a;
903
1012
  this.modelId = modelId;
904
1013
  this.config = config;
905
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
1014
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils7.generateId;
906
1015
  }
907
1016
  supportsUrl(url) {
908
1017
  return url.protocol === "https:";
@@ -971,7 +1080,7 @@ var AnthropicMessagesLanguageModel = class {
971
1080
  description: "Respond with a JSON object.",
972
1081
  inputSchema: responseFormat.schema
973
1082
  } : void 0;
974
- const anthropicOptions = await (0, import_provider_utils5.parseProviderOptions)({
1083
+ const anthropicOptions = await (0, import_provider_utils7.parseProviderOptions)({
975
1084
  provider: "anthropic",
976
1085
  providerOptions,
977
1086
  schema: anthropicProviderOptions
@@ -1063,8 +1172,8 @@ var AnthropicMessagesLanguageModel = class {
1063
1172
  betas,
1064
1173
  headers
1065
1174
  }) {
1066
- return (0, import_provider_utils5.combineHeaders)(
1067
- await (0, import_provider_utils5.resolve)(this.config.headers),
1175
+ return (0, import_provider_utils7.combineHeaders)(
1176
+ await (0, import_provider_utils7.resolve)(this.config.headers),
1068
1177
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1069
1178
  headers
1070
1179
  );
@@ -1101,19 +1210,19 @@ var AnthropicMessagesLanguageModel = class {
1101
1210
  });
1102
1211
  }
1103
1212
  async doGenerate(options) {
1104
- var _a, _b, _c, _d, _e;
1213
+ var _a, _b, _c, _d, _e, _f;
1105
1214
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1106
1215
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1107
1216
  const {
1108
1217
  responseHeaders,
1109
1218
  value: response,
1110
1219
  rawValue: rawResponse
1111
- } = await (0, import_provider_utils5.postJsonToApi)({
1220
+ } = await (0, import_provider_utils7.postJsonToApi)({
1112
1221
  url: this.buildRequestUrl(false),
1113
1222
  headers: await this.getHeaders({ betas, headers: options.headers }),
1114
1223
  body: this.transformRequestBody(args),
1115
1224
  failedResponseHandler: anthropicFailedResponseHandler,
1116
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1225
+ successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1117
1226
  anthropicMessagesResponseSchema
1118
1227
  ),
1119
1228
  abortSignal: options.abortSignal,
@@ -1178,7 +1287,7 @@ var AnthropicMessagesLanguageModel = class {
1178
1287
  break;
1179
1288
  }
1180
1289
  case "server_tool_use": {
1181
- if (part.name === "web_search" || part.name === "code_execution") {
1290
+ if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1182
1291
  content.push({
1183
1292
  type: "tool-call",
1184
1293
  toolCallId: part.id,
@@ -1189,6 +1298,44 @@ var AnthropicMessagesLanguageModel = class {
1189
1298
  }
1190
1299
  break;
1191
1300
  }
1301
+ case "web_fetch_tool_result": {
1302
+ if (part.content.type === "web_fetch_result") {
1303
+ content.push({
1304
+ type: "tool-result",
1305
+ toolCallId: part.tool_use_id,
1306
+ toolName: "web_fetch",
1307
+ result: {
1308
+ type: "web_fetch_result",
1309
+ url: part.content.url,
1310
+ retrievedAt: part.content.retrieved_at,
1311
+ content: {
1312
+ type: part.content.content.type,
1313
+ title: part.content.content.title,
1314
+ citations: part.content.content.citations,
1315
+ source: {
1316
+ type: part.content.content.source.type,
1317
+ mediaType: part.content.content.source.media_type,
1318
+ data: part.content.content.source.data
1319
+ }
1320
+ }
1321
+ },
1322
+ providerExecuted: true
1323
+ });
1324
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1325
+ content.push({
1326
+ type: "tool-result",
1327
+ toolCallId: part.tool_use_id,
1328
+ toolName: "web_fetch",
1329
+ isError: true,
1330
+ result: {
1331
+ type: "web_fetch_tool_result_error",
1332
+ errorCode: part.content.error_code
1333
+ },
1334
+ providerExecuted: true
1335
+ });
1336
+ }
1337
+ break;
1338
+ }
1192
1339
  case "web_search_tool_result": {
1193
1340
  if (Array.isArray(part.content)) {
1194
1341
  content.push({
@@ -1290,7 +1437,8 @@ var AnthropicMessagesLanguageModel = class {
1290
1437
  providerMetadata: {
1291
1438
  anthropic: {
1292
1439
  usage: response.usage,
1293
- cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1440
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
1441
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null
1294
1442
  }
1295
1443
  }
1296
1444
  };
@@ -1299,12 +1447,12 @@ var AnthropicMessagesLanguageModel = class {
1299
1447
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1300
1448
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1301
1449
  const body = { ...args, stream: true };
1302
- const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
1450
+ const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
1303
1451
  url: this.buildRequestUrl(true),
1304
1452
  headers: await this.getHeaders({ betas, headers: options.headers }),
1305
1453
  body: this.transformRequestBody(body),
1306
1454
  failedResponseHandler: anthropicFailedResponseHandler,
1307
- successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
1455
+ successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
1308
1456
  anthropicMessagesChunkSchema
1309
1457
  ),
1310
1458
  abortSignal: options.abortSignal,
@@ -1317,7 +1465,9 @@ var AnthropicMessagesLanguageModel = class {
1317
1465
  totalTokens: void 0
1318
1466
  };
1319
1467
  const contentBlocks = {};
1320
- let providerMetadata = void 0;
1468
+ let rawUsage = void 0;
1469
+ let cacheCreationInputTokens = null;
1470
+ let stopSequence = null;
1321
1471
  let blockType = void 0;
1322
1472
  const generateId2 = this.generateId;
1323
1473
  return {
@@ -1327,7 +1477,7 @@ var AnthropicMessagesLanguageModel = class {
1327
1477
  controller.enqueue({ type: "stream-start", warnings });
1328
1478
  },
1329
1479
  transform(chunk, controller) {
1330
- var _a, _b, _c, _d, _e, _f, _g;
1480
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1331
1481
  if (options.includeRawChunks) {
1332
1482
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1333
1483
  }
@@ -1390,7 +1540,7 @@ var AnthropicMessagesLanguageModel = class {
1390
1540
  return;
1391
1541
  }
1392
1542
  case "server_tool_use": {
1393
- if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1543
+ if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1394
1544
  contentBlocks[value.index] = {
1395
1545
  type: "tool-call",
1396
1546
  toolCallId: value.content_block.id,
@@ -1407,6 +1557,44 @@ var AnthropicMessagesLanguageModel = class {
1407
1557
  }
1408
1558
  return;
1409
1559
  }
1560
+ case "web_fetch_tool_result": {
1561
+ const part = value.content_block;
1562
+ if (part.content.type === "web_fetch_result") {
1563
+ controller.enqueue({
1564
+ type: "tool-result",
1565
+ toolCallId: part.tool_use_id,
1566
+ toolName: "web_fetch",
1567
+ result: {
1568
+ type: "web_fetch_result",
1569
+ url: part.content.url,
1570
+ retrievedAt: part.content.retrieved_at,
1571
+ content: {
1572
+ type: part.content.content.type,
1573
+ title: part.content.content.title,
1574
+ citations: part.content.content.citations,
1575
+ source: {
1576
+ type: part.content.content.source.type,
1577
+ mediaType: part.content.content.source.media_type,
1578
+ data: part.content.content.source.data
1579
+ }
1580
+ }
1581
+ }
1582
+ });
1583
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1584
+ controller.enqueue({
1585
+ type: "tool-result",
1586
+ toolCallId: part.tool_use_id,
1587
+ toolName: "web_fetch",
1588
+ isError: true,
1589
+ result: {
1590
+ type: "web_fetch_tool_result_error",
1591
+ errorCode: part.content.error_code
1592
+ },
1593
+ providerExecuted: true
1594
+ });
1595
+ }
1596
+ return;
1597
+ }
1410
1598
  case "web_search_tool_result": {
1411
1599
  const part = value.content_block;
1412
1600
  if (Array.isArray(part.content)) {
@@ -1609,12 +1797,10 @@ var AnthropicMessagesLanguageModel = class {
1609
1797
  case "message_start": {
1610
1798
  usage.inputTokens = value.message.usage.input_tokens;
1611
1799
  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
- }
1800
+ rawUsage = {
1801
+ ...value.message.usage
1617
1802
  };
1803
+ cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
1618
1804
  controller.enqueue({
1619
1805
  type: "response-metadata",
1620
1806
  id: (_d = value.message.id) != null ? _d : void 0,
@@ -1629,6 +1815,11 @@ var AnthropicMessagesLanguageModel = class {
1629
1815
  finishReason: value.delta.stop_reason,
1630
1816
  isJsonResponseFromTool: usesJsonResponseTool
1631
1817
  });
1818
+ stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
1819
+ rawUsage = {
1820
+ ...rawUsage,
1821
+ ...value.usage
1822
+ };
1632
1823
  return;
1633
1824
  }
1634
1825
  case "message_stop": {
@@ -1636,7 +1827,13 @@ var AnthropicMessagesLanguageModel = class {
1636
1827
  type: "finish",
1637
1828
  finishReason,
1638
1829
  usage,
1639
- providerMetadata
1830
+ providerMetadata: {
1831
+ anthropic: {
1832
+ usage: rawUsage != null ? rawUsage : null,
1833
+ cacheCreationInputTokens,
1834
+ stopSequence
1835
+ }
1836
+ }
1640
1837
  });
1641
1838
  return;
1642
1839
  }
@@ -1657,247 +1854,303 @@ var AnthropicMessagesLanguageModel = class {
1657
1854
  };
1658
1855
  }
1659
1856
  };
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()
1857
+ var anthropicMessagesResponseSchema = import_v47.z.object({
1858
+ type: import_v47.z.literal("message"),
1859
+ id: import_v47.z.string().nullish(),
1860
+ model: import_v47.z.string().nullish(),
1861
+ content: import_v47.z.array(
1862
+ import_v47.z.discriminatedUnion("type", [
1863
+ import_v47.z.object({
1864
+ type: import_v47.z.literal("text"),
1865
+ text: import_v47.z.string(),
1866
+ citations: import_v47.z.array(citationSchema).optional()
1670
1867
  }),
1671
- import_v45.z.object({
1672
- type: import_v45.z.literal("thinking"),
1673
- thinking: import_v45.z.string(),
1674
- signature: import_v45.z.string()
1868
+ import_v47.z.object({
1869
+ type: import_v47.z.literal("thinking"),
1870
+ thinking: import_v47.z.string(),
1871
+ signature: import_v47.z.string()
1675
1872
  }),
1676
- import_v45.z.object({
1677
- type: import_v45.z.literal("redacted_thinking"),
1678
- data: import_v45.z.string()
1873
+ import_v47.z.object({
1874
+ type: import_v47.z.literal("redacted_thinking"),
1875
+ data: import_v47.z.string()
1679
1876
  }),
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()
1877
+ import_v47.z.object({
1878
+ type: import_v47.z.literal("tool_use"),
1879
+ id: import_v47.z.string(),
1880
+ name: import_v47.z.string(),
1881
+ input: import_v47.z.unknown()
1685
1882
  }),
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()
1883
+ import_v47.z.object({
1884
+ type: import_v47.z.literal("server_tool_use"),
1885
+ id: import_v47.z.string(),
1886
+ name: import_v47.z.string(),
1887
+ input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
1691
1888
  }),
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()
1889
+ import_v47.z.object({
1890
+ type: import_v47.z.literal("web_fetch_tool_result"),
1891
+ tool_use_id: import_v47.z.string(),
1892
+ content: import_v47.z.union([
1893
+ import_v47.z.object({
1894
+ type: import_v47.z.literal("web_fetch_result"),
1895
+ url: import_v47.z.string(),
1896
+ retrieved_at: import_v47.z.string(),
1897
+ content: import_v47.z.object({
1898
+ type: import_v47.z.literal("document"),
1899
+ title: import_v47.z.string().nullable(),
1900
+ citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
1901
+ source: import_v47.z.object({
1902
+ type: import_v47.z.literal("text"),
1903
+ media_type: import_v47.z.string(),
1904
+ data: import_v47.z.string()
1905
+ })
1906
+ })
1907
+ }),
1908
+ import_v47.z.object({
1909
+ type: import_v47.z.literal("web_fetch_tool_result_error"),
1910
+ error_code: import_v47.z.string()
1911
+ })
1912
+ ])
1913
+ }),
1914
+ import_v47.z.object({
1915
+ type: import_v47.z.literal("web_search_tool_result"),
1916
+ tool_use_id: import_v47.z.string(),
1917
+ content: import_v47.z.union([
1918
+ import_v47.z.array(
1919
+ import_v47.z.object({
1920
+ type: import_v47.z.literal("web_search_result"),
1921
+ url: import_v47.z.string(),
1922
+ title: import_v47.z.string(),
1923
+ encrypted_content: import_v47.z.string(),
1924
+ page_age: import_v47.z.string().nullish()
1703
1925
  })
1704
1926
  ),
1705
- import_v45.z.object({
1706
- type: import_v45.z.literal("web_search_tool_result_error"),
1707
- error_code: import_v45.z.string()
1927
+ import_v47.z.object({
1928
+ type: import_v47.z.literal("web_search_tool_result_error"),
1929
+ error_code: import_v47.z.string()
1708
1930
  })
1709
1931
  ])
1710
1932
  }),
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()
1933
+ import_v47.z.object({
1934
+ type: import_v47.z.literal("code_execution_tool_result"),
1935
+ tool_use_id: import_v47.z.string(),
1936
+ content: import_v47.z.union([
1937
+ import_v47.z.object({
1938
+ type: import_v47.z.literal("code_execution_result"),
1939
+ stdout: import_v47.z.string(),
1940
+ stderr: import_v47.z.string(),
1941
+ return_code: import_v47.z.number()
1720
1942
  }),
1721
- import_v45.z.object({
1722
- type: import_v45.z.literal("code_execution_tool_result_error"),
1723
- error_code: import_v45.z.string()
1943
+ import_v47.z.object({
1944
+ type: import_v47.z.literal("code_execution_tool_result_error"),
1945
+ error_code: import_v47.z.string()
1724
1946
  })
1725
1947
  ])
1726
1948
  })
1727
1949
  ])
1728
1950
  ),
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()
1951
+ stop_reason: import_v47.z.string().nullish(),
1952
+ stop_sequence: import_v47.z.string().nullish(),
1953
+ usage: import_v47.z.looseObject({
1954
+ input_tokens: import_v47.z.number(),
1955
+ output_tokens: import_v47.z.number(),
1956
+ cache_creation_input_tokens: import_v47.z.number().nullish(),
1957
+ cache_read_input_tokens: import_v47.z.number().nullish()
1735
1958
  })
1736
1959
  });
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()
1960
+ var anthropicMessagesChunkSchema = import_v47.z.discriminatedUnion("type", [
1961
+ import_v47.z.object({
1962
+ type: import_v47.z.literal("message_start"),
1963
+ message: import_v47.z.object({
1964
+ id: import_v47.z.string().nullish(),
1965
+ model: import_v47.z.string().nullish(),
1966
+ usage: import_v47.z.looseObject({
1967
+ input_tokens: import_v47.z.number(),
1968
+ cache_creation_input_tokens: import_v47.z.number().nullish(),
1969
+ cache_read_input_tokens: import_v47.z.number().nullish()
1748
1970
  })
1749
1971
  })
1750
1972
  }),
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()
1973
+ import_v47.z.object({
1974
+ type: import_v47.z.literal("content_block_start"),
1975
+ index: import_v47.z.number(),
1976
+ content_block: import_v47.z.discriminatedUnion("type", [
1977
+ import_v47.z.object({
1978
+ type: import_v47.z.literal("text"),
1979
+ text: import_v47.z.string()
1758
1980
  }),
1759
- import_v45.z.object({
1760
- type: import_v45.z.literal("thinking"),
1761
- thinking: import_v45.z.string()
1981
+ import_v47.z.object({
1982
+ type: import_v47.z.literal("thinking"),
1983
+ thinking: import_v47.z.string()
1762
1984
  }),
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()
1985
+ import_v47.z.object({
1986
+ type: import_v47.z.literal("tool_use"),
1987
+ id: import_v47.z.string(),
1988
+ name: import_v47.z.string()
1767
1989
  }),
1768
- import_v45.z.object({
1769
- type: import_v45.z.literal("redacted_thinking"),
1770
- data: import_v45.z.string()
1990
+ import_v47.z.object({
1991
+ type: import_v47.z.literal("redacted_thinking"),
1992
+ data: import_v47.z.string()
1771
1993
  }),
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()
1994
+ import_v47.z.object({
1995
+ type: import_v47.z.literal("server_tool_use"),
1996
+ id: import_v47.z.string(),
1997
+ name: import_v47.z.string(),
1998
+ input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
1777
1999
  }),
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()
2000
+ import_v47.z.object({
2001
+ type: import_v47.z.literal("web_fetch_tool_result"),
2002
+ tool_use_id: import_v47.z.string(),
2003
+ content: import_v47.z.union([
2004
+ import_v47.z.object({
2005
+ type: import_v47.z.literal("web_fetch_result"),
2006
+ url: import_v47.z.string(),
2007
+ retrieved_at: import_v47.z.string(),
2008
+ content: import_v47.z.object({
2009
+ type: import_v47.z.literal("document"),
2010
+ title: import_v47.z.string().nullable(),
2011
+ citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
2012
+ source: import_v47.z.object({
2013
+ type: import_v47.z.literal("text"),
2014
+ media_type: import_v47.z.string(),
2015
+ data: import_v47.z.string()
2016
+ })
2017
+ })
2018
+ }),
2019
+ import_v47.z.object({
2020
+ type: import_v47.z.literal("web_fetch_tool_result_error"),
2021
+ error_code: import_v47.z.string()
2022
+ })
2023
+ ])
2024
+ }),
2025
+ import_v47.z.object({
2026
+ type: import_v47.z.literal("web_search_tool_result"),
2027
+ tool_use_id: import_v47.z.string(),
2028
+ content: import_v47.z.union([
2029
+ import_v47.z.array(
2030
+ import_v47.z.object({
2031
+ type: import_v47.z.literal("web_search_result"),
2032
+ url: import_v47.z.string(),
2033
+ title: import_v47.z.string(),
2034
+ encrypted_content: import_v47.z.string(),
2035
+ page_age: import_v47.z.string().nullish()
1789
2036
  })
1790
2037
  ),
1791
- import_v45.z.object({
1792
- type: import_v45.z.literal("web_search_tool_result_error"),
1793
- error_code: import_v45.z.string()
2038
+ import_v47.z.object({
2039
+ type: import_v47.z.literal("web_search_tool_result_error"),
2040
+ error_code: import_v47.z.string()
1794
2041
  })
1795
2042
  ])
1796
2043
  }),
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()
2044
+ import_v47.z.object({
2045
+ type: import_v47.z.literal("code_execution_tool_result"),
2046
+ tool_use_id: import_v47.z.string(),
2047
+ content: import_v47.z.union([
2048
+ import_v47.z.object({
2049
+ type: import_v47.z.literal("code_execution_result"),
2050
+ stdout: import_v47.z.string(),
2051
+ stderr: import_v47.z.string(),
2052
+ return_code: import_v47.z.number()
1806
2053
  }),
1807
- import_v45.z.object({
1808
- type: import_v45.z.literal("code_execution_tool_result_error"),
1809
- error_code: import_v45.z.string()
2054
+ import_v47.z.object({
2055
+ type: import_v47.z.literal("code_execution_tool_result_error"),
2056
+ error_code: import_v47.z.string()
1810
2057
  })
1811
2058
  ])
1812
2059
  })
1813
2060
  ])
1814
2061
  }),
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()
2062
+ import_v47.z.object({
2063
+ type: import_v47.z.literal("content_block_delta"),
2064
+ index: import_v47.z.number(),
2065
+ delta: import_v47.z.discriminatedUnion("type", [
2066
+ import_v47.z.object({
2067
+ type: import_v47.z.literal("input_json_delta"),
2068
+ partial_json: import_v47.z.string()
1822
2069
  }),
1823
- import_v45.z.object({
1824
- type: import_v45.z.literal("text_delta"),
1825
- text: import_v45.z.string()
2070
+ import_v47.z.object({
2071
+ type: import_v47.z.literal("text_delta"),
2072
+ text: import_v47.z.string()
1826
2073
  }),
1827
- import_v45.z.object({
1828
- type: import_v45.z.literal("thinking_delta"),
1829
- thinking: import_v45.z.string()
2074
+ import_v47.z.object({
2075
+ type: import_v47.z.literal("thinking_delta"),
2076
+ thinking: import_v47.z.string()
1830
2077
  }),
1831
- import_v45.z.object({
1832
- type: import_v45.z.literal("signature_delta"),
1833
- signature: import_v45.z.string()
2078
+ import_v47.z.object({
2079
+ type: import_v47.z.literal("signature_delta"),
2080
+ signature: import_v47.z.string()
1834
2081
  }),
1835
- import_v45.z.object({
1836
- type: import_v45.z.literal("citations_delta"),
2082
+ import_v47.z.object({
2083
+ type: import_v47.z.literal("citations_delta"),
1837
2084
  citation: citationSchema
1838
2085
  })
1839
2086
  ])
1840
2087
  }),
1841
- import_v45.z.object({
1842
- type: import_v45.z.literal("content_block_stop"),
1843
- index: import_v45.z.number()
2088
+ import_v47.z.object({
2089
+ type: import_v47.z.literal("content_block_stop"),
2090
+ index: import_v47.z.number()
1844
2091
  }),
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()
2092
+ import_v47.z.object({
2093
+ type: import_v47.z.literal("error"),
2094
+ error: import_v47.z.object({
2095
+ type: import_v47.z.string(),
2096
+ message: import_v47.z.string()
1850
2097
  })
1851
2098
  }),
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() })
2099
+ import_v47.z.object({
2100
+ type: import_v47.z.literal("message_delta"),
2101
+ delta: import_v47.z.object({
2102
+ stop_reason: import_v47.z.string().nullish(),
2103
+ stop_sequence: import_v47.z.string().nullish()
2104
+ }),
2105
+ usage: import_v47.z.looseObject({
2106
+ output_tokens: import_v47.z.number(),
2107
+ cache_creation_input_tokens: import_v47.z.number().nullish()
2108
+ })
1856
2109
  }),
1857
- import_v45.z.object({
1858
- type: import_v45.z.literal("message_stop")
2110
+ import_v47.z.object({
2111
+ type: import_v47.z.literal("message_stop")
1859
2112
  }),
1860
- import_v45.z.object({
1861
- type: import_v45.z.literal("ping")
2113
+ import_v47.z.object({
2114
+ type: import_v47.z.literal("ping")
1862
2115
  })
1863
2116
  ]);
1864
- var anthropicReasoningMetadataSchema = import_v45.z.object({
1865
- signature: import_v45.z.string().optional(),
1866
- redactedData: import_v45.z.string().optional()
2117
+ var anthropicReasoningMetadataSchema = import_v47.z.object({
2118
+ signature: import_v47.z.string().optional(),
2119
+ redactedData: import_v47.z.string().optional()
1867
2120
  });
1868
2121
 
1869
2122
  // 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)({
2123
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
2124
+ var import_v48 = __toESM(require("zod/v4"));
2125
+ var bash_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1873
2126
  id: "anthropic.bash_20241022",
1874
2127
  name: "bash",
1875
- inputSchema: import_v46.default.object({
1876
- command: import_v46.default.string(),
1877
- restart: import_v46.default.boolean().optional()
2128
+ inputSchema: import_v48.default.object({
2129
+ command: import_v48.default.string(),
2130
+ restart: import_v48.default.boolean().optional()
1878
2131
  })
1879
2132
  });
1880
2133
 
1881
2134
  // 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)({
2135
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
2136
+ var import_v49 = __toESM(require("zod/v4"));
2137
+ var bash_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1885
2138
  id: "anthropic.bash_20250124",
1886
2139
  name: "bash",
1887
- inputSchema: import_v47.default.object({
1888
- command: import_v47.default.string(),
1889
- restart: import_v47.default.boolean().optional()
2140
+ inputSchema: import_v49.default.object({
2141
+ command: import_v49.default.string(),
2142
+ restart: import_v49.default.boolean().optional()
1890
2143
  })
1891
2144
  });
1892
2145
 
1893
2146
  // 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)({
2147
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
2148
+ var import_v410 = require("zod/v4");
2149
+ var computer_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1897
2150
  id: "anthropic.computer_20241022",
1898
2151
  name: "computer",
1899
- inputSchema: import_v48.z.object({
1900
- action: import_v48.z.enum([
2152
+ inputSchema: import_v410.z.object({
2153
+ action: import_v410.z.enum([
1901
2154
  "key",
1902
2155
  "type",
1903
2156
  "mouse_move",
@@ -1909,19 +2162,19 @@ var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFact
1909
2162
  "screenshot",
1910
2163
  "cursor_position"
1911
2164
  ]),
1912
- coordinate: import_v48.z.array(import_v48.z.number().int()).optional(),
1913
- text: import_v48.z.string().optional()
2165
+ coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
2166
+ text: import_v410.z.string().optional()
1914
2167
  })
1915
2168
  });
1916
2169
 
1917
2170
  // 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)({
2171
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
2172
+ var import_v411 = require("zod/v4");
2173
+ var computer_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1921
2174
  id: "anthropic.computer_20250124",
1922
2175
  name: "computer",
1923
- inputSchema: import_v49.z.object({
1924
- action: import_v49.z.enum([
2176
+ inputSchema: import_v411.z.object({
2177
+ action: import_v411.z.enum([
1925
2178
  "key",
1926
2179
  "hold_key",
1927
2180
  "type",
@@ -1939,63 +2192,63 @@ var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFact
1939
2192
  "wait",
1940
2193
  "screenshot"
1941
2194
  ]),
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()
2195
+ coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2196
+ duration: import_v411.z.number().optional(),
2197
+ scroll_amount: import_v411.z.number().optional(),
2198
+ scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
2199
+ start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2200
+ text: import_v411.z.string().optional()
1948
2201
  })
1949
2202
  });
1950
2203
 
1951
2204
  // 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)({
2205
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2206
+ var import_v412 = require("zod/v4");
2207
+ var textEditor_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
1955
2208
  id: "anthropic.text_editor_20241022",
1956
2209
  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()
2210
+ inputSchema: import_v412.z.object({
2211
+ command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2212
+ path: import_v412.z.string(),
2213
+ file_text: import_v412.z.string().optional(),
2214
+ insert_line: import_v412.z.number().int().optional(),
2215
+ new_str: import_v412.z.string().optional(),
2216
+ old_str: import_v412.z.string().optional(),
2217
+ view_range: import_v412.z.array(import_v412.z.number().int()).optional()
1965
2218
  })
1966
2219
  });
1967
2220
 
1968
2221
  // 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)({
2222
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2223
+ var import_v413 = require("zod/v4");
2224
+ var textEditor_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
1972
2225
  id: "anthropic.text_editor_20250124",
1973
2226
  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()
2227
+ inputSchema: import_v413.z.object({
2228
+ command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2229
+ path: import_v413.z.string(),
2230
+ file_text: import_v413.z.string().optional(),
2231
+ insert_line: import_v413.z.number().int().optional(),
2232
+ new_str: import_v413.z.string().optional(),
2233
+ old_str: import_v413.z.string().optional(),
2234
+ view_range: import_v413.z.array(import_v413.z.number().int()).optional()
1982
2235
  })
1983
2236
  });
1984
2237
 
1985
2238
  // 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)({
2239
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2240
+ var import_v414 = require("zod/v4");
2241
+ var textEditor_20250429 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
1989
2242
  id: "anthropic.text_editor_20250429",
1990
2243
  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()
2244
+ inputSchema: import_v414.z.object({
2245
+ command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
2246
+ path: import_v414.z.string(),
2247
+ file_text: import_v414.z.string().optional(),
2248
+ insert_line: import_v414.z.number().int().optional(),
2249
+ new_str: import_v414.z.string().optional(),
2250
+ old_str: import_v414.z.string().optional(),
2251
+ view_range: import_v414.z.array(import_v414.z.number().int()).optional()
1999
2252
  })
2000
2253
  });
2001
2254
 
@@ -2061,6 +2314,8 @@ var anthropicTools = {
2061
2314
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2062
2315
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2063
2316
  *
2317
+ * Supported models: Claude Sonnet 3.5
2318
+ *
2064
2319
  * Tool name must be `str_replace_editor`.
2065
2320
  */
2066
2321
  textEditor_20241022,
@@ -2069,6 +2324,8 @@ var anthropicTools = {
2069
2324
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2070
2325
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2071
2326
  *
2327
+ * Supported models: Claude Sonnet 3.7
2328
+ *
2072
2329
  * Tool name must be `str_replace_editor`.
2073
2330
  */
2074
2331
  textEditor_20250124,
@@ -2080,8 +2337,36 @@ var anthropicTools = {
2080
2337
  * Note: This version does not support the "undo_edit" command.
2081
2338
  *
2082
2339
  * Tool name must be `str_replace_based_edit_tool`.
2340
+ *
2341
+ * @deprecated Use textEditor_20250728 instead
2083
2342
  */
2084
2343
  textEditor_20250429,
2344
+ /**
2345
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2346
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2347
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2348
+ *
2349
+ * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
2350
+ *
2351
+ * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
2352
+ *
2353
+ * Tool name must be `str_replace_based_edit_tool`.
2354
+ *
2355
+ * @param maxCharacters - Optional maximum number of characters to view in the file
2356
+ */
2357
+ textEditor_20250728,
2358
+ /**
2359
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
2360
+ *
2361
+ * Tool name must be `web_fetch`.
2362
+ *
2363
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
2364
+ * @param allowedDomains - Only fetch from these domains
2365
+ * @param blockedDomains - Never fetch from these domains
2366
+ * @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.
2367
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
2368
+ */
2369
+ webFetch_20250910,
2085
2370
  /**
2086
2371
  * Creates a web search tool that gives Claude direct access to real-time web content.
2087
2372
  *