Skip to main content

HarnessActionHost

Struct HarnessActionHost 

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

The RuntimeActionHost impl over an AgentHarness. Built once per session in crate::session::build — constructed empty before extension load (the harness doesn’t exist yet), then filled via set_harness once AgentHarness::create succeeds. Carried inside the [ActionBridge] as Arc<dyn RuntimeActionHost>.

runtime is captured at build time so the bridge can spawn dispatch from any thread; the impl’s async methods run ON that runtime (they are spawned by the trampoline), so they may freely await.

Implementations§

Source§

impl HarnessActionHost

Source

pub fn new_empty( catalog: Vec<Model>, cwd: PathBuf, runtime: Handle, cli_flags: BTreeMap<String, Value>, tool_context: ToolCallContext, ) -> (Self, Arc<OnceLock<WeakAgentHarness>>)

Build an empty host (no harness yet). The runtime is the handle the bridge captured (kept only so the impl can name it for future direct-spawn needs; the trampoline already spawns on the bridge’s runtime). Call set_harness once the harness is created. Returns (host, harness_cell) where harness_cell is the shared OnceLock the caller fills.

Source

pub fn set_catalog(&self, catalog: Vec<Model>)

Source

pub fn set_harness( cell: &Arc<OnceLock<WeakAgentHarness>>, harness: Arc<AgentHarness>, )

Fill the harness cell. Call exactly once, immediately after AgentHarness::create succeeds. Returns the host (for fluent chaining) — the caller already holds the Arc<dyn RuntimeActionHost> from construction; this just populates the cell that host reads.

Trait Implementations§

Source§

impl RuntimeActionHost for HarnessActionHost

Source§

fn reload_models<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

ReloadModels — re-read the model/provider catalog from disk without touching the extension registry.

The work happens on the TUI’s main loop (it owns the harness), so the request goes through the ReloadModelsMailbox and the answer comes back over the same request’s reply channel.

Source§

fn tool_program<'life0, 'async_trait>( &'life0 self, capability: Arc<ToolProgram>, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Action 30: an authenticated host-owned executing invocation, never registry JSON.
Source§

fn cancel_side_questions(&self, owner: u64)

Revoke side questions when their plugin bridge is retired.
Source§

fn side_question_revision(&self) -> u64

Host-internal TUI snapshots; never exposed as a cross-owner plugin action.
Source§

fn side_question_views(&self) -> Vec<Value>

Source§

fn side_question_ui<'life0, 'async_trait>( &'life0 self, owner: u64, thread_id: String, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn side_question<'life0, 'async_trait>( &'life0 self, owner: u64, args: Value, sink: SideQuestionSink, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Owner-scoped read-only inference, including host-owned UI publication.
Source§

fn cancel_child_agents(&self, owner: u64)

Invalidate child handles owned by an unloading/reloaded plugin.
Source§

fn replace_model_catalog(&self, models: Vec<Model>)

Refresh the host-side model selector after provider packages reload.
Source§

fn list_commands<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enumerate the registered slash commands. Read more
Source§

fn publish_registry(&self, snapshot: Arc<RegistrySnapshot>)

Publish a freshly loaded extension registry to the host. Read more
Source§

fn publish_registry_opt(&self, snapshot: Option<Arc<RegistrySnapshot>>)

Publish the registry, or None when a reload found no plugins at all. Read more
Source§

fn abort<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Abort the current run on the main lane. Read more
Source§

fn stop_round(&self, _args: Value) -> Result<Value, String>

Finish the current turn, then stop — the gentle counterpart of Self::abort. Read more
Source§

fn get_execution_context<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Safe, effective runtime metadata; never serialize credential bindings.
Source§

fn child_agent<'life0, 'async_trait>( &'life0 self, owner: u64, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Independent child lifecycle. owner is supplied by the bridge, NOT JSON.
Source§

fn get_cli_flag<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

GetCliFlag — read a parsed extension CLI flag. Args are {"name":"flag"} and the result is {"value": <bool|string|null>}.
Source§

fn send_message<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SendMessage — Pi-compatible triggerTurn and deliverAs scheduling. Defaults append while idle and steer while running; explicit true starts an idle run, false only updates context, and nextTurn waits for a new explicit prompt. Results distinguish appended/queued/run.
Source§

fn send_user_message<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SendUserMessage — drive a run from a user-text message.
Source§

fn append_entry<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

AppendEntry — append without starting a run. customType/data persists extension data only. A message is durably queued during an operation and committed after its current turn; the returned entryId is reserved and may not yet resolve to a transcript entry. Optional expected: {sessionId, leafId, customType, entryId} performs a conditional write against that exact branch snapshot; a successful reply must confirm scoped: true. Scoped messages additionally require outboxKey and must be custom messages: acceptance is idempotent on the current branch and pending context stays with its source state entry.
Source§

fn get_session_branch<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

GetSessionBranch — query custom entries on the current main branch. Required: non-empty customTypes string array. Optional: afterSeq (exclusive), limit (positive), order (oldestFirst default or newestFirst). Unknown/legacy keys and unfiltered {} are rejected. Sorting/limit apply globally across the requested types; identifiers match exactly. Consumers must require filtered == true in the reply rather than accepting an older host’s unfiltered successful response. This host also returns pinned sessionId, leafId, and scopedAppend: true for callers performing conditional state writes or outbox delivery.
Source§

fn set_session_name<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SetSessionName — set the session’s display name.
Source§

fn get_active_tools<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

GetActiveTools — the active tool-name list.
Source§

fn set_active_tools<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SetActiveTools — replace the active tool-name list.
Source§

fn set_model<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SetModel — switch the active model (by id; host resolves to a Model).
Source§

fn get_thinking_level<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

GetThinkingLevel — the current thinking level.
Source§

fn set_thinking_level<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SetThinkingLevel — set the thinking level.
Source§

fn compact<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compact — compact the session transcript.
Source§

fn get_system_prompt<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

GetSystemPrompt — the live composed system prompt.
Source§

fn new_session<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

NewSession — start a fresh session and switch to it.
Source§

fn fork<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fork — fork the current session and switch to the fork.
Source§

fn navigate_tree<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

NavigateTree — navigate/rewind the session tree.
Source§

fn switch_session<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

SwitchSession — hot-switch to an existing session by id.
Source§

fn reload<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reload — re-run extension discovery + Part-A resource loaders (a CLI concern; the host impl wires it to the ActionBridge.reload callback in B5d — until then this returns an “unsupported” error string).
Source§

fn ui_dialog<'life0, 'async_trait>( &'life0 self, _args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

UiDialog fallback for hosts that do not install an interactive mailbox. The default is deliberately an error so headless runs cannot accidentally report a fabricated user answer.

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> ErasedDestructor for T
where T: 'static,

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> MaybeSendSync for T

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