pub struct ToolRegistry { /* private fields */ }Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new(max_output_bytes: usize) -> Self
Sourcepub fn with_deferral_policies(self, cfg: &ToolsConfig) -> Self
pub fn with_deferral_policies(self, cfg: &ToolsConfig) -> Self
Take the deferral tools’ policies from the config. Separate from from_config_full
because the policies are only used if something is deferred, which defer decides much
later — once plugin tools have names.
Sourcepub fn with_hooks(self, hooks: Hooks) -> Self
pub fn with_hooks(self, hooks: Hooks) -> Self
Attach plugin hooks to every tool call.
pub fn hooks(&self) -> &Hooks
Sourcepub fn max_output_bytes(&self) -> usize
pub fn max_output_bytes(&self) -> usize
The cap for what the model reads. Public because the runtime applies it after the loop
hooks — redaction has to see whole tokens (#414).
Sourcepub fn from_config(cfg: &ToolsConfig, workspace_root: PathBuf) -> Self
pub fn from_config(cfg: &ToolsConfig, workspace_root: PathBuf) -> Self
Registry with the built-in tools, gated by cfg and confined to workspace_root.
Sourcepub fn from_config_with(
cfg: &ToolsConfig,
workspace_root: PathBuf,
skill_roots: Vec<Root>,
) -> Self
pub fn from_config_with( cfg: &ToolsConfig, workspace_root: PathBuf, skill_roots: Vec<Root>, ) -> Self
As Self::from_config, and shell may also be given a cwd inside a skill’s
directory, for the skills found under skill_roots.
Sourcepub fn from_config_full(
cfg: &ToolsConfig,
workspace_root: PathBuf,
skill_roots: Vec<Root>,
scripts_dir: Option<PathBuf>,
) -> Self
pub fn from_config_full( cfg: &ToolsConfig, workspace_root: PathBuf, skill_roots: Vec<Root>, scripts_dir: Option<PathBuf>, ) -> Self
As Self::from_config_with, and with a scripts directory: the script tool is
registered over it. None — no config directory could be worked out — means no
script tool, the same way there is no skill_manage without a directory to write.
Sourcepub fn register(&mut self, tool: Arc<dyn Tool>, policy: Policy)
pub fn register(&mut self, tool: Arc<dyn Tool>, policy: Policy)
Register a built-in (or runtime-provided) tool.
Sourcepub fn register_with_source(
&mut self,
tool: Arc<dyn Tool>,
policy: Policy,
source: ToolSource,
)
pub fn register_with_source( &mut self, tool: Arc<dyn Tool>, policy: Policy, source: ToolSource, )
Register a tool and say who added it. Plugins use this so that tools list can point
at the directory to look at when something is wrong.
Sourcepub fn disable(&mut self, names: &[String]) -> Vec<String>
pub fn disable(&mut self, names: &[String]) -> Vec<String>
Remove tools named in [tools] disabled, returning the names that matched nothing.
Called once after everything is registered — built-ins, plugin tools, the memory tool — because a plugin tool can only be found after plugins load. The unknown names come back instead of being ignored: a typo in this list is a tool the operator believes is off.
Sourcepub fn defer(&mut self, patterns: &[String]) -> Vec<String>
pub fn defer(&mut self, patterns: &[String]) -> Vec<String>
Withhold tools from the request without removing them: they stay registered and runnable, and the three tools that reach them are registered here — but only if something was actually deferred, because a config that defers nothing should not spend prompt tokens on three tools with nothing to reach.
Called once, after everything is registered, for the same reason as Self::disable:
a plugin’s name is only known once plugins have loaded. Returns the patterns that matched
nothing, so a typo is reported rather than silently doing nothing.
Defer by name or by source (#351).
A pattern is matched against a tool’s name and against its source label — builtin,
plugin:<name>, plugin:mcp:<server> — because that is the only way to say “every MCP
tool” without renaming them. MCP tools keep the name the server published (the #373
rule), so mcp_* would match nothing; plugin:mcp:* is the spelling that says what it
means, and it is the shipped default.
A source filter that matches nothing is not a typo: plugin:mcp:* on a box with no MCP
server is a filter over an empty set, and warning on every run would train the reader to
ignore the warning. Source labels are the patterns that carry a : (plugin:mcp:*,
plugin:greeter); a plain name pattern that matches nothing — note_*, shellish — is
still a mistake in the file and is still reported.
Sourcepub fn descriptors(&self) -> Vec<ToolDescriptor>
pub fn descriptors(&self) -> Vec<ToolDescriptor>
Every registered tool, advertised or not, in name order.
Sourcepub fn advertised_names(&self) -> Vec<String>
pub fn advertised_names(&self) -> Vec<String>
Names the model is offered, in name order.
Sourcepub fn schema_document(&self) -> Value
pub fn schema_document(&self) -> Value
One JSON Schema document describing every tool call this registry allows.
A call is {"name": …, "arguments": {…}}; oneOf gives one branch per advertised
tool, pinning name with const and validating arguments against the tool’s
parameters schema in $defs. $defs carries every registered tool’s schema, including
ones this configuration does not offer, so an external client can validate a call it
got hold of even after the policy changed.
pub fn names(&self) -> Vec<String>
Sourcepub fn only(&self, names: &[&str]) -> ToolRegistry
pub fn only(&self, names: &[&str]) -> ToolRegistry
A copy of this registry holding only names, for an agent whose capabilities are
declared rather than subtracted (#548).
The counterpart of without, and the direction that stays true: a
denylist is correct only until something new is registered — a plugin tool, an MCP server’s
tool, a tool added next release — and every one of those arrives granted. A flare is
read-only, so what it holds is written down, and everything else is absent from its registry
and therefore unreachable through a tool_call bridge.
Sourcepub fn without(&self, names: &[&str]) -> ToolRegistry
pub fn without(&self, names: &[&str]) -> ToolRegistry
A copy of this registry with names removed, for an agent that must not be able to
reach them at all (#171).
Not disable: a disabled tool is still registered, still dispatchable by
a tool_call that names it, and only withheld from the request. A flare is declared
read-only, so the write tools are not in its registry — the bridge cannot reach what is
not there, which is a claim a duplicated policy cannot make.
The rest is kept as it is, policies included: what a flare may read is decided by the parent’s own configuration, not by a second set of rules.
Sourcepub fn specs(&self) -> Vec<ToolSpec>
pub fn specs(&self) -> Vec<ToolSpec>
Specs for every tool the model is offered, derived from Self::descriptors.
Sourcepub async fn dispatch(
&self,
name: &str,
raw_args: &str,
approver: &dyn Approver,
) -> ToolOutcome
pub async fn dispatch( &self, name: &str, raw_args: &str, approver: &dyn Approver, ) -> ToolOutcome
Run a tool call as produced by a model. Never panics or errors: every failure
becomes an is_error outcome so it can be fed back to the model.
Plugin hooks see call_id: null here: this form is for a caller that is not the
loop and has no model-issued call to name. The loop uses [dispatch_call].
Sourcepub fn summary_of(&self, name: &str, raw_args: &str) -> String
pub fn summary_of(&self, name: &str, raw_args: &str) -> String
The one-liner an approval prompt would show for this call, without asking anyone. Used by
the loop when it records a call nobody answered: the row it writes has to read like the
question a person would have been asked, months later in eclipse approve --list.
Sourcepub async fn dispatch_call(
&self,
name: &str,
raw_args: &str,
approver: &dyn Approver,
call_id: Option<&str>,
) -> ToolOutcome
pub async fn dispatch_call( &self, name: &str, raw_args: &str, approver: &dyn Approver, call_id: Option<&str>, ) -> ToolOutcome
dispatch, telling the plugin hooks which tool call this is. With
[tools] concurrency above 1 several calls are in flight at once and their
before_tool / after_tool payloads interleave, so the id is how a hook tells them
apart — and how an after_tool rewrite is matched to the call it belongs to.
Sourcepub async fn dispatch_scoped(
&self,
name: &str,
raw_args: &str,
approver: &dyn Approver,
call_id: Option<&str>,
run: &RunScope,
) -> ToolOutcome
pub async fn dispatch_scoped( &self, name: &str, raw_args: &str, approver: &dyn Approver, call_id: Option<&str>, run: &RunScope, ) -> ToolOutcome
dispatch_call for a call made by a run: run is that run’s
scope, which a tool that starts children reads through Tool::call_scoped.