pub struct ToolManager { /* private fields */ }Implementations§
Source§impl ToolManager
impl ToolManager
pub fn new() -> Self
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,
auto_compact_enabled: bool,
) -> Vec<ToolDefinition>
pub fn tools_for_mode( &self, mode: AgentMode, auto_compact_enabled: bool, ) -> Vec<ToolDefinition>
Returns the tool definitions appropriate for the given agent mode.
When auto_compact_enabled is false, the auto_compact tool is excluded.
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.