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(voice): add always-on capture and hotkey listener
Steven Enamakel43e34df47f6c
diff --git a/crates/openhuman-core/src/voice/always_on/capture.rs b/crates/openhuman-core/src/voice/always_on/capture.rsindex 16968d47a3..d56f9bed56 100644--- a/crates/openhuman-core/src/voice/always_on/capture.rs+++ b/crates/openhuman-core/src/voice/always_on/capture.rs@@ -19,13 +19,14 @@ impl Drop for CapturePump {}/// Start a module stream and forward ordered batches to the bounded processor queue.pub(super) async fn spawn_capture_thread(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,tx: tokio::sync::mpsc::Sender<RawChunk>,) -> Result<(CaptureFormat, CapturePump), String> {let lease = CaptureLease::reserve(config, Kind::Stream).await?;let stream = lease.start_stream().await?;let mut stopped = STOP.subscribe();- let task = crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ let task = ctx.spawn(async move {loop {if tx.is_closed() {break;diff --git a/crates/openhuman-core/src/voice/always_on/processor.rs b/crates/openhuman-core/src/voice/always_on/processor.rsindex a392510040..34e9b26163 100644--- a/crates/openhuman-core/src/voice/always_on/processor.rs+++ b/crates/openhuman-core/src/voice/always_on/processor.rs@@ -71,7 +71,7 @@ const MAX_UTTERANCE_SAMPLES: usize = TARGET_SAMPLE_RATE as usize * 60;/// Opens a continuous mic stream, segments it through the `tinyvoice` module, and/// routes each finished utterance through STT and the dictation delivery bus (so/// it reaches the agent exactly like a hotkey dictation, and lights up the notch).-pub async fn start_if_enabled(app_config: &Config) {+pub async fn start_if_enabled(ctx: &crate::core::runtime::DispatchCtx, app_config: &Config) {if !app_config.components.voice {log::info!("{LOG_PREFIX} [components].voice is off — always-on stays down");shutdown().await;@@ -113,7 +113,7 @@ pub async fn start_if_enabled(app_config: &Config) {);let (tx, mut rx) = tokio::sync::mpsc::channel::<RawChunk>(CAPTURE_QUEUE_CHUNKS);- let (format, pump) = match spawn_capture_thread(app_config, tx).await {+ let (format, pump) = match spawn_capture_thread(ctx, app_config, tx).await {Ok(stream) => stream,Err(error) => {log::warn!("{LOG_PREFIX} could not start microphone capture: {error}");@@ -126,7 +126,7 @@ pub async fn start_if_enabled(app_config: &Config) {let onset_threshold = vad.onset_threshold;let mut stopped = super::capture::stop_subscription();- let processor = crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ let processor = ctx.spawn(async move {let _running = running;let _pump = pump;// The segmenter lives in the module now, so opening it can fail fordiff --git a/crates/openhuman-core/src/voice/server/hotkey_listener.rs b/crates/openhuman-core/src/voice/server/hotkey_listener.rsindex ab38c47d8c..4a4f69b6ba 100644--- a/crates/openhuman-core/src/voice/server/hotkey_listener.rs+++ b/crates/openhuman-core/src/voice/server/hotkey_listener.rs@@ -51,6 +51,7 @@ impl HotkeyListenerKind {/// with `EXC_BREAKPOINT` (`dispatch_assert_queue_fail`). Configure/// `hotkey = "fn"` to avoid this. (#2677)pub(crate) async fn start_hotkey_listener(+ ctx: &crate::core::runtime::DispatchCtx,config: &crate::config::Config,hotkey_str: &str,mode: hotkey::ActivationMode,@@ -65,7 +66,7 @@ pub(crate) async fn start_hotkey_listener(#[cfg(target_os = "macos")]{if hotkey_str.trim().eq_ignore_ascii_case("fn") {- return start_globe_hotkey_listener(config, mode, server_cancel).await;+ return start_globe_hotkey_listener(ctx, config, mode, server_cancel).await;}// rdev calls TSMGetInputSourceProperty off the main thread; macOS 26// enforces main-queue-only access and crashes the process. Only the@@ -83,12 +84,13 @@ pub(crate) async fn start_hotkey_listener(// Non-macOS: TinyVoice owns its native listener and cleanup worker.#[cfg(not(target_os = "macos"))]{- start_module_hotkey_listener(config, hotkey_str, mode, server_cancel).await+ start_module_hotkey_listener(ctx, config, hotkey_str, mode, server_cancel).await}}#[cfg(not(target_os = "macos"))]async fn start_module_hotkey_listener(+ ctx: &crate::core::runtime::DispatchCtx,config: &crate::config::Config,hotkey_str: &str,mode: hotkey::ActivationMode,@@ -121,7 +123,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 = crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ let task = ctx.spawn(async move {let generation = loop {if worker_cancel.is_cancelled() || events_tx.is_closed() {break None;@@ -306,6 +308,7 @@ impl HotkeyDelivery {/// still leaves an owner to recover a lost start reply and close the native lease.#[cfg(target_os = "macos")]async fn start_globe_hotkey_listener(+ ctx: &crate::core::runtime::DispatchCtx,config: &crate::config::Config,mode: hotkey::ActivationMode,server_cancel: &CancellationToken,@@ -317,6 +320,7 @@ async fn start_globe_hotkey_listener(String,> {start_globe_with_client(+ ctx,crate::modules::accessibility::AccessibilityClient::new(config),mode,server_cancel,@@ -326,6 +330,7 @@ async fn start_globe_hotkey_listener(#[cfg(any(target_os = "macos", test))]async fn start_globe_with_client(+ ctx: &crate::core::runtime::DispatchCtx,client: crate::modules::accessibility::AccessibilityClient,mode: hotkey::ActivationMode,server_cancel: &CancellationToken,@@ -344,7 +349,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 = crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ let task = ctx.spawn(async move {let _admission = admission;let started = match client.globe_start().await {Ok(started) => started,