a3s_code_core/orchestrator/mod.rs
1//! Advanced SubAgent control plane.
2//!
3//! This module is an advanced control-plane API for explicit SubAgent lifecycle
4//! management. Routine multi-agent composition should use the `task` /
5//! `parallel_task` delegation tools.
6//!
7//! Broadcast-backed lifecycle APIs support:
8//! - monitoring SubAgent behavior, planning, and execution
9//! - dynamically controlling SubAgents: pause, resume, cancel, and inspect
10//!
11//! ## 架构
12//!
13//! ```text
14//! AgentOrchestrator
15//! +-- spawn_subagent(SubAgentConfig)
16//! +-- AgentSession stream
17//! +-- broadcast OrchestratorEvent
18//! +-- pause/resume/cancel control signals
19//! ```
20//!
21//! ## 使用示例
22//!
23//! ```rust,ignore
24//! use a3s_code_core::orchestrator::{AgentOrchestrator, SubAgentConfig};
25//!
26//! # async fn example() -> anyhow::Result<()> {
27//! // Create a control plane backed by a real Agent.
28//! let agent = std::sync::Arc::new(a3s_code_core::Agent::from_config(config).await?);
29//! let orchestrator = AgentOrchestrator::from_agent(agent);
30//!
31//! // Subscribe to all events.
32//! let mut events = orchestrator.subscribe_all();
33//!
34//! // Spawn a SubAgent.
35//! let handle = orchestrator
36//! .spawn_subagent(
37//! SubAgentConfig::new("general", "Use glob to find Python files")
38//! .with_description("Analyze code")
39//! .with_max_steps(10),
40//! )
41//! .await?;
42//!
43//! // Monitor events.
44//! tokio::spawn(async move {
45//! while let Ok(event) = events.recv().await {
46//! println!("Event: {:?}", event);
47//! }
48//! });
49//!
50//! // Control the SubAgent lifecycle.
51//! orchestrator.pause_subagent(&handle.id).await?;
52//! orchestrator.resume_subagent(&handle.id).await?;
53//!
54//! # Ok(())
55//! # }
56//! ```
57
58mod agent;
59mod config;
60mod control;
61mod events;
62mod handle;
63mod state;
64mod wrapper;
65
66#[cfg(test)]
67mod tests;
68
69pub use agent::{AgentOrchestrator, SubAgentEventStream};
70pub use config::{OrchestratorConfig, SubAgentActivity, SubAgentConfig, SubAgentInfo};
71pub use control::ControlSignal;
72pub use events::OrchestratorEvent;
73pub use handle::SubAgentHandle;
74pub use state::SubAgentState;