Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, tool: Arc<dyn Tool>)

Register a tool. A later registration with the same name replaces the earlier one, so MCP servers can shadow built-ins deliberately.

Source

pub fn get(&self, name: &str) -> Option<&Arc<dyn Tool>>

Source

pub fn available(&self, name: &str) -> Option<&Arc<dyn Tool>>

The tool a call may actually reach: registered and inside whatever restriction is currently active.

Dispatch goes through this rather than get, because a restriction that only shortened the spec list would be advisory. A model that saw fs_write three turns ago can still name it, and a narrowing enforced only in the list is one the model routes around by remembering — the same reason the phase filter makes tools genuinely absent rather than merely refused.

Source

pub fn available_names(&self) -> Vec<&str>

Names a call may reach right now, for the message that says so.

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn iter(&self) -> impl Iterator<Item = &Arc<dyn Tool>>

Source

pub fn carried_state(&self) -> Vec<CarriedState>

Everything the registered tools want carried across a compaction.

In the registry’s stable order, so a compaction does not reorder the prompt for a reason nobody can see. Asked of every tool, including an MCP server’s — the loop does not learn which tools have state, only that some do, which is the same reason it never learns where a tool came from.

Source

pub fn specs(&self) -> Vec<ToolSpec>

Specs in a stable order — the tool list is the very front of the prompt prefix, so reordering it would invalidate the cache on every request.

Source

pub fn specs_for(&self, phase: Phase) -> Vec<ToolSpec>

Specs a given phase permits, in the same stable order.

Note what this does to the prompt cache: planning sends a shorter tool list, so switching phase changes the front of the prefix and the next turn re-pays for it. That is the price of the tools being genuinely absent rather than merely refused, and it is the right trade.

Source

pub fn forget_conversation_state(&self)

The names the surface is currently narrowed to, if anything is narrowing it.

The union across everything that has an opinion, which is the only composition that lets two restrictions coexist: each names the tools its own procedure needs, and intersecting them would strand a run that loaded two skills. The invariant that matters is not “smallest” but “never larger than the unrestricted surface”, and a union of subsets is still a subset — specs_for intersects with what is registered, so a name nothing matches adds nothing.

A tool that is itself restricting stays in the surface whatever it declared. Otherwise the first skill call could remove skill, and a procedure that says “then load the follow-up skill” would name a tool that had just been taken away — a restriction that eats its own mechanism is a trap rather than a policy. Tell every tool the conversation ended. See Tool::forget_conversation_state.

Source

pub fn surface_restriction(&self) -> Option<BTreeSet<String>>

Source

pub fn with_builtins(self, cfg: &ToolsConfig, sandbox: Arc<Sandbox>) -> Self

Register the built-ins permitted by config.

The sandbox is passed in rather than read from config here because it changes what shell is — an unconfined shell and a confined one declare different capabilities, and the loop’s interlock reads them.

Trait Implementations§

Source§

impl Default for Registry

Source§

fn default() -> Registry

Returns the “default value” for a type. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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