pub trait ToolProvider: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn can_handle(&self, source: &ToolSource) -> bool;
fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ToolResolveRequest<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resolved: &'life1 ResolvedTool,
options: &'life2 ToolOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchedTool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn is_cached(&self, resolved: &ResolvedTool, options: &ToolOptions) -> bool;
// Provided method
fn check_prerequisites<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for tool providers (GitHub, OCI, Nix).
Each provider implements this trait to handle resolution and fetching
of tools from a specific source type. Providers are registered with
the ToolRegistry and selected based on the source configuration.
§Example
pub struct GitHubToolProvider { /* ... */ }
#[async_trait]
impl ToolProvider for GitHubToolProvider {
fn name(&self) -> &'static str { "github" }
fn description(&self) -> &'static str { "Fetch tools from GitHub releases" }
// ...
}Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Provider name (e.g., “github”, “nix”, “oci”).
This should match the type field in the CUE schema.
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Human-readable description for help text.
Sourcefn can_handle(&self, source: &ToolSource) -> bool
fn can_handle(&self, source: &ToolSource) -> bool
Check if this provider can handle the given source type.
Sourcefn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ToolResolveRequest<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ToolResolveRequest<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Resolve a tool specification to a fetchable artifact.
This performs version resolution, platform matching, and returns the concrete artifact reference (image digest, release URL, etc.)
§Arguments
request- Resolution parameters including tool name, version, platform, provider-specific config, and optional authentication token
§Errors
Returns an error if resolution fails (version not found, etc.)
Sourcefn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resolved: &'life1 ResolvedTool,
options: &'life2 ToolOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resolved: &'life1 ResolvedTool,
options: &'life2 ToolOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetch and cache a resolved tool.
Downloads the artifact, extracts binaries, and returns the local path.
If the tool is already cached and force_refetch is false, returns
the cached path without re-downloading.
§Arguments
resolved- A previously resolved tooloptions- Fetch options (cache dir, force refetch)
§Errors
Returns an error if fetching or extraction fails.
Sourcefn is_cached(&self, resolved: &ResolvedTool, options: &ToolOptions) -> bool
fn is_cached(&self, resolved: &ResolvedTool, options: &ToolOptions) -> bool
Check if a tool is already cached.
Returns true if the tool binary exists in the cache directory.
Provided Methods§
Sourcefn check_prerequisites<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn check_prerequisites<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if provider prerequisites are available.
Called early during runtime activation to fail fast if required dependencies are missing (e.g., Nix CLI not installed).
§Default Implementation
Returns Ok(()) - most providers only need HTTP access.
§Errors
Returns an error with a helpful message if prerequisites are not met.