@ai-sdk/anthropic 1.1.11 → 1.1.13

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.
@@ -12,6 +12,13 @@ interface AnthropicMessagesSettings {
12
12
  optionally mark content for caching) and this setting is no longer needed.
13
13
  */
14
14
  cacheControl?: boolean;
15
+ /**
16
+ Include reasoning content in requests sent to the model. Defaults to `true`.
17
+
18
+ If you are experiencing issues with the model handling requests involving
19
+ reasoning content, you can set this to `false` to omit them from the request.
20
+ */
21
+ sendReasoning?: boolean;
15
22
  }
16
23
 
17
24
  type AnthropicMessagesConfig = {
@@ -87,6 +94,43 @@ declare function bashTool_20241022<RESULT>(options?: {
87
94
  execute: ExecuteFunction<z.infer<typeof Bash20241022Parameters>, RESULT>;
88
95
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
89
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
+ };
90
134
  declare const TextEditor20241022Parameters: z.ZodObject<{
91
135
  command: z.ZodEnum<["view", "create", "str_replace", "insert", "undo_edit"]>;
92
136
  path: z.ZodString;
@@ -159,6 +203,78 @@ declare function textEditorTool_20241022<RESULT>(options?: {
159
203
  execute: ExecuteFunction<z.infer<typeof TextEditor20241022Parameters>, RESULT>;
160
204
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
161
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
+ };
162
278
  declare const Computer20241022Parameters: z.ZodObject<{
163
279
  action: z.ZodEnum<["key", "type", "mouse_move", "left_click", "left_click_drag", "right_click", "middle_click", "double_click", "screenshot", "cursor_position"]>;
164
280
  coordinate: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
@@ -318,7 +434,9 @@ declare function computerTool_20250124<RESULT>(options: {
318
434
  };
319
435
  declare const anthropicTools: {
320
436
  bash_20241022: typeof bashTool_20241022;
437
+ bash_20250124: typeof bashTool_20250124;
321
438
  textEditor_20241022: typeof textEditorTool_20241022;
439
+ textEditor_20250124: typeof textEditorTool_20250124;
322
440
  computer_20241022: typeof computerTool_20241022;
323
441
  computer_20250124: typeof computerTool_20250124;
324
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({
@@ -158,7 +172,9 @@ function prepareTools(mode) {
158
172
  var import_provider2 = require("@ai-sdk/provider");
159
173
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
160
174
  function convertToAnthropicMessagesPrompt({
161
- prompt
175
+ prompt,
176
+ sendReasoning,
177
+ warnings
162
178
  }) {
163
179
  var _a, _b, _c, _d;
164
180
  const betas = /* @__PURE__ */ new Set();
@@ -322,12 +338,19 @@ function convertToAnthropicMessagesPrompt({
322
338
  break;
323
339
  }
324
340
  case "reasoning": {
325
- anthropicContent.push({
326
- type: "thinking",
327
- thinking: part.text,
328
- signature: part.signature,
329
- cache_control: cacheControl
330
- });
341
+ if (sendReasoning) {
342
+ anthropicContent.push({
343
+ type: "thinking",
344
+ thinking: part.text,
345
+ signature: part.signature,
346
+ cache_control: cacheControl
347
+ });
348
+ } else {
349
+ warnings.push({
350
+ type: "other",
351
+ message: "sending reasoning content is disabled for this model"
352
+ });
353
+ }
331
354
  break;
332
355
  }
333
356
  case "redacted-reasoning": {
@@ -459,7 +482,7 @@ var AnthropicMessagesLanguageModel = class {
459
482
  seed,
460
483
  providerMetadata: providerOptions
461
484
  }) {
462
- var _a, _b, _c;
485
+ var _a, _b, _c, _d;
463
486
  const type = mode.type;
464
487
  const warnings = [];
465
488
  if (frequencyPenalty != null) {
@@ -488,10 +511,12 @@ var AnthropicMessagesLanguageModel = class {
488
511
  });
489
512
  }
490
513
  const { prompt: messagesPrompt, betas: messagesBetas } = convertToAnthropicMessagesPrompt({
491
- prompt
514
+ prompt,
515
+ sendReasoning: (_a = this.settings.sendReasoning) != null ? _a : true,
516
+ warnings
492
517
  });
493
518
  const thinkingOptions = thinkingOptionsSchema.safeParse(
494
- (_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.thinking
519
+ (_b = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _b.thinking
495
520
  );
496
521
  if (!thinkingOptions.success) {
497
522
  throw new import_provider3.InvalidArgumentError({
@@ -500,8 +525,8 @@ var AnthropicMessagesLanguageModel = class {
500
525
  cause: thinkingOptions.error
501
526
  });
502
527
  }
503
- const isThinking = ((_b = thinkingOptions.data) == null ? void 0 : _b.type) === "enabled";
504
- const thinkingBudget = (_c = thinkingOptions.data) == null ? void 0 : _c.budgetTokens;
528
+ const isThinking = ((_c = thinkingOptions.data) == null ? void 0 : _c.type) === "enabled";
529
+ const thinkingBudget = (_d = thinkingOptions.data) == null ? void 0 : _d.budgetTokens;
505
530
  const baseArgs = {
506
531
  // model id:
507
532
  model: this.modelId,
@@ -994,6 +1019,20 @@ function bashTool_20241022(options = {}) {
994
1019
  experimental_toToolResultContent: options.experimental_toToolResultContent
995
1020
  };
996
1021
  }
1022
+ var Bash20250124Parameters = import_zod3.z.object({
1023
+ command: import_zod3.z.string(),
1024
+ restart: import_zod3.z.boolean().optional()
1025
+ });
1026
+ function bashTool_20250124(options = {}) {
1027
+ return {
1028
+ type: "provider-defined",
1029
+ id: "anthropic.bash_20250124",
1030
+ args: {},
1031
+ parameters: Bash20250124Parameters,
1032
+ execute: options.execute,
1033
+ experimental_toToolResultContent: options.experimental_toToolResultContent
1034
+ };
1035
+ }
997
1036
  var TextEditor20241022Parameters = import_zod3.z.object({
998
1037
  command: import_zod3.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
999
1038
  path: import_zod3.z.string(),
@@ -1013,6 +1052,25 @@ function textEditorTool_20241022(options = {}) {
1013
1052
  experimental_toToolResultContent: options.experimental_toToolResultContent
1014
1053
  };
1015
1054
  }
1055
+ var TextEditor20250124Parameters = import_zod3.z.object({
1056
+ command: import_zod3.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1057
+ path: import_zod3.z.string(),
1058
+ file_text: import_zod3.z.string().optional(),
1059
+ insert_line: import_zod3.z.number().int().optional(),
1060
+ new_str: import_zod3.z.string().optional(),
1061
+ old_str: import_zod3.z.string().optional(),
1062
+ view_range: import_zod3.z.array(import_zod3.z.number().int()).optional()
1063
+ });
1064
+ function textEditorTool_20250124(options = {}) {
1065
+ return {
1066
+ type: "provider-defined",
1067
+ id: "anthropic.text_editor_20250124",
1068
+ args: {},
1069
+ parameters: TextEditor20250124Parameters,
1070
+ execute: options.execute,
1071
+ experimental_toToolResultContent: options.experimental_toToolResultContent
1072
+ };
1073
+ }
1016
1074
  var Computer20241022Parameters = import_zod3.z.object({
1017
1075
  action: import_zod3.z.enum([
1018
1076
  "key",
@@ -1085,7 +1143,9 @@ function computerTool_20250124(options) {
1085
1143
  }
1086
1144
  var anthropicTools = {
1087
1145
  bash_20241022: bashTool_20241022,
1146
+ bash_20250124: bashTool_20250124,
1088
1147
  textEditor_20241022: textEditorTool_20241022,
1148
+ textEditor_20250124: textEditorTool_20250124,
1089
1149
  computer_20241022: computerTool_20241022,
1090
1150
  computer_20250124: computerTool_20250124
1091
1151
  };