rho-coding-agent 3.10.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
use super::Action;
use crate::browser::config::BrowserConfig;
use pretty_assertions::assert_eq;
use std::path::PathBuf;

// Covers: javascript_exec and file_upload are offered only when their own
// `[browser]` key turns them on, each independently of the other, and
// every other browser tool always is. Otherwise a session runs the model's
// JavaScript, or hands pages files, without anyone opting in.
// Owner: browser tool offer
#[test]
fn the_opt_in_tools_are_offered_only_when_config_turns_them_on() {
    let config = |javascript_exec, upload_dir: Option<&str>| BrowserConfig {
        javascript_exec,
        upload_dir: upload_dir.map(PathBuf::from),
        ..BrowserConfig::default()
    };
    let cases = [
        ("neither", config(false, None), vec![]),
        (
            "javascript",
            config(true, None),
            vec![Action::JavascriptExec],
        ),
        (
            "uploads",
            config(false, Some("/up")),
            vec![Action::FileUpload],
        ),
        (
            "both",
            config(true, Some("/up")),
            vec![Action::JavascriptExec, Action::FileUpload],
        ),
    ];
    let opt_in = [Action::JavascriptExec, Action::FileUpload];
    let always: Vec<Action> = Action::ALL
        .into_iter()
        .filter(|action| !opt_in.contains(action))
        .collect();
    for (case, config, extra) in cases {
        let expected: Vec<Action> = always.iter().copied().chain(extra).collect();
        assert_eq!(Action::offered(&config), expected, "{case}");
    }
}