Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-embed/src/runtime/run.rs,crates/openhuman-rpc/src/host.rs,crat

Steven Enamakel186c562cb3ca
diff --git a/crates/openhuman-embed/src/runtime/run.rs b/crates/openhuman-embed/src/runtime/run.rs
index 6da99821b6..2b58f85959 100644
--- a/crates/openhuman-embed/src/runtime/run.rs
+++ b/crates/openhuman-embed/src/runtime/run.rs
@@ -144,7 +144,9 @@ impl RuntimeBuilder {
impl CliGlobals {
/// Install every global; returns the storage backend, when one was
/// configured, now opened.
- fn install(mut self) -> Result<Option<Arc<dyn openhuman_core::storage::StorageBackend>>, String> {
+ fn install(
+ mut self,
+ ) -> Result<Option<Arc<dyn openhuman_core::storage::StorageBackend>>, String> {
if let Some(transport) = self.transport {
openhuman_core::backend::install_backend_transport(transport);
log::debug!("[embed][cli] backend transport installed (process global)");
diff --git a/crates/openhuman-rpc/src/host.rs b/crates/openhuman-rpc/src/host.rs
index a48e035155..f7bcfe3c14 100644
--- a/crates/openhuman-rpc/src/host.rs
+++ b/crates/openhuman-rpc/src/host.rs
@@ -70,11 +70,16 @@ pub fn cli(args: &[String]) -> anyhow::Result<()> {
args.len()
);
let mut builder = cli_builder();
- if cli_command_uses_storage(args) {
+ if cli_command_uses_storage(args, |namespace| {
+ crate::core_host::core::all::cli_handler_for_namespace(namespace).is_some()
+ }) {
// 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}");
+ log::warn!(
+ "[rpc:host] cli: early dotenv load failed ({error}); a storage url set only \
+ in that file will not be seen"
+ );
}
// A one-shot command reads the same backend the server would: the
// configured storage URL, opened on the core's storage runtime so the
@@ -91,36 +96,53 @@ pub fn cli(args: &[String]) -> anyhow::Result<()> {
}
/// Whether the CLI subcommand in `args` should open the configured storage
-/// backend itself. `run` / `serve` open it in their own server boot, and help,
-/// the moved TUI names and `sentry-test` never touch stored state.
+/// backend itself, following the dispatcher's own grammar
+/// (`core::cli::parse_launch_options` then the subcommand match): only the
+/// model/provider launch flags precede the command, and the first other token
+/// is the command. `run` / `serve` open storage in their own server boot;
+/// help, the moved TUI names and `sentry-test` never touch stored state; a
+/// bare namespace only prints help unless it has a domain CLI handler
+/// (`has_cli_handler`, e.g. `voice`), which runs. `help` counts only where
+/// the dispatcher reads it (the command, the function slot, or a `-h` /
+/// `--help` flag), never as an option value.
#[cfg(feature = "server")]
-fn cli_command_uses_storage(args: &[String]) -> bool {
+fn cli_command_uses_storage(args: &[String], has_cli_handler: impl Fn(&str) -> bool) -> bool {
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() {
+ let mut rest = args.iter().map(String::as_str).peekable();
+ while let Some(arg) = rest.peek().copied() {
match arg {
- // Launch-wide flags with a separate value.
"--model" | "--model-id" | "-m" | "--provider" | "--provider-id" | "-p" => {
rest.next();
+ rest.next();
}
_ if arg.starts_with("--model=")
|| arg.starts_with("--model-id=")
|| arg.starts_with("--provider=")
- || arg.starts_with("--provider-id=") => {}
- _ if arg.starts_with('-') => {}
- _ => positional.push(arg),
+ || arg.starts_with("--provider-id=") =>
+ {
+ rest.next();
+ }
+ _ => break,
}
}
- 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,
+ let Some(command) = rest.next() else {
+ return false;
+ };
+ if is_help(command) {
+ return false;
+ }
+ match command {
+ "run" | "serve" | "tui" | "chat" | "sentry-test" => false,
+ "mcp" | "mcp-server" | "call" | "agent" => true,
+ namespace => {
+ let tail: Vec<&str> = rest.collect();
+ match tail.as_slice() {
+ [] => has_cli_handler(namespace),
+ [function, ..] if is_help(function) => false,
+ [_, flag, ..] if is_help(flag) => false,
+ _ => true,
+ }
+ }
}
}
diff --git a/crates/openhuman-rpc/src/host_tests.rs b/crates/openhuman-rpc/src/host_tests.rs
index 77342e9514..d2f6ec3c03 100644
--- a/crates/openhuman-rpc/src/host_tests.rs
+++ b/crates/openhuman-rpc/src/host_tests.rs
@@ -98,27 +98,26 @@ fn tui_builder_runs_every_domain_without_services_on_the_disk_store() {
#[cfg(feature = "server")]
fn cli_storage_is_opened_for_one_shot_commands_only() {
let args = |parts: &[&str]| parts.iter().map(|p| p.to_string()).collect::<Vec<_>>();
- assert!(cli_command_uses_storage(&args(&["agent", "list"])));
- assert!(cli_command_uses_storage(&args(&["cron", "list"])));
- assert!(cli_command_uses_storage(&args(&[
- "--model",
- "x",
- "approvals",
- "list"
- ])));
- assert!(!cli_command_uses_storage(&args(&["serve"])));
- assert!(!cli_command_uses_storage(&args(&[
- "--provider=a",
- "-m",
- "b",
- "run"
- ])));
- 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"
- ])));
+ let uses = |parts: &[&str]| cli_command_uses_storage(&args(parts), |ns| ns == "voice");
+ assert!(uses(&["agent", "list"]));
+ assert!(uses(&["cron", "list"]));
+ assert!(uses(&["--model", "x", "approvals", "list"]));
+ assert!(uses(&["--model=x", "-p", "y", "cron", "list"]));
+ // Bare `voice` has a domain CLI handler, so it runs and needs storage;
+ // other bare namespaces only print help.
+ assert!(uses(&["voice"]));
+ assert!(uses(&["voice", "--skip-cleanup"]));
+ assert!(!uses(&["cron"]));
+ assert!(!uses(&["serve"]));
+ assert!(!uses(&["--provider=a", "-m", "b", "run"]));
+ assert!(!uses(&[]));
+ assert!(!uses(&["--help"]));
+ assert!(!uses(&["help"]));
+ assert!(!uses(&["cron", "--help"]));
+ assert!(!uses(&["cron", "help"]));
+ assert!(!uses(&["cron", "list", "-h"]));
+ assert!(!uses(&["cron", "list", "--help"]));
+ // `help` as an option value is not a help request.
+ assert!(uses(&["cron", "add", "--name", "help"]));
+ assert!(uses(&["--model", "help", "cron", "list"]));
}