@ai-sdk/anthropic 2.1.0-beta.4 → 2.1.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.1.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 11e4abe: feat(provider/anthropic): web search tool updates
8
+ - afb00e3: feat(provider/anthropic): add text_editor_20250728 tool support
9
+
10
+ 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.
11
+
12
+ - f6603b7: fix(provider/anthropic): correct raw usage information
13
+ - fa35e95: feat(provider/anthropic): add web fetch tool
14
+ - c5440c5: chore(provider/anthropic): update anthropic model ids
15
+
3
16
  ## 2.1.0-beta.4
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { ProviderV3, 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-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-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,11 +298,11 @@ 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
 
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ProviderV3, 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-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-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,11 +298,11 @@ 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