MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / wait_for_turn_summary

Function wait_for_turn_summary

src/sessions/codex_app_server.rs:309–343  ·  view source on GitHub ↗
(
    line_rx: &mpsc::Receiver<std::io::Result<String>>,
    deadline: Instant,
)

Source from the content-addressed store, hash-verified

307}
308
309fn wait_for_turn_summary(
310 line_rx: &mpsc::Receiver<std::io::Result<String>>,
311 deadline: Instant,
312) -> Result<CodexAppServerSummary> {
313 let mut text = String::new();
314 let mut model = None;
315 loop {
316 let line = recv_line(line_rx, deadline)?;
317 let value: Value = serde_json::from_str(&line)?;
318 if model.is_none() {
319 model = find_model_id(&value);
320 }
321 if let Some(error) = value.get("error") {
322 return Err(TraceDecayError::Config {
323 message: format!("codex app-server turn failed: {error}"),
324 });
325 }
326 match value.get("method").and_then(Value::as_str) {
327 Some("item/agentMessage/delta") => {
328 if let Some(delta) = value.pointer("/params/delta").and_then(Value::as_str) {
329 text.push_str(delta);
330 }
331 }
332 Some("item/completed") if text.trim().is_empty() => {
333 if let Some(item_text) = collect_item_text(value.get("params")) {
334 text.push_str(&item_text);
335 }
336 }
337 Some("turn/completed") => {
338 return Ok(CodexAppServerSummary { text, model });
339 }
340 _ => {}
341 }
342 }
343}
344
345fn recv_line(
346 line_rx: &mpsc::Receiver<std::io::Result<String>>,

Calls 4

recv_lineFunction · 0.85
find_model_idFunction · 0.85
collect_item_textFunction · 0.85
is_emptyMethod · 0.45