@ai-sdk/anthropic 2.0.0-beta.3 → 2.0.0-beta.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - b9ddcdd: feat(anthropic): add text_editor_20250429 tool for Claude 4 models
8
+
9
+ ## 2.0.0-beta.4
10
+
11
+ ### Patch Changes
12
+
13
+ - fdff8a4: fix(provider/anthropic): correct Claude 4 model ID format
14
+ - 84577c8: fix (providers/anthropic): remove fine grained tool streaming beta
15
+
3
16
  ## 2.0.0-beta.3
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- type AnthropicMessagesModelId = 'claude-4-opus-20250514' | 'claude-4-sonnet-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
6
+ type AnthropicMessagesModelId = 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
7
7
  declare const anthropicProviderOptions: z.ZodObject<{
8
8
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
9
9
  thinking: z.ZodOptional<z.ZodObject<{
@@ -60,6 +60,19 @@ declare const anthropicTools: {
60
60
  old_str?: string;
61
61
  view_range?: number[];
62
62
  }, {}>;
63
+ /**
64
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
65
+ * Note: This version does not support the "undo_edit" command.
66
+ */
67
+ textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
68
+ command: "view" | "create" | "str_replace" | "insert";
69
+ path: string;
70
+ file_text?: string;
71
+ insert_line?: number;
72
+ new_str?: string;
73
+ old_str?: string;
74
+ view_range?: number[];
75
+ }, {}>;
63
76
  /**
64
77
  * Creates a tool for executing actions on a computer. Must have name "computer".
65
78
  *
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- type AnthropicMessagesModelId = 'claude-4-opus-20250514' | 'claude-4-sonnet-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
6
+ type AnthropicMessagesModelId = 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
7
7
  declare const anthropicProviderOptions: z.ZodObject<{
8
8
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
9
9
  thinking: z.ZodOptional<z.ZodObject<{
@@ -60,6 +60,19 @@ declare const anthropicTools: {
60
60
  old_str?: string;
61
61
  view_range?: number[];
62
62
  }, {}>;
63
+ /**
64
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
65
+ * Note: This version does not support the "undo_edit" command.
66
+ */
67
+ textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
68
+ command: "view" | "create" | "str_replace" | "insert";
69
+ path: string;
70
+ file_text?: string;
71
+ insert_line?: number;
72
+ new_str?: string;
73
+ old_str?: string;
74
+ view_range?: number[];
75
+ }, {}>;
63
76
  /**
64
77
  * Creates a tool for executing actions on a computer. Must have name "computer".
65
78
  *
package/dist/index.js CHANGED
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(src_exports);
37
37
 
38
38
  // src/anthropic-provider.ts
39
39
  var import_provider4 = require("@ai-sdk/provider");
40
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
40
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
41
41
 
42
42
  // src/anthropic-messages-language-model.ts
43
43
  var import_provider3 = require("@ai-sdk/provider");
@@ -207,6 +207,13 @@ function prepareTools({
207
207
  type: "text_editor_20241022"
208
208
  });
209
209
  break;
210
+ case "anthropic.text_editor_20250429":
211
+ betas.add("computer-use-2025-01-24");
212
+ anthropicTools2.push({
213
+ name: "str_replace_based_edit_tool",
214
+ type: "text_editor_20250429"
215
+ });
216
+ break;
210
217
  case "anthropic.bash_20250124":
211
218
  betas.add("computer-use-2025-01-24");
212
219
  anthropicTools2.push({
@@ -951,11 +958,7 @@ var AnthropicMessagesLanguageModel = class {
951
958
  tool_choice: anthropicToolChoice
952
959
  },
953
960
  warnings: [...warnings, ...toolWarnings],
954
- betas: /* @__PURE__ */ new Set([
955
- "fine-grained-tool-streaming-2025-05-14",
956
- ...messagesBetas,
957
- ...toolsBetas
958
- ]),
961
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
959
962
  usesJsonResponseTool: jsonResponseTool != null
960
963
  };
961
964
  }
@@ -1792,6 +1795,23 @@ var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolF
1792
1795
  })
1793
1796
  });
1794
1797
 
1798
+ // src/tool/text-editor_20250429.ts
1799
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1800
+ var import_v411 = require("zod/v4");
1801
+ var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1802
+ id: "anthropic.text_editor_20250429",
1803
+ name: "str_replace_based_edit_tool",
1804
+ inputSchema: import_v411.z.object({
1805
+ command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
1806
+ path: import_v411.z.string(),
1807
+ file_text: import_v411.z.string().optional(),
1808
+ insert_line: import_v411.z.number().int().optional(),
1809
+ new_str: import_v411.z.string().optional(),
1810
+ old_str: import_v411.z.string().optional(),
1811
+ view_range: import_v411.z.array(import_v411.z.number().int()).optional()
1812
+ })
1813
+ });
1814
+
1795
1815
  // src/anthropic-tools.ts
1796
1816
  var anthropicTools = {
1797
1817
  /**
@@ -1818,6 +1838,11 @@ var anthropicTools = {
1818
1838
  * Creates a tool for editing text. Must have name "str_replace_editor".
1819
1839
  */
1820
1840
  textEditor_20250124,
1841
+ /**
1842
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
1843
+ * Note: This version does not support the "undo_edit" command.
1844
+ */
1845
+ textEditor_20250429,
1821
1846
  /**
1822
1847
  * Creates a tool for executing actions on a computer. Must have name "computer".
1823
1848
  *
@@ -1854,10 +1879,10 @@ var anthropicTools = {
1854
1879
  // src/anthropic-provider.ts
1855
1880
  function createAnthropic(options = {}) {
1856
1881
  var _a;
1857
- const baseURL = (_a = (0, import_provider_utils11.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
1882
+ const baseURL = (_a = (0, import_provider_utils12.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
1858
1883
  const getHeaders = () => ({
1859
1884
  "anthropic-version": "2023-06-01",
1860
- "x-api-key": (0, import_provider_utils11.loadApiKey)({
1885
+ "x-api-key": (0, import_provider_utils12.loadApiKey)({
1861
1886
  apiKey: options.apiKey,
1862
1887
  environmentVariableName: "ANTHROPIC_API_KEY",
1863
1888
  description: "Anthropic"
@@ -1871,7 +1896,7 @@ function createAnthropic(options = {}) {
1871
1896
  baseURL,
1872
1897
  headers: getHeaders,
1873
1898
  fetch: options.fetch,
1874
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils11.generateId,
1899
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils12.generateId,
1875
1900
  supportedUrls: () => ({
1876
1901
  "image/*": [/^https?:\/\/.*$/]
1877
1902
  })