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(examples): migrate embed examples to the Runtime library API
Steven Enamakel3a04b1bcd001
diff --git a/examples/embed_headless.rs b/examples/embed_headless.rsindex d7f836e3b1..d3bdaa3132 100644--- a/examples/embed_headless.rs+++ b/examples/embed_headless.rs@@ -1,14 +1,16 @@//! Embed the OpenHuman core as a library — no HTTP, no background services.//!-//! Demonstrates the pluggable-core API: build a fully-initialized core with-//! [`ServiceSet::none`] (no ports bound, no cron/channels/login-gated services) AND+//! Demonstrates the library API, `openhuman_embed::Runtime`: build a+//! fully-initialized core with [`ServiceSet::none`] (no ports bound, no cron/channels/login-gated services) AND//! [`DomainSet::harness`] (only the agent + memory + threads + config + security//! domain families are live — the gate families flows/skills/mcp/meet/channels///! web3/voice/media and the catch-all `platform` are off, so their controllers//! are unknown-method, their agent tools absent, and their stores/subscribers//! never initialize). Dispatch RPC methods in-process through-//! [`CoreRuntime::invoke`] — the exact same path the HTTP `/rpc` handler and the-//! CLI use.+//! [`Runtime::core_runtime`]'s `invoke` — the exact same path the HTTP `/rpc`+//! handler and the CLI use. The workspace is ephemeral (the library default),+//! so running this touches nothing in `~/.openhuman`. Turns belong to agents:+//! see `Runtime::agent` for the typed path.//!//! Run with://!@@ -16,15 +18,12 @@//! cargo run --example embed_headless//! ```//!-//! To instead expose the core over HTTP for a single-core cloud deployment,-//! swap `ServiceSet::none()` for `ServiceSet::headless_api()`, keep a-//! `CancellationToken`, and call `runtime.serve(None, Some(token)).await` — it-//! binds `127.0.0.1:7788` (override with `.host(..)` / `.port(..)` on the-//! builder, or `OPENHUMAN_CORE_HOST` / `OPENHUMAN_CORE_PORT`) and serves until-//! the token is cancelled. Widen the runtime surface by swapping-//! `DomainSet::harness()` for `DomainSet::full()`.+//! To instead expose the core over HTTP, use `openhuman-rpc`'s host entries+//! (`openhuman_rpc::host::serve_desktop` / the `openhuman-core serve` CLI),+//! which serve a runtime like this one over JSON-RPC. Widen the runtime surface+//! by swapping `DomainSet::harness()` for `DomainSet::full()`.-use openhuman_core::{CoreBuilder, DomainSet, HostKind, ServiceSet};+use openhuman_embed::{DomainSet, HostKind, Runtime, ServiceSet};#[tokio::main]async fn main() -> anyhow::Result<()> {@@ -32,28 +31,30 @@ async fn main() -> anyhow::Result<()> {// self-contained. (`RUST_LOG=info cargo run --example embed_headless`)let _ = env_logger::builder().is_test(false).try_init();- // Initialize the core against the local workspace. `HostKind::Cli` selects+ // Initialize the core on an ephemeral workspace. `HostKind::Cli` selects// the standalone (non-desktop) bootstrap path; `DomainSet::harness()` builds// the embeddable agent core; `ServiceSet::none()` means no transport and no// background services are started.- let runtime = CoreBuilder::new(HostKind::Cli)+ let runtime = Runtime::builder()+ .host_kind(HostKind::Cli).domains(DomainSet::harness()).services(ServiceSet::none()).build().await?;+ let core = runtime.core_runtime();// Dispatch a couple of RPC methods in-process — no network involved.// `core.version` and `openhuman.ping` (a legacy alias for the built-in// `core.ping`) are always available regardless of the DomainSet — they are// transport built-ins, not domain controllers — so they succeed even under// `harness()`.- let version = runtime+ let version = core.invoke("core.version", serde_json::json!({})).await.map_err(|e| anyhow::anyhow!("core.version failed: {e}"))?;println!("core.version -> {version}");- let ping = runtime+ let ping = core.invoke("openhuman.ping", serde_json::json!({})).await.map_err(|e| anyhow::anyhow!("openhuman.ping failed: {e}"))?;diff --git a/examples/embed_kernel.rs b/examples/embed_kernel.rsindex cb145cf33f..824e622c21 100644--- a/examples/embed_kernel.rs+++ b/examples/embed_kernel.rs@@ -33,7 +33,10 @@//! cargo run --example embed_kernel//! ```-use openhuman_core::{CoreBuilder, DomainSet, HostKind, ServiceSet};+//! Built with the library API (`openhuman_embed::Runtime`) on an ephemeral+//! workspace, so running it touches nothing in `~/.openhuman`.++use openhuman_embed::{DomainSet, HostKind, Runtime, ServiceSet};#[tokio::main]async fn main() -> anyhow::Result<()> {@@ -43,21 +46,23 @@ async fn main() -> anyhow::Result<()> {let mut domains = DomainSet::kernel();domains.memory = true;- let runtime = CoreBuilder::new(HostKind::Cli)+ let runtime = Runtime::builder()+ .host_kind(HostKind::Cli).domains(domains).services(ServiceSet::none()).build().await?;+ let core = runtime.core_runtime();// Always available — `core.*` is kernel transport, not a domain.- let version = runtime+ let version = core.invoke("core.version", serde_json::json!({})).await.map_err(|e| anyhow::anyhow!("core.version failed: {e}"))?;println!("core.version -> {version}");// Enabled: memory was opted in above.- match runtime+ match core.invoke("openhuman.memory_list_namespaces", serde_json::json!({})).await{@@ -69,7 +74,7 @@ async fn main() -> anyhow::Result<()> {// not a registered handler returning "agent disabled". Absence is the// contract: a registered-but-failing method teaches a model the capability// exists and makes it retry.- match runtime+ match core.invoke("openhuman.agent_list_definitions", serde_json::json!({})).await{