A token-only deployment (nix/agenix: backend.sessionTokenFile ->
HERMES_DASHBOARD_SESSION_TOKEN=file:<path>) had no way to satisfy the
June-2026 fail-closed gate: gated mode demands a registered
DashboardAuthProvider, the interactive prompt then writes basic-auth
credentials the deployment never asked for, and the provisioned token
itself is rejected on every gated leg (REST 401, /api/ws 403) — the
desktop's 'HTTP reachable but the WebSocket fails' incident.
The bundled session_token plugin closes that: it registers whenever the
session token is provisioned (skippable via
dashboard.session_token_auth.enabled: false) and verify_session
constant-time-compares the presented credential against it. Both legs a
token-mode client uses — the REST bearer path and the /api/ws ?token=
upgrade — run through that seam, so one provisioned token authorizes both.
It is deliberately not an interactive login: a new interactive_login
capability flag keeps it off the login page, /api/auth/providers, the
auto-SSO redirect and the native provider chooser (a token-gated /login
now renders a note explaining the credential channel), while
supports_session stays True so the gate's verify loops consult it.
Rotation semantics are pinned by tests: a saved client copy from before a
secret redeploy must fail closed, not half-work.
web_server.py is a facade and AGENTS.md puts behaviour in siblings
(<stem>_<topic>.py). The file-reading resolver is behaviour, so it now
lives in web_server_session_token.py as resolve_session_token(); the
facade keeps the _SESSION_TOKEN module state and the call. Tests import
the sibling; no re-export shim.
The code-health gate blocks new HERMES_* variables, and it is right:
the credential contract already exists. HERMES_DASHBOARD_SESSION_TOKEN
now takes 'file:<path>' -- the value names a file to read instead of
being the token -- so deployment managers pass a path (not a secret)
through the unit environment. Desktop's per-spawn minting writes raw
tokens and is unaffected.
The Windows footgun lint is right that utf-8 reads break on BOM-prefixed
files; utf-8-sig reads both alike. And a token file that is not valid
UTF-8 raised UnicodeDecodeError -- not an OSError -- so the startup
failure printed a traceback instead of naming
HERMES_DASHBOARD_SESSION_TOKEN_FILE. Catch UnicodeError with it.
Deployment managers (agenix, sops-nix, systemd credentials) hand a
secret over as a file path, and a path -- unlike the token itself --
can sit in a unit environment or a plist without leaking anything into
a world-readable store path. hermes only took the token as an env var,
so every secret-file deployment needed a shell wrapper to read the
file, export the token, and exec hermes -- and that wrapper is where
path quoting goes to die.
HERMES_DASHBOARD_SESSION_TOKEN_FILE names the file; it loses to
HERMES_DASHBOARD_SESSION_TOKEN, and an unreadable or empty file fails
at startup with a message that names the variable, in the same shape
the wrapper's check used to fail in.
Desktop/Webapp UI preferences lived only in each browser's localStorage, so
every device and every origin (LAN IP vs public URL) of the Webapp had its own
settings. They now live once on the machine that runs the app, beside the root
Hermes home (`<root>/ui-preferences.json`), independent of gateway connection
and profile:
- Python store `hermes_cli/ui_preferences.py` + `/api/ui-preferences`
(GET/PATCH, Webapp surface only, behind the existing session/sign-in gate).
- Electron twin `electron/ui-preferences.ts`: typed preload capability
(sync first-paint snapshot, read, validated per-key write, change push incl.
writes the Webapp's server makes).
- Shared on-disk contract: per-key merge under a `<store>.lock` directory
lock, temp+rename, revision counter; `seed` imports a window's existing
localStorage once and never overwrites an existing store.
- Renderer: allowlisted preference keys (no credentials, grants, drafts or
per-window state) sync both ways; localStorage stays the synchronous cache;
persistent atoms for shared keys follow changes live.
Review round on the system-proxy hand-off (#123387):
- The resolved proxy leaked into the relaunched Desktop and everything it
starts. posix.sh relaunched with the update env scrubbed but the proxy
env kept, the Windows Start-Process rung and the staged updater pass
their env on, and gateways `hermes update` restarts inherit it. With a
NO_PROXY of only localhost, every LAN or internal host the PAC sends
direct went through the proxy, and the next update read the stale proxy
as an explicit user setting and never re-resolved it.
The Desktop now names each variable it adds in HERMES_UPDATE_SYSTEM_PROXY
and saves a NO_PROXY of the user's it extends as
HERMES_UPDATE_USER_<KEY>. The Desktop restores its own env at entry (every
relaunch rung), posix.sh restores it in the relaunch subshells (Linux
and macOS), windows.ps1 before the tethered Start-Process rung, and the
gateway and serve/dashboard at start. A marked value is never taken
for the user's own on the next update.
- NO_PROXY gains 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
and .local, and a user NO_PROXY is extended instead of replaced. The
user's value previously also overrode the extended one, because
process.env was spread after the proxy env.
- Each update host is resolved on its own, and the env proxy is exported
only when every host is either that one plain PROXY or DIRECT. A PAC
that sends hosts to different proxies gets a logged note and no env.
- SOCKS and HTTPS answers are no longer exported. Chromium's "SOCKS" is
SOCKS4 and was mapped to socks5h. Beyond that, Python's urllib sends a
plaintext CONNECT to any proxy URL, npm reads no SOCKS env, httpx refuses
socks4, and the update's own git calls drop injected git config. They
get a logged note instead.
Live (Electron 44.9.3 on Xvnc :95):
- Before: the built Desktop launched with a marked proxy env gave its
Python backend all six proxy variables. After: only the user's
NO_PROXY=corp.internal.
- The real posix.sh --relaunch-target: `hermes update` still gets the
proxy, and the relaunched app gets none (before: all six).
- A PAC resolving LAN and corp hosts DIRECT keeps them direct, and so do
the update's localhost calls.
Native Desktop reads <root>/desktop-plugins from its own disk. A Webapp tab's
only disk is the server, and /api/fs is the wrong reader for it: it follows the
profile's SSH workspace and truncates at the 512 KiB preview cap.
/api/desktop-plugins/{root,list,read} answer exactly the loader's reads: the
app-level root, its plugin folders, and each folder's plugin.js and
.hermes-package.json, resolved through symlinks to inside the root, whole up
to Electron's 16 MiB plugin-source cap. Webapp surface only.
The Web Access routes, the browser's file-upload staging route and the file-ticket route were
mounted on every app, so the standalone `hermes dashboard` and `hermes serve` answered them too:
any loopback dashboard tab could turn on Web Access for the gateway (writing its config and .env
and restarting it), and pastes on the dashboard met the Webapp's pre-parse body cap. Only native
Desktop's Web Access pane (on the gateway's own listener) and the Webapp's browser use them.
The surface policy gains web_access (the gateway's listener, private or Webapp) and browser_files
(the Webapp only); an app with no recorded surface reads as the gateway's listener when a gateway
runner is bound to it, else as the dashboard. Each of those routes answers 404 where its surface
does not use it, and the chat upload body cap applies only where the browser's file routes do.
Tests that reached these routes on the dashboard surface now reach them on the surface that serves
them; native Desktop's Web Access calls in tests carry a real one-use native grant per request.
The gateway's Webapp listener read dashboard.public_url, the setting that describes `hermes
dashboard` behind a reverse proxy, to decide whether to require sign-in on a loopback bind, which
outside hostname to accept and where to send sign-in callbacks. So a user with a proxied dashboard
got a Webapp that demanded sign-in and accepted the dashboard's hostname, and with no sign-in
provider the gateway exited outright; and the Web Access pane had to rewrite dashboard.public_url
to publish the Webapp, breaking the dashboard it belonged to.
The Webapp now has webapp.public_url: an optional http(s) address with no credentials, query or
fragment (anything else keeps the Webapp off, like the other webapp settings). On the Webapp
listener it alone engages sign-in on a loopback bind, is the one outside hostname accepted, and is
the base of the sign-in and MCP OAuth callbacks and of the Origin check for browsers without Fetch
Metadata; dashboard.public_url never applies there. The listener records its own URL on the app
state and the shared resolver returns it; `hermes dashboard` declares none and reads
dashboard.public_url exactly as before. When the Webapp's URL needs sign-in and no provider is
registered, the gateway's reason names webapp.public_url. The key is in DEFAULT_CONFIG and the
configuration docs.
Carried from BearHuddleston's #93508 onto main. The Webapp relay and the
profile-incarnation fence stay out: carried code follows main's
named-profile rule and refuses a missing or deleted profile home.
- Webapp routes: one-use launch tickets, window handoff, and gateway
WebSocket tickets minted for the signed-in browser
- Browser surface policy and the SPA document policy
- A host terminal for the browser that survives reconnects
- Staged browser uploads and file tickets; file.attach takes a staged upload
- hermes sessions adopt
- Webapp bundle build helpers and the renderer freshness check
- Regenerated gateway contracts
Co-authored-by: emozilla <emozilla@nousresearch.com>
Settings › Model › Subagents gains a Routing section for delegation.backend:
Default / Model routes / Profile routes, plus any other plugin's backend by
its own label. Plugin modes stay visible with an Install / Turn on hint while
the Advanced Delegation plugin is absent or off.
Core fails closed, so the page shows the SAVED mode as selected even when it
cannot run, with a "Subagents will not start until …" banner naming the fix
(Install plugin / Turn on / restart) and a Switch to Default button.
Model routes get a list with create/edit/delete, a default route and inline
validation (reusing the provider catalog + ModelSelect picker); Profile routes
are a checkbox list of existing profiles with an optional description and a
default. In any mode but Default the subagent model/provider rows are shown
inert with one line saying why (with no default route, unrouted tasks use the
main agent's model) and a Switch to Default button.
Backend: GET /api/delegation/routing (configured + blocked_reason from core's
backend_status), PUT /api/delegation/backend (core set_global_backend, under
the profile scope + config lock), PUT /api/delegation/backends/{model_map,
profile_routes} — profile-scoped (?profile=), validated (unique route names,
known reasoning effort / service tier, existing profiles); route api_keys are
redacted on read and kept on write.
Since the unified gateway (#106742) the local Desktop runs `hermes gateway
ensure` and attaches; it never spawns a local `hermes serve` again. What
only that spawn reached is removed:
Desktop main process
- getBackendArgsForRuntime / backendSupportsServe, backend-serve-support.ts,
backend-command.ts: the local serve argv and its `serve --help` probe.
- spawnOwnedBackend / claimBackendChild and the claim-only half of
backend-claim.ts (claimDecision, probeStartMarker, the output tail) and
parent-process-identity's start-marker resolver. Orphan reaping and the
ownership ledger readers stay.
Runtime
- The local Desktop is decided only by the connection
(`process_identity.serving_local_desktop`); the env-token branch of
is_local_desktop_backend, which only the local spawn satisfied, is gone,
and with it the serve-boot first-install probe and due-answer boot that it
gated (the gateway runs that boot when the Desktop first connects).
- The welcome-trial grandfathering for guests minted before the claim
existed (grandfather_existing_guest, stamp_legacy_guest_claim).
- The `dashboard --no-open` legacy fallback exemption in
_dashboard_sanitize_desktop_env.
The remote SSH `hermes serve` path (token file on argv) is untouched.
A probe run with HOME=<scratch> resolved the bare `hermes-gateway` name (its scratch .hermes looked
native to _profile_suffix, which compared against the PROCESS home) while the user unit dir follows the
ACCOUNT home, so `hermes gateway stop` ran `systemctl --user stop hermes-gateway` on the account's real
gateway and interrupted its live sessions and background delegations.
Foreign-unit half (layered on the salvaged #141908 guard, one guard for both scopes):
- naming root: _native_service_homes / service_suffix compare against account_default_hermes_home()
(pwd account home), the same root #141908 used for the sudo remap; a scratch HOME no longer names
the bare unit.
- gateway_service_owner.foreign_systemd_unit_home / refuse_foreign_systemd_unit (moved from the
facade, unchanged logic) cover user AND system units before any home sync; launchd verbs get the
same refusal (refuse_foreign_launchd_plist).
- `stop --all` / `restart --all` kill only gateways whose live home is this install's
(partition_gateway_pids_by_scope, the `hermes update` fleet rule).
Live-sessions half:
- `gateway stop` / `restart` refuse while the gateway runs turns, cron jobs or background
delegations, naming each (describe_active_work_unit), unless `--interrupt` is passed.
- New `active-work` control verb answers live, including async delegations (absent from
active_agents); a fresh gateway_state.json active_agents covers older gateways.
- Dashboard: POST /api/gateway/stop answers 409 naming the work (?interrupt=true overrides);
config-save auto-restarts report the refusal. POST /api/gateway/restart stays the user-commanded
force path (D6, 19b2624404) and the update recovery restart stays drain-first (3163731289):
both pass --interrupt.
A multiplexed gateway stopped writing agent.log, errors.log and
gateway.log, for the default home and every profile, as soon as its API
listener was built at boot, and stayed silent until the next restart.
uvicorn.Config's default log_config runs dictConfig, which calls
logging.shutdown() on every live handler. The gateway installs its
profile log routers before start_gateway_runtime_api builds the
listener, and a closed router stays closed (82f19f928c), so that one
close retired every router for good.
Both in-process builders, build_listener_server and the dashboard's
_build_uvicorn_server, now pass log_config=None and attach uvicorn's own
console handlers directly: uvicorn.error still prints to stderr, access
lines stay off at log_level="warning", and neither propagates into the
Hermes log files. The final router close and its lock order are
unchanged.
Refs #134889, #140719
(cherry picked from commit 54ab6c9b53455420b1ef6d9d35ef332d8cfeb2cd)
(cherry picked from commit f041bddce0d9295bd94244d7d76f48b9d3e52988)
A request for a plugin name a secondary profile's cached list lacks
rescanned that profile's plugin dirs inline: in the HTTP gate and the
websocket gate, on the gateway's event loop, while holding the
process-wide _profile_plugins_lock. The negative cache bounded how often,
but each first miss per name per window still blocked the loop for a
scan, and any lookup waiting on the lock (on the loop too) waited for it.
_plugin_api_request_refused is now async and runs the miss rescan with
asyncio.to_thread. profile_dashboard_plugins and rescanned_plugin scan
the disk without the lock and take it only to read and publish the cache.
Since scans can now overlap, a per-profile count of explicit rescans
keeps a scan that began before an explicit rescan from publishing its
older list or caching a miss. The negative-cache rules are unchanged:
alternating absent names rescan once per name per window, and an explicit
or ?profile= rescan clears the profile's misses.
One new test asserts the miss rescan runs off the event loop and
unlocked. A second one finishes an explicit rescan inside a miss rescan's
scan and asserts the plugin answers with no miss cached.
Refs #134889 (PLG-3)
Refs #139523
On a gateway serving several profiles, dashboard plugins were discovered
from the launch home only and mounted once in the gateway process. A plugin
installed only in a secondary profile answered 404 from that profile's
Desktop window, its plugins.isolation was ignored, and the interim rule ran
the launch profile's copy for it when both profiles enabled the name.
A request scoped to a secondary profile (its native grant or a ?profile=
selection) now gets that profile's own plugins, served through its own
plugin host (the existing per-profile host and its asgi op, bound to that
profile's home and secrets) whatever its isolation setting says. Their code
is never imported into the gateway.
- Discovery: the profile's own plugins/, then the root ~/.hermes/plugins
(as a standalone `hermes --profile X serve` scanned before the cutover),
then bundled; the profile's own copy wins a name clash. Root plugins also
run in that profile's host.
- Consent: the requesting profile's plugins.enabled/disabled decide; the
launch profile's consent no longer gates them. Disabled, not enabled and
unknown names get identical answers (404 on HTTP, a 1008 close before
accept on a websocket).
- Bundled plugins are Hermes code: a secondary profile uses the in-process
router only when it is that profile's own bundled copy (the imported
module's file, or for a cold mount the copy that would be mounted), and
the cold mount binds the request's ?profile= before deciding. Otherwise,
for example when a launch-profile user plugin shadows the bundled name,
the request goes to the profile's host.
- Credentials: the session token, native grants, the Authorization and
Cookie headers, and the gateway's query keys (token, ticket, internal,
display_ticket, attach, profile; URL-decoded, every repeat) are removed
before the request reaches the host. Ordinary plugin parameters pass.
- Assets: /dashboard-plugins/@<profile>/<name>/<file>, and
/dashboard-plugins/... with ?profile=, bind that profile for the lookup
and consent check (traversal and file-type checks unchanged; an unknown
profile answers like an unknown plugin). The dashboard builds the path
form, so files a stylesheet or bundle loads by relative URL come from
the same profile. Its plugin loader binds its list request, asset URLs
and loaded plugins to the selected profile and drops a list that lands
after a switch; leaving a profile always removes that profile's
stylesheets and bundles, even after its list became empty. A ?profile=
rescan refreshes that profile's own cache.
- Plugin SDK: fetchJSON and authedFetch scope /api/plugins/ requests to
the selected profile with ?profile=, and plugin sockets carry it too; a
profile the plugin passes itself wins.
- The launch profile is unchanged.
The host protocol is request/response, so an authenticated websocket to a
secondary profile's hosted plugin gets a named refusal (HTTP 501 before
accept) instead of running in-process.
Tests that relied on a secondary profile reaching the launch copy now use
that profile's own copy (through a real host) or a bundled probe, and a
consent and refusal matrix covers both ways of selecting a profile.
Refs #134889 (PLG-3)
Refs #139523
- desktop-plugin-sdk.md: ctx.socket on a local gateway authenticates with
the native grant its ctx.rest calls carry (minted by main, attached as a
header to that one dial). Also when the socket keeps retrying, when it
stops, and when it starts again.
- web_server_chat._ws_auth_reason: a socket that sends
X-Hermes-Gateway-Ticket is judged by that header alone, so a core socket
presenting it is refused even with a valid token query credential.
- web_server.py: why the web_server_dashboard import sits mid-module. It is
not an import cycle (web_server_dashboard reaches back only inside
functions); the load-bearing part is the middleware registration order.
Refs #134889 (PLG-1, PLG-8)
Refs #139523
The runtime gate on /api/plugins/<name>/ stopped short in several ways.
- PLG-8: _plugin_api_runtime_gate is HTTP middleware, so a plugin disabled
while the server ran kept accepting new websocket connections until
restart. A pure ASGI gate now applies the same rule to upgrades. It closes
before accept, ahead of the route's own credential check (that check is
the disabled plugin's code, and a gated-mode ticket is single-use); on the
wire that is the same 403 handshake an unknown route or a refused
credential gets, so it is no plugin-name oracle.
- PLG-9: under a secondary profile's native ticket the gate read only that
profile's plugin lists. Dashboard discovery scans only the launch home and
the root, so every copy this server imports, hands to a plugin host or
serves files from is the launch profile's. A plugin the launch profile
disabled stayed reachable for the secondary profile (routes and assets),
and that profile's first request for a plugin only it enabled hot-mounted
the launch copy in its scope: imported here, or, under its own
plugins.isolation: host, run by its plugin host with its secrets
(GHSA-mcfc-hp25-cjv7). The hot mount also took plugins.isolation from the
requesting profile, so an in-process secondary imported a plugin the
launch profile runs in a host.
- A session-token request with ?profile= ran a plugin in the selected
profile's scope even when that profile had disabled it.
One rule now holds for HTTP, websocket upgrades, assets, the dashboard
plugin list (no tab whose script and API refuse) and the hot mount:
a plugin is served only while the launch profile, whose copy it is, has it
enabled and so does the profile the request acts for (a native ticket's
profile, a ?profile= selection once its scope is bound, else the launch
profile). Mount decisions, hot mounts included, are the launch profile's
alone, its isolation mode included. The gates read the enable lists once
per profile scope from the cached read-only config.
Refs #134889 (PLG-8, PLG-9)
(cherry picked from commit 04759b71e5f0eabac25b9cf7ba15216c405972c8)
Two approval gates stopped holding once one long-lived gateway owned every
local session.
- command_allowlist was read once at import (tools/approval.py), so a
pattern removed from config.yaml by hand stayed auto-approved until the
gateway restarted (`rm -rf` ran without a prompt). Every approval check now
applies the on-disk delta since its last sync: removed entries stop
matching, added ones start, and an "always" approval this process made but
could not save is kept. The read uses the signature-cached config loader.
- _plugin_api_runtime_gate only checked the enabled list for token- or
session-authenticated requests, so Desktop's native-ticket requests reached
a disabled plugin's /api/plugins/<name>/ routes until restart, weakening
the #46435 consent gate. Native-ticket requests are now gated too.
Refs #134889 (CFG-5, PLG-2)
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.
1eb04476c2 put the new first-install helper between @asynccontextmanager
and _lifespan, so the decorator wrapped the plain helper and FastAPI got a
bare async generator. Starlette 1.x only accepts that through a deprecated
wrapper path. The decorator is back on _lifespan; the helper is an ordinary
function.
- lifecycle.ts: gateway.ready handling moves into onGatewayReady, so
handleLifecycleEvent's complexity is back under its cap.
- auth.py: the Bedrock-rung comment and the no-provider message are
shorter, so the file is back to its line count on the base.
- web_server.py: the boot install check catches OSError/ValueError (what
the probe's own guards leave), not every exception.
- methods_onboarding.py: the trial claim after the run record moves into
_claim_after_record, which removes the extra nesting level in
onboarding.start.
The desktop asks onboarding.state at launch. The handler recomputed
everything inline, on the connection's serial queue, while boot threads
did the same provider reads. A slow answer missed the desktop's deadline,
and onboarding was skipped for that launch.
- hermes_cli/onboarding_due.py keeps the answer (run, eligible). A
reader waits a bounded time (8 s) for a boot computation in flight,
then answers live and caches that.
- The serve lifespan starts the computation on the desktop's local
backend (start_due_boot), after the setup bootstrap has recorded a
fresh install and kept an existing guest's trial.
- Every writer that can move the answer drops the cache: set_run, the OS
user's marker, and the setup record's refresh and reconcile. A stamp of
the files the answer reads catches edits made outside the process.
- onboarding.state runs on the RPC pool (_LONG_HANDLERS), so its wait
never holds the connection's queue. Remote backends answer eligible:
false at once, and --fresh-install still asks live.
The install check reads the default root's state.db. At serve boot the
same process starts creating or healing that database on another thread,
so the check could meet it mid-write. On the desktop's local backend the
check now runs once in the lifespan, before the state.db reconcile thread
starts, and its answer is cached for the process.
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`.
The old setup flow is deleted with no compatibility for installs that
still have a hermes-setup profile: such a directory stays on disk as an
ordinary named profile with whatever config it has. So the release goes:
hermes_cli/onboarding_migrations.py and its tests, its call from the serve
lifespan, the release of clones, imports and distribution installs in
profiles.py and profile_distribution.py, and the bool return the release
needed from _write_shared_nous_state (back to main).
hermes_cli/setup_profile.py and its copy hooks stay deleted.
This reverts the migration parts of 0707d8fc92 and commits dbd9546f00,
f0e5997b3a, 439a7f378a, 7dbd26aedc, 4808ab996c, 2311b36a92 and d6315dd337.
hermes_cli/setup_profile.py and SETUP_PROFILE_MARKER go, with the copy
hooks in profile create/clone/import and distribution install.
Canary/RC installs still have a hermes-setup profile on disk.
hermes_cli/onboarding_migrations.py releases it once per install (latched
by onboarding.seen.setup_profile_released in the root config), from the
serve lifespan before any RPC is served and before the free-tier
bootstrap, under a file lock, and never from a backend launched inside it:
1. a finished or skipped old guide (marker intro seen / completed_at, or
onboarding.seen.setup_intro) sets the root onboarding.run = false unless
the root already holds a bool;
2. the profile's Nous identity seeds the shared store when that is empty;
3. the marker and setup's tool limits go (cli toolset grant, toolsets setup
disabled, its exact deferred list); sessions, credentials, memories stay;
4. hub-installed initiate-setup / first-task skills are uninstalled.
Adapted: main has no onboarding_run module yet, so the release lists
profiles with profiles._iter_named_profile_dirs and writes onboarding.run
itself; the test file keeps one invariant (a finished guide's profile is
released once, chats, memories and identity kept).
Desktop: a stored active profile whose home is missing boots default, and a
source's remembered profile that its list no longer has lands on default.
The startup pick keeps skipping marker dirs: it runs before the backend
exists, so picking the setup profile there would keep it from ever being
released.
(cherry picked from commit a581c7e0ea3889782a2ed3d2557b40da5aa8e6ef, adapted)
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.
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.
start_gateway_api imported hermes_cli.web_server (the whole dashboard FastAPI app, ~686 routes)
on the event loop before the session API listened: ~0.57 s of every cold `chat -q`, and it
stalled identify. The listener now serves the ticketed native /api/ws itself (same Host, peer and
loopback checks) and mounts the dashboard on its first request, imported off the loop, running
its own startup then. A gated listener (non-loopback bind or dashboard.public_url) still mounts
the dashboard before it listens; a gateway started without --idle-exit (Desktop, services) loads
it in the background right after READY. The light boundary helpers move to
hermes_cli/web_server_boundary.py (web_server keeps the names); the dashboard's own uvicorn
builder is unchanged, the gateway uses a FastAPI-free build_listener_server.
Cold `chat -q` (fresh home, loopback stub, archive trees, loaded host, 3 reps): base 4.59 s,
with this and the adapter fix 3.76 s, main 3.34 s.
Review: https://github.com/NousResearch/hermes-agent/pull/106742#issuecomment-6073624820
(cherry picked from commit e90fa09fd682b729123fd9d1103f99af5ed869d9)
45 conflicts, all from #135177 (lefthook + `ruff check --fix` over 2,366 files). No other main commit
touches a conflicted file. Resolution: the branch side of each file, then main's exact autofix
(ruff 0.15.10, `--config ./ruff.strict.toml --fix`) on it — rewrites only (typing generics, noqa
drops, import forms), no import removed. tests/cron/test_bot_chat_cli_home.py stays deleted
(1cc9cb9199 retired its lane).
An IPv6 literal followed by :port is only a valid URL authority inside
brackets; http://::1:9119 is unparseable by browsers and urllib. Add
hermes_cli/url_utils.format_url_host and use it at every site that
builds an http URL from a (possibly IPv6) bind host: the named-profile
dashboard attach URL, the browser auto-open URL, the startup banner,
the plugin-activation loopback request, the proxy listening banner, and
the gateway-migration listener URLs. Zone identifiers (%eth0) are
percent-encoded per RFC 6874.
Fixes#67367
Co-authored-by: sjungwon03 <sjungwon03@gmail.com>
app.add_middleware(CORSMiddleware, ...) was registered before the
@app.middleware(http) auth decorators, making CORS the innermost
layer in Starlette's onion model. A cross-origin OPTIONS preflight
hit auth first → 401, and the CORS headers were never sent.
Moving the add_middleware call after all @app.middleware registrations
makes CORS outermost, so preflights are answered before auth runs.
Fixes#59052
A prior backend whose session died (dead spawner, PID re-parented to
init) stays alive, so it keeps holding the host flock and its record
passes every staleness check. A fresh backend hit HELD_BY_OTHER and
returned observe-only forever; every attach retried against the same
orphan and its 10s probe timed out indefinitely.
On HELD_BY_OTHER, look the conflicting owner up in the spawn ledger
and apply the established spawner_is_dead discipline (previously wired
only into the mcp-helper reap): a provably dead-spawned owner — or a
null-spawner owner reparented to init, old past the lock-write grace,
and claimed by no Desktop SSH lock — is terminated (SIGTERM, 2s,
SIGKILL), its record discarded, and the host lock re-claimed.
Live-spawned, lock-claimed, young, interactive, self, and unprovable
owners are never touched.
The pre-auth POST routes under /auth/ buffered the whole JSON body before validation, with no size limit, so anonymous clients could hold large uploads in memory. A pure-ASGI middleware now answers 413 when Content-Length exceeds 64 KiB, and counts the bytes actually received so chunked or understated bodies are cut off at the same limit. Authenticated routes and WebSockets are unchanged.
Reported-by: Tenable Research
Scoping a supervised dashboard/serve backend's background processes moved them out of the
backend's service cgroup, so they survived a backend restart, but nothing in dashboard/serve
startup recovers the process checkpoint: they kept running while process list/poll/kill could
not find them, and the next spawn dropped their checkpoint record. Recovering them in serve
would conflict with the gateway owning background processes (#106742). Revert to main's
behaviour for dashboard/serve (workers stay in the backend's cgroup and die with it) and leave
escapee cleanup there to the serve-to-gateway cutover.
Tests: the escapee in the hang test printed before the kill deadline, which ended the reader's
blocked read and let the old close finish in time, so the test passed without the fix. The hang
test's escapee is now silent; late-output rejection has its own test. Removing the reader-close
guard now fails the hang test.
Only the supervised messaging gateway ran background processes in their own
systemd scope (_is_supervised_gateway_process requires _HERMES_GATEWAY and the
gateway PID file). A dashboard or serve backend run by systemd hosts the same
kind of agent turns, but its background processes shared its cgroup, so a
descendant that setsid()s past the PTY/process-group kill survived it: the kill
reported success while the escapee kept running (and kept the PTY slave open).
web_server.start_server now marks the process as a backend host (process-local,
so terminal children and CLIs that inherit the supervisor env don't count), and
_scope_argv scopes when that host was launched by a service manager. The kill
already stops the scope, which reaps the whole cgroup. The self-kill guards that
also read _is_supervised_gateway_process are unchanged.
A Desktop reconnect that cannot prove the recorded pid is its own (dead-looking
pid, FOREIGN argv proof) drops desktop-ssh/<ownershipId>/backend.lock.json
without signalling that pid and spawns a new nonce. The superseded serve had no
signal that it lost ownership: it lived until the idle watchdog fired (900s
grace, gated on zero WebSockets, which a half-open tunnel keeps non-zero for up
to the 600s ping timeout), so a reconnect storm stacked detached backends, each
an extra state.db writer (#132034).
web_server_owner_exit mirrors web_server_skew_exit: a pure decision (retire only
when a VALID lock names another spawnNonce and the process is past the reaper's
180s settle window; missing, unreadable or skewed locks keep it up) and a daemon
watchdog that needs two consecutive observations, then exits through the
retirement fence so it never tears down mid-turn and admission is closed first.
The lock is read through dashboard_procs' existing validator (split out as
read_valid_backend_lock, shared with _lock_owned_serve_pids) rather than a
second parser, and its path is the validated --ssh-session-token-file's
ownership directory. Server-side only: cleanupStale is untouched, so this
composes with #126035.
Root-cause analysis and watchdog design from the #132034 report by @VexterZ;
lock-ownership watchdog first drafted in #89452 by @pmwanje2 (prior art).
Refs #132034 (POSIX SSH hosts; Windows-host locks are not validated yet)
One answer per profile, asked once, with the Desktop strip's three equal
choices (Send to Nous / Local only / No thanks) now offered by:
- `hermes setup`: at the end of every flow (Quick, Full, Blank Slate,
Portal, --quick), via the setup-completed record they all funnel into.
- `hermes` / `hermes --tui`: once before an interactive chat on a profile
that never answered. Skipped for -q, piped/JSON output, spawned actions
(HERMES_NONINTERACTIVE), Desktop-hosted panes and managed installs.
- Web dashboard: a banner for the profile being managed, backed by
GET/PUT /api/shared-metrics/consent.
"No thanks" is the terminal default so Enter never opts anyone in; Esc and
the banner's X leave the question open.
Also fixes the answer that could not stick: a CLI "no" equals the shipped
defaults, so save_config stripped it and every surface (Desktop strip
included) kept asking. The answer is now written to config.yaml directly,
and `decided` has one definition shared by the RPC, the CLI and the router.
The code-skew watchdog only covered SSH-isolated backends; Desktop-owned
local serves share the same 'updater never restarts me' property, so they
served stale modules until the app happened to restart them (R1). Extend
start_code_skew_watchdog wiring to is_desktop_owned_backend() backends.
Centralize the skew refusal: POST /api/model/set and the tui_gateway
model.options / model.save_key RPCs now refuse with the same restart
message the picker and the gateway /model switch already return (R2).
uvicorn's default timeout_graceful_shutdown=None makes Server.shutdown()
wait forever on a lingering ASGI task; Desktop sends a single SIGTERM and
escalates to SIGKILL ~5s later, so a mid-turn request orphans the backend
(#76244). Set timeout_graceful_shutdown=3, under the kill budget, with a
behavior-level regression test that cancels the lingerer and returns.
The fail-open built-in path gated ticks via can_dispatch, so a skipped
tick still recorded a successful heartbeat and cleared the tick error on
the store a live gateway owns. Tick this backend's own store through the
multiplex loop with the same profile_gate instead: a gated-out profile is
neither ticked nor heartbeated.
One _gateway_owns_cron(name, home) predicate now backs every path, so the
fail-open and external-provider paths also stand down for a satellite
served by the live default multiplexer. The external-provider wait probes
once per interval.
Tests: split the external-provider stand-down test and drop the iterator
that hid over-probing; pin the fail-open start kwargs exactly; cover the
satellite gate and the heartbeat through the real built-in loop.
(cherry picked from commit b9250805e7eb951632e9f56e1ce6321e9cbcb395)
The multiplex ticker already yields to a live gateway through its per-tick
profile_gate. The fail-open paths (profile enumeration failure, empty served
set, external provider) still took one ownership probe at backend start and
returned for good, so Desktop cron stayed dead after that gateway stopped.
The built-in single-store ticker now gets the same probe as a per-tick
can_dispatch gate: it stands down while a gateway owns this home, fires once
it stops, and stands down again if it returns. An external provider takes no
per-tick gate, so its start waits, re-probing every interval and honoring
stop_event, until the gateway is gone.
Fixes#126822
Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
(cherry picked from commit 4ffe4b3fd68b96fd48c4e8847344a69de7c4f0c2)