Skip to content

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

docs(modules): document module layout and conventions

Steven Enamakelce13d24722f4
diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.md
index e994d23298..640e2c5ee5 100644
--- a/crates/openhuman-core/src/modules/README.md
+++ b/crates/openhuman-core/src/modules/README.md
@@ -1,190 +1,369 @@
# modules
-The native loadable-module host. A module is a first-party `cdylib`: `tinydocs`,
-`tinywallet`, `tinyjuice`, `tinyvoice`, `tinyruntime` (+
-`tinyruntime-nodejs` / `tinyruntime-python`), `tinymcp`, `tinyconnectors`,
-`tinybox`, `tinychannels`, `tinyhosts`, `tinysearch`, that
-speaks the tinybus module ABI. It is downloaded from a pinned GitHub release,
-verified against a digest compiled into [`registry.rs`](registry.rs), admitted
-through tinybus's ABI/manifest gates, and attached to a private in-process
-broker as an ordinary bus peer. The core then calls it like any other service.
-See [`mod.rs`](mod.rs)'s own `//!` for the full "what this buys, what it costs"
-argument; this file is the navigation layer over it.
-
-Feature-gated as `modules`, and unusually load-bearing for a feature: it is ON
-in both the contributor default set and the shipped product set, because the
-default feature set keeps it on for the shipped modules (see the
-comment above `default = [...]` in `crates/openhuman-core/Cargo.toml`).
-`documents`, `web3`, and `voice` each imply `modules` and each turn a
-per-module host half on inside this directory (`documents.rs`, `wallet.rs`,
-`voice.rs`) but do not gate the directory itself; `lib.rs` gates the whole
-directory on `modules`.
+This folder is the host for loadable native modules. A module is a first-party
+`cdylib` that speaks the tinybus module ABI and ships separately from the core
+binary: `tinycomputer`, `tinysearch`, `tinydocs`, `tinywallet`, `tinyjuice`,
+`tinyvoice`, `tinyruntime` (with its `tinyruntime-nodejs` and
+`tinyruntime-python` providers), `tinymcp`, `tinyconnectors`, `tinybox`,
+`tinychannels` and `tinyhosts`. The core downloads a module from a pinned
+GitHub release, checks it against a digest compiled into this crate, lets
+tinybus admit it, attaches it to a private in-process broker, and then calls
+it like any other bus service. Domains reach a module through the per-module
+host files here (`documents.rs`, `wallet.rs`, `voice.rs`, ...) rather than
+talking to tinybus themselves.
+
+The `//!` comments in [`mod.rs`](mod.rs), [`host.rs`](host.rs) and
+[`ops.rs`](ops.rs) carry the full argument for this design. This README is
+the map over them.
+
+## How it works
+
+### What a module buys and what it costs
+
+Moving a capability into a module removes its dependency tree from the core
+build instead of only gating it behind a feature. A document writer or an
+integration SDK no longer compiles into a binary that mostly does something
+else.
+
+The price is isolation. A loaded module shares this process's address space,
+privileges and crash domain. tinybus deadlines, bounded queues and caught
+panics contain ordinary misbehavior, not a segfault, and `dlopen` runs code
+before any symbol can be inspected. The ABI, manifest and digest gates decide
+what is admitted, never what is safe. Modules are first-party code that
+happens to ship separately; anything untrusted belongs in its own process.
+
+tinybus also never unloads a library. A module that was refused, faulted, or
+failed to initialize stays failed until the process restarts, so this host
+caches failures instead of retrying them.
+
+### Layering
+
+```text
+ domain code (tools, voice, web3, search, inference/tokenjuice, ...)
+ |
+ v
+ per-module host file documents.rs, wallet.rs, voice.rs, runtime.rs,
+ (typed calls, errors) desktop.rs, browser*.rs, connectors.rs, search/
+ |
+ v
+ ops::ensure_loaded* ---> registry::find(id) (compiled-in ModuleRecord)
+ | |
+ | v
+ | tinybus::module::resolution (one slot per id)
+ v
+ host::runtime() -> ModuleRuntime { ModuleHost, Connection, tokio handle }
+ | |
+ | +-- private Broker on a MemoryBus
+ v
+ runtime.proxy(bus_name, object_path) -> tinybus Proxy -> loaded module
+```
+
+### The module bus
+
+`host::runtime()` builds the module bus once per process. It starts a
+dedicated thread (`openhuman-module-bus`) with its own multi-threaded tokio
+runtime, creates a `MemoryBus` transport and a `Broker`, spawns the broker,
+wraps it in a tinybus `ModuleHost`, and connects the host's own `Connection`.
+Before returning it installs the `tokenjuice_host` callback on that
+connection. The result is stored in a `OnceLock` as a `ModuleRuntime` and
+lives until the process exits; there is no shutdown path because there is
+nothing a shutdown could reclaim.
+
+Modules get their own broker because `core::bus::BUS` (a `OnceBus`) builds
+its broker internally and never hands it out, while `ModuleHost::new` needs
+one. The consequence is that a module can serve requests but cannot publish a
+`DomainEvent`.
+
+The dedicated runtime keeps module transports alive across short-lived caller
+runtimes (`#[tokio::test]`, an embedder's task runtime). `ModuleRuntime::spawn`
+runs process-lifetime work on it and `ModuleRuntime::blocking` runs admission
+work on its blocking pool.
+
+Admission runs in tinybus's permissive mode on purpose. Strict mode also
+refuses a module whose rustc version string differs from the host's, and
+published artifacts are built by CI on whatever toolchain that runner had.
+Permissive mode still enforces the ABI revision, descriptor layout, target
+triple, pointer width, endianness, feature bits, and the refusal of a
+`panic=abort` module.
+
+### Loading a module
+
+Every caller goes through `ops::ensure_loaded(config, id)` or the bounded
+`ops::ensure_loaded_within(config, id, within)`. The steps, in order:
+
+1. If `config.modules.enabled` is false, fail with a message saying so.
+2. `registry::find(id)` looks up the compiled-in `ModuleRecord`; an unknown id
+ fails.
+3. `tinybus::module::resolution::global().claim(id)` returns `Done` (already
+ ready or already failed), `Wait` (someone else is resolving), or `Run`
+ (this caller goes first). Each module has its own slot, so unrelated
+ modules never queue behind each other.
+4. A `Run` caller spawns the resolution on the module runtime, so a caller
+ runtime that shuts down mid-load cannot cancel a resolution others are
+ waiting on.
+5. Every caller then waits on the slot. `within` bounds only the wait: a
+ caller that gives up gets `LoadError::StillLoading`, and the download keeps
+ running for the next caller.
+
+The resolution itself (`ops::resolve`) tries the cheapest source first:
+
+```text
+ already serving on the broker? (search path at boot, earlier load)
+ | no
+ v
+ local override? [[modules.overrides]] id = "..."
+ | no or TINYSEARCH_TEST_MODULE /
+ v TINYCONNECTORS_TEST_MODULE
+ module search path? OPENHUMAN_MODULE_PATH, then
+ | no platform data dirs (tinybus)
+ v
+ release cache (load_cached)
+ host_candidates() -> artifact keys this host can run, best first
+ record.asset_for(key) -> ReleaseAsset { host_key, archive, sha256 }
+ ReleasePlan { install_root, bundled_root, allow_download, ... }
+ load_first_admitted() tries each asset until one is admitted
+ |
+ v
+ prune_stale_versions() removes older cached versions of this module
+```
+
+Inside the release cache, tinybus looks for the archive in the bundled
+directory first, then in `install_dir/<id>/<version>/<host_key>`, and
+downloads only when `modules.allow_download` is on. On download it fetches the
+release's own `checksum.toml`, checks it against the digest pinned in the
+registry, hashes the archive, extracts it and `dlopen`s the library. All of
+that is synchronous, so it runs on the module runtime's blocking pool and a
+cold download never stalls other tasks. Later launches re-verify the cached
+artifact from disk instead of downloading again.
+
+A panic inside the loader is reported as an error carrying
+`crate::tools::status::MODULE_FAULT_MARKER` and "restart the app to try
+again", rather than unwinding into whoever was waiting.
+
+### Bundled archives
+
+Shipped builds carry the registry-pinned archives so normal use needs no
+runtime download. `scripts/release/stage-modules.mjs` stages them at build
+time (the oldest published key per OS and arch: `macos-15`, `ubuntu-22.04`,
+`windows-2022` or `windows-11-arm64`) as the `bundled-modules/` Tauri resource
+for desktop installers, under `/opt/openhuman/bundled-modules` in the Docker
+image, and beside the binary in the CLI tarball and bench bundle.
+
+`ops::bundled_releases_dir` resolves the directory from, in order, the path
+the host registered with `ops::set_bundled_releases_dir` (the Tauri shell does
+this in `crates/openhuman-app/src/lib.rs`), the `OPENHUMAN_BUNDLED_MODULES`
+environment variable, and `bundled-modules/` beside the executable. Only an
+existing directory counts. Bundled files go through the same digest and
+admission checks as downloaded ones. A plain `cargo build` host has no bundle
+and uses the release cache.
+
+### Install directory
+
+`ops::install_dir` is `modules.install_dir` when set, else
+`<user cache dir>/openhuman/modules`, else `<workspace>/modules` for headless
+containers with no cache directory.
+
+### Module configuration
+
+Some modules take a private configuration blob at load and on
+reinitialization. `ops::module_config` builds it per id: `search::module_config`
+for `tinysearch`, `desktop::module_config` (from `computer_config.rs`) for
+`tinycomputer`, and `connectors::module_config` for `tinyconnectors`.
+Everything else gets `{}`. When the connector configuration cannot be built
+(direct mode with no key, an unknown mode) the module still loads with `{}`,
+because its capability members need no route.
+
+The host files for those three modules fingerprint the configuration and call
+`Connection::reinitialize_module` when it changes, so a rotated credential or
+a sign-out reaches a module that is already serving. Secrets travel only in
+that configuration, never in an ordinary method call or an RPC reply.
+
+### Boot
+
+`boot::load_declared_modules` runs as a background bootstrap job
+(`core/runtime/services.rs`, gated on `ServiceSet::integrations`). It does two
+things. It loads every artifact on the module search path through
+`ModuleHost::load_search_paths`, so an operator-placed artifact wins over a
+download. Then it calls `ensure_loaded` for each `LoadPolicy::Eager` record.
+Every record in the registry is currently `LoadPolicy::Lazy`, so the second
+step does nothing today. Boot never fails because of a module, and it never
+downloads lazy modules: a user who never touches a feature never pays for its
+download, its `dlopen`, or its resident memory.
## Layout
-| Path | Purpose |
+### Loading machinery
+
+| Path | What it does |
| --- | --- |
-| `mod.rs` | Module rustdoc for the whole loading model; re-exports |
-| `registry.rs` (+ `registry/records_browser.rs`, `registry/records_docs_wallet.rs`, `registry/records_extra.rs`, `registry/records_mcp_connectors.rs`, `registry/records_memory_juice.rs`, `registry/records_runtime.rs`, `registry/records_voice.rs`, `registry/records_search.rs`) | The compiled-in table: every `ModuleRecord`, its published per-platform digests, and `find`/`ALL` |
-| `platform.rs` | Which published artifact (`ubuntu-24.04-x86_64`, `macos-15-arm64`, ...) belongs to this host, newest-compatible first |
-| `types.rs` | `LoadPolicy`, `ModuleRecord`, `ModuleSource`, `ModuleState`, `ModuleStatus`, `PlatformAsset` |
-| `host.rs` | The module broker: a dedicated process-lifetime tokio runtime, its `ModuleHost`, and the host's own `Connection` for calling into loaded modules |
-| (tinybus `module::resolution`) | One resolution slot per module id, replacing a single global lock so unrelated modules never queue behind each other. Lives in `vendor/tinybus`; `ops.rs` claims, completes and waits on `tinybus::module::resolution::global()`. The cache-path helpers (`artifact_dir`, `is_safe_path_component`, `prune_stale_versions`) live in `tinybus::module` too |
-| `ops.rs` | `ensure_loaded` / `ensure_loaded_within` / `state_of` / `LoadError`; the release cache under `install_dir`; failure caching |
-| `boot.rs` | What loads at startup: search-path artifacts, then every `LoadPolicy::Eager` record: deliberately not every registry entry |
-| `schemas.rs` | The `modules` RPC namespace (`list`, `status`, `load`) |
-| `documents.rs` | Host half of `tinydocs` (feature `documents`): the three document operations |
-| `browser.rs`, `browser_task.rs` | Typed TinyComputer `Browser*` calls, shared website policy, and browser tasks over `StartTask`/`AwaitTask`/`ContinueTask`; the browser engine remains in the loadable module |
-| `computer_config.rs` | The private TinyComputer configuration: decision model (`jev`), planner and rescue route (`planner`), and browser executable, rebuilt from `[computer]` and the stored credentials on every call |
-
-| `wallet.rs` | Host half of `tinywallet` (feature `web3`): confidential and split transaction-signing flows |
-| `voice.rs` | Host half of `tinyvoice` (feature `voice`): the voice primitives |
-| `runtime.rs` | Host half of `tinyruntime`: resolving a language runtime (via `tinyruntime-nodejs`/`-python`) and running code on it |
-| `connectors.rs` | Reaching `tinyconnectors`; egress policy, route selection, and webhook delivery stay in this crate even though scope enforcement moved into the module |
-| `search.rs` | Private TinySearch configuration, synchronous tool declarations from `tinysearch-bus`, and confidential execution calls; reloads persisted settings and refreshes a loaded module before invocation |
-| `tokenjuice_host.rs` | Host-owned ML callback served to the `tinyjuice` module |
-| `*_tests.rs` | Focused tests beside each file above |
-
-The browser website list controls document navigation, including redirects and
-link clicks. It is not a network sandbox for page subresources or DNS rebinding;
-an allowed page can still load resources from other hosts. Hosts that require
-private-network isolation must also restrict the browser process at the network
-layer.
-
-## Loading pipeline
-
-1. `registry::find(id)` looks up the compiled-in `ModuleRecord`.
-2. `resolution::table().claim(id)` gives the caller `Run`, `Wait`, or `Done`:
- the first caller for a module resolves it as a process-lifetime task;
- everyone else waits on a watch channel (`ops.rs`).
-3. Resolution order is cheapest first: already serving on the host's broker,
- a developer's `modules.overrides` (or a `*_TEST_MODULE` env var), the
- module search path (`OPENHUMAN_MODULE_PATH`, then platform data dirs), then
- the release cache.
-4. `tinybus::module::platform::host_candidates()` picks the ordered list of artifact keys this
- host can run; `ops::load_cached` hands them to `tinybus::module::load_first_admitted`, which tries each until one is admitted.
-5. The release cache (`tinybus::module::CachedRelease`) downloads if
- `modules.allow_download`, fetches the release's own `checksum.toml`, checks
- it against the digest pinned in `registry.rs`, hashes the archive, extracts,
- and `dlopen`s: on the module runtime's blocking pool so a cold download
- never stalls another task.
- Every shipped artifact carries the registry-pinned archives, staged at
- build time by `scripts/release/stage-modules.mjs` (oldest published key per
- OS/arch: `macos-15`, `ubuntu-22.04`, `windows-2022` / `windows-11-arm64`):
- desktop installers as the `bundled-modules/` Tauri resource, the Docker
- image under `/opt/openhuman/bundled-modules`, the CLI tarball and the bench
- bundle beside the binary. `modules::ops` resolves that directory from the
- host's `set_bundled_releases_dir`, then `OPENHUMAN_BUNDLED_MODULES`, then
- `bundled-modules/` beside the executable. The same archive digest and
- TinyBus admission checks run against these local files first, so normal use
- needs no runtime download. Plain `cargo build` hosts keep using the release
- cache.
-6. tinybus's ABI descriptor, manifest, and dependency gates decide whether the
- artifact is *admitted*; a faulted or refused module is recorded as
- `Resolution::Failed` in the resolution table (surfaced as
- `LoadError::Failed`) and never retried in this process: restart is the
- only recovery, because tinybus never unloads a library.
-
-`boot::load_declared_modules` does two things at startup: it loads search-path
-artifacts directly through the host, then calls `ensure_loaded` for every
-`LoadPolicy::Eager` record (none at present). It never fails the boot. Everything else is
-`LoadPolicy::Lazy` and resolves on first `ensure_loaded` call: deliberately
-not eager, so a user who never touches a feature never pays its download.
-
-## TinySearch
-
-`search/` is the host adapter for the TinySearch module (`vendor/tinysearch`),
-which owns every web-search provider, its tool schemas, and role dispatch.
-
-- `search/mod.rs` — `module_config` builds the private module configuration
- from `crate::search::providers` (the host's resolved policy): per-provider
- route (`managed` → `ProviderRoute::Backend`), direct keys and limits, the
- backend credential (`resolve_backend_credential`: API key as `x-api-key`,
- else the session JWT as a bearer), `x-sdk-name`, and the per-role provider
- order. `configured_tool_specs` computes the tool declarations synchronously
- from that same configuration.
-- `search/proxy.rs` — lazy load (`ensure_loaded_within`), private
- reinitialization when the configuration fingerprint changes (the first call
- after a load keeps the load-time configuration; a reinitialize that lands
- while the module is still initializing waits and retries), and serialized
- `ListTools` / `ExecuteTool` calls. `ExecuteTool` is an ordinary call: keys
- travel only in the configuration, never in a call.
-- Credentials: `refresh_loaded` runs after a search settings save and on
- `DomainEvent::CredentialChanged` (`search::credential_refresh`), so managed
- providers follow login and logout without waiting for the next call.
-- Tests and local development load a local build through
- `TINYSEARCH_TEST_MODULE` or `[[modules.overrides]]` (`id = "tinysearch"`);
- `scripts/test-rust-with-mock.sh` and CI build the pinned submodule. Release
- checksums are pinned in `registry/records_search.rs` from the published
- `checksum.toml`, never from a local build.
-
-## Contract crates
-
-Each loadable module has a small `*-bus` contract crate for interface names,
-method constants, request/response types, and its contract version:
-
-| Contract | Feature or role |
+| [`mod.rs`](mod.rs) | Design rustdoc for the whole loading model; re-exports `ensure_loaded`, `ensure_loaded_within`, `state_of`, `LoadError`, the controller lists and the public types. |
+| [`registry.rs`](registry.rs) | The compiled-in `ALL` table and `find(id)`. Records live in [`registry/`](registry/README.md), one `records_*.rs` file per module family. |
+| [`types.rs`](types.rs) | `ModuleRecord`, `PlatformAsset`, `LoadPolicy`, `ModuleSource`, `ModuleState`, `ModuleStatus`. |
+| [`host.rs`](host.rs) | The module bus: the dedicated runtime, `ModuleRuntime`, `runtime()`, `is_started()`. |
+| [`ops.rs`](ops.rs) | Resolution (`ensure_loaded*`, `resolve`, `load_cached`, `load_local`), per-module configuration, overrides, the bundled and install directories, and status reporting (`list`, `state_of`). |
+| [`boot.rs`](boot.rs) | Startup loading: search-path artifacts, then eager records. |
+| [`schemas.rs`](schemas.rs) | The `modules` RPC namespace and its handlers. |
+
+### Per-module host files
+
+| Path | Module | What it does |
+| --- | --- | --- |
+| [`documents.rs`](documents.rs) | `tinydocs` | `generate_docx`, `generate_pptx`, `extract_text`, `extract_document`, `render_pdf`. Inbound bytes ride a tinybus stream; produced documents are held by the module and pulled with `ReadOutput`, then released. Feature `documents`. |
+| [`wallet.rs`](wallet.rs) | `tinywallet` | `derive_account`, `sign_transaction_in_module`, `sign_message`, `export_key`. Key material goes only to an attested module whose attested digest is one the registry pinned (`attested_proxy`). Feature `web3`. |
+| [`voice.rs`](voice.rs) | `tinyvoice` | Intent routing, command extraction, wake-word and hallucination checks, capture preparation, WAV encoding, frame energies, and a `VadSession` driven from the always-on capture loop. Every call returns a `VoiceCallError` the caller falls back from. Feature `voice`. |
+| [`runtime.rs`](runtime.rs) | `tinyruntime` + providers | `ensure_language` loads the router and the language provider, then `resolve`, `execute`, `languages`, `pool_stats`. Settings (`settings_for`, `pool_settings_for`) are read from config on every call. |
+| [`desktop.rs`](desktop.rs) | `tinycomputer` | The shared proxy for TinyComputer: loads it with an 8 second bound, reinitializes it when its configuration fingerprint changes, and exposes `call`, `permissions`, `state`, `jev_ready`. |
+| [`computer_config.rs`](computer_config.rs) | `tinycomputer` | The private configuration: `jev` (decision model), `planner` (planner, rescue and output models), `browser` (Chrome path), `trace_path`. Rebuilt from `[computer]` and stored credentials on every call; `OPENHUMAN_COMPUTER_TRACE` turns tracing on. |
+| [`computer.rs`](computer.rs) | `tinycomputer` | `status` for the Computer settings page: lifecycle state, configured routes, and optionally what the module reports through `Describe`. |
+| [`browser.rs`](browser.rs) | `tinycomputer` | `BrowserClient` for the `Browser*` members, over the desktop proxy, plus the shared website policy. |
+| [`browser_task.rs`](browser_task.rs) | `tinycomputer` | Browser tasks over `StartTask` / `AwaitTask` / `ContinueTask`: `start`, `wait`, `resume`, `cancel`, `report`. The host keeps the policy (surfaces, origins, action budget, approvals). |
+| [`browser_task_report.rs`](browser_task_report.rs) | `tinycomputer` | What is kept when a task stops: a content-free log summary, and with tracing on the full report under `<workspace>/state/computer/tasks/`. |
+| [`browser_sites.rs`](browser_sites.rs), [`browser_sites/store.rs`](browser_sites/store.rs) | `tinycomputer` | Per-site memory of plans and elements learned by finished tasks, in `<workspace>/state/computer/sites/<site>.json`, with 30-day expiry. Fed back on `StartTask`; never reaches the agent's memory or prompts. |
+| [`connectors.rs`](connectors.rs) | `tinyconnectors` | `proxy`, `call`, `call_stateless`, `call_bare`, `reconcile_route_if_loaded`. Builds the route configuration (signed-in backend or the user's own Composio key) and reconciles it on every call so sign-out reaches the module. |
+| [`search/mod.rs`](search/mod.rs) | `tinysearch` | `module_config` from the host's resolved search policy, and `configured_tool_specs` computed synchronously from that same configuration. |
+| [`search/proxy.rs`](search/proxy.rs) | `tinysearch` | Lazy load, private reinitialization on configuration change, and serialized `list_tools` / `execute_tool`; `refresh_loaded` after settings saves and credential changes. |
+| [`tokenjuice_host.rs`](tokenjuice_host.rs) | `tinyjuice` | The reverse direction: an `MlHost` object the host serves at the contract's `ML_HOST_NAME` / `ML_HOST_PATH`, so the module can call the host's ML compressor and one tool-less model call for its summary stage. |
+
+`tinymcp`, `tinybox`, `tinychannels` and `tinyhosts` have registry records but
+no host file in this folder.
+
+## Key types and entry points
+
+- `ModuleRecord` (`types.rs`) is one compiled-in module: `id`, `description`,
+ `bus_name`, `object_path`, `version`, `release_url`, its `assets`, and its
+ `load` policy. `asset_for(host_key)` picks the artifact for a host key.
+- `PlatformAsset` (`types.rs`) is one published archive: the host key (for
+ example `ubuntu-24.04-x86_64`), the archive name, and its lowercase hex
+ SHA-256 from the release's `checksum.toml`.
+- `LoadPolicy` (`types.rs`) is `Lazy` (first use) or `Eager` (at boot).
+- `ModuleState` (`types.rs`) is the coarse state reported over RPC:
+ `Available`, `Loading`, `Ready`, `Failed`, `Unsupported`. `ModuleStatus`
+ wraps it with id, version, bus name and a `detail` that never carries a
+ path, a credentialed URL, or a payload.
+- `ops::ensure_loaded` / `ops::ensure_loaded_within` (`ops.rs`) are the only
+ way to load a module. `LoadError` separates `Failed` (terminal for this
+ process) from `StillLoading`.
+- `ops::state_of` and `ops::list` (`ops.rs`) report state without loading
+ anything.
+- `host::runtime()` (`host.rs`) returns the `ModuleRuntime`; its `proxy`
+ method is how host files reach a loaded module. `host::is_started` lets
+ status code answer without starting a broker.
+- `ops::set_bundled_releases_dir` (`ops.rs`) is called by the desktop host
+ before the core starts.
+
+## RPC surface
+
+All methods are in the `modules` namespace (`schemas.rs`), wired into the
+registry from `core/all.rs`:
+
+| Method | What it does |
| --- | --- |
-| `tinydocs-bus` | `documents` |
-| `tinyvoice-bus` | `voice` |
-| `tinyjuice-bus` | inference kernel |
-| `tinyruntime-bus` | runtime clients |
-| `tinywallet-bus` | `web3` (contract; the chain primitives are in `tinywallet-crypto`) |
-| `tinymcp-bus` | `mcp` |
-| `tinysearch-bus` | search provider declarations and bus payloads |
-| `tinychannels-bus` | channel vocabulary |
-| `tinyconnectors-bus` | `tinyconnectors` names and the Composio types |
-
-Rules: never redeclare a contract type in OpenHuman; call members through
-contract constants, not string literals; contract crates stay synchronous and
-free of I/O and runtime dependencies; shared wire behavior belongs in the
-contract, runtime/config/security policy stays in this host.
-
-## Security and operational invariants
-
-A loaded module shares this process's address space, privileges, and crash
-domain: it is first-party code that happens to ship separately, not a
-sandbox boundary. From `AGENTS.md`, do not weaken these:
-
-- Only the compiled registry (`registry.rs`) may select which artifacts can
- load. There is no RPC method to name an arbitrary path.
-- Pin release checksums verbatim from the release's own `checksum.toml`. Never
- compute a replacement digest from a local build: that would make the check
- agree with whatever was served instead of with what the release published.
-- Keep the ABI, manifest, dependency, and digest admission checks intact.
-- Never unload or repeatedly retry a faulted module in the same process; a
- refused or crashed module is terminal until restart.
-- Untrusted code belongs in a separate process, not in a module.
-- Never enable the `modules` feature directly on the unconditional `tinybus`
- dependency; forward it from OpenHuman's own `modules` feature
- (`modules = ["tinybus/modules"]`), so a `--no-default-features` build without
- `modules` does not pull in tinybus's loader.
+| `modules.list` | Status of every module in the registry. |
+| `modules.status` | Status of one module by `id`. |
+| `modules.load` | Resolve and load a module now instead of on first use; returns its status after the attempt. |
+| `modules.browser_check_readiness` | Load TinyComputer and briefly launch Chrome; returns `module_ready`, `chrome_ready` and a sanitized `error`. |
+| `modules.browser_forget_sites` | Forget learned site memory for one `site`, or for every site when omitted; returns how many were forgotten. |
+| `modules.computer_status` | TinyComputer state, decision and planner routes, and with `load` set, what the module reports through `Describe`. |
+
+No method takes a path or an arbitrary artifact. Only the compiled registry
+decides what can load.
+
+## Configuration
+
+`config::schema::modules::ModulesConfig` (`[modules]` in `config.toml`)
+controls whether and from where the compiled-in modules load, never what is
+loadable:
+
+- `enabled`: modules may load at all. When off, `modules.list` reports every
+ module as `Unsupported` even if one is still mapped from an earlier request.
+- `allow_download`: a missing module may be fetched from its pinned release.
+ Off pins the host to bundled or already-cached artifacts.
+- `install_dir`: overrides the release cache location.
+- `overrides`: `[[modules.overrides]]` entries (`id`, `path`) that load a
+ local build instead of the release. An override bypasses the digest check,
+ which is acceptable only because the operator named their own file.
+
+## Boundaries
+
+- The loader, ABI and manifest gates, release cache, per-id resolution table,
+ platform host keys (`tinybus::module::platform::host_candidates`) and the
+ cache-path helpers (`prune_stale_versions` and friends) belong to tinybus
+ (`vendor/tinybus`). Change them there.
+- Each module's behavior lives in its own repository under `vendor/`
+ (`tinydocs`, `tinywallet`, `tinyvoice`, `tinyruntime`, `tinycomputer`,
+ `tinysearch`, `tinyconnectors`, `tinyjuice`, `tinymcp`, `tinybox`,
+ `tinychannels`, `tinyhosts`). This folder holds only the host half of each
+ call and the host's policy around it.
+- Each module has a `*-bus` contract crate with its interface names, method
+ constants, request and response types, and contract version:
+
+ | Contract | Feature or role |
+ | --- | --- |
+ | `tinydocs-bus` | `documents` |
+ | `tinyvoice-bus` | `voice` |
+ | `tinyjuice-bus` | inference kernel |
+ | `tinyruntime-bus` | runtime clients |
+ | `tinywallet-bus` | `web3` (the chain primitives are in `tinywallet-crypto`) |
+ | `tinymcp-bus` | `mcp` |
+ | `tinysearch-bus` | search provider declarations and bus payloads |
+ | `tinycomputer-bus` | desktop, browser and task members |
+ | `tinychannels-bus` | channel vocabulary |
+ | `tinyconnectors-bus` | connector names and the Composio types |
+
+ Never redeclare a contract type here, and call members through the
+ contract's constants rather than string literals. Contract crates stay
+ synchronous and free of I/O. Shared wire behavior belongs in the contract;
+ runtime, configuration and security policy stay in this host.
+- Policy stays here even where the work moved into a module. For connectors
+ that means egress policy (`crate::security::egress`, applied before
+ `Execute`), route selection, and webhook delivery; scope enforcement belongs
+ to the module, and the host must not re-filter against a second copy of the
+ preference. For browser tasks it means allowed surfaces and origins, action
+ budgets, and approval of irreversible steps.
+- Callers outside this folder: `runtime::client` re-exports `execute`,
+ `resolve` and `RuntimeCallError` from `modules::runtime` so `runtime/`
+ compiles without the gate; `web3/seams.rs` and `web3/x402/seams.rs` use
+ `wallet.rs`; `tools/impl/document`, `tools/impl/presentation`,
+ `agent/multimodal.rs` and `agent/attachments/` use `documents.rs`;
+ `voice/always_on` and `voice/streaming.rs` use `voice.rs`;
+ `tools/impl/browser/` and `desktop/control/` use the TinyComputer files;
+ `integrations/composio/module_client.rs` uses `connectors.rs`;
+ `search/tools.rs` and `search/bus.rs` use `search/`; and
+ `inference/tokenjuice` calls `ensure_loaded(config, "tinyjuice")` and is
+ called back through `tokenjuice_host.rs`.
+
+## Gotchas
+
+- `lib.rs` gates the whole folder on the `modules` feature, which is in both
+ the contributor default set and the shipped product set. `documents`,
+ `voice` and `web3` each imply `modules` and turn on their host file here.
+ Never enable `modules` directly on the unconditional `tinybus` dependency;
+ it is forwarded from this crate's own feature (`modules =
+ ["tinybus/modules", ...]`), so a build without `modules` does not pull in
+ the loader.
+- Pin release checksums verbatim from the release's own `checksum.toml`.
+ Never compute a replacement digest from a local build: that check would
+ agree with whatever was served.
+- A failed module is terminal for the process. Do not add retries or an
+ unload path; the fix is a restart, and the error says so.
+- Keep the ABI, manifest, dependency and digest admission checks intact.
+- `ensure_loaded` waits without bound. Use `ensure_loaded_within` from any
+ path with its own deadline, and treat `StillLoading` as "ask again later".
+- The browser website list controls document navigation, including redirects
+ and link clicks. It is not a network sandbox: an allowed page can still
+ load subresources from other hosts, and DNS rebinding is not covered. Hosts
+ that need private-network isolation must restrict the browser process at
+ the network layer.
- Initialize recursive submodules before building:
`git submodule update --init --recursive vendor/`.
-## Used by
-
-- `crate::runtime::client`: the ungated facade re-exporting `resolve`,
- `execute`, `pool_stats`, and `RuntimeCallError` from `modules::runtime`, so
- a build without `modules` still compiles.
-- `core::all::all_registered_controllers`: wires the `modules` RPC namespace
- (`crate::modules::all_registered_controllers()`).
-- `config::schema::modules::ModulesConfig`: `enabled`, `allow_download`,
- `install_dir`, and `overrides` control only whether (and from where) the
- compiled-in modules in this directory load, never what is loadable.
-- The per-module host halves are called from their domains:
- `web3/wallet/chains/*` and `web3/x402` (`wallet.rs`),
- `tools/impl/{document,presentation}` (`documents.rs`), `voice/` and
- `inference/voice` (`voice.rs`), `integrations/composio/module_client.rs`
- (`connectors.rs`), and `inference/tokenjuice`, which `ensure_loaded`s
- `tinyjuice` and is called back through `tokenjuice_host.rs`.
-
-## Where next
-
-- [`modules/registry`](registry/README.md) for how a module's record is
- admitted (checksum, ABI, manifest).
-- [`modules/documents.rs`](documents.rs) for one concrete example of a module's
- host-side half, `tinydocs`.
-- `gitbooks/developing/performance.md` for how loading modules on demand
- (rather than linking everything in) keeps a minimal build small and a full
- one modular without paying for what a given install never uses.
+## Tests
+
+Tests sit beside each file as `<file>_tests.rs`. Run them with
+`cargo test -p openhuman modules::` or `pnpm debug rust modules`. Tests that
+need a real module load a local build through `TINYSEARCH_TEST_MODULE`,
+`TINYCONNECTORS_TEST_MODULE`, or `[[modules.overrides]]`;
+`scripts/test-rust-with-mock.sh` and CI build the pinned submodules.
+
+See also `gitbooks/developing/performance.md` for how on-demand modules keep a
+minimal build small.