pub struct Registry { /* private fields */ }Implementations§
Source§impl Registry
impl Registry
pub fn new() -> Self
Sourcepub fn insert(&mut self, tool: Arc<dyn Tool>)
pub fn insert(&mut self, tool: Arc<dyn Tool>)
Register a tool. A later registration with the same name replaces the earlier one, so MCP servers can shadow built-ins deliberately.
pub fn get(&self, name: &str) -> Option<&Arc<dyn Tool>>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn iter(&self) -> impl Iterator<Item = &Arc<dyn Tool>>
Sourcepub fn carried_state(&self) -> Vec<CarriedState>
pub fn carried_state(&self) -> Vec<CarriedState>
Everything the registered tools want carried across a compaction.
In the registry’s stable order, so a compaction does not reorder the prompt for a reason nobody can see. Asked of every tool, including an MCP server’s — the loop does not learn which tools have state, only that some do, which is the same reason it never learns where a tool came from.
Sourcepub fn specs(&self) -> Vec<ToolSpec>
pub fn specs(&self) -> Vec<ToolSpec>
Specs in a stable order — the tool list is the very front of the prompt prefix, so reordering it would invalidate the cache on every request.
Sourcepub fn specs_for(&self, phase: Phase) -> Vec<ToolSpec>
pub fn specs_for(&self, phase: Phase) -> Vec<ToolSpec>
Specs a given phase permits, in the same stable order.
Note what this does to the prompt cache: planning sends a shorter tool list, so switching phase changes the front of the prefix and the next turn re-pays for it. That is the price of the tools being genuinely absent rather than merely refused, and it is the right trade.
Sourcepub fn with_builtins(self, cfg: &ToolsConfig, sandbox: Arc<Sandbox>) -> Self
pub fn with_builtins(self, cfg: &ToolsConfig, sandbox: Arc<Sandbox>) -> Self
Register the built-ins permitted by config.
The sandbox is passed in rather than read from config here because it
changes what shell is — an unconfined shell and a confined one
declare different capabilities, and the loop’s interlock reads them.