rho-coding-agent 3.13.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
//! Launch seams an external runtime session may replace.

use super::CliExecutable;

/// Seams a session may replace, each unset by default.
#[derive(Default)]
pub(crate) struct CliSessionOverrides {
    /// Binary to run instead of the resolved one.
    pub(crate) executable: Option<CliExecutable>,
    /// Title generated for this run. The artifact sink reads it; the watch
    /// channel stays one-way.
    pub(crate) live_title: Option<crate::run_artifacts::LiveRunTitle>,
    /// A frozen caller can verify process facts and configure the child at the spawn boundary.
    pub(crate) before_spawn: Option<BeforeSpawn>,
    /// Hears what the run records, as it records it: set when a host
    /// follows the run live.
    pub(crate) observer: Option<Box<dyn super::status_sink::RunObserver>>,
    /// The agent's own session the run resumes, as a later turn of a
    /// session the agent runs turn by turn does, instead of starting one.
    /// The run then sends its prompt alone: the session already has the
    /// agent's instructions.
    pub(crate) resume: Option<String>,
    /// Where the run's attach journal starts, for a run whose launcher
    /// wrote its starting status: after an earlier turn's, for a later turn.
    pub(crate) journal: crate::run_artifacts::JournalStart,
    /// What that journal records for the run's prompt, for a run whose
    /// launcher wrote its starting status: the prompt, unless it is its
    /// host's own, as a turn a daemon starts on its own sends.
    pub(crate) prompt_record: crate::run_artifacts::PromptRecord,
    /// Who answers what an ACP agent asks a person: set for a run a person
    /// attends, which then advertises forms and puts asks its policy
    /// leaves to a person to them ([`crate::acp_runtime::person`]).
    pub(crate) person: Option<crate::acp_runtime::person::Person>,
    /// Text the run's first prompt carries for the agent ahead of the
    /// run's prompt, which Rho records and shows nothing of: instructions
    /// Rho gives the agent, not what the person said.
    pub(crate) preamble: Option<String>,
    /// Background results the run's first prompt carries, as a content
    /// block of their own ahead of the preamble and the prompt, which the
    /// run shows, and tells their host it delivered, once that prompt is
    /// sent: a daemon session's agent gets what its work left since its
    /// last turn this way. Taken by an ACP run only.
    pub(crate) prompt_results: Option<super::parent_messages::ParentMessage>,
    /// Rho's tools the run serves its ACP agent, when its host offers
    /// them ([`crate::acp_runtime::agent_tools`]).
    pub(crate) agent_tools: Option<std::sync::Arc<dyn crate::acp_runtime::agent_tools::AgentTools>>,
    /// What the run does with work its agent leaves running after the
    /// prompted turn, where the agent reports it (ACP v2).
    pub(crate) background_work: BackgroundWork,
    /// Who records the children the run's agent starts on its own, when
    /// its host shows them ([`crate::acp_runtime::runtime_children`]).
    pub(crate) runtime_children:
        Option<std::sync::Arc<dyn crate::acp_runtime::runtime_children::RuntimeChildren>>,
}

/// What a run does with work its agent leaves running after the prompted
/// turn, such as a Bash command or a subagent in the background.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub(crate) enum BackgroundWork {
    /// Keep the agent until the work reported, within a budget: the run's
    /// answer is the agent's report, not its placeholder.
    #[default]
    Await,
    /// End the run with the prompted turn, as a turn of a daemon session
    /// does, which the session would otherwise hold busy.
    Leave,
}

pub(crate) type BeforeSpawn =
    Box<dyn Fn(&mut tokio::process::Command) -> std::io::Result<()> + Send + Sync>;