pub enum Tool {
Command {
command: String,
args: Option<String>,
},
Read {
file_path: String,
offset: Option<u64>,
limit: Option<u64>,
},
Write {
file_path: String,
content: String,
},
Edit {
file_path: String,
old_string: String,
new_string: String,
replace_all: bool,
},
MultiEdit {
file_path: String,
edits: Vec<EditOp>,
},
Bash {
command: String,
workdir: Option<String>,
timeout_ms: Option<u64>,
description: Option<String>,
run_in_background: bool,
},
Raw {
tool_name: String,
input: Value,
},
}Expand description
A canonical tool invocation.
Known tools are normalized to Claude-canonical names with typed arguments.
Everything else — MCP tools (mcp__*), harness-private tools, anything
unmodeled — lands in Tool::Raw with its name and untouched input.
Variants§
Command
A command the user ran at the harness itself — a slash command, not
a model tool call. It rides on a Role::User turn, and whatever the
harness printed back arrives as the paired Block::ToolResult.
The leading / in name is what distinguishes it canonically: no
model-facing tool name may start with one, so every codec and renderer
round-trips it through Tool::from_canonical without a special case.
(command rather than name: the enum is tagged by name, so a
field of that name would collide with the tag on the wire.)
Fields
Read
Write
Edit
MultiEdit
Bash
Fields
Raw
MCP tools, harness-private tools, and anything whose input doesn’t fit a typed variant. Holds the canonical name and the untouched input; always lossless.
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn from_canonical(name: &str, input: Value) -> Tool
pub fn from_canonical(name: &str, input: Value) -> Tool
Sourcepub fn to_canonical(&self) -> (String, Value)
pub fn to_canonical(&self) -> (String, Value)
Inverse of Tool::from_canonical: the canonical name and input for
this tool, ready for a codec to denormalize into a harness’s native
names and keys.