Skip to content

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

refactor(voice): extract desktop accessibility into a separate library crate

Steven Enamakel3300f01367b1
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index 8c9cfc094f..97644daed9 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -351,6 +351,13 @@ tinychannels = { version = "0.1", features = ["relay-websocket"], optional = tru
tinybus = { path = "../../vendor/tinybus/crates/tinybus", default-features = false, features = ["macros", "uds"] }
tinysearch-bus = { path = "../../vendor/tinysearch/crates/tinysearch-bus" }
tinycomputer-bus = { path = "../../vendor/tinycomputer/crates/tinycomputer-bus", optional = true }
+# Desktop accessibility middleware, linked as a plain library (not through the
+# tinycomputer module): the voice pipeline needs focus lookup, paste validation,
+# permission checks and the Globe key synchronously and in-process. Deps are
+# serde, serde_json and log; `cpal` only via the `inference` gate. The
+# submodule pin sits on `oh-accessibility-on-v0.7.0` (v0.7.0 + this crate) — see
+# scripts/ci/module-pin-exemptions.json.
+tinycomputer-accessibility = { path = "../../vendor/tinycomputer/crates/tinycomputer-accessibility" }
# Portable skill metadata, parsing, discovery, and filesystem hardening.
tinyskills = { path = "../../vendor/tinyskills/crates/tinyskills" }
serde = { version = "1", features = ["derive"] }
@@ -829,10 +836,10 @@ http-server = ["dep:axum", "tinymcp/server-http"]
# only (`voice_server.stt_engine`, `voice::factory`) — so `cpal` is all that is
# left behind the gate. The gate name stays `inference` because it is forwarded
# by name from `crates/openhuman-app/Cargo.toml`, asserted by `INFERENCE_COMPILED_IN`,
-# and referenced from `desktop::accessibility::permissions`; renaming it buys
+# and referenced from `tinycomputer-accessibility`'s `microphone-probe` feature (forwarded below); renaming it buys
# nothing and would silently drop the microphone probe from the shipped app if
# the forwarding list were not updated in lockstep.
-inference = ["dep:cpal"]
+inference = ["dep:cpal", "tinycomputer-accessibility/microphone-probe"]
# Office-document tools: the `generate_document` and `generate_presentation`
# agent tools, plus PDF text extraction during multimodal file ingest.
# Default-ON.
diff --git a/crates/openhuman-core/src/core/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rs
index 407ec6ccf2..e3a42eed1f 100644
--- a/crates/openhuman-core/src/core/all_tests.rs
+++ b/crates/openhuman-core/src/core/all_tests.rs
@@ -252,7 +252,7 @@ fn inference_engine_compiled_in_when_feature_on() {
#[test]
#[cfg(not(feature = "inference"))]
fn inference_engine_compiled_out_when_feature_off() {
- use crate::desktop::accessibility::{detect_microphone_permission, PermissionState};
+ use tinycomputer_accessibility::{detect_microphone_permission, PermissionState};
assert!(!crate::inference::INFERENCE_COMPILED_IN);
assert_eq!(
detect_microphone_permission(),
diff --git a/crates/openhuman-core/src/desktop/mod.rs b/crates/openhuman-core/src/desktop/mod.rs
index b830e20209..534eca9a4f 100644
--- a/crates/openhuman-core/src/desktop/mod.rs
+++ b/crates/openhuman-core/src/desktop/mod.rs
@@ -4,19 +4,18 @@
//! things a headless / embedded host has no use for. Grouped so a future
//! `desktop` gate can drop them as one unit.
//!
-//! - [`accessibility`] — OS accessibility APIs (screen reader, permissions,
-//! vision-assisted click). Reached today only from the `voice` family.
//! - [`app_state`] — persisted desktop app state
//! - [`dashboard`] — dashboard aggregation surface
//! - [`notifications`] — user-facing notification delivery
//! - [`overlay`] — the desktop overlay window surface
//! - [`provider_surfaces`] — per-provider UI surface descriptors
//!
-//! Not yet gated: `accessibility`'s `cpal` microphone probe already rides the
-//! `inference` gate, and the rest are ungated. See
+//! OS accessibility (AX/IOKit FFI, focus, permissions, Globe key) lives in the
+//! `tinycomputer-accessibility` library crate (`vendor/tinycomputer`), linked
+//! directly by the `voice` family; its `cpal` microphone probe rides the
+//! `inference` gate. Not yet gated: the modules below are ungated. See
//! `docs/specs/2026-08-02-core-kernel-domain-reorg.md`.
-pub mod accessibility;
pub mod app_state;
#[cfg(feature = "modules")]
pub mod control;
diff --git a/crates/openhuman-core/src/voice/README.md b/crates/openhuman-core/src/voice/README.md
index 2e235af2a2..fc96d0d1c0 100644
--- a/crates/openhuman-core/src/voice/README.md
+++ b/crates/openhuman-core/src/voice/README.md
@@ -141,7 +141,7 @@ transcription count, rolling recent-transcript buffer for context) behind a
- `tinyinference-voice` — hosted STT transport, Piper execution, transcription cleanup, and streaming PCM mechanics; `crate::inference` supplies the local runtime and provider policy.
- `crate::config` — `Config`, `config::rpc::load_config_with_timeout`, voice-server / dictation config sections, and `config::schema::voice_providers` (`VoiceProviderCreds`, capability/auth/API-style enums).
-- `crate::desktop::accessibility` (macOS only) — focused-text inspection (`focused_text_context_verbose`) and the Swift globe-key listener (`globe_listener_start` / `globe_listener_poll`) used in place of rdev for the Fn key.
+- `tinycomputer_accessibility` (`vendor/tinycomputer`) (macOS only) — focused-text inspection (`focused_text_context_verbose`) and the Swift globe-key listener (`globe_listener_start` / `globe_listener_poll`) used in place of rdev for the Fn key.
- `crate::backend` — `BackendClient`, `backend::base_url` (asks the installed transport); `security::credentials::session_support::get_session_token` for backend-proxied reply-speech and the realtime signed-URL bootstrap.
- `crate::modules::voice` (`tinyvoice`) — see Contract crates above.
- `crate::core::all` (`ControllerFuture`, `RegisteredController`), `crate::core::{ControllerSchema, FieldSchema, TypeSchema}`, `crate::core::bus::BUS` + `crate::core::events` (event publishing), `crate::core::logging` (CLI run init), and `crate::rpc::RpcOutcome`.
diff --git a/crates/openhuman-core/src/voice/always_on/capture.rs b/crates/openhuman-core/src/voice/always_on/capture.rs
index 3378e79eb9..79fbee35e7 100644
--- a/crates/openhuman-core/src/voice/always_on/capture.rs
+++ b/crates/openhuman-core/src/voice/always_on/capture.rs
@@ -66,7 +66,7 @@ fn capture_on_thread(
tx: tokio::sync::mpsc::Sender<RawChunk>,
setup_tx: &std::sync::mpsc::SyncSender<Result<CaptureFormat, String>>,
) -> Result<(), String> {
- use crate::desktop::accessibility::{detect_microphone_permission, PermissionState};
+ use tinycomputer_accessibility::{detect_microphone_permission, PermissionState};
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::{SampleFormat, StreamConfig};
diff --git a/crates/openhuman-core/src/voice/audio_capture.rs b/crates/openhuman-core/src/voice/audio_capture.rs
index 9b098d6858..54537b80c9 100644
--- a/crates/openhuman-core/src/voice/audio_capture.rs
+++ b/crates/openhuman-core/src/voice/audio_capture.rs
@@ -251,7 +251,7 @@ fn record_on_thread(
setup_tx: std::sync::mpsc::SyncSender<Result<(), String>>,
) -> Result<RawRecording, String> {
// --- Cross-platform microphone permission pre-check ---
- use crate::desktop::accessibility::{
+ use tinycomputer_accessibility::{
detect_microphone_permission, microphone_denied_message, request_microphone_access,
PermissionState,
};
diff --git a/crates/openhuman-core/src/voice/server/README.md b/crates/openhuman-core/src/voice/server/README.md
index 4809a6df00..97ce99aebf 100644
--- a/crates/openhuman-core/src/voice/server/README.md
+++ b/crates/openhuman-core/src/voice/server/README.md
@@ -19,7 +19,7 @@ standalone through the `openhuman voice`/`openhuman dictate` CLI subcommand.
| --- | --- |
| `types.rs` | `ServerState`, `VoiceServerStatus`, `VoiceServerConfig` (hotkey, activation mode, skip_cleanup, context, min duration, silence threshold, custom dictionary), plus the `DEFAULT_SILENCE_THRESHOLD` (0.002 RMS, matching OpenWhispr's default), `MAX_RECENT_TRANSCRIPTS` (5), and `MAX_INITIAL_PROMPT_CHARS` (500) tunables. |
| `runtime.rs` | `VoiceServer`: the hotkey event loop. Starts the platform hotkey listener, tracks in-progress and pending recordings, handles the race between a buffered release event and recording setup still in flight, and spawns `process_recording_bg` off the event loop so rapid consecutive presses are never missed. Owns `run`/`stop`/`status`. |
-| `hotkey_listener.rs` | Picks the platform-appropriate listener. Uses `rdev` everywhere except the macOS `Fn`/Globe key, which goes through a Swift-based globe listener (`crate::desktop::accessibility`) instead, because `rdev`'s `CGEventTap` callback calls `TSMGetInputSourceProperty` off the main thread and macOS 26 kills the process for that (#2677). Any other hotkey is rejected on macOS with a message pointing at `hotkey = "fn"`. |
+| `hotkey_listener.rs` | Picks the platform-appropriate listener. Uses `rdev` everywhere except the macOS `Fn`/Globe key, which goes through a Swift-based globe listener (`tinycomputer_accessibility` (`vendor/tinycomputer`)) instead, because `rdev`'s `CGEventTap` callback calls `TSMGetInputSourceProperty` off the main thread and macOS 26 kills the process for that (#2677). Any other hotkey is rejected on macOS with a message pointing at `hotkey = "fn"`. |
| `pipeline.rs` | `process_recording_bg`: stops the recording, applies the duration/silence/hallucination gates, builds the `initial_prompt` from the custom dictionary and recent transcripts, transcribes via `crate::voice::voice_transcribe_bytes`, and delivers the text either over Socket.IO (when the focused app is OpenHuman itself) or by pasting into the external app via `text_input::insert_text`. |
| `singleton.rs` | `global_server`/`try_global_server` (the process-global `OnceCell<Arc<VoiceServer>>`), `start_if_enabled` (embedded auto-start, gated on `config.voice_server.auto_start`), and `run_standalone` (the blocking CLI entry point, which deliberately does not register in the global singleton so CLI-started instances stay isolated from the core RPC lifecycle). |
diff --git a/crates/openhuman-core/src/voice/server/hotkey_listener.rs b/crates/openhuman-core/src/voice/server/hotkey_listener.rs
index d6626ca20d..729c24d529 100644
--- a/crates/openhuman-core/src/voice/server/hotkey_listener.rs
+++ b/crates/openhuman-core/src/voice/server/hotkey_listener.rs
@@ -33,7 +33,7 @@ impl HotkeyListenerKind {
/// Start the appropriate hotkey listener for the current platform and key.
///
/// On macOS, the Fn/Globe key is handled by the Swift-based globe listener
-/// (`accessibility::globe`) which monitors `NSEvent.flagsChanged`. All other
+/// (`tinycomputer_accessibility::globe`) which monitors `NSEvent.flagsChanged`. All other
/// keys return an error on macOS: rdev's CGEventTap callback calls
/// `TSMGetInputSourceProperty` off the main thread; macOS 26 enforces
/// `dispatch_assert_queue(main_queue)` inside that API and kills the process
@@ -94,7 +94,7 @@ fn start_globe_hotkey_listener(
),
String,
> {
- use crate::desktop::accessibility::{globe_listener_poll, globe_listener_start};
+ use tinycomputer_accessibility::{globe_listener_poll, globe_listener_start};
info!("{LOG_PREFIX} hotkey is Fn on macOS — using Swift globe listener instead of rdev");
diff --git a/crates/openhuman-core/src/voice/server/pipeline.rs b/crates/openhuman-core/src/voice/server/pipeline.rs
index 3cad54aadd..027d1ba009 100644
--- a/crates/openhuman-core/src/voice/server/pipeline.rs
+++ b/crates/openhuman-core/src/voice/server/pipeline.rs
@@ -12,7 +12,7 @@ use tokio::sync::Mutex;
use crate::config::Config;
#[cfg(target_os = "macos")]
-use crate::desktop::accessibility;
+use tinycomputer_accessibility as accessibility;
use crate::modules::voice::{is_hallucinated, HallucinationMode};
use crate::voice::audio_capture::RecordingHandle;
use crate::voice::text_input;
diff --git a/crates/openhuman-core/src/voice/text_input.rs b/crates/openhuman-core/src/voice/text_input.rs
index dd186b9936..e0d6794c45 100644
--- a/crates/openhuman-core/src/voice/text_input.rs
+++ b/crates/openhuman-core/src/voice/text_input.rs
@@ -12,7 +12,7 @@ use log::{debug, info, warn};
use std::time::Duration;
#[cfg(target_os = "macos")]
-use crate::desktop::accessibility;
+use tinycomputer_accessibility as accessibility;
use arboard::Clipboard;
use enigo::{Direction, Enigo, Key, Keyboard, Settings};
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index c3f554890d..f859970c04 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -110,8 +110,8 @@ Canonical mapping of every product feature to its test source(s). Drives gap-fil
| ID | Feature | Layer | Test path(s) | Status | Notes |
| ----- | --------------------------------- | ----- | -------------------------------------- | ------ | ------------------------------ |
-| 2.2.1 | Permission Grant Flow | RU | `crates/openhuman-core/src/desktop/accessibility/` | 🟡 | Core branch covered; UX manual |
-| 2.2.2 | Permission Denial Handling | RU | `crates/openhuman-core/src/desktop/accessibility/` | 🟡 | Same |
+| 2.2.1 | Permission Grant Flow | RU | `vendor/tinycomputer/crates/tinycomputer-accessibility/` | 🟡 | Core branch covered; UX manual |
+| 2.2.2 | Permission Denial Handling | RU | `vendor/tinycomputer/crates/tinycomputer-accessibility/` | 🟡 | Same |
| 2.2.3 | Permission Re-Sync / Refresh | WD | _missing_ — tracked #968 | ❌ | App-restart re-sync |
| 2.2.4 | Partial Permission State Handling | WD | _missing_ — tracked #968 | ❌ | macOS-only spec |
diff --git a/scripts/ci/coverage-presence-allowlist.txt b/scripts/ci/coverage-presence-allowlist.txt
index 1273337612..9eacaecdbb 100644
--- a/scripts/ci/coverage-presence-allowlist.txt
+++ b/scripts/ci/coverage-presence-allowlist.txt
@@ -31,11 +31,6 @@ crates/openhuman-core/src/runtime/client/disabled.rs
# in this coverage lane, so each fragment's `#[cfg(target_os = "macos")]`
# definition is intentionally absent. They are exercised by the macOS desktop
# E2E matrix instead.
-crates/openhuman-core/src/desktop/accessibility/helper/swift_source.rs
-crates/openhuman-core/src/desktop/accessibility/helper/swift_focus.rs
-crates/openhuman-core/src/desktop/accessibility/helper/swift_paste.rs
-crates/openhuman-core/src/desktop/accessibility/helper/swift_ax_actions.rs
-crates/openhuman-core/src/desktop/accessibility/helper/swift_overlay.rs
# `search/mod.rs` has module declarations and feature-gated re-exports only;
# executable search behavior is in sibling modules.
crates/openhuman-core/src/search/mod.rs