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 Enamakel4c4f97652ad9
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index 5bf727c04d..9548870e5b 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -794,39 +794,13 @@ impl CoreRuntime {
/// update checker) are tracked and stopped by
/// [`stop_services`](Self::stop_services) or when this runtime drops.
pub async fn start_services(&self) {
- use crate::core::runtime::services;
- if !self.service_tasks.begin() {
- log::debug!("[core-runtime] start_services: already started; skipped");
- return;
- }
- log::debug!("[core-runtime] start_services services={:?}", self.services);
- super::bootstrap::start_core_runtime_services(self.services, self.config.as_ref()).await;
-
- if self.services.login_gated {
- self.service_tasks.track(
- "login_gated",
- services::spawn_login_gated_services(self.ctx.host_kind().is_desktop_shell()),
- );
- }
- if self.services.update_scheduler {
- self.service_tasks
- .track("update_scheduler", services::spawn_update_scheduler());
- }
- if self.services.cron {
- self.service_tasks
- .track("cron", services::spawn_cron_service(Arc::clone(&self.ctx)));
- }
- // Flow-run boot reconciliation is selected by the flows *domain*, not by
- // a background service — runs can be started without cron in the
- // ServiceSet, so their orphans must be reconcilable without it too.
- if self.ctx.domains().flows {
- services::spawn_flows_boot_reconcile();
- }
- if self.services.channels {
- if let Some(handle) = services::spawn_channels_service() {
- self.service_tasks.track("channels", handle);
- }
- }
+ crate::core::runtime::services::start_selected_services(
+ &self.service_tasks,
+ self.services,
+ self.config.as_ref(),
+ &self.ctx,
+ )
+ .await;
}
/// Stop the background services [`start_services`](Self::start_services)
diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rs
index d68fda387f..d03d4f6067 100644
--- a/crates/openhuman-core/src/core/runtime/context.rs
+++ b/crates/openhuman-core/src/core/runtime/context.rs
@@ -550,9 +550,8 @@ impl CoreContext {
CURRENT_CONTEXT.scope(ctx, fut).await
}
- /// [`scope`](Self::scope) for a synchronous closure: `f` runs with `ctx`
- /// as [`CoreContext::current`]. For blocking work that reads the ambient
- /// context, such as building a session for a host-registered agent.
+ /// [`scope`](Self::scope) for a synchronous closure, e.g. building a
+ /// session for a host-registered agent under its own context.
pub fn sync_scope<R>(ctx: Arc<CoreContext>, f: impl FnOnce() -> R) -> R {
CURRENT_CONTEXT.sync_scope(ctx, f)
}
diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rs
index e8947c5d08..5dc077ee23 100644
--- a/crates/openhuman-core/src/core/runtime/services.rs
+++ b/crates/openhuman-core/src/core/runtime/services.rs
@@ -93,6 +93,45 @@ impl Drop for ServiceTasks {
}
}
+/// The body of [`CoreRuntime::start_services`](crate::core::runtime::CoreRuntime::start_services):
+/// start what `services` selects once, tracking the long-lived loops in `tasks`.
+pub(crate) async fn start_selected_services(
+ tasks: &ServiceTasks,
+ services: ServiceSet,
+ config: Option<&Config>,
+ ctx: &std::sync::Arc<crate::core::runtime::CoreContext>,
+) {
+ if !tasks.begin() {
+ log::debug!("[core-runtime] start_services: already started; skipped");
+ return;
+ }
+ log::debug!("[core-runtime] start_services services={services:?}");
+ super::bootstrap::start_core_runtime_services(services, config).await;
+ if services.login_gated {
+ tasks.track(
+ "login_gated",
+ spawn_login_gated_services(ctx.host_kind().is_desktop_shell()),
+ );
+ }
+ if services.update_scheduler {
+ tasks.track("update_scheduler", spawn_update_scheduler());
+ }
+ if services.cron {
+ tasks.track("cron", spawn_cron_service(std::sync::Arc::clone(ctx)));
+ }
+ // Flow-run boot reconciliation is selected by the flows *domain*, not by
+ // a background service — runs can be started without cron in the
+ // ServiceSet, so their orphans must be reconcilable without it too.
+ if ctx.domains().flows {
+ spawn_flows_boot_reconcile();
+ }
+ if services.channels {
+ if let Some(handle) = spawn_channels_service() {
+ tasks.track("channels", handle);
+ }
+ }
+}
+
/// Background bootstrap for login-gated services (local AI, voice, screen
/// intelligence, autocomplete).
///