pub struct SubagentController { /* private fields */ }Expand description
Central controller that manages spawning, lifecycle, and state of all subagents. The background completion monitor is cancelled when the final controller owner is dropped; its task-held clone is intentionally non-owning.
Implementations§
Source§impl SubagentController
impl SubagentController
pub async fn matrix_tracker_projection(&self) -> Option<Value>
Source§impl SubagentController
impl SubagentController
Sourcepub fn take_matrix_completion(&self) -> Option<MatrixSnapshot>
pub fn take_matrix_completion(&self) -> Option<MatrixSnapshot>
Coalesced notification projection; lifecycle authority stays in events.
Sourcepub fn has_matrix_completion(&self) -> bool
pub fn has_matrix_completion(&self) -> bool
Idle wakeups inspect readiness without consuming the outer loop’s result.
pub async fn set_matrix_persistence( &self, persistence: MatrixPersistence, ) -> Result<()>
pub fn matrix_is_executing(&self) -> bool
pub async fn cancel_matrix(&self) -> Result<()>
pub async fn matrix_control(&self, args: Value) -> Result<Value>
Source§impl SubagentController
impl SubagentController
Sourcepub async fn background_status_entries(&self) -> Vec<BackgroundSubprocessEntry>
pub async fn background_status_entries(&self) -> Vec<BackgroundSubprocessEntry>
Returns status entries for all tracked background subprocesses.
Sourcepub async fn background_snapshot(
&self,
target: &str,
) -> Result<BackgroundSubprocessSnapshot>
pub async fn background_snapshot( &self, target: &str, ) -> Result<BackgroundSubprocessSnapshot>
Returns a snapshot of a background subprocess including its preview output.
Sourcepub fn background_subagents_enabled(&self) -> bool
pub fn background_subagents_enabled(&self) -> bool
Returns whether background subagents are enabled in the configuration.
Sourcepub fn configured_default_background_agent(&self) -> Option<&str>
pub fn configured_default_background_agent(&self) -> Option<&str>
Returns the configured default background agent name, if any.
Sourcepub async fn toggle_default_background_subagent(
&self,
) -> Result<BackgroundSubprocessEntry>
pub async fn toggle_default_background_subagent( &self, ) -> Result<BackgroundSubprocessEntry>
Toggles the default background subagent between running and stopped.
Sourcepub async fn restore_background_subagents(
&self,
) -> Result<Vec<BackgroundSubprocessEntry>>
pub async fn restore_background_subagents( &self, ) -> Result<Vec<BackgroundSubprocessEntry>>
Restarts background subagents that were previously enabled but are no longer running.
Sourcepub async fn refresh_background_processes(
&self,
) -> Result<Vec<BackgroundSubprocessEntry>>
pub async fn refresh_background_processes( &self, ) -> Result<Vec<BackgroundSubprocessEntry>>
Refreshes the state of all background subprocesses and respawns as needed.
Sourcepub async fn wait_for_background(
&self,
targets: &[String],
timeout_ms: Option<u64>,
) -> Result<Option<BackgroundSubprocessEntry>>
pub async fn wait_for_background( &self, targets: &[String], timeout_ms: Option<u64>, ) -> Result<Option<BackgroundSubprocessEntry>>
Blocks until one of the target background subprocesses reaches a
terminal state (Stopped/Error) or the timeout expires.
This is the background counterpart to the delegated
SubagentController::wait: managed subprocesses previously had no
model-visible wait path, so the main orchestrator could only observe
completion via manual /subprocesses polling or the Local Agents
drawer. Unknown ids resolve to Ok(None) (fail-closed) rather than
an error so the unified agent action=wait dispatcher can race this
alongside the delegated wait without hallucinating completion.
Sourcepub async fn graceful_stop_background(
&self,
target: &str,
) -> Result<BackgroundSubprocessEntry>
pub async fn graceful_stop_background( &self, target: &str, ) -> Result<BackgroundSubprocessEntry>
Gracefully stops a background subprocess by setting its desired state to disabled.
Sourcepub async fn force_cancel_background(
&self,
target: &str,
) -> Result<BackgroundSubprocessEntry>
pub async fn force_cancel_background( &self, target: &str, ) -> Result<BackgroundSubprocessEntry>
Force-cancels a background subprocess, closing its exec session immediately.
Sourcepub async fn snapshot_for_thread(
&self,
target: &str,
) -> Result<SubagentThreadSnapshot>
pub async fn snapshot_for_thread( &self, target: &str, ) -> Result<SubagentThreadSnapshot>
Returns a thread snapshot for a tracked child subagent by its target id.
Source§impl SubagentController
impl SubagentController
Sourcepub async fn spawn(
&self,
request: SpawnAgentRequest,
) -> Result<SubagentStatusEntry>
pub async fn spawn( &self, request: SpawnAgentRequest, ) -> Result<SubagentStatusEntry>
Spawns a new subagent child process from a SpawnAgentRequest.
Sourcepub async fn spawn_background_subprocess(
&self,
request: SpawnBackgroundSubprocessRequest,
) -> Result<BackgroundSubprocessEntry>
pub async fn spawn_background_subprocess( &self, request: SpawnBackgroundSubprocessRequest, ) -> Result<BackgroundSubprocessEntry>
Spawns a background subprocess for a subagent marked background: true.
Sourcepub async fn spawn_custom(
&self,
spec: SubagentSpec,
request: SpawnAgentRequest,
) -> Result<SubagentStatusEntry>
pub async fn spawn_custom( &self, spec: SubagentSpec, request: SpawnAgentRequest, ) -> Result<SubagentStatusEntry>
Spawns a subagent with a custom SubagentSpec that must be read-only.
Sourcepub async fn send_input(
&self,
request: SendInputRequest,
) -> Result<SubagentStatusEntry>
pub async fn send_input( &self, request: SendInputRequest, ) -> Result<SubagentStatusEntry>
Sends additional input to a running or queued subagent.
Sourcepub async fn resume(&self, target: &str) -> Result<SubagentStatusEntry>
pub async fn resume(&self, target: &str) -> Result<SubagentStatusEntry>
Resumes a closed or errored subagent and its descendants by re-queuing
their prompts. Cascades recursively through child-scoped controllers so
grandchildren closed by close_tree are resumed too, not merely
un-gated.
Sourcepub async fn close(&self, target: &str) -> Result<SubagentStatusEntry>
pub async fn close(&self, target: &str) -> Result<SubagentStatusEntry>
Closes a subagent and all its descendants, aborting any in-flight work.
Sourcepub async fn wait(
&self,
targets: &[String],
timeout_ms: Option<u64>,
) -> Result<Option<SubagentStatusEntry>>
pub async fn wait( &self, targets: &[String], timeout_ms: Option<u64>, ) -> Result<Option<SubagentStatusEntry>>
Blocks until one of the target subagents reaches a terminal state or the timeout expires.
Sourcepub async fn status_for(&self, target: &str) -> Result<SubagentStatusEntry>
pub async fn status_for(&self, target: &str) -> Result<SubagentStatusEntry>
Returns the current status of a tracked subagent by its target id.
Sourcepub async fn signal_shutdown(&self)
pub async fn signal_shutdown(&self)
Signal that the program is shutting down. Subsequent calls to
save_background_state will be skipped. All running child handles
are aborted so subagent tasks do not outlive the parent session.
Source§impl SubagentController
impl SubagentController
Sourcepub async fn verify_proposed_change(
&self,
diff_description: &str,
file_paths: &[PathBuf],
) -> Result<VerificationResult>
pub async fn verify_proposed_change( &self, diff_description: &str, file_paths: &[PathBuf], ) -> Result<VerificationResult>
Verify a proposed change by spawning a read-only verifier sub-agent.
The verifier re-reads the affected files and either approves or rejects the change. On rejection, the caller can retry the mutation up to N times.
This implements the propose/verify separation from Osmani’s loop engineering pattern: the proposer and verifier are independent agents with no shared context bias.
Source§impl SubagentController
impl SubagentController
Sourcepub async fn new(config: SubagentControllerConfig) -> Result<Self>
pub async fn new(config: SubagentControllerConfig) -> Result<Self>
Creates a new controller, discovering subagent specs and loading persisted background state.
Sourcepub async fn new_with_discovered(
config: SubagentControllerConfig,
discovered: DiscoveredSubagents,
) -> Result<Self>
pub async fn new_with_discovered( config: SubagentControllerConfig, discovered: DiscoveredSubagents, ) -> Result<Self>
Creates a new controller reusing an already-discovered spec set.
Interactive startup discovers specs once on the first-paint path;
hydration passes that result here to skip a second workspace/plugin
filesystem scan. Behavior matches Self::new otherwise.
Sourcepub fn subscribe_background_completions(
&self,
) -> Receiver<BackgroundCompletionEvent>
pub fn subscribe_background_completions( &self, ) -> Receiver<BackgroundCompletionEvent>
Subscribes to terminal notifications for managed background subprocesses.
Sourcepub fn subscribe_parent_background_completions(
&self,
) -> Receiver<BackgroundCompletionEvent>
pub fn subscribe_parent_background_completions( &self, ) -> Receiver<BackgroundCompletionEvent>
Subscribes the parent run loop and replays completions that arrived before its receiver was installed.
Sourcepub fn background_completion_notify(&self) -> Arc<Notify> ⓘ
pub fn background_completion_notify(&self) -> Arc<Notify> ⓘ
Returns the wake signal used by the interactive loop while it is idle.
Sourcepub async fn set_parent_messages(&self, messages: &[Message])
pub async fn set_parent_messages(&self, messages: &[Message])
Stores the parent conversation messages for context forking into children.
Sourcepub async fn set_turn_delegation_hints_from_input(
&self,
input: &str,
) -> Vec<String>
pub async fn set_turn_delegation_hints_from_input( &self, input: &str, ) -> Vec<String>
Parses the current user input to extract explicit agent mentions and delegation signals.
Sourcepub async fn clear_turn_delegation_hints(&self)
pub async fn clear_turn_delegation_hints(&self)
Resets delegation hints at the end of a turn.
Sourcepub async fn set_parent_session_id(&self, session_id: impl Into<String>)
pub async fn set_parent_session_id(&self, session_id: impl Into<String>)
Updates the parent session identifier at runtime.
Sourcepub async fn effective_specs(&self) -> Vec<SubagentSpec>
pub async fn effective_specs(&self) -> Vec<SubagentSpec>
Returns the currently effective subagent specifications (merged builtin + workspace).
Sourcepub async fn shadowed_specs(&self) -> Vec<SubagentSpec>
pub async fn shadowed_specs(&self) -> Vec<SubagentSpec>
Returns specs that are shadowed by workspace-level overrides.
Sourcepub async fn status_entries(&self) -> Vec<SubagentStatusEntry>
pub async fn status_entries(&self) -> Vec<SubagentStatusEntry>
Returns status entries for all tracked child subagents.
Trait Implementations§
Source§impl Clone for SubagentController
impl Clone for SubagentController
Source§impl Drop for SubagentController
impl Drop for SubagentController
Auto Trait Implementations§
impl !RefUnwindSafe for SubagentController
impl !UnwindSafe for SubagentController
impl Freeze for SubagentController
impl Send for SubagentController
impl Sync for SubagentController
impl Unpin for SubagentController
impl UnsafeUnpin for SubagentController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CacheValue for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more