rho-coding-agent 3.10.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use std::{collections::BTreeMap, sync::Arc};

use pretty_assertions::assert_eq;

use super::*;

fn map(pairs: &[(&str, &str)]) -> BTreeMap<String, String> {
    pairs
        .iter()
        .map(|(name, value)| ((*name).to_owned(), (*value).to_owned()))
        .collect()
}

// Covers: a probe hides what each transport is given from its config: a
// stdio server's `env` and the variables its `env_from_env` reads, an HTTP
// server's `headers` and those its `headers_from_env` reads, never the
// other map's, and nothing for a variable the environment does not set.
// Owner: MCP probe redaction.
#[test]
fn a_probe_hides_the_values_each_transport_is_given() {
    let environment = Ambient::Client(Arc::new(map(&[
        ("STDIO_VAR", "stdio-from-env"),
        ("HTTP_VAR", "http-from-env"),
    ])));
    let cases = [
        (
            "stdio",
            McpTransport::Stdio {
                command: "server".to_owned(),
                args: Vec::new(),
                cwd: None,
                env: map(&[("LITERAL", "stdio-literal")]),
                env_from_env: map(&[("FROM", "STDIO_VAR"), ("UNSET", "NOT_SET")]),
                env_from_secret: vec!["SECRET".to_owned()],
            },
            vec!["stdio-literal", "stdio-from-env"],
        ),
        (
            "streamable http",
            McpTransport::StreamableHttp {
                url: "https://example.com/mcp".to_owned(),
                headers: map(&[("X-Literal", "http-literal")]),
                headers_from_env: map(&[("X-From", "HTTP_VAR")]),
                headers_from_secret: vec!["Authorization".to_owned()],
                oauth: None,
                allow_insecure_http: false,
            },
            vec!["http-literal", "http-from-env"],
        ),
    ];
    for (name, transport, expected) in cases {
        assert_eq!(given_values(&transport, &environment), expected, "{name}");
    }
}