(
session: &AgentSession,
prompt: &str,
)
| 49 | } |
| 50 | |
| 51 | pub(super) async fn dispatch_streaming( |
| 52 | session: &AgentSession, |
| 53 | prompt: &str, |
| 54 | ) -> Option<(mpsc::Receiver<AgentEvent>, JoinHandle<()>)> { |
| 55 | if !CommandRegistry::is_command(prompt) { |
| 56 | return None; |
| 57 | } |
| 58 | |
| 59 | let ctx = build_command_context(session); |
| 60 | let output = session_commands::dispatch(session, prompt, &ctx)?; |
| 61 | let (tx, rx) = mpsc::channel(256); |
| 62 | |
| 63 | let text = output.text; |
| 64 | let handle = tokio::spawn(async move { |
| 65 | send_text_output(&tx, text).await; |
| 66 | }); |
| 67 | |
| 68 | Some((rx, handle)) |
| 69 | } |
| 70 | |
| 71 | fn build_command_context(session: &AgentSession) -> CommandContext { |
| 72 | let history = read_or_recover(&session.history); |
no test coverage detected