rho-coding-agent 3.7.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
//! Rho's v1 `elicitation/create` in ACP v2 form, and the host's v2 answer
//! in the v1 form Rho reads.
//!
//! The two versions share the request's shape apart from what v2 removed
//! or tightened, which v2's own types already enforce, so the request is
//! built through them:
//!
//! - A string property's `pattern` is gone; the v2 property types drop it.
//! - The scope is strict: a request-scoped form names no `sessionId` or
//!   `toolCallId`, not even as `null`; the v2 types serialize only the keys
//!   of the one scope they hold.
//!
//! An `action` the host answers with that v2 doesn't define is handled as
//! `cancel`, as v2 requires; v1 would read it as a decline.

use agent_client_protocol::Error as AcpError;
use agent_client_protocol::{v1::schema as v1, v2::schema as v2};

use super::bridge;

pub(super) fn request(
    request: &v1::CreateElicitationRequest,
) -> Result<v2::CreateElicitationRequest, AcpError> {
    bridge(request)
}

pub(super) fn response(
    response: v2::CreateElicitationResponse,
) -> Result<v1::CreateElicitationResponse, AcpError> {
    let action = match response.action {
        v2::ElicitationAction::Accept(accept) => v1::ElicitationAction::Accept(bridge(&accept)?),
        v2::ElicitationAction::Decline => v1::ElicitationAction::Decline,
        v2::ElicitationAction::Cancel => v1::ElicitationAction::Cancel,
        // A custom or future action.
        _ => v1::ElicitationAction::Cancel,
    };
    Ok(v1::CreateElicitationResponse::new(action).meta(response.meta))
}

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