a3s_code_core/agent_api/
run_facade.rs1use super::*;
2
3impl AgentSession {
4 pub async fn steer(
6 &self,
7 request: crate::run_control::SteerRequest,
8 ) -> crate::error::Result<crate::run_control::RunControlReceipt> {
9 if self.is_closed() {
10 return Err(crate::error::CodeError::SessionClosed {
11 session_id: self.session_id.clone(),
12 });
13 }
14 RunControl::from_session(self).steer(request).await
15 }
16
17 pub async fn interrupt(
20 &self,
21 request: crate::run_control::InterruptRequest,
22 ) -> crate::error::Result<crate::run_control::RunControlReceipt> {
23 if self.is_closed() {
24 return Err(crate::error::CodeError::SessionClosed {
25 session_id: self.session_id.clone(),
26 });
27 }
28 RunControl::from_session(self).interrupt(request).await
29 }
30
31 pub async fn run_control_snapshot(&self) -> Option<crate::run_control::RunControlSnapshot> {
34 RunControl::from_session(self).run_control_snapshot().await
35 }
36
37 pub async fn cancel_run(&self, run_id: &str) -> bool {
42 RunControl::from_session(self).cancel_run(run_id).await
43 }
44
45 pub async fn runs(&self) -> Vec<crate::run::RunSnapshot> {
47 RunControl::from_session(self).runs().await
48 }
49
50 pub async fn run_snapshot(&self, run_id: &str) -> Option<crate::run::RunSnapshot> {
52 RunControl::from_session(self).run_snapshot(run_id).await
53 }
54
55 pub async fn run_events(&self, run_id: &str) -> Vec<crate::run::RunEventRecord> {
57 RunControl::from_session(self).run_events(run_id).await
58 }
59
60 pub async fn run_event_page(
66 &self,
67 run_id: &str,
68 after_sequence: Option<usize>,
69 limit: usize,
70 ) -> Option<crate::run::RunEventPage> {
71 RunControl::from_session(self)
72 .run_event_page(run_id, after_sequence, limit)
73 .await
74 }
75
76 pub(crate) async fn run_event_observation(
78 &self,
79 run_id: &str,
80 after_sequence: Option<usize>,
81 limit: usize,
82 ) -> Option<crate::run::RunEventObservation> {
83 RunControl::from_session(self)
84 .run_event_observation(run_id, after_sequence, limit)
85 .await
86 }
87
88 pub async fn current_run(&self) -> Option<crate::run::RunHandle> {
90 RunControl::from_session(self).current_run().await
91 }
92
93 pub async fn active_tools(&self) -> Vec<crate::run::ActiveToolSnapshot> {
95 SessionView::from_session(self).active_tools().await
96 }
97
98 pub async fn subagent_task(
101 &self,
102 task_id: &str,
103 ) -> Option<crate::subagent_task_tracker::SubagentTaskSnapshot> {
104 self.subagent_tasks.get(task_id).await
105 }
106
107 pub async fn subagent_tasks(&self) -> Vec<crate::subagent_task_tracker::SubagentTaskSnapshot> {
110 self.subagent_tasks.list_for_parent(&self.session_id).await
111 }
112
113 pub async fn pending_subagent_tasks(
115 &self,
116 ) -> Vec<crate::subagent_task_tracker::SubagentTaskSnapshot> {
117 use crate::subagent_task_tracker::SubagentStatus;
118 self.subagent_tasks
119 .list_for_parent(&self.session_id)
120 .await
121 .into_iter()
122 .filter(|task| task.status == SubagentStatus::Running)
123 .collect()
124 }
125
126 pub async fn cancel_subagent_task(&self, task_id: &str) -> bool {
132 self.subagent_tasks.cancel(task_id).await
133 }
134
135 pub fn subagent_tracker(
145 &self,
146 ) -> Arc<crate::subagent_task_tracker::InMemorySubagentTaskTracker> {
147 Arc::clone(&self.subagent_tasks)
148 }
149}