pub struct ToolManager { /* private fields */ }Implementations§
Source§impl ToolManager
impl ToolManager
pub fn new() -> Self
Sourcepub fn set_sandbox(&mut self, sandbox: Sandbox)
pub fn set_sandbox(&mut self, sandbox: Sandbox)
Enable sandboxing: all path-based tools (ls, read, write,
edit, grep, glob) are confined to the sandbox root, and the
run tool’s explicit cwd is checked against it.
Sourcepub fn sandbox_check(
&self,
tool_name: &str,
arguments: &Value,
) -> Option<String>
pub fn sandbox_check( &self, tool_name: &str, arguments: &Value, ) -> Option<String>
If a sandbox is active and this tool call would access a path outside
it, return the violation error message. Returns None if the call is
allowed (or no sandbox is active).
Sourcepub fn register_defaults(&mut self)
pub fn register_defaults(&mut self)
Register all built-in tools.
pub fn register_tool(&mut self, tool: Tool)
Sourcepub fn register_custom_tools(&mut self, tools: &[CustomToolDefinition])
pub fn register_custom_tools(&mut self, tools: &[CustomToolDefinition])
Register custom tools from crate::custom_tools::CustomToolManager.
Tools whose names collide with built-in tools are silently skipped.
Sourcepub fn get_all_tool_definitions(&self) -> Vec<ToolDefinition>
pub fn get_all_tool_definitions(&self) -> Vec<ToolDefinition>
Returns the tool definitions for all registered tools.
Sourcepub fn tools_for_mode(
&self,
mode: AgentMode,
availability: ToolAvailability,
) -> Vec<ToolDefinition>
pub fn tools_for_mode( &self, mode: AgentMode, availability: ToolAvailability, ) -> Vec<ToolDefinition>
Returns the tool definitions appropriate for the given agent mode.
Tools disabled in availability (e.g. auto_compact, question) are
excluded, so the model never sees them.
Sourcepub fn category_of(&self, tool_name: &str) -> Option<ToolCategory>
pub fn category_of(&self, tool_name: &str) -> Option<ToolCategory>
Returns the category of a tool by name, or None if not found.
Sourcepub fn needs_approval(&self, tool_name: &str) -> bool
pub fn needs_approval(&self, tool_name: &str) -> bool
Returns true if the tool requires user approval before execution.
Destructive tools (write, edit, run) and signal tools (switch_mode,
question, auto_compact) require approval.
Sourcepub fn is_signal_tool(&self, tool_name: &str) -> bool
pub fn is_signal_tool(&self, tool_name: &str) -> bool
Returns true if the tool is a signal tool (switch_mode, question, auto_compact).
Signal tools are handled specially by the agent loop rather than executed generically.
Sourcepub fn parse_signal_event(
&self,
tool_name: &str,
arguments: &Value,
) -> Option<SignalEvent>
pub fn parse_signal_event( &self, tool_name: &str, arguments: &Value, ) -> Option<SignalEvent>
Parse a signal tool’s result string into a structured SignalEvent.
Signal tools return plain strings, but the agent loop needs structured data to dispatch them correctly. This method interprets the tool call arguments (not the result string) to produce the appropriate event.
Returns None if the tool is not a signal tool or the arguments are invalid.