@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.
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(internal_exports);
28
28
 
29
29
  // src/anthropic-messages-language-model.ts
30
30
  var import_provider3 = require("@ai-sdk/provider");
31
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/anthropic-error.ts
34
34
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -909,6 +909,11 @@ var anthropicLanguageModelOptions = import_v43.z.object({
909
909
  * Only supported with claude-opus-4-6.
910
910
  */
911
911
  speed: import_v43.z.enum(["fast", "standard"]).optional(),
912
+ /**
913
+ * A set of beta features to enable.
914
+ * Allow a provider to receive the full `betas` set if it needs it.
915
+ */
916
+ anthropicBeta: import_v43.z.array(import_v43.z.string()).optional(),
912
917
  contextManagement: import_v43.z.object({
913
918
  edits: import_v43.z.array(
914
919
  import_v43.z.discriminatedUnion("type", [
@@ -1626,7 +1631,7 @@ function convertAnthropicMessagesUsage({
1626
1631
 
1627
1632
  // src/convert-to-anthropic-messages-prompt.ts
1628
1633
  var import_provider2 = require("@ai-sdk/provider");
1629
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
1634
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
1630
1635
 
1631
1636
  // src/tool/code-execution_20250522.ts
1632
1637
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
@@ -1772,22 +1777,139 @@ var codeExecution_20250825 = (args = {}) => {
1772
1777
  return factory7(args);
1773
1778
  };
1774
1779
 
1775
- // src/tool/tool-search-regex_20251119.ts
1780
+ // src/tool/code-execution_20260120.ts
1776
1781
  var import_provider_utils12 = require("@ai-sdk/provider-utils");
1777
1782
  var import_v411 = require("zod/v4");
1778
- var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils12.lazySchema)(
1783
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils12.lazySchema)(
1779
1784
  () => (0, import_provider_utils12.zodSchema)(
1780
- import_v411.z.array(
1785
+ import_v411.z.discriminatedUnion("type", [
1781
1786
  import_v411.z.object({
1782
- type: import_v411.z.literal("tool_reference"),
1783
- toolName: import_v411.z.string()
1787
+ type: import_v411.z.literal("code_execution_result"),
1788
+ stdout: import_v411.z.string(),
1789
+ stderr: import_v411.z.string(),
1790
+ return_code: import_v411.z.number(),
1791
+ content: import_v411.z.array(
1792
+ import_v411.z.object({
1793
+ type: import_v411.z.literal("code_execution_output"),
1794
+ file_id: import_v411.z.string()
1795
+ })
1796
+ ).optional().default([])
1797
+ }),
1798
+ import_v411.z.object({
1799
+ type: import_v411.z.literal("encrypted_code_execution_result"),
1800
+ encrypted_stdout: import_v411.z.string(),
1801
+ stderr: import_v411.z.string(),
1802
+ return_code: import_v411.z.number(),
1803
+ content: import_v411.z.array(
1804
+ import_v411.z.object({
1805
+ type: import_v411.z.literal("code_execution_output"),
1806
+ file_id: import_v411.z.string()
1807
+ })
1808
+ ).optional().default([])
1809
+ }),
1810
+ import_v411.z.object({
1811
+ type: import_v411.z.literal("bash_code_execution_result"),
1812
+ content: import_v411.z.array(
1813
+ import_v411.z.object({
1814
+ type: import_v411.z.literal("bash_code_execution_output"),
1815
+ file_id: import_v411.z.string()
1816
+ })
1817
+ ),
1818
+ stdout: import_v411.z.string(),
1819
+ stderr: import_v411.z.string(),
1820
+ return_code: import_v411.z.number()
1821
+ }),
1822
+ import_v411.z.object({
1823
+ type: import_v411.z.literal("bash_code_execution_tool_result_error"),
1824
+ error_code: import_v411.z.string()
1825
+ }),
1826
+ import_v411.z.object({
1827
+ type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
1828
+ error_code: import_v411.z.string()
1829
+ }),
1830
+ import_v411.z.object({
1831
+ type: import_v411.z.literal("text_editor_code_execution_view_result"),
1832
+ content: import_v411.z.string(),
1833
+ file_type: import_v411.z.string(),
1834
+ num_lines: import_v411.z.number().nullable(),
1835
+ start_line: import_v411.z.number().nullable(),
1836
+ total_lines: import_v411.z.number().nullable()
1837
+ }),
1838
+ import_v411.z.object({
1839
+ type: import_v411.z.literal("text_editor_code_execution_create_result"),
1840
+ is_file_update: import_v411.z.boolean()
1841
+ }),
1842
+ import_v411.z.object({
1843
+ type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
1844
+ lines: import_v411.z.array(import_v411.z.string()).nullable(),
1845
+ new_lines: import_v411.z.number().nullable(),
1846
+ new_start: import_v411.z.number().nullable(),
1847
+ old_lines: import_v411.z.number().nullable(),
1848
+ old_start: import_v411.z.number().nullable()
1784
1849
  })
1785
- )
1850
+ ])
1786
1851
  )
1787
1852
  );
1788
- var toolSearchRegex_20251119InputSchema = (0, import_provider_utils12.lazySchema)(
1853
+ var codeExecution_20260120InputSchema = (0, import_provider_utils12.lazySchema)(
1789
1854
  () => (0, import_provider_utils12.zodSchema)(
1790
- import_v411.z.object({
1855
+ import_v411.z.discriminatedUnion("type", [
1856
+ import_v411.z.object({
1857
+ type: import_v411.z.literal("programmatic-tool-call"),
1858
+ code: import_v411.z.string()
1859
+ }),
1860
+ import_v411.z.object({
1861
+ type: import_v411.z.literal("bash_code_execution"),
1862
+ command: import_v411.z.string()
1863
+ }),
1864
+ import_v411.z.discriminatedUnion("command", [
1865
+ import_v411.z.object({
1866
+ type: import_v411.z.literal("text_editor_code_execution"),
1867
+ command: import_v411.z.literal("view"),
1868
+ path: import_v411.z.string()
1869
+ }),
1870
+ import_v411.z.object({
1871
+ type: import_v411.z.literal("text_editor_code_execution"),
1872
+ command: import_v411.z.literal("create"),
1873
+ path: import_v411.z.string(),
1874
+ file_text: import_v411.z.string().nullish()
1875
+ }),
1876
+ import_v411.z.object({
1877
+ type: import_v411.z.literal("text_editor_code_execution"),
1878
+ command: import_v411.z.literal("str_replace"),
1879
+ path: import_v411.z.string(),
1880
+ old_str: import_v411.z.string(),
1881
+ new_str: import_v411.z.string()
1882
+ })
1883
+ ])
1884
+ ])
1885
+ )
1886
+ );
1887
+ var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1888
+ id: "anthropic.code_execution_20260120",
1889
+ inputSchema: codeExecution_20260120InputSchema,
1890
+ outputSchema: codeExecution_20260120OutputSchema,
1891
+ supportsDeferredResults: true
1892
+ });
1893
+ var codeExecution_20260120 = (args = {}) => {
1894
+ return factory8(args);
1895
+ };
1896
+
1897
+ // src/tool/tool-search-regex_20251119.ts
1898
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
1899
+ var import_v412 = require("zod/v4");
1900
+ var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils13.lazySchema)(
1901
+ () => (0, import_provider_utils13.zodSchema)(
1902
+ import_v412.z.array(
1903
+ import_v412.z.object({
1904
+ type: import_v412.z.literal("tool_reference"),
1905
+ toolName: import_v412.z.string()
1906
+ })
1907
+ )
1908
+ )
1909
+ );
1910
+ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema)(
1911
+ () => (0, import_provider_utils13.zodSchema)(
1912
+ import_v412.z.object({
1791
1913
  /**
1792
1914
  * A regex pattern to search for tools.
1793
1915
  * Uses Python re.search() syntax. Maximum 200 characters.
@@ -1798,28 +1920,28 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils12.lazySchema
1798
1920
  * - "database.*query|query.*database" - OR patterns for flexibility
1799
1921
  * - "(?i)slack" - case-insensitive search
1800
1922
  */
1801
- pattern: import_v411.z.string(),
1923
+ pattern: import_v412.z.string(),
1802
1924
  /**
1803
1925
  * Maximum number of tools to return. Optional.
1804
1926
  */
1805
- limit: import_v411.z.number().optional()
1927
+ limit: import_v412.z.number().optional()
1806
1928
  })
1807
1929
  )
1808
1930
  );
1809
- var factory8 = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
1931
+ var factory9 = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
1810
1932
  id: "anthropic.tool_search_regex_20251119",
1811
1933
  inputSchema: toolSearchRegex_20251119InputSchema,
1812
1934
  outputSchema: toolSearchRegex_20251119OutputSchema,
1813
1935
  supportsDeferredResults: true
1814
1936
  });
1815
1937
  var toolSearchRegex_20251119 = (args = {}) => {
1816
- return factory8(args);
1938
+ return factory9(args);
1817
1939
  };
1818
1940
 
1819
1941
  // src/convert-to-anthropic-messages-prompt.ts
1820
1942
  function convertToString(data) {
1821
1943
  if (typeof data === "string") {
1822
- return new TextDecoder().decode((0, import_provider_utils13.convertBase64ToUint8Array)(data));
1944
+ return new TextDecoder().decode((0, import_provider_utils14.convertBase64ToUint8Array)(data));
1823
1945
  }
1824
1946
  if (data instanceof Uint8Array) {
1825
1947
  return new TextDecoder().decode(data);
@@ -1849,7 +1971,7 @@ async function convertToAnthropicMessagesPrompt({
1849
1971
  cacheControlValidator,
1850
1972
  toolNameMapping
1851
1973
  }) {
1852
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1974
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1853
1975
  const betas = /* @__PURE__ */ new Set();
1854
1976
  const blocks = groupIntoBlocks(prompt);
1855
1977
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -1857,7 +1979,7 @@ async function convertToAnthropicMessagesPrompt({
1857
1979
  const messages = [];
1858
1980
  async function shouldEnableCitations(providerMetadata) {
1859
1981
  var _a2, _b2;
1860
- const anthropicOptions = await (0, import_provider_utils13.parseProviderOptions)({
1982
+ const anthropicOptions = await (0, import_provider_utils14.parseProviderOptions)({
1861
1983
  provider: "anthropic",
1862
1984
  providerOptions: providerMetadata,
1863
1985
  schema: anthropicFilePartProviderOptions
@@ -1865,7 +1987,7 @@ async function convertToAnthropicMessagesPrompt({
1865
1987
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1866
1988
  }
1867
1989
  async function getDocumentMetadata(providerMetadata) {
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
@@ -1931,7 +2053,7 @@ async function convertToAnthropicMessagesPrompt({
1931
2053
  } : {
1932
2054
  type: "base64",
1933
2055
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1934
- data: (0, import_provider_utils13.convertToBase64)(part.data)
2056
+ data: (0, import_provider_utils14.convertToBase64)(part.data)
1935
2057
  },
1936
2058
  cache_control: cacheControl
1937
2059
  });
@@ -1951,7 +2073,7 @@ async function convertToAnthropicMessagesPrompt({
1951
2073
  } : {
1952
2074
  type: "base64",
1953
2075
  media_type: "application/pdf",
1954
- data: (0, import_provider_utils13.convertToBase64)(part.data)
2076
+ data: (0, import_provider_utils14.convertToBase64)(part.data)
1955
2077
  },
1956
2078
  title: (_b = metadata.title) != null ? _b : part.filename,
1957
2079
  ...metadata.context && { context: metadata.context },
@@ -2089,7 +2211,7 @@ async function convertToAnthropicMessagesPrompt({
2089
2211
  return void 0;
2090
2212
  }
2091
2213
  }
2092
- }).filter(import_provider_utils13.isNonNullable);
2214
+ }).filter(import_provider_utils14.isNonNullable);
2093
2215
  break;
2094
2216
  case "text":
2095
2217
  case "error-text":
@@ -2165,7 +2287,7 @@ async function convertToAnthropicMessagesPrompt({
2165
2287
  }
2166
2288
  case "reasoning": {
2167
2289
  if (sendReasoning) {
2168
- const reasoningMetadata = await (0, import_provider_utils13.parseProviderOptions)({
2290
+ const reasoningMetadata = await (0, import_provider_utils14.parseProviderOptions)({
2169
2291
  provider: "anthropic",
2170
2292
  providerOptions: part.providerOptions,
2171
2293
  schema: anthropicReasoningMetadataSchema
@@ -2371,7 +2493,7 @@ async function convertToAnthropicMessagesPrompt({
2371
2493
  break;
2372
2494
  }
2373
2495
  if (output.value.type === "code_execution_result") {
2374
- const codeExecutionOutput = await (0, import_provider_utils13.validateTypes)({
2496
+ const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2375
2497
  value: output.value,
2376
2498
  schema: codeExecution_20250522OutputSchema
2377
2499
  });
@@ -2387,8 +2509,27 @@ async function convertToAnthropicMessagesPrompt({
2387
2509
  },
2388
2510
  cache_control: cacheControl
2389
2511
  });
2512
+ } else if (output.value.type === "encrypted_code_execution_result") {
2513
+ const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2514
+ value: output.value,
2515
+ schema: codeExecution_20260120OutputSchema
2516
+ });
2517
+ if (codeExecutionOutput.type === "encrypted_code_execution_result") {
2518
+ anthropicContent.push({
2519
+ type: "code_execution_tool_result",
2520
+ tool_use_id: part.toolCallId,
2521
+ content: {
2522
+ type: codeExecutionOutput.type,
2523
+ encrypted_stdout: codeExecutionOutput.encrypted_stdout,
2524
+ stderr: codeExecutionOutput.stderr,
2525
+ return_code: codeExecutionOutput.return_code,
2526
+ content: (_p = codeExecutionOutput.content) != null ? _p : []
2527
+ },
2528
+ cache_control: cacheControl
2529
+ });
2530
+ }
2390
2531
  } else {
2391
- const codeExecutionOutput = await (0, import_provider_utils13.validateTypes)({
2532
+ const codeExecutionOutput = await (0, import_provider_utils14.validateTypes)({
2392
2533
  value: output.value,
2393
2534
  schema: codeExecution_20250825OutputSchema
2394
2535
  });
@@ -2401,7 +2542,7 @@ async function convertToAnthropicMessagesPrompt({
2401
2542
  stdout: codeExecutionOutput.stdout,
2402
2543
  stderr: codeExecutionOutput.stderr,
2403
2544
  return_code: codeExecutionOutput.return_code,
2404
- content: (_p = codeExecutionOutput.content) != null ? _p : []
2545
+ content: (_q = codeExecutionOutput.content) != null ? _q : []
2405
2546
  },
2406
2547
  cache_control: cacheControl
2407
2548
  });
@@ -2434,7 +2575,7 @@ async function convertToAnthropicMessagesPrompt({
2434
2575
  errorValue = output.value;
2435
2576
  }
2436
2577
  } catch (e) {
2437
- const extractedErrorCode = (_q = output.value) == null ? void 0 : _q.errorCode;
2578
+ const extractedErrorCode = (_r = output.value) == null ? void 0 : _r.errorCode;
2438
2579
  errorValue = {
2439
2580
  errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unknown"
2440
2581
  };
@@ -2444,7 +2585,7 @@ async function convertToAnthropicMessagesPrompt({
2444
2585
  tool_use_id: part.toolCallId,
2445
2586
  content: {
2446
2587
  type: "web_fetch_tool_result_error",
2447
- error_code: (_r = errorValue.errorCode) != null ? _r : "unknown"
2588
+ error_code: (_s = errorValue.errorCode) != null ? _s : "unknown"
2448
2589
  },
2449
2590
  cache_control: cacheControl
2450
2591
  });
@@ -2457,7 +2598,7 @@ async function convertToAnthropicMessagesPrompt({
2457
2598
  });
2458
2599
  break;
2459
2600
  }
2460
- const webFetchOutput = await (0, import_provider_utils13.validateTypes)({
2601
+ const webFetchOutput = await (0, import_provider_utils14.validateTypes)({
2461
2602
  value: output.value,
2462
2603
  schema: webFetch_20250910OutputSchema
2463
2604
  });
@@ -2492,7 +2633,7 @@ async function convertToAnthropicMessagesPrompt({
2492
2633
  });
2493
2634
  break;
2494
2635
  }
2495
- const webSearchOutput = await (0, import_provider_utils13.validateTypes)({
2636
+ const webSearchOutput = await (0, import_provider_utils14.validateTypes)({
2496
2637
  value: output.value,
2497
2638
  schema: webSearch_20250305OutputSchema
2498
2639
  });
@@ -2519,7 +2660,7 @@ async function convertToAnthropicMessagesPrompt({
2519
2660
  });
2520
2661
  break;
2521
2662
  }
2522
- const toolSearchOutput = await (0, import_provider_utils13.validateTypes)({
2663
+ const toolSearchOutput = await (0, import_provider_utils14.validateTypes)({
2523
2664
  value: output.value,
2524
2665
  schema: toolSearchRegex_20251119OutputSchema
2525
2666
  });
@@ -2683,7 +2824,7 @@ var AnthropicMessagesLanguageModel = class {
2683
2824
  var _a;
2684
2825
  this.modelId = modelId;
2685
2826
  this.config = config;
2686
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils14.generateId;
2827
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils15.generateId;
2687
2828
  }
2688
2829
  supportsUrl(url) {
2689
2830
  return url.protocol === "https:";
@@ -2721,7 +2862,7 @@ var AnthropicMessagesLanguageModel = class {
2721
2862
  providerOptions,
2722
2863
  stream
2723
2864
  }) {
2724
- var _a, _b, _c, _d, _e, _f;
2865
+ var _a, _b, _c, _d, _e, _f, _g;
2725
2866
  const warnings = [];
2726
2867
  if (frequencyPenalty != null) {
2727
2868
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2757,12 +2898,12 @@ var AnthropicMessagesLanguageModel = class {
2757
2898
  }
2758
2899
  }
2759
2900
  const providerOptionsName = this.providerOptionsName;
2760
- const canonicalOptions = await (0, import_provider_utils14.parseProviderOptions)({
2901
+ const canonicalOptions = await (0, import_provider_utils15.parseProviderOptions)({
2761
2902
  provider: "anthropic",
2762
2903
  providerOptions,
2763
2904
  schema: anthropicLanguageModelOptions
2764
2905
  });
2765
- const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils14.parseProviderOptions)({
2906
+ const customProviderOptions = providerOptionsName !== "anthropic" ? await (0, import_provider_utils15.parseProviderOptions)({
2766
2907
  provider: providerOptionsName,
2767
2908
  providerOptions,
2768
2909
  schema: anthropicLanguageModelOptions
@@ -2789,7 +2930,7 @@ var AnthropicMessagesLanguageModel = class {
2789
2930
  } : void 0;
2790
2931
  const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
2791
2932
  const cacheControlValidator = new CacheControlValidator();
2792
- const toolNameMapping = (0, import_provider_utils14.createToolNameMapping)({
2933
+ const toolNameMapping = (0, import_provider_utils15.createToolNameMapping)({
2793
2934
  tools,
2794
2935
  providerToolNames: {
2795
2936
  "anthropic.code_execution_20250522": "code_execution",
@@ -3061,7 +3202,12 @@ var AnthropicMessagesLanguageModel = class {
3061
3202
  // do not send when not streaming
3062
3203
  },
3063
3204
  warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
3064
- betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas, ...userSuppliedBetas]),
3205
+ betas: /* @__PURE__ */ new Set([
3206
+ ...betas,
3207
+ ...toolsBetas,
3208
+ ...userSuppliedBetas,
3209
+ ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
3210
+ ]),
3065
3211
  usesJsonResponseTool: jsonResponseTool != null,
3066
3212
  toolNameMapping,
3067
3213
  providerOptionsName,
@@ -3072,15 +3218,15 @@ var AnthropicMessagesLanguageModel = class {
3072
3218
  betas,
3073
3219
  headers
3074
3220
  }) {
3075
- return (0, import_provider_utils14.combineHeaders)(
3076
- await (0, import_provider_utils14.resolve)(this.config.headers),
3221
+ return (0, import_provider_utils15.combineHeaders)(
3222
+ await (0, import_provider_utils15.resolve)(this.config.headers),
3077
3223
  headers,
3078
3224
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
3079
3225
  );
3080
3226
  }
3081
3227
  async getBetasFromHeaders(requestHeaders) {
3082
3228
  var _a, _b;
3083
- const configHeaders = await (0, import_provider_utils14.resolve)(this.config.headers);
3229
+ const configHeaders = await (0, import_provider_utils15.resolve)(this.config.headers);
3084
3230
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
3085
3231
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
3086
3232
  return new Set(
@@ -3094,9 +3240,9 @@ var AnthropicMessagesLanguageModel = class {
3094
3240
  var _a, _b, _c;
3095
3241
  return (_c = (_b = (_a = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
3096
3242
  }
3097
- transformRequestBody(args) {
3243
+ transformRequestBody(args, betas) {
3098
3244
  var _a, _b, _c;
3099
- return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args)) != null ? _c : args;
3245
+ return (_c = (_b = (_a = this.config).transformRequestBody) == null ? void 0 : _b.call(_a, args, betas)) != null ? _c : args;
3100
3246
  }
3101
3247
  extractCitationDocuments(prompt) {
3102
3248
  const isCitationPart = (part) => {
@@ -3122,7 +3268,7 @@ var AnthropicMessagesLanguageModel = class {
3122
3268
  });
3123
3269
  }
3124
3270
  async doGenerate(options) {
3125
- var _a, _b, _c, _d, _e, _f;
3271
+ var _a, _b, _c, _d, _e, _f, _g;
3126
3272
  const {
3127
3273
  args,
3128
3274
  warnings,
@@ -3146,12 +3292,12 @@ var AnthropicMessagesLanguageModel = class {
3146
3292
  responseHeaders,
3147
3293
  value: response,
3148
3294
  rawValue: rawResponse
3149
- } = await (0, import_provider_utils14.postJsonToApi)({
3295
+ } = await (0, import_provider_utils15.postJsonToApi)({
3150
3296
  url: this.buildRequestUrl(false),
3151
3297
  headers: await this.getHeaders({ betas, headers: options.headers }),
3152
- body: this.transformRequestBody(args),
3298
+ body: this.transformRequestBody(args, betas),
3153
3299
  failedResponseHandler: anthropicFailedResponseHandler,
3154
- successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
3300
+ successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3155
3301
  anthropicMessagesResponseSchema
3156
3302
  ),
3157
3303
  abortSignal: options.abortSignal,
@@ -3410,6 +3556,19 @@ var AnthropicMessagesLanguageModel = class {
3410
3556
  content: (_c = part.content.content) != null ? _c : []
3411
3557
  }
3412
3558
  });
3559
+ } else if (part.content.type === "encrypted_code_execution_result") {
3560
+ content.push({
3561
+ type: "tool-result",
3562
+ toolCallId: part.tool_use_id,
3563
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
3564
+ result: {
3565
+ type: part.content.type,
3566
+ encrypted_stdout: part.content.encrypted_stdout,
3567
+ stderr: part.content.stderr,
3568
+ return_code: part.content.return_code,
3569
+ content: (_d = part.content.content) != null ? _d : []
3570
+ }
3571
+ });
3413
3572
  } else if (part.content.type === "code_execution_tool_result_error") {
3414
3573
  content.push({
3415
3574
  type: "tool-result",
@@ -3486,13 +3645,13 @@ var AnthropicMessagesLanguageModel = class {
3486
3645
  finishReason: response.stop_reason,
3487
3646
  isJsonResponseFromTool
3488
3647
  }),
3489
- raw: (_d = response.stop_reason) != null ? _d : void 0
3648
+ raw: (_e = response.stop_reason) != null ? _e : void 0
3490
3649
  },
3491
3650
  usage: convertAnthropicMessagesUsage({ usage: response.usage }),
3492
3651
  request: { body: args },
3493
3652
  response: {
3494
- id: (_e = response.id) != null ? _e : void 0,
3495
- modelId: (_f = response.model) != null ? _f : void 0,
3653
+ id: (_f = response.id) != null ? _f : void 0,
3654
+ modelId: (_g = response.model) != null ? _g : void 0,
3496
3655
  headers: responseHeaders,
3497
3656
  body: rawResponse
3498
3657
  },
@@ -3553,12 +3712,12 @@ var AnthropicMessagesLanguageModel = class {
3553
3712
  body.tools
3554
3713
  );
3555
3714
  const url = this.buildRequestUrl(true);
3556
- const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
3715
+ const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
3557
3716
  url,
3558
3717
  headers: await this.getHeaders({ betas, headers: options.headers }),
3559
- body: this.transformRequestBody(body),
3718
+ body: this.transformRequestBody(body, betas),
3560
3719
  failedResponseHandler: anthropicFailedResponseHandler,
3561
- successfulResponseHandler: (0, import_provider_utils14.createEventSourceResponseHandler)(
3720
+ successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3562
3721
  anthropicMessagesChunkSchema
3563
3722
  ),
3564
3723
  abortSignal: options.abortSignal,
@@ -3592,7 +3751,7 @@ var AnthropicMessagesLanguageModel = class {
3592
3751
  controller.enqueue({ type: "stream-start", warnings });
3593
3752
  },
3594
3753
  transform(chunk, controller) {
3595
- var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
3754
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
3596
3755
  if (options.includeRawChunks) {
3597
3756
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3598
3757
  }
@@ -3842,6 +4001,19 @@ var AnthropicMessagesLanguageModel = class {
3842
4001
  content: (_c = part.content.content) != null ? _c : []
3843
4002
  }
3844
4003
  });
4004
+ } else if (part.content.type === "encrypted_code_execution_result") {
4005
+ controller.enqueue({
4006
+ type: "tool-result",
4007
+ toolCallId: part.tool_use_id,
4008
+ toolName: toolNameMapping.toCustomToolName("code_execution"),
4009
+ result: {
4010
+ type: part.content.type,
4011
+ encrypted_stdout: part.content.encrypted_stdout,
4012
+ stderr: part.content.stderr,
4013
+ return_code: part.content.return_code,
4014
+ content: (_d = part.content.content) != null ? _d : []
4015
+ }
4016
+ });
3845
4017
  } else if (part.content.type === "code_execution_tool_result_error") {
3846
4018
  controller.enqueue({
3847
4019
  type: "tool-result",
@@ -4109,12 +4281,12 @@ var AnthropicMessagesLanguageModel = class {
4109
4281
  }
4110
4282
  case "message_start": {
4111
4283
  usage.input_tokens = value.message.usage.input_tokens;
4112
- usage.cache_read_input_tokens = (_d = value.message.usage.cache_read_input_tokens) != null ? _d : 0;
4113
- usage.cache_creation_input_tokens = (_e = value.message.usage.cache_creation_input_tokens) != null ? _e : 0;
4284
+ usage.cache_read_input_tokens = (_e = value.message.usage.cache_read_input_tokens) != null ? _e : 0;
4285
+ usage.cache_creation_input_tokens = (_f = value.message.usage.cache_creation_input_tokens) != null ? _f : 0;
4114
4286
  rawUsage = {
4115
4287
  ...value.message.usage
4116
4288
  };
4117
- cacheCreationInputTokens = (_f = value.message.usage.cache_creation_input_tokens) != null ? _f : null;
4289
+ cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
4118
4290
  if (value.message.container != null) {
4119
4291
  container = {
4120
4292
  expiresAt: value.message.container.expires_at,
@@ -4133,8 +4305,8 @@ var AnthropicMessagesLanguageModel = class {
4133
4305
  }
4134
4306
  controller.enqueue({
4135
4307
  type: "response-metadata",
4136
- id: (_g = value.message.id) != null ? _g : void 0,
4137
- modelId: (_h = value.message.model) != null ? _h : void 0
4308
+ id: (_h = value.message.id) != null ? _h : void 0,
4309
+ modelId: (_i = value.message.model) != null ? _i : void 0
4138
4310
  });
4139
4311
  if (value.message.content != null) {
4140
4312
  for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
@@ -4150,7 +4322,7 @@ var AnthropicMessagesLanguageModel = class {
4150
4322
  id: part.id,
4151
4323
  toolName: part.name
4152
4324
  });
4153
- const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
4325
+ const inputStr = JSON.stringify((_j = part.input) != null ? _j : {});
4154
4326
  controller.enqueue({
4155
4327
  type: "tool-input-delta",
4156
4328
  id: part.id,
@@ -4198,17 +4370,17 @@ var AnthropicMessagesLanguageModel = class {
4198
4370
  finishReason: value.delta.stop_reason,
4199
4371
  isJsonResponseFromTool
4200
4372
  }),
4201
- raw: (_j = value.delta.stop_reason) != null ? _j : void 0
4373
+ raw: (_k = value.delta.stop_reason) != null ? _k : void 0
4202
4374
  };
4203
- stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
4375
+ stopSequence = (_l = value.delta.stop_sequence) != null ? _l : null;
4204
4376
  container = value.delta.container != null ? {
4205
4377
  expiresAt: value.delta.container.expires_at,
4206
4378
  id: value.delta.container.id,
4207
- skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
4379
+ skills: (_n = (_m = value.delta.container.skills) == null ? void 0 : _m.map((skill) => ({
4208
4380
  type: skill.type,
4209
4381
  skillId: skill.skill_id,
4210
4382
  version: skill.version
4211
- }))) != null ? _m : null
4383
+ }))) != null ? _n : null
4212
4384
  } : null;
4213
4385
  if (value.context_management) {
4214
4386
  contextManagement = mapAnthropicResponseContextManagement(
@@ -4382,25 +4554,9 @@ function mapAnthropicResponseContextManagement(contextManagement) {
4382
4554
  }
4383
4555
 
4384
4556
  // src/tool/bash_20241022.ts
4385
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
4386
- var import_v412 = require("zod/v4");
4387
- var bash_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
4388
- () => (0, import_provider_utils15.zodSchema)(
4389
- import_v412.z.object({
4390
- command: import_v412.z.string(),
4391
- restart: import_v412.z.boolean().optional()
4392
- })
4393
- )
4394
- );
4395
- var bash_20241022 = (0, import_provider_utils15.createProviderToolFactory)({
4396
- id: "anthropic.bash_20241022",
4397
- inputSchema: bash_20241022InputSchema
4398
- });
4399
-
4400
- // src/tool/bash_20250124.ts
4401
4557
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
4402
4558
  var import_v413 = require("zod/v4");
4403
- var bash_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
4559
+ var bash_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
4404
4560
  () => (0, import_provider_utils16.zodSchema)(
4405
4561
  import_v413.z.object({
4406
4562
  command: import_v413.z.string(),
@@ -4408,115 +4564,26 @@ var bash_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
4408
4564
  })
4409
4565
  )
4410
4566
  );
4411
- var bash_20250124 = (0, import_provider_utils16.createProviderToolFactory)({
4412
- id: "anthropic.bash_20250124",
4413
- inputSchema: bash_20250124InputSchema
4567
+ var bash_20241022 = (0, import_provider_utils16.createProviderToolFactory)({
4568
+ id: "anthropic.bash_20241022",
4569
+ inputSchema: bash_20241022InputSchema
4414
4570
  });
4415
4571
 
4416
- // src/tool/code-execution_20260120.ts
4572
+ // src/tool/bash_20250124.ts
4417
4573
  var import_provider_utils17 = require("@ai-sdk/provider-utils");
4418
4574
  var import_v414 = require("zod/v4");
4419
- var codeExecution_20260120OutputSchema = (0, import_provider_utils17.lazySchema)(
4420
- () => (0, import_provider_utils17.zodSchema)(
4421
- import_v414.z.discriminatedUnion("type", [
4422
- import_v414.z.object({
4423
- type: import_v414.z.literal("code_execution_result"),
4424
- stdout: import_v414.z.string(),
4425
- stderr: import_v414.z.string(),
4426
- return_code: import_v414.z.number(),
4427
- content: import_v414.z.array(
4428
- import_v414.z.object({
4429
- type: import_v414.z.literal("code_execution_output"),
4430
- file_id: import_v414.z.string()
4431
- })
4432
- ).optional().default([])
4433
- }),
4434
- import_v414.z.object({
4435
- type: import_v414.z.literal("bash_code_execution_result"),
4436
- content: import_v414.z.array(
4437
- import_v414.z.object({
4438
- type: import_v414.z.literal("bash_code_execution_output"),
4439
- file_id: import_v414.z.string()
4440
- })
4441
- ),
4442
- stdout: import_v414.z.string(),
4443
- stderr: import_v414.z.string(),
4444
- return_code: import_v414.z.number()
4445
- }),
4446
- import_v414.z.object({
4447
- type: import_v414.z.literal("bash_code_execution_tool_result_error"),
4448
- error_code: import_v414.z.string()
4449
- }),
4450
- import_v414.z.object({
4451
- type: import_v414.z.literal("text_editor_code_execution_tool_result_error"),
4452
- error_code: import_v414.z.string()
4453
- }),
4454
- import_v414.z.object({
4455
- type: import_v414.z.literal("text_editor_code_execution_view_result"),
4456
- content: import_v414.z.string(),
4457
- file_type: import_v414.z.string(),
4458
- num_lines: import_v414.z.number().nullable(),
4459
- start_line: import_v414.z.number().nullable(),
4460
- total_lines: import_v414.z.number().nullable()
4461
- }),
4462
- import_v414.z.object({
4463
- type: import_v414.z.literal("text_editor_code_execution_create_result"),
4464
- is_file_update: import_v414.z.boolean()
4465
- }),
4466
- import_v414.z.object({
4467
- type: import_v414.z.literal("text_editor_code_execution_str_replace_result"),
4468
- lines: import_v414.z.array(import_v414.z.string()).nullable(),
4469
- new_lines: import_v414.z.number().nullable(),
4470
- new_start: import_v414.z.number().nullable(),
4471
- old_lines: import_v414.z.number().nullable(),
4472
- old_start: import_v414.z.number().nullable()
4473
- })
4474
- ])
4475
- )
4476
- );
4477
- var codeExecution_20260120InputSchema = (0, import_provider_utils17.lazySchema)(
4575
+ var bash_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
4478
4576
  () => (0, import_provider_utils17.zodSchema)(
4479
- import_v414.z.discriminatedUnion("type", [
4480
- import_v414.z.object({
4481
- type: import_v414.z.literal("programmatic-tool-call"),
4482
- code: import_v414.z.string()
4483
- }),
4484
- import_v414.z.object({
4485
- type: import_v414.z.literal("bash_code_execution"),
4486
- command: import_v414.z.string()
4487
- }),
4488
- import_v414.z.discriminatedUnion("command", [
4489
- import_v414.z.object({
4490
- type: import_v414.z.literal("text_editor_code_execution"),
4491
- command: import_v414.z.literal("view"),
4492
- path: import_v414.z.string()
4493
- }),
4494
- import_v414.z.object({
4495
- type: import_v414.z.literal("text_editor_code_execution"),
4496
- command: import_v414.z.literal("create"),
4497
- path: import_v414.z.string(),
4498
- file_text: import_v414.z.string().nullish()
4499
- }),
4500
- import_v414.z.object({
4501
- type: import_v414.z.literal("text_editor_code_execution"),
4502
- command: import_v414.z.literal("str_replace"),
4503
- path: import_v414.z.string(),
4504
- old_str: import_v414.z.string(),
4505
- new_str: import_v414.z.string()
4506
- })
4507
- ])
4508
- ])
4577
+ import_v414.z.object({
4578
+ command: import_v414.z.string(),
4579
+ restart: import_v414.z.boolean().optional()
4580
+ })
4509
4581
  )
4510
4582
  );
4511
- var factory9 = (0, import_provider_utils17.createProviderToolFactoryWithOutputSchema)({
4512
- id: "anthropic.code_execution_20260120",
4513
- inputSchema: codeExecution_20260120InputSchema,
4514
- outputSchema: codeExecution_20260120OutputSchema,
4515
- supportsDeferredResults: true
4583
+ var bash_20250124 = (0, import_provider_utils17.createProviderToolFactory)({
4584
+ id: "anthropic.bash_20250124",
4585
+ inputSchema: bash_20250124InputSchema
4516
4586
  });
4517
- var codeExecution_20260120 = (args = {}) => {
4518
- return factory9(args);
4519
- };
4520
4587
 
4521
4588
  // src/tool/computer_20241022.ts
4522
4589
  var import_provider_utils18 = require("@ai-sdk/provider-utils");