The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(rpc): detect help flags anywhere in cli args
Steven Enamakelb54d1f5fbda7
diff --git a/crates/openhuman-rpc/src/host.rs b/crates/openhuman-rpc/src/host.rsindex 631b0b53f8..a48e035155 100644--- a/crates/openhuman-rpc/src/host.rs+++ b/crates/openhuman-rpc/src/host.rs@@ -71,6 +71,11 @@ pub fn cli(args: &[String]) -> anyhow::Result<()> {);let mut builder = cli_builder();if cli_command_uses_storage(args) {+ // The preflight reads the URL before the dispatcher loads `.env`+ // itself, so a URL supplied through the dotenv file must be loaded now.+ if let Err(error) = crate::core_host::core::cli::load_dotenv_for_cli() {+ log::debug!("[rpc:host] cli: early dotenv load failed: {error}");+ }// A one-shot command reads the same backend the server would: the// configured storage URL, opened on the core's storage runtime so the// backend outlives this call. No URL leaves the classic layout alone.@@ -90,28 +95,33 @@ pub fn cli(args: &[String]) -> anyhow::Result<()> {/// the moved TUI names and `sentry-test` never touch stored state.#[cfg(feature = "server")]fn cli_command_uses_storage(args: &[String]) -> bool {- let mut args = args.iter().map(String::as_str);- let mut command = None;- while let Some(arg) = args.next() {+ let is_help = |arg: &str| matches!(arg, "-h" | "--help" | "help");+ // Help is answered before any command runs, wherever it appears.+ if args.iter().any(|arg| is_help(arg)) {+ return false;+ }+ let mut rest = args.iter().map(String::as_str);+ let mut positional = Vec::new();+ while let Some(arg) = rest.next() {match arg {// Launch-wide flags with a separate value."--model" | "--model-id" | "-m" | "--provider" | "--provider-id" | "-p" => {- args.next();+ rest.next();}_ if arg.starts_with("--model=")|| arg.starts_with("--model-id=")|| arg.starts_with("--provider=")|| arg.starts_with("--provider-id=") => {}- _ => {- command = Some(arg);- break;- }+ _ if arg.starts_with('-') => {}+ _ => positional.push(arg),}}- !matches!(- command,- None | Some("run" | "serve" | "help" | "-h" | "--help" | "tui" | "chat" | "sentry-test")- )+ match positional.as_slice() {+ [] | ["run" | "serve" | "tui" | "chat" | "sentry-test", ..] => false,+ // A bare namespace prints its help instead of running a function.+ [namespace] => matches!(*namespace, "mcp" | "mcp-server"),+ _ => true,+ }}/// What the embedded desktop server binds and how it authenticates.diff --git a/crates/openhuman-rpc/src/host_tests.rs b/crates/openhuman-rpc/src/host_tests.rsindex f42d3fe37a..77342e9514 100644--- a/crates/openhuman-rpc/src/host_tests.rs+++ b/crates/openhuman-rpc/src/host_tests.rs@@ -115,4 +115,10 @@ fn cli_storage_is_opened_for_one_shot_commands_only() {])));assert!(!cli_command_uses_storage(&args(&[])));assert!(!cli_command_uses_storage(&args(&["--help"])));+ assert!(!cli_command_uses_storage(&args(&["cron", "--help"])));+ assert!(!cli_command_uses_storage(&args(&["cron", "list", "-h"])));+ assert!(!cli_command_uses_storage(&args(&["cron"])));+ assert!(!cli_command_uses_storage(&args(&[+ "--config", "p", "--help"+ ])));}diff --git a/tests/cli_storage_url_e2e.rs b/tests/cli_storage_url_e2e.rsindex 6979314c20..f07825cb3d 100644--- a/tests/cli_storage_url_e2e.rs+++ b/tests/cli_storage_url_e2e.rs@@ -31,6 +31,7 @@ fn a_one_shot_command_refuses_a_storage_url_it_cannot_open() {fn a_one_shot_command_opens_a_valid_storage_url_and_help_does_not_need_one() {let tmp = tempfile::tempdir().unwrap();let output = core(tmp.path(), Some("memory"), &["cron", "list"]);+ assert!(output.status.success(), "a valid URL must open the backend");let stderr = String::from_utf8_lossy(&output.stderr);assert!(!stderr.contains("opening the configured storage backend"),@@ -39,4 +40,10 @@ fn a_one_shot_command_opens_a_valid_storage_url_and_help_does_not_need_one() {// Help never opens the backend, even a bad one.let help = core(tmp.path(), Some("nonsense://nowhere"), &["--help"]);assert!(help.status.success());+ let nested = core(+ tmp.path(),+ Some("nonsense://nowhere"),+ &["cron", "list", "--help"],+ );+ assert!(nested.status.success(), "nested help never opens storage");}