feat(tui): add usage overlay and sidebar for displaying usage statistics and tasks
feat(tui): implement status bar with connection and turn state indicators feat(tui): create workflow panel for agent status and progress visualization feat(web): introduce web frontend interface with static file serving feat(ws): add WebSocket interface for real-time communication and session management
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
//! Subagent spawning — launch a subagent on a background OS thread.
|
||||
//!
|
||||
//! Flow: creates a new tokio runtime on a dedicated OS thread, then
|
||||
//! `block_on` the engine's `run_agent` future. Returns a
|
||||
//! `JoinHandle<Result<String>>` the caller can `.join()`.
|
||||
|
||||
use std::thread;
|
||||
|
||||
use anyhow::Result;
|
||||
use tracing::info;
|
||||
|
||||
use crate::subagent::context::SubagentContext;
|
||||
use crate::subagent::division::AccessTier;
|
||||
use crate::subagent::engine::run_agent;
|
||||
use crate::tools::ToolCtx;
|
||||
|
||||
/// Spawn a subagent on a background OS thread.
|
||||
///
|
||||
/// The subagent runs inside its own tokio runtime so it can make async calls
|
||||
/// without blocking the calling thread's runtime.
|
||||
///
|
||||
/// Flow: `thread::spawn` → create `tokio::runtime::Runtime` →
|
||||
/// `runtime.block_on(run_agent(...))` → return.
|
||||
///
|
||||
/// Returns a `JoinHandle` the caller can `join()` to await the result.
|
||||
pub fn spawn_subagent(
|
||||
ctx: SubagentContext,
|
||||
directive: String,
|
||||
access: AccessTier,
|
||||
tool_ctx: ToolCtx,
|
||||
) -> thread::JoinHandle<Result<String>> {
|
||||
info!("Spawning subagent: {directive}");
|
||||
thread::spawn(move || {
|
||||
let rt = tokio::runtime::Runtime::new()?;
|
||||
rt.block_on(run_agent(ctx, &directive, access, tool_ctx))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user