Skip to content

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

docs: add README files for several core modules

Steven Enamakel45c41bc0f110
diff --git a/crates/openhuman-core/src/channels/controllers/README.md b/crates/openhuman-core/src/channels/controllers/README.md
new file mode 100644
index 0000000000..62548c459c
--- /dev/null
+++ b/crates/openhuman-core/src/channels/controllers/README.md
@@ -0,0 +1,39 @@
+# Controllers
+
+Owns the `channels.*` RPC namespace: provider metadata, connect/disconnect lifecycle, status, messaging, and per-provider auth flows (Telegram login, Discord OAuth link).
+
+## Files
+
+| Path | Purpose |
+| --- | --- |
+| `backend.rs` | `OpenHumanChannelBackend` — the OpenHuman implementation of `tinychannels::ChannelBackend`, the seam `tinychannels::controllers` operations call back into for config, outbound sends (routing through `relay_runtime` when the relay-websocket transport fronts a channel), and RPC-shaped results |
+| `definitions.rs` | Re-exports provider metadata (`ChannelDefinition`, `ChannelAuthMode`, `ChannelCapability`, `AuthModeSpec`, `FieldRequirement`, `all_channel_definitions`, `find_channel_definition`) from `tinychannels::controllers` |
+| `ops/` | Business logic behind each RPC handler, grouped by concern (connect, discord, messaging, telegram, yuanbao) |
+| `schemas.rs` | `ControllerSchema`/`RegisteredController` declarations and thin RPC handlers that deserialize params, call into `ops`, and shape the `RpcOutcome` |
+
+## RPC surface
+
+`channels.{list, describe, connect, disconnect, status, set_default, get_default, test, telegram_login_start, telegram_login_check, discord_link_start, discord_link_check, discord_list_guilds, discord_list_channels, discord_check_permissions, send_message, send_reaction, create_thread, update_thread, list_threads}` — declared in `schemas.rs::all_registered_controllers`, wired into the global registry from `crates/openhuman-core/src/core/all.rs` (`controllers::all_channels_registered_controllers()`, gated on the `channels` feature).
+
+## `ops/`
+
+| Path | Purpose |
+| --- | --- |
+| `connect.rs` (+ `connect_part_01.rs`, `connect_part_02.rs`) | `connect_channel`, `disconnect_channel`, `channel_status`, `test_channel`, `get_default_channel`/`set_default_channel`, `connected_channel_slugs`, `merge_listener_health` (test-only re-export) |
+| `discord.rs` | Discord OAuth link flow and guild/channel/permission listing |
+| `messaging.rs` | `channel_send_message`, `channel_send_reaction`, `channel_create_thread`, `channel_update_thread`, `channel_list_threads` — all call the backend REST API directly (`crate::api::rest::BackendOAuthClient`), not `relay_runtime` |
+| `telegram.rs` | `telegram_login_start`/`telegram_login_check` |
+| `yuanbao.rs` | Yuanbao-specific connect helpers |
+| `types.rs` | Shared request/response types for the ops layer |
+
+`connected_channel_slugs` (from `connect.rs`) is re-exported at `channels::controllers::connected_channel_slugs` for callers outside the controller registry, e.g. the welcome agent's onboarding status snapshot.
+
+## Wiring
+
+Registered under `DomainGroup` in `crates/openhuman-core/src/core/all.rs` (~line 585) via `controllers::all_channels_registered_controllers()`, behind `#[cfg(feature = "channels")]`.
+
+## Tests
+
+- `backend_tests.rs`.
+- `ops_tests.rs` (+ `ops_tests_part_01_tests.rs`, `ops_tests_part_02_tests.rs`), `ops/connect_email_config_tests_tests.rs`.
+- `schemas_tests.rs`.
diff --git a/crates/openhuman-core/src/integrations/task_sources/README.md b/crates/openhuman-core/src/integrations/task_sources/README.md
index e2593b95ba..4be5ba09bf 100644
--- a/crates/openhuman-core/src/integrations/task_sources/README.md
+++ b/crates/openhuman-core/src/integrations/task_sources/README.md
@@ -101,7 +101,14 @@ Subscribes:
- `DomainEvent::ComposioConnectionCreated` (domain filter `["composio"]`) via `TaskSourcesConnectionSubscriber` — fires a one-shot `ConnectionCreated` fetch for matching enabled sources. Registered once at startup (`register_task_sources_subscriber`, idempotent `OnceLock` handle).
-Startup wiring lives in `crates/openhuman-core/src/core/jsonrpc.rs` (registers the subscriber and starts the periodic poll).
+Startup wiring is split across two sites:
+
+- `crates/openhuman-core/src/core/jsonrpc.rs` (~2159) calls
+ `crate::integrations::task_sources::bus::register_task_sources_subscriber()`.
+- `crates/openhuman-core/src/core/runtime/services.rs` (~349) calls
+ `crate::integrations::task_sources::start_periodic_poll()` (alongside
+ `agent::task_dispatcher::start_board_poller()`) when the `ServiceSet`'s
+ `proactive_task_pollers` bootstrap job is enabled (documented at ~212).
## Persistence
@@ -115,9 +122,9 @@ Additive idempotent column migrations (`add_column_if_missing`) backfill `ingest
## Dependencies
- `crate::core::all` — `ControllerFuture`, `RegisteredController` for the RPC registry.
-- `crate::core::event_bus` — `publish_global`, `subscribe_global`, `DomainEvent`, `EventHandler`, `SubscriptionHandle` for event publish/subscribe.
+- `crate::core::bus` (`BUS`) + `crate::core::events::DomainEvent` — `BUS.publish`/`BUS.subscribe` for event publish/subscribe.
- `crate::config` (+ `config::rpc`) — `Config`, `load_config_with_timeout`; reads the `[task_sources]` block for defaults and the master switch.
-- `crate::memory::sync::composio::providers` — `get_provider`, `ProviderContext`, `NormalizedTask`, `TaskFetchFilter`, `ComposioProvider::fetch_tasks`; the actual external fetch + normalized task shape.
+- `crate::integrations::composio::providers` — `get_provider`, `ProviderContext`, `NormalizedTask`, `TaskFetchFilter`, `ComposioProvider::fetch_tasks`; the actual external fetch + normalized task shape.
- `crate::agent::triage` — `run_triage`, `apply_decision`, `TriageOutcome`, `TriggerEnvelope`; dispatches the proactive agent turn for `AgentTodoProactive` sources.
- `crate::threads::todos` (`todos::ops`) — `add`/`remove`, `BoardLocation`, `CardPatch`; the thread-scoped board cards are stored here. Also references `agent::task_board::TaskBoardCard` for `board_cards`.
- `crate::cron::scheduler_gate` — `wait_for_capacity` capacity semaphore; gates proactive triage turns behind background-AI throttling.
diff --git a/crates/openhuman-core/src/mcp/server/README.md b/crates/openhuman-core/src/mcp/server/README.md
index e100ef1702..7cbd5c0597 100644
--- a/crates/openhuman-core/src/mcp/server/README.md
+++ b/crates/openhuman-core/src/mcp/server/README.md
@@ -19,13 +19,16 @@ Opt-in **Model Context Protocol (MCP) server** that exposes a curated, security-
| --- | --- |
| `crates/openhuman-core/src/mcp/server/mod.rs` | Module docstring + private submodule decls; re-exports `run_http`/`HttpServerConfig`, `run_stdio_from_cli`, `tool_specs`/`McpToolSpec`. |
| `crates/openhuman-core/src/mcp/server/protocol.rs` | JSON-RPC 2.0 dispatch core: parses lines/values (single + batch), routes `initialize`/`ping`/`tools/*`/`resources/*`, builds success/error envelopes, negotiates protocol version. |
-| `crates/openhuman-core/src/mcp/server/tools.rs` | Tool catalog (`tool_specs`, `base_tool_specs`, `searxng_tool_spec`), input schemas, argument validation, `call_tool` dispatch, read/act policy enforcement, subagent execution, slug/key helpers. |
-| `crates/openhuman-core/src/mcp/server/write_dispatch.rs` | Write/audit pipeline for `memory.store`/`memory.note`/`tree.tag`: config load, act-policy enforcement, RPC dispatch to `openhuman.memory_doc_put`, audit-record write (success/rejection), PII-redacting arg summaries. |
+| `crates/openhuman-core/src/mcp/server/tools/` | Tool catalog and dispatch, split into `mod.rs` (facade — `types` stays ungated so `McpToolSpec` is one real type in both builds), `specs.rs` (`tool_specs`/`base_tool_specs`/`searxng_tool_spec` builders), `params.rs` (argument parsing/validation → RPC params), `dispatch.rs` (`call_tool`/`list_tools_result`, act-policy enforcement, subagent handlers). |
+| `crates/openhuman-core/src/mcp/server/write_dispatch.rs` | Write/audit pipeline for `memory.store`/`memory.note`/`tree.tag`: config load, act-policy enforcement, RPC dispatch to `openhuman.memory_doc_put`, audit-record write (success/rejection) via `crate::mcp::audit::record_write`, PII-redacting arg summaries. |
| `crates/openhuman-core/src/mcp/server/resources.rs` | Static `RESOURCE_CATALOG` of compile-time-embedded (`include_str!`) prompt markdown; `resources/list`, `resources/templates/list` (always empty), `resources/read`. Test cross-checks catalog vs `agent::agents::BUILTINS`. |
| `crates/openhuman-core/src/mcp/server/session.rs` | `McpSession` — captures + normalizes client name from `initialize` into a `source_type`; first observation locks the value. |
-| `crates/openhuman-core/src/mcp/server/http.rs` | Axum Streamable HTTP + SSE transport (`run_http`, `HttpServerConfig`): POST/GET/DELETE on `/`, session map, protocol-version checks, optional `Authorization: Bearer`, SSE keep-alive, session-id redaction. |
+| `crates/openhuman-core/src/mcp/server/http.rs` | Axum Streamable HTTP + SSE transport (`run_http`, `HttpServerConfig`): POST/GET/DELETE on `/`, session map, protocol-version checks, optional `Authorization: Bearer`, SSE keep-alive, session-id redaction. Gated on `all(feature = "mcp", feature = "http-server")` — the transport is axum-only. |
+| `crates/openhuman-core/src/mcp/server/local.rs` | Lazily-started, process-wide in-process loopback HTTP MCP server (`ensure_local_http`, `LocalMcpEndpoint`). Lets the sandboxed `claude` subprocess (Claude Code provider) reach OpenHuman's memory/tools over loopback without the MCP server inheriting Claude Code's OS jail; a per-process random bearer token stops any other local process from talking to it. |
+| `crates/openhuman-core/src/mcp/server/subagent_depth.rs` | Per-delegation-chain depth tracking for `agent.run_subagent`, propagated across the loopback MCP HTTP hop via the `X-OpenHuman-Subagent-Depth` header so nested Claude Code subagent calls are bounded without penalizing unrelated parallel callers. |
| `crates/openhuman-core/src/mcp/server/stdio.rs` | CLI entry `run_stdio_from_cli` (arg parse: `--transport`/`--host`/`--port`/`--auth-token`/`-v`/`--help`), logging init, stdio read/write loop (`run_stdio`). |
-| `crates/openhuman-core/src/mcp/server/tools_tests.rs` | Sibling `#[cfg(test)]` suite for `tools.rs` (via `#[path]`). |
+| `crates/openhuman-core/src/mcp/server/stub.rs` | The `mcp`-less mirror of `run_stdio_from_cli`, `ensure_local_http`/`LocalMcpEndpoint`, and `tool_specs` — disabled-error / empty-catalog bodies so always-on callers (the Claude Code driver, `tool_registry`) keep a stable surface. |
+| `crates/openhuman-core/src/mcp/server/tools_tests.rs` | Sibling `#[cfg(test)]` suite for `tools/` (via `#[path]`). |
## Public surface
diff --git a/crates/openhuman-core/src/memory/conversations/README.md b/crates/openhuman-core/src/memory/conversations/README.md
new file mode 100644
index 0000000000..e4552859b4
--- /dev/null
+++ b/crates/openhuman-core/src/memory/conversations/README.md
@@ -0,0 +1,58 @@
+# conversations
+
+Workspace-backed conversation thread/message storage — transcript
+persistence, not semantic indexing. This is the JSONL store of raw
+thread/message records plus a trigram/CJK-bigram index for cross-thread
+substring search; the summary-tree archival of the same transcripts is a
+different index answering a different question and lives in
+[`memory/tree/`](../tree/). See `mod.rs` for the full accounting of how this
+code came back from `tinycortex::memory::conversations` in #5560 — it is not
+repeated here.
+
+## Three parts
+
+- **`store/`** — the implementation: on-disk format, root lifecycle, sharded
+ metadata/message locks, the warm index cache, and CRUD/search. Everything
+ it exposes is re-exported from `mod.rs`, so callers always name
+ `crate::memory::conversations::{…}`, never the `store` subtree directly.
+- **`blocking.rs`** — `spawn_blocking` wrappers around every store entry
+ point. The store is synchronous and takes `parking_lot` locks across
+ fsync'd file I/O, so calling it from an `async fn` directly would park a
+ tokio worker thread for the whole wait; request paths must go through
+ `blocking` instead (#5156).
+- **`bus.rs`** — the `core::bus` subscriber
+ (`register_conversation_persistence_subscriber`) that mirrors inbound and
+ processed channel turns into the store, so channel transcripts (Slack,
+ Telegram, …) persist alongside the UI's own threads.
+
+## On-disk layout
+
+```text
+<workspace>/memory/conversations/
+├── threads.jsonl # append-only upsert/delete log of thread metadata
+└── threads/
+ └── <hex(thread_id)>.jsonl # one file per thread, its messages in order
+```
+
+`store/` also builds a trigram/CJK-bigram inverted index over message content
+in memory for cross-thread search (`inverted_index.rs`, `tokenize.rs`); the
+index is not itself persisted, it is rebuilt from the JSONL on load.
+
+## Callers
+
+Async request paths use the `blocking` wrappers. Grepping
+`memory::conversations::` finds the store used directly by
+[`threads/`](../../threads/) (`ops_part_01.rs`, `turn_state/store.rs`), by
+[`channels/`](../../channels/) (`host/adapters.rs`,
+`providers/telegram/remote_control.rs`, `runtime/startup_part_01.rs`) for
+mirroring channel turns, and by the agent harness/orchestration layer
+(`agent/harness/subagent_runner/`, `agent/orchestration/tools/`,
+`agent/task_session.rs`, `agent/tinyagents/host/agent_memory.rs`) for
+sub-agent and worker-thread transcripts.
+
+## Tests
+
+`store/*_tests.rs` covers the implementation (`store_tests.rs`,
+`store_tests_late.rs`, `store_tests_more.rs`, `store_concurrency_tests.rs`,
+`inverted_index_tests.rs`, `tokenize_tests.rs`, `types_tests.rs`);
+`blocking_tests.rs` and `bus_tests.rs` cover the two wiring parts.
diff --git a/crates/openhuman-core/src/platform/service/README.md b/crates/openhuman-core/src/platform/service/README.md
index 4ecb2088ce..1d58c21080 100644
--- a/crates/openhuman-core/src/platform/service/README.md
+++ b/crates/openhuman-core/src/platform/service/README.md
@@ -85,7 +85,7 @@ Both subscribers are registered idempotently from `crates/openhuman-core/src/cor
## Dependencies
- `crate::config` — `Config` (paths, config dir) for every lifecycle/path operation; `config::rpc::load_config_with_timeout` in the schema handlers.
-- `crate::core::event_bus` — `DomainEvent`, `EventHandler`, `SubscriptionHandle`, `publish_global` / `subscribe_global` / `init_global` for restart/shutdown orchestration.
+- `crate::core::bus::BUS` (`tinybus::OnceBus<DomainEvent>`) — `publish` / `subscribe` for restart/shutdown orchestration; `crate::core::events::DomainEvent` for the event catalog.
- `crate::core` (`ControllerSchema`, `FieldSchema`, `TypeSchema`) and `crate::core::all` (`ControllerFuture`, `RegisteredController`) — controller schema/registration contract.
- `crate::rpc::RpcOutcome` — standard RPC result envelope.
- External: `anyhow`, `serde`/`serde_json`, `tokio`, `async_trait`, plus OS CLIs (`launchctl`, `systemctl`, `schtasks`).
diff --git a/crates/openhuman-core/src/web_chat/ops.rs b/crates/openhuman-core/src/web_chat/ops.rs
index 4079bdf03e..9b53d680ac 100644
--- a/crates/openhuman-core/src/web_chat/ops.rs
+++ b/crates/openhuman-core/src/web_chat/ops.rs
@@ -1,3 +1,8 @@
+//! `start_chat`/`cancel_*`/`channel_web_*` operations: session cache
+//! (`THREAD_SESSIONS`), in-flight/parallel turn tracking, and per-thread
+//! budget-exhaustion correlation. Split across `ops_part_01..03.rs` and
+//! `include!`d here rather than declared as submodules.
+
#[cfg(test)]
#[path = "ops_budget_correlation_tests_tests.rs"]
mod budget_correlation_tests;
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index a0ed72ae63..088e4e3a82 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -1,3 +1,8 @@
+//! Forwards a running turn's `AgentProgress` stream into `WebChannelEvent`
+//! socket events and mirrors it into `TurnStateStore`. Also emits the
+//! `inference_heartbeat` liveness beat (see [`INFERENCE_HEARTBEAT_SECS`])
+//! so a long silent prefill can't trip the frontend's disconnect timer.
+
use serde_json::json;
use crate::core::socketio::{SubagentProgressDetail, WebChannelEvent};