Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-core/src/core/runtime/builder.rs,crates/openhuman-core/src/cor

Steven Enamakel96b1471b28f2
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index 6158a09f61..4365ef581b 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -472,6 +472,7 @@ pub struct CoreBuilder {
host: Option<String>,
port: Option<u16>,
config: Option<crate::config::Config>,
+ backend_transport: Option<std::sync::Arc<dyn crate::api::transport::BackendTransport>>,
}
impl CoreBuilder {
@@ -487,9 +488,30 @@ impl CoreBuilder {
host: None,
port: None,
config: None,
+ backend_transport: None,
}
}
+ /// Bind the transport this core's handlers reach the hosted TinyHumans
+ /// backend through (see [`crate::api::transport`]).
+ ///
+ /// Optional: without it the core resolves the process-global transport
+ /// installed with
+ /// [`install_backend_transport`](crate::api::transport::install_backend_transport),
+ /// and with neither every backend-touching call degrades to a typed
+ /// "backend unavailable" error while agents, memory, tools and RPC keep
+ /// working. Library hosts that build one runtime per process prefer this
+ /// builder form; the desktop shell and CLI, which boot the core through
+ /// `run_server_embedded_with_ready` / `run_core_from_args`, install the
+ /// global.
+ pub fn backend_transport(
+ mut self,
+ transport: std::sync::Arc<dyn crate::api::transport::BackendTransport>,
+ ) -> Self {
+ self.backend_transport = Some(transport);
+ self
+ }
+
/// Choose which background services / transports [`CoreRuntime::serve`] runs.
pub fn services(mut self, services: ServiceSet) -> Self {
self.services = services;
@@ -632,6 +654,7 @@ impl CoreBuilder {
self.domains,
self.tool_groups.clone(),
self.config,
+ self.backend_transport,
)
.await?;
diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rs
index df6b4a68f8..12bc921031 100644
--- a/crates/openhuman-core/src/core/runtime/context.rs
+++ b/crates/openhuman-core/src/core/runtime/context.rs
@@ -94,6 +94,14 @@ pub struct CoreContext {
/// [`CoreContext::derive_with`] can turn it off so an embedded agent sees
/// only the skills its host installed for it, never the operator's.
user_skill_roots: bool,
+ /// The backend transport this context's handlers reach the hosted
+ /// TinyHumans backend through, when the host supplied one via
+ /// [`CoreBuilder::backend_transport`](crate::core::runtime::CoreBuilder::backend_transport).
+ /// `None` means "fall back to the process-global transport" — see
+ /// [`crate::api::transport::resolve_backend_transport`] for the order.
+ /// Inherited unchanged by every context derived through
+ /// [`CoreContext::derive_with`].
+ backend_transport: Option<Arc<dyn crate::api::transport::BackendTransport>>,
}
/// Per-agent overrides layered onto a booted context by
@@ -210,7 +218,7 @@ impl CoreContext {
token: &TokenSource,
domains: crate::core::runtime::DomainSet,
) -> anyhow::Result<(Arc<CoreContext>, bool, Option<crate::config::Config>)> {
- Self::init_with_config(host_kind, token, domains, Default::default(), None).await
+ Self::init_with_config(host_kind, token, domains, Default::default(), None, None).await
}
/// [`init`](Self::init) with an optional caller-supplied configuration.
@@ -230,10 +238,15 @@ impl CoreContext {
domains: crate::core::runtime::DomainSet,
tool_groups: crate::tools::toolpacks::ToolGroups,
preloaded_config: Option<crate::config::Config>,
+ backend_transport: Option<Arc<dyn crate::api::transport::BackendTransport>>,
) -> anyhow::Result<(Arc<CoreContext>, bool, Option<crate::config::Config>)> {
log::debug!(
"[core-context] init: host_kind={host_kind:?} domains={domains:?} \
- tool_groups={tool_groups:?}"
+ tool_groups={tool_groups:?} backend_transport={}",
+ backend_transport
+ .as_ref()
+ .map(|t| t.name())
+ .unwrap_or("<process-global>")
);
// 1. Ensure all controllers are registered before anything dispatches.
let _ = crate::core::all::all_registered_controllers();
@@ -341,6 +354,7 @@ impl CoreContext {
tool_groups,
embedder_config,
user_skill_roots: true,
+ backend_transport,
});
// Register the process default context (first build wins). Dispatch
@@ -430,9 +444,15 @@ impl CoreContext {
tool_groups: overlay.tool_groups,
embedder_config: Some(overlay.config),
user_skill_roots: overlay.user_skill_roots,
+ backend_transport: self.backend_transport.clone(),
})
}
+ /// The backend transport bound to this context, if the host supplied one.
+ pub fn backend_transport(&self) -> Option<Arc<dyn crate::api::transport::BackendTransport>> {
+ self.backend_transport.clone()
+ }
+
/// The resolved per-user workspace directory this context is bound to.
pub fn workspace_dir(&self) -> Result<std::path::PathBuf, String> {
self.workspace_binding