rho-coding-agent 3.10.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use pretty_assertions::assert_eq;
use rho_protocol as wire;
use serde_json::{json, Value};

use super::child_options;

fn model_ref(provider: &str, model: &str) -> wire::ModelRef {
    wire::ModelRef {
        provider: provider.into(),
        model: model.into(),
    }
}

// Covers: a child's options show what it runs with, each select offering
// only its current value, since a host may not change a child's options;
// an on/off option stays a select of its one current value.
// Owner: ACP v2 child session options
#[test]
fn a_childs_selects_offer_only_their_current_value() {
    let options = wire::SessionOptions {
        model: wire::ModelOptions {
            auth: "api-key".into(),
            current: model_ref("openai", "gpt-4"),
            available: vec![
                wire::ModelChoice {
                    model: model_ref("xai", "grok-3"),
                    label: "Grok 3".into(),
                },
                wire::ModelChoice {
                    model: model_ref("openai", "gpt-4"),
                    label: "gpt-4".into(),
                },
            ],
        },
        reasoning: None,
        fast_mode: Some(wire::FastModeOptions { enabled: false }),
        permission_mode: wire::PermissionModeOptions {
            current: wire::PermissionMode::Auto,
            available: vec![wire::PermissionMode::Plan, wire::PermissionMode::Auto],
        },
        commands: Vec::new(),
        added_dirs: Vec::new(),
    };

    let update = serde_json::to_value(child_options(&options).unwrap()).unwrap();
    let offered: Vec<(Value, Value)> = update["configOptions"]
        .as_array()
        .unwrap()
        .iter()
        .map(|option| {
            let values: Vec<&Value> = option["options"]
                .as_array()
                .unwrap()
                .iter()
                .map(|choice| &choice["value"])
                .collect();
            (option["currentValue"].clone(), json!(values))
        })
        .collect();

    assert_eq!(
        (update["sessionUpdate"].clone(), offered),
        (
            json!("config_option_update"),
            vec![
                (json!("auto"), json!(["auto"])),
                (json!("openai/gpt-4"), json!(["openai/gpt-4"])),
                (json!("off"), json!(["off"])),
            ]
        )
    );
}