@ai-sdk/anthropic 1.1.12 → 1.1.14

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.
@@ -32,7 +32,7 @@ type AnthropicMessagesConfig = {
32
32
  declare class AnthropicMessagesLanguageModel implements LanguageModelV1 {
33
33
  readonly specificationVersion = "v1";
34
34
  readonly defaultObjectGenerationMode = "tool";
35
- readonly supportsImageUrls = false;
35
+ readonly supportsImageUrls = true;
36
36
  readonly modelId: AnthropicMessagesModelId;
37
37
  readonly settings: AnthropicMessagesSettings;
38
38
  private readonly config;
@@ -94,6 +94,43 @@ declare function bashTool_20241022<RESULT>(options?: {
94
94
  execute: ExecuteFunction<z.infer<typeof Bash20241022Parameters>, RESULT>;
95
95
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
96
96
  };
97
+ declare const Bash20250124Parameters: z.ZodObject<{
98
+ command: z.ZodString;
99
+ restart: z.ZodOptional<z.ZodBoolean>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ command: string;
102
+ restart?: boolean | undefined;
103
+ }, {
104
+ command: string;
105
+ restart?: boolean | undefined;
106
+ }>;
107
+ /**
108
+ * Creates a tool for running a bash command. Must have name "bash".
109
+ *
110
+ * Image results are supported.
111
+ *
112
+ * @param execute - The function to execute the tool. Optional.
113
+ */
114
+ declare function bashTool_20250124<RESULT>(options?: {
115
+ execute?: ExecuteFunction<{
116
+ /**
117
+ * The bash command to run. Required unless the tool is being restarted.
118
+ */
119
+ command: string;
120
+ /**
121
+ * Specifying true will restart this tool. Otherwise, leave this unspecified.
122
+ */
123
+ restart?: boolean;
124
+ }, RESULT>;
125
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
126
+ }): {
127
+ type: 'provider-defined';
128
+ id: 'anthropic.bash_20250124';
129
+ args: {};
130
+ parameters: typeof Bash20250124Parameters;
131
+ execute: ExecuteFunction<z.infer<typeof Bash20250124Parameters>, RESULT>;
132
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
133
+ };
97
134
  declare const TextEditor20241022Parameters: z.ZodObject<{
98
135
  command: z.ZodEnum<["view", "create", "str_replace", "insert", "undo_edit"]>;
99
136
  path: z.ZodString;
@@ -166,6 +203,78 @@ declare function textEditorTool_20241022<RESULT>(options?: {
166
203
  execute: ExecuteFunction<z.infer<typeof TextEditor20241022Parameters>, RESULT>;
167
204
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
168
205
  };
206
+ declare const TextEditor20250124Parameters: z.ZodObject<{
207
+ command: z.ZodEnum<["view", "create", "str_replace", "insert", "undo_edit"]>;
208
+ path: z.ZodString;
209
+ file_text: z.ZodOptional<z.ZodString>;
210
+ insert_line: z.ZodOptional<z.ZodNumber>;
211
+ new_str: z.ZodOptional<z.ZodString>;
212
+ old_str: z.ZodOptional<z.ZodString>;
213
+ view_range: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
214
+ }, "strip", z.ZodTypeAny, {
215
+ path: string;
216
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
217
+ file_text?: string | undefined;
218
+ insert_line?: number | undefined;
219
+ new_str?: string | undefined;
220
+ old_str?: string | undefined;
221
+ view_range?: number[] | undefined;
222
+ }, {
223
+ path: string;
224
+ command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
225
+ file_text?: string | undefined;
226
+ insert_line?: number | undefined;
227
+ new_str?: string | undefined;
228
+ old_str?: string | undefined;
229
+ view_range?: number[] | undefined;
230
+ }>;
231
+ /**
232
+ * Creates a tool for editing text. Must have name "str_replace_editor".
233
+ *
234
+ * Image results are supported.
235
+ *
236
+ * @param execute - The function to execute the tool. Optional.
237
+ */
238
+ declare function textEditorTool_20250124<RESULT>(options?: {
239
+ execute?: ExecuteFunction<{
240
+ /**
241
+ * The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.
242
+ */
243
+ command: 'view' | 'create' | 'str_replace' | 'insert' | 'undo_edit';
244
+ /**
245
+ * Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.
246
+ */
247
+ path: string;
248
+ /**
249
+ * Required parameter of `create` command, with the content of the file to be created.
250
+ */
251
+ file_text?: string;
252
+ /**
253
+ * Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.
254
+ */
255
+ insert_line?: number;
256
+ /**
257
+ * Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.
258
+ */
259
+ new_str?: string;
260
+ /**
261
+ * Required parameter of `str_replace` command containing the string in `path` to replace.
262
+ */
263
+ old_str?: string;
264
+ /**
265
+ * Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.
266
+ */
267
+ view_range?: number[];
268
+ }, RESULT>;
269
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
270
+ }): {
271
+ type: 'provider-defined';
272
+ id: 'anthropic.text_editor_20250124';
273
+ args: {};
274
+ parameters: typeof TextEditor20250124Parameters;
275
+ execute: ExecuteFunction<z.infer<typeof TextEditor20250124Parameters>, RESULT>;
276
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
277
+ };
169
278
  declare const Computer20241022Parameters: z.ZodObject<{
170
279
  action: z.ZodEnum<["key", "type", "mouse_move", "left_click", "left_click_drag", "right_click", "middle_click", "double_click", "screenshot", "cursor_position"]>;
171
280
  coordinate: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
@@ -325,7 +434,9 @@ declare function computerTool_20250124<RESULT>(options: {
325
434
  };
326
435
  declare const anthropicTools: {
327
436
  bash_20241022: typeof bashTool_20241022;
437
+ bash_20250124: typeof bashTool_20250124;
328
438
  textEditor_20241022: typeof textEditorTool_20241022;
439
+ textEditor_20250124: typeof textEditorTool_20250124;
329
440
  computer_20241022: typeof computerTool_20241022;
330
441
  computer_20250124: typeof computerTool_20250124;
331
442
  };
@@ -87,6 +87,13 @@ function prepareTools(mode) {
87
87
  display_number: tool.args.displayNumber
88
88
  });
89
89
  break;
90
+ case "anthropic.text_editor_20250124":
91
+ betas.add("computer-use-2025-01-24");
92
+ anthropicTools2.push({
93
+ name: tool.name,
94
+ type: "text_editor_20250124"
95
+ });
96
+ break;
90
97
  case "anthropic.text_editor_20241022":
91
98
  betas.add("computer-use-2024-10-22");
92
99
  anthropicTools2.push({
@@ -94,6 +101,13 @@ function prepareTools(mode) {
94
101
  type: "text_editor_20241022"
95
102
  });
96
103
  break;
104
+ case "anthropic.bash_20250124":
105
+ betas.add("computer-use-2025-01-24");
106
+ anthropicTools2.push({
107
+ name: tool.name,
108
+ type: "bash_20250124"
109
+ });
110
+ break;
97
111
  case "anthropic.bash_20241022":
98
112
  betas.add("computer-use-2024-10-22");
99
113
  anthropicTools2.push({
@@ -211,14 +225,12 @@ function convertToAnthropicMessagesPrompt({
211
225
  break;
212
226
  }
213
227
  case "image": {
214
- if (part.image instanceof URL) {
215
- throw new import_provider2.UnsupportedFunctionalityError({
216
- functionality: "Image URLs in user messages"
217
- });
218
- }
219
228
  anthropicContent.push({
220
229
  type: "image",
221
- source: {
230
+ source: part.image instanceof URL ? {
231
+ type: "url",
232
+ url: part.image.toString()
233
+ } : {
222
234
  type: "base64",
223
235
  media_type: (_b = part.mimeType) != null ? _b : "image/jpeg",
224
236
  data: (0, import_provider_utils2.convertUint8ArrayToBase64)(part.image)
@@ -445,7 +457,7 @@ var AnthropicMessagesLanguageModel = class {
445
457
  constructor(modelId, settings, config) {
446
458
  this.specificationVersion = "v1";
447
459
  this.defaultObjectGenerationMode = "tool";
448
- this.supportsImageUrls = false;
460
+ this.supportsImageUrls = true;
449
461
  this.modelId = modelId;
450
462
  this.settings = settings;
451
463
  this.config = config;
@@ -1005,6 +1017,20 @@ function bashTool_20241022(options = {}) {
1005
1017
  experimental_toToolResultContent: options.experimental_toToolResultContent
1006
1018
  };
1007
1019
  }
1020
+ var Bash20250124Parameters = import_zod3.z.object({
1021
+ command: import_zod3.z.string(),
1022
+ restart: import_zod3.z.boolean().optional()
1023
+ });
1024
+ function bashTool_20250124(options = {}) {
1025
+ return {
1026
+ type: "provider-defined",
1027
+ id: "anthropic.bash_20250124",
1028
+ args: {},
1029
+ parameters: Bash20250124Parameters,
1030
+ execute: options.execute,
1031
+ experimental_toToolResultContent: options.experimental_toToolResultContent
1032
+ };
1033
+ }
1008
1034
  var TextEditor20241022Parameters = import_zod3.z.object({
1009
1035
  command: import_zod3.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1010
1036
  path: import_zod3.z.string(),
@@ -1024,6 +1050,25 @@ function textEditorTool_20241022(options = {}) {
1024
1050
  experimental_toToolResultContent: options.experimental_toToolResultContent
1025
1051
  };
1026
1052
  }
1053
+ var TextEditor20250124Parameters = import_zod3.z.object({
1054
+ command: import_zod3.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1055
+ path: import_zod3.z.string(),
1056
+ file_text: import_zod3.z.string().optional(),
1057
+ insert_line: import_zod3.z.number().int().optional(),
1058
+ new_str: import_zod3.z.string().optional(),
1059
+ old_str: import_zod3.z.string().optional(),
1060
+ view_range: import_zod3.z.array(import_zod3.z.number().int()).optional()
1061
+ });
1062
+ function textEditorTool_20250124(options = {}) {
1063
+ return {
1064
+ type: "provider-defined",
1065
+ id: "anthropic.text_editor_20250124",
1066
+ args: {},
1067
+ parameters: TextEditor20250124Parameters,
1068
+ execute: options.execute,
1069
+ experimental_toToolResultContent: options.experimental_toToolResultContent
1070
+ };
1071
+ }
1027
1072
  var Computer20241022Parameters = import_zod3.z.object({
1028
1073
  action: import_zod3.z.enum([
1029
1074
  "key",
@@ -1096,7 +1141,9 @@ function computerTool_20250124(options) {
1096
1141
  }
1097
1142
  var anthropicTools = {
1098
1143
  bash_20241022: bashTool_20241022,
1144
+ bash_20250124: bashTool_20250124,
1099
1145
  textEditor_20241022: textEditorTool_20241022,
1146
+ textEditor_20250124: textEditorTool_20250124,
1100
1147
  computer_20241022: computerTool_20241022,
1101
1148
  computer_20250124: computerTool_20250124
1102
1149
  };