Skip to main content

ToolBox

Struct ToolBox 

Source
pub struct ToolBox {
    pub skills_dir: PathBuf,
    pub searxng_url: Option<String>,
    pub langsearch_key: Option<String>,
    pub search_provider: String,
    pub blocked_domains: Vec<String>,
    pub supports_images: bool,
    pub image_gen_backend: Option<(OpenRouter, String)>,
    pub space_files_dir: PathBuf,
    pub space_apps_dir: PathBuf,
    pub space_scripts_dir: PathBuf,
    pub session_id: String,
    pub video_gen_backend: Option<(OpenRouter, String)>,
    /* private fields */
}

Fields§

§skills_dir: PathBuf

App-managed destination for newly created or downloaded skills.

§searxng_url: Option<String>

Base URL of a SearXNG instance (e.g. http://localhost:8080), no trailing slash. Free and self-hosted — no API key needed.

§langsearch_key: Option<String>

LangSearch API key (free tier, no card): https://langsearch.com/dashboard

§search_provider: String

Which backend search(mode=web) prefers: “auto” (LangSearch, then SearXNG, DuckDuckGo, and Brave), or an explicit “langsearch”/“searxng”/“duckduckgo”.

§blocked_domains: Vec<String>

Domains a per-space setting always excludes from search(mode=web) results (appended to any exclude_domains the model passes).

§supports_images: bool

Whether the current model supports image inputs. When false, tool image results are returned as text references instead of being injected as vision content (which would cause a 400).

§image_gen_backend: Option<(OpenRouter, String)>

Provider + model for AI image generation. None = tool disabled.

§space_files_dir: PathBuf

Directory to save generated images into / search for reference images.

§space_apps_dir: PathBuf§space_scripts_dir: PathBuf

Directory holding space-local scripts (created by the model via the scripts tool).

§session_id: String

Current session id — for attaching generated images to a message.

§video_gen_backend: Option<(OpenRouter, String)>

Provider + model for video generation. None = tools hidden.

Implementations§

Source§

impl ToolBox

Source

pub fn new( skills_dir: PathBuf, searxng_url: Option<String>, langsearch_key: Option<String>, search_provider: String, blocked_domains: Vec<String>, db_path: Option<PathBuf>, files: Option<FilesCtx>, apps: Option<AppsCtx>, ) -> Self

All config knobs; kept flat because ~17 test call sites construct this with inline None/default args — a config struct would churn every one of them for no readability gain.

Source

pub fn with_skill_dirs(self, skill_dirs: Vec<PathBuf>) -> Self

Replace the skill roots used for reads while retaining skills_dir as the app-managed install/create destination.

Source

pub fn research( searxng_url: Option<String>, langsearch_key: Option<String>, search_provider: String, blocked_domains: Vec<String>, db_path: Option<PathBuf>, ) -> Self

A toolbox restricted to search/fetch_url — for deep-research searcher agents, which get no filesystem/app/script access.

Source

pub fn with_research_session(self, session_id: String) -> Self

Attach a research session id, enabling research_lookup for follow-up turns in that session’s chat. Also merges any domains the user has discarded in this session into blocked_domains, so a later search/fetch_url call excludes them the same way the global setting does.

Source

pub const fn cache_only(self) -> Self

Restrict fetch_url to serving from web_cache only — a cache miss returns [not cached] instead of fetching. Used for the Verifier’s quote-checking pass (Task 8).

Source

pub fn defs(&self) -> Vec<ToolDef>

Tool definitions to attach to the request, or empty to send a request identical to one from before tool-calling existed (keeps models that don’t support tools working unchanged). search always works — it prefers configured API backends, then uses keyless HTML fallbacks when those are unavailable, so it needs no setup.

Source

pub async fn run(&self, name: &str, args: &str) -> (String, String)

Run a tool by name. Returns (result text sent back to the model, status label shown in the UI while it runs).

Trait Implementations§

Source§

impl ToolExecutor for ToolBox

Source§

fn defs(&self) -> Vec<ToolDef>

Tool definitions to attach to the request (see ToolBox::defs).
Source§

fn is_read_only(&self, name: &str, args: &str) -> bool

Whether a call is read-only (see is_read_only_tool) — parallel calls run concurrently only when every one of them is.
Source§

fn run<'a>( &'a self, name: &'a str, args: &'a str, ) -> Pin<Box<dyn Future<Output = (String, String)> + Send + 'a>>

Run one tool call, returning (result, status-label). Boxed future so the trait stays dyn-compatible (the loops hold Arc<dyn ToolExecutor>).
Source§

fn supports_images(&self) -> bool

Whether the current model accepts image inputs.
Source§

fn space_files_dir(&self) -> Option<PathBuf>

The active space’s files dir, for resolving image references in tool results.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more