pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute(&self, arguments: &str) -> ToolResult;
// Provided methods
fn requires_confirmation(&self) -> bool { ... }
fn confirmation_message(&self, arguments: &str) -> String { ... }
}Expand description
工具 trait
Required Methods§
fn name(&self) -> &str
fn description(&self) -> &str
fn parameters_schema(&self) -> Value
Sourcefn execute(&self, arguments: &str) -> ToolResult
fn execute(&self, arguments: &str) -> ToolResult
执行工具(同步)
Provided Methods§
Sourcefn requires_confirmation(&self) -> bool
fn requires_confirmation(&self) -> bool
是否需要用户确认(shell 命令需要,文件读取不需要)
Sourcefn confirmation_message(&self, arguments: &str) -> String
fn confirmation_message(&self, arguments: &str) -> String
生成确认提示文字(供 TUI 展示)