@ai-sdk/anthropic 3.0.18 → 3.0.20

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.mjs +1 -1
  4. package/docs/05-anthropic.mdx +1096 -0
  5. package/package.json +8 -3
  6. package/src/__fixtures__/anthropic-code-execution-20250825.1.chunks.txt +248 -0
  7. package/src/__fixtures__/anthropic-code-execution-20250825.1.json +70 -0
  8. package/src/__fixtures__/anthropic-code-execution-20250825.2.chunks.txt +984 -0
  9. package/src/__fixtures__/anthropic-code-execution-20250825.2.json +111 -0
  10. package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.chunks.txt +691 -0
  11. package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.json +1801 -0
  12. package/src/__fixtures__/anthropic-json-other-tool.1.chunks.txt +13 -0
  13. package/src/__fixtures__/anthropic-json-other-tool.1.json +26 -0
  14. package/src/__fixtures__/anthropic-json-output-format.1.chunks.txt +120 -0
  15. package/src/__fixtures__/anthropic-json-output-format.1.json +25 -0
  16. package/src/__fixtures__/anthropic-json-tool.1.chunks.txt +9 -0
  17. package/src/__fixtures__/anthropic-json-tool.1.json +37 -0
  18. package/src/__fixtures__/anthropic-json-tool.2.chunks.txt +14 -0
  19. package/src/__fixtures__/anthropic-mcp.1.chunks.txt +17 -0
  20. package/src/__fixtures__/anthropic-mcp.1.json +39 -0
  21. package/src/__fixtures__/anthropic-memory-20250818.1.json +28 -0
  22. package/src/__fixtures__/anthropic-message-delta-input-tokens.chunks.txt +8 -0
  23. package/src/__fixtures__/anthropic-programmatic-tool-calling.1.chunks.txt +278 -0
  24. package/src/__fixtures__/anthropic-programmatic-tool-calling.1.json +106 -0
  25. package/src/__fixtures__/anthropic-tool-no-args.chunks.txt +13 -0
  26. package/src/__fixtures__/anthropic-tool-no-args.json +31 -0
  27. package/src/__fixtures__/anthropic-tool-search-bm25.1.chunks.txt +47 -0
  28. package/src/__fixtures__/anthropic-tool-search-bm25.1.json +67 -0
  29. package/src/__fixtures__/anthropic-tool-search-regex.1.chunks.txt +51 -0
  30. package/src/__fixtures__/anthropic-tool-search-regex.1.json +65 -0
  31. package/src/__fixtures__/anthropic-web-fetch-tool.1.chunks.txt +64 -0
  32. package/src/__fixtures__/anthropic-web-fetch-tool.1.json +54 -0
  33. package/src/__fixtures__/anthropic-web-fetch-tool.2.json +56 -0
  34. package/src/__fixtures__/anthropic-web-fetch-tool.error.json +46 -0
  35. package/src/__fixtures__/anthropic-web-search-tool.1.chunks.txt +120 -0
  36. package/src/__fixtures__/anthropic-web-search-tool.1.json +181 -0
  37. package/src/__snapshots__/anthropic-messages-language-model.test.ts.snap +16719 -0
  38. package/src/anthropic-error.test.ts +42 -0
  39. package/src/anthropic-error.ts +26 -0
  40. package/src/anthropic-message-metadata.ts +105 -0
  41. package/src/anthropic-messages-api.ts +1188 -0
  42. package/src/anthropic-messages-language-model.test.ts +7170 -0
  43. package/src/anthropic-messages-language-model.ts +2067 -0
  44. package/src/anthropic-messages-options.ts +213 -0
  45. package/src/anthropic-prepare-tools.test.ts +1219 -0
  46. package/src/anthropic-prepare-tools.ts +341 -0
  47. package/src/anthropic-provider.test.ts +162 -0
  48. package/src/anthropic-provider.ts +152 -0
  49. package/src/anthropic-tools.ts +182 -0
  50. package/src/convert-anthropic-messages-usage.ts +32 -0
  51. package/src/convert-to-anthropic-messages-prompt.test.ts +2902 -0
  52. package/src/convert-to-anthropic-messages-prompt.ts +1050 -0
  53. package/src/forward-anthropic-container-id-from-last-step.ts +38 -0
  54. package/src/get-cache-control.ts +63 -0
  55. package/src/index.ts +10 -0
  56. package/src/internal/index.ts +4 -0
  57. package/src/map-anthropic-stop-reason.ts +28 -0
  58. package/src/tool/bash_20241022.ts +33 -0
  59. package/src/tool/bash_20250124.ts +33 -0
  60. package/src/tool/code-execution_20250522.ts +61 -0
  61. package/src/tool/code-execution_20250825.ts +281 -0
  62. package/src/tool/computer_20241022.ts +87 -0
  63. package/src/tool/computer_20250124.ts +130 -0
  64. package/src/tool/memory_20250818.ts +62 -0
  65. package/src/tool/text-editor_20241022.ts +63 -0
  66. package/src/tool/text-editor_20250124.ts +63 -0
  67. package/src/tool/text-editor_20250429.ts +64 -0
  68. package/src/tool/text-editor_20250728.ts +80 -0
  69. package/src/tool/tool-search-bm25_20251119.ts +98 -0
  70. package/src/tool/tool-search-regex_20251119.ts +110 -0
  71. package/src/tool/web-fetch-20250910.ts +145 -0
  72. package/src/tool/web-search_20250305.ts +136 -0
  73. package/src/version.ts +6 -0
@@ -0,0 +1,38 @@
1
+ import { JSONObject } from '@ai-sdk/provider';
2
+ import { AnthropicMessageMetadata } from './anthropic-message-metadata';
3
+
4
+ /**
5
+ * Sets the Anthropic container ID in the provider options based on
6
+ * any previous step's provider metadata.
7
+ *
8
+ * Searches backwards through steps to find the most recent container ID.
9
+ * You can use this function in `prepareStep` to forward the container ID between steps.
10
+ */
11
+ export function forwardAnthropicContainerIdFromLastStep({
12
+ steps,
13
+ }: {
14
+ steps: Array<{
15
+ providerMetadata?: Record<string, JSONObject>;
16
+ }>;
17
+ }): undefined | { providerOptions?: Record<string, JSONObject> } {
18
+ // Search backwards through steps to find the most recent container ID
19
+ for (let i = steps.length - 1; i >= 0; i--) {
20
+ const containerId = (
21
+ steps[i].providerMetadata?.anthropic as
22
+ | AnthropicMessageMetadata
23
+ | undefined
24
+ )?.container?.id;
25
+
26
+ if (containerId) {
27
+ return {
28
+ providerOptions: {
29
+ anthropic: {
30
+ container: { id: containerId },
31
+ },
32
+ },
33
+ };
34
+ }
35
+ }
36
+
37
+ return undefined;
38
+ }
@@ -0,0 +1,63 @@
1
+ import { SharedV3Warning, SharedV3ProviderMetadata } from '@ai-sdk/provider';
2
+ import { AnthropicCacheControl } from './anthropic-messages-api';
3
+
4
+ // Anthropic allows a maximum of 4 cache breakpoints per request
5
+ const MAX_CACHE_BREAKPOINTS = 4;
6
+
7
+ // Helper function to extract cache_control from provider metadata
8
+ // Allows both cacheControl and cache_control for flexibility
9
+ function getCacheControl(
10
+ providerMetadata: SharedV3ProviderMetadata | undefined,
11
+ ): AnthropicCacheControl | undefined {
12
+ const anthropic = providerMetadata?.anthropic;
13
+
14
+ // allow both cacheControl and cache_control:
15
+ const cacheControlValue = anthropic?.cacheControl ?? anthropic?.cache_control;
16
+
17
+ // Pass through value assuming it is of the correct type.
18
+ // The Anthropic API will validate the value.
19
+ return cacheControlValue as AnthropicCacheControl | undefined;
20
+ }
21
+
22
+ export class CacheControlValidator {
23
+ private breakpointCount = 0;
24
+ private warnings: SharedV3Warning[] = [];
25
+
26
+ getCacheControl(
27
+ providerMetadata: SharedV3ProviderMetadata | undefined,
28
+ context: { type: string; canCache: boolean },
29
+ ): AnthropicCacheControl | undefined {
30
+ const cacheControlValue = getCacheControl(providerMetadata);
31
+
32
+ if (!cacheControlValue) {
33
+ return undefined;
34
+ }
35
+
36
+ // Validate that cache_control is allowed in this context
37
+ if (!context.canCache) {
38
+ this.warnings.push({
39
+ type: 'unsupported',
40
+ feature: 'cache_control on non-cacheable context',
41
+ details: `cache_control cannot be set on ${context.type}. It will be ignored.`,
42
+ });
43
+ return undefined;
44
+ }
45
+
46
+ // Validate cache breakpoint limit
47
+ this.breakpointCount++;
48
+ if (this.breakpointCount > MAX_CACHE_BREAKPOINTS) {
49
+ this.warnings.push({
50
+ type: 'unsupported',
51
+ feature: 'cacheControl breakpoint limit',
52
+ details: `Maximum ${MAX_CACHE_BREAKPOINTS} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`,
53
+ });
54
+ return undefined;
55
+ }
56
+
57
+ return cacheControlValue;
58
+ }
59
+
60
+ getWarnings(): SharedV3Warning[] {
61
+ return this.warnings;
62
+ }
63
+ }
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export type { AnthropicMessageMetadata } from './anthropic-message-metadata';
2
+ export type { AnthropicProviderOptions } from './anthropic-messages-options';
3
+ export type { AnthropicToolOptions } from './anthropic-prepare-tools';
4
+ export { anthropic, createAnthropic } from './anthropic-provider';
5
+ export type {
6
+ AnthropicProvider,
7
+ AnthropicProviderSettings,
8
+ } from './anthropic-provider';
9
+ export { forwardAnthropicContainerIdFromLastStep } from './forward-anthropic-container-id-from-last-step';
10
+ export { VERSION } from './version';
@@ -0,0 +1,4 @@
1
+ export { AnthropicMessagesLanguageModel } from '../anthropic-messages-language-model';
2
+ export { anthropicTools } from '../anthropic-tools';
3
+ export type { AnthropicMessagesModelId } from '../anthropic-messages-options';
4
+ export { prepareTools } from '../anthropic-prepare-tools';
@@ -0,0 +1,28 @@
1
+ import { LanguageModelV3FinishReason } from '@ai-sdk/provider';
2
+
3
+ /**
4
+ * @see https://docs.anthropic.com/en/api/messages#response-stop-reason
5
+ */
6
+ export function mapAnthropicStopReason({
7
+ finishReason,
8
+ isJsonResponseFromTool,
9
+ }: {
10
+ finishReason: string | null | undefined;
11
+ isJsonResponseFromTool?: boolean;
12
+ }): LanguageModelV3FinishReason['unified'] {
13
+ switch (finishReason) {
14
+ case 'pause_turn':
15
+ case 'end_turn':
16
+ case 'stop_sequence':
17
+ return 'stop';
18
+ case 'refusal':
19
+ return 'content-filter';
20
+ case 'tool_use':
21
+ return isJsonResponseFromTool ? 'stop' : 'tool-calls';
22
+ case 'max_tokens':
23
+ case 'model_context_window_exceeded':
24
+ return 'length';
25
+ default:
26
+ return 'other';
27
+ }
28
+ }
@@ -0,0 +1,33 @@
1
+ import {
2
+ createProviderToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ const bash_20241022InputSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.object({
11
+ command: z.string(),
12
+ restart: z.boolean().optional(),
13
+ }),
14
+ ),
15
+ );
16
+
17
+ export const bash_20241022 = createProviderToolFactory<
18
+ {
19
+ /**
20
+ * The bash command to run. Required unless the tool is being restarted.
21
+ */
22
+ command: string;
23
+
24
+ /**
25
+ * Specifying true will restart this tool. Otherwise, leave this unspecified.
26
+ */
27
+ restart?: boolean;
28
+ },
29
+ {}
30
+ >({
31
+ id: 'anthropic.bash_20241022',
32
+ inputSchema: bash_20241022InputSchema,
33
+ });
@@ -0,0 +1,33 @@
1
+ import {
2
+ createProviderToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ const bash_20250124InputSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.object({
11
+ command: z.string(),
12
+ restart: z.boolean().optional(),
13
+ }),
14
+ ),
15
+ );
16
+
17
+ export const bash_20250124 = createProviderToolFactory<
18
+ {
19
+ /**
20
+ * The bash command to run. Required unless the tool is being restarted.
21
+ */
22
+ command: string;
23
+
24
+ /**
25
+ * Specifying true will restart this tool. Otherwise, leave this unspecified.
26
+ */
27
+ restart?: boolean;
28
+ },
29
+ {}
30
+ >({
31
+ id: 'anthropic.bash_20250124',
32
+ inputSchema: bash_20250124InputSchema,
33
+ });
@@ -0,0 +1,61 @@
1
+ import {
2
+ createProviderToolFactoryWithOutputSchema,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ export const codeExecution_20250522OutputSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.object({
11
+ type: z.literal('code_execution_result'),
12
+ stdout: z.string(),
13
+ stderr: z.string(),
14
+ return_code: z.number(),
15
+ content: z
16
+ .array(
17
+ z.object({
18
+ type: z.literal('code_execution_output'),
19
+ file_id: z.string(),
20
+ }),
21
+ )
22
+ .optional()
23
+ .default([]),
24
+ }),
25
+ ),
26
+ );
27
+
28
+ const codeExecution_20250522InputSchema = lazySchema(() =>
29
+ zodSchema(
30
+ z.object({
31
+ code: z.string(),
32
+ }),
33
+ ),
34
+ );
35
+
36
+ const factory = createProviderToolFactoryWithOutputSchema<
37
+ {
38
+ /**
39
+ * The Python code to execute.
40
+ */
41
+ code: string;
42
+ },
43
+ {
44
+ type: 'code_execution_result';
45
+ stdout: string;
46
+ stderr: string;
47
+ return_code: number;
48
+ content: Array<{ type: 'code_execution_output'; file_id: string }>;
49
+ },
50
+ {}
51
+ >({
52
+ id: 'anthropic.code_execution_20250522',
53
+ inputSchema: codeExecution_20250522InputSchema,
54
+ outputSchema: codeExecution_20250522OutputSchema,
55
+ });
56
+
57
+ export const codeExecution_20250522 = (
58
+ args: Parameters<typeof factory>[0] = {},
59
+ ) => {
60
+ return factory(args);
61
+ };
@@ -0,0 +1,281 @@
1
+ import {
2
+ createProviderToolFactoryWithOutputSchema,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ export const codeExecution_20250825OutputSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.discriminatedUnion('type', [
11
+ z.object({
12
+ type: z.literal('code_execution_result'),
13
+ stdout: z.string(),
14
+ stderr: z.string(),
15
+ return_code: z.number(),
16
+ content: z
17
+ .array(
18
+ z.object({
19
+ type: z.literal('code_execution_output'),
20
+ file_id: z.string(),
21
+ }),
22
+ )
23
+ .optional()
24
+ .default([]),
25
+ }),
26
+ z.object({
27
+ type: z.literal('bash_code_execution_result'),
28
+ content: z.array(
29
+ z.object({
30
+ type: z.literal('bash_code_execution_output'),
31
+ file_id: z.string(),
32
+ }),
33
+ ),
34
+ stdout: z.string(),
35
+ stderr: z.string(),
36
+ return_code: z.number(),
37
+ }),
38
+ z.object({
39
+ type: z.literal('bash_code_execution_tool_result_error'),
40
+ error_code: z.string(),
41
+ }),
42
+ z.object({
43
+ type: z.literal('text_editor_code_execution_tool_result_error'),
44
+ error_code: z.string(),
45
+ }),
46
+ z.object({
47
+ type: z.literal('text_editor_code_execution_view_result'),
48
+ content: z.string(),
49
+ file_type: z.string(),
50
+ num_lines: z.number().nullable(),
51
+ start_line: z.number().nullable(),
52
+ total_lines: z.number().nullable(),
53
+ }),
54
+ z.object({
55
+ type: z.literal('text_editor_code_execution_create_result'),
56
+ is_file_update: z.boolean(),
57
+ }),
58
+ z.object({
59
+ type: z.literal('text_editor_code_execution_str_replace_result'),
60
+ lines: z.array(z.string()).nullable(),
61
+ new_lines: z.number().nullable(),
62
+ new_start: z.number().nullable(),
63
+ old_lines: z.number().nullable(),
64
+ old_start: z.number().nullable(),
65
+ }),
66
+ ]),
67
+ ),
68
+ );
69
+
70
+ export const codeExecution_20250825InputSchema = lazySchema(() =>
71
+ zodSchema(
72
+ z.discriminatedUnion('type', [
73
+ // Programmatic tool calling format (mapped from { code } by AI SDK)
74
+ z.object({
75
+ type: z.literal('programmatic-tool-call'),
76
+ code: z.string(),
77
+ }),
78
+ z.object({
79
+ type: z.literal('bash_code_execution'),
80
+ command: z.string(),
81
+ }),
82
+ z.discriminatedUnion('command', [
83
+ z.object({
84
+ type: z.literal('text_editor_code_execution'),
85
+ command: z.literal('view'),
86
+ path: z.string(),
87
+ }),
88
+ z.object({
89
+ type: z.literal('text_editor_code_execution'),
90
+ command: z.literal('create'),
91
+ path: z.string(),
92
+ file_text: z.string().nullish(),
93
+ }),
94
+ z.object({
95
+ type: z.literal('text_editor_code_execution'),
96
+ command: z.literal('str_replace'),
97
+ path: z.string(),
98
+ old_str: z.string(),
99
+ new_str: z.string(),
100
+ }),
101
+ ]),
102
+ ]),
103
+ ),
104
+ );
105
+
106
+ const factory = createProviderToolFactoryWithOutputSchema<
107
+ | {
108
+ type: 'programmatic-tool-call';
109
+ /**
110
+ * Programmatic tool calling: Python code to execute when code_execution
111
+ * is used with allowedCallers to trigger client-executed tools.
112
+ */
113
+ code: string;
114
+ }
115
+ | {
116
+ type: 'bash_code_execution';
117
+
118
+ /**
119
+ * Shell command to execute.
120
+ */
121
+ command: string;
122
+ }
123
+ | {
124
+ type: 'text_editor_code_execution';
125
+ command: 'view';
126
+
127
+ /**
128
+ * The path to the file to view.
129
+ */
130
+ path: string;
131
+ }
132
+ | {
133
+ type: 'text_editor_code_execution';
134
+ command: 'create';
135
+
136
+ /**
137
+ * The path to the file to edit.
138
+ */
139
+ path: string;
140
+
141
+ /**
142
+ * The text of the file to edit.
143
+ */
144
+ file_text?: string | null;
145
+ }
146
+ | {
147
+ type: 'text_editor_code_execution';
148
+ command: 'str_replace';
149
+
150
+ /**
151
+ * The path to the file to edit.
152
+ */
153
+ path: string;
154
+
155
+ /**
156
+ * The string to replace.
157
+ */
158
+ old_str: string;
159
+
160
+ /**
161
+ * The new string to replace the old string with.
162
+ */
163
+ new_str: string;
164
+ },
165
+ | {
166
+ /**
167
+ * Programmatic tool calling result: returned when code_execution runs code
168
+ * that calls client-executed tools via allowedCallers.
169
+ */
170
+ type: 'code_execution_result';
171
+
172
+ /**
173
+ * Output from successful execution
174
+ */
175
+ stdout: string;
176
+
177
+ /**
178
+ * Error messages if execution fails
179
+ */
180
+ stderr: string;
181
+
182
+ /**
183
+ * 0 for success, non-zero for failure
184
+ */
185
+ return_code: number;
186
+
187
+ /**
188
+ * Output file Id list
189
+ */
190
+ content: Array<{ type: 'code_execution_output'; file_id: string }>;
191
+ }
192
+ | {
193
+ type: 'bash_code_execution_result';
194
+
195
+ /**
196
+ * Output file Id list
197
+ */
198
+ content: Array<{
199
+ type: 'bash_code_execution_output';
200
+ file_id: string;
201
+ }>;
202
+
203
+ /**
204
+ * Output from successful execution
205
+ */
206
+ stdout: string;
207
+
208
+ /**
209
+ * Error messages if execution fails
210
+ */
211
+ stderr: string;
212
+
213
+ /**
214
+ * 0 for success, non-zero for failure
215
+ */
216
+ return_code: number;
217
+ }
218
+ | {
219
+ type: 'bash_code_execution_tool_result_error';
220
+
221
+ /**
222
+ * Available options: invalid_tool_input, unavailable, too_many_requests,
223
+ * execution_time_exceeded, output_file_too_large.
224
+ */
225
+ error_code: string;
226
+ }
227
+ | {
228
+ type: 'text_editor_code_execution_tool_result_error';
229
+
230
+ /**
231
+ * Available options: invalid_tool_input, unavailable, too_many_requests,
232
+ * execution_time_exceeded, file_not_found.
233
+ */
234
+ error_code: string;
235
+ }
236
+ | {
237
+ type: 'text_editor_code_execution_view_result';
238
+
239
+ content: string;
240
+
241
+ /**
242
+ * The type of the file. Available options: text, image, pdf.
243
+ */
244
+ file_type: string;
245
+
246
+ num_lines: number | null;
247
+ start_line: number | null;
248
+ total_lines: number | null;
249
+ }
250
+ | {
251
+ type: 'text_editor_code_execution_create_result';
252
+
253
+ is_file_update: boolean;
254
+ }
255
+ | {
256
+ type: 'text_editor_code_execution_str_replace_result';
257
+
258
+ lines: string[] | null;
259
+ new_lines: number | null;
260
+ new_start: number | null;
261
+ old_lines: number | null;
262
+ old_start: number | null;
263
+ },
264
+ {
265
+ // no arguments
266
+ }
267
+ >({
268
+ id: 'anthropic.code_execution_20250825',
269
+ inputSchema: codeExecution_20250825InputSchema,
270
+ outputSchema: codeExecution_20250825OutputSchema,
271
+ // Programmatic tool calling: tool results may be deferred to a later turn
272
+ // when code execution triggers a client-executed tool that needs to be
273
+ // resolved before the code execution result can be returned.
274
+ supportsDeferredResults: true,
275
+ });
276
+
277
+ export const codeExecution_20250825 = (
278
+ args: Parameters<typeof factory>[0] = {},
279
+ ) => {
280
+ return factory(args);
281
+ };
@@ -0,0 +1,87 @@
1
+ import {
2
+ createProviderToolFactory,
3
+ lazySchema,
4
+ zodSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ const computer_20241022InputSchema = lazySchema(() =>
9
+ zodSchema(
10
+ z.object({
11
+ action: z.enum([
12
+ 'key',
13
+ 'type',
14
+ 'mouse_move',
15
+ 'left_click',
16
+ 'left_click_drag',
17
+ 'right_click',
18
+ 'middle_click',
19
+ 'double_click',
20
+ 'screenshot',
21
+ 'cursor_position',
22
+ ]),
23
+ coordinate: z.array(z.number().int()).optional(),
24
+ text: z.string().optional(),
25
+ }),
26
+ ),
27
+ );
28
+
29
+ export const computer_20241022 = createProviderToolFactory<
30
+ {
31
+ /**
32
+ * The action to perform. The available actions are:
33
+ * - `key`: Press a key or key-combination on the keyboard.
34
+ * - This supports xdotool's `key` syntax.
35
+ * - Examples: "a", "Return", "alt+Tab", "ctrl+s", "Up", "KP_0" (for the numpad 0 key).
36
+ * - `type`: Type a string of text on the keyboard.
37
+ * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.
38
+ * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
39
+ * - `left_click`: Click the left mouse button.
40
+ * - `left_click_drag`: Click and drag the cursor to a specified (x, y) pixel coordinate on the screen.
41
+ * - `right_click`: Click the right mouse button.
42
+ * - `middle_click`: Click the middle mouse button.
43
+ * - `double_click`: Double-click the left mouse button.
44
+ * - `screenshot`: Take a screenshot of the screen.
45
+ */
46
+ action:
47
+ | 'key'
48
+ | 'type'
49
+ | 'mouse_move'
50
+ | 'left_click'
51
+ | 'left_click_drag'
52
+ | 'right_click'
53
+ | 'middle_click'
54
+ | 'double_click'
55
+ | 'screenshot'
56
+ | 'cursor_position';
57
+
58
+ /**
59
+ * (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`.
60
+ */
61
+ coordinate?: number[];
62
+
63
+ /**
64
+ * Required only by `action=type` and `action=key`.
65
+ */
66
+ text?: string;
67
+ },
68
+ {
69
+ /**
70
+ * The width of the display being controlled by the model in pixels.
71
+ */
72
+ displayWidthPx: number;
73
+
74
+ /**
75
+ * The height of the display being controlled by the model in pixels.
76
+ */
77
+ displayHeightPx: number;
78
+
79
+ /**
80
+ * The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
81
+ */
82
+ displayNumber?: number;
83
+ }
84
+ >({
85
+ id: 'anthropic.computer_20241022',
86
+ inputSchema: computer_20241022InputSchema,
87
+ });