MCPcopy Create free account
hub / github.com/AI45Lab/Code / dispatch_streaming

Function dispatch_streaming

core/src/agent_api/command_runtime.rs:51–69  ·  view source on GitHub ↗
(
    session: &AgentSession,
    prompt: &str,
)

Source from the content-addressed store, hash-verified

49}
50
51pub(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
71fn build_command_context(session: &AgentSession) -> CommandContext {
72 let history = read_or_recover(&session.history);

Callers 1

streamFunction · 0.85

Calls 3

build_command_contextFunction · 0.85
dispatchFunction · 0.85
send_text_outputFunction · 0.85

Tested by

no test coverage detected