pub trait Tool:
Send
+ Sync
+ Attributable {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided method
fn spec(&self) -> ToolSpec { ... }
}Expand description
Core tool trait — implement for any capability.
Every Tool is Attributable: log emissions and audit traces from
a tool call carry the same <kind>.<alias> composite the rest of
the runtime uses for channels, providers, and memory. The supertrait
bound makes &dyn Tool coerce to &dyn Attributable automatically,
so dispatch-site logging can attribute without knowing the concrete
tool type.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON schema for parameters
Provided Methods§
Implementations on Foreign Types§
Source§impl Tool for GpioReadTool
impl Tool for GpioReadTool
fn name(&self) -> &str
fn description(&self) -> &str
fn parameters_schema(&self) -> Value
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
GpioReadTool: 'async_trait,
Source§impl Tool for GpioWriteTool
impl Tool for GpioWriteTool
fn name(&self) -> &str
fn description(&self) -> &str
fn parameters_schema(&self) -> Value
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
GpioWriteTool: 'async_trait,
Source§impl Tool for SubprocessTool
impl Tool for SubprocessTool
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON Schema Draft 7 — auto-generated from manifest.parameters.
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SubprocessTool: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
SubprocessTool: 'async_trait,
Spawn the binary, write args to stdin, read ToolResult from stdout.
Steps:
- Serialize
argsto a JSON string. - Spawn
binary_pathwith piped stdin/stdout/stderr. - Write
<json>\nto child stdin; close stdin (signal EOF). - Read one line from child stdout (10 s timeout).
- Kill the child process.
- Deserialize the line to
ToolResult. - On timeout → return error
ToolResult; on empty/bad output → error.