Skip to content

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

chore: files changed crates/openhuman-core/src/core/runtime/mod.rs,crates/openhuman-embed/README.md,

Steven Enamakel42441ea697a4
diff --git a/crates/openhuman-app/README.md b/crates/openhuman-app/README.md
new file mode 100644
index 0000000000..daf93e543c
--- /dev/null
+++ b/crates/openhuman-app/README.md
@@ -0,0 +1,100 @@
+# `openhuman-app`
+
+Thin Tauri v2 desktop host for OpenHuman on Windows, macOS, and Linux (Wry
+webview; no CEF). It links `openhuman_core` in-process and runs the core's
+HTTP/JSON-RPC server as a tokio task (`core_process.rs`) instead of spawning a
+sidecar binary — the core's lifetime is tied to the GUI process. Identities:
+Cargo package `openhuman-app`, library `openhuman`, binary `OpenHuman`. Only
+the Cargo package was renamed for the `crates/` layout; the library and
+executable names are shipped identities and are unchanged.
+
+See [`gitbooks/developing/architecture/tauri-shell.md`](../../gitbooks/developing/architecture/tauri-shell.md)
+for the full IPC command reference, window/tray behavior, and data-flow
+diagrams. This README covers what is specific to building and depending on
+this crate.
+
+## Separate Cargo world
+
+The root `Cargo.toml` `exclude`s this directory: this crate has its own
+`Cargo.lock` and `target/`, so root-only Cargo commands never resolve
+GTK/WebKit/Tauri. Build and check it explicitly:
+
+```bash
+cargo check --manifest-path crates/openhuman-app/Cargo.toml
+pnpm dev:app
+pnpm build
+```
+
+Its `[patch]` table mirrors the root manifest's tinymemory/tinyinference/
+tinytools/tinyflows/tinychannels pins and must be kept in sync — a drift here
+resolves two copies of the same crate as distinct Rust types.
+
+## Crate relationships
+
+- **`openhuman-rpc`** (`http-client` feature): `core_rpc.rs` re-exports
+ `bearer_header`, `redact_url_for_log`, and `HttpRpcResponse`, and calls
+ `post_json_rpc` for the host-side `relay_http_rpc` fallback.
+- **`openhuman_core`** (path dependency, package `openhuman`,
+ `default-features = false`): the embedded core does not inherit the core
+ crate's default feature set, so every default-ON product gate
+ (`channels`, `media`, `inference`, `voice`, `web3`, `documents`, `modules`,
+ `flows`, `skills`, `mcp`, `crash-reporting`, `http-server`,
+ `scheduler-gate`, `file-logging`, `contacts`, `runtime-node`, `hosting`)
+ must be forwarded explicitly in `Cargo.toml`. A gate missing from that list
+ vanishes from the shipped app silently — no build error, no test failure.
+ `scripts/ci/check-feature-forwarding.mjs` compares this list against
+ `scripts/ci/product-features.txt` and fails CI on drift.
+- `lib.rs` carries two `const _: () = assert!(...)` guards
+ (`VOICE_COMPILED_IN`, `HTTP_SERVER_COMPILED_IN`) that fail the build if
+ `voice` or `http-server` is ever dropped from the forwarded list — both
+ failure modes are otherwise silent and runtime-only.
+
+## Feature flags
+
+Shell-local gates from `[features]` in `Cargo.toml`. These are unrelated to
+the `openhuman_core` product-feature forwarding above and do not belong in
+`scripts/ci/product-features.txt`.
+
+| Feature | Meaning |
+| --- | --- |
+| `gateways` (default) | Routing the frontend to a core in a Docker container, over SSH, or both, via `tinybox`. |
+| `custom-protocol` | Serve the bundled `frontendDist` via `tauri://localhost` instead of the Vite dev server. Set automatically by `cargo tauri build`; never add to `default`. |
+| `sandbox-bubblewrap` | Reserved gate, currently empty. |
+| `e2e-test-support` | Forwards `openhuman_core/e2e-test-support` to expose `openhuman.test_reset`. Flipped on by the E2E build (`app/scripts/e2e-build.sh`). |
+
+## Entry points
+
+- `openhuman::run()` — starts the Tauri application (window, tray, plugins,
+ embedded core).
+- `openhuman::run_core_from_args(args)` — dispatches directly into
+ `openhuman_core`'s CLI without shelling out to a separate binary.
+- `main.rs` routes `OpenHuman core <args>` and `OpenHuman mcp` /
+ `OpenHuman mcp-server` to `run_core_from_args`; everything else starts the
+ GUI via `run()`.
+
+## Module map
+
+| Area | Modules |
+| --- | --- |
+| Core lifecycle | `core_process.rs`, `core_rpc.rs`, `process_kill.rs`, `process_recovery.rs`, `workspace_paths.rs` |
+| Gateways (feature-gated) | `gateway/` (`types`, `store`, `ops`, `provision`, `registry`, `commands`) |
+| Platform integration | `deep_link_ipc*.rs`, `native_notifications/`, `imessage_scanner/` (macOS `chat.db` reader), `mascot_native_window.rs`, `notch_window.rs`, `ptt_hotkeys.rs`/`ptt_overlay.rs`, `dictation_hotkeys.rs`, `window_state.rs` |
+| Updates / reset | `app_update.rs`, `local_data_reset.rs`, `reset_reboot_schedule.rs` |
+| Misc | `artifact_commands.rs`, `claude_code.rs`, `mcp_commands.rs`, `loopback_oauth.rs`, `directory_picker.rs`, `file_logging.rs`, `stderr_panic_hook.rs` |
+
+## Tests
+
+Behavior tests are `*_tests.rs` siblings: `lib_tests.rs`,
+`core_process_tests.rs`, `local_data_reset_tests.rs`, and
+`gateway/{ops,registry,store,types}_tests.rs`. `pnpm test:rust` runs them via
+`scripts/test-rust-with-mock.sh`.
+
+## Rules
+
+- Keep this crate thin. New behavior belongs in Rust-side IPC hooks, not
+ JavaScript injected into child webviews — audit new Tauri plugins for
+ `js_init_script`.
+- The `generate_handler!` call in `lib.rs` is the authoritative IPC command
+ list.
+- Do not restore CEF or CDP-scanner assumptions; the app runs on Wry. The
+ native iMessage scanner stays separate because it reads `chat.db` directly.
diff --git a/crates/openhuman-core/src/core/runtime/mod.rs b/crates/openhuman-core/src/core/runtime/mod.rs
index 299a6a15f2..93adce5a15 100644
--- a/crates/openhuman-core/src/core/runtime/mod.rs
+++ b/crates/openhuman-core/src/core/runtime/mod.rs
@@ -4,8 +4,9 @@
//! This module is the seam that separates *initialization* (workspace-bound
//! store setup — [`context`]) from *background services* (cron, channels,
//! heartbeat, update scheduler — [`services`]) so alternate hosts can compose
-//! them without going through the monolithic `run_server_inner`. See
-//! `docs/plans/pluggable-core/` for the full plan.
+//! them without going through the monolithic `run_server_inner`. See the
+//! pluggable-core work (`core::runtime::builder`, `core::runtime::context`) for
+//! the builder/context split this module composes.
//!
//! ## Shared tokio runtime tuning constants
//!
diff --git a/crates/openhuman-embed/README.md b/crates/openhuman-embed/README.md
index 1b1ec9156b..375fde0cec 100644
--- a/crates/openhuman-embed/README.md
+++ b/crates/openhuman-embed/README.md
@@ -50,3 +50,118 @@ if let Some(identity) = ProductIdentity::new("opencompany") {
Use `Core::raw()` only as a temporary escape hatch when the typed facade does
not yet model a required call. A repeated raw call is a candidate for a typed
embedding method in `openhuman-embed`.
+
+## Two entry points
+
+`Harness` builds its own runtime from typed inputs — the right choice for a
+host that has no `CoreRuntime` of its own yet:
+
+```rust,no_run
+use openhuman_embed::{Access, Harness, Provider, Workspace};
+
+# async fn demo() -> Result<(), Box<dyn std::error::Error>> {
+let harness = Harness::builder()
+ .provider(Provider::openai_compatible("https://api.example/v1", "sk-…").model("gpt-5"))
+ .workspace(Workspace::Ephemeral)
+ .access(Access::readonly())
+ .build()
+ .await?;
+
+let first = harness.run("Summarize what you can see.").await?;
+println!("{}", first.reply);
+
+let second = harness
+ .turn("Now list the risks.")
+ .session(&first.session_id)
+ .send()
+ .await?;
+println!("{}", second.reply);
+# Ok(())
+# }
+```
+
+`Core` is the typed facade shown above: a host that already built a
+`CoreRuntime` wraps it with `Core::from_runtime` and reaches sub-facades —
+`config()`, `auth()`, `agent()`, and, behind the `medulla` feature,
+`medulla()`.
+
+Both share the same process-scoped core state, so **only one `Harness` (or
+`Core::from_runtime`) may run per process**: the keyring master key, the RPC
+bearer, the global event bus, and the `Once`-guarded domain subscribers are
+process-scoped, and a second one would silently share them. `Harness::builder().build()`
+returns `HarnessError::AlreadyRunning` rather than letting that happen.
+
+Build the tokio runtime yourself — a turn is a large async state machine that
+overflows tokio's default 2 MiB worker stack once a sub-agent nests inside it —
+using
+[`AGENT_WORKER_STACK_BYTES`](../openhuman-core/src/core/runtime.rs) and
+`MAX_BLOCKING_THREADS` from `openhuman_core::core::runtime`:
+
+```rust,no_run
+use openhuman_core::core::runtime::{AGENT_WORKER_STACK_BYTES, MAX_BLOCKING_THREADS};
+
+let runtime = tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .thread_stack_size(AGENT_WORKER_STACK_BYTES)
+ .max_blocking_threads(MAX_BLOCKING_THREADS)
+ .build()
+ .expect("tokio runtime");
+```
+
+Other invariants worth knowing before wiring either entry point:
+
+- Set `config_path` together with `workspace_dir`.
+- Set a turn origin with its access tier; `Access::full()` configures both
+ access fields at once.
+- Copy skills into the harness's workspace rather than symlinking them — skill
+ discovery rejects symlinked bundles.
+
+## Feature flags
+
+Every feature on this crate is a pass-through to the same-named feature on
+`openhuman-core` (package `openhuman`): `default`, `http-server`,
+`inference`, `documents`, `hosting`, `modules`, `voice`, `web3`,
+`runtime-node`, `contacts`, `media`, `flows`, `skills`, `mcp`,
+`crash-reporting`, `medulla`, `channels`, `sandbox-landlock`,
+`sandbox-bubblewrap`, `peripheral-rpi`, `browser-native`, `whatsapp-web`,
+`file-logging`, `scheduler-gate`.
+
+Three of them also gate items on this crate's own public surface:
+
+- `medulla` — `Core::medulla()` and the `Medulla*` types.
+- `mcp` — `HttpHeader`, `McpAuthConfig`, `McpServer` (harness MCP server
+ configuration).
+- `skills` — harness skill loading.
+
+See [`docs/library-minimal-recipe.md`](../../docs/library-minimal-recipe.md)
+for a measured minimal-footprint feature set.
+
+## Examples and tests
+
+```bash
+# Against any OpenAI-compatible endpoint:
+OPENHUMAN_EXAMPLE_BASE_URL=https://api.openai.com/v1 \
+OPENHUMAN_EXAMPLE_API_KEY=sk-… \
+OPENHUMAN_EXAMPLE_MODEL=gpt-5 \
+ cargo run -p openhuman-embed --example run_turn -- "What can you see in this directory?"
+
+# Or against the machine's own configured inference, in its real workspace:
+OPENHUMAN_EXAMPLE_INHERIT=1 cargo run -p openhuman-embed --example run_turn -- "Hello."
+```
+
+Optional: `OPENHUMAN_EXAMPLE_BACKEND_URL` points non-inference backend calls
+somewhere specific, and `OPENHUMAN_EXAMPLE_SKILLS_DIR` supplies skill bundles.
+
+The repository root also has `examples/embed_headless.rs` (build a core and
+call plumbing methods without a harness) and `examples/embed_kernel.rs`.
+`tests/harness_embed.rs` is the end-to-end proof that `Harness` runs a real
+turn; `tests/public_api.rs` pins the host-facing embedding contract at compile
+time. Run both with `cargo test -p openhuman-embed`.
+
+## Relationship to other crates
+
+`openhuman-embed` depends only on `openhuman-core` (package `openhuman`) with
+`default-features = false` — every capability comes from a feature forwarded
+above. It does not depend on `openhuman-rpc`; that crate is for out-of-process
+callers (the TUI and, over the desktop shell's HTTP relay, the frontend), and
+the Tauri shell does not use `openhuman-embed`.
diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rs
index 77cf6ee879..3cd6b01210 100644
--- a/crates/openhuman-embed/src/lib.rs
+++ b/crates/openhuman-embed/src/lib.rs
@@ -1,7 +1,7 @@
//! Typed embedding facade over [`CoreRuntime`].
//!
//! [`CoreBuilder`](openhuman_core::core::runtime::CoreBuilder) gives an embedder a
-//! running core; [`CoreRuntime::invoke`] gives it JSON. This module is the
+//! running core; [`CoreRuntime::invoke`] gives it JSON. This crate is the
//! third piece: real Rust types, so a host application never writes
//! `serde_json::json!` or matches on an error string.
//!
diff --git a/crates/openhuman-rpc/src/lib.rs b/crates/openhuman-rpc/src/lib.rs
index 1b632aab47..e3e58e03b6 100644
--- a/crates/openhuman-rpc/src/lib.rs
+++ b/crates/openhuman-rpc/src/lib.rs
@@ -1,11 +1,19 @@
-//! Shared types for JSON-RPC / CLI controller surfaces.
+//! Shared JSON-RPC / CLI wire vocabulary for OpenHuman.
//!
-//! This module provides the foundational types and utilities for handling
-//! RPC outcomes across different domain modules. It ensures a consistent
-//! response format for both internal consumption and external presentation.
+//! This crate is linked by `openhuman_core` (re-exported there as
+//! `openhuman_core::rpc`), the Tauri shell (`crates/openhuman-app`), and the
+//! TUI (`crates/openhuman-tui`). It exists as a separate crate so the shell
+//! can speak the same wire format without linking the whole core, and it must
+//! stay free of domain types and runtime dependencies.
//!
-//! Domain `rpc` modules should use [`RpcOutcome`] to wrap their results,
-//! which facilitates consistent logging and error handling.
+//! - [`RpcOutcome`] and [`apply_log_envelope`] define handler results and the
+//! log envelope rule. Domain `ops.rs` operations return `RpcOutcome<T>`.
+//! - [`unwrap_rpc`] unwraps the client-side `result`/`data` envelopes.
+//! - [`StructuredRpcError`] and [`STRUCTURED_RPC_ERROR_SENTINEL`] are the
+//! typed error envelope decoded at the transport boundary.
+//! - Behind the `http-client` feature (default-on here, but disabled by the
+//! root workspace dependency so each consumer opts in): [`post_json_rpc`],
+//! [`bearer_header`], [`redact_url_for_log`], and [`HttpRpcResponse`].
use serde::Serialize;
use serde_json::json;
diff --git a/crates/openhuman-tui/README.md b/crates/openhuman-tui/README.md
new file mode 100644
index 0000000000..fae8f0aee6
--- /dev/null
+++ b/crates/openhuman-tui/README.md
@@ -0,0 +1,91 @@
+# `openhuman-tui`
+
+`openhuman-tui` is the standalone terminal client, embedding the core
+in-process. It is a [ratatui]-based agent cockpit with Chat, Logs, Config, and
+Settings tabs, persistent thread resume, command/file pickers, approvals, plan
+review, task/goal/agent/skill/MCP/artifact views, Git review, and a multiline
+composer. Chat uses the same `web_chat` surface the desktop app drives
+(`openhuman.channel_web_chat` / `openhuman.channel_web_cancel` +
+`web_chat::subscribe_web_channel_events`). It boots the core in-process — no
+HTTP, no sockets — via
+`CoreBuilder::new(HostKind::Cli).domains(DomainSet::full()).services(ServiceSet::none())`
+and streams a live transcript in the terminal.
+
+## Run / build
+
+See [Building the Rust Core](../../gitbooks/developing/building-rust-core.md)
+for toolchain setup.
+
+```bash
+cargo build --manifest-path Cargo.toml -p openhuman-tui
+cargo run -p openhuman-tui -- [OPTIONS] [PROMPT]
+```
+
+| Flag | Effect |
+| --- | --- |
+| `--thread <id>` | Attach to an existing conversation thread. |
+| `--new` | Force a new thread (default when `--thread` is omitted). |
+| `--resume` | Open the saved-thread picker (starts on the latest thread). |
+| `--last` | Resume the most recent thread. |
+| `--no-alt-screen` | Draw in the current terminal buffer. |
+| `-p`, `--provider <id>` | Override the inference provider for this session. |
+| `-m`, `--model <id>` | Override the model for this session. |
+| `-v`, `--verbose` | Debug-level file logging (never the UI — the TUI owns the terminal, so logging is file-only). |
+| a positional prompt | Sent immediately after startup. |
+
+`Ctrl+Tab`/`Alt+1-4` switch tabs, `/` opens the command picker (see
+`COMMANDS` in `src/composer.rs` for the full list), `Enter` sends,
+`Shift+Enter` inserts a newline, `Ctrl+C`/`Ctrl+D` quit.
+
+## Feature flags
+
+- `crash-reporting` (default on) — pulls in `sentry` and `dotenvy`, forwards
+ `openhuman-core/crash-reporting`, and makes `init_crash_reporting` install a
+ Sentry client and panic integration before the TUI takes over the terminal.
+ Without it, `init_crash_reporting` compiles to a no-op at the same call
+ site.
+
+## Crate relationships
+
+- Depends on `openhuman-core` directly and runs it in-process — there is no
+ need to spawn or connect to an `openhuman-core` binary.
+- Depends on `openhuman-rpc` only for `unwrap_rpc` (re-exported from
+ `src/cockpit.rs`) to decode the same RPC envelope shape the desktop app
+ handles over HTTP.
+- The ratatui/crossterm terminal dependencies live only in this crate.
+ `crates/openhuman-core/Cargo.toml` calls this out explicitly: "The
+ terminal-specific ratatui/crossterm cohort lives in the separate
+ `openhuman-tui` package," keeping the shared core free of UI dependencies.
+
+## Module map
+
+| File | Purpose |
+| --- | --- |
+| `app.rs` | Terminal chat event loop — bridges keyboard input, the web-channel broadcast, and a spinner ticker over `tokio::select!`. |
+| `cockpit.rs` | OpenHuman-native overlays and structured control-plane state. |
+| `composer.rs` | Keyboard-first, terminal-independent chat composer. |
+| `controls.rs` | Config and account actions for the tabbed terminal UI. |
+| `crash_reporting.rs` | Crash-reporting client ownership for the standalone terminal binary. |
+| `render.rs` | Ratatui rendering — a pure view over `TranscriptState` + `UiState`. |
+| `runner.rs` | CLI entry point (`run_from_cli`) — flag parsing, logging setup, and core boot. |
+| `state.rs` | Pure, terminal-free transcript reducer for the Chat tab. |
+| `terminal.rs` | Terminal setup/teardown with panic-safe restoration. |
+| `ui_state.rs` | Pure navigation and form state for the four terminal pages. |
+
+## Tests
+
+`state.rs` reducer tests run without a terminal since `TranscriptState` has no
+ratatui/crossterm/IO dependencies. `tests/cli_e2e.rs` covers process-boundary
+behavior (e.g. `--help` output) by spawning the built binary.
+
+```bash
+cargo test -p openhuman-tui
+```
+
+## Packaging
+
+`openhuman-tui` ships as the `openhuman-tui` binary alongside `openhuman-core`
+in the CLI tarball (`scripts/release/package-cli-tarball.sh`) and the apt
+packages (`scripts/release/build-apt-packages.sh`).
+
+[ratatui]: https://ratatui.rs
diff --git a/gitbooks/developing/building-rust-core.md b/gitbooks/developing/building-rust-core.md
index 9c61f43836..1312392650 100644
--- a/gitbooks/developing/building-rust-core.md
+++ b/gitbooks/developing/building-rust-core.md
@@ -83,9 +83,15 @@ cargo build --manifest-path Cargo.toml --bin openhuman-core
# Check the stable host-facing embedding facade
cargo check --manifest-path Cargo.toml -p openhuman-embed
+# Check the shared RPC contracts + HTTP client crate
+cargo check --manifest-path Cargo.toml -p openhuman-rpc
+
# Build the terminal frontend (embeds the core in-process)
cargo build --manifest-path Cargo.toml -p openhuman-tui
+# Check the desktop shell (separate Cargo world, own manifest/lockfile)
+cargo check --manifest-path crates/openhuman-app/Cargo.toml
+
# Release build
cargo build --manifest-path Cargo.toml --release --bin openhuman-core
@@ -131,8 +137,7 @@ Install:
Why:
-- `whisper-rs` compiles native code during the build.
-- On macOS this crate is built with the `metal` feature enabled in [`Cargo.toml`](../../Cargo.toml), so Apple toolchains and SDK headers need to be present.
+- Native dependencies (`cpal` for audio behind the `voice` feature, `objc2`-based crates behind `contacts`) compile C/Objective-C code during the build and need Apple toolchains and SDK headers present.
After Xcode CLT is installed, the core should build with the cargo commands above.