@@ -43,31 +43,33 @@ pub struct SubAgentHandle {
4343 task_handle : Arc < tokio:: task:: JoinHandle < Result < String > > > ,
4444}
4545
46+ pub ( crate ) struct SubAgentHandleParts {
47+ pub id : String ,
48+ pub config : SubAgentConfig ,
49+ pub control_tx : tokio:: sync:: mpsc:: Sender < ControlSignal > ,
50+ pub subagent_event_tx : tokio:: sync:: broadcast:: Sender < OrchestratorEvent > ,
51+ pub event_history : Arc < RwLock < std:: collections:: VecDeque < OrchestratorEvent > > > ,
52+ pub state : Arc < RwLock < SubAgentState > > ,
53+ pub activity : Arc < RwLock < SubAgentActivity > > ,
54+ pub task_handle : tokio:: task:: JoinHandle < Result < String > > ,
55+ }
56+
4657impl SubAgentHandle {
4758 /// 创建新的句柄
48- pub ( crate ) fn new (
49- id : String ,
50- config : SubAgentConfig ,
51- control_tx : tokio:: sync:: mpsc:: Sender < ControlSignal > ,
52- subagent_event_tx : tokio:: sync:: broadcast:: Sender < OrchestratorEvent > ,
53- event_history : Arc < RwLock < std:: collections:: VecDeque < OrchestratorEvent > > > ,
54- state : Arc < RwLock < SubAgentState > > ,
55- activity : Arc < RwLock < SubAgentActivity > > ,
56- task_handle : tokio:: task:: JoinHandle < Result < String > > ,
57- ) -> Self {
59+ pub ( crate ) fn new ( parts : SubAgentHandleParts ) -> Self {
5860 Self {
59- id,
60- config,
61+ id : parts . id ,
62+ config : parts . config ,
6163 created_at : std:: time:: SystemTime :: now ( )
6264 . duration_since ( std:: time:: UNIX_EPOCH )
6365 . unwrap ( )
6466 . as_millis ( ) as u64 ,
65- control_tx,
66- subagent_event_tx,
67- event_history,
68- state,
69- activity,
70- task_handle : Arc :: new ( task_handle) ,
67+ control_tx : parts . control_tx ,
68+ subagent_event_tx : parts . subagent_event_tx ,
69+ event_history : parts . event_history ,
70+ state : parts . state ,
71+ activity : parts . activity ,
72+ task_handle : Arc :: new ( parts . task_handle ) ,
7173 }
7274 }
7375
0 commit comments