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
refactor(runtime): extract transport from CoreRuntime::serve into openhuman-rpc
Steven Enamakelaae2e7a8c7a5
diff --git a/crates/openhuman-app/src/core_process.rs b/crates/openhuman-app/src/core_process.rsindex e7a867baaa..019c5901a6 100644--- a/crates/openhuman-app/src/core_process.rs+++ b/crates/openhuman-app/src/core_process.rs@@ -704,7 +704,7 @@ impl CoreProcessHandle {/// The moment is sized from what that teardown is allowed to take, so the/// abort below never lands in the middle of it: the memory exit budget/// (`EXIT_BUDGET`, every driver and the hook registry on one deadline),- /// the ollama cleanup after it in `serve_http` (2 s), and half a second+ /// the ollama cleanup after it in `CoreRuntime::exit_cleanup` (2 s), and half a second/// for the drain itself. Typical quits finish in milliseconds; the budget/// is only what a wedged store or daemon may cost.async fn drain_task_briefly(&self) {diff --git a/crates/openhuman-core/src/core/runtime/README.md b/crates/openhuman-core/src/core/runtime/README.mdindex 61ba5975a2..756bc8f6a6 100644--- a/crates/openhuman-core/src/core/runtime/README.md+++ b/crates/openhuman-core/src/core/runtime/README.md@@ -14,14 +14,14 @@ binary both build on to host the core without duplicating`CoreRuntime::invoke` can dispatch any RPC method in-process and agentturns can run: a harness-only embedder using `ServiceSet::none()` needsnothing more.-2. **`CoreRuntime::serve()`: transport + background services.** Binds the- HTTP listener (when `ServiceSet::rpc_http` is set), mounts the router,- fires the readiness signal, spawns the selected background services, and- serves until shutdown. When `rpc_http` is unset it just spawns the- selected background services and returns immediately: the caller owns- the process lifetime. In a build compiled without the `http-server`- feature, requesting `rpc_http` returns an `Err` rather than silently- binding nothing.+2. **`openhuman_rpc::server::serve(&runtime, …)`: transport + background+ services.** Binds the HTTP listener (when `ServiceSet::rpc_http` is set),+ mounts the router, fires the readiness signal, calls+ `CoreRuntime::start_services`, and serves until shutdown, then runs+ `CoreRuntime::exit_cleanup`. When `rpc_http` is unset it just starts the+ selected background services and returns: the caller owns the process+ lifetime. The server lives in `openhuman-rpc`, above this crate; a+ runtime that needs no transport calls `start_services` directly.`CoreRuntime::invoke(method, params)` dispatches an RPC method in-processthrough `jsonrpc::invoke_method`: the same path the HTTP `/rpc` handler anddiff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rsindex a5fdb649be..10b0049432 100644--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs@@ -3,7 +3,8 @@//! [`bootstrap_core_runtime`] runs from//! [`CoreContext::init`](super::context::CoreContext::init) whether or not the//! runtime ever binds a listener; [`start_core_runtime_services`] runs from-//! [`CoreRuntime::serve`](super::CoreRuntime::serve) once it does.+//! [`CoreRuntime::start_services`](super::CoreRuntime::start_services)+//! once a transport has bound, or directly when there is none./// Initializes long-lived socket/event-bus infrastructure.///diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rsindex ac2095c397..7d77b55a7e 100644--- a/crates/openhuman-core/src/core/runtime/builder.rs+++ b/crates/openhuman-core/src/core/runtime/builder.rs@@ -10,13 +10,15 @@//! background loops. After `build`, [`CoreRuntime::invoke`] can dispatch any//! RPC method in-process, and agent turns can run — so a harness-only embedder//! (`ServiceSet::none`) needs nothing more.-//! 2. [`CoreRuntime::serve`] — *transport + background services*: bind the HTTP-//! listener, mount the router, fire the readiness signal, spawn the selected-//! background services, and serve until shutdown.+//! 2. *Transport + background services*: `openhuman_rpc::server::serve` binds+//! the HTTP listener, mounts the router, fires the readiness signal, calls+//! [`CoreRuntime::start_services`], and serves until shutdown. A runtime+//! with no transport calls `start_services` itself.//!-//! The legacy entry points (`run_server`, `run_server_embedded`,-//! `run_server_embedded_with_ready`) are now thin shims over this builder, so-//! the desktop shell, the standalone CLI, and any new embedder share one path.+//! The server entry points in `openhuman-rpc` (`run_server`,+//! `run_server_embedded`, `run_server_embedded_with_ready`) are thin shims over+//! this builder, so the desktop shell, the standalone CLI, and any new embedder+//! share one path.//! See the pluggable-core work (`core::runtime`) for how this fits with//! [`context`](crate::core::runtime::context) and `services`.@@ -499,7 +501,7 @@ impl CoreBuilder {self}- /// Choose which background services / transports [`CoreRuntime::serve`] runs.+ /// Choose which background services and transports this runtime runs.pub fn services(mut self, services: ServiceSet) -> Self {self.services = services;self@@ -676,7 +678,8 @@ impl CoreBuilder {}/// A built, initialized core. Dispatch RPC in-process with [`CoreRuntime::invoke`],-/// or run the selected transport + background services with [`CoreRuntime::serve`].+/// start its background services with [`CoreRuntime::start_services`], or hand it+/// to `openhuman_rpc::server::serve` to run the selected transport as well.pub struct CoreRuntime {ctx: Arc<CoreContext>,config: Option<Config>,diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rsindex ceacf549a6..aa2616e633 100644--- a/crates/openhuman-core/src/core/runtime/context.rs+++ b/crates/openhuman-core/src/core/runtime/context.rs@@ -203,7 +203,7 @@ fn warn_if_memory_module_outlived_its_profile(_workspace_dir: &std::path::Path)impl CoreContext {/// Run the core initialization sequence and return the context plus whether/// an operator-supplied RPC bearer exists (for the public-bind safety check- /// in `CoreRuntime::serve`) plus the loaded config, when boot reached+ /// in `openhuman_rpc::server::serve`) plus the loaded config, when boot reached/// workspace-bound init. Order is load-bearing and mirrors the original/// `run_server_inner` sequence:///@@ -335,7 +335,7 @@ impl CoreContext {// 6. Long-lived runtime infrastructure: event bus, domain subscribers,// ledgers, agent-definition registry, live security policy, approval// gate, socket manager. Idempotent (Once-guarded internally). Selected- // background jobs start later, from CoreRuntime::serve(), after bind+ // background jobs start later, from CoreRuntime::start_services(), after a transport binds// succeeds.let runtime_config = config.clone();let memory_subsystem = configdiff --git a/crates/openhuman-core/src/memory/exit.rs b/crates/openhuman-core/src/memory/exit.rsindex 9bb1d23a39..e84741776a 100644--- a/crates/openhuman-core/src/memory/exit.rs+++ b/crates/openhuman-core/src/memory/exit.rs@@ -31,7 +31,7 @@ use crate::memory::binding::MemoryBinding;/// a hook still pending. Releasing a lease is one write per in-flight job;/// anything slower is a store that is not going to answer, and its leases/// expire by themselves. The shell sizes its drain budget from this constant-/// plus the ollama cleanup that follows it in `serve_http`.+/// plus the ollama cleanup that follows it in `CoreRuntime::exit_cleanup`.pub const EXIT_BUDGET: Duration = Duration::from_secs(2);/// The least the hook registry gets even when the drivers spent the budget.diff --git a/crates/openhuman-rpc/src/server/http/mod.rs b/crates/openhuman-rpc/src/server/http/mod.rsindex 00947a4090..146c24bc9d 100644--- a/crates/openhuman-rpc/src/server/http/mod.rs+++ b/crates/openhuman-rpc/src/server/http/mod.rs@@ -2,7 +2,7 @@//!//! [`build_core_http_router`] assembles every route; each route family has its//! own module. Binding the listener and running the server belongs to-//! [`CoreRuntime::serve`](openhuman_core::core::runtime::CoreRuntime::serve).+//! [`serve`](super::serve).use axum::extract::{DefaultBodyLimit, Request};use axum::http::StatusCode;