rho-coding-agent 3.13.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use super::*;
use pretty_assertions::assert_eq;
use serde_json::json;

// Covers: a v2 permission ask, as claude-agent-acp 0.114.0 sent one for a
// Write in default mode (attended wire check), becomes the v1 ask the
// policy and the person decide: its tool call, titled by the ask's own
// title, and its options. An ask about no tool call has no v1 form.
// Owner: v2 ask boundary mapping.
#[test]
fn a_v2_permission_ask_becomes_the_v1_ask_about_its_tool_call() {
    let wire: v2::RequestPermissionRequest = serde_json::from_value(json!({
        "sessionId": "s", "title": "Write probe.txt",
        "subject": {"type": "tool_call", "toolCall": {
            "toolCallId": "toolu_1", "name": "Write", "title": "Write probe.txt", "kind": "edit",
            "rawInput": {"file_path": "/work/probe.txt", "content": "hi\n"},
            "locations": [{"path": "/work/probe.txt"}]
        }},
        "options": [
            {"optionId": "allow-once", "name": "Yes", "kind": "allow_once"},
            {"optionId": "allow-with-updates", "name": "Yes, allow all edits during this session", "kind": "allow_always"},
            {"optionId": "reject", "name": "No", "kind": "reject_once"}
        ]
    }))
    .unwrap();
    let expected = v1::RequestPermissionRequest::new(
        "s",
        v1::ToolCallUpdate::new(
            "toolu_1",
            v1::ToolCallUpdateFields::new()
                .name("Write".to_owned())
                .title("Write probe.txt".to_owned())
                .kind(v1::ToolKind::Edit)
                .raw_input(json!({"file_path": "/work/probe.txt", "content": "hi\n"}))
                .locations(vec![v1::ToolCallLocation::new("/work/probe.txt")]),
        ),
        vec![
            v1::PermissionOption::new("allow-once", "Yes", v1::PermissionOptionKind::AllowOnce),
            v1::PermissionOption::new(
                "allow-with-updates",
                "Yes, allow all edits during this session",
                v1::PermissionOptionKind::AllowAlways,
            ),
            v1::PermissionOption::new("reject", "No", v1::PermissionOptionKind::RejectOnce),
        ],
    );
    assert_eq!(v1_permission(&wire), Some(expected));

    let mut no_subject = wire;
    no_subject.subject = None;
    assert_eq!(v1_permission(&no_subject), None);
}