Skip to main content

BuiltinToolExecutor

Struct BuiltinToolExecutor 

Source
pub struct BuiltinToolExecutor { /* private fields */ }
Expand description

Built-in tool executor that uses ToolRegistry for dynamic dispatch

Implementations§

Source§

impl BuiltinToolExecutor

Source

pub fn new() -> Self

Creates a new executor with all built-in tools registered

Source

pub fn new_with_permissions( permission_checker: Arc<dyn PermissionChecker>, ) -> Self

Creates a new executor with a permission checker

Source

pub fn new_with_config(_config: Arc<RwLock<Config>>) -> Self

Compatibility constructor for callers that already hold shared config. Current built-ins have no executor-time configuration dependency.

Source

pub fn new_with_config_and_permissions( _config: Arc<RwLock<Config>>, permission_checker: Arc<dyn PermissionChecker>, ) -> Self

Creates a new executor with both shared config and a permission checker.

Source

pub fn with_registry(registry: ToolRegistry) -> Self

Creates a new executor from an existing registry

Source

pub fn with_registry_and_permissions( registry: ToolRegistry, permission_checker: Arc<dyn PermissionChecker>, ) -> Self

Creates a new executor from an existing registry and permission checker.

This is the dependency-injection counterpart to new_with_permissions: callers that intentionally expose a selected/custom registry can keep the canonical permission gate instead of silently dropping it.

Source

pub fn with_tool_event_publisher( self, publisher: Arc<dyn ToolEventPublisher>, ) -> Self

Inject an instance-local, non-blocking tool-event publisher.

Source

pub fn registry(&self) -> &ToolRegistry

Returns a reference to the internal registry

Source

pub fn eligible_native_tool(&self, name: &str) -> bool

Observe the registered Arc, not a same-name custom replacement.

Source

pub fn with_native_tool_ceiling( self, names: Vec<String>, ) -> Result<Self, ToolError>

Install an immutable positive ceiling. Reinstallation can only narrow it.

Source

pub fn tool_schemas() -> Vec<ToolSchema>

Returns all built-in tool schemas

Source

pub fn register_tool<T: Tool + 'static>(&self, tool: T) -> Result<(), ToolError>

Registers a custom tool to this executor

Source

pub fn register_tool_with_guide<T, G>( &self, tool: T, guide: G, ) -> Result<(), ToolError>
where T: Tool + 'static, G: ToolGuide + 'static,

Register a tool with its guide

Source

pub fn get_guide(&self, tool_name: &str) -> Option<Arc<dyn ToolGuide>>

Get guide for a tool

Source

pub async fn check_framework_root_spawn_permissions( &self, call: &ToolCall, args: &Value, ctx: &ToolExecutionContext<'_>, ) -> Result<Option<ToolOutcome>, ToolError>

Host-side permission entry used only by the installed v2 Root owner. Classification is explicit while the typed request retains the actual spawn_session identity, original argument bytes and existing once gates.

Source

pub fn build_enhanced_prompt(&self, context: GuideBuildContext) -> String

Build enhanced prompt for all registered tools

Trait Implementations§

Source§

impl Default for BuiltinToolExecutor

Source§

fn default() -> Self

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

impl ToolExecutor for BuiltinToolExecutor

Source§

fn check_permissions_for<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, call: &'life1 ToolCall, ctx: &'life2 ToolExecutionContext<'life3>, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutcome>, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

The real permission gate for built-in tools, extracted from the execute path so it is reusable by wrapping executors (issue #341). The behavior is byte-for-byte the same block that used to run inline in execute_with_context_outcome:

  • resolves the SAME tool_name + args the execute path runs with (so the check sees exactly what the tool will run with);
  • “always ask” rules (requires_forced_confirmation) force a confirmation even under bypass; everything else is skipped when the session is in bypass-permissions mode;
  • forced confirmations route through check_or_request_forced so the active mode/bypass can’t suppress the prompt;
  • a ConfirmationRequired first tries the cross-process ApprovalProxy (a subagent worker forwarding to its host), then the interactive human sink (returning the synthesized approval pause as Ok(Some(..))), then fails closed;
  • deny fails closed.

The only mechanical difference from the old inline block: the interactive pause is returned as Ok(Some(outcome)) and a clean pass returns Ok(None), so the caller decides whether to run the tool. The fallback arg-parse warning is intentionally NOT re-logged here — the execute path already logs it once for this call.

Source§

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, call: &'life1 ToolCall, ) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Executes a tool call Read more
Source§

fn execute_with_context<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, call: &'life1 ToolCall, ctx: ToolExecutionContext<'life2>, ) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Executes a tool call with streaming-capable context. Read more
Source§

fn execute_with_context_outcome<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, call: &'life1 ToolCall, ctx: ToolExecutionContext<'life2>, ) -> Pin<Box<dyn Future<Output = Result<ToolOutcome, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Outcome-aware dispatch: returns the tool’s ToolOutcome rather than the collapsed ToolResult, so the agent loop can branch on Completed/Running/NeedsHuman directly instead of sniffing markers on a result. The default collapses via the execute_with_context path (always Completed), so executors that never surface Running/NeedsHuman (composition, MCP, tests) need no override; the built-in + overlay executors override this to return the real outcome.
Source§

fn execute_exact_with_context_outcome<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, call: &'life1 ToolCall, execution_name: &'life2 str, ctx: ToolExecutionContext<'life3>, ) -> Pin<Box<dyn Future<Output = Result<ToolOutcome, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Execute a call through an already-selected exact owner. Read more
Source§

fn check_permissions_for_exact<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, call: &'life1 ToolCall, execution_name: &'life2 str, ctx: &'life3 ToolExecutionContext<'life4>, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutcome>, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Permission gate for an already-selected exact owner identity. Read more
Source§

fn check_permissions_for_resolved<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, call: &'life1 ToolCall, execution_name: &'life2 str, resolved_args: &'life3 Value, ctx: &'life4 ToolExecutionContext<'life5>, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutcome>, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Permission gate for a call whose exact execution identity and effective arguments have already been resolved by a wrapping executor. Read more
Source§

fn list_tools(&self) -> Vec<ToolSchema>

Lists all available tools and their schemas Read more
Source§

fn owns_exact_tool(&self, tool_name: &str) -> bool

Returns whether this executor owns tool_name as a complete, exact, case-sensitive execution identity. Read more
Source§

fn exact_tool_owner(&self, name: &str) -> Option<&dyn ToolExecutor>

Read-only observation of the concrete exact owner in a known routing chain. Unknown wrappers return None; existence/name is not provenance.
Source§

fn local_execution_contract(&self, name: &str) -> Option<&'static str>

Only concrete owners override this hook. Transparent wrappers retain their existing exact-owner forwarding instead of guessing provenance.
Source§

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

Source§

fn tool_mutability(&self, tool_name: &str) -> ToolMutability

Returns mutability metadata for a tool name when available. Executors that can inspect concrete tools should override this.
Source§

fn call_mutability(&self, call: &ToolCall) -> ToolMutability

Returns mutability metadata for a specific tool call when available. Defaults to name-based classification.
Source§

fn tool_concurrency_safe(&self, tool_name: &str) -> bool

Returns whether a tool can safely execute in parallel with other read-only tools. Executors that can inspect concrete tools should override this. Fallback keeps current behavior for known read-only tools.
Source§

fn call_concurrency_safe(&self, call: &ToolCall) -> bool

Returns whether a specific tool call can safely run in parallel. Defaults to the tool-name level classification.
Source§

fn call_parallel_classification( &self, call: &ToolCall, ) -> (ToolMutability, bool)

Classify a tool call’s mutability AND concurrency-safety together, returning (mutability, concurrency_safe). Read more
Source§

fn for_session(&self, _session: &Session) -> Option<Arc<dyn ToolExecutor>>

Optionally bind an already installed Host tool surface to a canonical Session contract. This selects registrations, never adds a grant. Unknown wrappers retain the existing behavior with None.
Source§

fn resolve_reference_for_session( &self, session: &Session, reference: &str, ) -> Option<String>

Use the same versioned exact owner for live dispatch and typed replay.
Source§

fn execution_contract_for_exact(&self, name: &str) -> Option<&'static str>

Observe semantics through the existing exact-owner chain. Calling only the owner’s local hook avoids recursion when an owner returns self. Opaque wrappers supply no provenance, even when their catalog has a name.
Source§

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

Registry replacement is observable even if name and contract agree.
Source§

fn framework_session_tool_for_exact( &self, name: &str, ) -> Option<HostFrameworkSessionTool>

Only an explicit Host factory supplies this opaque in-process proof. Unknown wrappers and names/contract strings alone supply no provenance.
Source§

fn local_framework_session_tool( &self, _name: &str, ) -> Option<HostFrameworkSessionTool>

Source§

fn tool_guidance(&self) -> Option<String>

Server-level usage guidance to surface in the system prompt for whatever this executor currently exposes — e.g. the instructions an MCP server returns from initialize. Because it is derived from the live executor, the text is naturally scoped to what is actually connected/loaded for the run (a disconnected server contributes nothing). 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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