Skip to main content

Tool

Enum Tool 

Source
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

§command: String

Canonical name including the leading slash, e.g. "/release".

§args: Option<String>

Everything the user typed after the command name, when any.

§

Read

Fields

§file_path: String
§offset: Option<u64>
§limit: Option<u64>
§

Write

Fields

§file_path: String
§content: String
§

Edit

Fields

§file_path: String
§old_string: String
§new_string: String
§replace_all: bool
§

MultiEdit

Fields

§file_path: String
§edits: Vec<EditOp>
§

Bash

Fields

§command: String
§workdir: Option<String>
§timeout_ms: Option<u64>
§description: Option<String>
§run_in_background: bool
§

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.

Fields

§tool_name: String
§input: Value

Implementations§

Source§

impl Tool

Source

pub fn from_canonical(name: &str, input: Value) -> Tool

Build a Tool from a canonical tool name and input — names and argument keys already in the Claude convention (Read/Edit/Bash, file_path/old_string/…).

A typed variant is used only when the input fits its schema exactly; any unexpected key falls through to Tool::Raw. The mapping is lossless.

Source

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.

Trait Implementations§

Source§

impl Clone for Tool

Source§

fn clone(&self) -> Tool

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Tool

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Tool

Source§

fn eq(&self, other: &Tool) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Tool

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Tool

Auto Trait Implementations§

§

impl Freeze for Tool

§

impl RefUnwindSafe for Tool

§

impl Send for Tool

§

impl Sync for Tool

§

impl Unpin for Tool

§

impl UnsafeUnpin for Tool

§

impl UnwindSafe for Tool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.