The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
docs: sync developer-guide tooling/gateway/CLI + user-guide with the facade/siblings layout (#102117)
Teknium4ab96371d2b4
diff --git a/website/docs/developer-guide/adding-platform-adapters.md b/website/docs/developer-guide/adding-platform-adapters.mdindex 9572c684a56..6415baa6b1f 100644--- a/website/docs/developer-guide/adding-platform-adapters.md+++ b/website/docs/developer-guide/adding-platform-adapters.md@@ -213,7 +213,7 @@ When you call `ctx.register_platform()`, the following integration points are ha| Integration point | How it works ||---|---|-| Gateway adapter creation | Registry checked before built-in if/elif chain |+| Gateway adapter creation | Registry checked before the built-in `_BUILTIN_ADAPTERS` table || Config parsing | `Platform._missing_()` accepts any platform name || Connected platform validation | Registry `validate_config()` called || User authorization | `allowed_users_env` / `allow_all_env` checked |@@ -633,21 +633,21 @@ Three touchpoints:2. **`load_gateway_config()`** — Add token env map entry: `Platform.NEWPLAT: "NEWPLAT_TOKEN"`3. **`_apply_env_overrides()`** — Map all `NEWPLAT_*` env vars to config-### 4. Gateway Runner (`gateway/run.py`)+### 4. Gateway Runner (`gateway/run.py` + `gateway/run_*.py` siblings)Six touchpoints:-1. **`_instantiate_adapter()`** — Add an `elif platform == Platform.NEWPLAT:` branch. The `_create_adapter()` wrapper binds every successful adapter to its gateway runner.+1. **`_BUILTIN_ADAPTERS` table** (`gateway/run.py`) — Add a `Platform.NEWPLAT: (module, class, check_fn, error_msg)` entry; `_instantiate_adapter()` (`gateway/run_adapters.py`) consults the plugin registry, then this table — there is no `elif` chain to extend. The `_create_adapter()` wrapper binds every successful adapter to its gateway runner.2. **`_is_user_authorized()` allowed_users map** — `Platform.NEWPLAT: "NEWPLAT_ALLOWED_USERS"`3. **`_is_user_authorized()` allow_all map** — `Platform.NEWPLAT: "NEWPLAT_ALLOW_ALL_USERS"`-4. **Early env check `_any_allowlist` tuple** — Add `"NEWPLAT_ALLOWED_USERS"`-5. **Early env check `_allow_all` tuple** — Add `"NEWPLAT_ALLOW_ALL_USERS"`+4. **Startup access-policy check** (`gateway/run_startup.py`) — Add `"NEWPLAT"` to `_ALLOWLIST_ENV_PLATFORMS` (derives both `NEWPLAT_ALLOWED_USERS` and `NEWPLAT_ALLOW_ALL_USERS`)+5. **Startup `_BUILTIN_ALLOW_ALL_VARS`** (`gateway/run_startup.py`) — derived from the same `_ALLOWLIST_ENV_PLATFORMS` tuple; nothing extra to add6. **`_UPDATE_ALLOWED_PLATFORMS` frozenset** — Add `Platform.NEWPLAT`### 5. Cross-Platform Delivery1. **`gateway/platforms/webhook.py`** — Add `"newplat"` to the delivery type tuple-2. **`cron/scheduler.py`** — Add to `_KNOWN_DELIVERY_PLATFORMS` frozenset and `_deliver_result()` platform map+2. **`cron/scheduler_delivery.py`** — Add to `_KNOWN_DELIVERY_PLATFORMS` frozenset and `_deliver_result()` platform map### 6. CLI Integrationdiff --git a/website/docs/developer-guide/adding-providers.md b/website/docs/developer-guide/adding-providers.mdindex ede1f622fd7..5d11383b698 100644--- a/website/docs/developer-guide/adding-providers.md+++ b/website/docs/developer-guide/adding-providers.md@@ -151,8 +151,8 @@ Examples from the repo:That same id should appear in:- `PROVIDER_REGISTRY` in `hermes_cli/auth.py`-- `_PROVIDER_LABELS` in `hermes_cli/models.py`-- `_PROVIDER_ALIASES` in both `hermes_cli/auth.py` and `hermes_cli/models.py`+- `_PROVIDER_LABELS` in `hermes_cli/models_catalog_static.py` (re-exported by `hermes_cli/models.py`)+- `_PROVIDER_ALIASES` in both `hermes_cli/auth.py` and `hermes_cli/models_catalog_static.py`- CLI `--provider` choices in `hermes_cli/main.py`- setup / model selection branches- auxiliary-model defaultsdiff --git a/website/docs/developer-guide/adding-tools.md b/website/docs/developer-guide/adding-tools.mdindex 975bdaca060..2219d738010 100644--- a/website/docs/developer-guide/adding-tools.md+++ b/website/docs/developer-guide/adding-tools.md@@ -181,7 +181,7 @@ registry.register(## Agent-Loop Intercepted Tools-Some tools (`todo`, `memory`, `session_search`, `delegate_task`) need access to per-session agent state. These are intercepted by `run_agent.py` before reaching the registry. The registry still holds their schemas, but `dispatch()` returns a fallback error if the intercept is bypassed.+Some tools (`todo`, `memory`, `session_search`, `delegate_task`) need access to per-session agent state. These are intercepted by the agent loop (`agent/tool_executor.py`, called from `agent/conversation_loop.py`) before reaching the registry. The registry still holds their schemas, but `dispatch()` returns a fallback error if the intercept is bypassed.## Optional: Setup Wizard Integrationdiff --git a/website/docs/developer-guide/extending-the-cli.md b/website/docs/developer-guide/extending-the-cli.mdindex fbd6da6f946..c1a2cafd303 100644--- a/website/docs/developer-guide/extending-the-cli.md+++ b/website/docs/developer-guide/extending-the-cli.md@@ -6,7 +6,7 @@ description: "Build wrapper CLIs that extend the Hermes TUI with custom widgets,# Extending the CLI-Hermes exposes protected extension hooks on `HermesCLI` so wrapper CLIs can add widgets, keybindings, and layout customizations without overriding the 1000+ line `run()` method. This keeps your extension decoupled from internal changes.+Hermes exposes protected extension hooks on `HermesCLI` so wrapper CLIs can add widgets, keybindings, and layout customizations without overriding the `run()` method or the TUI construction in `hermes_cli/cli_tui_mixin.py` (where these hooks are defined; `HermesCLI` in `cli.py` mixes it in). This keeps your extension decoupled from internal changes.## Extension pointsdiff --git a/website/docs/developer-guide/gateway-internals.md b/website/docs/developer-guide/gateway-internals.mdindex a96c3d930d3..2b7b5b378c4 100644--- a/website/docs/developer-guide/gateway-internals.md+++ b/website/docs/developer-guide/gateway-internals.md@@ -12,7 +12,7 @@ The messaging gateway is the long-running process that connects Hermes to 20+ ex| File | Purpose ||------|---------|-| `gateway/run.py` | `GatewayRunner` — main loop, slash commands, message dispatch (large file; check git for current LOC) |+| `gateway/run.py` | `GatewayRunner` facade — composes the `gateway/run_*.py` sibling mixins (startup, adapters, inbound, turn, busy, goals, notifications, shutdown, …) and `gateway/slash_commands_*.py` handlers || `gateway/session.py` | `SessionStore` — conversation persistence and session key construction || `gateway/delivery.py` | Outbound message delivery to target platforms/channels || `gateway/pairing.py` | DM pairing flow for user authorization |@@ -85,7 +85,7 @@ When an agent is actively running, incoming messages pass through two sequential1. **Level 1 — Base adapter** (`gateway/platforms/base.py`): Checks `_active_sessions`. If the session is active, queues the message in `_pending_messages` and sets an interrupt event. This catches messages *before* they reach the gateway runner.-2. **Level 2 — Gateway runner** (`gateway/run.py`): Checks `_running_agents`. Intercepts specific commands (`/stop`, `/new`, `/queue`, `/status`, `/approve`, `/deny`) and routes them appropriately. Everything else triggers `running_agent.interrupt()`.+2. **Level 2 — Gateway runner** (`gateway/run_inbound.py`): Checks `_running_agents`. Intercepts specific commands (`/stop`, `/new`, `/queue`, `/status`, `/approve`, `/deny`) and routes them appropriately. Everything else triggers `running_agent.interrupt()`.Commands that must reach the runner while the agent is blocked (like `/approve`) are dispatched **inline** via `await self._message_handler(event)` — they bypass the background task system to avoid race conditions.@@ -116,20 +116,16 @@ All slash commands in the gateway flow through the same resolution pipeline:1. `resolve_command()` from `hermes_cli/commands.py` maps input to canonical name (handles aliases, prefix matching)2. The canonical name is checked against `GATEWAY_KNOWN_COMMANDS`-3. Handler in `_handle_message()` dispatches based on canonical name+3. `_handle_message()` (`gateway/run_inbound.py`) looks the handler up by name — `_handle_<name>_command` on the `gateway/slash_commands_*.py` mixins — via `_command_handler_table` over `_IDLE_COMMANDS` / `_PLAIN_COMMANDS` in `gateway/run_busy.py`; there is no `if canonical == ...` chain4. Some commands are gated on config (`gateway_config_gate` on `CommandDef`)### Running-Agent GuardCommands that must NOT execute while the agent is processing are rejected early:-```python-if _quick_key in self._running_agents:- if canonical == "model":- return "⏳ Agent is running — wait for it to finish or /stop first."-```+While `_quick_key in self._running_agents`, `_dispatch_busy_slash_command()` in `gateway/run_busy.py` routes each recognized command by its `CommandDef.busy_policy` / `busy_handler`: a mid-run variant (`_busy_<key>_command`) if one exists, otherwise the normal handler when `busy_policy` allows it, otherwise a reject message ("⏳ Agent is running — `/model` can't run mid-turn…").-Bypass commands (`/stop`, `/new`, `/approve`, `/deny`, `/queue`, `/status`) have special handling.+Bypass commands (`/stop`, `/new`, `/approve`, `/deny`, `/queue`, `/status`) have mid-run handlers and are dispatched inline.## Config Sourcesdiff --git a/website/docs/developer-guide/tools-runtime.md b/website/docs/developer-guide/tools-runtime.mdindex 7fcbb4d7cd0..c863219eb26 100644--- a/website/docs/developer-guide/tools-runtime.md+++ b/website/docs/developer-guide/tools-runtime.md@@ -65,7 +65,7 @@ Each import triggers the module's `registry.register()` calls. Errors in optionaAfter core tool discovery, MCP tools and plugin tools are also discovered:-1. **MCP tools** — `tools.mcp_tool.discover_mcp_tools()` reads MCP server config and registers tools from external servers.+1. **MCP tools** — `tools.mcp_tool_discovery.discover_mcp_tools()` (re-exported by the `tools.mcp_tool` facade) reads MCP server config and registers tools from external servers.2. **Plugin tools** — `hermes_cli.plugins.discover_plugins()` loads user/project/pip plugins that may register additional tools.## Tool availability checking (`check_fn`)@@ -132,7 +132,7 @@ When the model returns a `tool_call`, the flow is:```Model response with tool_call↓-run_agent.py agent loop+agent loop (`agent/conversation_loop.py`, via `run_agent.py`'s `AIAgent` facade)↓model_tools.handle_function_call(name, args, task_id, user_task)↓diff --git a/website/docs/user-guide/features/credential-pools.md b/website/docs/user-guide/features/credential-pools.mdindex 05c0e988b61..83d525b3d93 100644--- a/website/docs/user-guide/features/credential-pools.md+++ b/website/docs/user-guide/features/credential-pools.md@@ -219,7 +219,7 @@ The credential pool integrates at the provider resolution layer:1. **`agent/credential_pool.py`** — Pool manager: storage, selection, rotation, cooldowns2. **`hermes_cli/auth_commands.py`** — CLI commands and interactive wizard3. **`hermes_cli/runtime_provider.py`** — Pool-aware credential resolution-4. **`run_agent.py`** — Error recovery: 429/402/401 → pool rotation → fallback+4. **`agent/turn_api_error.py`** — Error recovery: 429/402/401 → pool rotation → fallback## Storagediff --git a/website/docs/user-guide/features/delegation.md b/website/docs/user-guide/features/delegation.mdindex 95c7f949854..a4ce8aba3b3 100644--- a/website/docs/user-guide/features/delegation.md+++ b/website/docs/user-guide/features/delegation.md@@ -373,7 +373,7 @@ Control actions run synchronously in-turn (never backgrounded), are scoped to th### From the TUI / gateway (session-facing)-`steer_subagent(subagent_id, text)` in `tools/delegate_tool.py` is the redirection-side mirror of `interrupt_subagent()`: it queues text into a live child through the same mechanism as [`/steer`](/reference/slash-commands) — the text is appended to the child's last tool result at its next iteration boundary, the in-flight tool call is never cut, and the child sees it as an out-of-band user message. Programmatic hosts reach it through the session-scoped `subagent.steer` gateway RPC, which sits beside `subagent.interrupt`:+`steer_subagent(subagent_id, text)` in `tools/delegate_tool_registry.py` is the redirection-side mirror of `interrupt_subagent()`: it queues text into a live child through the same mechanism as [`/steer`](/reference/slash-commands) — the text is appended to the child's last tool result at its next iteration boundary, the in-flight tool call is never cut, and the child sees it as an out-of-band user message. Programmatic hosts reach it through the session-scoped `subagent.steer` gateway RPC, which sits beside `subagent.interrupt`:```json{"method": "subagent.steer", "params": {"session_id": "owning-ui-session", "subagent_id": "sa-0-1a2b3c4d", "text": "focus on pricing instead"}}diff --git a/website/docs/user-guide/features/hooks.md b/website/docs/user-guide/features/hooks.mdindex e30b3b0d397..75c28a6407a 100644--- a/website/docs/user-guide/features/hooks.md+++ b/website/docs/user-guide/features/hooks.md@@ -676,7 +676,7 @@ def my_callback(session_id: str, user_message: str, conversation_history: list,| `model` | `str` | The model identifier (e.g. `"anthropic/claude-sonnet-4.6"`) || `platform` | `str` | Where the session is running: `"cli"`, `"telegram"`, `"discord"`, etc. |-**Fires:** In `run_agent.py`, inside `run_conversation()`, after context compression but before the main `while` loop. Fires once per `run_conversation()` call (i.e. once per user turn), not once per API call within the tool loop.+**Fires:** In `agent/turn_context.py` (turn preparation for `run_conversation()` in `agent/conversation_loop.py`), after context compression but before the main `while` loop. Fires once per `run_conversation()` call (i.e. once per user turn), not once per API call within the tool loop.**Return value:** If the callback returns a dict with a `"context"` key, or a plain non-empty string, the text is appended to the current turn's user message. Return `None` for no injection.@@ -758,7 +758,7 @@ def my_callback(session_id: str, user_message: str, assistant_response: str,| `model` | `str` | The model identifier || `platform` | `str` | Where the session is running |-**Fires:** In `run_agent.py`, inside `run_conversation()`, after the tool loop exits with a final response. Guarded by `if final_response and not interrupted` — so it does **not** fire when the user interrupts mid-turn or the agent hits the iteration limit without producing a response.+**Fires:** In `agent/turn_finalizer.py` (`finalize_turn()`, called by `run_conversation()` in `agent/conversation_loop.py`), after the tool loop exits with a final response. Guarded by `if final_response and not interrupted` — so it does **not** fire when the user interrupts mid-turn or the agent hits the iteration limit without producing a response.**Return value:** Ignored.@@ -899,7 +899,7 @@ def my_callback(session_id: str, model: str, platform: str, **kwargs):| `model` | `str` | The model identifier || `platform` | `str` | Where the session is running |-**Fires:** In `run_agent.py`, inside `run_conversation()`, during the first turn of a new session — specifically after the system prompt is built but before the tool loop starts. The check is `if not conversation_history` (no prior messages = new session).+**Fires:** In `agent/conversation_loop.py`, inside `run_conversation()`, during the first turn of a new session — specifically after the system prompt is built but before the tool loop starts. The check is `if not conversation_history` (no prior messages = new session).**Return value:** Ignored.@@ -944,7 +944,7 @@ def my_callback(session_id: str, completed: bool, interrupted: bool,| `platform` | `str` | Where the session is running |**Fires:** In two places:-1. **`run_agent.py`** — at the end of every `run_conversation()` call, after all cleanup. Always fires, even if the turn errored.+1. **`agent/turn_finalizer.py`** — at the end of every `run_conversation()` call (`agent/conversation_loop.py`), after all cleanup. Always fires, even if the turn errored.2. **`cli.py`** — in the CLI's atexit handler, but **only** if the agent was mid-turn (`_agent_running=True`) when the exit occurred. This catches Ctrl+C and `/exit` during processing. In this case, `completed=False` and `interrupted=True`.**Return value:** Ignored.diff --git a/website/docs/user-guide/features/skills.md b/website/docs/user-guide/features/skills.mdindex b751f30487f..d9b81d518e4 100644--- a/website/docs/user-guide/features/skills.md+++ b/website/docs/user-guide/features/skills.md@@ -961,7 +961,7 @@ Useful when you want to share one skill without asking the user to subscribe to#### Trust levels for taps-New taps are assigned `community` trust by default. Skills installed from them run through the standard security scan and show the third-party warning panel on first install. If your org or a widely-trusted source should get higher trust, add its repo to `TRUSTED_REPOS` in `tools/skills_hub.py` (requires a Hermes core PR).+New taps are assigned `community` trust by default. Skills installed from them run through the standard security scan and show the third-party warning panel on first install. If your org or a widely-trusted source should get higher trust, add its repo to `TRUSTED_REPOS` in `tools/skills_guard.py` (requires a Hermes core PR).#### Tap management