pub struct ToolRegistry { /* private fields */ }Expand description
Composable tool registry - stores and queries tool definitions.
Unlike the CLI’s registry which auto-registers all tools, this registry is empty by default. Callers compose it by registering tools from whichever modules they need.
§Example
use brainwires_tools::{ToolRegistry, BashTool, FileOpsTool, GitTool};
let mut registry = ToolRegistry::new();
registry.register_tools(BashTool::get_tools());
registry.register_tools(FileOpsTool::get_tools());
registry.register_tools(GitTool::get_tools());Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub const CORE_TOOL_NAMES: &'static [&'static str]
pub const CORE_TOOL_NAMES: &'static [&'static str]
Core tool names used for basic project exploration. Exposed so callers
can extend the default set with extras from config without forking the
list. Keep alphabetised so the serialised tools array is a stable
prefix — that is what makes the Anthropic prompt cache break points
in brainwires_providers::anthropic actually land cache hits.
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Create a registry pre-populated with all built-in tools
Sourcepub fn register_tools(&mut self, tools: Vec<Tool>)
pub fn register_tools(&mut self, tools: Vec<Tool>)
Register multiple tools at once
Sourcepub fn get_all_with_extra(&self, extra: &[Tool]) -> Vec<Tool>
pub fn get_all_with_extra(&self, extra: &[Tool]) -> Vec<Tool>
Get all tools including additional external tools (e.g., MCP tools)
Sourcepub fn get_initial_tools(&self) -> Vec<&Tool>
pub fn get_initial_tools(&self) -> Vec<&Tool>
Get tools that should be loaded initially (defer_loading = false)
Sourcepub fn get_deferred_tools(&self) -> Vec<&Tool>
pub fn get_deferred_tools(&self) -> Vec<&Tool>
Get only deferred tools (defer_loading = true)
Sourcepub fn search_tools(&self, query: &str) -> Vec<&Tool>
pub fn search_tools(&self, query: &str) -> Vec<&Tool>
Search tools by query string matching name and description
Sourcepub fn get_by_category(&self, category: ToolCategory) -> Vec<&Tool>
pub fn get_by_category(&self, category: ToolCategory) -> Vec<&Tool>
Get tools by category
Sourcepub fn get_all_with_mcp(&self, mcp_tools: &[Tool]) -> Vec<Tool>
pub fn get_all_with_mcp(&self, mcp_tools: &[Tool]) -> Vec<Tool>
Get all tools including MCP tools
Sourcepub fn get_core(&self) -> Vec<&Tool>
pub fn get_core(&self) -> Vec<&Tool>
Get core tools for basic project exploration, returned in the
canonical order defined by CORE_TOOL_NAMES so the resulting tools
array is byte-stable across turns.
Sourcepub fn get_core_with_extras(&self, extra_names: &[String]) -> Vec<&Tool>
pub fn get_core_with_extras(&self, extra_names: &[String]) -> Vec<&Tool>
Get core tools plus any extras named by extra_names (deduplicated,
extras appended after core in the order given). Unknown names are
silently skipped.
Sourcepub fn get_primary(&self) -> Vec<&Tool>
pub fn get_primary(&self) -> Vec<&Tool>
Get primary meta-tools (always available)
Sourcepub fn filtered_view(&self, allow: &[&str]) -> Vec<Tool>
pub fn filtered_view(&self, allow: &[&str]) -> Vec<Tool>
Return a filtered view containing only the named tools.
Useful when constructing a provider call for a constrained agent role —
the caller supplies the allow-list (e.g. from AgentRole::allowed_tools)
and receives only the matching Tool definitions.
Tools not present in the registry are silently skipped, so the list may
be shorter than allow if some tools are not registered.