rho-coding-agent 3.12.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;

fn v2_update(value: serde_json::Value) -> v2::ToolCallUpdate {
    serde_json::from_value(value).unwrap()
}

// Covers: a v2 tool call becomes what the v1 renderer and served tools take.
// The first update of an id starts the call, titled by its name when it has
// no title, with its `_meta` (where Claude names the tool); a later one
// changes it. A cancelled call fails, a paused one runs, a cleared list is
// empty, and a diff shows its patch.
// Owner: v2 tool-call boundary mapping.
#[test]
fn v2_tool_call_updates_start_then_change_their_v1_call() {
    let mut calls = ToolCalls::default();
    let cases = [
        (
            json!({"toolCallId": "a", "name": "mcp__rho__bash", "kind": "execute", "status": "pending",
                   "_meta": {"claudeCode": {"toolName": "mcp__rho__bash"}}}),
            v1::SessionUpdate::ToolCall(
                v1::ToolCall::new("a", "mcp__rho__bash")
                    .name("mcp__rho__bash".to_owned())
                    .kind(v1::ToolKind::Execute)
                    .status(v1::ToolCallStatus::Pending)
                    .meta(
                        json!({"claudeCode": {"toolName": "mcp__rho__bash"}})
                            .as_object()
                            .cloned(),
                    ),
            ),
        ),
        (
            json!({"toolCallId": "a", "status": "paused", "content": null}),
            v1::SessionUpdate::ToolCallUpdate(v1::ToolCallUpdate::new(
                "a",
                v1::ToolCallUpdateFields::new()
                    .status(v1::ToolCallStatus::InProgress)
                    .content(Vec::new()),
            )),
        ),
        (
            json!({"toolCallId": "a", "status": "cancelled"}),
            v1::SessionUpdate::ToolCallUpdate(v1::ToolCallUpdate::new(
                "a",
                v1::ToolCallUpdateFields::new().status(v1::ToolCallStatus::Failed),
            )),
        ),
        (
            json!({"toolCallId": "b", "title": "Edit a.rs", "status": "completed", "content": [{
                "type": "diff",
                "changes": [{"operation": "modify", "path": "/work/a.rs"}],
                "patch": {"format": "git_patch", "text": "@@ -1 +1 @@\n-old\n+new\n"}
            }]}),
            v1::SessionUpdate::ToolCall(
                v1::ToolCall::new("b", "Edit a.rs")
                    .status(v1::ToolCallStatus::Completed)
                    .content(vec!["```diff\n@@ -1 +1 @@\n-old\n+new\n```".into()]),
            ),
        ),
    ];
    for (update, expected) in cases {
        assert_eq!(calls.v1(&v2_update(update.clone())), expected, "{update}");
    }
}