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(core): let hosts pass a boot description through the CLI
Steven Enamakeldeaf36d13c47
diff --git a/crates/openhuman-core/src/core/cli.rs b/crates/openhuman-core/src/core/cli.rsindex c82b16aa07..a302b96658 100644--- a/crates/openhuman-core/src/core/cli.rs+++ b/crates/openhuman-core/src/core/cli.rs@@ -44,6 +44,15 @@ Contribute & Star us on GitHub: https://github.com/tinyhumansai/openhuman/// Returns an error if the command fails, parameters are invalid, or if/// the subcommand/namespace is unknown.pub fn run_from_cli_args(args: &[String]) -> Result<()> {+ run_from_cli_args_with(args, None)+}++/// [`run_from_cli_args`] with a host-supplied boot description for `run` /+/// `serve`; see [`crate::run_core_from_args_with`].+pub fn run_from_cli_args_with(+ args: &[String],+ host_boot: Option<crate::core::server_launcher::HostBoot>,+) -> Result<()> {load_dotenv_for_cli()?;let launch = parse_launch_options(args)?;@@ -69,7 +78,7 @@ pub fn run_from_cli_args(args: &[String]) -> Result<()> {// Match on the first argument to determine the subcommand.match args[0].as_str() {- "run" | "serve" => run_server_command(&args[1..]),+ "run" | "serve" => run_server_command(&args[1..], host_boot),"mcp" | "mcp-server" => crate::mcp::server::run_stdio_from_cli(&args[1..]),// Keep the historical names as a migration diagnostic now that the// terminal frontend is its own workspace crate and executable.diff --git a/crates/openhuman-core/src/core/server_launcher.rs b/crates/openhuman-core/src/core/server_launcher.rsindex 4451961083..f92df138da 100644--- a/crates/openhuman-core/src/core/server_launcher.rs+++ b/crates/openhuman-core/src/core/server_launcher.rs@@ -7,11 +7,65 @@//! Without one, `run` / `serve` fail with an error that says so instead of//! starting a core nothing can reach.+use std::any::Any;use std::future::Future;use std::pin::Pin;-use std::sync::OnceLock;+use std::sync::{Arc, Mutex, OnceLock};++/// An opaque, host-owned boot description handed through the CLI to the+/// installed [`ServerLauncher`].+///+/// The CLI never boots a core itself: `run` / `serve` start whatever the+/// launcher builds, and the launcher lives in a layer above this crate. So a+/// host that wants its own configured builder (domains, services, token,+/// listener, host kind) to be what the CLI boots with wraps it here, passes it+/// to [`run_core_from_args_with`](crate::run_core_from_args_with), and its+/// launcher takes it back out with [`HostBoot::take`]. The core only carries+/// it; it never looks inside.+#[derive(Clone)]+pub struct HostBoot(Arc<Mutex<Option<Box<dyn Any + Send>>>>);++impl HostBoot {+ /// Wrap `value` for the launcher to take.+ pub fn new<T: Any + Send>(value: T) -> Self {+ Self(Arc::new(Mutex::new(Some(Box::new(value)))))+ }++ /// Take the wrapped value out, once. `None` if it was already taken or is+ /// not a `T` (a mismatched type is left in place).+ pub fn take<T: Any + Send>(&self) -> Option<T> {+ let mut slot = self.0.lock().unwrap_or_else(|e| e.into_inner());+ match slot.take()?.downcast::<T>() {+ Ok(value) => Some(*value),+ Err(other) => {+ *slot = Some(other);+ None+ }+ }+ }+}++impl std::fmt::Debug for HostBoot {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.write_str("HostBoot(..)")+ }+}++impl PartialEq for HostBoot {+ fn eq(&self, other: &Self) -> bool {+ Arc::ptr_eq(&self.0, &other.0)+ }+}++impl Eq for HostBoot {}/// What the `run` / `serve` subcommand asked for.+///+/// Precedence: a field the operator set explicitly on the command line+/// (`host`, `port`, `--jsonrpc-only`, `--headless-api`, `--mode`) wins over+/// the host's [`host_boot`](Self::host_boot) builder, which in turn wins over+/// the launcher's own preset. Unset flags (`None`, or the `socketio_enabled`+/// default) leave the builder's value alone.#[derive(Debug, Clone, PartialEq, Eq)]pub struct ServeRequest {/// Bind host, when the operator passed one.@@ -26,6 +80,9 @@ pub struct ServeRequest {pub mode: crate::core::runtime::Mode,/// The operator's SaaS config file (`--saas-config`); required in SaaS mode.pub saas_config: Option<std::path::PathBuf>,+ /// The host's pre-configured builder, when it passed one to+ /// [`run_core_from_args_with`](crate::run_core_from_args_with).+ pub host_boot: Option<HostBoot>,}/// `openhuman-core run --help`.diff --git a/crates/openhuman-core/src/lib.rs b/crates/openhuman-core/src/lib.rsindex 29631b80c1..c0b4c99566 100644--- a/crates/openhuman-core/src/lib.rs+++ b/crates/openhuman-core/src/lib.rs@@ -114,6 +114,23 @@ pub use core::types::HostKind;////// Returns an error if command execution fails.pub fn run_core_from_args(args: &[String]) -> anyhow::Result<()> {+ run_core_from_args_with(args, None)+}++/// [`run_core_from_args`] with a host-supplied boot description.+///+/// `host_boot` rides on the `run` / `serve` [`ServeRequest`] to the installed+/// server launcher, which boots from it instead of its own default preset.+/// Explicit command-line flags still apply on top of it; see [`ServeRequest`]+/// for the precedence. Subcommands that do not start a server ignore it.+///+/// # Errors+///+/// Returns an error if command execution fails.+pub fn run_core_from_args_with(+ args: &[String],+ host_boot: Option<core::server_launcher::HostBoot>,+) -> anyhow::Result<()> {core::cli::load_dotenv_for_cli()?;platform::service::apply_startup_restart_delay_from_env();// A SaaS boot roots the keyring under its operator directory@@ -121,5 +138,5 @@ pub fn run_core_from_args(args: &[String]) -> anyhow::Result<()> {if !core::runtime::mode::requested_in(args, std::env::var("OPENHUMAN_MODE").ok().as_deref()) {security::keyring::init_master_key().map_err(anyhow::Error::msg)?;}- core::cli::run_from_cli_args(args)+ core::cli::run_from_cli_args_with(args, host_boot)}