@ai-sdk/anthropic 3.0.54 → 3.0.56

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.js CHANGED
@@ -32,11 +32,11 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.54" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.56" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
39
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
39
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
40
40
 
41
41
  // src/anthropic-error.ts
42
42
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -917,6 +917,11 @@ var anthropicLanguageModelOptions = import_v43.z.object({
917
917
  * Only supported with claude-opus-4-6.
918
918
  */
919
919
  speed: import_v43.z.enum(["fast", "standard"]).optional(),
920
+ /**
921
+ * A set of beta features to enable.
922
+ * Allow a provider to receive the full `betas` set if it needs it.
923
+ */
924
+ anthropicBeta: import_v43.z.array(import_v43.z.string()).optional(),
920
925
  contextManagement: import_v43.z.object({
921
926
  edits: import_v43.z.array(
922
927
  import_v43.z.discriminatedUnion("type", [
@@ -1634,7 +1639,7 @@ function convertAnthropicMessagesUsage({
1634
1639
 
1635
1640
  // src/convert-to-anthropic-messages-prompt.ts
1636
1641
  var import_provider2 = require("@ai-sdk/provider");
1637
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
1642
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
1638
1643
 
1639
1644
  // src/tool/code-execution_20250522.ts
1640
1645
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
@@ -1780,22 +1785,139 @@ var codeExecution_20250825 = (args = {}) => {
1780
1785
  return factory7(args);
1781
1786
  };
1782
1787
 
1783
- // src/tool/tool-search-regex_20251119.ts
1788
+ // src/tool/code-execution_20260120.ts
1784
1789
  var import_provider_utils12 = require("@ai-sdk/provider-utils");
1785
1790
  var import_v411 = require("zod/v4");
1786
- var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils12.lazySchema)(
1791
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)(
1787
1792
  () => (0, import_provider_utils12.zodSchema)(
1788
- import_v411.z.array(
1793
+ import_v411.z.discriminatedUnion("type", [
1789
1794
  import_v411.z.object({
1790
- type: import_v411.z.literal("tool_reference"),
1791
- toolName: import_v411.z.string()
1795
+ type: import_v411.z.literal("code_execution_result"),
1796
+ stdout: import_v411.z.string(),
1797
+ stderr: import_v411.z.string(),
1798
+ return_code: import_v411.z.number(),
1799
+ content: import_v411.z.array(
1800
+ import_v411.z.object({
1801
+ type: import_v411.z.literal("code_execution_output"),
1802
+ file_id: import_v411.z.string()
1803
+ })
1804
+ ).optional().default([])
1805
+ }),
1806
+ import_v411.z.object({
1807
+ type: import_v411.z.literal("encrypted_code_execution_result"),
1808
+ encrypted_stdout: import_v411.z.string(),
1809
+ stderr: import_v411.z.string(),
1810
+ return_code: import_v411.z.number(),
1811
+ content: import_v411.z.array(
1812
+ import_v411.z.object({
1813
+ type: import_v411.z.literal("code_execution_output"),
1814
+ file_id: import_v411.z.string()
1815
+ })
1816
+ ).optional().default([])
1817
+ }),
1818
+ import_v411.z.object({
1819
+ type: import_v411.z.literal("bash_code_execution_result"),
1820
+ content: import_v411.z.array(
1821
+ import_v411.z.object({
1822
+ type: import_v411.z.literal("bash_code_execution_output"),
1823
+ file_id: import_v411.z.string()
1824
+ })
1825
+ ),
1826
+ stdout: import_v411.z.string(),
1827
+ stderr: import_v411.z.string(),
1828
+ return_code: import_v411.z.number()
1829
+ }),
1830
+ import_v411.z.object({
1831
+ type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1832
+ error_code: import_v411.z.string()
1833
+ }),
1834
+ import_v411.z.object({
1835
+ type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
1836
+ error_code: import_v411.z.string()
1837
+ }),
1838
+ import_v411.z.object({
1839
+ type: import_v411.z.literal("text_editor_code_execution_view_result"),
1840
+ content: import_v411.z.string(),
1841
+ file_type: import_v411.z.string(),
1842
+ num_lines: import_v411.z.number().nullable(),
1843
+ start_line: import_v411.z.number().nullable(),
1844
+ total_lines: import_v411.z.number().nullable()
1845
+ }),
1846
+ import_v411.z.object({
1847
+ type: import_v411.z.literal("text_editor_code_execution_create_result"),
1848
+ is_file_update: import_v411.z.boolean()
1849
+ }),
1850
+ import_v411.z.object({
1851
+ type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
1852
+ lines: import_v411.z.array(import_v411.z.string()).nullable(),
1853
+ new_lines: import_v411.z.number().nullable(),
1854
+ new_start: import_v411.z.number().nullable(),
1855
+ old_lines: import_v411.z.number().nullable(),
1856
+ old_start: import_v411.z.number().nullable()
1792
1857
  })
1793
- )
1858
+ ])
1794
1859
  )
1795
1860
  );
1796
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils12.lazySchema)(
1861
+ var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
1797
1862
  () => (0, import_provider_utils12.zodSchema)(
1798
- import_v411.z.object({
1863
+ import_v411.z.discriminatedUnion("type", [
1864
+ import_v411.z.object({
1865
+ type: import_v411.z.literal("programmatic-tool-call"),
1866
+ code: import_v411.z.string()
1867
+ }),
1868
+ import_v411.z.object({
1869
+ type: import_v411.z.literal("bash_code_execution"),
1870
+ command: import_v411.z.string()
1871
+ }),
1872
+ import_v411.z.discriminatedUnion("command", [
1873
+ import_v411.z.object({
1874
+ type: import_v411.z.literal("text_editor_code_execution"),
1875
+ command: import_v411.z.literal("view"),
1876
+ path: import_v411.z.string()
1877
+ }),
1878
+ import_v411.z.object({
1879
+ type: import_v411.z.literal("text_editor_code_execution"),
1880
+ command: import_v411.z.literal("create"),
1881
+ path: import_v411.z.string(),
1882
+ file_text: import_v411.z.string().nullish()
1883
+ }),
1884
+ import_v411.z.object({
1885
+ type: import_v411.z.literal("text_editor_code_execution"),
1886
+ command: import_v411.z.literal("str_replace"),
1887
+ path: import_v411.z.string(),
1888
+ old_str: import_v411.z.string(),
1889
+ new_str: import_v411.z.string()
1890
+ })
1891
+ ])
1892
+ ])
1893
+ )
1894
+ );
1895
+ var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1896
+ id: "anthropic.code_execution_20260120",
1897
+ inputSchema: codeExecution_20260120InputSchema,
1898
+ outputSchema: codeExecution_20260120OutputSchema,
1899
+ supportsDeferredResults: true
1900
+ });
1901
+ var codeExecution_20260120 = (args = {}) => {
1902
+ return factory8(args);
1903
+ };
1904
+
1905
+ // src/tool/tool-search-regex_20251119.ts
1906
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
1907
+ var import_v412 = require("zod/v4");
1908
+ var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils13.lazySchema)(
1909
+ () => (0, import_provider_utils13.zodSchema)(
1910
+ import_v412.z.array(
1911
+ import_v412.z.object({
1912
+ type: import_v412.z.literal("tool_reference"),
1913
+ toolName: import_v412.z.string()
1914
+ })
1915
+ )
1916
+ )
1917
+ );
1918
+ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1919
+ () => (0, import_provider_utils13.zodSchema)(
1920
+ import_v412.z.object({
1799
1921
  /**
1800
1922
  * A regex pattern to search for tools.
1801
1923
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1806,28 +1928,28 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils12.lazySchema
1806
1928
  * - "database.*query|query.*database" - OR patterns for flexibility
1807
1929
  * - "(?i)slack" - case-insensitive search
1808
1930
  */
1809
- pattern: import_v411.z.string(),
1931
+ pattern: import_v412.z.string(),
1810
1932
  /**
1811
1933
  * Maximum number of tools to return. Optional.
1812
1934
  */
1813
- limit: import_v411.z.number().optional()
1935
+ limit: import_v412.z.number().optional()
1814
1936
  })
1815
1937
  )
1816
1938
  );
1817
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1939
+ var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
1818
1940
  id: "anthropic.tool_search_regex_20251119",
1819
1941
  inputSchema: toolSearchRegex_20251119InputSchema,
1820
1942
  outputSchema: toolSearchRegex_20251119OutputSchema,
1821
1943
  supportsDeferredResults: true
1822
1944
  });
1823
1945
  var toolSearchRegex_20251119 = (args = {}) => {
1824
- return factory8(args);
1946
+ return factory9(args);
1825
1947
  };
1826
1948
 
1827
1949
  // src/convert-to-anthropic-messages-prompt.ts
1828
1950
  function convertToString(data) {
1829
1951
  if (typeof data === "string") {
1830
- return new TextDecoder().decode((0, import_provider_utils13.convertBase64ToUint8Array)(data));
1952
+ return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
1831
1953
  }
1832
1954
  if (data instanceof Uint8Array) {
1833
1955
  return new TextDecoder().decode(data);
@@ -1857,7 +1979,7 @@ async function convertToAnthropicMessagesPrompt({
1857
1979
  cacheControlValidator,
1858
1980
  toolNameMapping
1859
1981
  }) {
1860
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1982
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1861
1983
  const betas = /* @__PURE__ */ new Set();
1862
1984
  const blocks = groupIntoBlocks(prompt);
1863
1985
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -1865,7 +1987,7 @@ async function convertToAnthropicMessagesPrompt({
1865
1987
  const messages = [];
1866
1988
  async function shouldEnableCitations(providerMetadata) {
1867
1989
  var _a2, _b2;
1868
- const anthropicOptions = await (0, import_provider_utils13.parseProviderOptions)({
1990
+ const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
1869
1991
  provider: "anthropic",
1870
1992
  providerOptions: providerMetadata,
1871
1993
  schema: anthropicFilePartProviderOptions
@@ -1873,7 +1995,7 @@ async function convertToAnthropicMessagesPrompt({
1873
1995
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1874
1996
  }
1875
1997
  async function getDocumentMetadata(providerMetadata) {
1876
- const anthropicOptions = await (0, import_provider_utils13.parseProviderOptions)({
1998
+ const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
1877
1999
  provider: "anthropic",
1878
2000
  providerOptions: providerMetadata,
1879
2001
  schema: anthropicFilePartProviderOptions
@@ -1939,7 +2061,7 @@ async function convertToAnthropicMessagesPrompt({
1939
2061
  } : {
1940
2062
  type: "base64",
1941
2063
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1942
- data: (0, import_provider_utils13.convertToBase64)(part.data)
2064
+ data: (0, import_provider_utils14.convertToBase64)(part.data)
1943
2065
  },
1944
2066
  cache_control: cacheControl
1945
2067
  });
@@ -1959,7 +2081,7 @@ async function convertToAnthropicMessagesPrompt({
1959
2081
  } : {
1960
2082
  type: "base64",
1961
2083
  media_type: "application/pdf",
1962
- data: (0, import_provider_utils13.convertToBase64)(part.data)
2084
+ data: (0, import_provider_utils14.convertToBase64)(part.data)
1963
2085
  },
1964
2086
  title: (_b = metadata.title) != null ? _b : part.filename,
1965
2087
  ...metadata.context && { context: metadata.context },
@@ -2097,7 +2219,7 @@ async function convertToAnthropicMessagesPrompt({
2097
2219
  return void 0;
2098
2220
  }
2099
2221
  }
2100
- }).filter(import_provider_utils13.isNonNullable);
2222
+ }).filter(import_provider_utils14.isNonNullable);
2101
2223
  break;
2102
2224
  case "text":
2103
2225
  case "error-text":
@@ -2173,7 +2295,7 @@ async function convertToAnthropicMessagesPrompt({
2173
2295
  }
2174
2296
  case "reasoning": {
2175
2297
  if (sendReasoning) {
2176
- const reasoningMetadata = await (0, import_provider_utils13.parseProviderOptions)({
2298
+ const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2177
2299
  provider: "anthropic",
2178
2300
  providerOptions: part.providerOptions,
2179
2301
  schema: anthropicReasoningMetadataSchema
@@ -2379,7 +2501,7 @@ async function convertToAnthropicMessagesPrompt({
2379
2501
  break;
2380
2502
  }
2381
2503
  if (output.value.type === "code_execution_result") {
2382
- const codeExecutionOutput = await (0, import_provider_utils13.validateTypes)({
2504
+ const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2383
2505
  value: output.value,
2384
2506
  schema: codeExecution_20250522OutputSchema
2385
2507
  });
@@ -2395,8 +2517,27 @@ async function convertToAnthropicMessagesPrompt({
2395
2517
  },
2396
2518
  cache_control: cacheControl
2397
2519
  });
2520
+ } else if (output.value.type === "encrypted_code_execution_result") {
2521
+ const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2522
+ value: output.value,
2523
+ schema: codeExecution_20260120OutputSchema
2524
+ });
2525
+ if (codeExecutionOutput.type === "encrypted_code_execution_result") {
2526
+ anthropicContent.push({
2527
+ type: "code_execution_tool_result",
2528
+ tool_use_id: part.toolCallId,
2529
+ content: {
2530
+ type: codeExecutionOutput.type,
2531
+ encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2532
+ stderr: codeExecutionOutput.stderr,
2533
+ return_code: codeExecutionOutput.return_code,
2534
+ content: (_p = codeExecutionOutput.content) != null ? _p : []
2535
+ },
2536
+ cache_control: cacheControl
2537
+ });
2538
+ }
2398
2539
  } else {
2399
- const codeExecutionOutput = await (0, import_provider_utils13.validateTypes)({
2540
+ const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2400
2541
  value: output.value,
2401
2542
  schema: codeExecution_20250825OutputSchema
2402
2543
  });
@@ -2409,7 +2550,7 @@ async function convertToAnthropicMessagesPrompt({
2409
2550
  stdout: codeExecutionOutput.stdout,
2410
2551
  stderr: codeExecutionOutput.stderr,
2411
2552
  return_code: codeExecutionOutput.return_code,
2412
- content: (_p = codeExecutionOutput.content) != null ? _p : []
2553
+ content: (_q = codeExecutionOutput.content) != null ? _q : []
2413
2554
  },
2414
2555
  cache_control: cacheControl
2415
2556
  });
@@ -2442,7 +2583,7 @@ async function convertToAnthropicMessagesPrompt({
2442
2583
  errorValue = output.value;
2443
2584
  }
2444
2585
  } catch (e) {
2445
- const extractedErrorCode = (_q = output.value) == null ? void 0 : _q.errorCode;
2586
+ const extractedErrorCode = (_r = output.value) == null ? void 0 : _r.errorCode;
2446
2587
  errorValue = {
2447
2588
  errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unknown"
2448
2589
  };
@@ -2452,7 +2593,7 @@ async function convertToAnthropicMessagesPrompt({
2452
2593
  tool_use_id: part.toolCallId,
2453
2594
  content: {
2454
2595
  type: "web_fetch_tool_result_error",
2455
- error_code: (_r = errorValue.errorCode) != null ? _r : "unknown"
2596
+ error_code: (_s = errorValue.errorCode) != null ? _s : "unknown"
2456
2597
  },
2457
2598
  cache_control: cacheControl
2458
2599
  });
@@ -2465,7 +2606,7 @@ async function convertToAnthropicMessagesPrompt({
2465
2606
  });
2466
2607
  break;
2467
2608
  }
2468
- const webFetchOutput = await (0, import_provider_utils13.validateTypes)({
2609
+ const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2469
2610
  value: output.value,
2470
2611
  schema: webFetch_20250910OutputSchema
2471
2612
  });
@@ -2500,7 +2641,7 @@ async function convertToAnthropicMessagesPrompt({
2500
2641
  });
2501
2642
  break;
2502
2643
  }
2503
- const webSearchOutput = await (0, import_provider_utils13.validateTypes)({
2644
+ const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2504
2645
  value: output.value,
2505
2646
  schema: webSearch_20250305OutputSchema
2506
2647
  });
@@ -2527,7 +2668,7 @@ async function convertToAnthropicMessagesPrompt({
2527
2668
  });
2528
2669
  break;
2529
2670
  }
2530
- const toolSearchOutput = await (0, import_provider_utils13.validateTypes)({
2671
+ const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2531
2672
  value: output.value,
2532
2673
  schema: toolSearchRegex_20251119OutputSchema
2533
2674
  });
@@ -2691,7 +2832,7 @@ var AnthropicMessagesLanguageModel = class {
2691
2832
  var _a;
2692
2833
  this.modelId = modelId;
2693
2834
  this.config = config;
2694
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils14.generateId;
2835
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
2695
2836
  }
2696
2837
  supportsUrl(url) {
2697
2838
  return url.protocol === "https:";
@@ -2729,7 +2870,7 @@ var AnthropicMessagesLanguageModel = class {
2729
2870
  providerOptions,
2730
2871
  stream
2731
2872
  }) {
2732
- var _a, _b, _c, _d, _e, _f;
2873
+ var _a, _b, _c, _d, _e, _f, _g;
2733
2874
  const warnings = [];
2734
2875
  if (frequencyPenalty != null) {
2735
2876
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2765,12 +2906,12 @@ var AnthropicMessagesLanguageModel = class {
2765
2906
  }
2766
2907
  }
2767
2908
  const providerOptionsName = this.providerOptionsName;
2768
- const canonicalOptions = await (0, import_provider_utils14.parseProviderOptions)({
2909
+ const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
2769
2910
  provider: "anthropic",
2770
2911
  providerOptions,
2771
2912
  schema: anthropicLanguageModelOptions
2772
2913
  });
2773
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils14.parseProviderOptions)({
2914
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
2774
2915
  provider: providerOptionsName,
2775
2916
  providerOptions,
2776
2917
  schema: anthropicLanguageModelOptions
@@ -2797,7 +2938,7 @@ var AnthropicMessagesLanguageModel = class {
2797
2938
  } : void 0;
2798
2939
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2799
2940
  const cacheControlValidator = new CacheControlValidator();
2800
- const toolNameMapping = (0, import_provider_utils14.createToolNameMapping)({
2941
+ const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
2801
2942
  tools,
2802
2943
  providerToolNames: {
2803
2944
  "anthropic.code_execution_20250522": "code_execution",
@@ -3069,7 +3210,12 @@ var AnthropicMessagesLanguageModel = class {
3069
3210
  // do not send when not streaming
3070
3211
  },
3071
3212
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
3072
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
3213
+ betas: /* @__PURE__ */ new Set([
3214
+ ...betas,
3215
+ ...toolsBetas,
3216
+ ...userSuppliedBetas,
3217
+ ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
3218
+ ]),
3073
3219
  usesJsonResponseTool: jsonResponseTool != null,
3074
3220
  toolNameMapping,
3075
3221
  providerOptionsName,
@@ -3080,15 +3226,15 @@ var AnthropicMessagesLanguageModel = class {
3080
3226
  betas,
3081
3227
  headers
3082
3228
  }) {
3083
- return (0, import_provider_utils14.combineHeaders)(
3084
- await (0, import_provider_utils14.resolve)(this.config.headers),
3229
+ return (0, import_provider_utils15.combineHeaders)(
3230
+ await (0, import_provider_utils15.resolve)(this.config.headers),
3085
3231
  headers,
3086
3232
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3087
3233
  );
3088
3234
  }
3089
3235
  async getBetasFromHeaders(requestHeaders) {
3090
3236
  var _a, _b;
3091
- const configHeaders = await (0, import_provider_utils14.resolve)(this.config.headers);
3237
+ const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3092
3238
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3093
3239
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3094
3240
  return new Set(
@@ -3102,9 +3248,9 @@ var AnthropicMessagesLanguageModel = class {
3102
3248
  var _a, _b, _c;
3103
3249
  return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
3104
3250
  }
3105
- transformRequestBody(args) {
3251
+ transformRequestBody(args, betas) {
3106
3252
  var _a, _b, _c;
3107
- return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
3253
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args, betas)) != null ? _c : args;
3108
3254
  }
3109
3255
  extractCitationDocuments(prompt) {
3110
3256
  const isCitationPart = (part) => {
@@ -3130,7 +3276,7 @@ var AnthropicMessagesLanguageModel = class {
3130
3276
  });
3131
3277
  }
3132
3278
  async doGenerate(options) {
3133
- var _a, _b, _c, _d, _e, _f;
3279
+ var _a, _b, _c, _d, _e, _f, _g;
3134
3280
  const {
3135
3281
  args,
3136
3282
  warnings,
@@ -3154,12 +3300,12 @@ var AnthropicMessagesLanguageModel = class {
3154
3300
  responseHeaders,
3155
3301
  value: response,
3156
3302
  rawValue: rawResponse
3157
- } = await (0, import_provider_utils14.postJsonToApi)({
3303
+ } = await (0, import_provider_utils15.postJsonToApi)({
3158
3304
  url: this.buildRequestUrl(false),
3159
3305
  headers: await this.getHeaders({ betas, headers: options.headers }),
3160
- body: this.transformRequestBody(args),
3306
+ body: this.transformRequestBody(args, betas),
3161
3307
  failedResponseHandler: anthropicFailedResponseHandler,
3162
- successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
3308
+ successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3163
3309
  anthropicMessagesResponseSchema
3164
3310
  ),
3165
3311
  abortSignal: options.abortSignal,
@@ -3418,6 +3564,19 @@ var AnthropicMessagesLanguageModel = class {
3418
3564
  content: (_c = part.content.content) != null ? _c : []
3419
3565
  }
3420
3566
  });
3567
+ } else if (part.content.type === "encrypted_code_execution_result") {
3568
+ content.push({
3569
+ type: "tool-result",
3570
+ toolCallId: part.tool_use_id,
3571
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
3572
+ result: {
3573
+ type: part.content.type,
3574
+ encrypted_stdout: part.content.encrypted_stdout,
3575
+ stderr: part.content.stderr,
3576
+ return_code: part.content.return_code,
3577
+ content: (_d = part.content.content) != null ? _d : []
3578
+ }
3579
+ });
3421
3580
  } else if (part.content.type === "code_execution_tool_result_error") {
3422
3581
  content.push({
3423
3582
  type: "tool-result",
@@ -3494,13 +3653,13 @@ var AnthropicMessagesLanguageModel = class {
3494
3653
  finishReason: response.stop_reason,
3495
3654
  isJsonResponseFromTool
3496
3655
  }),
3497
- raw: (_d = response.stop_reason) != null ? _d : void 0
3656
+ raw: (_e = response.stop_reason) != null ? _e : void 0
3498
3657
  },
3499
3658
  usage: convertAnthropicMessagesUsage({ usage: response.usage }),
3500
3659
  request: { body: args },
3501
3660
  response: {
3502
- id: (_e = response.id) != null ? _e : void 0,
3503
- modelId: (_f = response.model) != null ? _f : void 0,
3661
+ id: (_f = response.id) != null ? _f : void 0,
3662
+ modelId: (_g = response.model) != null ? _g : void 0,
3504
3663
  headers: responseHeaders,
3505
3664
  body: rawResponse
3506
3665
  },
@@ -3561,12 +3720,12 @@ var AnthropicMessagesLanguageModel = class {
3561
3720
  body.tools
3562
3721
  );
3563
3722
  const url = this.buildRequestUrl(true);
3564
- const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
3723
+ const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
3565
3724
  url,
3566
3725
  headers: await this.getHeaders({ betas, headers: options.headers }),
3567
- body: this.transformRequestBody(body),
3726
+ body: this.transformRequestBody(body, betas),
3568
3727
  failedResponseHandler: anthropicFailedResponseHandler,
3569
- successfulResponseHandler: (0, import_provider_utils14.createEventSourceResponseHandler)(
3728
+ successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3570
3729
  anthropicMessagesChunkSchema
3571
3730
  ),
3572
3731
  abortSignal: options.abortSignal,
@@ -3600,7 +3759,7 @@ var AnthropicMessagesLanguageModel = class {
3600
3759
  controller.enqueue({ type: "stream-start", warnings });
3601
3760
  },
3602
3761
  transform(chunk, controller) {
3603
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
3762
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
3604
3763
  if (options.includeRawChunks) {
3605
3764
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3606
3765
  }
@@ -3850,6 +4009,19 @@ var AnthropicMessagesLanguageModel = class {
3850
4009
  content: (_c = part.content.content) != null ? _c : []
3851
4010
  }
3852
4011
  });
4012
+ } else if (part.content.type === "encrypted_code_execution_result") {
4013
+ controller.enqueue({
4014
+ type: "tool-result",
4015
+ toolCallId: part.tool_use_id,
4016
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
4017
+ result: {
4018
+ type: part.content.type,
4019
+ encrypted_stdout: part.content.encrypted_stdout,
4020
+ stderr: part.content.stderr,
4021
+ return_code: part.content.return_code,
4022
+ content: (_d = part.content.content) != null ? _d : []
4023
+ }
4024
+ });
3853
4025
  } else if (part.content.type === "code_execution_tool_result_error") {
3854
4026
  controller.enqueue({
3855
4027
  type: "tool-result",
@@ -4117,12 +4289,12 @@ var AnthropicMessagesLanguageModel = class {
4117
4289
  }
4118
4290
  case "message_start": {
4119
4291
  usage.input_tokens = value.message.usage.input_tokens;
4120
- usage.cache_read_input_tokens = (_d = value.message.usage.cache_read_input_tokens) != null ? _d : 0;
4121
- usage.cache_creation_input_tokens = (_e = value.message.usage.cache_creation_input_tokens) != null ? _e : 0;
4292
+ usage.cache_read_input_tokens = (_e = value.message.usage.cache_read_input_tokens) != null ? _e : 0;
4293
+ usage.cache_creation_input_tokens = (_f = value.message.usage.cache_creation_input_tokens) != null ? _f : 0;
4122
4294
  rawUsage = {
4123
4295
  ...value.message.usage
4124
4296
  };
4125
- cacheCreationInputTokens = (_f = value.message.usage.cache_creation_input_tokens) != null ? _f : null;
4297
+ cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4126
4298
  if (value.message.container != null) {
4127
4299
  container = {
4128
4300
  expiresAt: value.message.container.expires_at,
@@ -4141,8 +4313,8 @@ var AnthropicMessagesLanguageModel = class {
4141
4313
  }
4142
4314
  controller.enqueue({
4143
4315
  type: "response-metadata",
4144
- id: (_g = value.message.id) != null ? _g : void 0,
4145
- modelId: (_h = value.message.model) != null ? _h : void 0
4316
+ id: (_h = value.message.id) != null ? _h : void 0,
4317
+ modelId: (_i = value.message.model) != null ? _i : void 0
4146
4318
  });
4147
4319
  if (value.message.content != null) {
4148
4320
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4158,7 +4330,7 @@ var AnthropicMessagesLanguageModel = class {
4158
4330
  id: part.id,
4159
4331
  toolName: part.name
4160
4332
  });
4161
- const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4333
+ const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4162
4334
  controller.enqueue({
4163
4335
  type: "tool-input-delta",
4164
4336
  id: part.id,
@@ -4206,17 +4378,17 @@ var AnthropicMessagesLanguageModel = class {
4206
4378
  finishReason: value.delta.stop_reason,
4207
4379
  isJsonResponseFromTool
4208
4380
  }),
4209
- raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4381
+ raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4210
4382
  };
4211
- stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4383
+ stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4212
4384
  container = value.delta.container != null ? {
4213
4385
  expiresAt: value.delta.container.expires_at,
4214
4386
  id: value.delta.container.id,
4215
- skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4387
+ skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4216
4388
  type: skill.type,
4217
4389
  skillId: skill.skill_id,
4218
4390
  version: skill.version
4219
- }))) != null ? _m : null
4391
+ }))) != null ? _n : null
4220
4392
  } : null;
4221
4393
  if (value.context_management) {
4222
4394
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4390,25 +4562,9 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4390
4562
  }
4391
4563
 
4392
4564
  // src/tool/bash_20241022.ts
4393
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
4394
- var import_v412 = require("zod/v4");
4395
- var bash_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
4396
- () => (0, import_provider_utils15.zodSchema)(
4397
- import_v412.z.object({
4398
- command: import_v412.z.string(),
4399
- restart: import_v412.z.boolean().optional()
4400
- })
4401
- )
4402
- );
4403
- var bash_20241022 = (0, import_provider_utils15.createProviderToolFactory)({
4404
- id: "anthropic.bash_20241022",
4405
- inputSchema: bash_20241022InputSchema
4406
- });
4407
-
4408
- // src/tool/bash_20250124.ts
4409
4565
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
4410
4566
  var import_v413 = require("zod/v4");
4411
- var bash_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
4567
+ var bash_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
4412
4568
  () => (0, import_provider_utils16.zodSchema)(
4413
4569
  import_v413.z.object({
4414
4570
  command: import_v413.z.string(),
@@ -4416,115 +4572,26 @@ var bash_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
4416
4572
  })
4417
4573
  )
4418
4574
  );
4419
- var bash_20250124 = (0, import_provider_utils16.createProviderToolFactory)({
4420
- id: "anthropic.bash_20250124",
4421
- inputSchema: bash_20250124InputSchema
4575
+ var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
4576
+ id: "anthropic.bash_20241022",
4577
+ inputSchema: bash_20241022InputSchema
4422
4578
  });
4423
4579
 
4424
- // src/tool/code-execution_20260120.ts
4580
+ // src/tool/bash_20250124.ts
4425
4581
  var import_provider_utils17 = require("@ai-sdk/provider-utils");
4426
4582
  var import_v414 = require("zod/v4");
4427
- var codeExecution_20260120OutputSchema = (0, import_provider_utils17.lazySchema)(
4428
- () => (0, import_provider_utils17.zodSchema)(
4429
- import_v414.z.discriminatedUnion("type", [
4430
- import_v414.z.object({
4431
- type: import_v414.z.literal("code_execution_result"),
4432
- stdout: import_v414.z.string(),
4433
- stderr: import_v414.z.string(),
4434
- return_code: import_v414.z.number(),
4435
- content: import_v414.z.array(
4436
- import_v414.z.object({
4437
- type: import_v414.z.literal("code_execution_output"),
4438
- file_id: import_v414.z.string()
4439
- })
4440
- ).optional().default([])
4441
- }),
4442
- import_v414.z.object({
4443
- type: import_v414.z.literal("bash_code_execution_result"),
4444
- content: import_v414.z.array(
4445
- import_v414.z.object({
4446
- type: import_v414.z.literal("bash_code_execution_output"),
4447
- file_id: import_v414.z.string()
4448
- })
4449
- ),
4450
- stdout: import_v414.z.string(),
4451
- stderr: import_v414.z.string(),
4452
- return_code: import_v414.z.number()
4453
- }),
4454
- import_v414.z.object({
4455
- type: import_v414.z.literal("bash_code_execution_tool_result_error"),
4456
- error_code: import_v414.z.string()
4457
- }),
4458
- import_v414.z.object({
4459
- type: import_v414.z.literal("text_editor_code_execution_tool_result_error"),
4460
- error_code: import_v414.z.string()
4461
- }),
4462
- import_v414.z.object({
4463
- type: import_v414.z.literal("text_editor_code_execution_view_result"),
4464
- content: import_v414.z.string(),
4465
- file_type: import_v414.z.string(),
4466
- num_lines: import_v414.z.number().nullable(),
4467
- start_line: import_v414.z.number().nullable(),
4468
- total_lines: import_v414.z.number().nullable()
4469
- }),
4470
- import_v414.z.object({
4471
- type: import_v414.z.literal("text_editor_code_execution_create_result"),
4472
- is_file_update: import_v414.z.boolean()
4473
- }),
4474
- import_v414.z.object({
4475
- type: import_v414.z.literal("text_editor_code_execution_str_replace_result"),
4476
- lines: import_v414.z.array(import_v414.z.string()).nullable(),
4477
- new_lines: import_v414.z.number().nullable(),
4478
- new_start: import_v414.z.number().nullable(),
4479
- old_lines: import_v414.z.number().nullable(),
4480
- old_start: import_v414.z.number().nullable()
4481
- })
4482
- ])
4483
- )
4484
- );
4485
- var codeExecution_20260120InputSchema = (0, import_provider_utils17.lazySchema)(
4583
+ var bash_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
4486
4584
  () => (0, import_provider_utils17.zodSchema)(
4487
- import_v414.z.discriminatedUnion("type", [
4488
- import_v414.z.object({
4489
- type: import_v414.z.literal("programmatic-tool-call"),
4490
- code: import_v414.z.string()
4491
- }),
4492
- import_v414.z.object({
4493
- type: import_v414.z.literal("bash_code_execution"),
4494
- command: import_v414.z.string()
4495
- }),
4496
- import_v414.z.discriminatedUnion("command", [
4497
- import_v414.z.object({
4498
- type: import_v414.z.literal("text_editor_code_execution"),
4499
- command: import_v414.z.literal("view"),
4500
- path: import_v414.z.string()
4501
- }),
4502
- import_v414.z.object({
4503
- type: import_v414.z.literal("text_editor_code_execution"),
4504
- command: import_v414.z.literal("create"),
4505
- path: import_v414.z.string(),
4506
- file_text: import_v414.z.string().nullish()
4507
- }),
4508
- import_v414.z.object({
4509
- type: import_v414.z.literal("text_editor_code_execution"),
4510
- command: import_v414.z.literal("str_replace"),
4511
- path: import_v414.z.string(),
4512
- old_str: import_v414.z.string(),
4513
- new_str: import_v414.z.string()
4514
- })
4515
- ])
4516
- ])
4585
+ import_v414.z.object({
4586
+ command: import_v414.z.string(),
4587
+ restart: import_v414.z.boolean().optional()
4588
+ })
4517
4589
  )
4518
4590
  );
4519
- var factory9 = (0, import_provider_utils17.createProviderToolFactoryWithOutputSchema)({
4520
- id: "anthropic.code_execution_20260120",
4521
- inputSchema: codeExecution_20260120InputSchema,
4522
- outputSchema: codeExecution_20260120OutputSchema,
4523
- supportsDeferredResults: true
4591
+ var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
4592
+ id: "anthropic.bash_20250124",
4593
+ inputSchema: bash_20250124InputSchema
4524
4594
  });
4525
- var codeExecution_20260120 = (args = {}) => {
4526
- return factory9(args);
4527
- };
4528
4595
 
4529
4596
  // src/tool/computer_20241022.ts
4530
4597
  var import_provider_utils18 = require("@ai-sdk/provider-utils");