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(rpc): add HTTP host configuration and CLI support
Steven Enamakele044b06726eb
diff --git a/crates/openhuman-rpc/Cargo.toml b/crates/openhuman-rpc/Cargo.tomlindex 19b6a9d9f9..c3cc2802e9 100644--- a/crates/openhuman-rpc/Cargo.toml+++ b/crates/openhuman-rpc/Cargo.toml@@ -28,6 +28,10 @@ server = ["dep:anyhow","dep:once_cell","dep:tinyinference-core",+ "dep:base64",+ "dep:rand",+ "dep:uuid",+ "dep:urlencoding",]# Forwarded so the server's Sentry-routing tests run against a core that# reports to Sentry.@@ -50,6 +54,10 @@ tracing = { version = "0.1", default-features = false, optional = true }chrono = { version = "0.4", features = ["serde"], optional = true }anyhow = { version = "1.0", optional = true }once_cell = { version = "1.19", optional = true }+base64 = { version = "0.22", optional = true }+rand = { version = "0.10", optional = true }+uuid = { version = "1", features = ["v4"], optional = true }+urlencoding = { version = "2.1", optional = true }tinyinference-core = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-core", optional = true }[dev-dependencies]diff --git a/crates/openhuman-rpc/src/http_host/mod.rs b/crates/openhuman-rpc/src/http_host/mod.rsindex 3e6c80fe82..3ef70e82aa 100644--- a/crates/openhuman-rpc/src/http_host/mod.rs+++ b/crates/openhuman-rpc/src/http_host/mod.rs@@ -1,10 +1,14 @@-//! Static directory hosting over ad-hoc HTTP listeners owned by the core.+//! Static directory hosting over ad-hoc HTTP listeners.//!//! This domain lets trusted callers start, inspect, list, and stop lightweight//! file servers that expose a chosen directory on a chosen TCP port. Each//! server runs in-process, shares the core's lifetime, and defaults to HTTP//! Basic authentication using the active user's identity plus a generated//! password.+//!+//! The domain is HTTP transport, so it lives with the JSON-RPC server rather+//! than in the core. Its controllers join the core's registry as an extension+//! ([`register_controllers`]), which the server entry points install.mod auth;mod handlers;@@ -23,3 +27,33 @@ pub use schemas::{};pub(crate) const LOG_PREFIX: &str = "[http_host]";++use openhuman_core::core::all::{register_controller_extension, ControllerExtension, DomainGroup};++const NAMESPACES: &[(&str, &str)] = &[(+ "http_host",+ "Serve a local directory over an ad-hoc, Basic-auth-protected HTTP listener.",+)];++/// Registers the `http_host.*` controllers with the core's registry.+///+/// Idempotent: the core treats an identical re-registration as a no-op, so+/// every server entry point may call it. Kernel surface with no family of its+/// own, so it is gated as [`DomainGroup::Platform`].+pub fn register_controllers() -> Result<(), String> {+ log::debug!("{LOG_PREFIX} registering controller extension");+ register_controller_extension(ControllerExtension {+ group: DomainGroup::Platform,+ controllers: all_http_host_registered_controllers(),+ namespaces: NAMESPACES,+ })+}++/// [`register_controllers`] for call sites that cannot propagate an error:+/// a failure means a namespace collision in the registry, which is a build+/// bug, so it is logged loudly rather than aborting the server.+pub(crate) fn ensure_registered() {+ if let Err(error) = register_controllers() {+ log::error!("{LOG_PREFIX} controller registration failed: {error}");+ }+}diff --git a/crates/openhuman-rpc/src/lib.rs b/crates/openhuman-rpc/src/lib.rsindex f102023920..fb3a96ef20 100644--- a/crates/openhuman-rpc/src/lib.rs+++ b/crates/openhuman-rpc/src/lib.rs@@ -14,13 +14,17 @@//! - Behind `http-client`: [`post_json_rpc`], [`bearer_header`],//! [`redact_url_for_log`] and [`HttpRpcResponse`].//! - Behind `server`: [`server`], the core's HTTP router, Socket.IO transport-//! and listener, plus the `run_server*` entry points hosts call.+//! and listener, plus the `run_server*` entry points hosts call; and+//! [`http_host`], the static-directory file server whose `http_host.*`+//! controllers the server registers with the core.#[cfg(feature = "http-client")]mod client;mod envelope;mod origin;#[cfg(feature = "server")]+pub mod http_host;+#[cfg(feature = "server")]pub mod server;#[cfg(feature = "http-client")]diff --git a/crates/openhuman-rpc/src/server/cli.rs b/crates/openhuman-rpc/src/server/cli.rsindex 6c33395773..fb38cc6595 100644--- a/crates/openhuman-rpc/src/server/cli.rs+++ b/crates/openhuman-rpc/src/server/cli.rs@@ -10,6 +10,7 @@ use openhuman_core::core::server_launcher::{install_server_launcher, ServeReques/// [`run_core_from_args`](openhuman_core::run_core_from_args); later calls are/// no-ops.pub fn install_cli_server() {+ crate::http_host::ensure_registered();install_server_launcher(launch);}diff --git a/crates/openhuman-rpc/src/server/http/mod.rs b/crates/openhuman-rpc/src/server/http/mod.rsindex f32deef0ee..75cedca509 100644--- a/crates/openhuman-rpc/src/server/http/mod.rs+++ b/crates/openhuman-rpc/src/server/http/mod.rs@@ -42,6 +42,7 @@ const MAX_RPC_BODY_BYTES: usize = 64 * 1024 * 1024;/// 2. `rpc_auth_middleware` — validates `Authorization: Bearer <token>` on protected paths/// 3. `http_request_log_middleware` — logs non-RPC HTTP requests with timingpub fn build_core_http_router(socketio_enabled: bool) -> Router {+ crate::http_host::ensure_registered();let router = Router::new().route("/", get(root_handler)).route("/health", get(health::health_handler))