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
feat(tui): add --provider and --model flags for transient inference overrides
Steven Enamakel97fde3f0387a
diff --git a/crates/openhuman-core/src/core/cli.rs b/crates/openhuman-core/src/core/cli.rsindex 8e29d9aed1..e97f1fe65a 100644--- a/crates/openhuman-core/src/core/cli.rs+++ b/crates/openhuman-core/src/core/cli.rs@@ -96,6 +96,16 @@ pub fn run_from_cli_args(args: &[String]) -> Result<()> {}}+/// Apply process-local provider/model overrides for a standalone frontend.+///+/// The values affect config loaded later in this process and are never written+/// back to the user's config file. This keeps independently packaged frontends+/// such as `openhuman-tui` compatible with the core CLI's launch flags.+#[doc(hidden)]+pub fn set_transient_inference_overrides(provider: Option<&str>, model: Option<&str>) {+ crate::openhuman::config::set_cli_inference_overrides(provider, model);+}+#[derive(Debug, Default, PartialEq, Eq)]struct CliLaunchOptions {args: Vec<String>,diff --git a/crates/openhuman-tui/src/runner.rs b/crates/openhuman-tui/src/runner.rsindex 0a7b093dcb..c30939a246 100644--- a/crates/openhuman-tui/src/runner.rs+++ b/crates/openhuman-tui/src/runner.rs@@ -22,6 +22,7 @@ use openhuman_core::core::types::HostKind;/// * `--new` — force a brand-new thread (default when `--thread` is absent)./// * `--last` / `--resume` — resume the newest thread, optionally opening the picker./// * `--no-alt-screen` — render in the current terminal buffer.+/// * `--provider <id>` / `--model <id>` — transient inference overrides./// * a positional prompt — send immediately after startup./// * `-v` / `--verbose` — debug-level file logging.pub fn run_from_cli(args: &[String]) -> anyhow::Result<()> {@@ -35,6 +36,8 @@ pub fn run_from_cli(args: &[String]) -> anyhow::Result<()> {let mut resume_picker = false;let mut use_last = false;let mut no_alt_screen = false;+ let mut provider: Option<String> = None;+ let mut model: Option<String> = None;let mut prompt_parts = Vec::new();let mut i = 0usize;@@ -64,6 +67,22 @@ pub fn run_from_cli(args: &[String]) -> anyhow::Result<()> {no_alt_screen = true;i += 1;}+ "--provider" | "--provider-id" | "-p" => {+ provider = Some(option_value(args, i, args[i].as_str())?);+ i += 2;+ }+ "--model" | "--model-id" | "-m" => {+ model = Some(option_value(args, i, args[i].as_str())?);+ i += 2;+ }+ arg if arg.starts_with("--provider=") || arg.starts_with("--provider-id=") => {+ provider = Some(inline_option_value(arg)?);+ i += 1;+ }+ arg if arg.starts_with("--model=") || arg.starts_with("--model-id=") => {+ model = Some(inline_option_value(arg)?);+ i += 1;+ }"-v" | "--verbose" => {verbose = true;i += 1;@@ -82,6 +101,11 @@ pub fn run_from_cli(args: &[String]) -> anyhow::Result<()> {}}+ openhuman_core::core::cli::set_transient_inference_overrides(+ provider.as_deref(),+ model.as_deref(),+ );+// File-only logging — never stderr while the TUI owns the terminal.let data_dir = resolve_data_dir();let log_dir = openhuman_core::core::logging::init_for_tui(&data_dir, verbose);@@ -113,6 +137,29 @@ pub fn run_from_cli(args: &[String]) -> anyhow::Result<()> {))}+fn option_value(args: &[String], index: usize, flag: &str) -> anyhow::Result<String> {+ let value = args+ .get(index + 1)+ .filter(|value| !value.starts_with('-'))+ .ok_or_else(|| anyhow::anyhow!("missing value for {flag}"))?;+ nonempty_option_value(value, flag)+}++fn inline_option_value(arg: &str) -> anyhow::Result<String> {+ let (flag, value) = arg+ .split_once('=')+ .ok_or_else(|| anyhow::anyhow!("missing value for {arg}"))?;+ nonempty_option_value(value, flag)+}++fn nonempty_option_value(value: &str, flag: &str) -> anyhow::Result<String> {+ let value = value.trim();+ if value.is_empty() {+ return Err(anyhow::anyhow!("empty value for {flag}"));+ }+ Ok(value.to_string())+}+async fn async_main(thread_flag: Option<String>,force_new: bool,@@ -229,6 +276,8 @@ fn print_help() {println!(" --resume Open the saved-thread picker (starts on the latest thread).");println!(" --last Resume the most recent thread.");println!(" --no-alt-screen Draw in the current terminal buffer.");+ println!(" -p, --provider <id> Override the provider for this TUI session.");+ println!(" -m, --model <id> Override the model for this TUI session.");println!(" -v, --verbose Debug-level logging (written to the log file, never the UI).");println!();println!("Keys: Ctrl+Tab or Alt+1-4 switch tabs · Enter send · Shift+Enter newline ·");diff --git a/crates/openhuman-tui/tests/cli_e2e.rs b/crates/openhuman-tui/tests/cli_e2e.rsindex 1c4e6e443f..a53f3e0b02 100644--- a/crates/openhuman-tui/tests/cli_e2e.rs+++ b/crates/openhuman-tui/tests/cli_e2e.rs@@ -23,6 +23,8 @@ fn tui_help_advertises_cockpit_launch_and_navigation_controls() {"--resume","--last","--no-alt-screen",+ "--provider",+ "--model","Shift+Enter newline","/ opens commands",] {@@ -33,6 +35,29 @@ fn tui_help_advertises_cockpit_launch_and_navigation_controls() {}}+#[test]+fn inference_override_flags_are_parsed_before_starting_the_core() {+ let output = run(&[+ "--provider",+ "ollama",+ "--model=qwen3:8b",+ "--definitely-unknown",+ ]);+ assert!(!output.status.success());+ let stderr = String::from_utf8_lossy(&output.stderr);+ assert!(stderr.contains("unknown tui arg: --definitely-unknown"), "{stderr}");+ assert!(!stderr.contains("unknown tui arg: --provider"), "{stderr}");+}++#[test]+fn inference_override_flags_require_values() {+ let output = run(&["--provider", "--help"]);+ assert!(!output.status.success());+ assert!(+ String::from_utf8_lossy(&output.stderr).contains("missing value for --provider")+ );+}+#[test]fn unknown_flags_are_rejected_before_starting_the_core() {let output = run(&["--definitely-unknown"]);