Skip to content

AnthropicTool

The AnthropicTool module defines Anthropic provider tools and the schemas for their inputs and results. It covers Anthropic-owned tools such as Bash, Code Execution, Computer Use, Memory, Text Editor, Web Search, Web Fetch, and Tool Search, which can be attached to Anthropic-backed Effect AI language model requests.

108 exports Added in v4.0.0 Source

Models

AnthropicTool type

Added in v4.0.0 Source

Union of all Anthropic provider-defined tool definitions exported by this module.

When to use

Use when a helper, collection, or option accepts any Anthropic provider-defined tool value created by this module.

Details

The union is built from the return types of the exported constructors, including Bash, Code Execution, Computer Use, Memory, Text Editor, Tool Search, Web Fetch, and Web Search tool versions.

Signature

type AnthropicTool =
| ReturnType<typeof Bash_20241022>
| ReturnType<typeof Bash_20250124>
| ReturnType<typeof CodeExecution_20250522>
| ReturnType<typeof CodeExecution_20250825>
| ReturnType<typeof ComputerUse_20241022>
| ReturnType<typeof ComputerUse_20250124>
| ReturnType<typeof ComputerUse_20251124>
| ReturnType<typeof Memory_20250818>
| ReturnType<typeof TextEditor_20241022>
| ReturnType<typeof TextEditor_20250124>
| ReturnType<typeof TextEditor_20250429>
| ReturnType<typeof TextEditor_20250728>
| ReturnType<typeof ToolSearchRegex_20251119>
| ReturnType<typeof ToolSearchBM25_20251119>
| ReturnType<typeof WebFetch_20250910>
| ReturnType<typeof WebSearch_20250305>;

Input payload for the 2025-08-25 Anthropic code execution tool.

When to use

Use when exposing the 2025-08-25 code-execution payload separately from the provider tool definition, such as at a transport or persistence boundary.

Details

The payload has a single code field containing the source code string to execute.

See

Signature

type CodeExecution_20250825_Parameters = typeof CodeExecution_20250825_Parameters.Type;

Input payload for a bash command routed through the Anthropic code execution tool.

When to use

Use when representing a provider-executed bash command request for the 2025-05-22 code execution tool.

Details

The payload uses type: "bash_code_execution" to distinguish bash execution from programmatic code and text editor operations, and command contains the bash command to run.

See

Signature

type CodeExecutionBashCommand = typeof CodeExecutionBashCommand.Type;

Input payload for a programmatic code execution tool call, including the source code to execute.

Signature

type CodeExecutionProgrammaticToolCall = typeof CodeExecutionProgrammaticToolCall.Type;

Input payload for creating a file through the text editor code execution tool, optionally including initial file text.

Signature

type CodeExecutionTextEditorCreate = typeof CodeExecutionTextEditorCreate.Type;

Input payload for replacing text in a file through the text editor code execution tool.

Signature

type CodeExecutionTextEditorStrReplace = typeof CodeExecutionTextEditorStrReplace.Type;

Input payload for the view command of Anthropic's text editor code execution tool.

When to use

Use when working at the Anthropic protocol boundary and the code-execution view request must be distinguished from standalone text-editor view requests.

Details

The payload is discriminated by type: "text_editor_code_execution" and command: "view". The path field identifies the file to view.

Gotchas

This code execution view payload does not include view_range; line ranges are part of the standalone text editor view payload, not this code execution payload.

See

Signature

type CodeExecutionTextEditorView = typeof CodeExecutionTextEditorView.Type;

Computer-use action payload for performing a double click, optionally at a specific coordinate.

Signature

type ComputerUseDoubleClickAction = typeof ComputerUseDoubleClickAction.Type;

Computer-use action payload for holding a key for a specified duration.

When to use

Use to represent a key that should remain pressed for a measured interval.

Details

Set action to "hold_key", text to the key to hold, and duration to the number of seconds to hold it.

See

Signature

type ComputerUseHoldKeyAction = typeof ComputerUseHoldKeyAction.Type;

ComputerUseKeyAction type

Added in v4.0.0 Source

Computer-use action payload for pressing a key or key combination.

When to use

Use when typing parsed computer-use key action payloads after schema validation, where provider-specific key-name validation is handled outside TypeScript.

Details

The payload uses action: "key" and stores the key or key combination to press in text, such as "Return", "ctrl+c", or "ctrl+s".

Gotchas

text is typed as string; the paired schema does not validate provider-specific key names or key combinations.

Signature

type ComputerUseKeyAction = typeof ComputerUseKeyAction.Type;

Computer-use action payload for performing a left click, optionally at a specific coordinate.

Signature

type ComputerUseLeftClickAction = typeof ComputerUseLeftClickAction.Type;

Computer-use action payload for dragging from a start coordinate to an end coordinate.

Signature

type ComputerUseLeftClickDragAction = typeof ComputerUseLeftClickDragAction.Type;

Computer-use action payload for pressing and holding the left mouse button, optionally at a specific coordinate.

Signature

type ComputerUseLeftMouseDownAction = typeof ComputerUseLeftMouseDownAction.Type;

Computer-use action payload for releasing the left mouse button, optionally at a specific coordinate.

Signature

type ComputerUseLeftMouseUpAction = typeof ComputerUseLeftMouseUpAction.Type;

Computer-use action payload for performing a middle click, optionally at a specific coordinate.

Signature

type ComputerUseMiddleClickAction = typeof ComputerUseMiddleClickAction.Type;

Computer-use action payload for moving the mouse cursor to a specific coordinate.

Signature

type ComputerUseMouseMoveAction = typeof ComputerUseMouseMoveAction.Type;

Computer-use action payload for performing a right click, optionally at a specific coordinate.

Signature

type ComputerUseRightClickAction = typeof ComputerUseRightClickAction.Type;

Computer-use action payload for capturing the current display.

Signature

type ComputerUseScreenshotAction = typeof ComputerUseScreenshotAction.Type;

Computer-use action payload for scrolling by a specified amount in a specified direction, optionally from a coordinate.

Signature

type ComputerUseScrollAction = typeof ComputerUseScrollAction.Type;

Computer-use action payload for performing a triple click, optionally at a specific coordinate.

Signature

type ComputerUseTripleClickAction = typeof ComputerUseTripleClickAction.Type;

Computer-use action payload for pausing for a specified duration.

Signature

type ComputerUseWaitAction = typeof ComputerUseWaitAction.Type;

Computer-use action payload for zooming into a specific screen region.

Gotchas

The enclosing computer-use tool must be configured with enableZoom: true. region is only a four-number tuple and does not validate corner ordering or display bounds.

Signature

type ComputerUseZoomAction = typeof ComputerUseZoomAction.Type;

Coordinate type

Added in v4.0.0 Source

An [x, y] screen coordinate in pixels.

Signature

type Coordinate = typeof Coordinate.Type;

MemoryCreateCommand type

Added in v4.0.0 Source

Memory tool command payload for creating a new file at a path.

Signature

type MemoryCreateCommand = typeof MemoryCreateCommand.Type;

MemoryDeleteCommand type

Added in v4.0.0 Source

Memory tool command payload for deleting a file or directory at a path.

Signature

type MemoryDeleteCommand = typeof MemoryDeleteCommand.Type;

MemoryInsertCommand type

Added in v4.0.0 Source

Memory tool command payload for inserting text at a specific line in a file.

Signature

type MemoryInsertCommand = typeof MemoryInsertCommand.Type;

MemoryRenameCommand type

Added in v4.0.0 Source

Memory tool command payload for renaming or moving a file or directory.

Signature

type MemoryRenameCommand = typeof MemoryRenameCommand.Type;

Memory tool command payload for replacing text in a file.

Signature

type MemoryStrReplaceCommand = typeof MemoryStrReplaceCommand.Type;

MemoryViewCommand type

Added in v4.0.0 Source

Memory tool command payload for viewing a file or directory, optionally with a file line range.

Signature

type MemoryViewCommand = typeof MemoryViewCommand.Type;

ModifierKey type

Added in v4.0.0 Source

Modifier key literals.

Details

Allowed values are "alt", "ctrl", "meta", and "shift".

Signature

type ModifierKey = typeof ModifierKey.Type;

Region type

Added in v4.0.0 Source

An [x1, y1, x2, y2] screen region in pixels, from top-left to bottom-right.

Signature

type Region = typeof Region.Type;

ScrollDirection type

Added in v4.0.0 Source

Direction used by computer-use scroll actions: "up", "down", "left", or "right".

Signature

type ScrollDirection = typeof ScrollDirection.Type;

Text editor command payload for creating a new file with the specified content.

When to use

Use when typing parsed text-editor create command payloads after schema validation and before dispatching to Anthropic tool handlers.

Gotchas

The command fails if the file already exists or if parent directories are missing.

Signature

type TextEditorCreateCommand = typeof TextEditorCreateCommand.Type;

Text editor command payload for inserting text after a specific line number in a file.

Signature

type TextEditorInsertCommand = typeof TextEditorInsertCommand.Type;

Text editor command payload for replacing one exact, unique string in a file.

When to use

Use when typing parsed text-editor replace command payloads that must carry one exact old_str match.

Gotchas

The old_str must match exactly, including whitespace and indentation, and must be unique in the file.

Signature

type TextEditorStrReplaceCommand = typeof TextEditorStrReplaceCommand.Type;

Text editor command payload for undoing the most recent edit to a file.

Gotchas

Available for text_editor_20241022 and text_editor_20250124, but not for text_editor_20250429 or text_editor_20250728.

Signature

type TextEditorUndoEditCommand = typeof TextEditorUndoEditCommand.Type;

Text editor command payload for viewing file contents or listing directory contents.

Details

view_range is a 1-indexed [start, end] tuple where -1 means through the end of the file.

Signature

type TextEditorViewCommand = typeof TextEditorViewCommand.Type;

Type of the parameters Claude supplies when invoking BM25 natural-language Anthropic tool search.

Signature

type ToolSearchBM25Parameters = typeof ToolSearchBM25Parameters.Type;

Type of the parameters Claude supplies when invoking regex-based Anthropic tool search.

Details

Claude constructs regex patterns using Python's re.search() syntax. Maximum query length: 200 characters.

Signature

type ToolSearchRegexParameters = typeof ToolSearchRegexParameters.Type;

TypeAction type

Added in v4.0.0 Source

Computer-use action payload for typing a text string.

Details

The payload uses action: "type" and a text string containing the text to enter.

Signature

type TypeAction = typeof TypeAction.Type;

ViewRange type

Added in v4.0.0 Source

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.

When to use

Use when typing view_range for memory or text editor view commands.

Signature

type ViewRange = typeof ViewRange.Type;

Configuration arguments for the Anthropic web fetch tool, including usage limits, domain filters, citation settings, and token limits.

When to use

Use when typing parsed web-fetch tool configuration shared by the provider-defined tool and request-building code.

Gotchas

allowedDomains and blockedDomains are mutually exclusive. maxContentTokens is approximate and does not apply to binary content such as PDFs.

Signature

type WebFetch_20250910_Args = typeof WebFetch_20250910_Args.Type;

Configuration payload for enabling or disabling citations on web fetch results.

When to use

Use when typing parsed web-fetch citation configuration shared between request arguments and handler code.

Details

The payload contains the enabled flag. citations is optional on WebFetch_20250910_Args, and citations are disabled by default.

See

Signature

type WebFetchCitationsConfig = typeof WebFetchCitationsConfig.Type;

WebFetchParameters type

Added in v4.0.0 Source

Type of the parameters Claude supplies when invoking the Anthropic web fetch tool.

When to use

Use when typing Claude-supplied web-fetch tool parameters after schema validation, before enforcing URL provenance or length constraints.

Details

The payload contains the single url parameter for Anthropic web fetch.

Gotchas

The URL must be user-provided or from prior search/fetch results. Maximum URL length is 250 characters.

Signature

type WebFetchParameters = typeof WebFetchParameters.Type;

Configuration arguments for the Anthropic web search tool, including usage limits, domain filters, and optional user location.

Gotchas

allowedDomains and blockedDomains are mutually exclusive.

Signature

type WebSearch_20250305_Args = typeof WebSearch_20250305_Args.Type;

WebSearchParameters type

Added in v4.0.0 Source

Type of the parameters Claude supplies when invoking the Anthropic web search tool.

Details

Contains the generated search query used by WebSearch_20250305.

See

Signature

type WebSearchParameters = typeof WebSearchParameters.Type;

Schemas

Schema for the 2025-08-25 code execution tool input, containing the code to execute.

When to use

Use when you need the schema for code-execution input at the Anthropic protocol boundary before sending source code to the 2025-08-25 tool.

See

Signature

declare const CodeExecution_20250825_Parameters: Struct<{
readonly code: String;
}>;

Schema for the bash_code_execution input variant of Anthropic Code Execution.

When to use

Use when validating or constructing a bash command request for CodeExecution_20250522.

Details

The schema requires type to be "bash_code_execution" and command to contain the bash command sent to Anthropic.

See

Signature

declare const CodeExecutionBashCommand: Struct<{
readonly command: String;
readonly type: Literal<"bash_code_execution">;
}>;

Schema for a code execution request that asks Anthropic to run source code as a programmatic tool call.

When to use

Use when constructing or validating a programmatic tool call for the Anthropic Code Execution tool.

See

Signature

declare const CodeExecutionProgrammaticToolCall: Struct<{
readonly code: String;
readonly type: Literal<"programmatic-tool-call">;
}>;

Schema for a text editor code execution request that creates a file at a path.

When to use

Use when validating or constructing an Anthropic text_editor_code_execution tool call that should create a file.

Details

The request is discriminated by type: "text_editor_code_execution" and command: "create". It requires path and accepts optional file_text; the schema allows file_text to be omitted, null, or a string.

See

Signature

declare const CodeExecutionTextEditorCreate: Struct<{
readonly command: Literal<"create">;
readonly file_text: optional<NullOr<String>>;
readonly path: String;
readonly type: Literal<"text_editor_code_execution">;
}>;

Schema for a code execution text editor request that replaces one exact string in a file.

When to use

Use when validating or constructing the str_replace text editor operation for the 2025-05-22 Anthropic code execution tool.

Gotchas

The old_str must match the file contents exactly, including whitespace and indentation, and must identify a single occurrence.

See

Signature

declare const CodeExecutionTextEditorStrReplace: Struct<{
readonly command: Literal<"str_replace">;
readonly new_str: String;
readonly old_str: String;
readonly path: String;
readonly type: Literal<"text_editor_code_execution">;
}>;

Schema for a code execution text editor request that views a file by path.

When to use

Use when you need the schema for provider-bound code-execution view requests before distinguishing them from create or replace text-editor commands.

Details

The encoded payload uses type: "text_editor_code_execution", command: "view", and a path string.

See

Signature

declare const CodeExecutionTextEditorView: Struct<{
readonly command: Literal<"view">;
readonly path: String;
readonly type: Literal<"text_editor_code_execution">;
}>;

Schema for a computer-use action that performs a double click.

When to use

Use to validate or construct an Anthropic computer-use payload for double clicking at the current mouse position or at a specific screen coordinate.

Details

The encoded payload uses action: "double_click". The optional coordinate field supplies the [x, y] pixel position; when omitted, the action uses the current mouse position.

Gotchas

The coordinate schema only checks that the value is a two-number tuple. It does not validate that the point falls within the configured display dimensions.

See

Signature

declare const ComputerUseDoubleClickAction: Struct<{
readonly action: Literal<"double_click">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Keeps a key pressed for a specified duration during computer-use execution.

When to use

Use to keep a keyboard key depressed for a fixed number of seconds in a computer-use action sequence.

Details

The schema describes objects with action: "hold_key", a text field containing the key to hold, and a duration field containing the number of seconds to hold it.

Gotchas

The schema only checks that duration is a number; it does not require a positive value.

See

Signature

declare const ComputerUseHoldKeyAction: Struct<{
readonly action: Literal<"hold_key">;
readonly duration: Finite;
readonly text: String;
}>;

Schema for a computer-use action that presses a key or key combination, such as "Return", "ctrl+c", or "ctrl+s".

When to use

Use when validating or constructing a computer-use action for keyboard shortcuts or non-text key presses.

See

Signature

declare const ComputerUseKeyAction: Struct<{
readonly action: Literal<"key">;
readonly text: String;
}>;

Schema for a computer-use action that performs a left click.

When to use

Use to validate or construct an Anthropic computer-use payload for clicking once at the current mouse position or at a specific screen coordinate.

Details

The encoded payload uses action: "left_click". The optional coordinate field supplies the [x, y] pixel position; when omitted, the action uses the current mouse position.

Gotchas

The coordinate schema only checks that the value is a two-number tuple. It does not validate that the point falls within the configured display dimensions.

See

Signature

declare const ComputerUseLeftClickAction: Struct<{
readonly action: Literal<"left_click">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Schema for a computer-use action that drags with the left mouse button.

When to use

Use to validate or construct an Anthropic computer-use payload for dragging from one screen coordinate to another in a single action.

Details

The encoded payload uses action: "left_click_drag" and requires both start_coordinate and coordinate as [x, y] pixel positions.

Gotchas

The coordinate schema only checks that each value is a two-number tuple. It does not validate that either point falls within the configured display dimensions.

See

Signature

declare const ComputerUseLeftClickDragAction: Struct<{
readonly action: Literal<"left_click_drag">;
readonly coordinate: Tuple<readonly [Int, Int]>;
readonly start_coordinate: Tuple<readonly [Int, Int]>;
}>;

Starts a left mouse button press without releasing it.

When to use

Use when constructing a manual click or drag sequence that should press and hold the left mouse button before a later release.

Signature

declare const ComputerUseLeftMouseDownAction: Struct<{
readonly action: Literal<"left_mouse_down">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Releases the left mouse button.

When to use

Use when constructing a manual click or drag sequence that should release the left mouse button after it was previously held down.

Signature

declare const ComputerUseLeftMouseUpAction: Struct<{
readonly action: Literal<"left_mouse_up">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Schema for a computer-use action that performs a middle click.

When to use

Use to validate or construct a middle-button click action for Anthropic computer use, optionally targeting a specific screen coordinate.

Details

The payload must use action: "middle_click". When coordinate is omitted, the click occurs at the current mouse position.

Gotchas

This action is available in the 2025-01-24 computer-use action set and later; it is not part of ComputerUse_20241022.

See

Signature

declare const ComputerUseMiddleClickAction: Struct<{
readonly action: Literal<"middle_click">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Schema for a computer-use action that moves the mouse cursor to a required [x, y] screen coordinate.

When to use

Use to validate or construct a mouse movement action for an Anthropic computer-use tool call.

Details

The encoded payload has action "mouse_move" and a required coordinate field containing the target [x, y] pixel position.

Gotchas

The coordinate schema only checks that the value is a two-number tuple. It does not validate that the point falls within the configured display dimensions.

Signature

declare const ComputerUseMouseMoveAction: Struct<{
readonly action: Literal<"mouse_move">;
readonly coordinate: Tuple<readonly [Int, Int]>;
}>;

Schema for a computer-use action that performs a right click, optionally at a specific screen coordinate.

When to use

Use to validate or construct the right_click action for an Anthropic computer-use tool call.

Details

The optional coordinate field is an [x, y] screen coordinate in pixels. When omitted, the right click is performed at the current mouse position.

See

Signature

declare const ComputerUseRightClickAction: Struct<{
readonly action: Literal<"right_click">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Schema for a computer-use action that requests a screenshot of the current display.

When to use

Use to validate or construct a computer-use tool action that asks the handler to capture the full current display.

Details

The payload contains only action: "screenshot" and does not include coordinates or other options.

See

  • ComputerUseZoomAction for requesting a zoomed-in screenshot of a specific screen region with the 2025-11-24 computer-use tool

Signature

declare const ComputerUseScreenshotAction: Struct<{
readonly action: Literal<"screenshot">;
}>;

Schema for a computer-use scroll action.

When to use

Use when validating or constructing Anthropic computer-use scroll payloads.

Details

The encoded payload uses action: "scroll", an optional coordinate, scroll_direction, and scroll_amount.

Gotchas

coordinate only checks a two-number tuple, and scroll_amount is only Schema.Int.

See

Signature

declare const ComputerUseScrollAction: Struct<{
readonly action: Literal<"scroll">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
readonly scroll_amount: Int;
readonly scroll_direction: Literals<readonly ["up", "down", "left", "right"]>;
}>;

Schema for a computer-use triple-click action.

When to use

Use when validating or constructing Anthropic computer-use triple-click payloads at the current pointer position or an optional coordinate.

Details

The encoded payload uses action: "triple_click" and an optional coordinate.

Gotchas

coordinate only validates as a two-number tuple and does not check display bounds.

See

Signature

declare const ComputerUseTripleClickAction: Struct<{
readonly action: Literal<"triple_click">;
readonly coordinate: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Schema for a computer-use wait action.

When to use

Use when validating or constructing Anthropic computer-use payloads that pause between actions.

Details

The encoded payload uses action: "wait" and a required duration in seconds.

Gotchas

duration is only Schema.Finite; it is not constrained to positive values.

See

Signature

declare const ComputerUseWaitAction: Struct<{
readonly action: Literal<"wait">;
readonly duration: Finite;
}>;

Zooms into a specific region of the screen at full resolution.

When to use

Use when building or validating the 2025-11-24 computer-use action for a zoom-enabled tool definition.

Details

The encoded payload uses action: "zoom" and a region tuple.

Gotchas

Requires enableZoom: true in the tool definition. region is only a four-number tuple and does not validate corner ordering or display bounds.

See

Signature

declare const ComputerUseZoomAction: Struct<{
readonly action: Literal<"zoom">;
readonly region: Tuple<readonly [Int, Int, Int, Int]>;
}>;

Coordinate

Added in v4.0.0 Source

Schema for an [x, y] screen coordinate in pixels.

When to use

Use when validating computer-use action payloads that carry a single screen position and provider-side bounds checks remain acceptable.

Details

This is a two-number tuple used by computer-use actions that accept screen positions.

Gotchas

This schema validates tuple shape only and does not check display bounds.

Signature

declare const Coordinate: Tuple<readonly [Int, Int]>;

Schema for the memory tool command that creates a new file at a path.

Details

The payload contains command: "create", a path string, and the file_text content to write to the file.

Signature

declare const MemoryCreateCommand: Struct<{
readonly command: Literal<"create">;
readonly file_text: String;
readonly path: String;
}>;

Schema for a memory command that deletes a file or directory.

Signature

declare const MemoryDeleteCommand: Struct<{
readonly command: Literal<"delete">;
readonly path: String;
}>;

Schema for the memory insert command.

When to use

Use when validating or constructing insert payloads for Memory_20250818.

Details

The payload is discriminated by command: "insert" and requires path, insert_line, and insert_text.

See

Signature

declare const MemoryInsertCommand: Struct<{
readonly command: Literal<"insert">;
readonly insert_line: Int;
readonly insert_text: String;
readonly path: String;
}>;

Schema for the memory command that renames or moves a file or directory.

Details

The payload uses command: "rename" and requires old_path as the current path plus new_path as the new destination path.

Signature

declare const MemoryRenameCommand: Struct<{
readonly command: Literal<"rename">;
readonly new_path: String;
readonly old_path: String;
}>;

Schema for the memory str_replace command.

When to use

Use when validating or constructing str_replace payloads for Memory_20250818.

Details

The payload is discriminated by command: "str_replace" and requires path, old_str, and new_str.

See

Signature

declare const MemoryStrReplaceCommand: Struct<{
readonly command: Literal<"str_replace">;
readonly new_str: String;
readonly old_str: String;
readonly path: String;
}>;

Shows directory contents or file contents with optional line ranges.

Details

When used on a file, returns file contents optionally limited by view_range. When used on a directory, lists contents.

Signature

declare const MemoryViewCommand: Struct<{
readonly command: Literal<"view">;
readonly path: String;
readonly view_range: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

ModifierKey

Added in v4.0.0 Source

Schema for modifier key literals.

Details

Allowed values are "alt", "ctrl", "meta", and "shift".

Signature

declare const ModifierKey: Literals<readonly ["alt", "ctrl", "meta", "shift"]>;

Region

Added in v4.0.0 Source

Schema for an [x1, y1, x2, y2] screen region in pixels.

When to use

Use when validating computer-use action payloads that carry a rectangular screen region and provider-side bounds checks remain acceptable.

Details

The tuple represents top-left and bottom-right corners.

Gotchas

This schema validates four numbers only and does not check coordinate ordering or display bounds.

Signature

declare const Region: Tuple<readonly [Int, Int, Int, Int]>;

Schema for scroll direction literals: "up", "down", "left", or "right".

See

Signature

declare const ScrollDirection: Literals<readonly ["up", "down", "left", "right"]>;

Create a new file with specified content.

When to use

Use when validating or constructing an Anthropic text editor create command.

Details

The payload is discriminated by command: "create" and requires both path and file_text.

Gotchas

Fails if the file already exists. Parent directories must exist.

Signature

declare const TextEditorCreateCommand: Struct<{
readonly command: Literal<"create">;
readonly file_text: String;
readonly path: String;
}>;

Inserts text at a specific line number in a file.

Details

Inserts the new text after the specified line number. Use 0 to insert at the beginning of the file; other values are 1-indexed.

Signature

declare const TextEditorInsertCommand: Struct<{
readonly command: Literal<"insert">;
readonly insert_line: Int;
readonly new_str: String;
readonly path: String;
}>;

Replaces a specific string in a file with a new string.

When to use

Use when validating or constructing standalone Anthropic text editor str_replace commands.

Details

The payload uses command: "str_replace", path, old_str, and new_str. new_str may be empty to delete text.

Gotchas

The old_str must match exactly (including whitespace and indentation) and must be unique in the file.

See

Signature

declare const TextEditorStrReplaceCommand: Struct<{
readonly command: Literal<"str_replace">;
readonly new_str: String;
readonly old_str: String;
readonly path: String;
}>;

Undoes the last edit made to a file.

Details

Reverts the most recent str_replace, insert, or create operation on the file.

Gotchas

This command is available in text_editor_20241022 and text_editor_20250124, but not in text_editor_20250429 or text_editor_20250728.

Signature

declare const TextEditorUndoEditCommand: Struct<{
readonly command: Literal<"undo_edit">;
readonly path: String;
}>;

Reads the contents of a file or lists directory contents.

When to use

Use when validating or constructing the standalone Anthropic Text Editor view command.

Details

When used on a file, returns the file contents, optionally limited to a line range. When used on a directory, lists all files and subdirectories. view_range is a 1-indexed [start, end] tuple where -1 means through the end of the file.

See

Signature

declare const TextEditorViewCommand: Struct<{
readonly command: Literal<"view">;
readonly path: String;
readonly view_range: optionalKey<Tuple<readonly [Int, Int]>>;
}>;

Defines input parameters for BM25/natural language tool search.

When to use

Use when validating or constructing the natural-language query payload for ToolSearchBM25_20251119.

Details

The payload contains Claude's natural-language query. BM25 searches tool names, descriptions, argument names, and argument descriptions.

See

Signature

declare const ToolSearchBM25Parameters: Struct<{
readonly query: String;
}>;

Schema for regex-based tool search input parameters.

Details

Claude constructs regex patterns using Python's re.search() syntax. Maximum query length: 200 characters.

Signature

declare const ToolSearchRegexParameters: Struct<{
readonly query: String;
}>;

TypeAction

Added in v4.0.0 Source

Schema for a computer-use action that enters text.

When to use

Use to validate or construct a computer-use action for entering ordinary text strings.

Details

The payload uses action: "type" and a text string containing the text to enter.

See

Signature

declare const TypeAction: Struct<{
readonly action: Literal<"type">;
readonly text: String;
}>;

ViewRange

Added in v4.0.0 Source

Defines a [start, end] line range for viewing file contents.

When to use

Use when constructing or validating view_range for memory or text editor view commands.

Details

Lines are 1-indexed. Use -1 for end to read to the end of the file. For example, [1, 50] views lines 1-50 and [100, -1] views from line 100 to the end of the file.

See

Signature

declare const ViewRange: Tuple<readonly [Int, Int]>;

Defines configuration arguments for the web fetch tool.

When to use

Use when you need to configure WebFetch_20250910 with usage limits, domain filters, citations, or content token limits.

Details

The payload can set maxUses, domain filters, citations, and maxContentTokens, which map to Anthropic web fetch request fields.

Gotchas

allowedDomains and blockedDomains are mutually exclusive. maxContentTokens is approximate and does not apply to binary content such as PDFs.

See

Signature

declare const WebFetch_20250910_Args: Struct<{
readonly allowedDomains: optional<$Array<String>>;
readonly blockedDomains: optional<$Array<String>>;
readonly citations: optional<
Struct<{
readonly enabled: Boolean;
}>
>;
readonly maxContentTokens: optional<Int>;
readonly maxUses: optional<Int>;
}>;

Defines citation configuration for web fetch.

When to use

Use when you need to enable or disable citations on web fetch results.

Details

The payload contains the enabled flag. citations is optional on WebFetch_20250910_Args, and citations are disabled by default.

See

Signature

declare const WebFetchCitationsConfig: Struct<{
readonly enabled: Boolean;
}>;

Schema for Claude-supplied web fetch parameters.

When to use

Use when validating or constructing the url payload consumed by WebFetch_20250910.

Details

The payload contains the single url parameter for Anthropic web fetch.

Gotchas

The URL must be user-provided or from prior search/fetch results. Maximum URL length is 250 characters.

See

Signature

declare const WebFetchParameters: Struct<{
readonly url: String;
}>;

Defines configuration arguments for the web search tool.

When to use

Use when you need to configure WebSearch_20250305 with search limits, domain filters, or user location.

Details

The payload can set maxUses, allowedDomains, blockedDomains, and userLocation.

Gotchas

allowedDomains and blockedDomains are mutually exclusive.

See

Signature

declare const WebSearch_20250305_Args: Struct<{
readonly allowedDomains: optional<$Array<String>>;
readonly blockedDomains: optional<$Array<String>>;
readonly maxUses: optional<Int>;
readonly userLocation: optional<
Struct<{
readonly city: optional<String>;
readonly country: optional<String>;
readonly region: optional<String>;
readonly timezone: optional<String>;
readonly type: Literal<"approximate">;
}>
>;
}>;

Schema for Claude-supplied web search tool parameters.

Details

The payload contains the generated query string and is consumed by WebSearch_20250305.

See

Signature

declare const WebSearchParameters: Struct<{
readonly query: String;
}>;

Describes user location for localizing search results.

When to use

Use when you need to localize search results for location-dependent queries like weather, local businesses, or events.

Details

The schema uses type: "approximate" plus optional city, region, country, and timezone. country is an ISO 3166-1 alpha-2 code, and timezone is an IANA time zone identifier.

See

Signature

declare const WebSearchUserLocation: Struct<{
readonly city: optional<String>;
readonly country: optional<String>;
readonly region: optional<String>;
readonly timezone: optional<String>;
readonly type: Literal<"approximate">;
}>;

Tools

Defines the Anthropic Bash tool (2024-10-22 version).

When to use

Use when you want the model to execute bash commands with the 2024-10-22 Anthropic computer-use beta.

Details

Allows the model to execute bash commands in a sandboxed environment. Requires the "computer-use-2024-10-22" beta header.

See

Signature

declare const Bash_20241022: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.bash_20241022",
"AnthropicBash",
{
readonly args: Void;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: String;
},
true
>;

Defines the Anthropic Bash tool (2025-01-24 version).

When to use

Use when you want the model to execute bash commands with the 2025-01-24 Anthropic computer-use beta.

Details

Allows the model to execute bash commands in a sandboxed environment. Requires the "computer-use-2025-01-24" beta header.

See

Signature

declare const Bash_20250124: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.bash_20250124",
"AnthropicBash",
{
readonly args: Void;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: String;
},
true
>;

Defines the Anthropic Code Execution tool (2025-05-22 version).

When to use

Use when you want the model to execute code in a sandboxed environment with the 2025-05-22 Anthropic code-execution beta.

Details

Allows the model to execute code in a sandboxed environment with support for multiple execution types including programmatic tool calls, bash execution, and text editor operations.

See

Signature

declare const CodeExecution_20250522: <Mode extends FailureMode | undefined = undefined>(
args: void,
) => ProviderDefined<
"anthropic.code_execution_20250522",
"AnthropicCodeExecution",
{
readonly args: Void;
readonly failure: Struct;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: Struct;
},
false
>;

Defines the Anthropic Code Execution tool (2025-08-25 version).

When to use

Use when you want the model to execute code in a sandboxed environment with the 2025-08-25 Anthropic code-execution beta.

Details

Requires the code-execution-2025-08-25 beta header and uses CodeExecution_20250825_Parameters as its input schema.

See

Signature

declare const CodeExecution_20250825: <Mode extends FailureMode | undefined = undefined>(
args: void,
) => ProviderDefined<
"anthropic.code_execution_20250825",
"AnthropicCodeExecution",
{
readonly args: Void;
readonly failure: Union;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: Union;
},
false
>;

Defines the deprecated computer-use tool for Claude 3.5 Sonnet v2.

Details

Requires the "computer-use-2024-10-22" beta header. Basic actions only: screenshot, left_click, type, key, mouse_move.

Signature

declare const ComputerUse_20241022: <Mode extends FailureMode | undefined = undefined>(args: {
readonly displayHeightPx: number;
readonly displayNumber?: number;
readonly displayWidthPx: number;
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.computer_use_20241022",
"AnthropicComputerUse",
{
readonly args: Struct;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the computer-use tool for Claude 4 models and Claude Sonnet 3.7.

When to use

Use when you need Anthropic computer use for Claude 4 models or Claude Sonnet 3.7 with the 2025-01-24 action set.

Details

Requires the "computer-use-2025-01-24" beta header. Includes basic actions plus enhanced actions: scroll, left_click_drag, right_click, middle_click, double_click, triple_click, left_mouse_down, left_mouse_up, hold_key, wait.

See

Signature

declare const ComputerUse_20250124: <Mode extends FailureMode | undefined = undefined>(args: {
readonly displayHeightPx: number;
readonly displayNumber?: number;
readonly displayWidthPx: number;
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.computer_20250124",
"AnthropicComputerUse",
{
readonly args: Struct;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the computer-use tool for Claude Opus 4.5 only.

When to use

Use when you need Anthropic computer use for Claude Opus 4.5 with the 2025-11-24 action set and zoom-capable screen inspection.

Details

Requires the "computer-use-2025-11-24" beta header. Includes all actions from computer_20250124 plus the zoom action for detailed screen region inspection.

Gotchas

Zoom actions require enableZoom: true in args.

See

Signature

declare const ComputerUse_20251124: <Mode extends FailureMode | undefined = undefined>(args: {
readonly displayHeightPx: number;
readonly displayNumber?: number;
readonly displayWidthPx: number;
readonly enableZoom?: boolean;
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.computer_20251124",
"AnthropicComputerUse",
{
readonly args: Struct;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the memory tool for persistent file operations across conversations.

Details

Provides commands for creating, viewing, editing, renaming, and deleting files within the model's memory space.

Signature

declare const Memory_20250818: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.memory_20250818",
"AnthropicMemory",
{
readonly args: Void;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the deprecated text editor tool for Claude 3.5 Sonnet.

When to use

Use when you need the 2024-10-22 str_replace_editor compatibility path for Claude 3.5 Sonnet.

Details

Requires the "computer-use-2024-10-22" beta header and supports view, create, str_replace, insert, and undo_edit commands.

See

Signature

declare const TextEditor_20241022: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.text_editor_20241022",
"AnthropicTextEditor",
{
readonly args: Void;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the text editor tool for deprecated Claude Sonnet 3.7.

When to use

Use when you need the 2025-01-24 Claude Sonnet 3.7 text editor tool using str_replace_editor.

Details

Requires the "computer-use-2025-01-24" beta header, requires a handler, and supports view, create, str_replace, insert, and undo_edit commands.

See

Signature

declare const TextEditor_20250124: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
}) => ProviderDefined<
"anthropic.text_editor_20250124",
"AnthropicTextEditor",
{
readonly args: Void;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the text editor tool for Claude 4 models using Anthropic's str_replace_based_edit_tool.

When to use

Use when you need the 2025-04-29 Claude 4 str_replace_based_edit_tool version.

Details

Requires the "computer-use-2025-01-24" beta header.

Gotchas

This version does not support the undo_edit command.

See

Signature

declare const TextEditor_20250429: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
readonly max_characters?: number;
}) => ProviderDefined<
"anthropic.text_editor_20250429",
"AnthropicTextEditor",
{
readonly args: Struct;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines the text editor tool for Claude 4 models.

Details

Uses Anthropic's str_replace_based_edit_tool. max_characters can limit file-view output for this version.

Gotchas

This version does not support the undo_edit command.

Signature

declare const TextEditor_20250728: <Mode extends FailureMode | undefined = undefined>(args: {
readonly failureMode?: Mode;
readonly max_characters?: number;
}) => ProviderDefined<
"anthropic.text_editor_20250728",
"AnthropicTextEditor",
{
readonly args: Struct;
readonly failure: Never;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Union;
readonly success: String;
},
true
>;

Defines BM25/natural language tool search for Claude models.

When to use

Use when you want Claude to find relevant tools from a natural-language query instead of a regex pattern.

Details

Claude uses natural language queries to search for tools using the BM25 algorithm. The search is performed against tool names, descriptions, argument names, and argument descriptions. Requires the "advanced-tool-use-2025-11-20" beta header.

See

Signature

declare const ToolSearchBM25_20251119: <Mode extends FailureMode | undefined = undefined>(
args: void,
) => ProviderDefined<
"anthropic.tool_search_tool_bm25_20251119",
"AnthropicToolSearchBM25",
{
readonly args: Void;
readonly failure: Struct;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: $Array;
},
false
>;

Defines regex-based tool search for Claude models.

Details

Claude constructs regex patterns using Python's re.search() syntax to find tools. The regex is matched against tool names, descriptions, argument names, and argument descriptions. Requires the "advanced-tool-use-2025-11-20" beta header.

Signature

declare const ToolSearchRegex_20251119: <Mode extends FailureMode | undefined = undefined>(
args: void,
) => ProviderDefined<
"anthropic.tool_search_tool_regex_20251119",
"AnthropicToolSearchRegex",
{
readonly args: Void;
readonly failure: Struct;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: $Array;
},
false
>;

Defines the web fetch tool for Claude models.

When to use

Use when you want Claude to retrieve the content of a specific web page or PDF.

Details

Allows Claude to retrieve full content from web pages and PDF documents. This is a server-side tool executed by Anthropic's infrastructure. Selecting this tool adds the "web-fetch-2025-09-10" beta header.

See

Signature

declare const WebFetch_20250910: <Mode extends FailureMode | undefined = undefined>(args: {
readonly allowedDomains?: readonly Array<string>;
readonly blockedDomains?: readonly Array<string>;
readonly citations?: ReadonlySide<{
readonly enabled: Boolean;
}, "Encoded">;
readonly maxContentTokens?: number;
readonly maxUses?: number;
}) => ProviderDefined<"anthropic.web_fetch_20250910", "AnthropicWebFetch", {
readonly args: Struct;
readonly failure: Struct;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: Struct;
}, false>

Defines the web search tool for Claude models.

When to use

Use when you want Claude to search the web for real-time information.

Details

Enables Claude to search the web for real-time information. This is a server-side tool executed by Anthropic's infrastructure. Generally available (no beta header required).

See

Signature

declare const WebSearch_20250305: <Mode extends FailureMode | undefined = undefined>(args: {
readonly allowedDomains?: readonly Array<string>;
readonly blockedDomains?: readonly Array<string>;
readonly maxUses?: number;
readonly userLocation?: {
readonly city?: string;
readonly country?: string;
readonly region?: string;
readonly timezone?: string;
readonly type: "approximate";
};
}) => ProviderDefined<"anthropic.web_search_20250305", "AnthropicWebSearch", {
readonly args: Struct;
readonly failure: Struct;
readonly failureMode: Mode extends undefined ? "error" : Mode;
readonly parameters: Struct;
readonly success: $Array;
}, false>