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
chore: apply routine updates across core modules
Steven Enamakelcef8f8707c89
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rsindex 1a7ea54d2c..1430171449 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs@@ -24,7 +24,7 @@ pub(super) fn spawn_typing_task(let (finished_tx, finished_rx) = tokio::sync::oneshot::channel();// The worker retains ownership across cancellation of the caller while// StartTypingRefresh is in flight, then closes the returned module handle.- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {match channel.begin_typing_refresh(&recipient, CHANNEL_TYPING_REFRESH_INTERVAL_SECS).await@@ -43,7 +43,7 @@ pub(super) fn spawn_typing_task(}let _ = finished_tx.send(());});- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {let _ = finished_rx.await;})}diff --git a/crates/openhuman-core/src/channels/runtime/session.rs b/crates/openhuman-core/src/channels/runtime/session.rsindex 289b2fb442..6131f4ee4e 100644--- a/crates/openhuman-core/src/channels/runtime/session.rs+++ b/crates/openhuman-core/src/channels/runtime/session.rs@@ -109,7 +109,7 @@ whereF: FnMut(CancellationToken) -> Fut + Send + 'static,Fut: Future<Output = anyhow::Result<()>> + Send + 'static,{- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().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.diff --git a/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs b/crates/openhuman-core/src/channels/tests/runtime_dispatch.rsindex b0cc7cb100..2813b4343a 100644--- a/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs+++ b/crates/openhuman-core/src/channels/tests/runtime_dispatch.rs@@ -363,7 +363,7 @@ fn watch_for_channel_processed(message_id: &str) -> tokio::task::JoinHandle<Doma.expect("event bus should be initialized").receiver();let message_id = message_id.to_string();- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {let deadline = tokio::time::Instant::now() + Duration::from_secs(30);loop {let event = tokio::time::timeout_at(deadline, events.recv())diff --git a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rsindex daf3b0ba54..fccb782b20 100644--- a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs@@ -287,7 +287,7 @@ impl ModuleReplTool {);return Ok(ToolResult::error(not_a_handle_message()));};- let read = tokio::task::spawn_blocking(move || {+ let read = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {read_tool_result_artifact(&dir, &path, MAX_ARTIFACT_BYTES)}).awaitdiff --git a/crates/openhuman-core/src/integrations/composio/file_store.rs b/crates/openhuman-core/src/integrations/composio/file_store.rsindex a635f058c1..d44a688daa 100644--- a/crates/openhuman-core/src/integrations/composio/file_store.rs+++ b/crates/openhuman-core/src/integrations/composio/file_store.rs@@ -31,7 +31,7 @@ async fn import_legacy() -> Result<(), String> {let marker_docs = docs.clone();let done =- tokio::task::spawn_blocking(move || marker_docs.legacy_imported(name))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || marker_docs.legacy_imported(name)).await.map_err(|error| format!("[composio:store] checking legacy {name} failed: {error}"))?.map_err(|error| {@@ -54,7 +54,7 @@ async fn import_legacy(.map_err(|error| format!("[composio:store] parsing legacy {name} failed: {error}"))?;let docs = docs.clone();let wrote =- tokio::task::spawn_blocking(move || docs.import_if_absent(name, value))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || docs.import_if_absent(name, value)).await.map_err(|error| format!("[composio:store] importing legacy {name} failed: {error}"))?.map_err(|error| {@@ -78,7 +78,7 @@ whereimport_legacy(config, &docs, name).await?;// The document port is reached through a blocking bridge; keep it off the// async worker, under the caller's context.- tokio::task::spawn_blocking(move || docs.load(name))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || docs.load(name)).await.map_err(|error| format!("[composio:store] reading {name} failed: {error}"))?.map_err(|error| format!("[composio:store] reading {name} failed: {error:#}"))@@ -103,7 +103,7 @@ wherelet docs = super::file_store_documents::current(&config.workspace_dir).map_err(|e| format!("[composio:store] {e:#}"))?;import_legacy(config, &docs, name).await?;- tokio::task::spawn_blocking(move || docs.update(name, change))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || docs.update(name, change)).await.map_err(|error| format!("[composio:store] updating {name} failed: {error}"))?.map_err(|error| format!("[composio:store] updating {name} failed: {error:#}"))@@ -123,7 +123,7 @@ where.map_err(|e| format!("[composio:store] {e:#}"))?;let value = serde_json::to_value(value).map_err(|error| format!("[composio:store] serializing failed: {error}"))?;- tokio::task::spawn_blocking(move || docs.save(name, &value))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || docs.save(name, &value)).await.map_err(|error| format!("[composio:store] writing {name} failed: {error}"))?.map_err(|error| format!("[composio:store] writing {name} failed: {error:#}"))diff --git a/crates/openhuman-core/src/integrations/composio/trigger_history.rs b/crates/openhuman-core/src/integrations/composio/trigger_history.rsindex 03b4a888b7..32bcef8cde 100644--- a/crates/openhuman-core/src/integrations/composio/trigger_history.rs+++ b/crates/openhuman-core/src/integrations/composio/trigger_history.rs@@ -87,7 +87,7 @@ impl TriggerHistory {let client = self.client(&config);// Keep ownership installation running if the caller is cancelled while// OpenArchive completes. A later close can still release the handle.- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {let mut guard = lease.lock_owned().await;Self::ensure_lease(&config, &mut guard, client).await?;Ok(guard)@@ -157,7 +157,7 @@ impl TriggerHistory {/// Release the module resource while retaining all persisted documents.pub async fn close(&self) -> Result<(), String> {let lease = Arc::clone(&self.lease);- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {Self::release(&mut *lease.lock_owned().await).await}).awaitdiff --git a/crates/openhuman-core/src/integrations/task_sources/periodic.rs b/crates/openhuman-core/src/integrations/task_sources/periodic.rsindex 89df1b8f6e..f965de8f74 100644--- a/crates/openhuman-core/src/integrations/task_sources/periodic.rs+++ b/crates/openhuman-core/src/integrations/task_sources/periodic.rs@@ -81,7 +81,7 @@ pub fn start_periodic_poll() {tracing::debug!("[task_sources:periodic] scheduler already running, skipping start");return;}- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {tracing::info!(tick_seconds = TICK_SECONDS,"[task_sources:periodic] scheduler starting"diff --git a/crates/openhuman-core/src/mcp/ui/tools.rs b/crates/openhuman-core/src/mcp/ui/tools.rsindex e1f8d9a148..c11c9b2bb0 100644--- a/crates/openhuman-core/src/mcp/ui/tools.rs+++ b/crates/openhuman-core/src/mcp/ui/tools.rs@@ -110,7 +110,7 @@ pub fn confine_path_in(roots: &[PathBuf], path: &str) -> Result<(PathBuf, PathBu////// When the open is refused, the file is not regular, or it is too large.pub async fn read_confined(root: PathBuf, resolved: PathBuf) -> Result<String, String> {- tokio::task::spawn_blocking(move || {+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {use std::io::Read;let file = crate::agent::attachments::provider::open::secure_open(&resolved, &root).map_err(|error| {diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch.rsindex 3cfb144d93..568fb64f95 100644--- a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs@@ -171,7 +171,7 @@ pub(crate) fn pre_turn(if let Some(channel) = channel {let workspace = config.workspace_dir.clone();let thread = input.thread_id.clone();- let _ = tokio::task::spawn_blocking(move || {+ let _ = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {crate::memory::channels::record(&workspace, &channel, &thread)}).await;diff --git a/crates/openhuman-core/src/modules/storage_host_endpoint.rs b/crates/openhuman-core/src/modules/storage_host_endpoint.rsindex a1eee19340..549cc0c7c0 100644--- a/crates/openhuman-core/src/modules/storage_host_endpoint.rs+++ b/crates/openhuman-core/src/modules/storage_host_endpoint.rs@@ -102,7 +102,7 @@ impl StorageHost {let mut signals = binding.server.signals();let tx = relay.tx.clone();relay.fed_by = Some(Arc::downgrade(binding));- relay.bridge = Some(tokio::spawn(async move {+ relay.bridge = Some(crate::core::runtime::DispatchCtx::ambient().spawn(async move {loop {match signals.recv().await {Ok(signal) => {diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rsindex 5e44c61a55..8bd1c7b0fa 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs@@ -92,7 +92,7 @@ async fn import_into(scoped: &ScopedStorage, state_dir: &Path) -> Result<Outcome}let legacy =- tokio::task::spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || read_legacy(&prefs_dir, &triggers_dir)).await.context("the legacy reader panicked")??;diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rsindex d69e5a9652..19b31a1c3b 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs@@ -93,7 +93,7 @@ async fn import_into(let dir = root.to_owned();let (originals, mut skipped) =- tokio::task::spawn_blocking(move || read_originals(&dir, now))+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || read_originals(&dir, now)).await.context("the legacy reader panicked")??;diff --git a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs b/crates/openhuman-core/src/modules/storage_import_tinymcp.rsindex be5dd84741..6b78c07f73 100644--- a/crates/openhuman-core/src/modules/storage_import_tinymcp.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinymcp.rs@@ -110,7 +110,7 @@ async fn import_into(// The files are read on a blocking thread, from copies.let (legacy_servers, legacy_audit) =- tokio::task::spawn_blocking(move || -> Result<_> {+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || -> Result<_> {let servers = if clients.exists() {read_servers(&clients)?} else {diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rsindex a615833920..da7b0967a7 100644--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs@@ -66,7 +66,7 @@ async fn import_into(scoped: &ScopedStorage, workspace_dir: &Path) -> Result<Outif !ledger.is_file() {return Ok(Outcome::NoSource);}- let (records, skipped) = tokio::task::spawn_blocking(move || -> Result<_> {+ let (records, skipped) = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || -> Result<_> {let text = std::fs::read_to_string(&ledger).with_context(|| format!("read {}", ledger.display()))?;Ok(support::parse_jsonl(&text))diff --git a/crates/openhuman-core/src/profiles/background.rs b/crates/openhuman-core/src/profiles/background.rsindex 91f31d7c91..01ea7aa4b3 100644--- a/crates/openhuman-core/src/profiles/background.rs+++ b/crates/openhuman-core/src/profiles/background.rs@@ -41,7 +41,7 @@ pub struct TickReport {/// Start the loop. It runs until the process exits.pub fn spawn(host: Arc<ProfileHost>) -> tokio::task::JoinHandle<()> {- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {log::info!("[profiles][background] started (every {}s)",TICK_INTERVAL.as_secs()diff --git a/crates/openhuman-core/src/storage/blob_sweep.rs b/crates/openhuman-core/src/storage/blob_sweep.rsindex f91b182b6a..7e5e471839 100644--- a/crates/openhuman-core/src/storage/blob_sweep.rs+++ b/crates/openhuman-core/src/storage/blob_sweep.rs@@ -174,7 +174,7 @@ pub async fn sweep_installed() -> u64 {/// Spawns the sweeper: after `first_delay`, then every `interval`, until the/// task is aborted. Missed ticks are skipped, not replayed.pub fn spawn(first_delay: Duration, interval: Duration) -> tokio::task::JoinHandle<()> {- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {tracing::debug!(first_delay_secs = first_delay.as_secs(),interval_secs = interval.as_secs(),diff --git a/crates/openhuman-core/src/storage/import/mod.rs b/crates/openhuman-core/src/storage/import/mod.rsindex 233f895c4a..68597bb126 100644--- a/crates/openhuman-core/src/storage/import/mod.rs+++ b/crates/openhuman-core/src/storage/import/mod.rs@@ -191,7 +191,7 @@ pub async fn run(config: &Config) -> Vec<Report> {}let config = config.clone();let joined =- tokio::task::spawn_blocking(move || run_all(&backend, &config)).await;+ crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || run_all(&backend, &config)).await;match joined {Ok(reports) => reports,Err(error) => {diff --git a/crates/openhuman-core/src/tinymemes/callbacks.rs b/crates/openhuman-core/src/tinymemes/callbacks.rsindex 0e69b16d4f..e9e0d97c90 100644--- a/crates/openhuman-core/src/tinymemes/callbacks.rs+++ b/crates/openhuman-core/src/tinymemes/callbacks.rs@@ -257,7 +257,7 @@ async fn search(async fn load_index(session: &Session, request: LoadIndexRequest) -> HostResult<Option<String>> {let config = session.config.clone();let kind: IndexKind = request.kind;- match tokio::task::spawn_blocking(move || docs::load(&config, kind)).await {+ match crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || docs::load(&config, kind)).await {Ok(Ok(document)) => Ok(document),Ok(Err(error)) => {log::warn!("[tinymemes] cannot read index: {error}");@@ -272,7 +272,7 @@ async fn load_index(session: &Session, request: LoadIndexRequest) -> HostResult<async fn save_index(session: &Session, request: SaveIndexRequest) -> HostResult<()> {let config = session.config.clone();- match tokio::task::spawn_blocking(move || {+ match crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {docs::save(&config, request.kind, request.json)}).awaitdiff --git a/crates/openhuman-core/src/voice/always_on/capture.rs b/crates/openhuman-core/src/voice/always_on/capture.rsindex 24afa5c0dc..16968d47a3 100644--- a/crates/openhuman-core/src/voice/always_on/capture.rs+++ b/crates/openhuman-core/src/voice/always_on/capture.rs@@ -25,7 +25,7 @@ pub(super) async fn spawn_capture_thread(let lease = CaptureLease::reserve(config, Kind::Stream).await?;let stream = lease.start_stream().await?;let mut stopped = STOP.subscribe();- let task = tokio::spawn(async move {+ let task = crate::core::runtime::DispatchCtx::ambient().spawn(async move {loop {if tx.is_closed() {break;diff --git a/crates/openhuman-core/src/voice/server/hotkey_listener.rs b/crates/openhuman-core/src/voice/server/hotkey_listener.rsindex 6625d5478d..ab38c47d8c 100644--- a/crates/openhuman-core/src/voice/server/hotkey_listener.rs+++ b/crates/openhuman-core/src/voice/server/hotkey_listener.rs@@ -121,7 +121,7 @@ async fn start_module_hotkey_listener(let (events_tx, events_rx) = tokio::sync::mpsc::channel(65);let (ready_tx, ready_rx) = tokio::sync::oneshot::channel();let worker_handle = handle.clone();- let task = tokio::spawn(async move {+ let task = crate::core::runtime::DispatchCtx::ambient().spawn(async move {let generation = loop {if worker_cancel.is_cancelled() || events_tx.is_closed() {break None;@@ -344,7 +344,7 @@ async fn start_globe_with_client(let (ready_tx, ready_rx) = tokio::sync::oneshot::channel();let cancel = server_cancel.child_token();let task_cancel = cancel.clone();- let task = tokio::spawn(async move {+ let task = crate::core::runtime::DispatchCtx::ambient().spawn(async move {let _admission = admission;let started = match client.globe_start().await {Ok(started) => started,diff --git a/crates/openhuman-core/src/web_chat/turn_activity.rs b/crates/openhuman-core/src/web_chat/turn_activity.rsindex 77e5cdaf33..4a2e7a4759 100644--- a/crates/openhuman-core/src/web_chat/turn_activity.rs+++ b/crates/openhuman-core/src/web_chat/turn_activity.rs@@ -289,7 +289,7 @@ pub(crate) fn tap(capacity: usize,) -> mpsc::Receiver<AgentProgress> {let (bridge_tx, bridge_rx) = mpsc::channel(capacity);- tokio::spawn(async move {+ crate::core::runtime::DispatchCtx::ambient().spawn(async move {while let Some(event) = agent_rx.recv().await {activity.observe(&event);if bridge_tx.send(event).await.is_err() {