HERMES_GATEWAY_EXTERNAL_SUPERVISOR is the only profile pin an
--external-supervisor gateway holds: the agent's own `hermes ...` commands
read it (_under_gateway_supervisor) to skip the sticky active_profile.
Stripping it from tool children sent a default gateway's agent onto another
profile after `hermes profile use work` (#74872 shape), and the auto-started
daemon lost HERMES_SUPERVISED_CHILD's pin the same way.
Both strip points now carry the pin as HERMES_GATEWAY_PROFILE_PIN, which
_under_gateway_supervisor and the dashboard's fixed-identity check read and
is_gateway_supervisor_process / is_supervised_gateway_launch never do, so a
gateway an agent starts still answers unsupervised.
Reported by @kshitijk4poor in the #145930 review.
Conflict: hermes_cli/env_loader.py import block. Kept the branch's
left_core_migration.profile_env_names import and main's ConfigBackend
switch (load_yaml_file_readonly no longer imported; _load_secrets_config
reads through config_backend.read_config_doc_readonly).
No main commit since 0c771d7a5b touches Copilot code; nothing to port.
LEFT_CORE rows gain three generic fields for a model-provider plugin:
- providers: the ids and aliases the plugin's profiles register. A name
nothing resolves to gets the install line appended on every "unknown
provider" surface (runtime resolution / Desktop error text via
auth.resolve_provider, /model, `hermes model`, `hermes auth add`);
resolve_runtime_provider installs the plugin first for a home that uses it
(the CLI and Desktop resolve the provider before the agent whose start runs
the migration exists); and hermes_cli.providers.get_provider never lets the
models.dev catalog stand in for such a name while the plugin is not loaded
(models.dev lists `github-copilot` at api.githubcopilot.com with
GITHUB_TOKEN: it would have sent a raw GitHub token there).
- profile_env: env names core kept profile-managed. env_loader's
_PROFILE_MANAGED_ENV_KEYS and config._EXTRA_ENV_KEYS read them statically
(env_loader runs before discovery), and the generic env writers refuse them
while the plugin is absent (the executable/argv authority its profile
declares once installed).
- notice: one more per-home sentence on every migration outcome.
First consumer: the github-copilot row (providers copilot + copilot-acp and
every alias). It is in use when copilot/copilot-acp is a provider the home
routes through: model, fallback chain, auxiliary tasks, delegation and its
fallback chain, MoA presets, cron job pins, auth.json active_provider, or
HERMES_INFERENCE_PROVIDER. A GH_TOKEN alone is not use. COPILOT_GITHUB_TOKEN
and the two base-URL overrides stay out of children as provider env (Tier 2),
as when core shipped Copilot. Its notice tells a profile with no token the
plugin reads (no COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN, no `manual`
credential-pool row or providers.copilot login: a gh_cli pool row was seeded
from `gh auth token`) to run `hermes auth add copilot`; the plugin no longer
reads gh or the Copilot CLI's token files. Read-only, never runs gh.
The unknown-provider hint helper moves out of auth.py (over the size cap)
into auth_error_copy.unknown_provider_hint.
Add hermes_cli/config_backend.py (config-config design §4.1, D10/D11): a
ConfigBackend protocol, the FileBackend (today's behaviour), selection by
HERMES_CONFIG_BACKEND only (default file; 'remote' and unknown values fail
closed with ConfigBackendUnavailable), and path-level helpers
(read_config_doc, read_config_doc_readonly, config_version, config_exists,
write_config_key, write_config_document, supports_file_tooling).
Migrate every direct reader/stat/exists/bypass writer of a user config.yaml
to the helpers (config.py loaders + caches, config_effective, env_loader,
gateway, TUI, CLI watchers, cron, tools, profiles, logging, time). File
tooling (config edit, backups, xAI migration rewrite, raw dashboard editor)
checks supports_file_tooling() first; migrations skip write-back without it.
Add scripts/check_config_yaml_readers.py (CI lint next to the writers gate)
that rejects a direct read of a config path outside the backend.
The Desktop Accounts tab only offered in-app device-code login to four hardcoded
providers (_DEVICE_CODE_STARTERS) and carried a hand-written copilot-acp card; the
`hermes model` flows for copilot / copilot-acp and the effort-picker branch lived in
core. They now go through generic ProviderProfile fields (providers/base.py, L6 block):
- account_card / account_status: a profile customises (or adds) its Accounts card.
- start_device_login / poll_device_login / save_device_login: data-only device-code
hooks; core owns the wait loop, cancellation and the profile-scoped atomic save, so
/api/providers/oauth/<id>/start and /poll serve any profile that fills them.
- model_setup_flow: a provider's own `hermes model` step ahead of the generic one.
- setup_reasoning_efforts: the setup effort picker's per-model levels.
The copilot plugin fills them in setup.py (flow moved verbatim; Desktop device login
reuses the terminal flow's OAuth app, RFC 8628 polling and COPILOT_GITHUB_TOKEN), and
copilot-acp keeps its card/flow via its own setup.py. setup_migration reads the
profile's ambient_credentials flag (lane L2) instead of a slug. Review-bot comment
attributions in voice code are reworded.
hermes webapp builds the bundle when it is stale, starts the gateway and
opens a one-use link the gateway mints over its private control socket.
On macOS the server cannot verify a one-use link's peer, so the command
prints the gateway's private link and never opens it. --status and
--sign-out ask the running gateway; sign-out also works with no gateway
running. A named profile served by the default gateway opens on that
profile.
- run_agent / gateway shutdown / cli + hermes -q atexit / /browser and the
browser.manage RPC import cleanup_*, emergency_cleanup_all_sessions,
get_cloud_provider, get_browser_engine, the lightpanda status pair and the
CDP override + supervisor helpers from tools.browser_session_{lifecycle,
cloud,cdp} and tools.browser_lightpanda;
- per-turn cleanup reads browser.headed through is_headed_mode() only (the
AGENT_BROWSER_HEADED fallback is gone with agent-browser);
- tests repointed; tests that only covered browser_vision / the built-in
tool wrapper are dropped, the browser child env is credential-free per
the session layer, and the codex MCP list must name core tools only.
Hermes spawns its own CLI as `python -m hermes_cli.main`. Run that way the
module executes as __main__, and a later `import hermes_cli.main` loads a
second copy whose import-time _apply_profile_override sees the argv the
first one already stripped and HERMES_HOME at the root, so it follows a
sticky active_profile: `--profile default` (setup's import child,
spawn_unmanaged_gateway's root selector) ran in the other profile. The
__main__ module now registers itself as hermes_cli.main before the
override runs, so the later import reuses it.
A home with sync sources (import-sync.json) that upgraded without
`hermes update` (a Docker image swap) has no agent-importers plugin, and
when the scheduled `hermes import-agent --sync` is its only Hermes process
no agent or gateway start ever runs the left-core recovery: every run
failed with the moved-command hint. A command a left-core plugin registers
now runs that recovery for the active home before plugin commands are
discovered (same lazy-install policy and backoff), so the install lands and
the command runs in the same invocation.
`hermes claw` (hermes_cli/claw.py) and the openclaw-migration optional skill
moved into the agent-importers plugin (hermes-official-plugins #140/#141), which
keeps `hermes claw migrate|cleanup` as the older spelling of
`hermes import-agent openclaw`. Core drops them with their tests (ported to the
plugin) and the eval leg that loaded the skill's script.
Setup: hermes_cli/setup_agent_import.py replaces setup_migration's OpenClaw
offer. On a first-time `hermes setup` it checks ~/.openclaw (or ~/.clawdbot /
~/.moltbot), ~/.claude, ~/.codex and ~/.cursor; when any is found it asks
"Import your setup from <found>?" (default yes), shows a checklist when more
than one was found, installs agent-importers through the normal catalog install
(or enables it when present), then runs `hermes import-agent <agent>` for each
pick in a child process, which previews and asks first. OpenClaw gets
--migrate-secrets, as core's step did. Nothing found, a no, or
HERMES_NONINTERACTIVE: no prompt, nothing installed. The skip-configured-section
offer now follows any import that changed config.yaml or .env.
LEFT_CORE: `claw` joins the agent-importers row as old_cli, so `hermes claw`
without the plugin names the install. No automatic install for it: an OpenClaw
migration is one-shot and leaves no state that needs the plugin later.
Docs: import guide, OpenClaw guide, cli-commands, quickstart, bundled
cli-reference; locale tips and README pointers.
The Claude Code / Codex CLI importer (hermes_cli/agent_import.py,
agent_import_sync.py, the import-agent subparser and its tests) now
ships as the official agent-importers catalog plugin, which also adds
Cursor. The command spelling, flags and the per-profile import-sync.json
manifest are unchanged.
Migration: a LEFT_CORE row (cli=import-agent) makes the old spelling,
run without the plugin, print the install line for the active home.
Only homes with a registered sync source (import-sync.json, which
scheduled --sync runs read) get the plugin installed automatically; a
one-shot import leaves no other trace, so everyone else installs it when
they next need it.
hermes profile create --sync-imports keeps copying import-sync.json (a
plain file at the profile root); it no longer imports the importer.
`hermes mcp serve` (mcp_serve.py) moves to the official mcp-serve plugin in
hermes-official-plugins, which registers `hermes mcp-serve` and also carries
the `--tools` mode from #83364.
- delete mcp_serve.py and tests/test_mcp_serve.py (the suite moved with it)
- drop the serve subparser, its dispatcher branch, the mcp agent-subcommand
row and the inline MCP discovery path only `mcp serve` reached
- LEFT_CORE row (command + old_command): `hermes mcp serve` and a bare
`hermes mcp-serve` without the plugin print the new spelling and the
install line on stderr. MCP clients live outside Hermes, so no home shows
the feature in use and nothing installs automatically.
- docs, locale tips and the bundled cli-reference point at the plugin
agent/transports/hermes_tools_mcp_server.py stays: the codex_app_server
runtime launches it as its hermes-tools MCP server.
`hermes -c`, `--resume latest` and `session.resume latest` skipped every
0-message row as a launch stub (min_message_count=1). A first prompt is
durable in session_admissions from admission on, but its transcript row is
written only at turn start, and a restart in between leaves the admission
`unknown` with no messages. In that window both selectors picked the older
conversation and the new prompt went there.
search_sessions(skip_launch_stubs=True) now keeps a row that has messages
or owns any admission, before LIMIT. A read-only store from before the
runtime tables has no session_admissions, so messages alone decide there.
Test: test_latest_skips_a_newer_empty_launch_stub[queued|unknown] (red on
the previous head: both selectors returned the older session).
The trailing comment described the search_sessions calls below, not the
_session_db() context manager it trailed. Moving it above the calls
would grow main.py past its line cap; the gateway resolve_latest_session
comment and the stub-skip commit already explain min_message_count=1.
The gateway insert now stamps created_source (previous commits). A 0-message
local-<hex> launch stub left by a crash or failed resume therefore matches
created_source='cli' and is the newest row, so `hermes -c`, `--resume latest`
and `session.resume latest` picked the empty stub over the real conversation
(CLI-31; on main the stub stayed NULL, which hid it from the same lookup).
search_sessions gains min_message_count, a WHERE on the existing
s.message_count column applied before LIMIT (the same filter
list_sessions_rich already supports). The owner's resolve_latest_session and
the client's _resolve_last_session both pass 1. Stubs are not deleted, so this
adds no writer.
Existing latest-lookup fixtures that created message-less sessions now give
those sessions one message, as a real resumable session has.
Credit: #139058 (@KoNit-K) proposed the same placeholder repair as #138838 for
CLI-31 and is closed as its duplicate.
Co-authored-by: KoNit-K <konit.block@protonmail.com>
Resolves the hermes_cli/cli_tui_mixin.py conflict from #141501 landing: main moved _Panel to
hermes_cli/cli_panel.py and this branch moved the wrap helpers to hermes_cli/cli_tui_wrap.py.
Keep both moves: import _Panel and the wrap helpers, define neither here.
Refs #134889 (N8)
main.py and cli_tui_mixin.py are over the file-size cap, and the N8
resume recreate and the TUI-26 consumed-stop branch grew them. The
code-health ratchet asks for the growth to be offset in the same PR.
Moved unchanged:
- _import_foreign_resume and the new resume worktree recreate go to
hermes_cli/main_resume_args.py.
- _wrap_rows and _prefix_wrapped_rows go to hermes_cli/cli_tui_wrap.py.
Refs #134889 (N8)
Quitting a clean, idle `hermes --tui -w` session removes its tree and
branch (N8). The session's policy froze that cwd, so a later resume
had every turn refused workspace_unavailable.
The launcher now records each tree it creates in the profile's
tui_worktrees.json. A resume (`--tui --resume`, `--tui -c`, classic
`--resume`/`-c`; all go through _resolve_chat_session_args) whose
session cwd is such a missing tree recreates it at the same path
before attaching. It uses the branch when that survived, else a new
branch of the same name from the repo's current HEAD, and locks the
tree for the session. Only a recorded path directly under the repo's
.worktrees/ is created. Any other missing directory is left alone.
The CLI docs list every keep reason, the resume recreate, and the
remaining quit-time race.
Refs #134889 (N8)
cmd_chat built cli.main's kwargs from _CHAT_PASSTHROUGH and a few explicit
keys, and neither had api_key or base_url, although cli.main takes both.
So `hermes chat --cli --api-key K --base-url U` launched the classic CLI on
the profile's credential and endpoint: the session's policy froze no key
(credential_ref null). The TUI refuses the two flags and points users to
exactly this command.
Add both to the classic CLI's kwargs only. _CHAT_PASSTHROUGH stays as is:
_launch_tui gets that table and doesn't take them (_TUI_UNFORWARDED
refuses them first).
Refs #134889 (CLI-34)
(cherry picked from commit 4f4e31e93997f813c5e1c4f0892b93efc5925658)
The salvaged change keyed interactive on "not gateway", so `cron run/tick`
(scheduled, nobody at the console) and `mcp serve` (stdin carries the MCP
protocol stream, so input() would eat a protocol frame) still prompted.
Allowlist the foreground commands instead of denylisting one service.
register_from_config() asked for consent whenever sys.stdin.isatty() was
true. A hidden console (the Windows .vbs / Scheduled Task launcher) and NUL
both report a TTY, so gateway startup, every secondary-profile load and the
force-reload re-registration blocked in input() on the event-loop thread
until the liveness watchdog exited 75 (#120356); `hermes gateway run`
itself blocked the same way before the loop started (#127822).
Make "never prompt" explicit instead of guessing from the TTY:
register_from_config() takes interactive=False by default, and only the
foreground CLI path in hermes_cli/main.py passes interactive=True, never for
`gateway run`. An unapproved hook is declined with the existing warning,
which now names the allowlist file of the profile it must be approved in.
record_consent_from_config() (the classic CLI's own consent step) keeps
prompting.
Direction from the maintainer triage on #120356; the running-loop decline
idea is from #120362 by @KoNit-K.
Fixes#120356
On top of the salvaged routed-profile lookup: every refusal in
`hermes webhook subscribe` (bad name/profile, secret reuse on rebind,
--deliver-only conflicts, unknown or ambiguous --cron-job) and the
webhook-disabled gate now return 1, and `hermes webhook` forwards the
handler's code to the process exit, so a script can tell no route was
written. Tests drive the real `hermes` entry point.
Pre-existing before #106742 (the default-profile resolve_job_ref call and
the exit-0 path are both at d04056d609); the wrong-profile lookup only
bites when --route-profile names a multiplexed secondary. Needs a live
retest on a multiplexed install with a cron job in a secondary profile.
Refs #139332
Refs #134889 (CRON-2)
Refs #140138
After the cutover no local surface fired pre_command where the command runs.
slash.exec and command.dispatch (classic CLI forwards, Ink TUI, Desktop) never
fired it, and the classic CLI fired it from its own second copy of the plugin.
- The gateway fires pre_command for every recognized command a local session
runs, under the session's profile: before the handler for commands it runs
itself (slash.exec, command.dispatch; an accepted TUI read fires once inside
the read path), and for commands the classic CLI runs in its own process
through the new command.observe (plain data: the command as typed and its
arguments). command.observe replies first, so the CLI never waits on a
plugin. The hook arguments keep main's values: surface and platform "cli"
on every local surface, session_key the session id.
- It fires only for commands that run. A busy rejection or a named refusal
fires nothing; during a turn it fires when the busy dispatcher accepts the
command, so a refused /goal, /loop or empty /queue or /steer fires nothing
either. Every command that does run mid-turn fires, as main's CLI did,
except messaging's escape hatches (/stop and the approval controls).
- Each delivery waits out its callback on its own thread, never the shared
executor, with at most one delivery in flight per session: one session's
deliveries fire in order and a slow callback never holds up another
session's. The hook dispatcher's existing bounds apply
(plugins.hook_callback_timeout and its abandoned-worker cap), and with
plugins.isolation: host the hook runs in the plugin host. pre_command takes
that bounded path everywhere, so off the gateway its callbacks also run on a
worker thread.
- On a gateway session the classic CLI loads no plugin code. It reads skills,
plugin commands and plugin toolsets from the gateway (commands.catalog,
scoped to the session's own folder, and plugins.list) for /help, skill
dispatch and completion, /tools and the status and banner fallbacks. -s and
skills.auto_load are rendered in the gateway, and /reload-skills and
/skills install rescan there and drop the CLI's cached catalog. These reads
are cached per gateway life and never served once the connection has hung
up. The "Unknown toolsets" warning comes from the gateway (a new
unknown_toolsets field when the session opens). An older gateway without
command.observe gets one named notice, and nothing fires locally.
- The canonical gateway connection serves plugins.list for its profile:
loaded plugins with tool/hook/command counts, load error, toolsets and
portable MCP server names (optional fields added to the contract; TS and
OpenRPC regenerated). On a gateway session the CLI's /plugins reads it
instead of this process's plugin manager. Off the gateway the in-process
paths are unchanged.
Key-less inject_message (B2-11), which the classic CLI's own plugin copy
used to serve, is handled in the next commit.
Refs #134889 (PLG-7)
Refs #139523
Review of #139067 (teknium1, unsupportedpastels, greptile):
- a launch's --accept-hooks survives a failed allowlist write (accept_for_launch)
- gateway run --accept-hooks keeps approving hooks added after start
- config + allowlist are read under the same lock as the apply, so no stale snapshot lands last
- a malformed hooks: entry or allowlist record adds but never removes
- register_from_config never re-asks for an already-wired hook
- skipped hooks warn once per process; TUI --resume carries --accept-hooks
Since #106742 every `hermes chat` turn runs in the gateway, which registered shell hooks once at
startup with no TTY. The classic CLI lost main's first-use "Allow this hook to run? [y/N]" prompt,
`--accept-hooks` was dropped on the full-parser chat path (only HERMES_ACCEPT_HOOKS=1 worked), and
hooks added, approved, removed or revoked after the gateway started never took effect until a
gateway restart.
- The classic CLI asks for consent on its own terminal before it opens its gateway session
(skipped for a remote gateway and for --safe-mode / --ignore-user-config launches).
- `--accept-hooks` on chat exports HERMES_ACCEPT_HOOKS, which rides session.create.
- The gateway re-syncs the profile's hooks from its live config on every local session create /
resume (new shell_hooks.sync_from_config): newly configured or approved hooks register, removed or
revoked ones are unregistered, under one lock hold. Consent is the allowlist or an opt-in in
force (hooks_auto_accept / HERMES_ACCEPT_HOOKS), as on main. It never prompts or writes, a
re-sync failure never blocks opening the session, and an empty (failed-open) config or an
unreadable allowlist adds but never removes, so a fail_closed guard is never disarmed by a
half-saved file or a failed allowlist write.
- `--accept-hooks` on session.create records consent (record_consent_from_config); the resume that
follows registers. register_from_config keeps its old add-only contract for every other caller.
- `hermes hooks revoke` text now says a running gateway drops the hook at the next session open.
Regression from 46a5a627 (teknium1, Oct 12; cherry-picked from 4dbd7426, merged with #106742),
which moved hook registration out of the classic CLI process.
Refs #134889 (CLI-5).
375 commits from main (0e427d788d). 24 files conflicted; the resolutions that carry a decision:
- /initiate-setup: main removed the command (25bf722063). Its gateway rewrite, CLI handler and the
Desktop kickoff go with main; this branch's command-layer admission of it is dropped too
(gateway/session_commands.py _PROMPT_COMMANDS, its slash.exec test row, the parity doc row), and
the Desktop slash dispatcher loses the `hidden` option that only the kickoff used.
- Code this branch moved out of its old file, carrying main's edits to the moved copy:
first-contact notes (gateway/run_turn.py -> run_turn_prepare.py: no message/setup_command),
the TUI agent factory (tui_gateway/server.py -> agent_factory.py: onboarding toolsets at build,
setup_beat/set_theme lifecycle cards, no cli platform extras on a coding selection), the serve
lifespan (web_server.py -> web_server_app.py standalone_lifespan: first-install probe before the
state.db reconcile, onboarding due answer after the setup bootstrap), and the compression child
publish (the shared _publish_compression_child_on_conn reads the parent's model_config).
- agent/auxiliary_client.py: both import changes (_route_key from main; this branch's move of
_without_structured_output_format).
- Desktop: main's onboarding run (decideOnboarding, OnboardingEnd, card-waiting Send) replaces the
kickoff; this branch's prepared-submission slash path, request_id on session.create and
PreparedImageRecovery stay. Pool-limits imports are dropped (this branch removed the pool).
createBackendSessionForSend takes main's (preview, overrides) signature.
- ci.yaml detect job: main's `ref: inputs.commit` plus this branch's sparse checkout.
- package.json / lock: main's vitest 4.1.11 plus this branch's ws 8.21.1.
- Generated: gateway-contract.openrpc.json regenerated; parity doc regenerated.
HERMES_GUEST_ONBOARDING was a process-wide launch gate: with it set, every CLI,
gateway and serve boot minted an anonymous Nous account and any guest (a
connector guest included) carried inference. It is gone from Python.
- hermes_cli/welcome_trial.py: claim_desktop_free_tier() mints a guest, stamps
welcome_claim on it and marks the machine. A table of blockers decides
eligibility: the desktop's local backend only (never SSH, URL, cloud, CLI or
gateway), nous.guest on, no Nous identity, no provider, and a machine that
never used Hermes (install_state; the unpackaged desktop may pass
assume_fresh). grandfather_existing_guest() keeps the trial for a guest that
already chatted on nous/welcome; connector-only guests never qualify.
- anon_auth.free_inference_active() replaces guest_enabled(): a stamped guest on
the local desktop backend. The resolver rung, the active-provider check, the
picker row, the sign-in offer and guest_without_free_tier (inference, status,
account, pool readers) all read it. ensure_portal_identity is connectors-only
plus the claim; every token exchange names its purpose.
- No boot mint: free_tier_bootstrap only records who carries inference (and runs
the grandfather check); the CLI and gateway boot hooks are deleted, and so is
the inference re-mint after a dead credential (a lost claim is never
re-claimed).
- onboarding.start claims for a new run before the chat exists; a failed claim
is error 5079 and writes nothing, so the next launch tries again. A rerun
never claims. onboarding.state answers eligible only on the local desktop
backend when the trial or a configured provider can carry the first chat.
- Sign-in from any guest takes the promotion path (connected apps carry over).
- Deleted CLI/gateway free-tier copy: the startup line, both /status lines, the
one-time CLI notice, the banner's route model and their locale keys.
`hermes model` points a guest at `hermes auth upgrade`.
Main's epilogue printed `hermes --tui --resume 20261012_185208_a67483`; a
canonical session printed its 70-char `local-<64 hex>` id (FINDINGS row 36).
The epilogue now prints the id's 22-char prefix when it names only that
session, and `--resume` resolves a unique `local-` prefix back to it. An
ambiguous prefix and every stored id print whole, as before.
(cherry picked from commit 0a4c66ca6736c4df42443b9f8caab40302dc8c7a)
(cherry picked from commit 3f2f14ab0996cc5f51528881d227fdb6dfcb7781)
- hermes_cli/main.py: one early return for chat launches covers MCP discovery and hook /
webhook registration (main.py stays under its line cap).
- the status bar's background counts move to gateway_tools.background_counts (keeps
_get_status_bar_snapshot at its complexity cap).
(cherry picked from commit c970238f5f65e17627d99c8c95856770b6908c3b)
main.py's read-only `_session_db()` lookups (bare `-c` MRU via `_resolve_last_session`,
`--resume` title/id resolve, recorded cwd) filtered on main's `source='cli'` label, which the
gateway's interactive rows do not carry (`local`, surface in `created_source`). Bare `-c` after a
`-Q` run continued a different session. The lookup handle is now the same SurfaceLabelReader the
CLI's session store reads through.
LEDGER: DB-READ-013 (bare -c), FLAG-014 (harness 16_flags bare_c_create).
(cherry picked from commit fec0a72ca28f1a9b4b423ad589c652901eaacc2a)
Main's `_create_titled_session` minted an id and wrote the row and title through a local
SessionDB writer. On the gateway path that row had no local receipt, so its first turn failed
("couldn't start the model connection: runtime_coordination_required") and the CLI process
wrote state.db. It is now `session.create {title}` (the owner's own resolve -> create -> title
step, so concurrent programmatic callers converge); main's resolve / stderr copy / exit codes are
unchanged. The bare `-c --create-if-missing` warning was already main's.
Tests: test_chat_c_fail_loudly's creation cases now drive a stand-in for the gateway create
(they asserted the local write this removes).
LEDGER: FLAG-014.
(cherry picked from commit 8ec030ac39a71b00f0c508edd5751c4b583900d8)
The gateway session runs every turn and owns MCP servers, shell hooks, outbound webhooks,
state.db / checkpoint maintenance and async delegations (session policy, owner housekeeping).
The CLI process no longer:
- waits on / starts MCP discovery before its (gateway-backed) agent build or on the Termux
deferred path;
- registers shell hooks / outbound webhooks for `hermes` / `hermes chat` launches
(accept_hooks still rides on session.create);
- runs state.db archive/prune/VACUUM or checkpoint pruning at startup (a second writer);
- tears down MCP servers or interrupts async delegations on exit.
LEDGER: NEW-startup-trim (DB-WRITE-023, IPS-057, IPS-058, IPS-059, IPS-140).
(cherry picked from commit 4dbd74263cb3a36eb73c932cc61be805d08aac08)
_resolve_continue_arg wrote the titled row from the CLI process
(_create_titled_session: a registry writer). The gateway then refused to
adopt that pre-authority row while the CLI held its active-session lease
(runtime_coordination_required), so the create, the --query-file resend and
the title resume all failed where main answers. The classic path now asks the
gateway (session.create with `title`, resolved-or-created under the owner's
lock); the TUI keeps main's local row.
tests/hermes_cli/test_gateway_chat_title_live.py: the witness asserts no write
path (no SessionDB opened read-write, no INSERT/UPDATE/DELETE on state.db from
the CLI pid) instead of no SessionDB import; a read-only reader in the CLI is
allowed. The sid comes from main's -Q `session_id:` stderr line.
Test: test_chat_c_fail_loudly.py::test_create_if_missing_sets_resume (red before:
the CLI wrote state.db itself).
scripts/check --only health --base cli-base reported 10 blocking items on the rewired files:
- BLE001 on the gateway seams' deliberate broad catches: reviewed allow comments with the reason;
- HX013: the interrupt test waits for the turn's admission (tests.waiting.wait_until) instead
of sleeping; the scripted frame gap keeps an allow comment (the delay is the behaviour);
- CC on CLIInfoMixin.show_banner: the gateway banner and its warning lines are two helpers;
- FILE_LINES on hermes_cli/main.py: _bypass_chat_launch moves to main_tui_launch.py next to the
other launch-surface predicates, and the cmd_chat comment is shorter.
Now 0 blocking, 1 advisory (HX012 on GatewayConnection.start, pre-existing).
(cherry picked from commit a6b2d399d10de2c9bce7cd6c3c7b41a08526e54f)
The maintainer's requirement is main's classic CLI, unchanged, with the gateway
behind the agent seam. cmd_chat and cli.main() handed every classic launch to the
thin gateway REPL (hermes_cli/gateway_chat_view.py). Now:
- cmd_chat: only stream-json and the --safe-mode / --ignore-user-config bypass keep
the gateway transport client; interactive and -q/-Q reach cli.main exactly as on
main. The TUI flag refusal applies to --tui launches only.
- cli.py is byte-identical to origin/main (the launch_from_kwargs hand-off and the
"refused on the gateway path" docstring are gone).
- The fast chat path restores main's deferred-startup hints for the interactive
prompt (HERMES_DEFER_AGENT_STARTUP / HERMES_FAST_STARTUP_BANNER, accept_hooks).
The agent itself becomes gateway-backed at the AIAgent seam in the next commits.
Test: tests/hermes_cli/test_classic_cli_routing.py (red on cli-base: 3 failed).
(cherry picked from commit b0f08281a3f905cc1da0a1cb0822238b02e2a441)
Conflicts (2 files, 1 hunk each); every main-side change is kept, ported to
where the branch moved the code:
hermes_cli/kanban_db.py (build_worker_context helpers _ctx_cap .. _ctx_comments)
main: f5a6651231c/d56e357556f coerce foreign/text timestamps on read; in
_ctx_role_history the "Recent work" stamp became
_ctx_stamp(_to_epoch(row['ended_at']) or 0, now) instead of int().
branch: moved the whole _ctx_* helper block into hermes_cli/kanban_db_context.py
(kanban_db.py imports it back), deleting it from kanban_db.py.
merged: kept the branch's deletion in kanban_db.py and applied main's change in
kanban_db_context.py::_ctx_role_history as
_ctx_stamp(_kb._to_epoch(row['ended_at']) or 0, now). Main's other
timestamp coercions in kanban_db.py (Task/Run/Comment/Attachment/Event
from_row, _TASK_EPOCH_COLUMNS, release_stale_claims,
_extend_live_stale_claim, task_age) auto-merged unchanged.
hermes_cli/web_server.py (_lifespan)
main: d7830c6f42 reworded one comment in the free-tier bootstrap block
("the ONE place its identity is created" -> "the one boot-time creator
of its identity"; guests are now also created on first connector use).
branch: moved _lifespan's body into hermes_cli/web_server_app.py::app_lifespan.
merged: kept the branch's relocation and applied main's comment rewording in
web_server_app.py.
Merge-induced health fix (no conflict marker; the combination tripped the ratchet):
apps/desktop/src/app/session/hooks/use-cwd-actions.ts::changeSessionCwd
main: 63ed3caa4ba/dbc538547fc grew the function (statusbar cwd change for the
focused chat / tile runtime ids) to CC 20.
branch: added the session_busy refusal mapping (sidebar.projects.moveBusy) in
its catch, +1 branch -> CC 21 > target 20 (scripts/check health blocking).
merged: both behaviours kept; the busy-error mapping moved verbatim into a
module-level cwdChangeError(err) helper. Health back to 0 blocking.
Check: every line main added between 1fd1827726 and 3b63f7b0a4 (317 files) is
present in the merged tree.
Fixes from an adversarial review of the two previous commits:
- Several Connectors-page RPCs fire at once on page load. When the first
mint failed (429, portal down), each queued caller minted again in turn,
because the cooldown was checked before the locks. _reconcile_and_provision
now re-checks the failure memo under the locks, and a None result no
longer clears the memo.
- connectors.operation.status / .wake (polls) no longer create the identity:
creation moved out of _account_gate_closed into _account_identity_error,
which only the page-load, list and connect RPCs call.
- A failed creation on connectors.list returns the failure copy instead of
"available: false", so the page and setup card can say why.
- The model sees "Hosted connectors could not be set up." before the free-tier
copy, and inside a cooldown the wait still left, not the original one.
- tool_search's not_set_up hint carries the last failure, so the model tells
the user instead of retrying into the cooldown.
- Comments and docs that described the launch gate and the boot path as the
only creator now say what is true.
A user with no Nous sign-in could use connectors only inside the store desktop
build, where the boot bootstrap mints a guest because HERMES_GUEST_ONBOARDING=1.
On the plain CLI, TUI, messaging gateway and other desktop builds the
manage_connections tool was hidden, so connectors were unreachable.
Now any user with no Nous identity sees manage_connections, and the guest
identity is created when they first ask for an app:
- connectors_available() also admits a user with no identity who may get one
(guest_identity_pending: nous.guest is not false, no bearer, no terminal
mint refusal). No network, so the check_fn stays cheap.
- managed.managed_client(), the real gateway client behind every hosted
manage_connections action, calls ensure_guest_identity() first. The mint is
synchronous and bounded by the existing 5 s budget; a failure returns the
free-tier copy with its wait.
- The desktop Connectors page RPCs (both account gates) create it the same way:
opening the page is the user asking for apps, and the page has no rows to
click without an identity.
- The model's read legs (tool_search, tool_describe, connector calls) never
mint. With no identity they make no request and answer not_set_up, whose
hint names manage_connections. Before, the same case said "sign in to Nous
again".
The free model is unchanged: guest_enabled() still requires the launch gate,
so a guest created for connectors never becomes the inference provider. Only
the connectors path reads the new guest_allowed() (nous.guest), through
managed_tool_gateway._read_nous_provider_state. Boot minting is unchanged.
The setup chat's apps card no longer mints on its own; its rows come from the
connectors.list RPC, which now creates the identity.
Conflicts (5 files):
- gateway/run_notifications.py: main lifted completion ownership into a new
GatewayNotificationOwnershipMixin (run_notifications_ownership.py); the branch had lifted the
update watcher into GatewayUpdateNotificationsMixin. The mixin inherits both. Kept both sides
of the completion-event metadata (the branch's automation identities + local display card,
main's proven_session_id / completion_ids), and in the async-delegation group the branch's
authority admission runs first, then main's terminal-parent drop. Neither function main moved
was changed on the branch.
- gateway/run_turn.py: the branch moved _hmwa_resolve_session into run_turn_prepare.py; main's
one changed line there (the resolver receives the proven session id and completion ids) is
ported into run_turn_prepare.py.
- hermes_cli/subcommands/sessions.py: keep both main's lazy cmd_sessions and the branch's
rename/discard parser helper.
- ui-tui: keep both canonicalEn and connectorsEn catalogs; keep the branch's interfaces import
plus main's findSlashCommand import.
Review on ee2d14de98:
- `hermes connectors` registers in _build_cli_parser next to `mcp`, not
from inside the mcp builder. The sessions lazy handler moves into its
own subcommands module to keep main.py under its size cap.
- `disconnect --alias` can pick a retired account (shown by
`accounts --all`); reconnect still never targets one.
- The connect link and its instruction flush at once, so a piped run
shows the link before the wait.
- The two reference links in the tool-gateway guide go up two levels.
The connectors parser registers from the mcp builder, next to the command
it sits beside in --help, so main.py does not grow. $isBlocked reads a key
list instead of a 21-term boolean, and the accounts overlay's app picker
and link view are their own components.
One app can now hold several named accounts. The CLI lists them (retired
ones folded behind --all), connects a new named account and waits for the
browser step, renames by name or app label, and removes one account after
a confirmation. Ctrl-C settles the open operation so the next connect of
that app is not blocked.
Conflicts: tests/hermes_cli/test_finite_chat_delegation.py and
tests/tools/test_completed_process_results.py, where main's lint sweep (0006a5e229) added
check=False to subprocess.run calls this branch had rewritten. Kept the branch's test bodies
and carried check=False onto their subprocess.run calls.
Two halves of one defect: a launch-only key could be silently replaced by
the profile's credentials, and once an owner restart revoked it nothing
could supply it again.
1. `--tui` dropped the flags: _CHAT_PASSTHROUGH / _launch_tui carry no
api_key, base_url or reasoning, and Ink's localCreationOptions never
sends them, so the session ran on the profile's endpoint and key. The
smaller correct fix is to refuse them, as classic chat refuses flags it
cannot honour (exit 2, naming `hermes chat --cli ...` and the config
keys). Forwarding the key would need a non-inherited channel into the
Node child (never a daemon-visible env var) plus an Ink change in
another lane; recorded in NOT_COVERED as the follow-up.
_refuse_unforwarded_tui_flags lives in main_tui_launch (main.py stays
below main's size).
2. Launch keys live only in authority memory, so after an owner restart
(routine since the idle exit) the turn fails
`launch_credentials_unavailable`, and `session.resume` had no api_key
field (invalid_params). The durable credential_ref now carries the
key's sha256 fingerprint (`<instance>:<epoch>:<sid>#sha256:...`, the
same digest config_secret_ref already persists for config keys), and
session.resume accepts a non-durable `api_key` that rebinds only when
the frozen policy has a credential_ref and the key matches that
fingerprint (session:control required). A session launched without a
key, or a different key, is refused `admission_conflict` (a route
override, same as every other creation flag on resume). The key never
reaches the receipt. Pre-existing refs without a fingerprint keep
failing closed.
Classic client: `--resume/-c ... --api-key` sends the key on
session.resume (readable refusal on mismatch), and `/new` re-sends this
terminal's launch key, which build_policy strips from launch_request.
Contracts regenerated (CanonicalResumeParams.api_key).
Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5475590057
17 conflicts, all from main's lint sweep (ruff UP007/UP017/UP022/UP028/UP031/UP037/UP041,
FURB188/FURB192); no other main commit touches a conflicted file. Resolution: the branch side
of each file plus main's exact autofix (ruff 0.15.10, main's ruff.strict.toml, --fix
--unsafe-fixes). ruff.strict.toml takes main's copy. The pool-retirement live fixture stays
deleted with the pooled backend this branch retires.