Skip to main content

Engine

Struct Engine 

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

Cloneable in-process engine handle. It contains no transport concerns and is safe for tool providers to call while their parent call is executing.

Implementations§

Source§

impl Engine

Source§

impl Engine

Source§

impl Engine

Source§

impl Engine

Source

pub fn read_artifact( &self, path: &str, offset: u64, limit: u64, ) -> Result<ArtifactReadPage, ToolError>

Read a public artifact URI by possession, without a session ownership lookup. This synchronous API blocks; async tool executors use ToolExecutionContext::read_artifact.

Source§

impl Engine

Source

pub async fn compact_session( &self, session: SessionId, focus: Option<&str>, origin: EventOrigin, ) -> Result<bool, EngineError>

Source

pub async fn compact_session_result( &self, session: SessionId, focus: Option<&str>, origin: EventOrigin, ) -> Result<SessionCompactResult, EngineError>

Source§

impl Engine

Source

pub async fn delegate_invoke( &self, invocation: DelegateInvocation, ) -> Result<DelegateHandle, EngineError>

Admits a delegate invocation, creates/attaches its child, and starts the invocation-derived child run exactly once.

Source

pub fn await_delegate(&self, handle: DelegateHandle) -> DelegateAwait ⓘ

Waits for a child terminal state and returns the bounded model-visible delegate result. Cancellation retains the child session identity.

Source

pub async fn cancel_delegate( &self, handle: DelegateHandle, ) -> Result<ToolResult, EngineError>

Cancels the child run and returns the structured delegate cancellation result used by the parent tool invocation.

Source

pub fn subagent_agent_type( &self, caller_session_id: SessionId, child_session_id: SessionId, ) -> Result<AgentId, EngineError>

Source

pub async fn get_subagent_result( &self, caller_session_id: SessionId, reference: impl Display, wait: bool, offset: u32, limit: u32, cancellation: CancellationToken, ) -> Result<ToolResult, EngineError>

Reports session liveness, not delegation lifecycle. A running (including queued/starting, or finished-then-woken) subagent reports “running”; once it ends, the result is the last assistant message of its most recent turn, paginated by offset/limit.

Source

pub async fn steer_subagent( &self, caller_session_id: SessionId, child_session_id: SessionId, message: String, ) -> Result<ToolResult, EngineError>

Source

pub async fn cancel_subagent( &self, caller_session_id: SessionId, reference: impl Display, reason: Option<String>, ) -> Result<ToolResult, EngineError>

Source§

impl Engine

Source

pub async fn get_history( &self, session: SessionId, view: EngineHistoryView, ) -> Result<Vec<HistoryTurn>, EngineError>

Returns a live history projection for the given session.

Callable by anything holding an engine reference. The result reflects state at query time and may include events appended after the current model request started, such as earlier tool results from the same in-flight turn. Tool providers needing history should retain an Engine handle, following the delegate-provider pattern; the engine is deliberately not injected into every tool context.

Source§

impl Engine

Source

pub fn resolve_subagent_target( &self, caller: SessionId, reference: impl Display, scope: SubagentScope, ) -> Result<SessionId, EngineError>

Resolves a full UUID or a complete handle within caller’s addressable set (its direct children, or every tree peer).

There is deliberately no prefix matching: a partial handle is an error. An unresolvable reference never falls through to creating a subagent.

Source§

impl Engine

Source

pub async fn subscribe( &self, session: SessionId, cursor: Option<u64>, ) -> Result<(EventsSubscribeResult, Receiver<EventSubscriptionMessage>), EngineError>

Source

pub fn snapshot_events( &self, session: SessionId, cursor: Option<u64>, ) -> Result<EventsSubscribeResult, EngineError>

Source

pub fn subscribe_tool_output( &self, call: ToolCallId, stream: OutputStream, ) -> Option<(OutputSnapshot, Receiver<OutputMessage>)>

Subscribes to a currently running call’s retained output and live tail. Output is ephemeral and intentionally separate from event cursors.

Source

pub fn tool_output_streams( &self, call_id: ToolCallId, ) -> Option<Vec<OutputStream>>

Source

pub async fn append( &self, session: SessionId, run: Option<RunId>, origin: EventOrigin, event: Event, ) -> Result<(), EngineError>

Source

pub fn append_blocking( &self, session: SessionId, run: Option<RunId>, origin: EventOrigin, event: Event, ) -> Result<(), EngineError>

Synchronous setup/CLI wrapper. Do not call from a Tokio runtime.

Source

pub async fn submit_tool_result( &self, session: SessionId, run: RunId, tool_call_id: ToolCallId, result: Result<ToolResult, String>, ) -> Result<(), EngineError>

Commits a completed tool invocation through its session actor.

Source§

impl Engine

Source

pub fn message_relationship( &self, sender: SessionId, recipient: SessionId, ) -> Result<&'static str, EngineError>

Relationship label used as the message permission resource for a sender→recipient pair: parent, child, sibling, or *.

§Errors

Returns EngineError::Messaging with send_message:unknown_session when either session does not exist.

Source

pub async fn send_agent_message( &self, invocation: AgentMessageInvocation, ) -> Result<AgentMessageHandle, EngineError>

Durably accepts one agent message into the recipient’s producer inbox.

The sender’s ProducerOwner::Agent registration on the recipient is found-or-registered per send; registrations are runtime-only by contract, so re-registration after a process restart is expected and cheap. The idempotency key derives from (sender session, run, tool call): a retried call returns the original message_id and delivers once. The inbox-cap check, the pair-window check, the hop guard, and the acceptance run atomically inside the recipient’s actor (ProducerCommand::SendAgentMessage).

Chain depth is computed here, from the sender’s log, because the hop basis is the sender run’s own durable observation of agent mail — a different actor’s state that the recipient must not reach into. Depth is monotonic within a run, so two concurrent sends from one run resolve to the same value, which is the correct answer for both.

§Errors

Returns EngineError::Messaging stable codes for disabled messaging, invalid bodies, unknown recipients, non-tree-peer recipients, self sends, full inboxes, exhausted pair windows, chains past max_hops, and shutdown races; EngineError::Producer for idempotency payload conflicts.

Source§

impl Engine

Source§

impl Engine

Source

pub async fn start_run( &self, params: RunStartParams, origin: EventOrigin, ) -> Result<RunStartResult, EngineError>

Source

pub fn start_run_blocking( &self, params: RunStartParams, origin: EventOrigin, ) -> Result<RunStartResult, EngineError>

Synchronous setup/CLI wrapper. Do not call from a Tokio runtime.

Source

pub async fn steer( &self, run_id: RunId, input: String, origin: EventOrigin, ) -> Result<RunSteerResult, EngineError>

Source

pub fn steer_blocking( &self, run_id: RunId, input: String, origin: EventOrigin, ) -> Result<RunSteerResult, EngineError>

Synchronous setup/CLI wrapper. Do not call from a Tokio runtime.

Source

pub async fn recall_steer( &self, run_id: RunId, ) -> Result<RunRecallSteerResult, EngineError>

Source

pub async fn cancel_run( &self, run_id: RunId, ) -> Result<RunCancelResult, EngineError>

Source

pub async fn tool_stdin( &self, params: RunToolStdinParams, ) -> Result<RunToolStdinResult, EngineError>

Source§

impl Engine

Source

pub fn session_model_selection( &self, session: SessionId, ) -> Result<RunSelection, EngineError>

The accepted selection, advanced only by a committed fallback model turn.

Source

pub fn create_session( &self, selection: RunSelection, ) -> Result<SessionMeta, EngineError>

Source

pub fn list_sessions(&self) -> Vec<SessionMeta>

Top-level session listing: delegation roots only. Delegated children are selected through their root’s tree and stay reachable via Engine::get_session, Engine::children, Engine::tree and resume.

Source

pub fn get_session(&self, id: SessionId) -> Result<SessionMeta, EngineError>

Source

pub fn session_usage( &self, id: SessionId, ) -> Result<SessionUsageResult, EngineError>

Source

pub fn agent_usage(&self, agent_id: AgentId) -> AgentUsageResult

Source

pub fn global_usage(&self) -> GlobalUsageResult

Source

pub fn session_tree_usage( &self, id: SessionId, ) -> Result<SessionTreeUsageResult, EngineError>

Source

pub fn delegate_targets( &self, id: SessionId, ) -> Result<Vec<AgentId>, EngineError>

Source

pub fn children(&self, id: SessionId) -> Result<Vec<ChildSummary>, EngineError>

Source

pub fn tree(&self, id: SessionId) -> Result<SessionTree, EngineError>

Source

pub async fn resume(&self, id: SessionId) -> Result<SessionMeta, EngineError>

Adopts id and resolves the work its adoption found interrupted.

Adoption schedules delegation recovery instead of running it inline, so the wait below is what makes the ordering observable: when this returns, every delegation record under the session’s root that the adoption classified as running without a live run here has been resolved, and the root’s background-delegation capacity reads settled rather than transiently over-counted.

The wait happens here, after the actor has replied, and never inside the Resume handler: resolving a recovered delegate goes through its parent session’s mailbox, which is the very mailbox that handler occupies.

Source

pub async fn revert_session( &self, session_id: SessionId, through_seq: u64, origin: EventOrigin, ) -> Result<SessionRevertResult, EngineError>

Source

pub async fn fork_session( &self, session_id: SessionId, through_seq: u64, origin: EventOrigin, ) -> Result<SessionForkResult, EngineError>

Source

pub fn set_permission_mode( &self, session_id: SessionId, mode: PermissionMode, ) -> Result<(), EngineError>

Source

pub async fn rename_session( &self, params: SessionRenameParams, origin: EventOrigin, ) -> Result<SessionRenameResult, EngineError>

Source§

impl Engine

Source

pub fn is_reserved_staged_skill_prompt(prompt: &str) -> bool

Source

pub fn skill_tool_available( &self, session: SessionId, ) -> Result<bool, EngineError>

Source

pub fn list_skills( &self, session: SessionId, ) -> Result<SkillsListResult, EngineError>

Source

pub fn get_skill( &self, session: SessionId, name: &str, args: &str, ) -> Result<SkillsGetResult, EngineError>

Source

pub fn get_user_skill( &self, session: SessionId, name: &str, args: &str, ) -> Result<SkillsGetResult, EngineError>

Source

pub fn get_model_skill( &self, session: SessionId, name: &str, args: &str, ) -> Result<SkillsGetResult, EngineError>

Source

pub async fn invoke_skill( &self, session: SessionId, run: Option<RunId>, name: &str, args: &str, permission_preapproved: bool, ) -> Result<SkillInvocation, EngineError>

Source

pub fn skill_invocation_context( &self, name: &str, ) -> Result<Option<SkillContext>, EngineError>

Source

pub fn is_direct_skill_call(&self, call_id: ToolCallId) -> bool

Source

pub async fn execute_skill_fork( &self, session: SessionId, run: RunId, call_id: ToolCallId, name: &str, args: &str, ) -> Result<PersistedToolResult, EngineError>

Source

pub fn take_skill_model_override(&self, session: SessionId) -> Option<ModelKey>

Source§

impl Engine

Source

pub fn open(options: EngineOptions) -> Result<Self, EngineError>

Source

pub fn current_runtime(&self) -> Arc<PublishedRuntime> ⓘ

Source

pub fn runtime_snapshot(&self) -> Result<RuntimeSnapshotResult, EngineError>

Source

pub fn subscribe_runtime_changes(&self) -> Receiver<RuntimeChangedNotification>

Source

pub fn subscribe_engine_events(&self) -> Receiver<EngineEvent>

Source

pub fn connect_provider( &self, params: ProviderConnectParams, ) -> Result<ProviderConnectResult, EngineError>

Source

pub fn disconnect_provider( &self, params: ProviderDisconnectParams, ) -> Result<ProviderDisconnectResult, EngineError>

Source

pub fn reconcile_provider_store(&self) -> Result<bool, EngineError>

Source

pub fn refresh_catalog( &self, catalog: Arc<CatalogSnapshot>, ) -> Result<RuntimeSnapshotResult, EngineError>

Atomically recompiles and publishes a newly acquired catalog snapshot.

Source

pub fn register_tool_provider(&self, provider: Arc<dyn ToolProvider>)

Registers a tool provider after engine open, allowing providers that require an Engine (notably delegate) to break the construction cycle.

Source

pub fn try_register_tool_provider( &self, provider: Arc<dyn ToolProvider>, ) -> Result<(), EngineError>

Source

pub fn mcp_statuses(&self) -> Vec<McpServerStatus>

Source

pub fn plugin_statuses(&self) -> Vec<PluginStatus>

Source

pub async fn ping_plugin(&self, name: &str) -> Result<(), String>

Source

pub async fn shutdown(&self)

Stops new session mailbox traffic and cancels active work. Existing client clones may keep a session mailbox alive.

Trait Implementations§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Engine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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
§

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

§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

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
§

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
§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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