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

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,93 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.1.0-beta.11
4
+
5
+ ### Patch Changes
6
+
7
+ - e8109d3: feat: tool execution approval
8
+ - Updated dependencies [046aa3b]
9
+ - Updated dependencies [e8109d3]
10
+ - @ai-sdk/provider@2.1.0-beta.5
11
+ - @ai-sdk/provider-utils@3.1.0-beta.7
12
+
13
+ ## 2.1.0-beta.10
14
+
15
+ ### Patch Changes
16
+
17
+ - dedf206: feat(provider/anthropic): expose stop_sequence in provider metadata
18
+
19
+ ## 2.1.0-beta.9
20
+
21
+ ### Patch Changes
22
+
23
+ - 0adc679: feat(provider): shared spec v3
24
+ - Updated dependencies [0adc679]
25
+ - Updated dependencies [2b0caef]
26
+ - @ai-sdk/provider-utils@3.1.0-beta.6
27
+ - @ai-sdk/provider@2.1.0-beta.4
28
+
29
+ ## 2.1.0-beta.8
30
+
31
+ ### Patch Changes
32
+
33
+ - a5a8db4: chore: add model ID for Sonnet 4.5
34
+
35
+ ## 2.1.0-beta.7
36
+
37
+ ### Patch Changes
38
+
39
+ - e1e2821: fix(provider/anthropic): support null title in web fetch tool
40
+
41
+ ## 2.1.0-beta.6
42
+
43
+ ### Patch Changes
44
+
45
+ - 8dac895: feat: `LanguageModelV3`
46
+ - 10c1322: fix: moved dependency `@ai-sdk/test-server` to devDependencies
47
+ - Updated dependencies [8dac895]
48
+ - @ai-sdk/provider-utils@3.1.0-beta.5
49
+ - @ai-sdk/provider@2.1.0-beta.3
50
+
51
+ ## 2.1.0-beta.5
52
+
53
+ ### Patch Changes
54
+
55
+ - 11e4abe: feat(provider/anthropic): web search tool updates
56
+ - afb00e3: feat(provider/anthropic): add text_editor_20250728 tool support
57
+
58
+ Add text_editor_20250728 tool for Claude 4 models (Sonnet 4, Opus 4, Opus 4.1) with optional max_characters parameter and no undo_edit command support.
59
+
60
+ - f6603b7: fix(provider/anthropic): correct raw usage information
61
+ - fa35e95: feat(provider/anthropic): add web fetch tool
62
+ - c5440c5: chore(provider/anthropic): update anthropic model ids
63
+
64
+ ## 2.1.0-beta.4
65
+
66
+ ### Patch Changes
67
+
68
+ - 4616b86: chore: update zod peer depenedency version
69
+ - Updated dependencies [4616b86]
70
+ - @ai-sdk/provider-utils@3.1.0-beta.4
71
+
72
+ ## 2.1.0-beta.3
73
+
74
+ ### Patch Changes
75
+
76
+ - ed329cb: feat: `Provider-V3`
77
+ - Updated dependencies [ed329cb]
78
+ - Updated dependencies [522f6b8]
79
+ - @ai-sdk/provider@2.1.0-beta.2
80
+ - @ai-sdk/provider-utils@3.1.0-beta.3
81
+
82
+ ## 2.1.0-beta.2
83
+
84
+ ### Patch Changes
85
+
86
+ - 1cad0ab: feat: add provider version to user-agent header
87
+ - Updated dependencies [0c4822d]
88
+ - @ai-sdk/provider@2.1.0-beta.1
89
+ - @ai-sdk/provider-utils@3.1.0-beta.2
90
+
3
91
  ## 2.1.0-beta.1
4
92
 
5
93
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
2
+ import { ProviderV3, LanguageModelV3 } 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-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 & {});
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 & {});
7
7
  declare const anthropicProviderOptions: z.ZodObject<{
8
8
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
9
9
  thinking: z.ZodOptional<z.ZodObject<{
@@ -119,6 +119,8 @@ declare const anthropicTools: {
119
119
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
120
120
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
121
121
  *
122
+ * Supported models: Claude Sonnet 3.5
123
+ *
122
124
  * Tool name must be `str_replace_editor`.
123
125
  */
124
126
  textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
@@ -135,6 +137,8 @@ declare const anthropicTools: {
135
137
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
136
138
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
137
139
  *
140
+ * Supported models: Claude Sonnet 3.7
141
+ *
138
142
  * Tool name must be `str_replace_editor`.
139
143
  */
140
144
  textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
@@ -154,6 +158,8 @@ declare const anthropicTools: {
154
158
  * Note: This version does not support the "undo_edit" command.
155
159
  *
156
160
  * Tool name must be `str_replace_based_edit_tool`.
161
+ *
162
+ * @deprecated Use textEditor_20250728 instead
157
163
  */
158
164
  textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
159
165
  command: "view" | "create" | "str_replace" | "insert";
@@ -164,6 +170,102 @@ declare const anthropicTools: {
164
170
  old_str?: string;
165
171
  view_range?: number[];
166
172
  }, {}>;
173
+ /**
174
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
175
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
176
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
177
+ *
178
+ * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
179
+ *
180
+ * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
181
+ *
182
+ * Tool name must be `str_replace_based_edit_tool`.
183
+ *
184
+ * @param maxCharacters - Optional maximum number of characters to view in the file
185
+ */
186
+ textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactory<{
187
+ command: "view" | "create" | "str_replace" | "insert";
188
+ path: string;
189
+ file_text?: string;
190
+ insert_line?: number;
191
+ new_str?: string;
192
+ old_str?: string;
193
+ view_range?: number[];
194
+ }, {
195
+ maxCharacters?: number;
196
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
197
+ command: "view" | "create" | "str_replace" | "insert";
198
+ path: string;
199
+ file_text?: string;
200
+ insert_line?: number;
201
+ new_str?: string;
202
+ old_str?: string;
203
+ view_range?: number[];
204
+ }, unknown>;
205
+ /**
206
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
207
+ *
208
+ * Tool name must be `web_fetch`.
209
+ *
210
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
211
+ * @param allowedDomains - Only fetch from these domains
212
+ * @param blockedDomains - Never fetch from these domains
213
+ * @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
214
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
215
+ */
216
+ webFetch_20250910: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
217
+ url: string;
218
+ }, {
219
+ type: "web_fetch_result";
220
+ url: string;
221
+ content: {
222
+ type: "document";
223
+ title: string;
224
+ citations?: {
225
+ enabled: boolean;
226
+ };
227
+ source: {
228
+ type: "base64";
229
+ mediaType: "application/pdf";
230
+ data: string;
231
+ } | {
232
+ type: "text";
233
+ mediaType: "text/plain";
234
+ data: string;
235
+ };
236
+ };
237
+ retrievedAt: string | null;
238
+ }, {
239
+ maxUses?: number;
240
+ allowedDomains?: string[];
241
+ blockedDomains?: string[];
242
+ citations?: {
243
+ enabled: boolean;
244
+ };
245
+ maxContentTokens?: number;
246
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
247
+ url: string;
248
+ }, {
249
+ type: "web_fetch_result";
250
+ url: string;
251
+ content: {
252
+ type: "document";
253
+ title: string;
254
+ citations?: {
255
+ enabled: boolean;
256
+ };
257
+ source: {
258
+ type: "base64";
259
+ mediaType: "application/pdf";
260
+ data: string;
261
+ } | {
262
+ type: "text";
263
+ mediaType: "text/plain";
264
+ data: string;
265
+ };
266
+ };
267
+ retrievedAt: string | null;
268
+ }>;
167
269
  /**
168
270
  * Creates a web search tool that gives Claude direct access to real-time web content.
169
271
  *
@@ -177,11 +279,11 @@ declare const anthropicTools: {
177
279
  webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
178
280
  query: string;
179
281
  }, {
282
+ type: "web_search_result";
180
283
  url: string;
181
284
  title: string;
182
285
  pageAge: string | null;
183
286
  encryptedContent: string;
184
- type: string;
185
287
  }[], {
186
288
  maxUses?: number;
187
289
  allowedDomains?: string[];
@@ -196,25 +298,25 @@ declare const anthropicTools: {
196
298
  }>>[0]) => _ai_sdk_provider_utils.Tool<{
197
299
  query: string;
198
300
  }, {
301
+ type: "web_search_result";
199
302
  url: string;
200
303
  title: string;
201
304
  pageAge: string | null;
202
305
  encryptedContent: string;
203
- type: string;
204
306
  }[]>;
205
307
  };
206
308
 
207
- interface AnthropicProvider extends ProviderV2 {
309
+ interface AnthropicProvider extends ProviderV3 {
208
310
  /**
209
311
  Creates a model for text generation.
210
312
  */
211
- (modelId: AnthropicMessagesModelId): LanguageModelV2;
313
+ (modelId: AnthropicMessagesModelId): LanguageModelV3;
212
314
  /**
213
315
  Creates a model for text generation.
214
316
  */
215
- languageModel(modelId: AnthropicMessagesModelId): LanguageModelV2;
216
- chat(modelId: AnthropicMessagesModelId): LanguageModelV2;
217
- messages(modelId: AnthropicMessagesModelId): LanguageModelV2;
317
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
318
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
319
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV3;
218
320
  /**
219
321
  Anthropic-specific computer use tool.
220
322
  */
@@ -251,4 +353,6 @@ Default Anthropic provider instance.
251
353
  */
252
354
  declare const anthropic: AnthropicProvider;
253
355
 
254
- export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, anthropic, createAnthropic };
356
+ declare const VERSION: string;
357
+
358
+ export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
2
+ import { ProviderV3, LanguageModelV3 } 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-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 & {});
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 & {});
7
7
  declare const anthropicProviderOptions: z.ZodObject<{
8
8
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
9
9
  thinking: z.ZodOptional<z.ZodObject<{
@@ -119,6 +119,8 @@ declare const anthropicTools: {
119
119
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
120
120
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
121
121
  *
122
+ * Supported models: Claude Sonnet 3.5
123
+ *
122
124
  * Tool name must be `str_replace_editor`.
123
125
  */
124
126
  textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
@@ -135,6 +137,8 @@ declare const anthropicTools: {
135
137
  * helping you debug, fix, and improve your code or other text documents. This allows Claude
136
138
  * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
137
139
  *
140
+ * Supported models: Claude Sonnet 3.7
141
+ *
138
142
  * Tool name must be `str_replace_editor`.
139
143
  */
140
144
  textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
@@ -154,6 +158,8 @@ declare const anthropicTools: {
154
158
  * Note: This version does not support the "undo_edit" command.
155
159
  *
156
160
  * Tool name must be `str_replace_based_edit_tool`.
161
+ *
162
+ * @deprecated Use textEditor_20250728 instead
157
163
  */
158
164
  textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
159
165
  command: "view" | "create" | "str_replace" | "insert";
@@ -164,6 +170,102 @@ declare const anthropicTools: {
164
170
  old_str?: string;
165
171
  view_range?: number[];
166
172
  }, {}>;
173
+ /**
174
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
175
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
176
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
177
+ *
178
+ * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
179
+ *
180
+ * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
181
+ *
182
+ * Tool name must be `str_replace_based_edit_tool`.
183
+ *
184
+ * @param maxCharacters - Optional maximum number of characters to view in the file
185
+ */
186
+ textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactory<{
187
+ command: "view" | "create" | "str_replace" | "insert";
188
+ path: string;
189
+ file_text?: string;
190
+ insert_line?: number;
191
+ new_str?: string;
192
+ old_str?: string;
193
+ view_range?: number[];
194
+ }, {
195
+ maxCharacters?: number;
196
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
197
+ command: "view" | "create" | "str_replace" | "insert";
198
+ path: string;
199
+ file_text?: string;
200
+ insert_line?: number;
201
+ new_str?: string;
202
+ old_str?: string;
203
+ view_range?: number[];
204
+ }, unknown>;
205
+ /**
206
+ * Creates a web fetch tool that gives Claude direct access to real-time web content.
207
+ *
208
+ * Tool name must be `web_fetch`.
209
+ *
210
+ * @param maxUses - The max_uses parameter limits the number of web fetches performed
211
+ * @param allowedDomains - Only fetch from these domains
212
+ * @param blockedDomains - Never fetch from these domains
213
+ * @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
214
+ * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
215
+ */
216
+ webFetch_20250910: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
217
+ url: string;
218
+ }, {
219
+ type: "web_fetch_result";
220
+ url: string;
221
+ content: {
222
+ type: "document";
223
+ title: string;
224
+ citations?: {
225
+ enabled: boolean;
226
+ };
227
+ source: {
228
+ type: "base64";
229
+ mediaType: "application/pdf";
230
+ data: string;
231
+ } | {
232
+ type: "text";
233
+ mediaType: "text/plain";
234
+ data: string;
235
+ };
236
+ };
237
+ retrievedAt: string | null;
238
+ }, {
239
+ maxUses?: number;
240
+ allowedDomains?: string[];
241
+ blockedDomains?: string[];
242
+ citations?: {
243
+ enabled: boolean;
244
+ };
245
+ maxContentTokens?: number;
246
+ }>>[0]) => _ai_sdk_provider_utils.Tool<{
247
+ url: string;
248
+ }, {
249
+ type: "web_fetch_result";
250
+ url: string;
251
+ content: {
252
+ type: "document";
253
+ title: string;
254
+ citations?: {
255
+ enabled: boolean;
256
+ };
257
+ source: {
258
+ type: "base64";
259
+ mediaType: "application/pdf";
260
+ data: string;
261
+ } | {
262
+ type: "text";
263
+ mediaType: "text/plain";
264
+ data: string;
265
+ };
266
+ };
267
+ retrievedAt: string | null;
268
+ }>;
167
269
  /**
168
270
  * Creates a web search tool that gives Claude direct access to real-time web content.
169
271
  *
@@ -177,11 +279,11 @@ declare const anthropicTools: {
177
279
  webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
178
280
  query: string;
179
281
  }, {
282
+ type: "web_search_result";
180
283
  url: string;
181
284
  title: string;
182
285
  pageAge: string | null;
183
286
  encryptedContent: string;
184
- type: string;
185
287
  }[], {
186
288
  maxUses?: number;
187
289
  allowedDomains?: string[];
@@ -196,25 +298,25 @@ declare const anthropicTools: {
196
298
  }>>[0]) => _ai_sdk_provider_utils.Tool<{
197
299
  query: string;
198
300
  }, {
301
+ type: "web_search_result";
199
302
  url: string;
200
303
  title: string;
201
304
  pageAge: string | null;
202
305
  encryptedContent: string;
203
- type: string;
204
306
  }[]>;
205
307
  };
206
308
 
207
- interface AnthropicProvider extends ProviderV2 {
309
+ interface AnthropicProvider extends ProviderV3 {
208
310
  /**
209
311
  Creates a model for text generation.
210
312
  */
211
- (modelId: AnthropicMessagesModelId): LanguageModelV2;
313
+ (modelId: AnthropicMessagesModelId): LanguageModelV3;
212
314
  /**
213
315
  Creates a model for text generation.
214
316
  */
215
- languageModel(modelId: AnthropicMessagesModelId): LanguageModelV2;
216
- chat(modelId: AnthropicMessagesModelId): LanguageModelV2;
217
- messages(modelId: AnthropicMessagesModelId): LanguageModelV2;
317
+ languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
318
+ chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
319
+ messages(modelId: AnthropicMessagesModelId): LanguageModelV3;
218
320
  /**
219
321
  Anthropic-specific computer use tool.
220
322
  */
@@ -251,4 +353,6 @@ Default Anthropic provider instance.
251
353
  */
252
354
  declare const anthropic: AnthropicProvider;
253
355
 
254
- export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, anthropic, createAnthropic };
356
+ declare const VERSION: string;
357
+
358
+ export { type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };