@ai-sdk/anthropic 3.0.24 → 3.0.26
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 +12 -0
- package/dist/index.d.mts +51 -41
- package/dist/index.d.ts +51 -41
- package/dist/index.js +153 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -76
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +39 -21
- package/dist/internal/index.d.ts +39 -21
- package/dist/internal/index.js +146 -72
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +153 -75
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +59 -14
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +9 -0
- package/src/anthropic-prepare-tools.ts +13 -0
- package/src/anthropic-provider.ts +20 -20
- package/src/anthropic-tools.ts +18 -0
- package/src/tool/computer_20251124.ts +151 -0
package/docs/05-anthropic.mdx
CHANGED
|
@@ -56,6 +56,13 @@ You can use the following optional settings to customize the Anthropic provider
|
|
|
56
56
|
|
|
57
57
|
API key that is being sent using the `x-api-key` header.
|
|
58
58
|
It defaults to the `ANTHROPIC_API_KEY` environment variable.
|
|
59
|
+
Only one of `apiKey` or `authToken` is required.
|
|
60
|
+
|
|
61
|
+
- **authToken** _string_
|
|
62
|
+
|
|
63
|
+
Auth token that is being sent using the `Authorization: Bearer` header.
|
|
64
|
+
It defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable.
|
|
65
|
+
Only one of `apiKey` or `authToken` is required.
|
|
59
66
|
|
|
60
67
|
- **headers** _Record<string,string>_
|
|
61
68
|
|
|
@@ -78,6 +85,12 @@ Some models have multi-modal capabilities.
|
|
|
78
85
|
const model = anthropic('claude-3-haiku-20240307');
|
|
79
86
|
```
|
|
80
87
|
|
|
88
|
+
You can also use the following aliases for model creation:
|
|
89
|
+
|
|
90
|
+
- `anthropic.languageModel('claude-3-haiku-20240307')` - Creates a language model
|
|
91
|
+
- `anthropic.chat('claude-3-haiku-20240307')` - Alias for `languageModel`
|
|
92
|
+
- `anthropic.messages('claude-3-haiku-20240307')` - Alias for `languageModel`
|
|
93
|
+
|
|
81
94
|
You can use Anthropic language models to generate text with the `generateText` function:
|
|
82
95
|
|
|
83
96
|
```ts
|
|
@@ -317,7 +330,7 @@ import { generateText } from 'ai';
|
|
|
317
330
|
const errorMessage = '... long error message ...';
|
|
318
331
|
|
|
319
332
|
const result = await generateText({
|
|
320
|
-
model: anthropic('claude-
|
|
333
|
+
model: anthropic('claude-sonnet-4-5'),
|
|
321
334
|
messages: [
|
|
322
335
|
{
|
|
323
336
|
role: 'user',
|
|
@@ -345,7 +358,7 @@ You can also use cache control on system messages by providing multiple system m
|
|
|
345
358
|
|
|
346
359
|
```ts highlight="3,7-9"
|
|
347
360
|
const result = await generateText({
|
|
348
|
-
model: anthropic('claude-
|
|
361
|
+
model: anthropic('claude-sonnet-4-5'),
|
|
349
362
|
messages: [
|
|
350
363
|
{
|
|
351
364
|
role: 'system',
|
|
@@ -444,7 +457,7 @@ For more on prompt caching with Anthropic, see [Anthropic's Cache Control docume
|
|
|
444
457
|
The Bash Tool allows running bash commands. Here's how to create and use it:
|
|
445
458
|
|
|
446
459
|
```ts
|
|
447
|
-
const bashTool = anthropic.tools.
|
|
460
|
+
const bashTool = anthropic.tools.bash_20250124({
|
|
448
461
|
execute: async ({ command, restart }) => {
|
|
449
462
|
// Implement your bash command execution logic here
|
|
450
463
|
// Return the result of the command execution
|
|
@@ -457,7 +470,10 @@ Parameters:
|
|
|
457
470
|
- `command` (string): The bash command to run. Required unless the tool is being restarted.
|
|
458
471
|
- `restart` (boolean, optional): Specifying true will restart this tool.
|
|
459
472
|
|
|
460
|
-
<Note>
|
|
473
|
+
<Note>
|
|
474
|
+
Two versions are available: `bash_20250124` (recommended) and `bash_20241022`.
|
|
475
|
+
Only certain Claude versions are supported.
|
|
476
|
+
</Note>
|
|
461
477
|
|
|
462
478
|
### Memory Tool
|
|
463
479
|
|
|
@@ -491,8 +507,14 @@ const tools = {
|
|
|
491
507
|
```
|
|
492
508
|
|
|
493
509
|
<Note>
|
|
494
|
-
Different models support different versions of the tool
|
|
495
|
-
|
|
510
|
+
Different models support different versions of the tool:
|
|
511
|
+
|
|
512
|
+
- `textEditor_20250728` - For Claude Sonnet 4, Opus 4, and Opus 4.1 (recommended)
|
|
513
|
+
- `textEditor_20250124` - For Claude Sonnet 3.7
|
|
514
|
+
- `textEditor_20241022` - For Claude Sonnet 3.5
|
|
515
|
+
|
|
516
|
+
Note: `textEditor_20250429` is deprecated. Use `textEditor_20250728` instead.
|
|
517
|
+
|
|
496
518
|
</Note>
|
|
497
519
|
|
|
498
520
|
Parameters:
|
|
@@ -510,12 +532,13 @@ Parameters:
|
|
|
510
532
|
The Computer Tool enables control of keyboard and mouse actions on a computer:
|
|
511
533
|
|
|
512
534
|
```ts
|
|
513
|
-
const computerTool = anthropic.tools.
|
|
535
|
+
const computerTool = anthropic.tools.computer_20251124({
|
|
514
536
|
displayWidthPx: 1920,
|
|
515
537
|
displayHeightPx: 1080,
|
|
516
538
|
displayNumber: 0, // Optional, for X11 environments
|
|
539
|
+
enableZoom: true, // Optional, enables the zoom action
|
|
517
540
|
|
|
518
|
-
execute: async ({ action, coordinate, text }) => {
|
|
541
|
+
execute: async ({ action, coordinate, text, region }) => {
|
|
519
542
|
// Implement your computer control logic here
|
|
520
543
|
// Return the result of the action
|
|
521
544
|
|
|
@@ -530,6 +553,13 @@ const computerTool = anthropic.tools.computer_20241022({
|
|
|
530
553
|
.toString('base64'),
|
|
531
554
|
};
|
|
532
555
|
}
|
|
556
|
+
case 'zoom': {
|
|
557
|
+
// region is [x1, y1, x2, y2] defining the area to zoom into
|
|
558
|
+
return {
|
|
559
|
+
type: 'image',
|
|
560
|
+
data: fs.readFileSync('./data/zoomed-region.png').toString('base64'),
|
|
561
|
+
};
|
|
562
|
+
}
|
|
533
563
|
default: {
|
|
534
564
|
console.log('Action:', action);
|
|
535
565
|
console.log('Coordinate:', coordinate);
|
|
@@ -548,13 +578,22 @@ const computerTool = anthropic.tools.computer_20241022({
|
|
|
548
578
|
});
|
|
549
579
|
```
|
|
550
580
|
|
|
581
|
+
<Note>
|
|
582
|
+
Use `computer_20251124` for Claude Opus 4.5 which supports the zoom action.
|
|
583
|
+
Use `computer_20250124` for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4,
|
|
584
|
+
Opus 4, and Sonnet 3.7.
|
|
585
|
+
</Note>
|
|
586
|
+
|
|
551
587
|
Parameters:
|
|
552
588
|
|
|
553
|
-
- `action` ('key' | 'type' | 'mouse_move' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click' | 'screenshot' | 'cursor_position'): The action to perform.
|
|
589
|
+
- `action` ('key' | 'type' | 'mouse_move' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click' | 'screenshot' | 'cursor_position' | 'zoom'): The action to perform. The `zoom` action is only available with `computer_20251124`.
|
|
554
590
|
- `coordinate` (number[], optional): Required for `mouse_move` and `left_click_drag` actions. Specifies the (x, y) coordinates.
|
|
555
591
|
- `text` (string, optional): Required for `type` and `key` actions.
|
|
556
|
-
|
|
557
|
-
|
|
592
|
+
- `region` (number[], optional): Required for `zoom` action. Specifies `[x1, y1, x2, y2]` coordinates for the area to inspect.
|
|
593
|
+
- `displayWidthPx` (number): The width of the display in pixels.
|
|
594
|
+
- `displayHeightPx` (number): The height of the display in pixels.
|
|
595
|
+
- `displayNumber` (number, optional): The display number for X11 environments.
|
|
596
|
+
- `enableZoom` (boolean, optional): Enable the zoom action. Only available with `computer_20251124`. Default: `false`.
|
|
558
597
|
|
|
559
598
|
### Web Search Tool
|
|
560
599
|
|
|
@@ -831,6 +870,12 @@ const result = await generateText({
|
|
|
831
870
|
});
|
|
832
871
|
```
|
|
833
872
|
|
|
873
|
+
<Note>
|
|
874
|
+
Two versions are available: `codeExecution_20250825` (recommended, supports
|
|
875
|
+
Python and Bash with enhanced file operations) and `codeExecution_20250522`
|
|
876
|
+
(supports Bash only).
|
|
877
|
+
</Note>
|
|
878
|
+
|
|
834
879
|
#### Error Handling
|
|
835
880
|
|
|
836
881
|
Code execution errors are handled differently depending on whether you're using streaming or non-streaming:
|
|
@@ -1017,14 +1062,14 @@ const result = await generateText({
|
|
|
1017
1062
|
|
|
1018
1063
|
### PDF support
|
|
1019
1064
|
|
|
1020
|
-
Anthropic
|
|
1065
|
+
Anthropic Claude models support reading PDF files.
|
|
1021
1066
|
You can pass PDF files as part of the message content using the `file` type:
|
|
1022
1067
|
|
|
1023
1068
|
Option 1: URL-based PDF document
|
|
1024
1069
|
|
|
1025
1070
|
```ts
|
|
1026
1071
|
const result = await generateText({
|
|
1027
|
-
model: anthropic('claude-
|
|
1072
|
+
model: anthropic('claude-sonnet-4-5'),
|
|
1028
1073
|
messages: [
|
|
1029
1074
|
{
|
|
1030
1075
|
role: 'user',
|
|
@@ -1050,7 +1095,7 @@ Option 2: Base64-encoded PDF document
|
|
|
1050
1095
|
|
|
1051
1096
|
```ts
|
|
1052
1097
|
const result = await generateText({
|
|
1053
|
-
model: anthropic('claude-
|
|
1098
|
+
model: anthropic('claude-sonnet-4-5'),
|
|
1054
1099
|
messages: [
|
|
1055
1100
|
{
|
|
1056
1101
|
role: 'user',
|
package/package.json
CHANGED
|
@@ -360,6 +360,15 @@ export type AnthropicTool =
|
|
|
360
360
|
display_number: number;
|
|
361
361
|
cache_control: AnthropicCacheControl | undefined;
|
|
362
362
|
}
|
|
363
|
+
| {
|
|
364
|
+
name: string;
|
|
365
|
+
type: 'computer_20251124';
|
|
366
|
+
display_width_px: number;
|
|
367
|
+
display_height_px: number;
|
|
368
|
+
display_number: number;
|
|
369
|
+
enable_zoom?: boolean;
|
|
370
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
371
|
+
}
|
|
363
372
|
| {
|
|
364
373
|
name: string;
|
|
365
374
|
type:
|
|
@@ -131,6 +131,19 @@ export async function prepareTools({
|
|
|
131
131
|
});
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
134
|
+
case 'anthropic.computer_20251124': {
|
|
135
|
+
betas.add('computer-use-2025-11-24');
|
|
136
|
+
anthropicTools.push({
|
|
137
|
+
name: 'computer',
|
|
138
|
+
type: 'computer_20251124',
|
|
139
|
+
display_width_px: tool.args.displayWidthPx as number,
|
|
140
|
+
display_height_px: tool.args.displayHeightPx as number,
|
|
141
|
+
display_number: tool.args.displayNumber as number,
|
|
142
|
+
enable_zoom: tool.args.enableZoom as boolean,
|
|
143
|
+
cache_control: undefined,
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
134
147
|
case 'anthropic.computer_20241022': {
|
|
135
148
|
betas.add('computer-use-2024-10-22');
|
|
136
149
|
anthropicTools.push({
|
|
@@ -19,13 +19,13 @@ import { anthropicTools } from './anthropic-tools';
|
|
|
19
19
|
|
|
20
20
|
export interface AnthropicProvider extends ProviderV3 {
|
|
21
21
|
/**
|
|
22
|
-
Creates a model for text generation.
|
|
23
|
-
*/
|
|
22
|
+
* Creates a model for text generation.
|
|
23
|
+
*/
|
|
24
24
|
(modelId: AnthropicMessagesModelId): LanguageModelV3;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
Creates a model for text generation.
|
|
28
|
-
*/
|
|
27
|
+
* Creates a model for text generation.
|
|
28
|
+
*/
|
|
29
29
|
languageModel(modelId: AnthropicMessagesModelId): LanguageModelV3;
|
|
30
30
|
|
|
31
31
|
chat(modelId: AnthropicMessagesModelId): LanguageModelV3;
|
|
@@ -38,41 +38,41 @@ Creates a model for text generation.
|
|
|
38
38
|
textEmbeddingModel(modelId: string): never;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
Anthropic-specific computer use tool.
|
|
41
|
+
* Anthropic-specific computer use tool.
|
|
42
42
|
*/
|
|
43
43
|
tools: typeof anthropicTools;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface AnthropicProviderSettings {
|
|
47
47
|
/**
|
|
48
|
-
Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
49
|
-
The default prefix is `https://api.anthropic.com/v1`.
|
|
48
|
+
* Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
49
|
+
* The default prefix is `https://api.anthropic.com/v1`.
|
|
50
50
|
*/
|
|
51
51
|
baseURL?: string;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
API key that is being send using the `x-api-key` header.
|
|
55
|
-
It defaults to the `ANTHROPIC_API_KEY` environment variable.
|
|
56
|
-
Only one of `apiKey` or `authToken` is required.
|
|
54
|
+
* API key that is being send using the `x-api-key` header.
|
|
55
|
+
* It defaults to the `ANTHROPIC_API_KEY` environment variable.
|
|
56
|
+
* Only one of `apiKey` or `authToken` is required.
|
|
57
57
|
*/
|
|
58
58
|
apiKey?: string;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
Auth token that is being sent using the `Authorization: Bearer` header.
|
|
62
|
-
It defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable.
|
|
63
|
-
Only one of `apiKey` or `authToken` is required.
|
|
61
|
+
* Auth token that is being sent using the `Authorization: Bearer` header.
|
|
62
|
+
* It defaults to the `ANTHROPIC_AUTH_TOKEN` environment variable.
|
|
63
|
+
* Only one of `apiKey` or `authToken` is required.
|
|
64
64
|
*/
|
|
65
65
|
authToken?: string;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
Custom headers to include in the requests.
|
|
69
|
-
|
|
68
|
+
* Custom headers to include in the requests.
|
|
69
|
+
*/
|
|
70
70
|
headers?: Record<string, string>;
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
74
|
-
or to provide a custom fetch implementation for e.g. testing.
|
|
75
|
-
|
|
73
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
74
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
75
|
+
*/
|
|
76
76
|
fetch?: FetchFunction;
|
|
77
77
|
|
|
78
78
|
generateId?: () => string;
|
|
@@ -85,7 +85,7 @@ or to provide a custom fetch implementation for e.g. testing.
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
Create an Anthropic provider instance.
|
|
88
|
+
* Create an Anthropic provider instance.
|
|
89
89
|
*/
|
|
90
90
|
export function createAnthropic(
|
|
91
91
|
options: AnthropicProviderSettings = {},
|
|
@@ -172,6 +172,6 @@ export function createAnthropic(
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
Default Anthropic provider instance.
|
|
175
|
+
* Default Anthropic provider instance.
|
|
176
176
|
*/
|
|
177
177
|
export const anthropic = createAnthropic();
|
package/src/anthropic-tools.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { codeExecution_20250522 } from './tool/code-execution_20250522';
|
|
|
4
4
|
import { codeExecution_20250825 } from './tool/code-execution_20250825';
|
|
5
5
|
import { computer_20241022 } from './tool/computer_20241022';
|
|
6
6
|
import { computer_20250124 } from './tool/computer_20250124';
|
|
7
|
+
import { computer_20251124 } from './tool/computer_20251124';
|
|
7
8
|
import { memory_20250818 } from './tool/memory_20250818';
|
|
8
9
|
import { textEditor_20241022 } from './tool/text-editor_20241022';
|
|
9
10
|
import { textEditor_20250124 } from './tool/text-editor_20250124';
|
|
@@ -77,6 +78,23 @@ export const anthropicTools = {
|
|
|
77
78
|
*/
|
|
78
79
|
computer_20250124,
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Claude can interact with computer environments through the computer use tool, which
|
|
83
|
+
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
84
|
+
*
|
|
85
|
+
* This version adds the zoom action for detailed screen region inspection.
|
|
86
|
+
*
|
|
87
|
+
* Image results are supported.
|
|
88
|
+
*
|
|
89
|
+
* Supported models: Claude Opus 4.5
|
|
90
|
+
*
|
|
91
|
+
* @param displayWidthPx - The width of the display being controlled by the model in pixels.
|
|
92
|
+
* @param displayHeightPx - The height of the display being controlled by the model in pixels.
|
|
93
|
+
* @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.
|
|
94
|
+
* @param enableZoom - Enable zoom action. Set to true to allow Claude to zoom into specific screen regions. Default: false.
|
|
95
|
+
*/
|
|
96
|
+
computer_20251124,
|
|
97
|
+
|
|
80
98
|
/**
|
|
81
99
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
82
100
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
7
|
+
|
|
8
|
+
const computer_20251124InputSchema = lazySchema(() =>
|
|
9
|
+
zodSchema(
|
|
10
|
+
z.object({
|
|
11
|
+
action: z.enum([
|
|
12
|
+
'key',
|
|
13
|
+
'hold_key',
|
|
14
|
+
'type',
|
|
15
|
+
'cursor_position',
|
|
16
|
+
'mouse_move',
|
|
17
|
+
'left_mouse_down',
|
|
18
|
+
'left_mouse_up',
|
|
19
|
+
'left_click',
|
|
20
|
+
'left_click_drag',
|
|
21
|
+
'right_click',
|
|
22
|
+
'middle_click',
|
|
23
|
+
'double_click',
|
|
24
|
+
'triple_click',
|
|
25
|
+
'scroll',
|
|
26
|
+
'wait',
|
|
27
|
+
'screenshot',
|
|
28
|
+
'zoom',
|
|
29
|
+
]),
|
|
30
|
+
coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),
|
|
31
|
+
duration: z.number().optional(),
|
|
32
|
+
region: z
|
|
33
|
+
.tuple([
|
|
34
|
+
z.number().int(),
|
|
35
|
+
z.number().int(),
|
|
36
|
+
z.number().int(),
|
|
37
|
+
z.number().int(),
|
|
38
|
+
])
|
|
39
|
+
.optional(),
|
|
40
|
+
scroll_amount: z.number().optional(),
|
|
41
|
+
scroll_direction: z.enum(['up', 'down', 'left', 'right']).optional(),
|
|
42
|
+
start_coordinate: z
|
|
43
|
+
.tuple([z.number().int(), z.number().int()])
|
|
44
|
+
.optional(),
|
|
45
|
+
text: z.string().optional(),
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const computer_20251124 = createProviderToolFactory<
|
|
51
|
+
{
|
|
52
|
+
/**
|
|
53
|
+
* - `key`: Press a key or key-combination on the keyboard.
|
|
54
|
+
* - This supports xdotool's `key` syntax.
|
|
55
|
+
* - Examples: "a", "Return", "alt+Tab", "ctrl+s", "Up", "KP_0" (for the numpad 0 key).
|
|
56
|
+
* - `hold_key`: Hold down a key or multiple keys for a specified duration (in seconds). Supports the same syntax as `key`.
|
|
57
|
+
* - `type`: Type a string of text on the keyboard.
|
|
58
|
+
* - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.
|
|
59
|
+
* - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
|
|
60
|
+
* - `left_mouse_down`: Press the left mouse button.
|
|
61
|
+
* - `left_mouse_up`: Release the left mouse button.
|
|
62
|
+
* - `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.
|
|
63
|
+
* - `left_click_drag`: Click and drag the cursor from `start_coordinate` to a specified (x, y) pixel coordinate on the screen.
|
|
64
|
+
* - `right_click`: Click the right mouse button at the specified (x, y) pixel coordinate on the screen.
|
|
65
|
+
* - `middle_click`: Click the middle mouse button at the specified (x, y) pixel coordinate on the screen.
|
|
66
|
+
* - `double_click`: Double-click the left mouse button at the specified (x, y) pixel coordinate on the screen.
|
|
67
|
+
* - `triple_click`: Triple-click the left mouse button at the specified (x, y) pixel coordinate on the screen.
|
|
68
|
+
* - `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.
|
|
69
|
+
* - `wait`: Wait for a specified duration (in seconds).
|
|
70
|
+
* - `screenshot`: Take a screenshot of the screen.
|
|
71
|
+
* - `zoom`: View a specific region of the screen at full resolution. Requires `enableZoom: true` in tool definition. Takes a `region` parameter with coordinates `[x1, y1, x2, y2]` defining top-left and bottom-right corners of the area to inspect.
|
|
72
|
+
*/
|
|
73
|
+
action:
|
|
74
|
+
| 'key'
|
|
75
|
+
| 'hold_key'
|
|
76
|
+
| 'type'
|
|
77
|
+
| 'cursor_position'
|
|
78
|
+
| 'mouse_move'
|
|
79
|
+
| 'left_mouse_down'
|
|
80
|
+
| 'left_mouse_up'
|
|
81
|
+
| 'left_click'
|
|
82
|
+
| 'left_click_drag'
|
|
83
|
+
| 'right_click'
|
|
84
|
+
| 'middle_click'
|
|
85
|
+
| 'double_click'
|
|
86
|
+
| 'triple_click'
|
|
87
|
+
| 'scroll'
|
|
88
|
+
| 'wait'
|
|
89
|
+
| 'screenshot'
|
|
90
|
+
| 'zoom';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* (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`.
|
|
94
|
+
*/
|
|
95
|
+
coordinate?: [number, number];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The duration to hold the key down for. Required only by `action=hold_key` and `action=wait`.
|
|
99
|
+
*/
|
|
100
|
+
duration?: number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* [x1, y1, x2, y2]: The coordinates defining the region to zoom into. x1, y1 is the top-left corner and x2, y2 is the bottom-right corner. Required only by `action=zoom`.
|
|
104
|
+
*/
|
|
105
|
+
region?: [number, number, number, number];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The number of 'clicks' to scroll. Required only by `action=scroll`.
|
|
109
|
+
*/
|
|
110
|
+
scroll_amount?: number;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The direction to scroll the screen. Required only by `action=scroll`.
|
|
114
|
+
*/
|
|
115
|
+
scroll_direction?: 'up' | 'down' | 'left' | 'right';
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* (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`.
|
|
119
|
+
*/
|
|
120
|
+
start_coordinate?: [number, number];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 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.
|
|
124
|
+
*/
|
|
125
|
+
text?: string;
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
/**
|
|
129
|
+
* The width of the display being controlled by the model in pixels.
|
|
130
|
+
*/
|
|
131
|
+
displayWidthPx: number;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The height of the display being controlled by the model in pixels.
|
|
135
|
+
*/
|
|
136
|
+
displayHeightPx: number;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
|
|
140
|
+
*/
|
|
141
|
+
displayNumber?: number;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Enable zoom action. Set to true to allow Claude to zoom into specific screen regions. Default: false.
|
|
145
|
+
*/
|
|
146
|
+
enableZoom?: boolean;
|
|
147
|
+
}
|
|
148
|
+
>({
|
|
149
|
+
id: 'anthropic.computer_20251124',
|
|
150
|
+
inputSchema: computer_20251124InputSchema,
|
|
151
|
+
});
|