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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.10" : "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
@@ -632,30 +718,20 @@ async function convertToAnthropicMessagesPrompt({
632
718
  }
633
719
  case "tool-call": {
634
720
  if (part.providerExecuted) {
635
- if (part.toolName === "web_search") {
721
+ if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
636
722
  anthropicContent.push({
637
723
  type: "server_tool_use",
638
724
  id: part.toolCallId,
639
- name: "web_search",
725
+ name: part.toolName,
640
726
  input: part.input,
641
727
  cache_control: cacheControl
642
728
  });
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
729
+ } else {
730
+ warnings.push({
731
+ type: "other",
732
+ message: `provider executed tool call for tool ${part.toolName} is not supported`
652
733
  });
653
- break;
654
734
  }
655
- warnings.push({
656
- type: "other",
657
- message: `provider executed tool call for tool ${part.toolName} is not supported`
658
- });
659
735
  break;
660
736
  }
661
737
  anthropicContent.push({
@@ -668,7 +744,7 @@ async function convertToAnthropicMessagesPrompt({
668
744
  break;
669
745
  }
670
746
  case "tool-result": {
671
- if (part.toolName === "web_search") {
747
+ if (part.toolName === "code_execution") {
672
748
  const output = part.output;
673
749
  if (output.type !== "json") {
674
750
  warnings.push({
@@ -677,24 +753,21 @@ async function convertToAnthropicMessagesPrompt({
677
753
  });
678
754
  break;
679
755
  }
680
- const webSearchOutput = webSearch_20250305OutputSchema.parse(
681
- output.value
682
- );
756
+ const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
683
757
  anthropicContent.push({
684
- type: "web_search_tool_result",
758
+ type: "code_execution_tool_result",
685
759
  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
- })),
760
+ content: {
761
+ type: codeExecutionOutput.type,
762
+ stdout: codeExecutionOutput.stdout,
763
+ stderr: codeExecutionOutput.stderr,
764
+ return_code: codeExecutionOutput.return_code
765
+ },
693
766
  cache_control: cacheControl
694
767
  });
695
768
  break;
696
769
  }
697
- if (part.toolName === "code_execution") {
770
+ if (part.toolName === "web_fetch") {
698
771
  const output = part.output;
699
772
  if (output.type !== "json") {
700
773
  warnings.push({
@@ -703,20 +776,57 @@ async function convertToAnthropicMessagesPrompt({
703
776
  });
704
777
  break;
705
778
  }
706
- const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
779
+ const webFetchOutput = webFetch_20250910OutputSchema.parse(
780
+ output.value
781
+ );
707
782
  anthropicContent.push({
708
- type: "code_execution_tool_result",
783
+ type: "web_fetch_tool_result",
709
784
  tool_use_id: part.toolCallId,
710
785
  content: {
711
- type: codeExecutionOutput.type,
712
- stdout: codeExecutionOutput.stdout,
713
- stderr: codeExecutionOutput.stderr,
714
- return_code: codeExecutionOutput.return_code
786
+ type: "web_fetch_result",
787
+ url: webFetchOutput.url,
788
+ retrieved_at: webFetchOutput.retrievedAt,
789
+ content: {
790
+ type: "document",
791
+ title: webFetchOutput.content.title,
792
+ citations: webFetchOutput.content.citations,
793
+ source: {
794
+ type: webFetchOutput.content.source.type,
795
+ media_type: webFetchOutput.content.source.mediaType,
796
+ data: webFetchOutput.content.source.data
797
+ }
798
+ }
715
799
  },
716
800
  cache_control: cacheControl
717
801
  });
718
802
  break;
719
803
  }
804
+ if (part.toolName === "web_search") {
805
+ const output = part.output;
806
+ if (output.type !== "json") {
807
+ warnings.push({
808
+ type: "other",
809
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
810
+ });
811
+ break;
812
+ }
813
+ const webSearchOutput = webSearch_20250305OutputSchema.parse(
814
+ output.value
815
+ );
816
+ anthropicContent.push({
817
+ type: "web_search_tool_result",
818
+ tool_use_id: part.toolCallId,
819
+ content: webSearchOutput.map((result) => ({
820
+ url: result.url,
821
+ title: result.title,
822
+ page_age: result.pageAge,
823
+ encrypted_content: result.encryptedContent,
824
+ type: result.type
825
+ })),
826
+ cache_control: cacheControl
827
+ });
828
+ break;
829
+ }
720
830
  warnings.push({
721
831
  type: "other",
722
832
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -810,36 +920,36 @@ function mapAnthropicStopReason({
810
920
 
811
921
  // src/anthropic-messages-language-model.ts
812
922
  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()
923
+ webSearchResult: z7.object({
924
+ type: z7.literal("web_search_result_location"),
925
+ cited_text: z7.string(),
926
+ url: z7.string(),
927
+ title: z7.string(),
928
+ encrypted_index: z7.string()
819
929
  }),
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()
930
+ pageLocation: z7.object({
931
+ type: z7.literal("page_location"),
932
+ cited_text: z7.string(),
933
+ document_index: z7.number(),
934
+ document_title: z7.string().nullable(),
935
+ start_page_number: z7.number(),
936
+ end_page_number: z7.number()
827
937
  }),
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()
938
+ charLocation: z7.object({
939
+ type: z7.literal("char_location"),
940
+ cited_text: z7.string(),
941
+ document_index: z7.number(),
942
+ document_title: z7.string().nullable(),
943
+ start_char_index: z7.number(),
944
+ end_char_index: z7.number()
835
945
  })
836
946
  };
837
- var citationSchema = z5.discriminatedUnion("type", [
947
+ var citationSchema = z7.discriminatedUnion("type", [
838
948
  citationSchemas.webSearchResult,
839
949
  citationSchemas.pageLocation,
840
950
  citationSchemas.charLocation
841
951
  ]);
842
- var documentCitationSchema = z5.discriminatedUnion("type", [
952
+ var documentCitationSchema = z7.discriminatedUnion("type", [
843
953
  citationSchemas.pageLocation,
844
954
  citationSchemas.charLocation
845
955
  ]);
@@ -884,7 +994,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
884
994
  }
885
995
  var AnthropicMessagesLanguageModel = class {
886
996
  constructor(modelId, config) {
887
- this.specificationVersion = "v2";
997
+ this.specificationVersion = "v3";
888
998
  var _a;
889
999
  this.modelId = modelId;
890
1000
  this.config = config;
@@ -1087,7 +1197,7 @@ var AnthropicMessagesLanguageModel = class {
1087
1197
  });
1088
1198
  }
1089
1199
  async doGenerate(options) {
1090
- var _a, _b, _c, _d, _e;
1200
+ var _a, _b, _c, _d, _e, _f;
1091
1201
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1092
1202
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1093
1203
  const {
@@ -1164,7 +1274,7 @@ var AnthropicMessagesLanguageModel = class {
1164
1274
  break;
1165
1275
  }
1166
1276
  case "server_tool_use": {
1167
- if (part.name === "web_search" || part.name === "code_execution") {
1277
+ if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1168
1278
  content.push({
1169
1279
  type: "tool-call",
1170
1280
  toolCallId: part.id,
@@ -1175,6 +1285,44 @@ var AnthropicMessagesLanguageModel = class {
1175
1285
  }
1176
1286
  break;
1177
1287
  }
1288
+ case "web_fetch_tool_result": {
1289
+ if (part.content.type === "web_fetch_result") {
1290
+ content.push({
1291
+ type: "tool-result",
1292
+ toolCallId: part.tool_use_id,
1293
+ toolName: "web_fetch",
1294
+ result: {
1295
+ type: "web_fetch_result",
1296
+ url: part.content.url,
1297
+ retrievedAt: part.content.retrieved_at,
1298
+ content: {
1299
+ type: part.content.content.type,
1300
+ title: part.content.content.title,
1301
+ citations: part.content.content.citations,
1302
+ source: {
1303
+ type: part.content.content.source.type,
1304
+ mediaType: part.content.content.source.media_type,
1305
+ data: part.content.content.source.data
1306
+ }
1307
+ }
1308
+ },
1309
+ providerExecuted: true
1310
+ });
1311
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1312
+ content.push({
1313
+ type: "tool-result",
1314
+ toolCallId: part.tool_use_id,
1315
+ toolName: "web_fetch",
1316
+ isError: true,
1317
+ result: {
1318
+ type: "web_fetch_tool_result_error",
1319
+ errorCode: part.content.error_code
1320
+ },
1321
+ providerExecuted: true
1322
+ });
1323
+ }
1324
+ break;
1325
+ }
1178
1326
  case "web_search_tool_result": {
1179
1327
  if (Array.isArray(part.content)) {
1180
1328
  content.push({
@@ -1276,7 +1424,8 @@ var AnthropicMessagesLanguageModel = class {
1276
1424
  providerMetadata: {
1277
1425
  anthropic: {
1278
1426
  usage: response.usage,
1279
- cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1427
+ cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
1428
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null
1280
1429
  }
1281
1430
  }
1282
1431
  };
@@ -1303,7 +1452,9 @@ var AnthropicMessagesLanguageModel = class {
1303
1452
  totalTokens: void 0
1304
1453
  };
1305
1454
  const contentBlocks = {};
1306
- let providerMetadata = void 0;
1455
+ let rawUsage = void 0;
1456
+ let cacheCreationInputTokens = null;
1457
+ let stopSequence = null;
1307
1458
  let blockType = void 0;
1308
1459
  const generateId3 = this.generateId;
1309
1460
  return {
@@ -1313,7 +1464,7 @@ var AnthropicMessagesLanguageModel = class {
1313
1464
  controller.enqueue({ type: "stream-start", warnings });
1314
1465
  },
1315
1466
  transform(chunk, controller) {
1316
- var _a, _b, _c, _d, _e, _f, _g;
1467
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1317
1468
  if (options.includeRawChunks) {
1318
1469
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1319
1470
  }
@@ -1376,7 +1527,7 @@ var AnthropicMessagesLanguageModel = class {
1376
1527
  return;
1377
1528
  }
1378
1529
  case "server_tool_use": {
1379
- if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1530
+ if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1380
1531
  contentBlocks[value.index] = {
1381
1532
  type: "tool-call",
1382
1533
  toolCallId: value.content_block.id,
@@ -1393,6 +1544,44 @@ var AnthropicMessagesLanguageModel = class {
1393
1544
  }
1394
1545
  return;
1395
1546
  }
1547
+ case "web_fetch_tool_result": {
1548
+ const part = value.content_block;
1549
+ if (part.content.type === "web_fetch_result") {
1550
+ controller.enqueue({
1551
+ type: "tool-result",
1552
+ toolCallId: part.tool_use_id,
1553
+ toolName: "web_fetch",
1554
+ result: {
1555
+ type: "web_fetch_result",
1556
+ url: part.content.url,
1557
+ retrievedAt: part.content.retrieved_at,
1558
+ content: {
1559
+ type: part.content.content.type,
1560
+ title: part.content.content.title,
1561
+ citations: part.content.content.citations,
1562
+ source: {
1563
+ type: part.content.content.source.type,
1564
+ mediaType: part.content.content.source.media_type,
1565
+ data: part.content.content.source.data
1566
+ }
1567
+ }
1568
+ }
1569
+ });
1570
+ } else if (part.content.type === "web_fetch_tool_result_error") {
1571
+ controller.enqueue({
1572
+ type: "tool-result",
1573
+ toolCallId: part.tool_use_id,
1574
+ toolName: "web_fetch",
1575
+ isError: true,
1576
+ result: {
1577
+ type: "web_fetch_tool_result_error",
1578
+ errorCode: part.content.error_code
1579
+ },
1580
+ providerExecuted: true
1581
+ });
1582
+ }
1583
+ return;
1584
+ }
1396
1585
  case "web_search_tool_result": {
1397
1586
  const part = value.content_block;
1398
1587
  if (Array.isArray(part.content)) {
@@ -1595,12 +1784,10 @@ var AnthropicMessagesLanguageModel = class {
1595
1784
  case "message_start": {
1596
1785
  usage.inputTokens = value.message.usage.input_tokens;
1597
1786
  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
- }
1787
+ rawUsage = {
1788
+ ...value.message.usage
1603
1789
  };
1790
+ cacheCreationInputTokens = (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null;
1604
1791
  controller.enqueue({
1605
1792
  type: "response-metadata",
1606
1793
  id: (_d = value.message.id) != null ? _d : void 0,
@@ -1615,6 +1802,11 @@ var AnthropicMessagesLanguageModel = class {
1615
1802
  finishReason: value.delta.stop_reason,
1616
1803
  isJsonResponseFromTool: usesJsonResponseTool
1617
1804
  });
1805
+ stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
1806
+ rawUsage = {
1807
+ ...rawUsage,
1808
+ ...value.usage
1809
+ };
1618
1810
  return;
1619
1811
  }
1620
1812
  case "message_stop": {
@@ -1622,7 +1814,13 @@ var AnthropicMessagesLanguageModel = class {
1622
1814
  type: "finish",
1623
1815
  finishReason,
1624
1816
  usage,
1625
- providerMetadata
1817
+ providerMetadata: {
1818
+ anthropic: {
1819
+ usage: rawUsage != null ? rawUsage : null,
1820
+ cacheCreationInputTokens,
1821
+ stopSequence
1822
+ }
1823
+ }
1626
1824
  });
1627
1825
  return;
1628
1826
  }
@@ -1643,247 +1841,303 @@ var AnthropicMessagesLanguageModel = class {
1643
1841
  };
1644
1842
  }
1645
1843
  };
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()
1844
+ var anthropicMessagesResponseSchema = z7.object({
1845
+ type: z7.literal("message"),
1846
+ id: z7.string().nullish(),
1847
+ model: z7.string().nullish(),
1848
+ content: z7.array(
1849
+ z7.discriminatedUnion("type", [
1850
+ z7.object({
1851
+ type: z7.literal("text"),
1852
+ text: z7.string(),
1853
+ citations: z7.array(citationSchema).optional()
1656
1854
  }),
1657
- z5.object({
1658
- type: z5.literal("thinking"),
1659
- thinking: z5.string(),
1660
- signature: z5.string()
1855
+ z7.object({
1856
+ type: z7.literal("thinking"),
1857
+ thinking: z7.string(),
1858
+ signature: z7.string()
1661
1859
  }),
1662
- z5.object({
1663
- type: z5.literal("redacted_thinking"),
1664
- data: z5.string()
1860
+ z7.object({
1861
+ type: z7.literal("redacted_thinking"),
1862
+ data: z7.string()
1665
1863
  }),
1666
- z5.object({
1667
- type: z5.literal("tool_use"),
1668
- id: z5.string(),
1669
- name: z5.string(),
1670
- input: z5.unknown()
1864
+ z7.object({
1865
+ type: z7.literal("tool_use"),
1866
+ id: z7.string(),
1867
+ name: z7.string(),
1868
+ input: z7.unknown()
1671
1869
  }),
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()
1870
+ z7.object({
1871
+ type: z7.literal("server_tool_use"),
1872
+ id: z7.string(),
1873
+ name: z7.string(),
1874
+ input: z7.record(z7.string(), z7.unknown()).nullish()
1677
1875
  }),
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()
1876
+ z7.object({
1877
+ type: z7.literal("web_fetch_tool_result"),
1878
+ tool_use_id: z7.string(),
1879
+ content: z7.union([
1880
+ z7.object({
1881
+ type: z7.literal("web_fetch_result"),
1882
+ url: z7.string(),
1883
+ retrieved_at: z7.string(),
1884
+ content: z7.object({
1885
+ type: z7.literal("document"),
1886
+ title: z7.string().nullable(),
1887
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1888
+ source: z7.object({
1889
+ type: z7.literal("text"),
1890
+ media_type: z7.string(),
1891
+ data: z7.string()
1892
+ })
1893
+ })
1894
+ }),
1895
+ z7.object({
1896
+ type: z7.literal("web_fetch_tool_result_error"),
1897
+ error_code: z7.string()
1898
+ })
1899
+ ])
1900
+ }),
1901
+ z7.object({
1902
+ type: z7.literal("web_search_tool_result"),
1903
+ tool_use_id: z7.string(),
1904
+ content: z7.union([
1905
+ z7.array(
1906
+ z7.object({
1907
+ type: z7.literal("web_search_result"),
1908
+ url: z7.string(),
1909
+ title: z7.string(),
1910
+ encrypted_content: z7.string(),
1911
+ page_age: z7.string().nullish()
1689
1912
  })
1690
1913
  ),
1691
- z5.object({
1692
- type: z5.literal("web_search_tool_result_error"),
1693
- error_code: z5.string()
1914
+ z7.object({
1915
+ type: z7.literal("web_search_tool_result_error"),
1916
+ error_code: z7.string()
1694
1917
  })
1695
1918
  ])
1696
1919
  }),
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()
1920
+ z7.object({
1921
+ type: z7.literal("code_execution_tool_result"),
1922
+ tool_use_id: z7.string(),
1923
+ content: z7.union([
1924
+ z7.object({
1925
+ type: z7.literal("code_execution_result"),
1926
+ stdout: z7.string(),
1927
+ stderr: z7.string(),
1928
+ return_code: z7.number()
1706
1929
  }),
1707
- z5.object({
1708
- type: z5.literal("code_execution_tool_result_error"),
1709
- error_code: z5.string()
1930
+ z7.object({
1931
+ type: z7.literal("code_execution_tool_result_error"),
1932
+ error_code: z7.string()
1710
1933
  })
1711
1934
  ])
1712
1935
  })
1713
1936
  ])
1714
1937
  ),
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()
1938
+ stop_reason: z7.string().nullish(),
1939
+ stop_sequence: z7.string().nullish(),
1940
+ usage: z7.looseObject({
1941
+ input_tokens: z7.number(),
1942
+ output_tokens: z7.number(),
1943
+ cache_creation_input_tokens: z7.number().nullish(),
1944
+ cache_read_input_tokens: z7.number().nullish()
1721
1945
  })
1722
1946
  });
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()
1947
+ var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
1948
+ z7.object({
1949
+ type: z7.literal("message_start"),
1950
+ message: z7.object({
1951
+ id: z7.string().nullish(),
1952
+ model: z7.string().nullish(),
1953
+ usage: z7.looseObject({
1954
+ input_tokens: z7.number(),
1955
+ cache_creation_input_tokens: z7.number().nullish(),
1956
+ cache_read_input_tokens: z7.number().nullish()
1734
1957
  })
1735
1958
  })
1736
1959
  }),
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()
1960
+ z7.object({
1961
+ type: z7.literal("content_block_start"),
1962
+ index: z7.number(),
1963
+ content_block: z7.discriminatedUnion("type", [
1964
+ z7.object({
1965
+ type: z7.literal("text"),
1966
+ text: z7.string()
1744
1967
  }),
1745
- z5.object({
1746
- type: z5.literal("thinking"),
1747
- thinking: z5.string()
1968
+ z7.object({
1969
+ type: z7.literal("thinking"),
1970
+ thinking: z7.string()
1748
1971
  }),
1749
- z5.object({
1750
- type: z5.literal("tool_use"),
1751
- id: z5.string(),
1752
- name: z5.string()
1972
+ z7.object({
1973
+ type: z7.literal("tool_use"),
1974
+ id: z7.string(),
1975
+ name: z7.string()
1753
1976
  }),
1754
- z5.object({
1755
- type: z5.literal("redacted_thinking"),
1756
- data: z5.string()
1977
+ z7.object({
1978
+ type: z7.literal("redacted_thinking"),
1979
+ data: z7.string()
1757
1980
  }),
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()
1981
+ z7.object({
1982
+ type: z7.literal("server_tool_use"),
1983
+ id: z7.string(),
1984
+ name: z7.string(),
1985
+ input: z7.record(z7.string(), z7.unknown()).nullish()
1763
1986
  }),
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()
1987
+ z7.object({
1988
+ type: z7.literal("web_fetch_tool_result"),
1989
+ tool_use_id: z7.string(),
1990
+ content: z7.union([
1991
+ z7.object({
1992
+ type: z7.literal("web_fetch_result"),
1993
+ url: z7.string(),
1994
+ retrieved_at: z7.string(),
1995
+ content: z7.object({
1996
+ type: z7.literal("document"),
1997
+ title: z7.string().nullable(),
1998
+ citations: z7.object({ enabled: z7.boolean() }).optional(),
1999
+ source: z7.object({
2000
+ type: z7.literal("text"),
2001
+ media_type: z7.string(),
2002
+ data: z7.string()
2003
+ })
2004
+ })
2005
+ }),
2006
+ z7.object({
2007
+ type: z7.literal("web_fetch_tool_result_error"),
2008
+ error_code: z7.string()
2009
+ })
2010
+ ])
2011
+ }),
2012
+ z7.object({
2013
+ type: z7.literal("web_search_tool_result"),
2014
+ tool_use_id: z7.string(),
2015
+ content: z7.union([
2016
+ z7.array(
2017
+ z7.object({
2018
+ type: z7.literal("web_search_result"),
2019
+ url: z7.string(),
2020
+ title: z7.string(),
2021
+ encrypted_content: z7.string(),
2022
+ page_age: z7.string().nullish()
1775
2023
  })
1776
2024
  ),
1777
- z5.object({
1778
- type: z5.literal("web_search_tool_result_error"),
1779
- error_code: z5.string()
2025
+ z7.object({
2026
+ type: z7.literal("web_search_tool_result_error"),
2027
+ error_code: z7.string()
1780
2028
  })
1781
2029
  ])
1782
2030
  }),
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()
2031
+ z7.object({
2032
+ type: z7.literal("code_execution_tool_result"),
2033
+ tool_use_id: z7.string(),
2034
+ content: z7.union([
2035
+ z7.object({
2036
+ type: z7.literal("code_execution_result"),
2037
+ stdout: z7.string(),
2038
+ stderr: z7.string(),
2039
+ return_code: z7.number()
1792
2040
  }),
1793
- z5.object({
1794
- type: z5.literal("code_execution_tool_result_error"),
1795
- error_code: z5.string()
2041
+ z7.object({
2042
+ type: z7.literal("code_execution_tool_result_error"),
2043
+ error_code: z7.string()
1796
2044
  })
1797
2045
  ])
1798
2046
  })
1799
2047
  ])
1800
2048
  }),
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()
2049
+ z7.object({
2050
+ type: z7.literal("content_block_delta"),
2051
+ index: z7.number(),
2052
+ delta: z7.discriminatedUnion("type", [
2053
+ z7.object({
2054
+ type: z7.literal("input_json_delta"),
2055
+ partial_json: z7.string()
1808
2056
  }),
1809
- z5.object({
1810
- type: z5.literal("text_delta"),
1811
- text: z5.string()
2057
+ z7.object({
2058
+ type: z7.literal("text_delta"),
2059
+ text: z7.string()
1812
2060
  }),
1813
- z5.object({
1814
- type: z5.literal("thinking_delta"),
1815
- thinking: z5.string()
2061
+ z7.object({
2062
+ type: z7.literal("thinking_delta"),
2063
+ thinking: z7.string()
1816
2064
  }),
1817
- z5.object({
1818
- type: z5.literal("signature_delta"),
1819
- signature: z5.string()
2065
+ z7.object({
2066
+ type: z7.literal("signature_delta"),
2067
+ signature: z7.string()
1820
2068
  }),
1821
- z5.object({
1822
- type: z5.literal("citations_delta"),
2069
+ z7.object({
2070
+ type: z7.literal("citations_delta"),
1823
2071
  citation: citationSchema
1824
2072
  })
1825
2073
  ])
1826
2074
  }),
1827
- z5.object({
1828
- type: z5.literal("content_block_stop"),
1829
- index: z5.number()
2075
+ z7.object({
2076
+ type: z7.literal("content_block_stop"),
2077
+ index: z7.number()
1830
2078
  }),
1831
- z5.object({
1832
- type: z5.literal("error"),
1833
- error: z5.object({
1834
- type: z5.string(),
1835
- message: z5.string()
2079
+ z7.object({
2080
+ type: z7.literal("error"),
2081
+ error: z7.object({
2082
+ type: z7.string(),
2083
+ message: z7.string()
1836
2084
  })
1837
2085
  }),
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() })
2086
+ z7.object({
2087
+ type: z7.literal("message_delta"),
2088
+ delta: z7.object({
2089
+ stop_reason: z7.string().nullish(),
2090
+ stop_sequence: z7.string().nullish()
2091
+ }),
2092
+ usage: z7.looseObject({
2093
+ output_tokens: z7.number(),
2094
+ cache_creation_input_tokens: z7.number().nullish()
2095
+ })
1842
2096
  }),
1843
- z5.object({
1844
- type: z5.literal("message_stop")
2097
+ z7.object({
2098
+ type: z7.literal("message_stop")
1845
2099
  }),
1846
- z5.object({
1847
- type: z5.literal("ping")
2100
+ z7.object({
2101
+ type: z7.literal("ping")
1848
2102
  })
1849
2103
  ]);
1850
- var anthropicReasoningMetadataSchema = z5.object({
1851
- signature: z5.string().optional(),
1852
- redactedData: z5.string().optional()
2104
+ var anthropicReasoningMetadataSchema = z7.object({
2105
+ signature: z7.string().optional(),
2106
+ redactedData: z7.string().optional()
1853
2107
  });
1854
2108
 
1855
2109
  // src/tool/bash_20241022.ts
1856
- import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
1857
- import z6 from "zod/v4";
1858
- var bash_20241022 = createProviderDefinedToolFactory({
2110
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
2111
+ import z8 from "zod/v4";
2112
+ var bash_20241022 = createProviderDefinedToolFactory2({
1859
2113
  id: "anthropic.bash_20241022",
1860
2114
  name: "bash",
1861
- inputSchema: z6.object({
1862
- command: z6.string(),
1863
- restart: z6.boolean().optional()
2115
+ inputSchema: z8.object({
2116
+ command: z8.string(),
2117
+ restart: z8.boolean().optional()
1864
2118
  })
1865
2119
  });
1866
2120
 
1867
2121
  // 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({
2122
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
2123
+ import z9 from "zod/v4";
2124
+ var bash_20250124 = createProviderDefinedToolFactory3({
1871
2125
  id: "anthropic.bash_20250124",
1872
2126
  name: "bash",
1873
- inputSchema: z7.object({
1874
- command: z7.string(),
1875
- restart: z7.boolean().optional()
2127
+ inputSchema: z9.object({
2128
+ command: z9.string(),
2129
+ restart: z9.boolean().optional()
1876
2130
  })
1877
2131
  });
1878
2132
 
1879
2133
  // 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({
2134
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
2135
+ import { z as z10 } from "zod/v4";
2136
+ var computer_20241022 = createProviderDefinedToolFactory4({
1883
2137
  id: "anthropic.computer_20241022",
1884
2138
  name: "computer",
1885
- inputSchema: z8.object({
1886
- action: z8.enum([
2139
+ inputSchema: z10.object({
2140
+ action: z10.enum([
1887
2141
  "key",
1888
2142
  "type",
1889
2143
  "mouse_move",
@@ -1895,19 +2149,19 @@ var computer_20241022 = createProviderDefinedToolFactory3({
1895
2149
  "screenshot",
1896
2150
  "cursor_position"
1897
2151
  ]),
1898
- coordinate: z8.array(z8.number().int()).optional(),
1899
- text: z8.string().optional()
2152
+ coordinate: z10.array(z10.number().int()).optional(),
2153
+ text: z10.string().optional()
1900
2154
  })
1901
2155
  });
1902
2156
 
1903
2157
  // 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({
2158
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory5 } from "@ai-sdk/provider-utils";
2159
+ import { z as z11 } from "zod/v4";
2160
+ var computer_20250124 = createProviderDefinedToolFactory5({
1907
2161
  id: "anthropic.computer_20250124",
1908
2162
  name: "computer",
1909
- inputSchema: z9.object({
1910
- action: z9.enum([
2163
+ inputSchema: z11.object({
2164
+ action: z11.enum([
1911
2165
  "key",
1912
2166
  "hold_key",
1913
2167
  "type",
@@ -1925,63 +2179,63 @@ var computer_20250124 = createProviderDefinedToolFactory4({
1925
2179
  "wait",
1926
2180
  "screenshot"
1927
2181
  ]),
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()
2182
+ coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2183
+ duration: z11.number().optional(),
2184
+ scroll_amount: z11.number().optional(),
2185
+ scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
2186
+ start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
2187
+ text: z11.string().optional()
1934
2188
  })
1935
2189
  });
1936
2190
 
1937
2191
  // 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({
2192
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory6 } from "@ai-sdk/provider-utils";
2193
+ import { z as z12 } from "zod/v4";
2194
+ var textEditor_20241022 = createProviderDefinedToolFactory6({
1941
2195
  id: "anthropic.text_editor_20241022",
1942
2196
  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()
2197
+ inputSchema: z12.object({
2198
+ command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2199
+ path: z12.string(),
2200
+ file_text: z12.string().optional(),
2201
+ insert_line: z12.number().int().optional(),
2202
+ new_str: z12.string().optional(),
2203
+ old_str: z12.string().optional(),
2204
+ view_range: z12.array(z12.number().int()).optional()
1951
2205
  })
1952
2206
  });
1953
2207
 
1954
2208
  // 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({
2209
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory7 } from "@ai-sdk/provider-utils";
2210
+ import { z as z13 } from "zod/v4";
2211
+ var textEditor_20250124 = createProviderDefinedToolFactory7({
1958
2212
  id: "anthropic.text_editor_20250124",
1959
2213
  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()
2214
+ inputSchema: z13.object({
2215
+ command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2216
+ path: z13.string(),
2217
+ file_text: z13.string().optional(),
2218
+ insert_line: z13.number().int().optional(),
2219
+ new_str: z13.string().optional(),
2220
+ old_str: z13.string().optional(),
2221
+ view_range: z13.array(z13.number().int()).optional()
1968
2222
  })
1969
2223
  });
1970
2224
 
1971
2225
  // 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({
2226
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory8 } from "@ai-sdk/provider-utils";
2227
+ import { z as z14 } from "zod/v4";
2228
+ var textEditor_20250429 = createProviderDefinedToolFactory8({
1975
2229
  id: "anthropic.text_editor_20250429",
1976
2230
  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()
2231
+ inputSchema: z14.object({
2232
+ command: z14.enum(["view", "create", "str_replace", "insert"]),
2233
+ path: z14.string(),
2234
+ file_text: z14.string().optional(),
2235
+ insert_line: z14.number().int().optional(),
2236
+ new_str: z14.string().optional(),
2237
+ old_str: z14.string().optional(),
2238
+ view_range: z14.array(z14.number().int()).optional()
1985
2239
  })
1986
2240
  });
1987
2241
 
@@ -2047,6 +2301,8 @@ var anthropicTools = {
2047
2301
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2048
2302
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2049
2303
  *
2304
+ * Supported models: Claude Sonnet 3.5
2305
+ *
2050
2306
  * Tool name must be `str_replace_editor`.
2051
2307
  */
2052
2308
  textEditor_20241022,
@@ -2055,6 +2311,8 @@ var anthropicTools = {
2055
2311
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
2056
2312
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2057
2313
  *
2314
+ * Supported models: Claude Sonnet 3.7
2315
+ *
2058
2316
  * Tool name must be `str_replace_editor`.
2059
2317
  */
2060
2318
  textEditor_20250124,
@@ -2066,8 +2324,36 @@ var anthropicTools = {
2066
2324
  * Note: This version does not support the "undo_edit" command.
2067
2325
  *
2068
2326
  * Tool name must be `str_replace_based_edit_tool`.
2327
+ *
2328
+ * @deprecated Use textEditor_20250728 instead
2069
2329
  */
2070
2330
  textEditor_20250429,
2331
+ /**
2332
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2333
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2334
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2335
+ *
2336
+ * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
2337
+ *
2338
+ * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
2339
+ *
2340
+ * Tool name must be `str_replace_based_edit_tool`.
2341
+ *
2342
+ * @param maxCharacters - Optional maximum number of characters to view in the file
2343
+ */
2344
+ textEditor_20250728,
2345
+ /**
2346
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
2347
+ *
2348
+ * Tool name must be `web_fetch`.
2349
+ *
2350
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
2351
+ * @param allowedDomains - Only fetch from these domains
2352
+ * @param blockedDomains - Never fetch from these domains
2353
+ * @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.
2354
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
2355
+ */
2356
+ webFetch_20250910,
2071
2357
  /**
2072
2358
  * Creates a web search tool that gives Claude direct access to real-time web content.
2073
2359
  *
@@ -2085,15 +2371,18 @@ var anthropicTools = {
2085
2371
  function createAnthropic(options = {}) {
2086
2372
  var _a;
2087
2373
  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
- });
2374
+ const getHeaders = () => withUserAgentSuffix(
2375
+ {
2376
+ "anthropic-version": "2023-06-01",
2377
+ "x-api-key": loadApiKey({
2378
+ apiKey: options.apiKey,
2379
+ environmentVariableName: "ANTHROPIC_API_KEY",
2380
+ description: "Anthropic"
2381
+ }),
2382
+ ...options.headers
2383
+ },
2384
+ `ai-sdk/anthropic/${VERSION}`
2385
+ );
2097
2386
  const createChatModel = (modelId) => {
2098
2387
  var _a2;
2099
2388
  return new AnthropicMessagesLanguageModel(modelId, {
@@ -2129,6 +2418,7 @@ function createAnthropic(options = {}) {
2129
2418
  }
2130
2419
  var anthropic = createAnthropic();
2131
2420
  export {
2421
+ VERSION,
2132
2422
  anthropic,
2133
2423
  createAnthropic
2134
2424
  };