rho-coding-agent 3.13.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
//! Protocol-level events translated into protocol-neutral run artifacts.

pub(crate) mod render;
mod served;
mod tool_cards;

use agent_client_protocol::v1::schema::{SessionUpdate, StopReason, ToolCall, ToolCallId};
use rho_protocol::{
    display::{Presentation, ToolCard},
    ToolContent,
};

/// Protocol-level vocabulary for external agents, rendered into artifact-level
/// `StreamEffect`s. ACP delivers updates over stdio; an in-process runtime such
/// as Claude may construct the same variants later. Non-ACP extras can become
/// sibling variants when needed.
#[derive(Debug)]
pub(crate) enum AgentEvent {
    /// One ACP session update, verbatim. Boxed because `SessionUpdate` dwarfs
    /// the other variants; build it with `AgentEvent::from(update)`.
    Update(Box<SessionUpdate>),
    /// A prompt turn ended; the driver owns terminal classification. `None`
    /// for an end v1 has no stop reason for, such as a v2 turn the agent
    /// ended with an error.
    TurnEnded(Option<StopReason>),
    /// Fail-soft diagnostic for drift, decoding, or unsupported events.
    Notice(String),
    /// The agent announced a call of a tool the run serves it
    /// ([`crate::acp_runtime::agent_tools`]): the served call draws its
    /// card ([`Self::Served`]), so the agent's own is held back. Boxed as
    /// [`Self::Update`] is.
    ServedToolCall(Box<ToolCall>),
    /// A served call drew `card`, on the card of the agent's tool call
    /// `call`.
    Served { call: ToolCallId, card: ServedCard },
    /// The agent's tool call `call` of a served tool draws no card: it
    /// shows on another call's, as an `await` of the stdio bridge waits on
    /// a call that drew its own.
    ServedHidden(ToolCallId),
}

/// What one served call draws, as a Rho session draws its call of the same
/// tool: its card as it starts, as it reports progress and as it ends, and
/// what it shows besides, such as the A2UI surface of a `ui` call.
#[derive(Debug)]
pub(crate) enum ServedCard {
    Started(ToolCard),
    Updated {
        card: ToolCard,
        /// Shown besides the card; nothing new when empty.
        content: Vec<ToolContent>,
    },
    Finished {
        presentation: Presentation,
        /// Shown besides the card; nothing new when empty.
        content: Vec<ToolContent>,
    },
}

impl From<SessionUpdate> for AgentEvent {
    fn from(update: SessionUpdate) -> Self {
        Self::Update(Box::new(update))
    }
}