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(session): add session runtime service wiring
Steven Enamakel4607cf675dfd
diff --git a/crates/openhuman-core/src/channels/runtime/session.rs b/crates/openhuman-core/src/channels/runtime/session.rsindex 6131f4ee4e..a9bc7e5066 100644--- a/crates/openhuman-core/src/channels/runtime/session.rs+++ b/crates/openhuman-core/src/channels/runtime/session.rs@@ -102,6 +102,7 @@ pub(crate) fn resume_channel_service() {}fn spawn_channel_service_with<F, Fut>(+ dispatch: &crate::core::runtime::DispatchCtx,controller: ChannelSessionController,mut run: F,) -> tokio::task::JoinHandle<()>@@ -109,7 +110,7 @@ whereF: FnMut(CancellationToken) -> Fut + Send + 'static,Fut: Future<Output = anyhow::Result<()>> + Send + 'static,{- crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ dispatch.spawn(async move {// A logout can race the service task's first poll. Do not let a// service created during that window start with the replacement// token before a credential has been installed again.@@ -130,12 +131,15 @@ where})}-pub(crate) fn spawn_current_channel_service_with<F, Fut>(run: F) -> tokio::task::JoinHandle<()>+pub(crate) fn spawn_current_channel_service_with<F, Fut>(+ dispatch: &crate::core::runtime::DispatchCtx,+ run: F,+) -> tokio::task::JoinHandle<()>whereF: FnMut(CancellationToken) -> Fut + Send + 'static,Fut: Future<Output = anyhow::Result<()>> + Send + 'static,{- spawn_channel_service_with(SESSION.clone(), run)+ spawn_channel_service_with(dispatch, SESSION.clone(), run)}/// Stop the host dispatch generation on logout, even with independent model auth.diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rsindex 52a2f9234d..2b06b0bab4 100644--- a/crates/openhuman-core/src/core/runtime/services.rs+++ b/crates/openhuman-core/src/core/runtime/services.rs@@ -140,7 +140,9 @@ pub(crate) async fn start_selected_services(spawn_flows_boot_reconcile();}if services.channels {- if let Some(handle) = spawn_channels_service() {+ if let Some(handle) = spawn_channels_service(&crate::core::runtime::DispatchCtx::new(+ std::sync::Arc::clone(ctx),+ )) {tasks.track("channels", handle);}}@@ -295,7 +297,9 @@ pub fn spawn_cron_service(/// messages are never polled. Skipped entirely when/// `OPENHUMAN_DISABLE_CHANNEL_LISTENERS` is set to `1`/`true`, and returns early/// when no channel integrations are configured.-pub fn spawn_channels_service() -> Option<tokio::task::JoinHandle<()>> {+pub fn spawn_channels_service(+ dispatch: &crate::core::runtime::DispatchCtx,+) -> Option<tokio::task::JoinHandle<()>> {// Compile-time `channels` gate: the body names `channels::start_channels`,// so the whole thing is `#[cfg]`-gated. With the feature off there are no// realtime listeners to spawn.@@ -309,6 +313,7 @@ pub fn spawn_channels_service() -> Option<tokio::task::JoinHandle<()>> {// invalidate a listener that has not finished starting yet.return Some(crate::channels::session::spawn_current_channel_service_with(+ dispatch,|channel_session| async move {let config = match crate::config::Config::load_or_init().await {Ok(c) => c,