pub struct ToolRegistry { /* private fields */ }Expand description
Tool registry for managing all available tools
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn with_artifact_limits(
workspace: PathBuf,
artifact_limits: ArtifactStoreLimits,
) -> Self
pub fn with_artifact_limits( workspace: PathBuf, artifact_limits: ArtifactStoreLimits, ) -> Self
Create a new tool registry with custom artifact retention limits.
Sourcepub fn register_builtin(&self, tool: Arc<dyn Tool>)
pub fn register_builtin(&self, tool: Arc<dyn Tool>)
Register a builtin tool (cannot be overridden by dynamic tools)
Sourcepub fn register(&self, tool: Arc<dyn Tool>)
pub fn register(&self, tool: Arc<dyn Tool>)
Register a tool
If a tool with the same name already exists as a builtin, the registration is rejected to prevent shadowing of core tools.
Sourcepub fn unregister(&self, name: &str) -> bool
pub fn unregister(&self, name: &str) -> bool
Unregister a tool by name
Returns true if the tool was found and removed.
Sourcepub fn unregister_by_prefix(&self, prefix: &str)
pub fn unregister_by_prefix(&self, prefix: &str)
Unregister all tools whose names start with the given prefix.
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Get all tool definitions for LLM
Sourcepub fn context(&self) -> ToolContext
pub fn context(&self) -> ToolContext
Get the tool context
Sourcepub fn artifact_store(&self) -> ArtifactStore
pub fn artifact_store(&self) -> ArtifactStore
Return a clone of the registry’s artifact store handle.
Sourcepub fn get_artifact(&self, artifact_uri: &str) -> Option<ToolArtifact>
pub fn get_artifact(&self, artifact_uri: &str) -> Option<ToolArtifact>
Get a stored tool artifact by URI.
Sourcepub fn set_trace_sink(&self, sink: Arc<dyn TraceSink>)
pub fn set_trace_sink(&self, sink: Arc<dyn TraceSink>)
Replace the trace sink used for compact tool/program execution events.
Sourcepub fn trace_sink(&self) -> Arc<dyn TraceSink> ⓘ
pub fn trace_sink(&self) -> Arc<dyn TraceSink> ⓘ
Return the current trace sink.
Sourcepub fn set_search_config(&self, config: SearchConfig)
pub fn set_search_config(&self, config: SearchConfig)
Set the search configuration for the tool context
Sourcepub fn set_sandbox(&self, sandbox: Arc<dyn BashSandbox>)
pub fn set_sandbox(&self, sandbox: Arc<dyn BashSandbox>)
Set a sandbox executor so that bash tool calls use the sandbox even
when executed without an explicit ToolContext (i.e., via execute()).
Sourcepub async fn execute(&self, name: &str, args: &Value) -> Result<ToolResult>
pub async fn execute(&self, name: &str, args: &Value) -> Result<ToolResult>
Execute a tool by name using the registry’s default context
Sourcepub async fn execute_with_context(
&self,
name: &str,
args: &Value,
ctx: &ToolContext,
) -> Result<ToolResult>
pub async fn execute_with_context( &self, name: &str, args: &Value, ctx: &ToolContext, ) -> Result<ToolResult>
Execute a tool by name with an external context
Sourcepub async fn execute_raw(
&self,
name: &str,
args: &Value,
) -> Result<Option<ToolOutput>>
pub async fn execute_raw( &self, name: &str, args: &Value, ) -> Result<Option<ToolOutput>>
Execute a tool and return raw output using the registry’s default context
Sourcepub async fn execute_raw_with_context(
&self,
name: &str,
args: &Value,
ctx: &ToolContext,
) -> Result<Option<ToolOutput>>
pub async fn execute_raw_with_context( &self, name: &str, args: &Value, ctx: &ToolContext, ) -> Result<Option<ToolOutput>>
Execute a tool and return raw output with an external context
Auto Trait Implementations§
impl !Freeze for ToolRegistry
impl RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
impl UnwindSafe 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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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