rho-coding-agent 3.11.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
//! Finding the deferred tool output a client asks for
//! (`rho/session/tool_output`) in a feed: its buffered live events first,
//! which hold what only live events show, such as a `diff`'s whole files,
//! newest first, by the refs each kept when pushed, or worked out by the
//! first search for one pushed while no client deferred, then its saved
//! transcript, which the lock is not held for.

use super::Feed;
use crate::app::session_events::{Deferrables, NewestTurns, Wanted};

impl Feed {
    /// Takes the wanted items the buffered events carry, and the
    /// transcript's turns to search after; `None` when the session defers
    /// nothing, as one an agent runtime runs, which holds no item a client
    /// could ask for.
    pub(in crate::app::daemon_host::sessions) fn find_tool_output(
        &self,
        wanted: &mut Wanted,
    ) -> Option<NewestTurns> {
        let mut state = self.state();
        if !state.defers() {
            return None;
        }
        for buffered in state.buffer.iter_mut().rev() {
            if wanted.complete() {
                break;
            }
            // Pushed while no client deferred: worked out once, now.
            let deferrables = buffered
                .deferrables
                .get_or_insert_with(|| Deferrables::of(&buffered.event.event));
            wanted.find_listed(&buffered.event.event, deferrables);
        }
        Some(state.transcript.newest_turns())
    }
}

#[cfg(test)]
#[path = "feed_tool_output_tests.rs"]
mod tests;