@ai-sdk/anthropic 1.1.9 → 1.1.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,21 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 1.1.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 00276ae: feat (provider/anthropic): update types for Anthropic computer_20250124 tool
8
+ - a4f8714: feat (provider/anthropic): update beta flag for sonnet-3-7 when using new computer-use tool
9
+
10
+ ## 1.1.10
11
+
12
+ ### Patch Changes
13
+
14
+ - ddf9740: feat (ai): add anthropic reasoning
15
+ - Updated dependencies [ddf9740]
16
+ - @ai-sdk/provider@1.0.9
17
+ - @ai-sdk/provider-utils@2.1.10
18
+
3
19
  ## 1.1.9
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
5
- type AnthropicMessagesModelId = '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 & {});
5
+ type AnthropicMessagesModelId = '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
6
  interface AnthropicMessagesSettings {
7
7
  /**
8
8
  Enable Anthropic cache control. This will allow you to use provider-specific
@@ -196,10 +196,106 @@ declare function computerTool_20241022<RESULT>(options: {
196
196
  execute: ExecuteFunction<z.infer<typeof Computer20241022Parameters>, RESULT>;
197
197
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
198
198
  };
199
+ declare const Computer20250124Parameters: z.ZodObject<{
200
+ action: z.ZodEnum<["key", "hold_key", "type", "cursor_position", "mouse_move", "left_mouse_down", "left_mouse_up", "left_click", "left_click_drag", "right_click", "middle_click", "double_click", "triple_click", "scroll", "wait", "screenshot"]>;
201
+ coordinate: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
202
+ duration: z.ZodOptional<z.ZodNumber>;
203
+ scroll_amount: z.ZodOptional<z.ZodNumber>;
204
+ scroll_direction: z.ZodOptional<z.ZodEnum<["up", "down", "left", "right"]>>;
205
+ start_coordinate: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
206
+ text: z.ZodOptional<z.ZodString>;
207
+ }, "strip", z.ZodTypeAny, {
208
+ action: "type" | "key" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position" | "hold_key" | "left_mouse_down" | "left_mouse_up" | "triple_click" | "scroll" | "wait";
209
+ text?: string | undefined;
210
+ coordinate?: [number, number] | undefined;
211
+ duration?: number | undefined;
212
+ scroll_amount?: number | undefined;
213
+ scroll_direction?: "up" | "down" | "left" | "right" | undefined;
214
+ start_coordinate?: [number, number] | undefined;
215
+ }, {
216
+ action: "type" | "key" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position" | "hold_key" | "left_mouse_down" | "left_mouse_up" | "triple_click" | "scroll" | "wait";
217
+ text?: string | undefined;
218
+ coordinate?: [number, number] | undefined;
219
+ duration?: number | undefined;
220
+ scroll_amount?: number | undefined;
221
+ scroll_direction?: "up" | "down" | "left" | "right" | undefined;
222
+ start_coordinate?: [number, number] | undefined;
223
+ }>;
224
+ /**
225
+ * Creates a tool for executing actions on a computer. Must have name "computer".
226
+ *
227
+ * Image results are supported.
228
+ *
229
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
230
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
231
+ * @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.
232
+ * @param execute - The function to execute the tool. Optional.
233
+ */
234
+ declare function computerTool_20250124<RESULT>(options: {
235
+ displayWidthPx: number;
236
+ displayHeightPx: number;
237
+ displayNumber?: number;
238
+ execute?: ExecuteFunction<{
239
+ /**
240
+ * - `key`: Press a key or key-combination on the keyboard.
241
+ * - This supports xdotool's `key` syntax.
242
+ * - Examples: "a", "Return", "alt+Tab", "ctrl+s", "Up", "KP_0" (for the numpad 0 key).
243
+ * - `hold_key`: Hold down a key or multiple keys for a specified duration (in seconds). Supports the same syntax as `key`.
244
+ * - `type`: Type a string of text on the keyboard.
245
+ * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.
246
+ * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
247
+ * - `left_mouse_down`: Press the left mouse button.
248
+ * - `left_mouse_up`: Release the left mouse button.
249
+ * - `left_click`: Click the left mouse button at the specified (x, y) pixel coordinate on the screen. You can also include a key combination to hold down while clicking using the `text` parameter.
250
+ * - `left_click_drag`: Click and drag the cursor from `start_coordinate` to a specified (x, y) pixel coordinate on the screen.
251
+ * - `right_click`: Click the right mouse button at the specified (x, y) pixel coordinate on the screen.
252
+ * - `middle_click`: Click the middle mouse button at the specified (x, y) pixel coordinate on the screen.
253
+ * - `double_click`: Double-click the left mouse button at the specified (x, y) pixel coordinate on the screen.
254
+ * - `triple_click`: Triple-click the left mouse button at the specified (x, y) pixel coordinate on the screen.
255
+ * - `scroll`: Scroll the screen in a specified direction by a specified amount of clicks of the scroll wheel, at the specified (x, y) pixel coordinate. DO NOT use PageUp/PageDown to scroll.
256
+ * - `wait`: Wait for a specified duration (in seconds).
257
+ * - `screenshot`: Take a screenshot of the screen.
258
+ */
259
+ action: 'key' | 'hold_key' | 'type' | 'cursor_position' | 'mouse_move' | 'left_mouse_down' | 'left_mouse_up' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click' | 'triple_click' | 'scroll' | 'wait' | 'screenshot';
260
+ /**
261
+ * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.
262
+ */
263
+ coordinate?: [number, number];
264
+ /**
265
+ * The duration to hold the key down for. Required only by `action=hold_key` and `action=wait`.
266
+ */
267
+ duration?: number;
268
+ /**
269
+ * The number of 'clicks' to scroll. Required only by `action=scroll`.
270
+ */
271
+ scroll_amount?: number;
272
+ /**
273
+ * The direction to scroll the screen. Required only by `action=scroll`.
274
+ */
275
+ scroll_direction?: 'up' | 'down' | 'left' | 'right';
276
+ /**
277
+ * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to start the drag from. Required only by `action=left_click_drag`.
278
+ */
279
+ start_coordinate?: [number, number];
280
+ /**
281
+ * Required only by `action=type`, `action=key`, and `action=hold_key`. Can also be used by click or scroll actions to hold down keys while clicking or scrolling.
282
+ */
283
+ text?: string;
284
+ }, RESULT>;
285
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
286
+ }): {
287
+ type: 'provider-defined';
288
+ id: 'anthropic.computer_20250124';
289
+ args: {};
290
+ parameters: typeof Computer20250124Parameters;
291
+ execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
292
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
293
+ };
199
294
  declare const anthropicTools: {
200
295
  bash_20241022: typeof bashTool_20241022;
201
296
  textEditor_20241022: typeof textEditorTool_20241022;
202
297
  computer_20241022: typeof computerTool_20241022;
298
+ computer_20250124: typeof computerTool_20250124;
203
299
  };
204
300
 
205
301
  interface AnthropicProvider extends ProviderV1 {
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
5
- type AnthropicMessagesModelId = '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 & {});
5
+ type AnthropicMessagesModelId = '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
6
  interface AnthropicMessagesSettings {
7
7
  /**
8
8
  Enable Anthropic cache control. This will allow you to use provider-specific
@@ -196,10 +196,106 @@ declare function computerTool_20241022<RESULT>(options: {
196
196
  execute: ExecuteFunction<z.infer<typeof Computer20241022Parameters>, RESULT>;
197
197
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
198
198
  };
199
+ declare const Computer20250124Parameters: z.ZodObject<{
200
+ action: z.ZodEnum<["key", "hold_key", "type", "cursor_position", "mouse_move", "left_mouse_down", "left_mouse_up", "left_click", "left_click_drag", "right_click", "middle_click", "double_click", "triple_click", "scroll", "wait", "screenshot"]>;
201
+ coordinate: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
202
+ duration: z.ZodOptional<z.ZodNumber>;
203
+ scroll_amount: z.ZodOptional<z.ZodNumber>;
204
+ scroll_direction: z.ZodOptional<z.ZodEnum<["up", "down", "left", "right"]>>;
205
+ start_coordinate: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
206
+ text: z.ZodOptional<z.ZodString>;
207
+ }, "strip", z.ZodTypeAny, {
208
+ action: "type" | "key" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position" | "hold_key" | "left_mouse_down" | "left_mouse_up" | "triple_click" | "scroll" | "wait";
209
+ text?: string | undefined;
210
+ coordinate?: [number, number] | undefined;
211
+ duration?: number | undefined;
212
+ scroll_amount?: number | undefined;
213
+ scroll_direction?: "up" | "down" | "left" | "right" | undefined;
214
+ start_coordinate?: [number, number] | undefined;
215
+ }, {
216
+ action: "type" | "key" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position" | "hold_key" | "left_mouse_down" | "left_mouse_up" | "triple_click" | "scroll" | "wait";
217
+ text?: string | undefined;
218
+ coordinate?: [number, number] | undefined;
219
+ duration?: number | undefined;
220
+ scroll_amount?: number | undefined;
221
+ scroll_direction?: "up" | "down" | "left" | "right" | undefined;
222
+ start_coordinate?: [number, number] | undefined;
223
+ }>;
224
+ /**
225
+ * Creates a tool for executing actions on a computer. Must have name "computer".
226
+ *
227
+ * Image results are supported.
228
+ *
229
+ * @param displayWidthPx - The width of the display being controlled by the model in pixels.
230
+ * @param displayHeightPx - The height of the display being controlled by the model in pixels.
231
+ * @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.
232
+ * @param execute - The function to execute the tool. Optional.
233
+ */
234
+ declare function computerTool_20250124<RESULT>(options: {
235
+ displayWidthPx: number;
236
+ displayHeightPx: number;
237
+ displayNumber?: number;
238
+ execute?: ExecuteFunction<{
239
+ /**
240
+ * - `key`: Press a key or key-combination on the keyboard.
241
+ * - This supports xdotool's `key` syntax.
242
+ * - Examples: "a", "Return", "alt+Tab", "ctrl+s", "Up", "KP_0" (for the numpad 0 key).
243
+ * - `hold_key`: Hold down a key or multiple keys for a specified duration (in seconds). Supports the same syntax as `key`.
244
+ * - `type`: Type a string of text on the keyboard.
245
+ * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.
246
+ * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
247
+ * - `left_mouse_down`: Press the left mouse button.
248
+ * - `left_mouse_up`: Release the left mouse button.
249
+ * - `left_click`: Click the left mouse button at the specified (x, y) pixel coordinate on the screen. You can also include a key combination to hold down while clicking using the `text` parameter.
250
+ * - `left_click_drag`: Click and drag the cursor from `start_coordinate` to a specified (x, y) pixel coordinate on the screen.
251
+ * - `right_click`: Click the right mouse button at the specified (x, y) pixel coordinate on the screen.
252
+ * - `middle_click`: Click the middle mouse button at the specified (x, y) pixel coordinate on the screen.
253
+ * - `double_click`: Double-click the left mouse button at the specified (x, y) pixel coordinate on the screen.
254
+ * - `triple_click`: Triple-click the left mouse button at the specified (x, y) pixel coordinate on the screen.
255
+ * - `scroll`: Scroll the screen in a specified direction by a specified amount of clicks of the scroll wheel, at the specified (x, y) pixel coordinate. DO NOT use PageUp/PageDown to scroll.
256
+ * - `wait`: Wait for a specified duration (in seconds).
257
+ * - `screenshot`: Take a screenshot of the screen.
258
+ */
259
+ action: 'key' | 'hold_key' | 'type' | 'cursor_position' | 'mouse_move' | 'left_mouse_down' | 'left_mouse_up' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click' | 'triple_click' | 'scroll' | 'wait' | 'screenshot';
260
+ /**
261
+ * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.
262
+ */
263
+ coordinate?: [number, number];
264
+ /**
265
+ * The duration to hold the key down for. Required only by `action=hold_key` and `action=wait`.
266
+ */
267
+ duration?: number;
268
+ /**
269
+ * The number of 'clicks' to scroll. Required only by `action=scroll`.
270
+ */
271
+ scroll_amount?: number;
272
+ /**
273
+ * The direction to scroll the screen. Required only by `action=scroll`.
274
+ */
275
+ scroll_direction?: 'up' | 'down' | 'left' | 'right';
276
+ /**
277
+ * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to start the drag from. Required only by `action=left_click_drag`.
278
+ */
279
+ start_coordinate?: [number, number];
280
+ /**
281
+ * Required only by `action=type`, `action=key`, and `action=hold_key`. Can also be used by click or scroll actions to hold down keys while clicking or scrolling.
282
+ */
283
+ text?: string;
284
+ }, RESULT>;
285
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
286
+ }): {
287
+ type: 'provider-defined';
288
+ id: 'anthropic.computer_20250124';
289
+ args: {};
290
+ parameters: typeof Computer20250124Parameters;
291
+ execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
292
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
293
+ };
199
294
  declare const anthropicTools: {
200
295
  bash_20241022: typeof bashTool_20241022;
201
296
  textEditor_20241022: typeof textEditorTool_20241022;
202
297
  computer_20241022: typeof computerTool_20241022;
298
+ computer_20250124: typeof computerTool_20250124;
203
299
  };
204
300
 
205
301
  interface AnthropicProvider extends ProviderV1 {