pub struct ToolRegistry {
pub headless: bool,
pub hook_runner: ExternalHookRunner,
pub auto_classifier: Option<Arc<Mutex<AutoClassifier>>>,
/* private fields */
}Fields§
§headless: boolGoal-199: headless mode — interactive tools go through external hooks instead of waiting for terminal input.
hook_runner: ExternalHookRunnerGoal-199: external hook runner for headless permission checks.
auto_classifier: Option<Arc<Mutex<AutoClassifier>>>Goal-200: optional auto classifier for PermissionMode::Auto.
When Some, each tool call in Auto mode is classified by the
LLM before execution. Wrapped in a Mutex (tokio) because classify()
takes &mut self (it updates the denial tracker).
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new(transport: Arc<dyn ToolTransport>) -> Self
Sourcepub fn transport(&self) -> &Arc<dyn ToolTransport> ⓘ
pub fn transport(&self) -> &Arc<dyn ToolTransport> ⓘ
Returns a reference to the transport layer.
Sourcepub fn with_same_transport(&self) -> Self
pub fn with_same_transport(&self) -> Self
Create a new empty registry that shares the same transport.
Sourcepub fn with_permission_hook(self, hook: Arc<dyn PermissionHook>) -> Self
pub fn with_permission_hook(self, hook: Arc<dyn PermissionHook>) -> Self
Attach a PermissionHook (Goal 161). When set, ask_permission
is called before every tool invocation; returning false causes
invoke to return Error::PermissionDenied without running the tool.
Sourcepub fn set_permission_hook(&mut self, hook: Arc<dyn PermissionHook>)
pub fn set_permission_hook(&mut self, hook: Arc<dyn PermissionHook>)
Attach a permission hook via mutable reference.
Equivalent to [with_permission_hook] but usable on existing registries.
Sourcepub fn clear_permission_hook(&mut self)
pub fn clear_permission_hook(&mut self)
Remove any previously attached permission hook.
Sourcepub fn with_policy(self, policy: PolicyConfig) -> Self
pub fn with_policy(self, policy: PolicyConfig) -> Self
Attach an L1 policy config. The registry stores the policy so that
individual tools (e.g. run_shell) can query it via
registry.policy() at call time.
Sourcepub fn set_policy(&mut self, policy: PolicyConfig)
pub fn set_policy(&mut self, policy: PolicyConfig)
Set the L1 policy config via mutable reference.
Sourcepub fn policy(&self) -> Option<&PolicyConfig>
pub fn policy(&self) -> Option<&PolicyConfig>
Return the attached policy config, if any.
Sourcepub fn with_headless(self, headless: bool) -> Self
pub fn with_headless(self, headless: bool) -> Self
Enable headless mode (Goal 199): interactive tools go through external hooks instead of waiting for terminal input.
Sourcepub fn set_headless(&mut self, headless: bool)
pub fn set_headless(&mut self, headless: bool)
Set headless mode via mutable reference.
Sourcepub fn with_hook_runner(self, hook_runner: ExternalHookRunner) -> Self
pub fn with_hook_runner(self, hook_runner: ExternalHookRunner) -> Self
Attach an [ExternalHookRunner] for headless permission checks.
Sourcepub fn set_hook_runner(&mut self, hook_runner: ExternalHookRunner)
pub fn set_hook_runner(&mut self, hook_runner: ExternalHookRunner)
Set the external hook runner via mutable reference.
Sourcepub fn with_permissions(self, permissions: PermissionsConfig) -> Self
pub fn with_permissions(self, permissions: PermissionsConfig) -> Self
Set the permissions configuration for this registry.
Attach a SharedPermissions reference for runtime rule updates.
Unlike [with_permissions], this accepts an already-constructed
Arc<RwLock<LayeredPermissionsConfig>> so that multiple components
can share the same mutable config. Changes made via
add_session_rule / remove_session_rule on the shared config
are immediately visible through this registry.
Sourcepub fn with_auto_classifier(self, classifier: AutoClassifier) -> Self
pub fn with_auto_classifier(self, classifier: AutoClassifier) -> Self
Attach an AutoClassifier for PermissionMode::Auto.
When the registry’s permission mode is Auto,
each tool call is sent to the classifier before execution. The
classifier is wrapped in Arc<Mutex<...>> so it can be shared
across clones of the registry.
Sourcepub fn permission_mode(&self) -> PermissionMode
pub fn permission_mode(&self) -> PermissionMode
Return the current permission mode.
Sourcepub fn permissions_config(&self) -> Option<PermissionsConfig>
pub fn permissions_config(&self) -> Option<PermissionsConfig>
Return a reference to the current permissions config, if any. Return a cloned snapshot of the current permissions config.
Uses try_read() — returns None if the lock is held for writing
(which is rare and brief). Callers that need a guaranteed read
should use [invoke_with_audit] which does an async .read().await.
Sourcepub fn is_plan_mode(&self, tool_name: &str) -> bool
pub fn is_plan_mode(&self, tool_name: &str) -> bool
Check whether a tool requires plan mode according to the current permissions configuration.
Sourcepub fn with_touched_files(self, slot: Arc<Mutex<TouchedFiles>>) -> Self
pub fn with_touched_files(self, slot: Arc<Mutex<TouchedFiles>>) -> Self
Attach a TouchedFiles collector. Tool invocations on
structured filesystem tools will record their path arguments
onto the shared collector. Used by AgentRuntime to assemble
per-turn checkpoint metadata.
Sourcepub fn clear_touched_files(&mut self)
pub fn clear_touched_files(&mut self)
Detach any previously attached collector.
Sourcepub fn touched_files(&self) -> Option<Arc<Mutex<TouchedFiles>>>
pub fn touched_files(&self) -> Option<Arc<Mutex<TouchedFiles>>>
Return the currently attached touched-files collector, if any.
pub fn register(self, tool: Arc<dyn Tool>) -> Self
Sourcepub fn register_with_aliases(
self,
tool: Arc<dyn Tool>,
aliases: &[&str],
) -> Self
pub fn register_with_aliases( self, tool: Arc<dyn Tool>, aliases: &[&str], ) -> Self
Register a tool and associate one or more aliases with it.
Aliases are not sent to the LLM — they are only used by
[find_by_name] so sandboxed replacements can be looked up under
the original name the model knows.
Sourcepub fn register_mut(&mut self, tool: Arc<dyn Tool>)
pub fn register_mut(&mut self, tool: Arc<dyn Tool>)
Register a tool via mutable reference (for use with shared registries).
Sourcepub fn register_mut_with_aliases(
&mut self,
tool: Arc<dyn Tool>,
aliases: &[&str],
)
pub fn register_mut_with_aliases( &mut self, tool: Arc<dyn Tool>, aliases: &[&str], )
Register a tool with aliases via mutable reference.
Sourcepub fn find_by_name(&self, name: &str) -> Option<Arc<dyn Tool>>
pub fn find_by_name(&self, name: &str) -> Option<Arc<dyn Tool>>
Find a registered tool by its primary name or any alias.
This is the preferred lookup path. invoke delegates to this so that
sandboxed tool replacements can be reached under the original name.
pub fn specs(&self) -> Vec<ToolSpec>
pub fn names(&self) -> Vec<String>
pub fn get(&self, name: &str) -> Option<Arc<dyn Tool>>
Sourcepub fn is_readonly(&self, name: &str) -> bool
pub fn is_readonly(&self, name: &str) -> bool
Check if a tool is read-only (no side effects).
Sourcepub fn is_readonly_for_call(&self, name: &str, args: &Value) -> bool
pub fn is_readonly_for_call(&self, name: &str, args: &Value) -> bool
Like is_readonly but passes call-time arguments to the tool so it can
make an argument-specific decision (e.g. sub_agent checking
subagent_type: "explore").
pub async fn invoke(&self, name: &str, arguments: Value) -> Result<String>
Sourcepub async fn invoke_with_audit(
&self,
name: &str,
arguments: Value,
) -> ToolDispatch
pub async fn invoke_with_audit( &self, name: &str, arguments: Value, ) -> ToolDispatch
Invoke a tool and return both its result and a populated
AuditMeta. Callers that need to persist audit data should
use this method; callers that don’t can call invoke which
discards the audit half.
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§fn clone(&self) -> ToolRegistry
fn clone(&self) -> ToolRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more