@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.
package/dist/index.mjs CHANGED
@@ -5,9 +5,13 @@ import {
5
5
  import {
6
6
  generateId as generateId2,
7
7
  loadApiKey,
8
- withoutTrailingSlash
8
+ withoutTrailingSlash,
9
+ withUserAgentSuffix
9
10
  } from "@ai-sdk/provider-utils";
10
11
 
12
+ // src/version.ts
13
+ var VERSION = true ? "2.1.0-beta.11" : "0.0.0-test";
14
+
11
15
  // src/anthropic-messages-language-model.ts
12
16
  import {
13
17
  UnsupportedFunctionalityError as UnsupportedFunctionalityError3
@@ -21,7 +25,7 @@ import {
21
25
  postJsonToApi,
22
26
  resolve
23
27
  } from "@ai-sdk/provider-utils";
24
- import { z as z5 } from "zod/v4";
28
+ import { z as z7 } from "zod/v4";
25
29
 
26
30
  // src/anthropic-error.ts
27
31
  import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
@@ -97,58 +101,110 @@ function getCacheControl(providerMetadata) {
97
101
  return cacheControlValue;
98
102
  }
99
103
 
104
+ // src/tool/text-editor_20250728.ts
105
+ import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
106
+ import { z as z3 } from "zod/v4";
107
+ var textEditor_20250728ArgsSchema = z3.object({
108
+ maxCharacters: z3.number().optional()
109
+ });
110
+ var factory = createProviderDefinedToolFactory({
111
+ id: "anthropic.text_editor_20250728",
112
+ name: "str_replace_based_edit_tool",
113
+ inputSchema: z3.object({
114
+ command: z3.enum(["view", "create", "str_replace", "insert"]),
115
+ path: z3.string(),
116
+ file_text: z3.string().optional(),
117
+ insert_line: z3.number().int().optional(),
118
+ new_str: z3.string().optional(),
119
+ old_str: z3.string().optional(),
120
+ view_range: z3.array(z3.number().int()).optional()
121
+ })
122
+ });
123
+ var textEditor_20250728 = (args = {}) => {
124
+ return factory(args);
125
+ };
126
+
100
127
  // src/tool/web-search_20250305.ts
101
128
  import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
102
- import { z as z3 } from "zod/v4";
103
- var webSearch_20250305ArgsSchema = z3.object({
104
- /**
105
- * Maximum number of web searches Claude can perform during the conversation.
106
- */
107
- maxUses: z3.number().optional(),
108
- /**
109
- * Optional list of domains that Claude is allowed to search.
110
- */
111
- allowedDomains: z3.array(z3.string()).optional(),
112
- /**
113
- * Optional list of domains that Claude should avoid when searching.
114
- */
115
- blockedDomains: z3.array(z3.string()).optional(),
116
- /**
117
- * Optional user location information to provide geographically relevant search results.
118
- */
119
- userLocation: z3.object({
120
- type: z3.literal("approximate"),
121
- city: z3.string().optional(),
122
- region: z3.string().optional(),
123
- country: z3.string().optional(),
124
- timezone: z3.string().optional()
129
+ import { z as z4 } from "zod/v4";
130
+ var webSearch_20250305ArgsSchema = z4.object({
131
+ maxUses: z4.number().optional(),
132
+ allowedDomains: z4.array(z4.string()).optional(),
133
+ blockedDomains: z4.array(z4.string()).optional(),
134
+ userLocation: z4.object({
135
+ type: z4.literal("approximate"),
136
+ city: z4.string().optional(),
137
+ region: z4.string().optional(),
138
+ country: z4.string().optional(),
139
+ timezone: z4.string().optional()
125
140
  }).optional()
126
141
  });
127
- var webSearch_20250305OutputSchema = z3.array(
128
- z3.object({
129
- url: z3.string(),
130
- title: z3.string(),
131
- pageAge: z3.string().nullable(),
132
- encryptedContent: z3.string(),
133
- type: z3.string()
142
+ var webSearch_20250305OutputSchema = z4.array(
143
+ z4.object({
144
+ url: z4.string(),
145
+ title: z4.string(),
146
+ pageAge: z4.string().nullable(),
147
+ encryptedContent: z4.string(),
148
+ type: z4.literal("web_search_result")
134
149
  })
135
150
  );
136
- var factory = createProviderDefinedToolFactoryWithOutputSchema({
151
+ var factory2 = createProviderDefinedToolFactoryWithOutputSchema({
137
152
  id: "anthropic.web_search_20250305",
138
153
  name: "web_search",
139
- inputSchema: z3.object({
140
- query: z3.string()
154
+ inputSchema: z4.object({
155
+ query: z4.string()
141
156
  }),
142
157
  outputSchema: webSearch_20250305OutputSchema
143
158
  });
144
159
  var webSearch_20250305 = (args = {}) => {
145
- return factory(args);
160
+ return factory2(args);
161
+ };
162
+
163
+ // src/tool/web-fetch-20250910.ts
164
+ import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
165
+ import { z as z5 } from "zod/v4";
166
+ var webFetch_20250910ArgsSchema = z5.object({
167
+ maxUses: z5.number().optional(),
168
+ allowedDomains: z5.array(z5.string()).optional(),
169
+ blockedDomains: z5.array(z5.string()).optional(),
170
+ citations: z5.object({ enabled: z5.boolean() }).optional(),
171
+ maxContentTokens: z5.number().optional()
172
+ });
173
+ var webFetch_20250910OutputSchema = z5.object({
174
+ type: z5.literal("web_fetch_result"),
175
+ url: z5.string(),
176
+ content: z5.object({
177
+ type: z5.literal("document"),
178
+ title: z5.string(),
179
+ citations: z5.object({ enabled: z5.boolean() }).optional(),
180
+ source: z5.union([
181
+ z5.object({
182
+ type: z5.literal("base64"),
183
+ mediaType: z5.literal("application/pdf"),
184
+ data: z5.string()
185
+ }),
186
+ z5.object({
187
+ type: z5.literal("text"),
188
+ mediaType: z5.literal("text/plain"),
189
+ data: z5.string()
190
+ })
191
+ ])
192
+ }),
193
+ retrievedAt: z5.string().nullable()
194
+ });
195
+ var factory3 = createProviderDefinedToolFactoryWithOutputSchema2({
196
+ id: "anthropic.web_fetch_20250910",
197
+ name: "web_fetch",
198
+ inputSchema: z5.object({
199
+ url: z5.string()
200
+ }),
201
+ outputSchema: webFetch_20250910OutputSchema
202
+ });
203
+ var webFetch_20250910 = (args = {}) => {
204
+ return factory3(args);
146
205
  };
147
206
 
148
207
  // src/anthropic-prepare-tools.ts
149
- function isWebSearchTool(tool) {
150
- return typeof tool === "object" && tool !== null && "type" in tool && tool.type === "web_search_20250305";
151
- }
152
208
  function prepareTools({
153
209
  tools,
154
210
  toolChoice,
@@ -162,12 +218,8 @@ function prepareTools({
162
218
  }
163
219
  const anthropicTools2 = [];
164
220
  for (const tool of tools) {
165
- if (isWebSearchTool(tool)) {
166
- anthropicTools2.push(tool);
167
- continue;
168
- }
169
221
  switch (tool.type) {
170
- case "function":
222
+ case "function": {
171
223
  const cacheControl = getCacheControl(tool.providerOptions);
172
224
  anthropicTools2.push({
173
225
  name: tool.name,
@@ -176,9 +228,18 @@ function prepareTools({
176
228
  cache_control: cacheControl
177
229
  });
178
230
  break;
179
- case "provider-defined":
231
+ }
232
+ case "provider-defined": {
180
233
  switch (tool.id) {
181
- case "anthropic.computer_20250124":
234
+ case "anthropic.code_execution_20250522": {
235
+ betas.add("code-execution-2025-05-22");
236
+ anthropicTools2.push({
237
+ type: "code_execution_20250522",
238
+ name: "code_execution"
239
+ });
240
+ break;
241
+ }
242
+ case "anthropic.computer_20250124": {
182
243
  betas.add("computer-use-2025-01-24");
183
244
  anthropicTools2.push({
184
245
  name: "computer",
@@ -188,7 +249,8 @@ function prepareTools({
188
249
  display_number: tool.args.displayNumber
189
250
  });
190
251
  break;
191
- case "anthropic.computer_20241022":
252
+ }
253
+ case "anthropic.computer_20241022": {
192
254
  betas.add("computer-use-2024-10-22");
193
255
  anthropicTools2.push({
194
256
  name: "computer",
@@ -198,41 +260,70 @@ function prepareTools({
198
260
  display_number: tool.args.displayNumber
199
261
  });
200
262
  break;
201
- case "anthropic.text_editor_20250124":
263
+ }
264
+ case "anthropic.text_editor_20250124": {
202
265
  betas.add("computer-use-2025-01-24");
203
266
  anthropicTools2.push({
204
267
  name: "str_replace_editor",
205
268
  type: "text_editor_20250124"
206
269
  });
207
270
  break;
208
- case "anthropic.text_editor_20241022":
271
+ }
272
+ case "anthropic.text_editor_20241022": {
209
273
  betas.add("computer-use-2024-10-22");
210
274
  anthropicTools2.push({
211
275
  name: "str_replace_editor",
212
276
  type: "text_editor_20241022"
213
277
  });
214
278
  break;
215
- case "anthropic.text_editor_20250429":
279
+ }
280
+ case "anthropic.text_editor_20250429": {
216
281
  betas.add("computer-use-2025-01-24");
217
282
  anthropicTools2.push({
218
283
  name: "str_replace_based_edit_tool",
219
284
  type: "text_editor_20250429"
220
285
  });
221
286
  break;
222
- case "anthropic.bash_20250124":
287
+ }
288
+ case "anthropic.text_editor_20250728": {
289
+ const args = textEditor_20250728ArgsSchema.parse(tool.args);
290
+ anthropicTools2.push({
291
+ name: "str_replace_based_edit_tool",
292
+ type: "text_editor_20250728",
293
+ max_characters: args.maxCharacters
294
+ });
295
+ break;
296
+ }
297
+ case "anthropic.bash_20250124": {
223
298
  betas.add("computer-use-2025-01-24");
224
299
  anthropicTools2.push({
225
300
  name: "bash",
226
301
  type: "bash_20250124"
227
302
  });
228
303
  break;
229
- case "anthropic.bash_20241022":
304
+ }
305
+ case "anthropic.bash_20241022": {
230
306
  betas.add("computer-use-2024-10-22");
231
307
  anthropicTools2.push({
232
308
  name: "bash",
233
309
  type: "bash_20241022"
234
310
  });
235
311
  break;
312
+ }
313
+ case "anthropic.web_fetch_20250910": {
314
+ betas.add("web-fetch-2025-09-10");
315
+ const args = webFetch_20250910ArgsSchema.parse(tool.args);
316
+ anthropicTools2.push({
317
+ type: "web_fetch_20250910",
318
+ name: "web_fetch",
319
+ max_uses: args.maxUses,
320
+ allowed_domains: args.allowedDomains,
321
+ blocked_domains: args.blockedDomains,
322
+ citations: args.citations,
323
+ max_content_tokens: args.maxContentTokens
324
+ });
325
+ break;
326
+ }
236
327
  case "anthropic.web_search_20250305": {
237
328
  const args = webSearch_20250305ArgsSchema.parse(tool.args);
238
329
  anthropicTools2.push({
@@ -245,22 +336,17 @@ function prepareTools({
245
336
  });
246
337
  break;
247
338
  }
248
- case "anthropic.code_execution_20250522": {
249
- betas.add("code-execution-2025-05-22");
250
- anthropicTools2.push({
251
- type: "code_execution_20250522",
252
- name: "code_execution"
253
- });
254
- break;
255
- }
256
- default:
339
+ default: {
257
340
  toolWarnings.push({ type: "unsupported-tool", tool });
258
341
  break;
342
+ }
259
343
  }
260
344
  break;
261
- default:
345
+ }
346
+ default: {
262
347
  toolWarnings.push({ type: "unsupported-tool", tool });
263
348
  break;
349
+ }
264
350
  }
265
351
  }
266
352
  if (toolChoice == null) {
@@ -322,24 +408,24 @@ import {
322
408
  import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
323
409
 
324
410
  // src/tool/code-execution_20250522.ts
325
- import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
326
- import { z as z4 } from "zod/v4";
327
- var codeExecution_20250522OutputSchema = z4.object({
328
- type: z4.literal("code_execution_result"),
329
- stdout: z4.string(),
330
- stderr: z4.string(),
331
- return_code: z4.number()
411
+ import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
412
+ import { z as z6 } from "zod/v4";
413
+ var codeExecution_20250522OutputSchema = z6.object({
414
+ type: z6.literal("code_execution_result"),
415
+ stdout: z6.string(),
416
+ stderr: z6.string(),
417
+ return_code: z6.number()
332
418
  });
333
- var factory2 = createProviderDefinedToolFactoryWithOutputSchema2({
419
+ var factory4 = createProviderDefinedToolFactoryWithOutputSchema3({
334
420
  id: "anthropic.code_execution_20250522",
335
421
  name: "code_execution",
336
- inputSchema: z4.object({
337
- code: z4.string()
422
+ inputSchema: z6.object({
423
+ code: z6.string()
338
424
  }),
339
425
  outputSchema: codeExecution_20250522OutputSchema
340
426
  });
341
427
  var codeExecution_20250522 = (args = {}) => {
342
- return factory2(args);
428
+ return factory4(args);
343
429
  };
344
430
 
345
431
  // src/convert-to-anthropic-messages-prompt.ts
@@ -364,7 +450,7 @@ async function convertToAnthropicMessagesPrompt({
364
450
  sendReasoning,
365
451
  warnings
366
452
  }) {
367
- var _a, _b, _c, _d, _e;
453
+ var _a, _b, _c, _d, _e, _f;
368
454
  const betas = /* @__PURE__ */ new Set();
369
455
  const blocks = groupIntoBlocks(prompt);
370
456
  let system = void 0;
@@ -540,6 +626,9 @@ async function convertToAnthropicMessagesPrompt({
540
626
  case "error-text":
541
627
  contentValue = output.value;
542
628
  break;
629
+ case "execution-denied":
630
+ contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
631
+ break;
543
632
  case "json":
544
633
  case "error-json":
545
634
  default:
@@ -574,7 +663,7 @@ async function convertToAnthropicMessagesPrompt({
574
663
  for (let k = 0; k < content.length; k++) {
575
664
  const part = content[k];
576
665
  const isLastContentPart = k === content.length - 1;
577
- const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
666
+ const cacheControl = (_f = getCacheControl(part.providerOptions)) != null ? _f : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
578
667
  switch (part.type) {
579
668
  case "text": {
580
669
  anthropicContent.push({
@@ -632,30 +721,20 @@ async function convertToAnthropicMessagesPrompt({
632
721
  }
633
722
  case "tool-call": {
634
723
  if (part.providerExecuted) {
635
- if (part.toolName === "web_search") {
724
+ if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
636
725
  anthropicContent.push({
637
726
  type: "server_tool_use",
638
727
  id: part.toolCallId,
639
- name: "web_search",
728
+ name: part.toolName,
640
729
  input: part.input,
641
730
  cache_control: cacheControl
642
731
  });
643
- break;
644
- }
645
- if (part.toolName === "code_execution") {
646
- anthropicContent.push({
647
- type: "server_tool_use",
648
- id: part.toolCallId,
649
- name: "code_execution",
650
- input: part.input,
651
- cache_control: cacheControl
732
+ } else {
733
+ warnings.push({
734
+ type: "other",
735
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
652
736
  });
653
- break;
654
737
  }
655
- warnings.push({
656
- type: "other",
657
- message: `provider executed tool call for tool ${part.toolName} is not supported`
658
- });
659
738
  break;
660
739
  }
661
740
  anthropicContent.push({
@@ -668,7 +747,7 @@ async function convertToAnthropicMessagesPrompt({
668
747
  break;
669
748
  }
670
749
  case "tool-result": {
671
- if (part.toolName === "web_search") {
750
+ if (part.toolName === "code_execution") {
672
751
  const output = part.output;
673
752
  if (output.type !== "json") {
674
753
  warnings.push({
@@ -677,24 +756,21 @@ async function convertToAnthropicMessagesPrompt({
677
756
  });
678
757
  break;
679
758
  }
680
- const webSearchOutput = webSearch_20250305OutputSchema.parse(
681
- output.value
682
- );
759
+ const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
683
760
  anthropicContent.push({
684
- type: "web_search_tool_result",
761
+ type: "code_execution_tool_result",
685
762
  tool_use_id: part.toolCallId,
686
- content: webSearchOutput.map((result) => ({
687
- url: result.url,
688
- title: result.title,
689
- page_age: result.pageAge,
690
- encrypted_content: result.encryptedContent,
691
- type: result.type
692
- })),
763
+ content: {
764
+ type: codeExecutionOutput.type,
765
+ stdout: codeExecutionOutput.stdout,
766
+ stderr: codeExecutionOutput.stderr,
767
+ return_code: codeExecutionOutput.return_code
768
+ },
693
769
  cache_control: cacheControl
694
770
  });
695
771
  break;
696
772
  }
697
- if (part.toolName === "code_execution") {
773
+ if (part.toolName === "web_fetch") {
698
774
  const output = part.output;
699
775
  if (output.type !== "json") {
700
776
  warnings.push({
@@ -703,20 +779,57 @@ async function convertToAnthropicMessagesPrompt({
703
779
  });
704
780
  break;
705
781
  }
706
- const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
782
+ const webFetchOutput = webFetch_20250910OutputSchema.parse(
783
+ output.value
784
+ );
707
785
  anthropicContent.push({
708
- type: "code_execution_tool_result",
786
+ type: "web_fetch_tool_result",
709
787
  tool_use_id: part.toolCallId,
710
788
  content: {
711
- type: codeExecutionOutput.type,
712
- stdout: codeExecutionOutput.stdout,
713
- stderr: codeExecutionOutput.stderr,
714
- return_code: codeExecutionOutput.return_code
789
+ type: "web_fetch_result",
790
+ url: webFetchOutput.url,
791
+ retrieved_at: webFetchOutput.retrievedAt,
792
+ content: {
793
+ type: "document",
794
+ title: webFetchOutput.content.title,
795
+ citations: webFetchOutput.content.citations,
796
+ source: {
797
+ type: webFetchOutput.content.source.type,
798
+ media_type: webFetchOutput.content.source.mediaType,
799
+ data: webFetchOutput.content.source.data
800
+ }
801
+ }
715
802
  },
716
803
  cache_control: cacheControl
717
804
  });
718
805
  break;
719
806
  }
807
+ if (part.toolName === "web_search") {
808
+ const output = part.output;
809
+ if (output.type !== "json") {
810
+ warnings.push({
811
+ type: "other",
812
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
813
+ });
814
+ break;
815
+ }
816
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
817
+ output.value
818
+ );
819
+ anthropicContent.push({
820
+ type: "web_search_tool_result",
821
+ tool_use_id: part.toolCallId,
822
+ content: webSearchOutput.map((result) => ({
823
+ url: result.url,
824
+ title: result.title,
825
+ page_age: result.pageAge,
826
+ encrypted_content: result.encryptedContent,
827
+ type: result.type
828
+ })),
829
+ cache_control: cacheControl
830
+ });
831
+ break;
832
+ }
720
833
  warnings.push({
721
834
  type: "other",
722
835
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -810,36 +923,36 @@ function mapAnthropicStopReason({
810
923
 
811
924
  // src/anthropic-messages-language-model.ts
812
925
  var citationSchemas = {
813
- webSearchResult: z5.object({
814
- type: z5.literal("web_search_result_location"),
815
- cited_text: z5.string(),
816
- url: z5.string(),
817
- title: z5.string(),
818
- encrypted_index: z5.string()
926
+ webSearchResult: z7.object({
927
+ type: z7.literal("web_search_result_location"),
928
+ cited_text: z7.string(),
929
+ url: z7.string(),
930
+ title: z7.string(),
931
+ encrypted_index: z7.string()
819
932
  }),
820
- pageLocation: z5.object({
821
- type: z5.literal("page_location"),
822
- cited_text: z5.string(),
823
- document_index: z5.number(),
824
- document_title: z5.string().nullable(),
825
- start_page_number: z5.number(),
826
- end_page_number: z5.number()
933
+ pageLocation: z7.object({
934
+ type: z7.literal("page_location"),
935
+ cited_text: z7.string(),
936
+ document_index: z7.number(),
937
+ document_title: z7.string().nullable(),
938
+ start_page_number: z7.number(),
939
+ end_page_number: z7.number()
827
940
  }),
828
- charLocation: z5.object({
829
- type: z5.literal("char_location"),
830
- cited_text: z5.string(),
831
- document_index: z5.number(),
832
- document_title: z5.string().nullable(),
833
- start_char_index: z5.number(),
834
- end_char_index: z5.number()
941
+ charLocation: z7.object({
942
+ type: z7.literal("char_location"),
943
+ cited_text: z7.string(),
944
+ document_index: z7.number(),
945
+ document_title: z7.string().nullable(),
946
+ start_char_index: z7.number(),
947
+ end_char_index: z7.number()
835
948
  })
836
949
  };
837
- var citationSchema = z5.discriminatedUnion("type", [
950
+ var citationSchema = z7.discriminatedUnion("type", [
838
951
  citationSchemas.webSearchResult,
839
952
  citationSchemas.pageLocation,
840
953
  citationSchemas.charLocation
841
954
  ]);
842
- var documentCitationSchema = z5.discriminatedUnion("type", [
955
+ var documentCitationSchema = z7.discriminatedUnion("type", [
843
956
  citationSchemas.pageLocation,
844
957
  citationSchemas.charLocation
845
958
  ]);
@@ -884,7 +997,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
884
997
  }
885
998
  var AnthropicMessagesLanguageModel = class {
886
999
  constructor(modelId, config) {
887
- this.specificationVersion = "v2";
1000
+ this.specificationVersion = "v3";
888
1001
  var _a;
889
1002
  this.modelId = modelId;
890
1003
  this.config = config;
@@ -1087,7 +1200,7 @@ var AnthropicMessagesLanguageModel = class {
1087
1200
  });
1088
1201
  }
1089
1202
  async doGenerate(options) {
1090
- var _a, _b, _c, _d, _e;
1203
+ var _a, _b, _c, _d, _e, _f;
1091
1204
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1092
1205
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1093
1206
  const {
@@ -1164,7 +1277,7 @@ var AnthropicMessagesLanguageModel = class {
1164
1277
  break;
1165
1278
  }
1166
1279
  case "server_tool_use": {
1167
- if (part.name === "web_search" || part.name === "code_execution") {
1280
+ if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1168
1281
  content.push({
1169
1282
  type: "tool-call",
1170
1283
  toolCallId: part.id,
@@ -1175,6 +1288,44 @@ var AnthropicMessagesLanguageModel = class {
1175
1288
  }
1176
1289
  break;
1177
1290
  }
1291
+ case "web_fetch_tool_result": {
1292
+ if (part.content.type === "web_fetch_result") {
1293
+ content.push({
1294
+ type: "tool-result",
1295
+ toolCallId: part.tool_use_id,
1296
+ toolName: "web_fetch",
1297
+ result: {
1298
+ type: "web_fetch_result",
1299
+ url: part.content.url,
1300
+ retrievedAt: part.content.retrieved_at,
1301
+ content: {
1302
+ type: part.content.content.type,
1303
+ title: part.content.content.title,
1304
+ citations: part.content.content.citations,
1305
+ source: {
1306
+ type: part.content.content.source.type,
1307
+ mediaType: part.content.content.source.media_type,
1308
+ data: part.content.content.source.data
1309
+ }
1310
+ }
1311
+ },
1312
+ providerExecuted: true
1313
+ });
1314
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1315
+ content.push({
1316
+ type: "tool-result",
1317
+ toolCallId: part.tool_use_id,
1318
+ toolName: "web_fetch",
1319
+ isError: true,
1320
+ result: {
1321
+ type: "web_fetch_tool_result_error",
1322
+ errorCode: part.content.error_code
1323
+ },
1324
+ providerExecuted: true
1325
+ });
1326
+ }
1327
+ break;
1328
+ }
1178
1329
  case "web_search_tool_result": {
1179
1330
  if (Array.isArray(part.content)) {
1180
1331
  content.push({
@@ -1276,7 +1427,8 @@ var AnthropicMessagesLanguageModel = class {
1276
1427
  providerMetadata: {
1277
1428
  anthropic: {
1278
1429
  usage: response.usage,
1279
- cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1430
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
1431
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null
1280
1432
  }
1281
1433
  }
1282
1434
  };
@@ -1303,7 +1455,9 @@ var AnthropicMessagesLanguageModel = class {
1303
1455
  totalTokens: void 0
1304
1456
  };
1305
1457
  const contentBlocks = {};
1306
- let providerMetadata = void 0;
1458
+ let rawUsage = void 0;
1459
+ let cacheCreationInputTokens = null;
1460
+ let stopSequence = null;
1307
1461
  let blockType = void 0;
1308
1462
  const generateId3 = this.generateId;
1309
1463
  return {
@@ -1313,7 +1467,7 @@ var AnthropicMessagesLanguageModel = class {
1313
1467
  controller.enqueue({ type: "stream-start", warnings });
1314
1468
  },
1315
1469
  transform(chunk, controller) {
1316
- var _a, _b, _c, _d, _e, _f, _g;
1470
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1317
1471
  if (options.includeRawChunks) {
1318
1472
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1319
1473
  }
@@ -1376,7 +1530,7 @@ var AnthropicMessagesLanguageModel = class {
1376
1530
  return;
1377
1531
  }
1378
1532
  case "server_tool_use": {
1379
- if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1533
+ if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1380
1534
  contentBlocks[value.index] = {
1381
1535
  type: "tool-call",
1382
1536
  toolCallId: value.content_block.id,
@@ -1393,6 +1547,44 @@ var AnthropicMessagesLanguageModel = class {
1393
1547
  }
1394
1548
  return;
1395
1549
  }
1550
+ case "web_fetch_tool_result": {
1551
+ const part = value.content_block;
1552
+ if (part.content.type === "web_fetch_result") {
1553
+ controller.enqueue({
1554
+ type: "tool-result",
1555
+ toolCallId: part.tool_use_id,
1556
+ toolName: "web_fetch",
1557
+ result: {
1558
+ type: "web_fetch_result",
1559
+ url: part.content.url,
1560
+ retrievedAt: part.content.retrieved_at,
1561
+ content: {
1562
+ type: part.content.content.type,
1563
+ title: part.content.content.title,
1564
+ citations: part.content.content.citations,
1565
+ source: {
1566
+ type: part.content.content.source.type,
1567
+ mediaType: part.content.content.source.media_type,
1568
+ data: part.content.content.source.data
1569
+ }
1570
+ }
1571
+ }
1572
+ });
1573
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1574
+ controller.enqueue({
1575
+ type: "tool-result",
1576
+ toolCallId: part.tool_use_id,
1577
+ toolName: "web_fetch",
1578
+ isError: true,
1579
+ result: {
1580
+ type: "web_fetch_tool_result_error",
1581
+ errorCode: part.content.error_code
1582
+ },
1583
+ providerExecuted: true
1584
+ });
1585
+ }
1586
+ return;
1587
+ }
1396
1588
  case "web_search_tool_result": {
1397
1589
  const part = value.content_block;
1398
1590
  if (Array.isArray(part.content)) {
@@ -1595,12 +1787,10 @@ var AnthropicMessagesLanguageModel = class {
1595
1787
  case "message_start": {
1596
1788
  usage.inputTokens = value.message.usage.input_tokens;
1597
1789
  usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1598
- providerMetadata = {
1599
- anthropic: {
1600
- usage: value.message.usage,
1601
- cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1602
- }
1790
+ rawUsage = {
1791
+ ...value.message.usage
1603
1792
  };
1793
+ cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
1604
1794
  controller.enqueue({
1605
1795
  type: "response-metadata",
1606
1796
  id: (_d = value.message.id) != null ? _d : void 0,
@@ -1615,6 +1805,11 @@ var AnthropicMessagesLanguageModel = class {
1615
1805
  finishReason: value.delta.stop_reason,
1616
1806
  isJsonResponseFromTool: usesJsonResponseTool
1617
1807
  });
1808
+ stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
1809
+ rawUsage = {
1810
+ ...rawUsage,
1811
+ ...value.usage
1812
+ };
1618
1813
  return;
1619
1814
  }
1620
1815
  case "message_stop": {
@@ -1622,7 +1817,13 @@ var AnthropicMessagesLanguageModel = class {
1622
1817
  type: "finish",
1623
1818
  finishReason,
1624
1819
  usage,
1625
- providerMetadata
1820
+ providerMetadata: {
1821
+ anthropic: {
1822
+ usage: rawUsage != null ? rawUsage : null,
1823
+ cacheCreationInputTokens,
1824
+ stopSequence
1825
+ }
1826
+ }
1626
1827
  });
1627
1828
  return;
1628
1829
  }
@@ -1643,247 +1844,303 @@ var AnthropicMessagesLanguageModel = class {
1643
1844
  };
1644
1845
  }
1645
1846
  };
1646
- var anthropicMessagesResponseSchema = z5.object({
1647
- type: z5.literal("message"),
1648
- id: z5.string().nullish(),
1649
- model: z5.string().nullish(),
1650
- content: z5.array(
1651
- z5.discriminatedUnion("type", [
1652
- z5.object({
1653
- type: z5.literal("text"),
1654
- text: z5.string(),
1655
- citations: z5.array(citationSchema).optional()
1847
+ var anthropicMessagesResponseSchema = z7.object({
1848
+ type: z7.literal("message"),
1849
+ id: z7.string().nullish(),
1850
+ model: z7.string().nullish(),
1851
+ content: z7.array(
1852
+ z7.discriminatedUnion("type", [
1853
+ z7.object({
1854
+ type: z7.literal("text"),
1855
+ text: z7.string(),
1856
+ citations: z7.array(citationSchema).optional()
1656
1857
  }),
1657
- z5.object({
1658
- type: z5.literal("thinking"),
1659
- thinking: z5.string(),
1660
- signature: z5.string()
1858
+ z7.object({
1859
+ type: z7.literal("thinking"),
1860
+ thinking: z7.string(),
1861
+ signature: z7.string()
1661
1862
  }),
1662
- z5.object({
1663
- type: z5.literal("redacted_thinking"),
1664
- data: z5.string()
1863
+ z7.object({
1864
+ type: z7.literal("redacted_thinking"),
1865
+ data: z7.string()
1665
1866
  }),
1666
- z5.object({
1667
- type: z5.literal("tool_use"),
1668
- id: z5.string(),
1669
- name: z5.string(),
1670
- input: z5.unknown()
1867
+ z7.object({
1868
+ type: z7.literal("tool_use"),
1869
+ id: z7.string(),
1870
+ name: z7.string(),
1871
+ input: z7.unknown()
1671
1872
  }),
1672
- z5.object({
1673
- type: z5.literal("server_tool_use"),
1674
- id: z5.string(),
1675
- name: z5.string(),
1676
- input: z5.record(z5.string(), z5.unknown()).nullish()
1873
+ z7.object({
1874
+ type: z7.literal("server_tool_use"),
1875
+ id: z7.string(),
1876
+ name: z7.string(),
1877
+ input: z7.record(z7.string(), z7.unknown()).nullish()
1677
1878
  }),
1678
- z5.object({
1679
- type: z5.literal("web_search_tool_result"),
1680
- tool_use_id: z5.string(),
1681
- content: z5.union([
1682
- z5.array(
1683
- z5.object({
1684
- type: z5.literal("web_search_result"),
1685
- url: z5.string(),
1686
- title: z5.string(),
1687
- encrypted_content: z5.string(),
1688
- page_age: z5.string().nullish()
1879
+ z7.object({
1880
+ type: z7.literal("web_fetch_tool_result"),
1881
+ tool_use_id: z7.string(),
1882
+ content: z7.union([
1883
+ z7.object({
1884
+ type: z7.literal("web_fetch_result"),
1885
+ url: z7.string(),
1886
+ retrieved_at: z7.string(),
1887
+ content: z7.object({
1888
+ type: z7.literal("document"),
1889
+ title: z7.string().nullable(),
1890
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1891
+ source: z7.object({
1892
+ type: z7.literal("text"),
1893
+ media_type: z7.string(),
1894
+ data: z7.string()
1895
+ })
1896
+ })
1897
+ }),
1898
+ z7.object({
1899
+ type: z7.literal("web_fetch_tool_result_error"),
1900
+ error_code: z7.string()
1901
+ })
1902
+ ])
1903
+ }),
1904
+ z7.object({
1905
+ type: z7.literal("web_search_tool_result"),
1906
+ tool_use_id: z7.string(),
1907
+ content: z7.union([
1908
+ z7.array(
1909
+ z7.object({
1910
+ type: z7.literal("web_search_result"),
1911
+ url: z7.string(),
1912
+ title: z7.string(),
1913
+ encrypted_content: z7.string(),
1914
+ page_age: z7.string().nullish()
1689
1915
  })
1690
1916
  ),
1691
- z5.object({
1692
- type: z5.literal("web_search_tool_result_error"),
1693
- error_code: z5.string()
1917
+ z7.object({
1918
+ type: z7.literal("web_search_tool_result_error"),
1919
+ error_code: z7.string()
1694
1920
  })
1695
1921
  ])
1696
1922
  }),
1697
- z5.object({
1698
- type: z5.literal("code_execution_tool_result"),
1699
- tool_use_id: z5.string(),
1700
- content: z5.union([
1701
- z5.object({
1702
- type: z5.literal("code_execution_result"),
1703
- stdout: z5.string(),
1704
- stderr: z5.string(),
1705
- return_code: z5.number()
1923
+ z7.object({
1924
+ type: z7.literal("code_execution_tool_result"),
1925
+ tool_use_id: z7.string(),
1926
+ content: z7.union([
1927
+ z7.object({
1928
+ type: z7.literal("code_execution_result"),
1929
+ stdout: z7.string(),
1930
+ stderr: z7.string(),
1931
+ return_code: z7.number()
1706
1932
  }),
1707
- z5.object({
1708
- type: z5.literal("code_execution_tool_result_error"),
1709
- error_code: z5.string()
1933
+ z7.object({
1934
+ type: z7.literal("code_execution_tool_result_error"),
1935
+ error_code: z7.string()
1710
1936
  })
1711
1937
  ])
1712
1938
  })
1713
1939
  ])
1714
1940
  ),
1715
- stop_reason: z5.string().nullish(),
1716
- usage: z5.looseObject({
1717
- input_tokens: z5.number(),
1718
- output_tokens: z5.number(),
1719
- cache_creation_input_tokens: z5.number().nullish(),
1720
- cache_read_input_tokens: z5.number().nullish()
1941
+ stop_reason: z7.string().nullish(),
1942
+ stop_sequence: z7.string().nullish(),
1943
+ usage: z7.looseObject({
1944
+ input_tokens: z7.number(),
1945
+ output_tokens: z7.number(),
1946
+ cache_creation_input_tokens: z7.number().nullish(),
1947
+ cache_read_input_tokens: z7.number().nullish()
1721
1948
  })
1722
1949
  });
1723
- var anthropicMessagesChunkSchema = z5.discriminatedUnion("type", [
1724
- z5.object({
1725
- type: z5.literal("message_start"),
1726
- message: z5.object({
1727
- id: z5.string().nullish(),
1728
- model: z5.string().nullish(),
1729
- usage: z5.looseObject({
1730
- input_tokens: z5.number(),
1731
- output_tokens: z5.number(),
1732
- cache_creation_input_tokens: z5.number().nullish(),
1733
- cache_read_input_tokens: z5.number().nullish()
1950
+ var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
1951
+ z7.object({
1952
+ type: z7.literal("message_start"),
1953
+ message: z7.object({
1954
+ id: z7.string().nullish(),
1955
+ model: z7.string().nullish(),
1956
+ usage: z7.looseObject({
1957
+ input_tokens: z7.number(),
1958
+ cache_creation_input_tokens: z7.number().nullish(),
1959
+ cache_read_input_tokens: z7.number().nullish()
1734
1960
  })
1735
1961
  })
1736
1962
  }),
1737
- z5.object({
1738
- type: z5.literal("content_block_start"),
1739
- index: z5.number(),
1740
- content_block: z5.discriminatedUnion("type", [
1741
- z5.object({
1742
- type: z5.literal("text"),
1743
- text: z5.string()
1963
+ z7.object({
1964
+ type: z7.literal("content_block_start"),
1965
+ index: z7.number(),
1966
+ content_block: z7.discriminatedUnion("type", [
1967
+ z7.object({
1968
+ type: z7.literal("text"),
1969
+ text: z7.string()
1744
1970
  }),
1745
- z5.object({
1746
- type: z5.literal("thinking"),
1747
- thinking: z5.string()
1971
+ z7.object({
1972
+ type: z7.literal("thinking"),
1973
+ thinking: z7.string()
1748
1974
  }),
1749
- z5.object({
1750
- type: z5.literal("tool_use"),
1751
- id: z5.string(),
1752
- name: z5.string()
1975
+ z7.object({
1976
+ type: z7.literal("tool_use"),
1977
+ id: z7.string(),
1978
+ name: z7.string()
1753
1979
  }),
1754
- z5.object({
1755
- type: z5.literal("redacted_thinking"),
1756
- data: z5.string()
1980
+ z7.object({
1981
+ type: z7.literal("redacted_thinking"),
1982
+ data: z7.string()
1757
1983
  }),
1758
- z5.object({
1759
- type: z5.literal("server_tool_use"),
1760
- id: z5.string(),
1761
- name: z5.string(),
1762
- input: z5.record(z5.string(), z5.unknown()).nullish()
1984
+ z7.object({
1985
+ type: z7.literal("server_tool_use"),
1986
+ id: z7.string(),
1987
+ name: z7.string(),
1988
+ input: z7.record(z7.string(), z7.unknown()).nullish()
1763
1989
  }),
1764
- z5.object({
1765
- type: z5.literal("web_search_tool_result"),
1766
- tool_use_id: z5.string(),
1767
- content: z5.union([
1768
- z5.array(
1769
- z5.object({
1770
- type: z5.literal("web_search_result"),
1771
- url: z5.string(),
1772
- title: z5.string(),
1773
- encrypted_content: z5.string(),
1774
- page_age: z5.string().nullish()
1990
+ z7.object({
1991
+ type: z7.literal("web_fetch_tool_result"),
1992
+ tool_use_id: z7.string(),
1993
+ content: z7.union([
1994
+ z7.object({
1995
+ type: z7.literal("web_fetch_result"),
1996
+ url: z7.string(),
1997
+ retrieved_at: z7.string(),
1998
+ content: z7.object({
1999
+ type: z7.literal("document"),
2000
+ title: z7.string().nullable(),
2001
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
2002
+ source: z7.object({
2003
+ type: z7.literal("text"),
2004
+ media_type: z7.string(),
2005
+ data: z7.string()
2006
+ })
2007
+ })
2008
+ }),
2009
+ z7.object({
2010
+ type: z7.literal("web_fetch_tool_result_error"),
2011
+ error_code: z7.string()
2012
+ })
2013
+ ])
2014
+ }),
2015
+ z7.object({
2016
+ type: z7.literal("web_search_tool_result"),
2017
+ tool_use_id: z7.string(),
2018
+ content: z7.union([
2019
+ z7.array(
2020
+ z7.object({
2021
+ type: z7.literal("web_search_result"),
2022
+ url: z7.string(),
2023
+ title: z7.string(),
2024
+ encrypted_content: z7.string(),
2025
+ page_age: z7.string().nullish()
1775
2026
  })
1776
2027
  ),
1777
- z5.object({
1778
- type: z5.literal("web_search_tool_result_error"),
1779
- error_code: z5.string()
2028
+ z7.object({
2029
+ type: z7.literal("web_search_tool_result_error"),
2030
+ error_code: z7.string()
1780
2031
  })
1781
2032
  ])
1782
2033
  }),
1783
- z5.object({
1784
- type: z5.literal("code_execution_tool_result"),
1785
- tool_use_id: z5.string(),
1786
- content: z5.union([
1787
- z5.object({
1788
- type: z5.literal("code_execution_result"),
1789
- stdout: z5.string(),
1790
- stderr: z5.string(),
1791
- return_code: z5.number()
2034
+ z7.object({
2035
+ type: z7.literal("code_execution_tool_result"),
2036
+ tool_use_id: z7.string(),
2037
+ content: z7.union([
2038
+ z7.object({
2039
+ type: z7.literal("code_execution_result"),
2040
+ stdout: z7.string(),
2041
+ stderr: z7.string(),
2042
+ return_code: z7.number()
1792
2043
  }),
1793
- z5.object({
1794
- type: z5.literal("code_execution_tool_result_error"),
1795
- error_code: z5.string()
2044
+ z7.object({
2045
+ type: z7.literal("code_execution_tool_result_error"),
2046
+ error_code: z7.string()
1796
2047
  })
1797
2048
  ])
1798
2049
  })
1799
2050
  ])
1800
2051
  }),
1801
- z5.object({
1802
- type: z5.literal("content_block_delta"),
1803
- index: z5.number(),
1804
- delta: z5.discriminatedUnion("type", [
1805
- z5.object({
1806
- type: z5.literal("input_json_delta"),
1807
- partial_json: z5.string()
2052
+ z7.object({
2053
+ type: z7.literal("content_block_delta"),
2054
+ index: z7.number(),
2055
+ delta: z7.discriminatedUnion("type", [
2056
+ z7.object({
2057
+ type: z7.literal("input_json_delta"),
2058
+ partial_json: z7.string()
1808
2059
  }),
1809
- z5.object({
1810
- type: z5.literal("text_delta"),
1811
- text: z5.string()
2060
+ z7.object({
2061
+ type: z7.literal("text_delta"),
2062
+ text: z7.string()
1812
2063
  }),
1813
- z5.object({
1814
- type: z5.literal("thinking_delta"),
1815
- thinking: z5.string()
2064
+ z7.object({
2065
+ type: z7.literal("thinking_delta"),
2066
+ thinking: z7.string()
1816
2067
  }),
1817
- z5.object({
1818
- type: z5.literal("signature_delta"),
1819
- signature: z5.string()
2068
+ z7.object({
2069
+ type: z7.literal("signature_delta"),
2070
+ signature: z7.string()
1820
2071
  }),
1821
- z5.object({
1822
- type: z5.literal("citations_delta"),
2072
+ z7.object({
2073
+ type: z7.literal("citations_delta"),
1823
2074
  citation: citationSchema
1824
2075
  })
1825
2076
  ])
1826
2077
  }),
1827
- z5.object({
1828
- type: z5.literal("content_block_stop"),
1829
- index: z5.number()
2078
+ z7.object({
2079
+ type: z7.literal("content_block_stop"),
2080
+ index: z7.number()
1830
2081
  }),
1831
- z5.object({
1832
- type: z5.literal("error"),
1833
- error: z5.object({
1834
- type: z5.string(),
1835
- message: z5.string()
2082
+ z7.object({
2083
+ type: z7.literal("error"),
2084
+ error: z7.object({
2085
+ type: z7.string(),
2086
+ message: z7.string()
1836
2087
  })
1837
2088
  }),
1838
- z5.object({
1839
- type: z5.literal("message_delta"),
1840
- delta: z5.object({ stop_reason: z5.string().nullish() }),
1841
- usage: z5.object({ output_tokens: z5.number() })
2089
+ z7.object({
2090
+ type: z7.literal("message_delta"),
2091
+ delta: z7.object({
2092
+ stop_reason: z7.string().nullish(),
2093
+ stop_sequence: z7.string().nullish()
2094
+ }),
2095
+ usage: z7.looseObject({
2096
+ output_tokens: z7.number(),
2097
+ cache_creation_input_tokens: z7.number().nullish()
2098
+ })
1842
2099
  }),
1843
- z5.object({
1844
- type: z5.literal("message_stop")
2100
+ z7.object({
2101
+ type: z7.literal("message_stop")
1845
2102
  }),
1846
- z5.object({
1847
- type: z5.literal("ping")
2103
+ z7.object({
2104
+ type: z7.literal("ping")
1848
2105
  })
1849
2106
  ]);
1850
- var anthropicReasoningMetadataSchema = z5.object({
1851
- signature: z5.string().optional(),
1852
- redactedData: z5.string().optional()
2107
+ var anthropicReasoningMetadataSchema = z7.object({
2108
+ signature: z7.string().optional(),
2109
+ redactedData: z7.string().optional()
1853
2110
  });
1854
2111
 
1855
2112
  // src/tool/bash_20241022.ts
1856
- import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
1857
- import z6 from "zod/v4";
1858
- var bash_20241022 = createProviderDefinedToolFactory({
2113
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
2114
+ import z8 from "zod/v4";
2115
+ var bash_20241022 = createProviderDefinedToolFactory2({
1859
2116
  id: "anthropic.bash_20241022",
1860
2117
  name: "bash",
1861
- inputSchema: z6.object({
1862
- command: z6.string(),
1863
- restart: z6.boolean().optional()
2118
+ inputSchema: z8.object({
2119
+ command: z8.string(),
2120
+ restart: z8.boolean().optional()
1864
2121
  })
1865
2122
  });
1866
2123
 
1867
2124
  // src/tool/bash_20250124.ts
1868
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
1869
- import z7 from "zod/v4";
1870
- var bash_20250124 = createProviderDefinedToolFactory2({
2125
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
2126
+ import z9 from "zod/v4";
2127
+ var bash_20250124 = createProviderDefinedToolFactory3({
1871
2128
  id: "anthropic.bash_20250124",
1872
2129
  name: "bash",
1873
- inputSchema: z7.object({
1874
- command: z7.string(),
1875
- restart: z7.boolean().optional()
2130
+ inputSchema: z9.object({
2131
+ command: z9.string(),
2132
+ restart: z9.boolean().optional()
1876
2133
  })
1877
2134
  });
1878
2135
 
1879
2136
  // src/tool/computer_20241022.ts
1880
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
1881
- import { z as z8 } from "zod/v4";
1882
- var computer_20241022 = createProviderDefinedToolFactory3({
2137
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
2138
+ import { z as z10 } from "zod/v4";
2139
+ var computer_20241022 = createProviderDefinedToolFactory4({
1883
2140
  id: "anthropic.computer_20241022",
1884
2141
  name: "computer",
1885
- inputSchema: z8.object({
1886
- action: z8.enum([
2142
+ inputSchema: z10.object({
2143
+ action: z10.enum([
1887
2144
  "key",
1888
2145
  "type",
1889
2146
  "mouse_move",
@@ -1895,19 +2152,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
1895
2152
  "screenshot",
1896
2153
  "cursor_position"
1897
2154
  ]),
1898
- coordinate: z8.array(z8.number().int()).optional(),
1899
- text: z8.string().optional()
2155
+ coordinate: z10.array(z10.number().int()).optional(),
2156
+ text: z10.string().optional()
1900
2157
  })
1901
2158
  });
1902
2159
 
1903
2160
  // src/tool/computer_20250124.ts
1904
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
1905
- import { z as z9 } from "zod/v4";
1906
- var computer_20250124 = createProviderDefinedToolFactory4({
2161
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
2162
+ import { z as z11 } from "zod/v4";
2163
+ var computer_20250124 = createProviderDefinedToolFactory5({
1907
2164
  id: "anthropic.computer_20250124",
1908
2165
  name: "computer",
1909
- inputSchema: z9.object({
1910
- action: z9.enum([
2166
+ inputSchema: z11.object({
2167
+ action: z11.enum([
1911
2168
  "key",
1912
2169
  "hold_key",
1913
2170
  "type",
@@ -1925,63 +2182,63 @@ var computer_20250124 = createProviderDefinedToolFactory4({
1925
2182
  "wait",
1926
2183
  "screenshot"
1927
2184
  ]),
1928
- coordinate: z9.tuple([z9.number().int(), z9.number().int()]).optional(),
1929
- duration: z9.number().optional(),
1930
- scroll_amount: z9.number().optional(),
1931
- scroll_direction: z9.enum(["up", "down", "left", "right"]).optional(),
1932
- start_coordinate: z9.tuple([z9.number().int(), z9.number().int()]).optional(),
1933
- text: z9.string().optional()
2185
+ coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2186
+ duration: z11.number().optional(),
2187
+ scroll_amount: z11.number().optional(),
2188
+ scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
2189
+ start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2190
+ text: z11.string().optional()
1934
2191
  })
1935
2192
  });
1936
2193
 
1937
2194
  // src/tool/text-editor_20241022.ts
1938
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
1939
- import { z as z10 } from "zod/v4";
1940
- var textEditor_20241022 = createProviderDefinedToolFactory5({
2195
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
2196
+ import { z as z12 } from "zod/v4";
2197
+ var textEditor_20241022 = createProviderDefinedToolFactory6({
1941
2198
  id: "anthropic.text_editor_20241022",
1942
2199
  name: "str_replace_editor",
1943
- inputSchema: z10.object({
1944
- command: z10.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1945
- path: z10.string(),
1946
- file_text: z10.string().optional(),
1947
- insert_line: z10.number().int().optional(),
1948
- new_str: z10.string().optional(),
1949
- old_str: z10.string().optional(),
1950
- view_range: z10.array(z10.number().int()).optional()
2200
+ inputSchema: z12.object({
2201
+ command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2202
+ path: z12.string(),
2203
+ file_text: z12.string().optional(),
2204
+ insert_line: z12.number().int().optional(),
2205
+ new_str: z12.string().optional(),
2206
+ old_str: z12.string().optional(),
2207
+ view_range: z12.array(z12.number().int()).optional()
1951
2208
  })
1952
2209
  });
1953
2210
 
1954
2211
  // src/tool/text-editor_20250124.ts
1955
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
1956
- import { z as z11 } from "zod/v4";
1957
- var textEditor_20250124 = createProviderDefinedToolFactory6({
2212
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
2213
+ import { z as z13 } from "zod/v4";
2214
+ var textEditor_20250124 = createProviderDefinedToolFactory7({
1958
2215
  id: "anthropic.text_editor_20250124",
1959
2216
  name: "str_replace_editor",
1960
- inputSchema: z11.object({
1961
- command: z11.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1962
- path: z11.string(),
1963
- file_text: z11.string().optional(),
1964
- insert_line: z11.number().int().optional(),
1965
- new_str: z11.string().optional(),
1966
- old_str: z11.string().optional(),
1967
- view_range: z11.array(z11.number().int()).optional()
2217
+ inputSchema: z13.object({
2218
+ command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2219
+ path: z13.string(),
2220
+ file_text: z13.string().optional(),
2221
+ insert_line: z13.number().int().optional(),
2222
+ new_str: z13.string().optional(),
2223
+ old_str: z13.string().optional(),
2224
+ view_range: z13.array(z13.number().int()).optional()
1968
2225
  })
1969
2226
  });
1970
2227
 
1971
2228
  // src/tool/text-editor_20250429.ts
1972
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
1973
- import { z as z12 } from "zod/v4";
1974
- var textEditor_20250429 = createProviderDefinedToolFactory7({
2229
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
2230
+ import { z as z14 } from "zod/v4";
2231
+ var textEditor_20250429 = createProviderDefinedToolFactory8({
1975
2232
  id: "anthropic.text_editor_20250429",
1976
2233
  name: "str_replace_based_edit_tool",
1977
- inputSchema: z12.object({
1978
- command: z12.enum(["view", "create", "str_replace", "insert"]),
1979
- path: z12.string(),
1980
- file_text: z12.string().optional(),
1981
- insert_line: z12.number().int().optional(),
1982
- new_str: z12.string().optional(),
1983
- old_str: z12.string().optional(),
1984
- view_range: z12.array(z12.number().int()).optional()
2234
+ inputSchema: z14.object({
2235
+ command: z14.enum(["view", "create", "str_replace", "insert"]),
2236
+ path: z14.string(),
2237
+ file_text: z14.string().optional(),
2238
+ insert_line: z14.number().int().optional(),
2239
+ new_str: z14.string().optional(),
2240
+ old_str: z14.string().optional(),
2241
+ view_range: z14.array(z14.number().int()).optional()
1985
2242
  })
1986
2243
  });
1987
2244
 
@@ -2047,6 +2304,8 @@ var anthropicTools = {
2047
2304
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2048
2305
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2049
2306
  *
2307
+ * Supported models: Claude Sonnet 3.5
2308
+ *
2050
2309
  * Tool name must be `str_replace_editor`.
2051
2310
  */
2052
2311
  textEditor_20241022,
@@ -2055,6 +2314,8 @@ var anthropicTools = {
2055
2314
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2056
2315
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2057
2316
  *
2317
+ * Supported models: Claude Sonnet 3.7
2318
+ *
2058
2319
  * Tool name must be `str_replace_editor`.
2059
2320
  */
2060
2321
  textEditor_20250124,
@@ -2066,8 +2327,36 @@ var anthropicTools = {
2066
2327
  * Note: This version does not support the "undo_edit" command.
2067
2328
  *
2068
2329
  * Tool name must be `str_replace_based_edit_tool`.
2330
+ *
2331
+ * @deprecated Use textEditor_20250728 instead
2069
2332
  */
2070
2333
  textEditor_20250429,
2334
+ /**
2335
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2336
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2337
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2338
+ *
2339
+ * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
2340
+ *
2341
+ * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
2342
+ *
2343
+ * Tool name must be `str_replace_based_edit_tool`.
2344
+ *
2345
+ * @param maxCharacters - Optional maximum number of characters to view in the file
2346
+ */
2347
+ textEditor_20250728,
2348
+ /**
2349
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
2350
+ *
2351
+ * Tool name must be `web_fetch`.
2352
+ *
2353
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
2354
+ * @param allowedDomains - Only fetch from these domains
2355
+ * @param blockedDomains - Never fetch from these domains
2356
+ * @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.
2357
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
2358
+ */
2359
+ webFetch_20250910,
2071
2360
  /**
2072
2361
  * Creates a web search tool that gives Claude direct access to real-time web content.
2073
2362
  *
@@ -2085,15 +2374,18 @@ var anthropicTools = {
2085
2374
  function createAnthropic(options = {}) {
2086
2375
  var _a;
2087
2376
  const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2088
- const getHeaders = () => ({
2089
- "anthropic-version": "2023-06-01",
2090
- "x-api-key": loadApiKey({
2091
- apiKey: options.apiKey,
2092
- environmentVariableName: "ANTHROPIC_API_KEY",
2093
- description: "Anthropic"
2094
- }),
2095
- ...options.headers
2096
- });
2377
+ const getHeaders = () => withUserAgentSuffix(
2378
+ {
2379
+ "anthropic-version": "2023-06-01",
2380
+ "x-api-key": loadApiKey({
2381
+ apiKey: options.apiKey,
2382
+ environmentVariableName: "ANTHROPIC_API_KEY",
2383
+ description: "Anthropic"
2384
+ }),
2385
+ ...options.headers
2386
+ },
2387
+ `ai-sdk/anthropic/${VERSION}`
2388
+ );
2097
2389
  const createChatModel = (modelId) => {
2098
2390
  var _a2;
2099
2391
  return new AnthropicMessagesLanguageModel(modelId, {
@@ -2129,6 +2421,7 @@ function createAnthropic(options = {}) {
2129
2421
  }
2130
2422
  var anthropic = createAnthropic();
2131
2423
  export {
2424
+ VERSION,
2132
2425
  anthropic,
2133
2426
  createAnthropic
2134
2427
  };