Skip to content

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

docs(desktop): expand module README with architecture and RPC surface

Steven Enamakelc1578ff29848
diff --git a/crates/openhuman-core/src/desktop/README.md b/crates/openhuman-core/src/desktop/README.md
index e9b5455501..2ce570f839 100644
--- a/crates/openhuman-core/src/desktop/README.md
+++ b/crates/openhuman-core/src/desktop/README.md
@@ -1,46 +1,151 @@
# desktop
-Domain logic that exists only to serve the desktop client: things a headless
-or embedded host has no use for. The module is grouped this way so a future
-`desktop` Cargo feature can drop the whole family as one unit; today only two
-of its members are gated (see below), and the rest compile unconditionally.
-
-This is not the Tauri shell itself. The shell lives in `crates/openhuman-app/`
-and hosts the windows, tray, and native OS integration; this module is the
-core-side business logic those windows call into over RPC and Socket.IO
-(accessibility queries, app-state snapshots, notification routing, and so
-on). OpenHuman also ships the same frontend as a browser SPA and a ratatui
-TUI (`crates/openhuman-tui`), neither of which reaches most of this module,
-since it is specifically the desktop-only slice.
-
-## Subfolders
-
-| Folder | Owns |
+Core-side logic that exists to serve the desktop client: the app-state
+snapshot the shell polls, the notification center, overlay attention bubbles,
+the model-health dashboard, the provider respond queue, and opt-in native
+desktop control. A headless or embedded host has little use for any of it,
+which is why these domains are grouped here and tagged `DomainGroup::Desktop`.
+
+This is not the Tauri shell. The shell lives in `crates/openhuman-app/` and
+owns windows, the tray, and native OS integration. This folder is the
+business logic those windows reach over JSON-RPC and Socket.IO. The browser
+SPA uses the same RPC surface; the TUI (`crates/openhuman-tui`) uses little of
+it.
+
+## How it works
+
+The members are independent. They share a host-facing role, not a data model.
+Each one meets the frontend in one of two ways:
+
+```text
+ React shell / notch window / browser SPA
+ | ^
+ JSON-RPC | | Socket.IO
+ (openhuman.*)| | (openhuman-rpc server/socketio.rs)
+ v |
+ +--------------------------+ +-------------------------------+
+ | controllers (core/all.rs)| | in-process broadcast channels |
+ | app_state_* | | overlay::subscribe_attention |
+ | notification_* | | _events |
+ | dashboard_* | | notifications::subscribe_ |
+ | provider_surfaces_* | | core_notifications |
+ | desktop_* (internal) | +-------------------------------+
+ +--------------------------+ ^
+ | | publish
+ v |
+ peer domains (config, auth, DomainEvent bus -> notifications::bridge
+ local AI, service, keyring) any caller -> overlay::publish_attention
+```
+
+Request and response flows (the app-state snapshot, the notification list,
+model health, the respond queue, desktop status) are ordinary controllers
+registered under `DomainGroup::Desktop` in `core/all.rs`. Push flows use
+process-global `tokio::sync::broadcast` channels that the Socket.IO server in
+`crates/openhuman-rpc` subscribes to and forwards. Notifications get onto
+their channel through `NotificationBridgeSubscriber` (`notifications::bridge`),
+which translates selected `DomainEvent`s; it is registered at startup from
+`core/runtime/subscribers.rs`. Overlay attention events are published
+directly by any caller.
+
+### Desktop control
+
+`control/` is different from the rest: it lets the agent drive native desktop
+apps through the `tinycomputer` module's accessibility layer, with Jev picking
+actions. It is opt-in per computer. The enabled flag lives in
+`<workspace>/state/desktop-control.json` and fails closed when the file is
+missing or corrupt. Control is only supported on macOS and Windows, and only
+when the core's HTTP listener is bound to loopback
+(`set_listener_is_loopback`, set from `core/runtime/builder.rs` once the
+address is known). The tools refuse to run when the listener is not loopback
+or control is disabled.
+
+The agent tools are `desktop_list_apps`, `desktop_list_windows`,
+`desktop_launch`, `desktop_snapshot`, `desktop_find`, `desktop_goal`, and
+`desktop_continue_goal` (`DesktopTool` with a `DesktopToolKind`, registered in
+`tools/ops.rs`). A `desktop_goal` call hands one bounded task to the module,
+which runs and verifies several actions in that call. When the operator turns
+desktop approvals on (`config.desktop.approvals_enabled`), the module can stop
+on a pending action. `confirmation.rs` keeps those one-use decisions for ten
+minutes and exposes them through `desktop_pending` and `desktop_confirm`. With
+approvals off (the default), `approvals_disabled_for` lets these seven tools
+skip only the approval park; permission caps, denies, OS grants, and the
+action budget still apply. The agent-facing instructions are in
+`control/WORKFLOW.md`.
+
+## Layout
+
+| Path | What it does |
| --- | --- |
-| [`app_state`](app_state/README.md) | The aggregator the React shell polls (`openhuman.app_state_snapshot`): stored credential, local-AI status, service health, onboarding tasks, keyring status. |
-| `control` | Local opt-in desktop automation: native window inspection and control, driven through [Jev](../../../../gitbooks/developing/jev.md)-ranked accessibility actions. See its `WORKFLOW.md`. Gated by `#[cfg(feature = "modules")]`. |
-| [`dashboard`](dashboard/README.md) | Aggregate operator-facing views over local config; today a single read-only per-model health comparison table. |
-| [`notifications`](notifications/README.md) | Translates cross-domain events into user-facing notifications, and separately ingests, triages, and stores notifications captured from embedded webview integrations. |
-| [`overlay`](overlay/README.md) | A broadcast bus for short "attention" messages pushed to the desktop overlay/notch window. |
-| [`provider_surfaces`](provider_surfaces/README.md) | An early scaffold for a normalized event model and respond queue over embedded provider webviews (LinkedIn, Gmail, and similar). |
+| `mod.rs` | Declares the members. Only `control` is feature-gated. |
+| [`app_state/`](app_state/README.md) | The snapshot the shell polls (`app_state_snapshot`): stored credential and user, local-AI and service status, onboarding tasks, keyring status, config-recovery notice. Owns `state/app-state.json` and `update_local_state`. |
+| `control/` | Opt-in native desktop control: enablement and status (`ops.rs`), pending-action decisions (`confirmation.rs`), the `desktop_*` agent tools (`tools.rs`), and internal-only controllers (`schemas.rs`). `modules` feature only. Agent guidance in `WORKFLOW.md`. |
+| [`dashboard/`](dashboard/README.md) | Read-only per-model health table for Settings, built from `model_registry` and the `dashboard.model_health` thresholds. Also the `dashboard_model_health` agent tool. |
+| [`notifications/`](notifications/README.md) | Two pipelines: the event bridge that turns `DomainEvent`s into `CoreNotificationEvent`s, and the integration-notification store (SQLite) with background triage and per-provider settings. |
+| [`overlay/`](overlay/README.md) | One broadcast channel for short attention messages shown in the notch or overlay window. No RPC, no persistence. |
+| [`provider_surfaces/`](provider_surfaces/README.md) | An early scaffold: a normalized `ProviderEvent` model and an in-memory respond queue (soft cap 500) over embedded provider webviews. |
+
+## Key types and entry points
+
+- `app_state::snapshot()` (`app_state/ops/snapshot.rs`) assembles
+ `AppStateSnapshot` from peer domains. It never calls the backend; the user
+ it reports is what the host passed in through `auth.set_credential`.
+- `notifications::register_notification_bridge_subscriber(config)` and
+ `notifications::publish_core_notification` / `subscribe_core_notifications`
+ (`notifications/bus.rs`) are the push path for the notification center.
+- `overlay::publish_attention(OverlayAttentionEvent)` returns how many
+ subscribers received the event (zero means it was dropped).
+- `control::status`, `control::set_enabled`, and `control::probe`
+ (`control/ops.rs`) back the Connections page.
+- `DesktopTool` and `DesktopToolKind` (`control/tools.rs`) are the desktop
+ agent tools, re-exported through `tools/mod.rs`.
+
+## RPC / CLI surface
+
+Method names are `openhuman.<namespace>_<function>`.
+
+| Namespace | Functions | Notes |
+| --- | --- | --- |
+| `app_state` | `snapshot`, `update_local_state` | Polled by the shell every few seconds. |
+| `notification` | `ingest`, `list`, `mark_read`, `dismiss`, `mark_acted`, `settings_get`, `settings_set`, `stats`, `core_list`, `core_mark_read` | Integration notifications plus persisted core notifications. |
+| `dashboard` | `model_health` | Errors when `dashboard.model_health.enabled` is false. |
+| `provider_surfaces` | `ingest_event`, `list_queue` | In-memory only. |
+| `desktop` | `status`, `set_enabled`, `probe`, `pending`, `confirm` | Internal-only (`build_internal_only_controllers`): callable by the shell, hidden from agent tool listings. `modules` feature only. |
+
+## Boundaries
-## Gating
+- Windows, tray, notch window, and OS integration belong to the Tauri shell
+ (`crates/openhuman-app/`). The notch window host is
+ `crates/openhuman-app/src/notch_window.rs`.
+- Socket.IO forwarding belongs to `crates/openhuman-rpc/src/server/socketio.rs`.
+- OS accessibility (AX and IOKit FFI, the Swift helper, focus, permissions,
+ the Globe key) belongs to the `tinycomputer-accessibility` crate in
+ `vendor/tinycomputer` (upstream `tinyhumansai/tinycomputer`). Desktop
+ observation, interaction, and Jev-driven goals belong to the `tinycomputer`
+ module; this folder calls it through `tinycomputer-bus`.
+- The live current user belongs to the host's session owner
+ (`openhuman_tinyhumans::session`), not to `app_state`.
+- Dictation overlay activation is driven by `voice::dictation_listener`, not
+ by `overlay`.
-Only one member is feature-gated today. (OS accessibility — macOS AX/IOKit FFI,
-the Swift helper, focus, permissions, Globe key — moved to the
-`tinycomputer-accessibility` crate in `vendor/tinycomputer`; its microphone probe
-rides the `inference` feature, and reports `PermissionState::Unknown` without it.)
+## Gotchas
-- `control` is compiled only under `#[cfg(feature = "modules")]`.
+- Only `control` is feature-gated (`modules`). Everything else compiles
+ unconditionally. The runtime filter is `DomainSet::desktop`
+ (`core/runtime/builder.rs`). The plan for a dedicated compile-time gate is
+ in `docs/specs/2026-08-02-core-kernel-domain-reorg.md`.
+- `control` checks loopback on every tool call and every confirmation, not
+ just at enable time. A core bound to a non-loopback address reports
+ `supported: false`.
+- The overlay and notification channels drop events when no one is
+ subscribed. They are notifications, not a queue.
+- `provider_surfaces` keeps its queue in process memory, so it is empty after
+ a restart.
-Everything else in this module compiles unconditionally. See
-`docs/specs/2026-08-02-core-kernel-domain-reorg.md` for the reorg that
-grouped these domains together and the plan for a dedicated gate.
+## Tests
-## Where to look next
+Each member keeps sibling `*_tests.rs` files.
-Each subfolder's own README covers its RPC surface, persistence, and event
-wiring in detail. Start with [`app_state`](app_state/README.md) if you are
-looking for the shell's general health/status picture, or
-[`notifications`](notifications/README.md) for anything about the in-app
-notification center.
+```bash
+cargo test -p openhuman desktop::
+pnpm debug rust desktop::
+```