@ai-sdk/anthropic 2.0.28 → 2.0.30

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,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.30
4
+
5
+ ### Patch Changes
6
+
7
+ - 650287f: chore: add model ID for Haiku 4.5
8
+
9
+ ## 2.0.29
10
+
11
+ ### Patch Changes
12
+
13
+ - 4dd53dd: feat(provider/anthropic): memory tool
14
+
3
15
  ## 2.0.28
4
16
 
5
17
  ### 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-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-0' | 'claude-sonnet-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-haiku-20240307' | (string & {});
6
+ type AnthropicMessagesModelId = 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-0' | 'claude-sonnet-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | '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<{
@@ -219,6 +219,42 @@ declare const anthropicTools: {
219
219
  displayHeightPx: number;
220
220
  displayNumber?: number;
221
221
  }>;
222
+ /**
223
+ * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
224
+ * Claude can create, read, update, and delete files that persist between sessions,
225
+ * allowing it to build knowledge over time without keeping everything in the context window.
226
+ * The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
227
+ *
228
+ * Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
229
+ *
230
+ * Tool name must be `memory`.
231
+ */
232
+ memory_20250818: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
233
+ command: "view";
234
+ path: string;
235
+ view_range?: [number, number];
236
+ } | {
237
+ command: "create";
238
+ path: string;
239
+ file_text: string;
240
+ } | {
241
+ command: "str_replace";
242
+ path: string;
243
+ old_str: string;
244
+ new_str: string;
245
+ } | {
246
+ command: "insert";
247
+ path: string;
248
+ insert_line: number;
249
+ insert_text: string;
250
+ } | {
251
+ command: "delete";
252
+ path: string;
253
+ } | {
254
+ command: "rename";
255
+ old_path: string;
256
+ new_path: string;
257
+ }, {}>;
222
258
  /**
223
259
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
224
260
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
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-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-0' | 'claude-sonnet-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-haiku-20240307' | (string & {});
6
+ type AnthropicMessagesModelId = 'claude-haiku-4-5' | 'claude-haiku-4-5-20251001' | 'claude-sonnet-4-5' | 'claude-sonnet-4-5-20250929' | 'claude-opus-4-1' | 'claude-opus-4-0' | 'claude-sonnet-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'claude-3-7-sonnet-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | '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<{
@@ -219,6 +219,42 @@ declare const anthropicTools: {
219
219
  displayHeightPx: number;
220
220
  displayNumber?: number;
221
221
  }>;
222
+ /**
223
+ * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
224
+ * Claude can create, read, update, and delete files that persist between sessions,
225
+ * allowing it to build knowledge over time without keeping everything in the context window.
226
+ * The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
227
+ *
228
+ * Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
229
+ *
230
+ * Tool name must be `memory`.
231
+ */
232
+ memory_20250818: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
233
+ command: "view";
234
+ path: string;
235
+ view_range?: [number, number];
236
+ } | {
237
+ command: "create";
238
+ path: string;
239
+ file_text: string;
240
+ } | {
241
+ command: "str_replace";
242
+ path: string;
243
+ old_str: string;
244
+ new_str: string;
245
+ } | {
246
+ command: "insert";
247
+ path: string;
248
+ insert_line: number;
249
+ insert_text: string;
250
+ } | {
251
+ command: "delete";
252
+ path: string;
253
+ } | {
254
+ command: "rename";
255
+ old_path: string;
256
+ new_path: string;
257
+ }, {}>;
222
258
  /**
223
259
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
224
260
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
package/dist/index.js CHANGED
@@ -28,10 +28,10 @@ module.exports = __toCommonJS(src_exports);
28
28
 
29
29
  // src/anthropic-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
31
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "2.0.28" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.30" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -814,6 +814,14 @@ async function prepareTools({
814
814
  });
815
815
  break;
816
816
  }
817
+ case "anthropic.memory_20250818": {
818
+ betas.add("context-management-2025-06-27");
819
+ anthropicTools2.push({
820
+ name: "memory",
821
+ type: "memory_20250818"
822
+ });
823
+ break;
824
+ }
817
825
  case "anthropic.web_fetch_20250910": {
818
826
  betas.add("web-fetch-2025-09-10");
819
827
  const args = await (0, import_provider_utils7.validateTypes)({
@@ -2625,32 +2633,56 @@ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFac
2625
2633
  inputSchema: computer_20250124InputSchema
2626
2634
  });
2627
2635
 
2628
- // src/tool/text-editor_20241022.ts
2636
+ // src/tool/memory_20250818.ts
2629
2637
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
2630
2638
  var import_v413 = require("zod/v4");
2631
- var textEditor_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
2639
+ var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
2632
2640
  () => (0, import_provider_utils16.zodSchema)(
2633
- import_v413.z.object({
2634
- command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2635
- path: import_v413.z.string(),
2636
- file_text: import_v413.z.string().optional(),
2637
- insert_line: import_v413.z.number().int().optional(),
2638
- new_str: import_v413.z.string().optional(),
2639
- old_str: import_v413.z.string().optional(),
2640
- view_range: import_v413.z.array(import_v413.z.number().int()).optional()
2641
- })
2641
+ import_v413.z.discriminatedUnion("command", [
2642
+ import_v413.z.object({
2643
+ command: import_v413.z.literal("view"),
2644
+ path: import_v413.z.string(),
2645
+ view_range: import_v413.z.tuple([import_v413.z.number(), import_v413.z.number()]).optional()
2646
+ }),
2647
+ import_v413.z.object({
2648
+ command: import_v413.z.literal("create"),
2649
+ path: import_v413.z.string(),
2650
+ file_text: import_v413.z.string()
2651
+ }),
2652
+ import_v413.z.object({
2653
+ command: import_v413.z.literal("str_replace"),
2654
+ path: import_v413.z.string(),
2655
+ old_str: import_v413.z.string(),
2656
+ new_str: import_v413.z.string()
2657
+ }),
2658
+ import_v413.z.object({
2659
+ command: import_v413.z.literal("insert"),
2660
+ path: import_v413.z.string(),
2661
+ insert_line: import_v413.z.number(),
2662
+ insert_text: import_v413.z.string()
2663
+ }),
2664
+ import_v413.z.object({
2665
+ command: import_v413.z.literal("delete"),
2666
+ path: import_v413.z.string()
2667
+ }),
2668
+ import_v413.z.object({
2669
+ command: import_v413.z.literal("rename"),
2670
+ old_path: import_v413.z.string(),
2671
+ new_path: import_v413.z.string()
2672
+ })
2673
+ ])
2642
2674
  )
2643
2675
  );
2644
- var textEditor_20241022 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2645
- id: "anthropic.text_editor_20241022",
2646
- name: "str_replace_editor",
2647
- inputSchema: textEditor_20241022InputSchema
2676
+ var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2677
+ id: "anthropic.memory_20250818",
2678
+ name: "memory",
2679
+ inputSchema: memory_20250818InputSchema
2648
2680
  });
2649
2681
 
2650
- // src/tool/text-editor_20250124.ts
2682
+ // src/tool/text-editor_20241022.ts
2651
2683
  var import_provider_utils17 = require("@ai-sdk/provider-utils");
2652
2684
  var import_v414 = require("zod/v4");
2653
- var textEditor_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
2685
+ var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
2654
2686
  () => (0, import_provider_utils17.zodSchema)(
2655
2687
  import_v414.z.object({
2656
2688
  command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -2663,19 +2695,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
2663
2695
  })
2664
2696
  )
2665
2697
  );
2666
- var textEditor_20250124 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2667
- id: "anthropic.text_editor_20250124",
2698
+ var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2699
+ id: "anthropic.text_editor_20241022",
2668
2700
  name: "str_replace_editor",
2669
- inputSchema: textEditor_20250124InputSchema
2701
+ inputSchema: textEditor_20241022InputSchema
2670
2702
  });
2671
2703
 
2672
- // src/tool/text-editor_20250429.ts
2704
+ // src/tool/text-editor_20250124.ts
2673
2705
  var import_provider_utils18 = require("@ai-sdk/provider-utils");
2674
2706
  var import_v415 = require("zod/v4");
2675
- var textEditor_20250429InputSchema = (0, import_provider_utils18.lazySchema)(
2707
+ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
2676
2708
  () => (0, import_provider_utils18.zodSchema)(
2677
2709
  import_v415.z.object({
2678
- command: import_v415.z.enum(["view", "create", "str_replace", "insert"]),
2710
+ command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2679
2711
  path: import_v415.z.string(),
2680
2712
  file_text: import_v415.z.string().optional(),
2681
2713
  insert_line: import_v415.z.number().int().optional(),
@@ -2685,7 +2717,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils18.lazySchema)(
2685
2717
  })
2686
2718
  )
2687
2719
  );
2688
- var textEditor_20250429 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
2720
+ var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
2721
+ id: "anthropic.text_editor_20250124",
2722
+ name: "str_replace_editor",
2723
+ inputSchema: textEditor_20250124InputSchema
2724
+ });
2725
+
2726
+ // src/tool/text-editor_20250429.ts
2727
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
2728
+ var import_v416 = require("zod/v4");
2729
+ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
2730
+ () => (0, import_provider_utils19.zodSchema)(
2731
+ import_v416.z.object({
2732
+ command: import_v416.z.enum(["view", "create", "str_replace", "insert"]),
2733
+ path: import_v416.z.string(),
2734
+ file_text: import_v416.z.string().optional(),
2735
+ insert_line: import_v416.z.number().int().optional(),
2736
+ new_str: import_v416.z.string().optional(),
2737
+ old_str: import_v416.z.string().optional(),
2738
+ view_range: import_v416.z.array(import_v416.z.number().int()).optional()
2739
+ })
2740
+ )
2741
+ );
2742
+ var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
2689
2743
  id: "anthropic.text_editor_20250429",
2690
2744
  name: "str_replace_based_edit_tool",
2691
2745
  inputSchema: textEditor_20250429InputSchema
@@ -2761,6 +2815,17 @@ var anthropicTools = {
2761
2815
  * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
2762
2816
  */
2763
2817
  computer_20250124,
2818
+ /**
2819
+ * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
2820
+ * Claude can create, read, update, and delete files that persist between sessions,
2821
+ * allowing it to build knowledge over time without keeping everything in the context window.
2822
+ * The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
2823
+ *
2824
+ * Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
2825
+ *
2826
+ * Tool name must be `memory`.
2827
+ */
2828
+ memory_20250818,
2764
2829
  /**
2765
2830
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2766
2831
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
@@ -2835,11 +2900,11 @@ var anthropicTools = {
2835
2900
  // src/anthropic-provider.ts
2836
2901
  function createAnthropic(options = {}) {
2837
2902
  var _a;
2838
- const baseURL = (_a = (0, import_provider_utils19.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2839
- const getHeaders = () => (0, import_provider_utils19.withUserAgentSuffix)(
2903
+ const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2904
+ const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
2840
2905
  {
2841
2906
  "anthropic-version": "2023-06-01",
2842
- "x-api-key": (0, import_provider_utils19.loadApiKey)({
2907
+ "x-api-key": (0, import_provider_utils20.loadApiKey)({
2843
2908
  apiKey: options.apiKey,
2844
2909
  environmentVariableName: "ANTHROPIC_API_KEY",
2845
2910
  description: "Anthropic"
@@ -2855,7 +2920,7 @@ function createAnthropic(options = {}) {
2855
2920
  baseURL,
2856
2921
  headers: getHeaders,
2857
2922
  fetch: options.fetch,
2858
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils19.generateId,
2923
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils20.generateId,
2859
2924
  supportedUrls: () => ({
2860
2925
  "image/*": [/^https?:\/\/.*$/]
2861
2926
  })