@effect/ai-anthropic 4.0.0-beta.8 → 4.0.0-beta.81
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/dist/AnthropicClient.d.ts +93 -74
- package/dist/AnthropicClient.d.ts.map +1 -1
- package/dist/AnthropicClient.js +51 -19
- package/dist/AnthropicClient.js.map +1 -1
- package/dist/AnthropicConfig.d.ts +55 -10
- package/dist/AnthropicConfig.d.ts.map +1 -1
- package/dist/AnthropicConfig.js +30 -7
- package/dist/AnthropicConfig.js.map +1 -1
- package/dist/AnthropicError.d.ts +136 -37
- package/dist/AnthropicError.d.ts.map +1 -1
- package/dist/AnthropicError.js +1 -1
- package/dist/AnthropicLanguageModel.d.ts +362 -52
- package/dist/AnthropicLanguageModel.d.ts.map +1 -1
- package/dist/AnthropicLanguageModel.js +88 -21
- package/dist/AnthropicLanguageModel.js.map +1 -1
- package/dist/AnthropicTelemetry.d.ts +43 -16
- package/dist/AnthropicTelemetry.d.ts.map +1 -1
- package/dist/AnthropicTelemetry.js +15 -9
- package/dist/AnthropicTelemetry.js.map +1 -1
- package/dist/AnthropicTool.d.ts +1223 -289
- package/dist/AnthropicTool.d.ts.map +1 -1
- package/dist/AnthropicTool.js +859 -201
- package/dist/AnthropicTool.js.map +1 -1
- package/dist/Generated.d.ts +1 -1
- package/dist/Generated.js +1 -1
- package/dist/index.d.ts +8 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -29
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +7 -7
- package/dist/internal/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/AnthropicClient.ts +114 -104
- package/src/AnthropicConfig.ts +56 -11
- package/src/AnthropicError.ts +138 -37
- package/src/AnthropicLanguageModel.ts +395 -43
- package/src/AnthropicTelemetry.ts +48 -22
- package/src/AnthropicTool.ts +1216 -282
- package/src/Generated.ts +1 -1
- package/src/index.ts +8 -29
- package/src/internal/errors.ts +9 -7
package/src/AnthropicTool.ts
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Anthropic provider
|
|
2
|
+
* The `AnthropicTool` module defines Anthropic provider tools and the schemas
|
|
3
|
+
* for their inputs and results. It covers Anthropic-owned tools such as Bash,
|
|
4
|
+
* Code Execution, Computer Use, Memory, Text Editor, Web Search, Web Fetch, and
|
|
5
|
+
* Tool Search, which can be attached to Anthropic-backed Effect AI language
|
|
6
|
+
* model requests.
|
|
3
7
|
*
|
|
4
|
-
*
|
|
5
|
-
* Bash, Code Execution, Computer Use, Memory, and Text Editor functionality.
|
|
6
|
-
*
|
|
7
|
-
* @since 1.0.0
|
|
8
|
+
* @since 4.0.0
|
|
8
9
|
*/
|
|
9
10
|
import * as Schema from "effect/Schema"
|
|
10
11
|
import * as Tool from "effect/unstable/ai/Tool"
|
|
11
12
|
import * as Generated from "./Generated.ts"
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
* Union of all Anthropic provider-defined
|
|
15
|
+
* Union of all Anthropic provider-defined tool definitions exported by this module.
|
|
16
|
+
*
|
|
17
|
+
* **When to use**
|
|
18
|
+
*
|
|
19
|
+
* Use when a helper, collection, or option accepts any Anthropic
|
|
20
|
+
* provider-defined tool value created by this module.
|
|
21
|
+
*
|
|
22
|
+
* **Details**
|
|
23
|
+
*
|
|
24
|
+
* The union is built from the return types of the exported constructors,
|
|
25
|
+
* including Bash, Code Execution, Computer Use, Memory, Text Editor, Tool
|
|
26
|
+
* Search, Web Fetch, and Web Search tool versions.
|
|
15
27
|
*
|
|
16
|
-
* @since 1.0.0
|
|
17
28
|
* @category models
|
|
29
|
+
* @since 4.0.0
|
|
18
30
|
*/
|
|
19
31
|
export type AnthropicTool =
|
|
20
32
|
| ReturnType<typeof Bash_20241022>
|
|
@@ -39,13 +51,22 @@ export type AnthropicTool =
|
|
|
39
51
|
// =============================================================================
|
|
40
52
|
|
|
41
53
|
/**
|
|
42
|
-
* Anthropic Bash tool (2024-10-22 version).
|
|
54
|
+
* Defines the Anthropic Bash tool (2024-10-22 version).
|
|
55
|
+
*
|
|
56
|
+
* **When to use**
|
|
57
|
+
*
|
|
58
|
+
* Use when you want the model to execute bash commands with the 2024-10-22
|
|
59
|
+
* Anthropic computer-use beta.
|
|
60
|
+
*
|
|
61
|
+
* **Details**
|
|
43
62
|
*
|
|
44
63
|
* Allows the model to execute bash commands in a sandboxed environment.
|
|
45
64
|
* Requires the "computer-use-2024-10-22" beta header.
|
|
46
65
|
*
|
|
47
|
-
* @
|
|
66
|
+
* @see {@link Bash_20250124} for the newer 2025-01-24 version of the bash tool
|
|
67
|
+
*
|
|
48
68
|
* @category Bash
|
|
69
|
+
* @since 4.0.0
|
|
49
70
|
*/
|
|
50
71
|
export const Bash_20241022 = Tool.providerDefined({
|
|
51
72
|
id: "anthropic.bash_20241022",
|
|
@@ -60,13 +81,22 @@ export const Bash_20241022 = Tool.providerDefined({
|
|
|
60
81
|
})
|
|
61
82
|
|
|
62
83
|
/**
|
|
63
|
-
* Anthropic Bash tool (2025-01-24 version).
|
|
84
|
+
* Defines the Anthropic Bash tool (2025-01-24 version).
|
|
85
|
+
*
|
|
86
|
+
* **When to use**
|
|
87
|
+
*
|
|
88
|
+
* Use when you want the model to execute bash commands with the 2025-01-24
|
|
89
|
+
* Anthropic computer-use beta.
|
|
90
|
+
*
|
|
91
|
+
* **Details**
|
|
64
92
|
*
|
|
65
93
|
* Allows the model to execute bash commands in a sandboxed environment.
|
|
66
94
|
* Requires the "computer-use-2025-01-24" beta header.
|
|
67
95
|
*
|
|
68
|
-
* @
|
|
96
|
+
* @see {@link Bash_20241022} for the older 2024-10-22 version of the bash tool
|
|
97
|
+
*
|
|
69
98
|
* @category Bash
|
|
99
|
+
* @since 4.0.0
|
|
70
100
|
*/
|
|
71
101
|
export const Bash_20250124 = Tool.providerDefined({
|
|
72
102
|
id: "anthropic.bash_20250124",
|
|
@@ -89,10 +119,17 @@ export const Bash_20250124 = Tool.providerDefined({
|
|
|
89
119
|
// -----------------------------------------------------------------------------
|
|
90
120
|
|
|
91
121
|
/**
|
|
92
|
-
*
|
|
122
|
+
* Schema for a code execution request that asks Anthropic to run source code as a programmatic tool call.
|
|
123
|
+
*
|
|
124
|
+
* **When to use**
|
|
125
|
+
*
|
|
126
|
+
* Use when constructing or validating a programmatic tool call for the Anthropic
|
|
127
|
+
* Code Execution tool.
|
|
128
|
+
*
|
|
129
|
+
* @see {@link CodeExecution_20250522} for the parent tool definition
|
|
93
130
|
*
|
|
94
|
-
* @since 1.0.0
|
|
95
131
|
* @category Code Execution
|
|
132
|
+
* @since 4.0.0
|
|
96
133
|
*/
|
|
97
134
|
export const CodeExecutionProgrammaticToolCall = Schema.Struct({
|
|
98
135
|
type: Schema.Literal("programmatic-tool-call"),
|
|
@@ -102,16 +139,30 @@ export const CodeExecutionProgrammaticToolCall = Schema.Struct({
|
|
|
102
139
|
code: Schema.String
|
|
103
140
|
})
|
|
104
141
|
/**
|
|
105
|
-
*
|
|
142
|
+
* Input payload for a programmatic code execution tool call, including the source code to execute.
|
|
143
|
+
*
|
|
106
144
|
* @category Code Execution
|
|
145
|
+
* @since 4.0.0
|
|
107
146
|
*/
|
|
108
147
|
export type CodeExecutionProgrammaticToolCall = typeof CodeExecutionProgrammaticToolCall.Type
|
|
109
148
|
|
|
110
149
|
/**
|
|
111
|
-
*
|
|
150
|
+
* Schema for the `bash_code_execution` input variant of Anthropic Code Execution.
|
|
151
|
+
*
|
|
152
|
+
* **When to use**
|
|
153
|
+
*
|
|
154
|
+
* Use when validating or constructing a bash command request for
|
|
155
|
+
* `CodeExecution_20250522`.
|
|
156
|
+
*
|
|
157
|
+
* **Details**
|
|
158
|
+
*
|
|
159
|
+
* The schema requires `type` to be `"bash_code_execution"` and `command` to
|
|
160
|
+
* contain the bash command sent to Anthropic.
|
|
161
|
+
*
|
|
162
|
+
* @see {@link CodeExecution_20250522} for the provider-defined tool that consumes this input variant
|
|
112
163
|
*
|
|
113
|
-
* @since 1.0.0
|
|
114
164
|
* @category Code Execution
|
|
165
|
+
* @since 4.0.0
|
|
115
166
|
*/
|
|
116
167
|
export const CodeExecutionBashCommand = Schema.Struct({
|
|
117
168
|
type: Schema.Literal("bash_code_execution"),
|
|
@@ -121,16 +172,48 @@ export const CodeExecutionBashCommand = Schema.Struct({
|
|
|
121
172
|
command: Schema.String
|
|
122
173
|
})
|
|
123
174
|
/**
|
|
124
|
-
*
|
|
175
|
+
* Input payload for a bash command routed through the Anthropic code execution tool.
|
|
176
|
+
*
|
|
177
|
+
* **When to use**
|
|
178
|
+
*
|
|
179
|
+
* Use when representing a provider-executed bash command request for the
|
|
180
|
+
* 2025-05-22 code execution tool.
|
|
181
|
+
*
|
|
182
|
+
* **Details**
|
|
183
|
+
*
|
|
184
|
+
* The payload uses `type: "bash_code_execution"` to distinguish bash execution
|
|
185
|
+
* from programmatic code and text editor operations, and `command` contains the
|
|
186
|
+
* bash command to run.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link CodeExecutionProgrammaticToolCall} for programmatic code execution input
|
|
189
|
+
* @see {@link CodeExecutionTextEditorView} for viewing files through text editor code execution
|
|
190
|
+
* @see {@link CodeExecutionTextEditorCreate} for creating files through text editor code execution
|
|
191
|
+
* @see {@link CodeExecutionTextEditorStrReplace} for replacing text through text editor code execution
|
|
192
|
+
* @see {@link CodeExecution_20250522} for the provider-defined tool that consumes this payload
|
|
193
|
+
*
|
|
125
194
|
* @category Code Execution
|
|
195
|
+
* @since 4.0.0
|
|
126
196
|
*/
|
|
127
197
|
export type CodeExecutionBashCommand = typeof CodeExecutionBashCommand.Type
|
|
128
198
|
|
|
129
199
|
/**
|
|
130
|
-
*
|
|
200
|
+
* Schema for a code execution text editor request that views a file by path.
|
|
201
|
+
*
|
|
202
|
+
* **When to use**
|
|
203
|
+
*
|
|
204
|
+
* Use when you need the schema for provider-bound code-execution view requests
|
|
205
|
+
* before distinguishing them from create or replace text-editor commands.
|
|
206
|
+
*
|
|
207
|
+
* **Details**
|
|
208
|
+
*
|
|
209
|
+
* The encoded payload uses `type: "text_editor_code_execution"`,
|
|
210
|
+
* `command: "view"`, and a `path` string.
|
|
211
|
+
*
|
|
212
|
+
* @see {@link CodeExecutionTextEditorCreate} for the command that creates a file
|
|
213
|
+
* @see {@link CodeExecutionTextEditorStrReplace} for the command that replaces text in a file
|
|
131
214
|
*
|
|
132
|
-
* @since 1.0.0
|
|
133
215
|
* @category Code Execution
|
|
216
|
+
* @since 4.0.0
|
|
134
217
|
*/
|
|
135
218
|
export const CodeExecutionTextEditorView = Schema.Struct({
|
|
136
219
|
type: Schema.Literal("text_editor_code_execution"),
|
|
@@ -141,16 +224,52 @@ export const CodeExecutionTextEditorView = Schema.Struct({
|
|
|
141
224
|
path: Schema.String
|
|
142
225
|
})
|
|
143
226
|
/**
|
|
144
|
-
*
|
|
227
|
+
* Input payload for the `view` command of Anthropic's text editor code execution tool.
|
|
228
|
+
*
|
|
229
|
+
* **When to use**
|
|
230
|
+
*
|
|
231
|
+
* Use when working at the Anthropic protocol boundary and the code-execution
|
|
232
|
+
* view request must be distinguished from standalone text-editor view requests.
|
|
233
|
+
*
|
|
234
|
+
* **Details**
|
|
235
|
+
*
|
|
236
|
+
* The payload is discriminated by `type: "text_editor_code_execution"` and
|
|
237
|
+
* `command: "view"`. The `path` field identifies the file to view.
|
|
238
|
+
*
|
|
239
|
+
* **Gotchas**
|
|
240
|
+
*
|
|
241
|
+
* This code execution view payload does not include `view_range`; line ranges
|
|
242
|
+
* are part of the standalone text editor view payload, not this code execution
|
|
243
|
+
* payload.
|
|
244
|
+
*
|
|
245
|
+
* @see {@link CodeExecution_20250522} for the provider-defined code execution tool that includes this payload
|
|
246
|
+
* @see {@link TextEditorViewCommand} for the standalone text editor view payload
|
|
247
|
+
*
|
|
145
248
|
* @category Code Execution
|
|
249
|
+
* @since 4.0.0
|
|
146
250
|
*/
|
|
147
251
|
export type CodeExecutionTextEditorView = typeof CodeExecutionTextEditorView.Type
|
|
148
252
|
|
|
149
253
|
/**
|
|
150
|
-
*
|
|
254
|
+
* Schema for a text editor code execution request that creates a file at a path.
|
|
255
|
+
*
|
|
256
|
+
* **When to use**
|
|
257
|
+
*
|
|
258
|
+
* Use when validating or constructing an Anthropic `text_editor_code_execution`
|
|
259
|
+
* tool call that should create a file.
|
|
260
|
+
*
|
|
261
|
+
* **Details**
|
|
262
|
+
*
|
|
263
|
+
* The request is discriminated by `type: "text_editor_code_execution"` and
|
|
264
|
+
* `command: "create"`. It requires `path` and accepts optional `file_text`; the
|
|
265
|
+
* schema allows `file_text` to be omitted, `null`, or a string.
|
|
266
|
+
*
|
|
267
|
+
* @see {@link CodeExecution_20250522} for the provider-defined tool that consumes this request
|
|
268
|
+
* @see {@link CodeExecutionTextEditorView} for the matching view request
|
|
269
|
+
* @see {@link CodeExecutionTextEditorStrReplace} for the matching replace request
|
|
151
270
|
*
|
|
152
|
-
* @since 1.0.0
|
|
153
271
|
* @category Code Execution
|
|
272
|
+
* @since 4.0.0
|
|
154
273
|
*/
|
|
155
274
|
export const CodeExecutionTextEditorCreate = Schema.Struct({
|
|
156
275
|
type: Schema.Literal("text_editor_code_execution"),
|
|
@@ -165,16 +284,31 @@ export const CodeExecutionTextEditorCreate = Schema.Struct({
|
|
|
165
284
|
file_text: Schema.optional(Schema.NullOr(Schema.String))
|
|
166
285
|
})
|
|
167
286
|
/**
|
|
168
|
-
*
|
|
287
|
+
* Input payload for creating a file through the text editor code execution tool, optionally including initial file text.
|
|
288
|
+
*
|
|
169
289
|
* @category Code Execution
|
|
290
|
+
* @since 4.0.0
|
|
170
291
|
*/
|
|
171
292
|
export type CodeExecutionTextEditorCreate = typeof CodeExecutionTextEditorCreate.Type
|
|
172
293
|
|
|
173
294
|
/**
|
|
174
|
-
*
|
|
295
|
+
* Schema for a code execution text editor request that replaces one exact string in a file.
|
|
296
|
+
*
|
|
297
|
+
* **When to use**
|
|
298
|
+
*
|
|
299
|
+
* Use when validating or constructing the `str_replace` text editor operation
|
|
300
|
+
* for the 2025-05-22 Anthropic code execution tool.
|
|
301
|
+
*
|
|
302
|
+
* **Gotchas**
|
|
303
|
+
*
|
|
304
|
+
* The `old_str` must match the file contents exactly, including whitespace and
|
|
305
|
+
* indentation, and must identify a single occurrence.
|
|
306
|
+
*
|
|
307
|
+
* @see {@link CodeExecutionTextEditorView} for reading file contents before choosing the replacement text
|
|
308
|
+
* @see {@link CodeExecution_20250522} for the provider-defined tool that consumes this payload
|
|
175
309
|
*
|
|
176
|
-
* @since 1.0.0
|
|
177
310
|
* @category Code Execution
|
|
311
|
+
* @since 4.0.0
|
|
178
312
|
*/
|
|
179
313
|
export const CodeExecutionTextEditorStrReplace = Schema.Struct({
|
|
180
314
|
type: Schema.Literal("text_editor_code_execution"),
|
|
@@ -193,8 +327,10 @@ export const CodeExecutionTextEditorStrReplace = Schema.Struct({
|
|
|
193
327
|
new_str: Schema.String
|
|
194
328
|
})
|
|
195
329
|
/**
|
|
196
|
-
*
|
|
330
|
+
* Input payload for replacing text in a file through the text editor code execution tool.
|
|
331
|
+
*
|
|
197
332
|
* @category Code Execution
|
|
333
|
+
* @since 4.0.0
|
|
198
334
|
*/
|
|
199
335
|
export type CodeExecutionTextEditorStrReplace = typeof CodeExecutionTextEditorStrReplace.Type
|
|
200
336
|
|
|
@@ -211,10 +347,17 @@ const CodeExecution_20250522_Parameters = Schema.Union([
|
|
|
211
347
|
// -----------------------------------------------------------------------------
|
|
212
348
|
|
|
213
349
|
/**
|
|
214
|
-
*
|
|
350
|
+
* Schema for the 2025-08-25 code execution tool input, containing the code to execute.
|
|
351
|
+
*
|
|
352
|
+
* **When to use**
|
|
353
|
+
*
|
|
354
|
+
* Use when you need the schema for code-execution input at the Anthropic
|
|
355
|
+
* protocol boundary before sending source code to the 2025-08-25 tool.
|
|
356
|
+
*
|
|
357
|
+
* @see {@link CodeExecution_20250825} for the provider-defined tool that consumes this schema
|
|
215
358
|
*
|
|
216
|
-
* @since 1.0.0
|
|
217
359
|
* @category Code Execution
|
|
360
|
+
* @since 4.0.0
|
|
218
361
|
*/
|
|
219
362
|
export const CodeExecution_20250825_Parameters = Schema.Struct({
|
|
220
363
|
/**
|
|
@@ -223,8 +366,22 @@ export const CodeExecution_20250825_Parameters = Schema.Struct({
|
|
|
223
366
|
code: Schema.String
|
|
224
367
|
})
|
|
225
368
|
/**
|
|
226
|
-
*
|
|
369
|
+
* Input payload for the 2025-08-25 Anthropic code execution tool.
|
|
370
|
+
*
|
|
371
|
+
* **When to use**
|
|
372
|
+
*
|
|
373
|
+
* Use when exposing the 2025-08-25 code-execution payload separately from the
|
|
374
|
+
* provider tool definition, such as at a transport or persistence boundary.
|
|
375
|
+
*
|
|
376
|
+
* **Details**
|
|
377
|
+
*
|
|
378
|
+
* The payload has a single `code` field containing the source code string to
|
|
379
|
+
* execute.
|
|
380
|
+
*
|
|
381
|
+
* @see {@link CodeExecution_20250825} for the provider-defined tool that consumes this payload
|
|
382
|
+
*
|
|
227
383
|
* @category Code Execution
|
|
384
|
+
* @since 4.0.0
|
|
228
385
|
*/
|
|
229
386
|
export type CodeExecution_20250825_Parameters = typeof CodeExecution_20250825_Parameters.Type
|
|
230
387
|
|
|
@@ -233,14 +390,23 @@ export type CodeExecution_20250825_Parameters = typeof CodeExecution_20250825_Pa
|
|
|
233
390
|
// -----------------------------------------------------------------------------
|
|
234
391
|
|
|
235
392
|
/**
|
|
236
|
-
* Anthropic Code Execution tool (2025-05-22 version).
|
|
393
|
+
* Defines the Anthropic Code Execution tool (2025-05-22 version).
|
|
394
|
+
*
|
|
395
|
+
* **When to use**
|
|
396
|
+
*
|
|
397
|
+
* Use when you want the model to execute code in a sandboxed environment with
|
|
398
|
+
* the 2025-05-22 Anthropic code-execution beta.
|
|
399
|
+
*
|
|
400
|
+
* **Details**
|
|
237
401
|
*
|
|
238
402
|
* Allows the model to execute code in a sandboxed environment with support
|
|
239
403
|
* for multiple execution types including programmatic tool calls, bash
|
|
240
404
|
* execution, and text editor operations.
|
|
241
405
|
*
|
|
242
|
-
* @
|
|
406
|
+
* @see {@link CodeExecutionProgrammaticToolCall} for the programmatic tool call schema
|
|
407
|
+
*
|
|
243
408
|
* @category Code Execution
|
|
409
|
+
* @since 4.0.0
|
|
244
410
|
*/
|
|
245
411
|
export const CodeExecution_20250522 = Tool.providerDefined({
|
|
246
412
|
id: "anthropic.code_execution_20250522",
|
|
@@ -252,12 +418,23 @@ export const CodeExecution_20250522 = Tool.providerDefined({
|
|
|
252
418
|
})
|
|
253
419
|
|
|
254
420
|
/**
|
|
255
|
-
* Anthropic Code Execution tool (2025-08-25 version).
|
|
421
|
+
* Defines the Anthropic Code Execution tool (2025-08-25 version).
|
|
422
|
+
*
|
|
423
|
+
* **When to use**
|
|
424
|
+
*
|
|
425
|
+
* Use when you want the model to execute code in a sandboxed environment with
|
|
426
|
+
* the 2025-08-25 Anthropic code-execution beta.
|
|
427
|
+
*
|
|
428
|
+
* **Details**
|
|
256
429
|
*
|
|
257
|
-
*
|
|
430
|
+
* Requires the `code-execution-2025-08-25` beta header and uses
|
|
431
|
+
* `CodeExecution_20250825_Parameters` as its input schema.
|
|
432
|
+
*
|
|
433
|
+
* @see {@link CodeExecution_20250522} for the older 2025-05-22 code execution tool
|
|
434
|
+
* @see {@link CodeExecution_20250825_Parameters} for the input schema consumed by this tool
|
|
258
435
|
*
|
|
259
|
-
* @since 1.0.0
|
|
260
436
|
* @category Code Execution
|
|
437
|
+
* @since 4.0.0
|
|
261
438
|
*/
|
|
262
439
|
export const CodeExecution_20250825 = Tool.providerDefined({
|
|
263
440
|
id: "anthropic.code_execution_20250825",
|
|
@@ -287,54 +464,100 @@ export const CodeExecution_20250825 = Tool.providerDefined({
|
|
|
287
464
|
// -----------------------------------------------------------------------------
|
|
288
465
|
|
|
289
466
|
/**
|
|
290
|
-
*
|
|
467
|
+
* Schema for an `[x, y]` screen coordinate in pixels.
|
|
468
|
+
*
|
|
469
|
+
* **When to use**
|
|
470
|
+
*
|
|
471
|
+
* Use when validating computer-use action payloads that carry a single screen
|
|
472
|
+
* position and provider-side bounds checks remain acceptable.
|
|
473
|
+
*
|
|
474
|
+
* **Details**
|
|
475
|
+
*
|
|
476
|
+
* This is a two-number tuple used by computer-use actions that accept screen
|
|
477
|
+
* positions.
|
|
478
|
+
*
|
|
479
|
+
* **Gotchas**
|
|
291
480
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
481
|
+
* This schema validates tuple shape only and does not check display bounds.
|
|
482
|
+
*
|
|
483
|
+
* @category computer use
|
|
484
|
+
* @since 4.0.0
|
|
294
485
|
*/
|
|
295
486
|
export const Coordinate = Schema.Tuple([Schema.Number, Schema.Number])
|
|
296
487
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
488
|
+
* An `[x, y]` screen coordinate in pixels.
|
|
489
|
+
*
|
|
490
|
+
* @category computer use
|
|
491
|
+
* @since 4.0.0
|
|
299
492
|
*/
|
|
300
493
|
export type Coordinate = typeof Coordinate.Type
|
|
301
494
|
|
|
302
495
|
/**
|
|
303
|
-
*
|
|
496
|
+
* Schema for an `[x1, y1, x2, y2]` screen region in pixels.
|
|
497
|
+
*
|
|
498
|
+
* **When to use**
|
|
499
|
+
*
|
|
500
|
+
* Use when validating computer-use action payloads that carry a rectangular
|
|
501
|
+
* screen region and provider-side bounds checks remain acceptable.
|
|
502
|
+
*
|
|
503
|
+
* **Details**
|
|
504
|
+
*
|
|
505
|
+
* The tuple represents top-left and bottom-right corners.
|
|
304
506
|
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
507
|
+
* **Gotchas**
|
|
508
|
+
*
|
|
509
|
+
* This schema validates four numbers only and does not check coordinate ordering
|
|
510
|
+
* or display bounds.
|
|
511
|
+
*
|
|
512
|
+
* @category computer use
|
|
513
|
+
* @since 4.0.0
|
|
307
514
|
*/
|
|
308
515
|
export const Region = Schema.Tuple([Schema.Number, Schema.Number, Schema.Number, Schema.Number])
|
|
309
516
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
517
|
+
* An `[x1, y1, x2, y2]` screen region in pixels, from top-left to bottom-right.
|
|
518
|
+
*
|
|
519
|
+
* @category computer use
|
|
520
|
+
* @since 4.0.0
|
|
312
521
|
*/
|
|
313
522
|
export type Region = typeof Region.Type
|
|
314
523
|
|
|
315
524
|
/**
|
|
316
|
-
*
|
|
525
|
+
* Schema for scroll direction literals: `"up"`, `"down"`, `"left"`, or `"right"`.
|
|
317
526
|
*
|
|
318
|
-
* @
|
|
319
|
-
*
|
|
527
|
+
* @see {@link ComputerUseScrollAction} for the action payload that consumes this schema
|
|
528
|
+
*
|
|
529
|
+
* @category computer use
|
|
530
|
+
* @since 4.0.0
|
|
320
531
|
*/
|
|
321
532
|
export const ScrollDirection = Schema.Literals(["up", "down", "left", "right"])
|
|
322
533
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
534
|
+
* Direction used by computer-use scroll actions: `"up"`, `"down"`, `"left"`, or `"right"`.
|
|
535
|
+
*
|
|
536
|
+
* @category computer use
|
|
537
|
+
* @since 4.0.0
|
|
325
538
|
*/
|
|
326
539
|
export type ScrollDirection = typeof ScrollDirection.Type
|
|
327
540
|
|
|
328
541
|
/**
|
|
329
|
-
*
|
|
542
|
+
* Schema for modifier key literals.
|
|
543
|
+
*
|
|
544
|
+
* **Details**
|
|
330
545
|
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
546
|
+
* Allowed values are `"alt"`, `"ctrl"`, `"meta"`, and `"shift"`.
|
|
547
|
+
*
|
|
548
|
+
* @category computer use
|
|
549
|
+
* @since 4.0.0
|
|
333
550
|
*/
|
|
334
551
|
export const ModifierKey = Schema.Literals(["alt", "ctrl", "meta", "shift"])
|
|
335
552
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
553
|
+
* Modifier key literals.
|
|
554
|
+
*
|
|
555
|
+
* **Details**
|
|
556
|
+
*
|
|
557
|
+
* Allowed values are `"alt"`, `"ctrl"`, `"meta"`, and `"shift"`.
|
|
558
|
+
*
|
|
559
|
+
* @category computer use
|
|
560
|
+
* @since 4.0.0
|
|
338
561
|
*/
|
|
339
562
|
export type ModifierKey = typeof ModifierKey.Type
|
|
340
563
|
|
|
@@ -371,10 +594,19 @@ const ComputerUse_20251124_Args = Schema.Struct({
|
|
|
371
594
|
// -----------------------------------------------------------------------------
|
|
372
595
|
|
|
373
596
|
/**
|
|
374
|
-
*
|
|
597
|
+
* Schema for a computer-use action that presses a key or key combination, such
|
|
598
|
+
* as `"Return"`, `"ctrl+c"`, or `"ctrl+s"`.
|
|
599
|
+
*
|
|
600
|
+
* **When to use**
|
|
601
|
+
*
|
|
602
|
+
* Use when validating or constructing a computer-use action for keyboard
|
|
603
|
+
* shortcuts or non-text key presses.
|
|
375
604
|
*
|
|
376
|
-
* @
|
|
377
|
-
* @
|
|
605
|
+
* @see {@link TypeAction} for entering ordinary text strings
|
|
606
|
+
* @see {@link ComputerUseHoldKeyAction} for holding a key for a duration
|
|
607
|
+
*
|
|
608
|
+
* @category computer use
|
|
609
|
+
* @since 4.0.0
|
|
378
610
|
*/
|
|
379
611
|
export const ComputerUseKeyAction = Schema.Struct({
|
|
380
612
|
action: Schema.Literal("key"),
|
|
@@ -384,16 +616,54 @@ export const ComputerUseKeyAction = Schema.Struct({
|
|
|
384
616
|
text: Schema.String
|
|
385
617
|
})
|
|
386
618
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
619
|
+
* Computer-use action payload for pressing a key or key combination.
|
|
620
|
+
*
|
|
621
|
+
* **When to use**
|
|
622
|
+
*
|
|
623
|
+
* Use when typing parsed computer-use key action payloads after schema
|
|
624
|
+
* validation, where provider-specific key-name validation is handled outside
|
|
625
|
+
* TypeScript.
|
|
626
|
+
*
|
|
627
|
+
* **Details**
|
|
628
|
+
*
|
|
629
|
+
* The payload uses `action: "key"` and stores the key or key combination to
|
|
630
|
+
* press in `text`, such as `"Return"`, `"ctrl+c"`, or `"ctrl+s"`.
|
|
631
|
+
*
|
|
632
|
+
* **Gotchas**
|
|
633
|
+
*
|
|
634
|
+
* `text` is typed as `string`; the paired schema does not validate
|
|
635
|
+
* provider-specific key names or key combinations.
|
|
636
|
+
*
|
|
637
|
+
* @category computer use
|
|
638
|
+
* @since 4.0.0
|
|
389
639
|
*/
|
|
390
640
|
export type ComputerUseKeyAction = typeof ComputerUseKeyAction.Type
|
|
391
641
|
|
|
392
642
|
/**
|
|
393
|
-
*
|
|
643
|
+
* Schema for a computer-use action that performs a left click.
|
|
644
|
+
*
|
|
645
|
+
* **When to use**
|
|
646
|
+
*
|
|
647
|
+
* Use to validate or construct an Anthropic computer-use payload for clicking
|
|
648
|
+
* once at the current mouse position or at a specific screen coordinate.
|
|
649
|
+
*
|
|
650
|
+
* **Details**
|
|
651
|
+
*
|
|
652
|
+
* The encoded payload uses `action: "left_click"`. The optional `coordinate`
|
|
653
|
+
* field supplies the `[x, y]` pixel position; when omitted, the action uses the
|
|
654
|
+
* current mouse position.
|
|
655
|
+
*
|
|
656
|
+
* **Gotchas**
|
|
394
657
|
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
658
|
+
* The coordinate schema only checks that the value is a two-number tuple. It
|
|
659
|
+
* does not validate that the point falls within the configured display
|
|
660
|
+
* dimensions.
|
|
661
|
+
*
|
|
662
|
+
* @see {@link ComputerUseDoubleClickAction} for performing a double click
|
|
663
|
+
* @see {@link ComputerUseMouseMoveAction} for moving the mouse without clicking
|
|
664
|
+
*
|
|
665
|
+
* @category computer use
|
|
666
|
+
* @since 4.0.0
|
|
397
667
|
*/
|
|
398
668
|
export const ComputerUseLeftClickAction = Schema.Struct({
|
|
399
669
|
action: Schema.Literal("left_click"),
|
|
@@ -404,16 +674,35 @@ export const ComputerUseLeftClickAction = Schema.Struct({
|
|
|
404
674
|
coordinate: Schema.optional(Coordinate)
|
|
405
675
|
})
|
|
406
676
|
/**
|
|
407
|
-
*
|
|
408
|
-
*
|
|
677
|
+
* Computer-use action payload for performing a left click, optionally at a specific coordinate.
|
|
678
|
+
*
|
|
679
|
+
* @category computer use
|
|
680
|
+
* @since 4.0.0
|
|
409
681
|
*/
|
|
410
682
|
export type ComputerUseLeftClickAction = typeof ComputerUseLeftClickAction.Type
|
|
411
683
|
|
|
412
684
|
/**
|
|
413
|
-
*
|
|
685
|
+
* Schema for a computer-use action that moves the mouse cursor to a required
|
|
686
|
+
* `[x, y]` screen coordinate.
|
|
687
|
+
*
|
|
688
|
+
* **When to use**
|
|
689
|
+
*
|
|
690
|
+
* Use to validate or construct a mouse movement action for an Anthropic
|
|
691
|
+
* computer-use tool call.
|
|
692
|
+
*
|
|
693
|
+
* **Details**
|
|
414
694
|
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
695
|
+
* The encoded payload has action `"mouse_move"` and a required `coordinate`
|
|
696
|
+
* field containing the target `[x, y]` pixel position.
|
|
697
|
+
*
|
|
698
|
+
* **Gotchas**
|
|
699
|
+
*
|
|
700
|
+
* The coordinate schema only checks that the value is a two-number tuple. It
|
|
701
|
+
* does not validate that the point falls within the configured display
|
|
702
|
+
* dimensions.
|
|
703
|
+
*
|
|
704
|
+
* @category computer use
|
|
705
|
+
* @since 4.0.0
|
|
417
706
|
*/
|
|
418
707
|
export const ComputerUseMouseMoveAction = Schema.Struct({
|
|
419
708
|
action: Schema.Literal("mouse_move"),
|
|
@@ -423,31 +712,59 @@ export const ComputerUseMouseMoveAction = Schema.Struct({
|
|
|
423
712
|
coordinate: Coordinate
|
|
424
713
|
})
|
|
425
714
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
715
|
+
* Computer-use action payload for moving the mouse cursor to a specific coordinate.
|
|
716
|
+
*
|
|
717
|
+
* @category computer use
|
|
718
|
+
* @since 4.0.0
|
|
428
719
|
*/
|
|
429
720
|
export type ComputerUseMouseMoveAction = typeof ComputerUseMouseMoveAction.Type
|
|
430
721
|
|
|
431
722
|
/**
|
|
432
|
-
*
|
|
723
|
+
* Schema for a computer-use action that requests a screenshot of the current display.
|
|
724
|
+
*
|
|
725
|
+
* **When to use**
|
|
726
|
+
*
|
|
727
|
+
* Use to validate or construct a computer-use tool action that asks the handler
|
|
728
|
+
* to capture the full current display.
|
|
433
729
|
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
730
|
+
* **Details**
|
|
731
|
+
*
|
|
732
|
+
* The payload contains only `action: "screenshot"` and does not include
|
|
733
|
+
* coordinates or other options.
|
|
734
|
+
*
|
|
735
|
+
* @see {@link ComputerUseZoomAction} for requesting a zoomed-in screenshot of a specific screen region with the 2025-11-24 computer-use tool
|
|
736
|
+
*
|
|
737
|
+
* @category computer use
|
|
738
|
+
* @since 4.0.0
|
|
436
739
|
*/
|
|
437
740
|
export const ComputerUseScreenshotAction = Schema.Struct({
|
|
438
741
|
action: Schema.Literal("screenshot")
|
|
439
742
|
})
|
|
440
743
|
/**
|
|
441
|
-
*
|
|
442
|
-
*
|
|
744
|
+
* Computer-use action payload for capturing the current display.
|
|
745
|
+
*
|
|
746
|
+
* @category computer use
|
|
747
|
+
* @since 4.0.0
|
|
443
748
|
*/
|
|
444
749
|
export type ComputerUseScreenshotAction = typeof ComputerUseScreenshotAction.Type
|
|
445
750
|
|
|
446
751
|
/**
|
|
447
|
-
*
|
|
752
|
+
* Schema for a computer-use action that enters text.
|
|
753
|
+
*
|
|
754
|
+
* **When to use**
|
|
755
|
+
*
|
|
756
|
+
* Use to validate or construct a computer-use action for entering ordinary text
|
|
757
|
+
* strings.
|
|
448
758
|
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
759
|
+
* **Details**
|
|
760
|
+
*
|
|
761
|
+
* The payload uses `action: "type"` and a `text` string containing the text to
|
|
762
|
+
* enter.
|
|
763
|
+
*
|
|
764
|
+
* @see {@link ComputerUseKeyAction} for key presses and keyboard shortcuts
|
|
765
|
+
*
|
|
766
|
+
* @category computer use
|
|
767
|
+
* @since 4.0.0
|
|
451
768
|
*/
|
|
452
769
|
export const TypeAction = Schema.Struct({
|
|
453
770
|
action: Schema.Literal("type"),
|
|
@@ -457,8 +774,15 @@ export const TypeAction = Schema.Struct({
|
|
|
457
774
|
text: Schema.String
|
|
458
775
|
})
|
|
459
776
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
777
|
+
* Computer-use action payload for typing a text string.
|
|
778
|
+
*
|
|
779
|
+
* **Details**
|
|
780
|
+
*
|
|
781
|
+
* The payload uses `action: "type"` and a `text` string containing the text to
|
|
782
|
+
* enter.
|
|
783
|
+
*
|
|
784
|
+
* @category computer use
|
|
785
|
+
* @since 4.0.0
|
|
462
786
|
*/
|
|
463
787
|
export type TypeAction = typeof TypeAction.Type
|
|
464
788
|
|
|
@@ -475,10 +799,29 @@ const ComputerUse_20241022_Actions = Schema.Union([
|
|
|
475
799
|
// -----------------------------------------------------------------------------
|
|
476
800
|
|
|
477
801
|
/**
|
|
478
|
-
*
|
|
802
|
+
* Schema for a computer-use action that performs a double click.
|
|
803
|
+
*
|
|
804
|
+
* **When to use**
|
|
805
|
+
*
|
|
806
|
+
* Use to validate or construct an Anthropic computer-use payload for double
|
|
807
|
+
* clicking at the current mouse position or at a specific screen coordinate.
|
|
808
|
+
*
|
|
809
|
+
* **Details**
|
|
810
|
+
*
|
|
811
|
+
* The encoded payload uses `action: "double_click"`. The optional
|
|
812
|
+
* `coordinate` field supplies the `[x, y]` pixel position; when omitted, the
|
|
813
|
+
* action uses the current mouse position.
|
|
814
|
+
*
|
|
815
|
+
* **Gotchas**
|
|
816
|
+
*
|
|
817
|
+
* The coordinate schema only checks that the value is a two-number tuple. It
|
|
818
|
+
* does not validate that the point falls within the configured display
|
|
819
|
+
* dimensions.
|
|
479
820
|
*
|
|
480
|
-
* @
|
|
481
|
-
*
|
|
821
|
+
* @see {@link ComputerUseLeftClickAction} for performing a single left click
|
|
822
|
+
*
|
|
823
|
+
* @category computer use
|
|
824
|
+
* @since 4.0.0
|
|
482
825
|
*/
|
|
483
826
|
export const ComputerUseDoubleClickAction = Schema.Struct({
|
|
484
827
|
action: Schema.Literal("double_click"),
|
|
@@ -489,16 +832,37 @@ export const ComputerUseDoubleClickAction = Schema.Struct({
|
|
|
489
832
|
coordinate: Schema.optional(Coordinate)
|
|
490
833
|
})
|
|
491
834
|
/**
|
|
492
|
-
*
|
|
493
|
-
*
|
|
835
|
+
* Computer-use action payload for performing a double click, optionally at a specific coordinate.
|
|
836
|
+
*
|
|
837
|
+
* @category computer use
|
|
838
|
+
* @since 4.0.0
|
|
494
839
|
*/
|
|
495
840
|
export type ComputerUseDoubleClickAction = typeof ComputerUseDoubleClickAction.Type
|
|
496
841
|
|
|
497
842
|
/**
|
|
498
|
-
*
|
|
843
|
+
* Keeps a key pressed for a specified duration during computer-use execution.
|
|
844
|
+
*
|
|
845
|
+
* **When to use**
|
|
846
|
+
*
|
|
847
|
+
* Use to keep a keyboard key depressed for a fixed number of seconds in a
|
|
848
|
+
* computer-use action sequence.
|
|
849
|
+
*
|
|
850
|
+
* **Details**
|
|
851
|
+
*
|
|
852
|
+
* The schema describes objects with `action: "hold_key"`, a `text` field
|
|
853
|
+
* containing the key to hold, and a `duration` field containing the number of
|
|
854
|
+
* seconds to hold it.
|
|
499
855
|
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
856
|
+
* **Gotchas**
|
|
857
|
+
*
|
|
858
|
+
* The schema only checks that `duration` is a number; it does not require a
|
|
859
|
+
* positive value.
|
|
860
|
+
*
|
|
861
|
+
* @see {@link ComputerUseKeyAction} for pressing a key or key combination without holding it
|
|
862
|
+
* @see {@link ComputerUseWaitAction} for pausing between actions without holding a key
|
|
863
|
+
*
|
|
864
|
+
* @category computer use
|
|
865
|
+
* @since 4.0.0
|
|
502
866
|
*/
|
|
503
867
|
export const ComputerUseHoldKeyAction = Schema.Struct({
|
|
504
868
|
action: Schema.Literal("hold_key"),
|
|
@@ -512,16 +876,48 @@ export const ComputerUseHoldKeyAction = Schema.Struct({
|
|
|
512
876
|
duration: Schema.Number
|
|
513
877
|
})
|
|
514
878
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
879
|
+
* Computer-use action payload for holding a key for a specified duration.
|
|
880
|
+
*
|
|
881
|
+
* **When to use**
|
|
882
|
+
*
|
|
883
|
+
* Use to represent a key that should remain pressed for a measured interval.
|
|
884
|
+
*
|
|
885
|
+
* **Details**
|
|
886
|
+
*
|
|
887
|
+
* Set `action` to `"hold_key"`, `text` to the key to hold, and `duration` to
|
|
888
|
+
* the number of seconds to hold it.
|
|
889
|
+
*
|
|
890
|
+
* @see {@link ComputerUseKeyAction} for a single key press or key combination without a hold duration
|
|
891
|
+
*
|
|
892
|
+
* @category computer use
|
|
893
|
+
* @since 4.0.0
|
|
517
894
|
*/
|
|
518
895
|
export type ComputerUseHoldKeyAction = typeof ComputerUseHoldKeyAction.Type
|
|
519
896
|
|
|
520
897
|
/**
|
|
521
|
-
*
|
|
898
|
+
* Schema for a computer-use action that drags with the left mouse button.
|
|
899
|
+
*
|
|
900
|
+
* **When to use**
|
|
901
|
+
*
|
|
902
|
+
* Use to validate or construct an Anthropic computer-use payload for dragging
|
|
903
|
+
* from one screen coordinate to another in a single action.
|
|
904
|
+
*
|
|
905
|
+
* **Details**
|
|
906
|
+
*
|
|
907
|
+
* The encoded payload uses `action: "left_click_drag"` and requires both
|
|
908
|
+
* `start_coordinate` and `coordinate` as `[x, y]` pixel positions.
|
|
522
909
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
910
|
+
* **Gotchas**
|
|
911
|
+
*
|
|
912
|
+
* The coordinate schema only checks that each value is a two-number tuple. It
|
|
913
|
+
* does not validate that either point falls within the configured display
|
|
914
|
+
* dimensions.
|
|
915
|
+
*
|
|
916
|
+
* @see {@link ComputerUseLeftMouseDownAction} for starting a manual drag sequence
|
|
917
|
+
* @see {@link ComputerUseLeftMouseUpAction} for ending a manual drag sequence
|
|
918
|
+
*
|
|
919
|
+
* @category computer use
|
|
920
|
+
* @since 4.0.0
|
|
525
921
|
*/
|
|
526
922
|
export const ComputerUseLeftClickDragAction = Schema.Struct({
|
|
527
923
|
action: Schema.Literal("left_click_drag"),
|
|
@@ -535,18 +931,23 @@ export const ComputerUseLeftClickDragAction = Schema.Struct({
|
|
|
535
931
|
coordinate: Coordinate
|
|
536
932
|
})
|
|
537
933
|
/**
|
|
538
|
-
*
|
|
539
|
-
*
|
|
934
|
+
* Computer-use action payload for dragging from a start coordinate to an end coordinate.
|
|
935
|
+
*
|
|
936
|
+
* @category computer use
|
|
937
|
+
* @since 4.0.0
|
|
540
938
|
*/
|
|
541
939
|
export type ComputerUseLeftClickDragAction = typeof ComputerUseLeftClickDragAction.Type
|
|
542
940
|
|
|
543
941
|
/**
|
|
544
|
-
*
|
|
942
|
+
* Starts a left mouse button press without releasing it.
|
|
943
|
+
*
|
|
944
|
+
* **When to use**
|
|
545
945
|
*
|
|
546
|
-
*
|
|
946
|
+
* Use when constructing a manual click or drag sequence that should press and
|
|
947
|
+
* hold the left mouse button before a later release.
|
|
547
948
|
*
|
|
548
|
-
* @
|
|
549
|
-
* @
|
|
949
|
+
* @category computer use
|
|
950
|
+
* @since 4.0.0
|
|
550
951
|
*/
|
|
551
952
|
export const ComputerUseLeftMouseDownAction = Schema.Struct({
|
|
552
953
|
action: Schema.Literal("left_mouse_down"),
|
|
@@ -557,18 +958,23 @@ export const ComputerUseLeftMouseDownAction = Schema.Struct({
|
|
|
557
958
|
coordinate: Schema.optional(Coordinate)
|
|
558
959
|
})
|
|
559
960
|
/**
|
|
560
|
-
*
|
|
561
|
-
*
|
|
961
|
+
* Computer-use action payload for pressing and holding the left mouse button, optionally at a specific coordinate.
|
|
962
|
+
*
|
|
963
|
+
* @category computer use
|
|
964
|
+
* @since 4.0.0
|
|
562
965
|
*/
|
|
563
966
|
export type ComputerUseLeftMouseDownAction = typeof ComputerUseLeftMouseDownAction.Type
|
|
564
967
|
|
|
565
968
|
/**
|
|
566
|
-
*
|
|
969
|
+
* Releases the left mouse button.
|
|
567
970
|
*
|
|
568
|
-
*
|
|
971
|
+
* **When to use**
|
|
569
972
|
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
973
|
+
* Use when constructing a manual click or drag sequence that should release the
|
|
974
|
+
* left mouse button after it was previously held down.
|
|
975
|
+
*
|
|
976
|
+
* @category computer use
|
|
977
|
+
* @since 4.0.0
|
|
572
978
|
*/
|
|
573
979
|
export const ComputerUseLeftMouseUpAction = Schema.Struct({
|
|
574
980
|
action: Schema.Literal("left_mouse_up"),
|
|
@@ -579,16 +985,37 @@ export const ComputerUseLeftMouseUpAction = Schema.Struct({
|
|
|
579
985
|
coordinate: Schema.optional(Coordinate)
|
|
580
986
|
})
|
|
581
987
|
/**
|
|
582
|
-
*
|
|
583
|
-
*
|
|
988
|
+
* Computer-use action payload for releasing the left mouse button, optionally at a specific coordinate.
|
|
989
|
+
*
|
|
990
|
+
* @category computer use
|
|
991
|
+
* @since 4.0.0
|
|
584
992
|
*/
|
|
585
993
|
export type ComputerUseLeftMouseUpAction = typeof ComputerUseLeftMouseUpAction.Type
|
|
586
994
|
|
|
587
995
|
/**
|
|
588
|
-
*
|
|
996
|
+
* Schema for a computer-use action that performs a middle click.
|
|
997
|
+
*
|
|
998
|
+
* **When to use**
|
|
999
|
+
*
|
|
1000
|
+
* Use to validate or construct a middle-button click action for Anthropic
|
|
1001
|
+
* computer use, optionally targeting a specific screen coordinate.
|
|
1002
|
+
*
|
|
1003
|
+
* **Details**
|
|
1004
|
+
*
|
|
1005
|
+
* The payload must use `action: "middle_click"`. When `coordinate` is omitted,
|
|
1006
|
+
* the click occurs at the current mouse position.
|
|
589
1007
|
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
1008
|
+
* **Gotchas**
|
|
1009
|
+
*
|
|
1010
|
+
* This action is available in the 2025-01-24 computer-use action set and later;
|
|
1011
|
+
* it is not part of `ComputerUse_20241022`.
|
|
1012
|
+
*
|
|
1013
|
+
* @see {@link ComputerUse_20250124} for the provider-defined tool version that first accepts this action
|
|
1014
|
+
* @see {@link ComputerUseLeftClickAction} for primary-button clicks
|
|
1015
|
+
* @see {@link ComputerUseRightClickAction} for secondary-button clicks
|
|
1016
|
+
*
|
|
1017
|
+
* @category computer use
|
|
1018
|
+
* @since 4.0.0
|
|
592
1019
|
*/
|
|
593
1020
|
export const ComputerUseMiddleClickAction = Schema.Struct({
|
|
594
1021
|
action: Schema.Literal("middle_click"),
|
|
@@ -599,16 +1026,33 @@ export const ComputerUseMiddleClickAction = Schema.Struct({
|
|
|
599
1026
|
coordinate: Schema.optional(Coordinate)
|
|
600
1027
|
})
|
|
601
1028
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
1029
|
+
* Computer-use action payload for performing a middle click, optionally at a specific coordinate.
|
|
1030
|
+
*
|
|
1031
|
+
* @category computer use
|
|
1032
|
+
* @since 4.0.0
|
|
604
1033
|
*/
|
|
605
1034
|
export type ComputerUseMiddleClickAction = typeof ComputerUseMiddleClickAction.Type
|
|
606
1035
|
|
|
607
1036
|
/**
|
|
608
|
-
*
|
|
1037
|
+
* Schema for a computer-use action that performs a right click, optionally at a
|
|
1038
|
+
* specific screen coordinate.
|
|
1039
|
+
*
|
|
1040
|
+
* **When to use**
|
|
1041
|
+
*
|
|
1042
|
+
* Use to validate or construct the `right_click` action for an Anthropic
|
|
1043
|
+
* computer-use tool call.
|
|
609
1044
|
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
1045
|
+
* **Details**
|
|
1046
|
+
*
|
|
1047
|
+
* The optional `coordinate` field is an `[x, y]` screen coordinate in pixels.
|
|
1048
|
+
* When omitted, the right click is performed at the current mouse position.
|
|
1049
|
+
*
|
|
1050
|
+
* @see {@link ComputerUse_20250124} for the provider-defined computer-use tool version that introduced this action
|
|
1051
|
+
* @see {@link ComputerUseLeftClickAction} for the corresponding left-click action
|
|
1052
|
+
* @see {@link ComputerUseMiddleClickAction} for the corresponding middle-click action
|
|
1053
|
+
*
|
|
1054
|
+
* @category computer use
|
|
1055
|
+
* @since 4.0.0
|
|
612
1056
|
*/
|
|
613
1057
|
export const ComputerUseRightClickAction = Schema.Struct({
|
|
614
1058
|
action: Schema.Literal("right_click"),
|
|
@@ -619,16 +1063,35 @@ export const ComputerUseRightClickAction = Schema.Struct({
|
|
|
619
1063
|
coordinate: Schema.optional(Coordinate)
|
|
620
1064
|
})
|
|
621
1065
|
/**
|
|
622
|
-
*
|
|
623
|
-
*
|
|
1066
|
+
* Computer-use action payload for performing a right click, optionally at a specific coordinate.
|
|
1067
|
+
*
|
|
1068
|
+
* @category computer use
|
|
1069
|
+
* @since 4.0.0
|
|
624
1070
|
*/
|
|
625
1071
|
export type ComputerUseRightClickAction = typeof ComputerUseRightClickAction.Type
|
|
626
1072
|
|
|
627
1073
|
/**
|
|
628
|
-
*
|
|
1074
|
+
* Schema for a computer-use scroll action.
|
|
1075
|
+
*
|
|
1076
|
+
* **When to use**
|
|
1077
|
+
*
|
|
1078
|
+
* Use when validating or constructing Anthropic computer-use scroll payloads.
|
|
629
1079
|
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
1080
|
+
* **Details**
|
|
1081
|
+
*
|
|
1082
|
+
* The encoded payload uses `action: "scroll"`, an optional `coordinate`,
|
|
1083
|
+
* `scroll_direction`, and `scroll_amount`.
|
|
1084
|
+
*
|
|
1085
|
+
* **Gotchas**
|
|
1086
|
+
*
|
|
1087
|
+
* `coordinate` only checks a two-number tuple, and `scroll_amount` is only
|
|
1088
|
+
* `Schema.Number`.
|
|
1089
|
+
*
|
|
1090
|
+
* @see {@link ComputerUse_20250124} for the tool version that accepts this action
|
|
1091
|
+
* @see {@link ScrollDirection} for the accepted direction literals
|
|
1092
|
+
*
|
|
1093
|
+
* @category computer use
|
|
1094
|
+
* @since 4.0.0
|
|
632
1095
|
*/
|
|
633
1096
|
export const ComputerUseScrollAction = Schema.Struct({
|
|
634
1097
|
action: Schema.Literal("scroll"),
|
|
@@ -647,16 +1110,37 @@ export const ComputerUseScrollAction = Schema.Struct({
|
|
|
647
1110
|
scroll_amount: Schema.Number
|
|
648
1111
|
})
|
|
649
1112
|
/**
|
|
650
|
-
*
|
|
651
|
-
*
|
|
1113
|
+
* Computer-use action payload for scrolling by a specified amount in a specified direction, optionally from a coordinate.
|
|
1114
|
+
*
|
|
1115
|
+
* @category computer use
|
|
1116
|
+
* @since 4.0.0
|
|
652
1117
|
*/
|
|
653
1118
|
export type ComputerUseScrollAction = typeof ComputerUseScrollAction.Type
|
|
654
1119
|
|
|
655
1120
|
/**
|
|
656
|
-
*
|
|
1121
|
+
* Schema for a computer-use triple-click action.
|
|
657
1122
|
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
1123
|
+
* **When to use**
|
|
1124
|
+
*
|
|
1125
|
+
* Use when validating or constructing Anthropic computer-use triple-click
|
|
1126
|
+
* payloads at the current pointer position or an optional coordinate.
|
|
1127
|
+
*
|
|
1128
|
+
* **Details**
|
|
1129
|
+
*
|
|
1130
|
+
* The encoded payload uses `action: "triple_click"` and an optional
|
|
1131
|
+
* `coordinate`.
|
|
1132
|
+
*
|
|
1133
|
+
* **Gotchas**
|
|
1134
|
+
*
|
|
1135
|
+
* `coordinate` only validates as a two-number tuple and does not check display
|
|
1136
|
+
* bounds.
|
|
1137
|
+
*
|
|
1138
|
+
* @see {@link ComputerUse_20250124} for the tool version that accepts this action
|
|
1139
|
+
* @see {@link ComputerUseDoubleClickAction} for the two-click variant
|
|
1140
|
+
* @see {@link ComputerUseLeftClickAction} for a single left click
|
|
1141
|
+
*
|
|
1142
|
+
* @category computer use
|
|
1143
|
+
* @since 4.0.0
|
|
660
1144
|
*/
|
|
661
1145
|
export const ComputerUseTripleClickAction = Schema.Struct({
|
|
662
1146
|
action: Schema.Literal("triple_click"),
|
|
@@ -667,16 +1151,36 @@ export const ComputerUseTripleClickAction = Schema.Struct({
|
|
|
667
1151
|
coordinate: Schema.optional(Coordinate)
|
|
668
1152
|
})
|
|
669
1153
|
/**
|
|
670
|
-
*
|
|
671
|
-
*
|
|
1154
|
+
* Computer-use action payload for performing a triple click, optionally at a specific coordinate.
|
|
1155
|
+
*
|
|
1156
|
+
* @category computer use
|
|
1157
|
+
* @since 4.0.0
|
|
672
1158
|
*/
|
|
673
1159
|
export type ComputerUseTripleClickAction = typeof ComputerUseTripleClickAction.Type
|
|
674
1160
|
|
|
675
1161
|
/**
|
|
676
|
-
*
|
|
1162
|
+
* Schema for a computer-use wait action.
|
|
1163
|
+
*
|
|
1164
|
+
* **When to use**
|
|
1165
|
+
*
|
|
1166
|
+
* Use when validating or constructing Anthropic computer-use payloads that pause
|
|
1167
|
+
* between actions.
|
|
1168
|
+
*
|
|
1169
|
+
* **Details**
|
|
1170
|
+
*
|
|
1171
|
+
* The encoded payload uses `action: "wait"` and a required `duration` in
|
|
1172
|
+
* seconds.
|
|
677
1173
|
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
1174
|
+
* **Gotchas**
|
|
1175
|
+
*
|
|
1176
|
+
* `duration` is only `Schema.Number`; it is not constrained to positive or
|
|
1177
|
+
* finite values.
|
|
1178
|
+
*
|
|
1179
|
+
* @see {@link ComputerUseHoldKeyAction} for another duration-based computer-use action
|
|
1180
|
+
* @see {@link ComputerUse_20250124} for the tool version that accepts this action
|
|
1181
|
+
*
|
|
1182
|
+
* @category computer use
|
|
1183
|
+
* @since 4.0.0
|
|
680
1184
|
*/
|
|
681
1185
|
export const ComputerUseWaitAction = Schema.Struct({
|
|
682
1186
|
action: Schema.Literal("wait"),
|
|
@@ -686,8 +1190,10 @@ export const ComputerUseWaitAction = Schema.Struct({
|
|
|
686
1190
|
duration: Schema.Number
|
|
687
1191
|
})
|
|
688
1192
|
/**
|
|
689
|
-
*
|
|
690
|
-
*
|
|
1193
|
+
* Computer-use action payload for pausing for a specified duration.
|
|
1194
|
+
*
|
|
1195
|
+
* @category computer use
|
|
1196
|
+
* @since 4.0.0
|
|
691
1197
|
*/
|
|
692
1198
|
export type ComputerUseWaitAction = typeof ComputerUseWaitAction.Type
|
|
693
1199
|
|
|
@@ -710,12 +1216,27 @@ const ComputerUse_20250124_Actions = Schema.Union([
|
|
|
710
1216
|
// -----------------------------------------------------------------------------
|
|
711
1217
|
|
|
712
1218
|
/**
|
|
713
|
-
*
|
|
1219
|
+
* Zooms into a specific region of the screen at full resolution.
|
|
1220
|
+
*
|
|
1221
|
+
* **When to use**
|
|
1222
|
+
*
|
|
1223
|
+
* Use when building or validating the 2025-11-24 computer-use action for a
|
|
1224
|
+
* zoom-enabled tool definition.
|
|
1225
|
+
*
|
|
1226
|
+
* **Details**
|
|
714
1227
|
*
|
|
715
|
-
*
|
|
1228
|
+
* The encoded payload uses `action: "zoom"` and a `region` tuple.
|
|
716
1229
|
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
1230
|
+
* **Gotchas**
|
|
1231
|
+
*
|
|
1232
|
+
* Requires `enableZoom: true` in the tool definition. `region` is only a
|
|
1233
|
+
* four-number tuple and does not validate corner ordering or display bounds.
|
|
1234
|
+
*
|
|
1235
|
+
* @see {@link ComputerUse_20251124} for the tool version that accepts this action
|
|
1236
|
+
* @see {@link ComputerUseScreenshotAction} for capturing the full screen instead
|
|
1237
|
+
*
|
|
1238
|
+
* @category computer use
|
|
1239
|
+
* @since 4.0.0
|
|
719
1240
|
*/
|
|
720
1241
|
export const ComputerUseZoomAction = Schema.Struct({
|
|
721
1242
|
action: Schema.Literal("zoom"),
|
|
@@ -726,8 +1247,16 @@ export const ComputerUseZoomAction = Schema.Struct({
|
|
|
726
1247
|
region: Region
|
|
727
1248
|
})
|
|
728
1249
|
/**
|
|
729
|
-
*
|
|
730
|
-
*
|
|
1250
|
+
* Computer-use action payload for zooming into a specific screen region.
|
|
1251
|
+
*
|
|
1252
|
+
* **Gotchas**
|
|
1253
|
+
*
|
|
1254
|
+
* The enclosing computer-use tool must be configured with `enableZoom: true`.
|
|
1255
|
+
* `region` is only a four-number tuple and does not validate corner ordering or
|
|
1256
|
+
* display bounds.
|
|
1257
|
+
*
|
|
1258
|
+
* @category computer use
|
|
1259
|
+
* @since 4.0.0
|
|
731
1260
|
*/
|
|
732
1261
|
export type ComputerUseZoomAction = typeof ComputerUseZoomAction.Type
|
|
733
1262
|
|
|
@@ -741,14 +1270,15 @@ const ComputerUse_20251124_Actions = Schema.Union([
|
|
|
741
1270
|
// -----------------------------------------------------------------------------
|
|
742
1271
|
|
|
743
1272
|
/**
|
|
744
|
-
*
|
|
1273
|
+
* Defines the deprecated computer-use tool for Claude 3.5 Sonnet v2.
|
|
745
1274
|
*
|
|
746
|
-
*
|
|
1275
|
+
* **Details**
|
|
747
1276
|
*
|
|
1277
|
+
* Requires the "computer-use-2024-10-22" beta header.
|
|
748
1278
|
* Basic actions only: screenshot, left_click, type, key, mouse_move.
|
|
749
1279
|
*
|
|
750
|
-
* @
|
|
751
|
-
* @
|
|
1280
|
+
* @category computer use
|
|
1281
|
+
* @since 4.0.0
|
|
752
1282
|
*/
|
|
753
1283
|
export const ComputerUse_20241022 = Tool.providerDefined({
|
|
754
1284
|
id: "anthropic.computer_use_20241022",
|
|
@@ -761,16 +1291,25 @@ export const ComputerUse_20241022 = Tool.providerDefined({
|
|
|
761
1291
|
})
|
|
762
1292
|
|
|
763
1293
|
/**
|
|
764
|
-
*
|
|
1294
|
+
* Defines the computer-use tool for Claude 4 models and Claude Sonnet 3.7.
|
|
765
1295
|
*
|
|
766
|
-
*
|
|
1296
|
+
* **When to use**
|
|
767
1297
|
*
|
|
1298
|
+
* Use when you need Anthropic computer use for Claude 4 models or Claude
|
|
1299
|
+
* Sonnet 3.7 with the 2025-01-24 action set.
|
|
1300
|
+
*
|
|
1301
|
+
* **Details**
|
|
1302
|
+
*
|
|
1303
|
+
* Requires the "computer-use-2025-01-24" beta header.
|
|
768
1304
|
* Includes basic actions plus enhanced actions: scroll, left_click_drag,
|
|
769
1305
|
* right_click, middle_click, double_click, triple_click, left_mouse_down,
|
|
770
1306
|
* left_mouse_up, hold_key, wait.
|
|
771
1307
|
*
|
|
772
|
-
* @
|
|
773
|
-
* @
|
|
1308
|
+
* @see {@link ComputerUse_20241022} for the older basic action set
|
|
1309
|
+
* @see {@link ComputerUse_20251124} for the newer zoom-capable version
|
|
1310
|
+
*
|
|
1311
|
+
* @category computer use
|
|
1312
|
+
* @since 4.0.0
|
|
774
1313
|
*/
|
|
775
1314
|
export const ComputerUse_20250124 = Tool.providerDefined({
|
|
776
1315
|
id: "anthropic.computer_20250124",
|
|
@@ -783,15 +1322,28 @@ export const ComputerUse_20250124 = Tool.providerDefined({
|
|
|
783
1322
|
})
|
|
784
1323
|
|
|
785
1324
|
/**
|
|
786
|
-
*
|
|
1325
|
+
* Defines the computer-use tool for Claude Opus 4.5 only.
|
|
787
1326
|
*
|
|
788
|
-
*
|
|
1327
|
+
* **When to use**
|
|
1328
|
+
*
|
|
1329
|
+
* Use when you need Anthropic computer use for Claude Opus 4.5 with the
|
|
1330
|
+
* 2025-11-24 action set and zoom-capable screen inspection.
|
|
789
1331
|
*
|
|
1332
|
+
* **Details**
|
|
1333
|
+
*
|
|
1334
|
+
* Requires the "computer-use-2025-11-24" beta header.
|
|
790
1335
|
* Includes all actions from computer_20250124 plus the zoom action for
|
|
791
|
-
* detailed screen region inspection.
|
|
1336
|
+
* detailed screen region inspection.
|
|
1337
|
+
*
|
|
1338
|
+
* **Gotchas**
|
|
792
1339
|
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
1340
|
+
* Zoom actions require `enableZoom: true` in args.
|
|
1341
|
+
*
|
|
1342
|
+
* @see {@link ComputerUse_20250124} for the previous action set without zoom
|
|
1343
|
+
* @see {@link ComputerUseZoomAction} for the zoom action payload
|
|
1344
|
+
*
|
|
1345
|
+
* @category computer use
|
|
1346
|
+
* @since 4.0.0
|
|
795
1347
|
*/
|
|
796
1348
|
export const ComputerUse_20251124 = Tool.providerDefined({
|
|
797
1349
|
id: "anthropic.computer_20251124",
|
|
@@ -812,20 +1364,35 @@ export const ComputerUse_20251124 = Tool.providerDefined({
|
|
|
812
1364
|
// -----------------------------------------------------------------------------
|
|
813
1365
|
|
|
814
1366
|
/**
|
|
815
|
-
*
|
|
1367
|
+
* Defines a `[start, end]` line range for viewing file contents.
|
|
1368
|
+
*
|
|
1369
|
+
* **When to use**
|
|
816
1370
|
*
|
|
817
|
-
*
|
|
1371
|
+
* Use when constructing or validating `view_range` for memory or text editor
|
|
1372
|
+
* view commands.
|
|
818
1373
|
*
|
|
819
|
-
*
|
|
820
|
-
* @example [100, -1] // View from line 100 to end of file
|
|
1374
|
+
* **Details**
|
|
821
1375
|
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
1376
|
+
* Lines are 1-indexed. Use `-1` for end to read to the end of the file. For
|
|
1377
|
+
* example, `[1, 50]` views lines 1-50 and `[100, -1]` views from line 100 to
|
|
1378
|
+
* the end of the file.
|
|
1379
|
+
*
|
|
1380
|
+
* @see {@link MemoryViewCommand} for memory view payloads that use this range
|
|
1381
|
+
* @see {@link TextEditorViewCommand} for text editor view payloads that use this range
|
|
1382
|
+
*
|
|
1383
|
+
* @category memory
|
|
1384
|
+
* @since 4.0.0
|
|
824
1385
|
*/
|
|
825
1386
|
export const ViewRange = Schema.Tuple([Schema.Number, Schema.Number])
|
|
826
1387
|
/**
|
|
827
|
-
*
|
|
828
|
-
*
|
|
1388
|
+
* A `[start, end]` 1-indexed line range for viewing file contents, using `-1` as the end value to read through the end of the file.
|
|
1389
|
+
*
|
|
1390
|
+
* **When to use**
|
|
1391
|
+
*
|
|
1392
|
+
* Use when typing `view_range` for memory or text editor view commands.
|
|
1393
|
+
*
|
|
1394
|
+
* @category memory
|
|
1395
|
+
* @since 4.0.0
|
|
829
1396
|
*/
|
|
830
1397
|
export type ViewRange = typeof ViewRange.Type
|
|
831
1398
|
|
|
@@ -834,10 +1401,14 @@ export type ViewRange = typeof ViewRange.Type
|
|
|
834
1401
|
// -----------------------------------------------------------------------------
|
|
835
1402
|
|
|
836
1403
|
/**
|
|
837
|
-
*
|
|
1404
|
+
* Schema for the memory tool command that creates a new file at a path.
|
|
1405
|
+
*
|
|
1406
|
+
* **Details**
|
|
838
1407
|
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
1408
|
+
* The payload contains `command: "create"` and a `path` string.
|
|
1409
|
+
*
|
|
1410
|
+
* @category memory
|
|
1411
|
+
* @since 4.0.0
|
|
841
1412
|
*/
|
|
842
1413
|
export const MemoryCreateCommand = Schema.Struct({
|
|
843
1414
|
command: Schema.Literal("create"),
|
|
@@ -847,35 +1418,51 @@ export const MemoryCreateCommand = Schema.Struct({
|
|
|
847
1418
|
path: Schema.String
|
|
848
1419
|
})
|
|
849
1420
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
1421
|
+
* Memory tool command payload for creating a new file at a path.
|
|
1422
|
+
*
|
|
1423
|
+
* @category memory
|
|
1424
|
+
* @since 4.0.0
|
|
852
1425
|
*/
|
|
853
1426
|
export type MemoryCreateCommand = typeof MemoryCreateCommand.Type
|
|
854
1427
|
|
|
855
1428
|
/**
|
|
856
|
-
*
|
|
1429
|
+
* Schema for a memory command that deletes a file or directory.
|
|
857
1430
|
*
|
|
858
|
-
* @
|
|
859
|
-
* @
|
|
1431
|
+
* @category memory
|
|
1432
|
+
* @since 4.0.0
|
|
860
1433
|
*/
|
|
861
1434
|
export const MemoryDeleteCommand = Schema.Struct({
|
|
862
1435
|
command: Schema.Literal("delete"),
|
|
863
1436
|
/**
|
|
864
|
-
* The path to the file to delete.
|
|
1437
|
+
* The path to the file or directory to delete.
|
|
865
1438
|
*/
|
|
866
1439
|
path: Schema.String
|
|
867
1440
|
})
|
|
868
1441
|
/**
|
|
869
|
-
*
|
|
870
|
-
*
|
|
1442
|
+
* Memory tool command payload for deleting a file or directory at a path.
|
|
1443
|
+
*
|
|
1444
|
+
* @category memory
|
|
1445
|
+
* @since 4.0.0
|
|
871
1446
|
*/
|
|
872
1447
|
export type MemoryDeleteCommand = typeof MemoryDeleteCommand.Type
|
|
873
1448
|
|
|
874
1449
|
/**
|
|
875
|
-
*
|
|
1450
|
+
* Schema for the memory `insert` command.
|
|
876
1451
|
*
|
|
877
|
-
*
|
|
878
|
-
*
|
|
1452
|
+
* **When to use**
|
|
1453
|
+
*
|
|
1454
|
+
* Use when validating or constructing `insert` payloads for `Memory_20250818`.
|
|
1455
|
+
*
|
|
1456
|
+
* **Details**
|
|
1457
|
+
*
|
|
1458
|
+
* The payload is discriminated by `command: "insert"` and requires `path`,
|
|
1459
|
+
* `insert_line`, and `insert_text`.
|
|
1460
|
+
*
|
|
1461
|
+
* @see {@link Memory_20250818} for the provider-defined tool that consumes this command
|
|
1462
|
+
* @see {@link MemoryStrReplaceCommand} for replacing existing text instead
|
|
1463
|
+
*
|
|
1464
|
+
* @category memory
|
|
1465
|
+
* @since 4.0.0
|
|
879
1466
|
*/
|
|
880
1467
|
export const MemoryInsertCommand = Schema.Struct({
|
|
881
1468
|
command: Schema.Literal("insert"),
|
|
@@ -893,16 +1480,23 @@ export const MemoryInsertCommand = Schema.Struct({
|
|
|
893
1480
|
insert_text: Schema.String
|
|
894
1481
|
})
|
|
895
1482
|
/**
|
|
896
|
-
*
|
|
897
|
-
*
|
|
1483
|
+
* Memory tool command payload for inserting text at a specific line in a file.
|
|
1484
|
+
*
|
|
1485
|
+
* @category memory
|
|
1486
|
+
* @since 4.0.0
|
|
898
1487
|
*/
|
|
899
1488
|
export type MemoryInsertCommand = typeof MemoryInsertCommand.Type
|
|
900
1489
|
|
|
901
1490
|
/**
|
|
902
|
-
*
|
|
1491
|
+
* Schema for the memory command that renames or moves a file or directory.
|
|
903
1492
|
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
1493
|
+
* **Details**
|
|
1494
|
+
*
|
|
1495
|
+
* The payload uses `command: "rename"` and requires `old_path` as the current
|
|
1496
|
+
* path plus `new_path` as the new destination path.
|
|
1497
|
+
*
|
|
1498
|
+
* @category memory
|
|
1499
|
+
* @since 4.0.0
|
|
906
1500
|
*/
|
|
907
1501
|
export const MemoryRenameCommand = Schema.Struct({
|
|
908
1502
|
command: Schema.Literal("rename"),
|
|
@@ -916,16 +1510,30 @@ export const MemoryRenameCommand = Schema.Struct({
|
|
|
916
1510
|
new_path: Schema.String
|
|
917
1511
|
})
|
|
918
1512
|
/**
|
|
919
|
-
*
|
|
920
|
-
*
|
|
1513
|
+
* Memory tool command payload for renaming or moving a file or directory.
|
|
1514
|
+
*
|
|
1515
|
+
* @category memory
|
|
1516
|
+
* @since 4.0.0
|
|
921
1517
|
*/
|
|
922
1518
|
export type MemoryRenameCommand = typeof MemoryRenameCommand.Type
|
|
923
1519
|
|
|
924
1520
|
/**
|
|
925
|
-
*
|
|
1521
|
+
* Schema for the memory `str_replace` command.
|
|
1522
|
+
*
|
|
1523
|
+
* **When to use**
|
|
1524
|
+
*
|
|
1525
|
+
* Use when validating or constructing `str_replace` payloads for
|
|
1526
|
+
* `Memory_20250818`.
|
|
1527
|
+
*
|
|
1528
|
+
* **Details**
|
|
926
1529
|
*
|
|
927
|
-
*
|
|
928
|
-
*
|
|
1530
|
+
* The payload is discriminated by `command: "str_replace"` and requires `path`,
|
|
1531
|
+
* `old_str`, and `new_str`.
|
|
1532
|
+
*
|
|
1533
|
+
* @see {@link Memory_20250818} for the provider-defined tool that consumes this command
|
|
1534
|
+
*
|
|
1535
|
+
* @category memory
|
|
1536
|
+
* @since 4.0.0
|
|
929
1537
|
*/
|
|
930
1538
|
export const MemoryStrReplaceCommand = Schema.Struct({
|
|
931
1539
|
command: Schema.Literal("str_replace"),
|
|
@@ -943,21 +1551,28 @@ export const MemoryStrReplaceCommand = Schema.Struct({
|
|
|
943
1551
|
new_str: Schema.String
|
|
944
1552
|
})
|
|
945
1553
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
1554
|
+
* Memory tool command payload for replacing text in a file.
|
|
1555
|
+
*
|
|
1556
|
+
* @category memory
|
|
1557
|
+
* @since 4.0.0
|
|
948
1558
|
*/
|
|
949
1559
|
export type MemoryStrReplaceCommand = typeof MemoryStrReplaceCommand.Type
|
|
950
1560
|
|
|
951
1561
|
/**
|
|
952
1562
|
* Shows directory contents or file contents with optional line ranges.
|
|
953
1563
|
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
1564
|
+
* **Details**
|
|
1565
|
+
*
|
|
1566
|
+
* When used on a file, returns file contents optionally limited by `view_range`.
|
|
1567
|
+
* When used on a directory, lists contents.
|
|
1568
|
+
*
|
|
1569
|
+
* @category memory
|
|
1570
|
+
* @since 4.0.0
|
|
956
1571
|
*/
|
|
957
1572
|
export const MemoryViewCommand = Schema.Struct({
|
|
958
1573
|
command: Schema.Literal("view"),
|
|
959
1574
|
/**
|
|
960
|
-
* The path to the file to view.
|
|
1575
|
+
* The path to the file or directory to view.
|
|
961
1576
|
*/
|
|
962
1577
|
path: Schema.String,
|
|
963
1578
|
/**
|
|
@@ -966,8 +1581,10 @@ export const MemoryViewCommand = Schema.Struct({
|
|
|
966
1581
|
view_range: Schema.optional(ViewRange)
|
|
967
1582
|
})
|
|
968
1583
|
/**
|
|
969
|
-
*
|
|
970
|
-
*
|
|
1584
|
+
* Memory tool command payload for viewing a file or directory, optionally with a file line range.
|
|
1585
|
+
*
|
|
1586
|
+
* @category memory
|
|
1587
|
+
* @since 4.0.0
|
|
971
1588
|
*/
|
|
972
1589
|
export type MemoryViewCommand = typeof MemoryViewCommand.Type
|
|
973
1590
|
|
|
@@ -985,13 +1602,15 @@ const Memory_20250818_Commands = Schema.Union([
|
|
|
985
1602
|
// -----------------------------------------------------------------------------
|
|
986
1603
|
|
|
987
1604
|
/**
|
|
988
|
-
*
|
|
1605
|
+
* Defines the memory tool for persistent file operations across conversations.
|
|
1606
|
+
*
|
|
1607
|
+
* **Details**
|
|
989
1608
|
*
|
|
990
1609
|
* Provides commands for creating, viewing, editing, renaming, and deleting
|
|
991
1610
|
* files within the model's memory space.
|
|
992
1611
|
*
|
|
993
|
-
* @
|
|
994
|
-
* @
|
|
1612
|
+
* @category memory
|
|
1613
|
+
* @since 4.0.0
|
|
995
1614
|
*/
|
|
996
1615
|
export const Memory_20250818 = Tool.providerDefined({
|
|
997
1616
|
id: "anthropic.memory_20250818",
|
|
@@ -1010,13 +1629,24 @@ export const Memory_20250818 = Tool.providerDefined({
|
|
|
1010
1629
|
// -----------------------------------------------------------------------------
|
|
1011
1630
|
|
|
1012
1631
|
/**
|
|
1013
|
-
*
|
|
1632
|
+
* Reads the contents of a file or lists directory contents.
|
|
1014
1633
|
*
|
|
1015
|
-
* When
|
|
1016
|
-
* When used on a directory: Lists all files and subdirectories.
|
|
1634
|
+
* **When to use**
|
|
1017
1635
|
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1636
|
+
* Use when validating or constructing the standalone Anthropic Text Editor
|
|
1637
|
+
* `view` command.
|
|
1638
|
+
*
|
|
1639
|
+
* **Details**
|
|
1640
|
+
*
|
|
1641
|
+
* When used on a file, returns the file contents, optionally limited to a line
|
|
1642
|
+
* range. When used on a directory, lists all files and subdirectories.
|
|
1643
|
+
* `view_range` is a 1-indexed `[start, end]` tuple where `-1` means through
|
|
1644
|
+
* the end of the file.
|
|
1645
|
+
*
|
|
1646
|
+
* @see {@link CodeExecutionTextEditorView} for the code-execution variant without `view_range`
|
|
1647
|
+
*
|
|
1648
|
+
* @category text editor
|
|
1649
|
+
* @since 4.0.0
|
|
1020
1650
|
*/
|
|
1021
1651
|
export const TextEditorViewCommand = Schema.Struct({
|
|
1022
1652
|
command: Schema.Literal("view"),
|
|
@@ -1031,18 +1661,37 @@ export const TextEditorViewCommand = Schema.Struct({
|
|
|
1031
1661
|
view_range: Schema.optional(ViewRange)
|
|
1032
1662
|
})
|
|
1033
1663
|
/**
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1664
|
+
* Text editor command payload for viewing file contents or listing directory contents.
|
|
1665
|
+
*
|
|
1666
|
+
* **Details**
|
|
1667
|
+
*
|
|
1668
|
+
* `view_range` is a 1-indexed `[start, end]` tuple where `-1` means through
|
|
1669
|
+
* the end of the file.
|
|
1670
|
+
*
|
|
1671
|
+
* @category text editor
|
|
1672
|
+
* @since 4.0.0
|
|
1036
1673
|
*/
|
|
1037
1674
|
export type TextEditorViewCommand = typeof TextEditorViewCommand.Type
|
|
1038
1675
|
|
|
1039
1676
|
/**
|
|
1040
1677
|
* Create a new file with specified content.
|
|
1041
1678
|
*
|
|
1042
|
-
*
|
|
1679
|
+
* **When to use**
|
|
1680
|
+
*
|
|
1681
|
+
* Use when validating or constructing an Anthropic text editor `create`
|
|
1682
|
+
* command.
|
|
1683
|
+
*
|
|
1684
|
+
* **Details**
|
|
1685
|
+
*
|
|
1686
|
+
* The payload is discriminated by `command: "create"` and requires both `path`
|
|
1687
|
+
* and `file_text`.
|
|
1688
|
+
*
|
|
1689
|
+
* **Gotchas**
|
|
1690
|
+
*
|
|
1691
|
+
* Fails if the file already exists. Parent directories must exist.
|
|
1043
1692
|
*
|
|
1044
|
-
* @
|
|
1045
|
-
* @
|
|
1693
|
+
* @category text editor
|
|
1694
|
+
* @since 4.0.0
|
|
1046
1695
|
*/
|
|
1047
1696
|
export const TextEditorCreateCommand = Schema.Struct({
|
|
1048
1697
|
command: Schema.Literal("create"),
|
|
@@ -1056,19 +1705,45 @@ export const TextEditorCreateCommand = Schema.Struct({
|
|
|
1056
1705
|
file_text: Schema.String
|
|
1057
1706
|
})
|
|
1058
1707
|
/**
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1708
|
+
* Text editor command payload for creating a new file with the specified content.
|
|
1709
|
+
*
|
|
1710
|
+
* **When to use**
|
|
1711
|
+
*
|
|
1712
|
+
* Use when typing parsed text-editor create command payloads after schema
|
|
1713
|
+
* validation and before dispatching to Anthropic tool handlers.
|
|
1714
|
+
*
|
|
1715
|
+
* **Gotchas**
|
|
1716
|
+
*
|
|
1717
|
+
* The command fails if the file already exists or if parent directories are missing.
|
|
1718
|
+
*
|
|
1719
|
+
* @category text editor
|
|
1720
|
+
* @since 4.0.0
|
|
1061
1721
|
*/
|
|
1062
1722
|
export type TextEditorCreateCommand = typeof TextEditorCreateCommand.Type
|
|
1063
1723
|
|
|
1064
1724
|
/**
|
|
1065
|
-
*
|
|
1725
|
+
* Replaces a specific string in a file with a new string.
|
|
1726
|
+
*
|
|
1727
|
+
* **When to use**
|
|
1728
|
+
*
|
|
1729
|
+
* Use when validating or constructing standalone Anthropic text editor
|
|
1730
|
+
* `str_replace` commands.
|
|
1731
|
+
*
|
|
1732
|
+
* **Details**
|
|
1733
|
+
*
|
|
1734
|
+
* The payload uses `command: "str_replace"`, `path`, `old_str`, and `new_str`.
|
|
1735
|
+
* `new_str` may be empty to delete text.
|
|
1736
|
+
*
|
|
1737
|
+
* **Gotchas**
|
|
1066
1738
|
*
|
|
1067
1739
|
* The `old_str` must match exactly (including whitespace and indentation)
|
|
1068
1740
|
* and must be unique in the file.
|
|
1069
1741
|
*
|
|
1070
|
-
* @
|
|
1071
|
-
* @
|
|
1742
|
+
* @see {@link TextEditorViewCommand} for reading contents before choosing `old_str`
|
|
1743
|
+
* @see {@link CodeExecutionTextEditorStrReplace} for the code-execution variant
|
|
1744
|
+
*
|
|
1745
|
+
* @category text editor
|
|
1746
|
+
* @since 4.0.0
|
|
1072
1747
|
*/
|
|
1073
1748
|
export const TextEditorStrReplaceCommand = Schema.Struct({
|
|
1074
1749
|
command: Schema.Literal("str_replace"),
|
|
@@ -1086,18 +1761,33 @@ export const TextEditorStrReplaceCommand = Schema.Struct({
|
|
|
1086
1761
|
new_str: Schema.String
|
|
1087
1762
|
})
|
|
1088
1763
|
/**
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1764
|
+
* Text editor command payload for replacing one exact, unique string in a file.
|
|
1765
|
+
*
|
|
1766
|
+
* **When to use**
|
|
1767
|
+
*
|
|
1768
|
+
* Use when typing parsed text-editor replace command payloads that must carry
|
|
1769
|
+
* one exact `old_str` match.
|
|
1770
|
+
*
|
|
1771
|
+
* **Gotchas**
|
|
1772
|
+
*
|
|
1773
|
+
* The `old_str` must match exactly, including whitespace and indentation, and
|
|
1774
|
+
* must be unique in the file.
|
|
1775
|
+
*
|
|
1776
|
+
* @category text editor
|
|
1777
|
+
* @since 4.0.0
|
|
1091
1778
|
*/
|
|
1092
1779
|
export type TextEditorStrReplaceCommand = typeof TextEditorStrReplaceCommand.Type
|
|
1093
1780
|
|
|
1094
1781
|
/**
|
|
1095
|
-
*
|
|
1782
|
+
* Inserts text at a specific line number in a file.
|
|
1783
|
+
*
|
|
1784
|
+
* **Details**
|
|
1096
1785
|
*
|
|
1097
|
-
* Inserts the new text
|
|
1786
|
+
* Inserts the new text after the specified line number. Use `0` to insert at
|
|
1787
|
+
* the beginning of the file; other values are 1-indexed.
|
|
1098
1788
|
*
|
|
1099
|
-
* @
|
|
1100
|
-
* @
|
|
1789
|
+
* @category text editor
|
|
1790
|
+
* @since 4.0.0
|
|
1101
1791
|
*/
|
|
1102
1792
|
export const TextEditorInsertCommand = Schema.Struct({
|
|
1103
1793
|
command: Schema.Literal("insert"),
|
|
@@ -1115,21 +1805,29 @@ export const TextEditorInsertCommand = Schema.Struct({
|
|
|
1115
1805
|
new_str: Schema.String
|
|
1116
1806
|
})
|
|
1117
1807
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1808
|
+
* Text editor command payload for inserting text after a specific line number in a file.
|
|
1809
|
+
*
|
|
1810
|
+
* @category text editor
|
|
1811
|
+
* @since 4.0.0
|
|
1120
1812
|
*/
|
|
1121
1813
|
export type TextEditorInsertCommand = typeof TextEditorInsertCommand.Type
|
|
1122
1814
|
|
|
1123
1815
|
/**
|
|
1124
|
-
*
|
|
1816
|
+
* Undoes the last edit made to a file.
|
|
1125
1817
|
*
|
|
1126
|
-
*
|
|
1818
|
+
* **Details**
|
|
1127
1819
|
*
|
|
1128
|
-
*
|
|
1129
|
-
*
|
|
1820
|
+
* Reverts the most recent `str_replace`, `insert`, or `create` operation on the
|
|
1821
|
+
* file.
|
|
1130
1822
|
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1823
|
+
* **Gotchas**
|
|
1824
|
+
*
|
|
1825
|
+
* This command is available in `text_editor_20241022` and
|
|
1826
|
+
* `text_editor_20250124`, but not in `text_editor_20250429` or
|
|
1827
|
+
* `text_editor_20250728`.
|
|
1828
|
+
*
|
|
1829
|
+
* @category text editor
|
|
1830
|
+
* @since 4.0.0
|
|
1133
1831
|
*/
|
|
1134
1832
|
export const TextEditorUndoEditCommand = Schema.Struct({
|
|
1135
1833
|
command: Schema.Literal("undo_edit"),
|
|
@@ -1139,8 +1837,15 @@ export const TextEditorUndoEditCommand = Schema.Struct({
|
|
|
1139
1837
|
path: Schema.String
|
|
1140
1838
|
})
|
|
1141
1839
|
/**
|
|
1142
|
-
*
|
|
1143
|
-
*
|
|
1840
|
+
* Text editor command payload for undoing the most recent edit to a file.
|
|
1841
|
+
*
|
|
1842
|
+
* **Gotchas**
|
|
1843
|
+
*
|
|
1844
|
+
* Available for `text_editor_20241022` and `text_editor_20250124`, but not for
|
|
1845
|
+
* `text_editor_20250429` or `text_editor_20250728`.
|
|
1846
|
+
*
|
|
1847
|
+
* @category text editor
|
|
1848
|
+
* @since 4.0.0
|
|
1144
1849
|
*/
|
|
1145
1850
|
export type TextEditorUndoEditCommand = typeof TextEditorUndoEditCommand.Type
|
|
1146
1851
|
|
|
@@ -1176,12 +1881,23 @@ const TextEditor_StrReplaceBasedEdit_Args = Schema.Struct({
|
|
|
1176
1881
|
// -----------------------------------------------------------------------------
|
|
1177
1882
|
|
|
1178
1883
|
/**
|
|
1179
|
-
*
|
|
1884
|
+
* Defines the deprecated text editor tool for Claude 3.5 Sonnet.
|
|
1180
1885
|
*
|
|
1181
|
-
*
|
|
1886
|
+
* **When to use**
|
|
1182
1887
|
*
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1888
|
+
* Use when you need the 2024-10-22 `str_replace_editor` compatibility path for
|
|
1889
|
+
* Claude 3.5 Sonnet.
|
|
1890
|
+
*
|
|
1891
|
+
* **Details**
|
|
1892
|
+
*
|
|
1893
|
+
* Requires the "computer-use-2024-10-22" beta header and supports `view`,
|
|
1894
|
+
* `create`, `str_replace`, `insert`, and `undo_edit` commands.
|
|
1895
|
+
*
|
|
1896
|
+
* @see {@link TextEditor_20250124} for the newer `str_replace_editor` version
|
|
1897
|
+
* @see {@link TextEditor_20250728} for the Claude 4 `str_replace_based_edit_tool` line
|
|
1898
|
+
*
|
|
1899
|
+
* @category text editor
|
|
1900
|
+
* @since 4.0.0
|
|
1185
1901
|
*/
|
|
1186
1902
|
export const TextEditor_20241022 = Tool.providerDefined({
|
|
1187
1903
|
id: "anthropic.text_editor_20241022",
|
|
@@ -1193,10 +1909,23 @@ export const TextEditor_20241022 = Tool.providerDefined({
|
|
|
1193
1909
|
})
|
|
1194
1910
|
|
|
1195
1911
|
/**
|
|
1196
|
-
*
|
|
1912
|
+
* Defines the text editor tool for deprecated Claude Sonnet 3.7.
|
|
1913
|
+
*
|
|
1914
|
+
* **When to use**
|
|
1915
|
+
*
|
|
1916
|
+
* Use when you need the 2025-01-24 Claude Sonnet 3.7 text editor tool using
|
|
1917
|
+
* `str_replace_editor`.
|
|
1197
1918
|
*
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
1919
|
+
* **Details**
|
|
1920
|
+
*
|
|
1921
|
+
* Requires the "computer-use-2025-01-24" beta header, requires a handler, and
|
|
1922
|
+
* supports `view`, `create`, `str_replace`, `insert`, and `undo_edit` commands.
|
|
1923
|
+
*
|
|
1924
|
+
* @see {@link TextEditor_20241022} for the older `str_replace_editor` version
|
|
1925
|
+
* @see {@link TextEditor_20250429} for the Claude 4 `str_replace_based_edit_tool` line
|
|
1926
|
+
*
|
|
1927
|
+
* @category text editor
|
|
1928
|
+
* @since 4.0.0
|
|
1200
1929
|
*/
|
|
1201
1930
|
export const TextEditor_20250124 = Tool.providerDefined({
|
|
1202
1931
|
id: "anthropic.text_editor_20250124",
|
|
@@ -1208,12 +1937,26 @@ export const TextEditor_20250124 = Tool.providerDefined({
|
|
|
1208
1937
|
})
|
|
1209
1938
|
|
|
1210
1939
|
/**
|
|
1211
|
-
*
|
|
1940
|
+
* Defines the text editor tool for Claude 4 models using Anthropic's `str_replace_based_edit_tool`.
|
|
1941
|
+
*
|
|
1942
|
+
* **When to use**
|
|
1212
1943
|
*
|
|
1213
|
-
*
|
|
1944
|
+
* Use when you need the 2025-04-29 Claude 4 `str_replace_based_edit_tool`
|
|
1945
|
+
* version.
|
|
1946
|
+
*
|
|
1947
|
+
* **Details**
|
|
1948
|
+
*
|
|
1949
|
+
* Requires the "computer-use-2025-01-24" beta header.
|
|
1214
1950
|
*
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1951
|
+
* **Gotchas**
|
|
1952
|
+
*
|
|
1953
|
+
* This version does not support the `undo_edit` command.
|
|
1954
|
+
*
|
|
1955
|
+
* @see {@link TextEditor_20250124} for the previous `str_replace_editor` version
|
|
1956
|
+
* @see {@link TextEditor_20250728} for the later Claude 4 text editor version
|
|
1957
|
+
*
|
|
1958
|
+
* @category text editor
|
|
1959
|
+
* @since 4.0.0
|
|
1217
1960
|
*/
|
|
1218
1961
|
export const TextEditor_20250429 = Tool.providerDefined({
|
|
1219
1962
|
id: "anthropic.text_editor_20250429",
|
|
@@ -1226,12 +1969,19 @@ export const TextEditor_20250429 = Tool.providerDefined({
|
|
|
1226
1969
|
})
|
|
1227
1970
|
|
|
1228
1971
|
/**
|
|
1229
|
-
*
|
|
1972
|
+
* Defines the text editor tool for Claude 4 models.
|
|
1973
|
+
*
|
|
1974
|
+
* **Details**
|
|
1975
|
+
*
|
|
1976
|
+
* Uses Anthropic's `str_replace_based_edit_tool`. `max_characters` can limit
|
|
1977
|
+
* file-view output for this version.
|
|
1978
|
+
*
|
|
1979
|
+
* **Gotchas**
|
|
1230
1980
|
*
|
|
1231
|
-
*
|
|
1981
|
+
* This version does not support the `undo_edit` command.
|
|
1232
1982
|
*
|
|
1233
|
-
* @
|
|
1234
|
-
* @
|
|
1983
|
+
* @category text editor
|
|
1984
|
+
* @since 4.0.0
|
|
1235
1985
|
*/
|
|
1236
1986
|
export const TextEditor_20250728 = Tool.providerDefined({
|
|
1237
1987
|
id: "anthropic.text_editor_20250728",
|
|
@@ -1252,13 +2002,23 @@ export const TextEditor_20250728 = Tool.providerDefined({
|
|
|
1252
2002
|
// -----------------------------------------------------------------------------
|
|
1253
2003
|
|
|
1254
2004
|
/**
|
|
1255
|
-
*
|
|
2005
|
+
* Describes user location for localizing search results.
|
|
1256
2006
|
*
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
2007
|
+
* **When to use**
|
|
2008
|
+
*
|
|
2009
|
+
* Use when you need to localize search results for location-dependent queries
|
|
2010
|
+
* like weather, local businesses, or events.
|
|
2011
|
+
*
|
|
2012
|
+
* **Details**
|
|
2013
|
+
*
|
|
2014
|
+
* The schema uses `type: "approximate"` plus optional `city`, `region`,
|
|
2015
|
+
* `country`, and `timezone`. `country` is an ISO 3166-1 alpha-2 code, and
|
|
2016
|
+
* `timezone` is an IANA time zone identifier.
|
|
2017
|
+
*
|
|
2018
|
+
* @see {@link WebSearch_20250305_Args} for the argument schema that consumes this location
|
|
1259
2019
|
*
|
|
1260
|
-
* @since 1.0.0
|
|
1261
2020
|
* @category Web Search
|
|
2021
|
+
* @since 4.0.0
|
|
1262
2022
|
*/
|
|
1263
2023
|
export const WebSearchUserLocation = Schema.Struct({
|
|
1264
2024
|
/**
|
|
@@ -1288,10 +2048,27 @@ export const WebSearchUserLocation = Schema.Struct({
|
|
|
1288
2048
|
// -----------------------------------------------------------------------------
|
|
1289
2049
|
|
|
1290
2050
|
/**
|
|
1291
|
-
*
|
|
2051
|
+
* Defines configuration arguments for the web search tool.
|
|
2052
|
+
*
|
|
2053
|
+
* **When to use**
|
|
2054
|
+
*
|
|
2055
|
+
* Use when you need to configure `WebSearch_20250305` with search limits,
|
|
2056
|
+
* domain filters, or user location.
|
|
2057
|
+
*
|
|
2058
|
+
* **Details**
|
|
2059
|
+
*
|
|
2060
|
+
* The payload can set `maxUses`, `allowedDomains`, `blockedDomains`, and
|
|
2061
|
+
* `userLocation`.
|
|
2062
|
+
*
|
|
2063
|
+
* **Gotchas**
|
|
2064
|
+
*
|
|
2065
|
+
* `allowedDomains` and `blockedDomains` are mutually exclusive.
|
|
2066
|
+
*
|
|
2067
|
+
* @see {@link WebSearch_20250305} for the provider-defined tool that consumes these arguments
|
|
2068
|
+
* @see {@link WebSearchUserLocation} for localizing search results
|
|
1292
2069
|
*
|
|
1293
|
-
* @since 1.0.0
|
|
1294
2070
|
* @category Web Search
|
|
2071
|
+
* @since 4.0.0
|
|
1295
2072
|
*/
|
|
1296
2073
|
export const WebSearch_20250305_Args = Schema.Struct({
|
|
1297
2074
|
/**
|
|
@@ -1316,8 +2093,14 @@ export const WebSearch_20250305_Args = Schema.Struct({
|
|
|
1316
2093
|
userLocation: Schema.optional(WebSearchUserLocation)
|
|
1317
2094
|
})
|
|
1318
2095
|
/**
|
|
1319
|
-
*
|
|
2096
|
+
* Configuration arguments for the Anthropic web search tool, including usage limits, domain filters, and optional user location.
|
|
2097
|
+
*
|
|
2098
|
+
* **Gotchas**
|
|
2099
|
+
*
|
|
2100
|
+
* `allowedDomains` and `blockedDomains` are mutually exclusive.
|
|
2101
|
+
*
|
|
1320
2102
|
* @category Web Search
|
|
2103
|
+
* @since 4.0.0
|
|
1321
2104
|
*/
|
|
1322
2105
|
export type WebSearch_20250305_Args = typeof WebSearch_20250305_Args.Type
|
|
1323
2106
|
|
|
@@ -1326,10 +2109,17 @@ export type WebSearch_20250305_Args = typeof WebSearch_20250305_Args.Type
|
|
|
1326
2109
|
// -----------------------------------------------------------------------------
|
|
1327
2110
|
|
|
1328
2111
|
/**
|
|
1329
|
-
*
|
|
2112
|
+
* Schema for Claude-supplied web search tool parameters.
|
|
2113
|
+
*
|
|
2114
|
+
* **Details**
|
|
2115
|
+
*
|
|
2116
|
+
* The payload contains the generated `query` string and is consumed by
|
|
2117
|
+
* `WebSearch_20250305`.
|
|
2118
|
+
*
|
|
2119
|
+
* @see {@link WebSearch_20250305} for the provider-defined tool that consumes this payload
|
|
1330
2120
|
*
|
|
1331
|
-
* @since 1.0.0
|
|
1332
2121
|
* @category Web Search
|
|
2122
|
+
* @since 4.0.0
|
|
1333
2123
|
*/
|
|
1334
2124
|
export const WebSearchParameters = Schema.Struct({
|
|
1335
2125
|
/**
|
|
@@ -1338,8 +2128,16 @@ export const WebSearchParameters = Schema.Struct({
|
|
|
1338
2128
|
query: Schema.String
|
|
1339
2129
|
})
|
|
1340
2130
|
/**
|
|
1341
|
-
*
|
|
2131
|
+
* Type of the parameters Claude supplies when invoking the Anthropic web search tool.
|
|
2132
|
+
*
|
|
2133
|
+
* **Details**
|
|
2134
|
+
*
|
|
2135
|
+
* Contains the generated search query used by `WebSearch_20250305`.
|
|
2136
|
+
*
|
|
2137
|
+
* @see {@link WebSearch_20250305} for the provider-defined tool that consumes this payload
|
|
2138
|
+
*
|
|
1342
2139
|
* @category Web Search
|
|
2140
|
+
* @since 4.0.0
|
|
1343
2141
|
*/
|
|
1344
2142
|
export type WebSearchParameters = typeof WebSearchParameters.Type
|
|
1345
2143
|
|
|
@@ -1348,15 +2146,22 @@ export type WebSearchParameters = typeof WebSearchParameters.Type
|
|
|
1348
2146
|
// -----------------------------------------------------------------------------
|
|
1349
2147
|
|
|
1350
2148
|
/**
|
|
1351
|
-
*
|
|
2149
|
+
* Defines the web search tool for Claude models.
|
|
2150
|
+
*
|
|
2151
|
+
* **When to use**
|
|
2152
|
+
*
|
|
2153
|
+
* Use when you want Claude to search the web for real-time information.
|
|
2154
|
+
*
|
|
2155
|
+
* **Details**
|
|
1352
2156
|
*
|
|
1353
2157
|
* Enables Claude to search the web for real-time information. This is a
|
|
1354
2158
|
* server-side tool executed by Anthropic's infrastructure.
|
|
1355
|
-
*
|
|
1356
2159
|
* Generally available (no beta header required).
|
|
1357
2160
|
*
|
|
1358
|
-
* @
|
|
2161
|
+
* @see {@link WebFetch_20250910} for retrieving known URLs after discovery
|
|
2162
|
+
*
|
|
1359
2163
|
* @category Web Search
|
|
2164
|
+
* @since 4.0.0
|
|
1360
2165
|
*/
|
|
1361
2166
|
export const WebSearch_20250305 = Tool.providerDefined({
|
|
1362
2167
|
id: "anthropic.web_search_20250305",
|
|
@@ -1377,10 +2182,21 @@ export const WebSearch_20250305 = Tool.providerDefined({
|
|
|
1377
2182
|
// -----------------------------------------------------------------------------
|
|
1378
2183
|
|
|
1379
2184
|
/**
|
|
1380
|
-
*
|
|
2185
|
+
* Defines citation configuration for web fetch.
|
|
2186
|
+
*
|
|
2187
|
+
* **When to use**
|
|
2188
|
+
*
|
|
2189
|
+
* Use when you need to enable or disable citations on web fetch results.
|
|
2190
|
+
*
|
|
2191
|
+
* **Details**
|
|
2192
|
+
*
|
|
2193
|
+
* The payload contains the `enabled` flag. `citations` is optional on
|
|
2194
|
+
* `WebFetch_20250910_Args`, and citations are disabled by default.
|
|
2195
|
+
*
|
|
2196
|
+
* @see {@link WebFetch_20250910_Args} for the argument schema that consumes this configuration
|
|
1381
2197
|
*
|
|
1382
|
-
* @since 1.0.0
|
|
1383
2198
|
* @category Web Fetch
|
|
2199
|
+
* @since 4.0.0
|
|
1384
2200
|
*/
|
|
1385
2201
|
export const WebFetchCitationsConfig = Schema.Struct({
|
|
1386
2202
|
/**
|
|
@@ -1389,8 +2205,22 @@ export const WebFetchCitationsConfig = Schema.Struct({
|
|
|
1389
2205
|
enabled: Schema.Boolean
|
|
1390
2206
|
})
|
|
1391
2207
|
/**
|
|
1392
|
-
*
|
|
2208
|
+
* Configuration payload for enabling or disabling citations on web fetch results.
|
|
2209
|
+
*
|
|
2210
|
+
* **When to use**
|
|
2211
|
+
*
|
|
2212
|
+
* Use when typing parsed web-fetch citation configuration shared between
|
|
2213
|
+
* request arguments and handler code.
|
|
2214
|
+
*
|
|
2215
|
+
* **Details**
|
|
2216
|
+
*
|
|
2217
|
+
* The payload contains the `enabled` flag. `citations` is optional on
|
|
2218
|
+
* `WebFetch_20250910_Args`, and citations are disabled by default.
|
|
2219
|
+
*
|
|
2220
|
+
* @see {@link WebFetch_20250910_Args} for the argument schema that consumes this configuration
|
|
2221
|
+
*
|
|
1393
2222
|
* @category Web Fetch
|
|
2223
|
+
* @since 4.0.0
|
|
1394
2224
|
*/
|
|
1395
2225
|
export type WebFetchCitationsConfig = typeof WebFetchCitationsConfig.Type
|
|
1396
2226
|
|
|
@@ -1399,10 +2229,29 @@ export type WebFetchCitationsConfig = typeof WebFetchCitationsConfig.Type
|
|
|
1399
2229
|
// -----------------------------------------------------------------------------
|
|
1400
2230
|
|
|
1401
2231
|
/**
|
|
1402
|
-
*
|
|
2232
|
+
* Defines configuration arguments for the web fetch tool.
|
|
2233
|
+
*
|
|
2234
|
+
* **When to use**
|
|
2235
|
+
*
|
|
2236
|
+
* Use when you need to configure `WebFetch_20250910` with usage limits, domain
|
|
2237
|
+
* filters, citations, or content token limits.
|
|
2238
|
+
*
|
|
2239
|
+
* **Details**
|
|
2240
|
+
*
|
|
2241
|
+
* The payload can set `maxUses`, domain filters, `citations`, and
|
|
2242
|
+
* `maxContentTokens`, which map to Anthropic web fetch request fields.
|
|
2243
|
+
*
|
|
2244
|
+
* **Gotchas**
|
|
2245
|
+
*
|
|
2246
|
+
* `allowedDomains` and `blockedDomains` are mutually exclusive.
|
|
2247
|
+
* `maxContentTokens` is approximate and does not apply to binary content such
|
|
2248
|
+
* as PDFs.
|
|
2249
|
+
*
|
|
2250
|
+
* @see {@link WebFetch_20250910} for the provider-defined tool that consumes these arguments
|
|
2251
|
+
* @see {@link WebFetchCitationsConfig} for configuring citations
|
|
1403
2252
|
*
|
|
1404
|
-
* @since 1.0.0
|
|
1405
2253
|
* @category Web Fetch
|
|
2254
|
+
* @since 4.0.0
|
|
1406
2255
|
*/
|
|
1407
2256
|
export const WebFetch_20250910_Args = Schema.Struct({
|
|
1408
2257
|
/**
|
|
@@ -1431,8 +2280,21 @@ export const WebFetch_20250910_Args = Schema.Struct({
|
|
|
1431
2280
|
maxContentTokens: Schema.optional(Schema.Number)
|
|
1432
2281
|
})
|
|
1433
2282
|
/**
|
|
1434
|
-
*
|
|
2283
|
+
* Configuration arguments for the Anthropic web fetch tool, including usage limits, domain filters, citation settings, and token limits.
|
|
2284
|
+
*
|
|
2285
|
+
* **When to use**
|
|
2286
|
+
*
|
|
2287
|
+
* Use when typing parsed web-fetch tool configuration shared by the
|
|
2288
|
+
* provider-defined tool and request-building code.
|
|
2289
|
+
*
|
|
2290
|
+
* **Gotchas**
|
|
2291
|
+
*
|
|
2292
|
+
* `allowedDomains` and `blockedDomains` are mutually exclusive.
|
|
2293
|
+
* `maxContentTokens` is approximate and does not apply to binary content such
|
|
2294
|
+
* as PDFs.
|
|
2295
|
+
*
|
|
1435
2296
|
* @category Web Fetch
|
|
2297
|
+
* @since 4.0.0
|
|
1436
2298
|
*/
|
|
1437
2299
|
export type WebFetch_20250910_Args = typeof WebFetch_20250910_Args.Type
|
|
1438
2300
|
|
|
@@ -1441,10 +2303,26 @@ export type WebFetch_20250910_Args = typeof WebFetch_20250910_Args.Type
|
|
|
1441
2303
|
// -----------------------------------------------------------------------------
|
|
1442
2304
|
|
|
1443
2305
|
/**
|
|
1444
|
-
*
|
|
2306
|
+
* Schema for Claude-supplied web fetch parameters.
|
|
2307
|
+
*
|
|
2308
|
+
* **When to use**
|
|
2309
|
+
*
|
|
2310
|
+
* Use when validating or constructing the `url` payload consumed by
|
|
2311
|
+
* `WebFetch_20250910`.
|
|
2312
|
+
*
|
|
2313
|
+
* **Details**
|
|
2314
|
+
*
|
|
2315
|
+
* The payload contains the single `url` parameter for Anthropic web fetch.
|
|
2316
|
+
*
|
|
2317
|
+
* **Gotchas**
|
|
2318
|
+
*
|
|
2319
|
+
* The URL must be user-provided or from prior search/fetch results. Maximum URL
|
|
2320
|
+
* length is 250 characters.
|
|
2321
|
+
*
|
|
2322
|
+
* @see {@link WebFetch_20250910} for the provider-defined tool that consumes this payload
|
|
1445
2323
|
*
|
|
1446
|
-
* @since 1.0.0
|
|
1447
2324
|
* @category Web Fetch
|
|
2325
|
+
* @since 4.0.0
|
|
1448
2326
|
*/
|
|
1449
2327
|
export const WebFetchParameters = Schema.Struct({
|
|
1450
2328
|
/**
|
|
@@ -1454,8 +2332,24 @@ export const WebFetchParameters = Schema.Struct({
|
|
|
1454
2332
|
url: Schema.String
|
|
1455
2333
|
})
|
|
1456
2334
|
/**
|
|
1457
|
-
*
|
|
2335
|
+
* Type of the parameters Claude supplies when invoking the Anthropic web fetch tool.
|
|
2336
|
+
*
|
|
2337
|
+
* **When to use**
|
|
2338
|
+
*
|
|
2339
|
+
* Use when typing Claude-supplied web-fetch tool parameters after schema
|
|
2340
|
+
* validation, before enforcing URL provenance or length constraints.
|
|
2341
|
+
*
|
|
2342
|
+
* **Details**
|
|
2343
|
+
*
|
|
2344
|
+
* The payload contains the single `url` parameter for Anthropic web fetch.
|
|
2345
|
+
*
|
|
2346
|
+
* **Gotchas**
|
|
2347
|
+
*
|
|
2348
|
+
* The URL must be user-provided or from prior search/fetch results. Maximum URL
|
|
2349
|
+
* length is 250 characters.
|
|
2350
|
+
*
|
|
1458
2351
|
* @category Web Fetch
|
|
2352
|
+
* @since 4.0.0
|
|
1459
2353
|
*/
|
|
1460
2354
|
export type WebFetchParameters = typeof WebFetchParameters.Type
|
|
1461
2355
|
|
|
@@ -1464,15 +2358,23 @@ export type WebFetchParameters = typeof WebFetchParameters.Type
|
|
|
1464
2358
|
// -----------------------------------------------------------------------------
|
|
1465
2359
|
|
|
1466
2360
|
/**
|
|
1467
|
-
*
|
|
2361
|
+
* Defines the web fetch tool for Claude models.
|
|
2362
|
+
*
|
|
2363
|
+
* **When to use**
|
|
2364
|
+
*
|
|
2365
|
+
* Use when you want Claude to retrieve the content of a specific web page or
|
|
2366
|
+
* PDF.
|
|
2367
|
+
*
|
|
2368
|
+
* **Details**
|
|
1468
2369
|
*
|
|
1469
2370
|
* Allows Claude to retrieve full content from web pages and PDF documents.
|
|
1470
|
-
* This is a server-side tool executed by Anthropic's infrastructure.
|
|
2371
|
+
* This is a server-side tool executed by Anthropic's infrastructure. Selecting
|
|
2372
|
+
* this tool adds the "web-fetch-2025-09-10" beta header.
|
|
1471
2373
|
*
|
|
1472
|
-
*
|
|
2374
|
+
* @see {@link WebSearch_20250305} for discovering URLs before fetching specific content
|
|
1473
2375
|
*
|
|
1474
|
-
* @since 1.0.0
|
|
1475
2376
|
* @category Web Fetch
|
|
2377
|
+
* @since 4.0.0
|
|
1476
2378
|
*/
|
|
1477
2379
|
export const WebFetch_20250910 = Tool.providerDefined({
|
|
1478
2380
|
id: "anthropic.web_fetch_20250910",
|
|
@@ -1493,13 +2395,15 @@ export const WebFetch_20250910 = Tool.providerDefined({
|
|
|
1493
2395
|
// -----------------------------------------------------------------------------
|
|
1494
2396
|
|
|
1495
2397
|
/**
|
|
1496
|
-
*
|
|
2398
|
+
* Schema for regex-based tool search input parameters.
|
|
2399
|
+
*
|
|
2400
|
+
* **Details**
|
|
1497
2401
|
*
|
|
1498
2402
|
* Claude constructs regex patterns using Python's `re.search()` syntax.
|
|
1499
2403
|
* Maximum query length: 200 characters.
|
|
1500
2404
|
*
|
|
1501
|
-
* @
|
|
1502
|
-
* @
|
|
2405
|
+
* @category tool search
|
|
2406
|
+
* @since 4.0.0
|
|
1503
2407
|
*/
|
|
1504
2408
|
export const ToolSearchRegexParameters = Schema.Struct({
|
|
1505
2409
|
/**
|
|
@@ -1508,16 +2412,35 @@ export const ToolSearchRegexParameters = Schema.Struct({
|
|
|
1508
2412
|
query: Schema.String
|
|
1509
2413
|
})
|
|
1510
2414
|
/**
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
2415
|
+
* Type of the parameters Claude supplies when invoking regex-based Anthropic tool search.
|
|
2416
|
+
*
|
|
2417
|
+
* **Details**
|
|
2418
|
+
*
|
|
2419
|
+
* Claude constructs regex patterns using Python's `re.search()` syntax.
|
|
2420
|
+
* Maximum query length: 200 characters.
|
|
2421
|
+
*
|
|
2422
|
+
* @category tool search
|
|
2423
|
+
* @since 4.0.0
|
|
1513
2424
|
*/
|
|
1514
2425
|
export type ToolSearchRegexParameters = typeof ToolSearchRegexParameters.Type
|
|
1515
2426
|
|
|
1516
2427
|
/**
|
|
1517
|
-
*
|
|
2428
|
+
* Defines input parameters for BM25/natural language tool search.
|
|
2429
|
+
*
|
|
2430
|
+
* **When to use**
|
|
1518
2431
|
*
|
|
1519
|
-
*
|
|
1520
|
-
*
|
|
2432
|
+
* Use when validating or constructing the natural-language query payload for
|
|
2433
|
+
* `ToolSearchBM25_20251119`.
|
|
2434
|
+
*
|
|
2435
|
+
* **Details**
|
|
2436
|
+
*
|
|
2437
|
+
* The payload contains Claude's natural-language `query`. BM25 searches tool
|
|
2438
|
+
* names, descriptions, argument names, and argument descriptions.
|
|
2439
|
+
*
|
|
2440
|
+
* @see {@link ToolSearchBM25_20251119} for the provider-defined tool that consumes these parameters
|
|
2441
|
+
*
|
|
2442
|
+
* @category tool search
|
|
2443
|
+
* @since 4.0.0
|
|
1521
2444
|
*/
|
|
1522
2445
|
export const ToolSearchBM25Parameters = Schema.Struct({
|
|
1523
2446
|
/**
|
|
@@ -1526,8 +2449,10 @@ export const ToolSearchBM25Parameters = Schema.Struct({
|
|
|
1526
2449
|
query: Schema.String
|
|
1527
2450
|
})
|
|
1528
2451
|
/**
|
|
1529
|
-
*
|
|
1530
|
-
*
|
|
2452
|
+
* Type of the parameters Claude supplies when invoking BM25 natural-language Anthropic tool search.
|
|
2453
|
+
*
|
|
2454
|
+
* @category tool search
|
|
2455
|
+
* @since 4.0.0
|
|
1531
2456
|
*/
|
|
1532
2457
|
export type ToolSearchBM25Parameters = typeof ToolSearchBM25Parameters.Type
|
|
1533
2458
|
|
|
@@ -1536,16 +2461,17 @@ export type ToolSearchBM25Parameters = typeof ToolSearchBM25Parameters.Type
|
|
|
1536
2461
|
// -----------------------------------------------------------------------------
|
|
1537
2462
|
|
|
1538
2463
|
/**
|
|
1539
|
-
*
|
|
2464
|
+
* Defines regex-based tool search for Claude models.
|
|
2465
|
+
*
|
|
2466
|
+
* **Details**
|
|
1540
2467
|
*
|
|
1541
2468
|
* Claude constructs regex patterns using Python's `re.search()` syntax to
|
|
1542
2469
|
* find tools. The regex is matched against tool names, descriptions,
|
|
1543
2470
|
* argument names, and argument descriptions.
|
|
1544
|
-
*
|
|
1545
2471
|
* Requires the "advanced-tool-use-2025-11-20" beta header.
|
|
1546
2472
|
*
|
|
1547
|
-
* @
|
|
1548
|
-
* @
|
|
2473
|
+
* @category tool search
|
|
2474
|
+
* @since 4.0.0
|
|
1549
2475
|
*/
|
|
1550
2476
|
export const ToolSearchRegex_20251119 = Tool.providerDefined({
|
|
1551
2477
|
id: "anthropic.tool_search_tool_regex_20251119",
|
|
@@ -1557,16 +2483,24 @@ export const ToolSearchRegex_20251119 = Tool.providerDefined({
|
|
|
1557
2483
|
})
|
|
1558
2484
|
|
|
1559
2485
|
/**
|
|
1560
|
-
* BM25/natural language tool search for Claude models.
|
|
2486
|
+
* Defines BM25/natural language tool search for Claude models.
|
|
2487
|
+
*
|
|
2488
|
+
* **When to use**
|
|
2489
|
+
*
|
|
2490
|
+
* Use when you want Claude to find relevant tools from a natural-language query
|
|
2491
|
+
* instead of a regex pattern.
|
|
2492
|
+
*
|
|
2493
|
+
* **Details**
|
|
1561
2494
|
*
|
|
1562
2495
|
* Claude uses natural language queries to search for tools using the
|
|
1563
2496
|
* BM25 algorithm. The search is performed against tool names, descriptions,
|
|
1564
2497
|
* argument names, and argument descriptions.
|
|
1565
|
-
*
|
|
1566
2498
|
* Requires the "advanced-tool-use-2025-11-20" beta header.
|
|
1567
2499
|
*
|
|
1568
|
-
* @
|
|
1569
|
-
*
|
|
2500
|
+
* @see {@link ToolSearchRegex_20251119} for the regex-pattern alternative
|
|
2501
|
+
*
|
|
2502
|
+
* @category tool search
|
|
2503
|
+
* @since 4.0.0
|
|
1570
2504
|
*/
|
|
1571
2505
|
export const ToolSearchBM25_20251119 = Tool.providerDefined({
|
|
1572
2506
|
id: "anthropic.tool_search_tool_bm25_20251119",
|