When uv exhausts its HTTP retries before PM's deadline, classify_uv_failure
now attaches the same UV_CONCURRENT_DOWNLOADS / UV_HTTP_TIMEOUT hint. The
docs separate what regular and pinned-runtime builds keep, and the child
env test moves into test_index_bridging.py on its shared fixture.
The uv timeout hint now points slow links at UV_CONCURRENT_DOWNLOADS
first, and the package-management reference lists which UV_* network
settings survive PM isolation.
Co-authored-by: marlonferreira1800-hue <marlonferreira1800@gmail.com>
`hermes dashboard password` removes the HERMES_DASHBOARD_BASIC_AUTH_{USERNAME,PASSWORD,
PASSWORD_HASH} lines that would override config.yaml. It finds and removes them line by
line (load_env, remove_env_value). The loader is python-dotenv, which reads a double- or
single-quoted value over several lines as one value.
Measured with a real .env holding a PEM-style TLS_KEY="..." over four lines (one of them
`HERMES_DASHBOARD_BASIC_AUTH_PASSWORD=look-alike...`) and a two-line
HERMES_DASHBOARD_BASIC_AUTH_PASSWORD="first\nsecond". The command removed the look-alike line
from inside the key, which silently corrupted TLS_KEY. It also removed only the first line of
the password, leaving a stray `second"` line the loader can't parse. The file went from 300 to
174 bytes.
When the .env holds any quoted value over several lines, the cleanup now removes whole
assignments as python-dotenv parses them, under the existing .env write lock. It writes every
other byte back unchanged: the BOM, comments, the blank lines before a removed assignment,
line endings and the file mode (the same atomic, mode-keeping writer as remove_env_value). A
look-alike line inside another value is part of that value, so it stays. Such a file that
isn't UTF-8 would be re-encoded by the rewrite, so when it has an override assignment to
remove (as python-dotenv parses it) it is refused before config.yaml is written, with nothing
changed. With none to remove (a Latin-1 note and PLAIN=1, or only a look-alike line inside a
value), the file is left alone and the command succeeds, as on main for that note. "Every
other byte" is the cleanup's own write: the startup .env sanitizer that runs on main before
it (env_loader, unchanged here) may already have rewritten the file.
That write turns off newline translation: _write_env_lines takes an optional `newline`
(open()'s; default None, as before for every other caller), and this caller passes "".
Otherwise text mode on Windows would write a kept CRLF as "\r\r\n". Measured on Linux with
Windows translation simulated (os.fdopen newline="\r\n"): `KEEP="a\r\nb"\r\n...` came back as
`KEEP="a\r\r\nb"\r\r\n` without it, and byte-exact with it. main's line-by-line writer
doesn't translate twice: it reads with universal newlines and writes "\n" once, so on Windows
it writes CRLF once. It also turns an LF file into CRLF there, as it always has; that path is
left as it is.
A .env with no multi-line value still goes through remove_env_value line by line, exactly as
before; a real run on such a file prints and writes the same as main.
Follow-up to #157393.
* feat(pm): a launcher can name the install-state folder of its process
A sandbox that runs Hermes on the host's own files grants the selected
dependency environment read-only and nothing else of installs/<key>. On
Windows the process inside still sees that folder, because it is an
ancestor of a grant, while reading facts.json and taking the install lock
are refused. Start-up took that for an install state it has to use and
ended with "install state is not writable by this user", so a sandbox on
an installer-made Hermes on Windows did not start.
HERMES_INSTALL_STATE_DIR names the folder a process and its children keep
their install state in. A process started with it runs on the interpreter
it was given: it selects no environment, from the install's own state or
from the named folder, it is not restarted on another interpreter, and it
writes nothing into the install's own state. A Linux sandbox gets the
same from a mount of an empty folder over installs/<key>; Windows has no
mount.
* fix(pm): start-up reads nothing from a folder a launcher named
A process whose launcher named its install-state folder still acted at
start on that folder and on the checkout's markers:
- An update that stopped half way leaves .update-incomplete in the
checkout. The process ran the repair, which builds into the named
folder, and cleared the marker the install's own next start needs.
- A publication.json placed in the named folder, which the process can
write, was replayed: it could put a config.yaml back, and a damaged
one ended the start.
Start-up now takes the path of a process with no install state: no lock,
no journal, no recorded selection, and the named folder is left as it
is. A sealed install still selects the environment its manifest names,
which is part of its tree.
* fix(env): the install-state folder a launcher named is launch-only
A .env line that names HERMES_INSTALL_STATE_DIR replaced the launcher's
value when the file was loaded, after start-up, and every later lock and
marker went to the other folder. The same line made the variable residue
of the launch profile, so a worker started for another profile lost it.
The variable joins LAUNCH_ONLY_ENV_KEYS: no .env, secret source or .env
writer sets it.
* fix(pm): refuse to build an environment no process would select
In a process whose launcher named its state folder, `hermes pm install
--extra` built an environment in that folder and reported it installed.
No process selects an environment recorded there. `hermes pm repair` did
the same, and counted a failed attempt against the install's marker.
Both entries of the venv sync (pm.client, pm.install) and the explicit
repair now refuse first and say why.
* docs(reference): what a named install-state folder does
The row for HERMES_INSTALL_STATE_DIR says what start-up leaves alone,
which commands are refused, that a sealed install keeps the environment
it ships, that the variable is launch-only, and that the launcher keeps
the interpreter's environment in place while the process runs.
After the fleet check, when this profile still runs an old `hermes dashboard` / `hermes serve` backend,
`hermes update` prints one paragraph naming it and the command that shows the move to the gateway
without changing anything: `hermes -p <profile> gateway migrate --backends --apply --dry-run`, typed
the way the migration prints its own steps. A profile of a root other than the platform default
(HERMES_HOME=/srv/team-hermes) also pins that root, because `-p` resolves against the shell's own
HERMES_HOME: `HERMES_HOME=<root> hermes -p <profile> ...`, or `$env:HERMES_HOME='<root>'; hermes ...` in
PowerShell, quoted for each shell by the migration's own `hermes_command(home, powershell=)` and
`pin_hermes_home`. If that backend still runs a Hermes older than v2026.7.30, the dry run says to restart it
with the updated hermes first. The notice never stops, restarts, migrates or prompts.
It only looks when the update already met such a backend: its pre-update inventory lists a serve or
dashboard runtime no Desktop owns, or its restart phase touched a hermes-serve*/hermes-dashboard* unit,
leaving out the ones the inventory attributes to a sibling profile. With no such candidate it resolves
nothing else (not even the active profile), starts no process and prints what it printed before. A
stopped unit is not named while the migration's backend_migration.json says the old backend stays down
(running, done, failed, or unreadable); a running backend is named in every state.
The whole notice, gate and report, runs inside the update's `_best_effort`: a failure is logged at debug
and never fails the update.
macOS lets `hermes dashboard --port P` bind 127.0.0.1:P while the gateway listens on *:P, and another
address of the same port binds on any OS, so a retired backend could come back as a second session
owner beside the gateway. When the migration manifest says the old backend is retired and this home's
gateway serves the port, the bind check reports a conflict and the old command gets the existing exit-78
message. Without a manifest, or after a rollback or restore, nothing changes.
`--apply` records a manifest (backups and manifest fsynced, 0600 from creation), copies sign-in settings
that exist only in the old unit's environment into .env, installs and starts the gateway, retires the
old backend (systemd unit disabled with a RestartPreventExitStatus=78 drop-in; launchd job booted out,
disabled and its plist set aside; a hand-started process stopped by its recorded pid) and verifies every
address within 90 seconds. Nothing changes (exit 3) while a turn runs on the old backend (unless
--force-interrupt), while another old backend serves this home, when the unit's enablement could not be
put back exactly, when config.yaml or .env is a symlink, when a hand-started backend's command line and
environment cannot be recorded and read back, when the run (or the rollback of an unfinished run) is
inside the gateway's unit, or when the manifest exists but cannot be read. A finished migration makes a
second --apply report nothing to do; it never re-plans or replaces the backups. Any failure undoes only
the steps the run entered (a journal in the manifest), and starts the old backend again only once the
gateway is proven off its address (and never a second hand-started process: the replacement is recorded
at once and a live one is reused); otherwise exit 5 with numbered, profile-qualified manual steps.
Unknown gateway identity counts as "off" only when nothing listens on the port; a hand-started backend
without its recorded launch snapshot is left down (exit 5; --restore checks it before stopping the
gateway), and the snapshot is removed after a verified rollback or restore. A run killed mid-way is
rolled back by the next run, never continued. `--restore` undoes a finished migration, `--status
[--json]` reports the last run, `--detach` runs outside the caller's systemd unit with the same profile
(exit 7 when it never confirms), and `--expect TOKEN` (from the dry run's expect_token) refuses with
exit 8 when the backend found under the run lock is another one. One run per home at a time: a second
exits 3 and changes nothing. The --backends report no longer says migration is unavailable. Its tests
are in tests/hermes_cli/gateway_migrate_backends_apply/ (the dry-run file keeps the shared fake host).
Docs: the "Moving a dashboard backend to the gateway" section and the migrate row.
`hermes update` restarts an inactive but enabled-like hermes-dashboard.service. Once a backend migration
has stopped the old backend (backend_migration.json in the home says so), that restart leaves it
stopped. A manifest that exists but cannot be read counts as retired too: a migration may have stopped
half-way. Without the file the update behaves as before.
`hermes gateway migrate --backends --apply --dry-run [--json]` prints the plan for moving this home's
old dashboard/serve backend onto the gateway's Webapp on the same address, and every blocker. The
blockers are:
- a running turn (unless --force-interrupt);
- an address that matches no backend;
- a bind the gateway would refuse;
- a Webapp already enabled elsewhere;
- a run from inside the old unit;
- a stopped unit whose environment cannot be read, or whose EnvironmentFile= is a pattern;
- a config.yaml that cannot be read or parsed (the parser's text is not repeated).
It only reads the host: the new SystemHost has no method that starts, stops, installs or writes
anything. It judges the Webapp settings with the gateway's own webapp_settings, on the config the
gateway would see: defaults, ${VAR} expansion and the managed overlay, merged from config.yaml as
written without load_config's writes (it creates the home layout and backs up the config).
Secrets: a public URL is copied only when the gateway accepts it; otherwise it is a blocker that does
not print it. The argv in the plan has inline env assignments, credential flags and URL passwords
redacted.
Backends this command will not drive (Nix, s6/containers, a systemd system unit, a host without a
service manager) exit 6 with printed steps that fit the host:
- every hermes command names the home: -p PROFILE, and -p default for the default home, so a sticky
`hermes profile use` choice cannot redirect it;
- the old backend stops first;
- the gateway is then installed, started or restarted by what `hermes gateway status` says, and
`hermes webapp --status` checks the result;
- Nix and container steps say what to change in their own configuration;
- without a service manager, the last step is `hermes gateway run`.
Which home a stopped systemd unit belongs to comes from the environment systemd gives it:
Environment= first, then each EnvironmentFile= in order, a later value winning (systemd.exec(5)). A
required file that cannot be read, or an EnvironmentFile= pattern (systemd expands it), blocks the
plan. A system unit must also run as the caller.
A stopped Nix unit's address comes from its ExecStart. An address that cannot be read stays absent
(null in JSON), with no address-dependent steps or text. A launchd LaunchAgent is planned with the
credentials in its plist and the gateway as a launchd agent. `--apply` without `--dry-run` exits 2 in
this version.
A new test runs the real CLI against a scratch account with a hand-started `hermes serve` and checks
that every file under it, the backend's process and its install id are unchanged. Docs: a "Planning a
move to the gateway (dry run)" section and the cli-commands migrate row.
Windows environment names ignore case, so a hermes_dashboard_basic_auth_password
line in a .env is loaded as HERMES_DASHBOARD_BASIC_AUTH_PASSWORD and overrides
config.yaml, while the command removes and judges only the exact upper-case
names: it exited 0 and the old password came back on the next start.
On Windows the command now refuses first, before writing anything, when this
home's .env or the checkout's has one of those keys in another case. It names
the file, the line number and the key as spelled, never the value, and asks
for the line to be deleted or renamed. Lines are read one at a time with the
tokenizer load_env uses, so a look-alike line inside a quoted multi-line value
refuses too. Nothing else changes: off Windows the check does not run.
This reverts commit b518656ea2a4d9416c918ae977f0b59b309218e8.
Matching the overrides in any case changed which lines the command reads from the
home's .env with a second tokenizer, and on Linux a quoted key ('HERMES_DASHBOARD_
BASIC_AUTH_PASSWORD'=...) in the home's .env with the same key in the checkout's
.env no longer refused: the command exited 0 and left the old override in effect.
On Windows it could still let the checkout's spelling win, deleted look-alike lines
inside a quoted multi-line value, and could print a value as the kept username.
The matching and removal are back to the exact names, byte for byte as before. The
POSIX test from that commit stays: a lower-case line is another variable there.
Windows environment names ignore case, so a hermes_dashboard_basic_auth_password
line in a .env is loaded as HERMES_DASHBOARD_BASIC_AUTH_PASSWORD and overrides
config.yaml. hermes dashboard password looked the overrides up by their exact
upper-case names: it left such a line in the home's .env (exit 0, the old
password back after a restart) and did not refuse one in the checkout's .env.
The overrides are now matched the way the .env writer compares names
(_env_var_policy_name): any case on Windows, exactly elsewhere. That covers
removing them from the home's .env, the username kept from it, the username
reference check, and the checkout .env judgment, whose simulated removal now
drops every spelling the home's .env has. POSIX behavior is unchanged.
The CLI reference now says the checkout .env refusal uses the loader's own rules: ${...}
expanded, fill-gaps-only when the home has its own .env, so an empty or unresolved value
overrides nothing.
The hint for a shared gateway owned by the default home printed a bare
`hermes dashboard password`. After `hermes profile use work` a bare `hermes ...` runs as
`work`, so following the hint rotated `work` again and left the gateway's credentials
unchanged. The restart hint had the same shape (`hermes gateway restart`).
Every command the output prints is now built by one helper that pins it to its home:
`hermes -p default ...` for the default home, `hermes --profile NAME ...` for a profile,
`HERMES_HOME=... hermes ...` for any other home. Docs say so.
Tests: test_with_a_sticky_profile_every_printed_command_names_its_home (live multiplexing
gateway after `hermes profile use work`; red on d0e58089: "change them with hermes
dashboard password."), test_the_new_password_signs_in_on_the_gateways_webapp and
test_a_named_profile_gets_its_own_sign_in (now expect `hermes -p default ...`).
CLI reference and web dashboard page for `hermes dashboard password`: the default
username now comes from this home's .env first; the command refuses before any write
for a managed config.yaml pin, an override in the checkout's .env, or a username
${...} reference to a key it removes; and -p sets only that profile's own sign-in
(its --isolated dashboard/serve and a gateway it runs by itself), while the machine
dashboard and a multi-profile gateway use their own home's credentials.
`hermes dashboard password [--username U] [--password-stdin]` stores the dashboard sign-in for
`hermes dashboard` / `hermes serve` and the gateway's Webapp: the username and an scrypt hash under
dashboard.basic_auth in config.yaml (written 0600 by save_config), plus a signing secret when the
section has none, so sign-ins survive restarts. It is the same storage the interactive prompt of
`hermes dashboard --host 0.0.0.0` writes: that prompt now calls the shared store_basic_auth and
prints and stores exactly what it did before (same transcript, a secret also when
HERMES_DASHBOARD_BASIC_AUTH_SECRET is set, the re-enabled-plugin line before the save).
The password is never taken from argv and never printed. --password-stdin refuses a terminal on
standard input (typed text would show; the hidden prompt is the way to type it), reads the first
line as UTF-8, drops its \n or \r\n (a lone \r is part of the password) and refuses an empty,
non-UTF-8 or over-1024-byte value with exit 2 and nothing written; without it the command asks
twice on a terminal and exits 2 when there is none.
HERMES_DASHBOARD_BASIC_AUTH_{USERNAME,PASSWORD,PASSWORD_HASH} override config.yaml. One the
administrator pins in the managed .env is refused before config.yaml is touched (exit 1). Ones in
this home's .env are removed after the save (named, never shown); if one cannot be removed the
command exits 1 and says that config.yaml changed and which key is left in which file. Values the
calling environment itself sets (the new env_loader.environ_before_dotenv: os.environ with the
CLI's .env load peeled back, read before the cleanup) are named with a warning that a listener
started from that environment still signs in with them. The command says which running gateway or backend has to
restart (a listener reads the sign-in when it starts; one started with a new password ends the old
sign-ins). -p <profile> sets that profile's sign-in.
Docs: the CLI reference section and a "Setting the password from the command line" part of the
web dashboard page.
The installed `hermes` runs the CLI under a launcher process whose argv is the
same `hermes dashboard --status [--port N]`. The status scan parsed that
launcher as a dashboard on 9119 (or N), and the reachability probe answered for
whatever held that port, so `--status` listed its own launcher as a running
backend: beside a real old backend on that port it counted two, and on a host
whose gateway serves the Webapp there it listed only itself and never named
the gateway.
An ancestor of the `--status` process is now listed only while psutil shows it
holding that port's listener itself (an unknown answer keeps main's listing).
This home's gateway is asked about one address only: the concrete address the
probe reached for such a launcher (a wildcard host probes 127.0.0.1), and only
when no listed backend's own probe reached that same address. It gets the same
proof as the failed-bind path: its `identify` names the port and its live
listener takes the address. When it serves the Webapp there, one line names the
gateway, its PID and the Webapp's address. So `--status` with its port free, or
naming the address a listed backend answers on, reaches no gateway, and a
backend on another address of the port (127.0.0.2:P beside the gateway's
127.0.0.1:P) does not hide the gateway that `--host 0.0.0.0` reached. The exit
code stays 0.
Tests: test_dashboard_status_beside_gateway.py (a real gateway; a real old
backend in a home with no gateway, with --status naming a free port and the
backend's port; an old backend beside this home's gateway, where --status
naming the backend's port never connects to the gateway's control socket; an
old backend on 127.0.0.2:P beside the gateway on 127.0.0.1:P, where
--status --host 0.0.0.0 still names the gateway). Docs: the --status row of cli-commands.md.
A host moved to the gateway serves the Webapp from the gateway's listener,
often on the old backend's port (9119). An old `hermes dashboard` or
`hermes serve` started there (by hand, or by a unit left behind) printed the
generic "already in use" hint and exited 75 (EX_TEMPFAIL: try again), although
no retry can succeed.
When the bind fails, `_report_port_in_use` now asks this home's gateway, over
its private control socket, whether its listener is bound to that port. If it
is, the command says the gateway serves the Webapp at that address, that the
old command is no longer needed, and what usually starts it (a systemd unit or
launchd job; a Task Scheduler task or Startup-folder entry on Windows), and
exits 78 (EX_CONFIG). The BACKEND_PORT_IN_USE sentinel stays the first line.
Ownership must be proven, else the old answer stands. The gateway's
`identify` must name the requested port, and the OS's socket table must show
that gateway process listening on that port at an address that takes the
requested one in the same address family (the same address, or a wildcard of
that family). Across families nothing is proven: the old command's bind probe
sets no dual-stack option, and Windows binds IPv6 only. A gateway on
127.0.0.1:P beside another process on [::1]:P therefore leaves both
`--host ::1` and `--host ::` with exit 75.
The gateway is asked only on the failed-bind path, and its Webapp state is read
only after both checks. Asking only connects: unlike discover_gateway_endpoint,
it never judges or narrows the mode of a home's gateway.lock when no gateway
runs. A free port never reaches the control socket; a port held by anything
else keeps the old message word for word and exit 75; port 0 never asks. The unused
PORT_IN_USE_EXIT_CODE import in web_server.py goes away.
Tests: test_dashboard_port_held_by_gateway.py (a real gateway in a temp home)
and test_dashboard_port_free_parity.py (free port, other-holder and lock
parity; its CLI tests pass unchanged on the parent commit). Docs: the "Port conflicts" paragraph of
cli-commands.md, including what systemd, launchd and Windows need so a
supervisor stops restarting the old command.
Every launch of a source install wrote inside the dependency tree: a lease
file in the selected generation (`<generation>/.leases/<uuid>`, for both
`environments/` and `pm-runtime/generations/`), `installs/<key>/.install.lock`
and `pm-runtime/.prepare.lock`. Generation names change with every build, so
a sandbox policy (Landlock/OpenShell, rootless Podman, systemd
`ReadOnlyPaths=`) could not keep the dependencies read-only without a new
exception per build: on a read-only generation `lease_directory` raised
PermissionError.
Leases now live in `installs/<key>/leases/{environments,pm-runtime}/<generation>/`
and the locks in `installs/<key>/locks/{install,prepare}.lock`. Neither path
changes between builds, so a sandbox grants write access to those two
directories and keeps the generations read-only.
- `lease_dirs(generation)` finds the install state from the generation's
parents (`environments/<gen>`, `pm-runtime/generations/<gen>`; a PM
worker's `sys.prefix` is the latter). It returns the new directory first
and the in-generation `.leases` second.
- Processes started on an earlier release keep leasing `<gen>/.leases` and
locking the old files until they exit. The collectors
(`collect_generations`, `collect_runtime_generations`, orphan reclaim)
treat a lease in either place as held, and drop the lease directories of
generations they removed.
- `moved_lock(old, new)` takes the old lock first, then the new one, so an
old process and a new one always contend on one file in one order. An old
lock this process may only read (EACCES/EPERM/EROFS) is flocked through a
read-only descriptor; it is skipped only when it cannot be opened at all.
- `_last_used` also reads the `leases/*/*` mtimes, so a launch still counts
as recent use for orphan reclaim.
- Orphan reclaim unlinks `locks/` with the old `.install.lock`, last: on
Windows an open lock file cannot be unlinked.
`runtime_lock`, `collect_generations` and the other frozen old-updater names
keep their signatures.
Refs #151951
`webapp.host` now also accepts one literal IP address of this machine (a LAN or Tailscale address,
IPv4 or IPv6), as `hermes dashboard --host` takes it. On main an enabled Webapp with such a host was
refused: the listener stayed off and `hermes webapp --status` named the error.
The gateway's Webapp then listens on that address and, on the same port, on loopback (127.0.0.1, or
::1 for an IPv6 address), because Desktop and the CLI accept only a loopback origin. Both sockets
serve one app under one boundary state, so sign-in is required exactly as on a 0.0.0.0 bind: the
browser credential is never a way around it, cookie writes come only from the Webapp's own page, a
missing sign-in provider refuses the bind with the gate's message, and webapp.public_url works the
same. Unlike a wildcard bind, the Host check accepts only the address, loopback names and the
Webapp's public host. When the address is on no interface, or the loopback port is taken, neither
socket stays open and the gateway keeps its private listener with the reason.
Only unicast addresses an interface can hold qualify: names, other loopback addresses, broadcast,
multicast, reserved, 0.0.0.0/8, IPv6 link-local and IPv4-mapped addresses stay refused;
the refusal message lists the new choice. Loopback, wildcard and disabled configs behave as on main
(tests/gateway/test_webapp_host_parity.py passes on main and here). The gateway reports the address it is
bound to (an `address` field in webapp-status, only for such a bind). `hermes webapp` opens it, ahead
of a Web Access LAN registration, which never sends the browser to another address: when that
registration names one, the command says Nous sign-in cannot finish here. `--status` prints the
bound address and the loopback one this machine's clients use, and names a different webapp.host in
config.yaml that waits for a restart. Web Access counts the address as LAN. Docs: configuration, desktop, cli-commands, gateway-local-sessions.
The install used to end with a one-line pointer at `hermes plugins config`. From a
terminal it now lists the declared settings with their values and asks "Edit
these now?" (default No; default Yes, naming them, when a required setting is
empty). Scripts, HERMES_NONINTERACTIVE and brief setup-wizard installs keep the
one-line pointer and never read stdin. The offer is the last step, so a Ctrl-C
there leaves a complete install.
Plugins declare their settings in config_schema and requires_env, and the Desktop
renders them as a form, but the CLI had no way to see or change them short of
hand-typing plugins.entries.<id>.settings.<key>. `hermes plugins config <name>`
lists every declared setting with its current value and edits one at a time
(choices and bool as pickers, numbers and JSON type-checked, secrets masked),
saving through the same writers as the Desktop form: save_plugin_settings for
config.yaml and the PUT /api/env credential route for .env. Without a TTY it
prints the settings instead. plugins show and install point at it.
plugins_settings.py becomes a package (fields.py unchanged, facade re-exports).
A fresh `hermes setup` asked a mode question, then (Quick Setup) a Nous
Portal sign-in, a terminal-backend menu, a messaging checklist and the
service question. It now asks one thing, "How do you want to power
Hermes?":
Keep my imported model (...) when an agent import brought one
Free, start now: no account, no API key when the welcome trial is claimable
Sign in to Nous Portal
Use my own API key or a subscription (ChatGPT, OpenCode Go, ...)
Full setup
Blank Slate
The first four set up that model and default everything else, then print
a short primer: hermes model, hermes setup gateway, hermes tools,
hermes desktop, hermes setup. Full setup and Blank Slate are unchanged.
The free row claims the same once-per-OS-user welcome trial the desktop
claims. welcome_trial gains a second claim surface, "cli_setup", allowed
only when a person answers setup in a real terminal: stdin and stdout are
TTYs, not a container, not CI, not a dashboard/desktop-spawned run. Every
other blocker (guests off, an identity, a provider, a used machine) is
shared with the desktop. A claim that fails offers the two sign-up rows.
A stdio MCP server that owns a single-writer resource (a PGLite datastore lock, a
device, a pid file) can only ever have ONE live child system-wide. When a second
Hermes context starts, its own copy of the child dies before the MCP handshake
because the resource is already held:
GBrain's local database is already open through 'gbrain serve' (MCP, PID 2509385)
The initial-connect ladder then burns its 3 attempts, the server parks, and
_PARKED_RETRY_INTERVAL makes the parked server self-probe every 300s - each probe
spawning another child that is guaranteed to lose the same race. The loop is
unbounded and never converges: measured here at ~285 park events/day over 18 days
(16,068 spawn attempts). The functional damage is to triage - errors.log fills with
"parked until a reconnect is requested" lines and buries real failures.
Two changes:
- New `single_instance: true` stdio server option. When the initial ladder is
exhausted and the child never reached the handshake, the server parks QUIETLY:
no timed self-probe at all, because the conflict is provably unwinnable (the
resource is held by another process). Only an explicit reconnect
(/reload-mcp, `hermes mcp` refresh) revives it, which is the correct trigger -
that is what happens once the owning instance exits.
- The parked self-probe now backs off for everyone: _PARKED_RETRY_INTERVAL (300s)
doubling per consecutive still-failed probe, capped at _PARKED_PROBE_BACKOFF_MAX
(3600s), and reset by _mark_session_proven() once a session is healthy again.
A transient park keeps its original cadence, so nothing recovers more slowly
than before in the ordinary network-blip case.
Tests: tests/tools/test_mcp_single_instance_park.py (new) covers the quiet park and
the backoff ladder, cap and reset.
Verified on a566d20d22 (upstream main at the time of writing), diff applies clean:
- 16/16 in the targeted set: the new file plus test_mcp_parked_self_probe.py,
test_mcp_parked_probe_no_browser.py, test_mcp_rapid_drop_budget.py,
test_mcp_reconnect_log_hygiene.py.
- The wider tests/tools/test_mcp_* + connectors run shows only PRE-EXISTING
failures in test_mcp_oauth_manager.py (24 failed / 6 passed) - identical on a
pristine checkout with the patch reverted, so not a regression from this change.
The Hermes Marketplace replaces them and the portal already redirects both
routes there. The published feeds (plugins.json, skills.json, skills-index.json)
and their generators stay.
Messaging is its own page (sidebar, command palette), not a Settings tab, so a user who opened
Settings looking for it would not find it. Every line this PR adds now names the Messaging page:
the confirm and done screens, the user guide, the CLI reference, the import's printed hint.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
A bot token answers to one running Hermes at a time. The transfer now
brings Telegram, Discord, Slack and every other messaging bot over with
its token and settings but switched off, so the computer it came from
keeps answering until the user switches each bot over by hand.
`hermes import --keep-host --messaging-off` (the Desktop transfer route
always passes it; the undo never does): in the root home and in each
profile the archive carries, every bot the archive would run (an
`enabled: true` block, or a token in that home's .env with no `enabled`
set) gets `platforms.<id>.enabled: false`, the switch Settings >
Messaging writes, inside the same merged config.yaml the keep-host
restore publishes. The explicit false sets the gateway's
_enabled_explicit marker, so the env token cannot re-enable it, and
turning the switch on in Settings > Messaging is the only step needed.
The import prints `Messaging switched off: <names>`, the action status
returns them as `messaging_off`, and the Desktop done screen names them.
The confirm note says the bots come over switched off.
`--keep-host` was a second restore wrapped around `hermes import`: a
`_KeepHostZip` proxy merged every member named config.yaml/.env, a separate
writer published auth.json members without the import's path checks, and a
prune ran after the maintenance reservation was released. Reviews of #156330
reproduced the results: a `../x/auth.json` member written outside the home, a
symlinked skills/ emptied through the link (and missing from Undo), a skill's
templates/config.yaml stripped, a destination-only profile half-emptied while
its gateway ran, comments lost, and an Undo that left the source's
cron/jobs.json behind.
Now keep-host is a per-member policy (`KeepHostImport`) inside
`_import_members_exclusive`, under the same `exclusive_maintenance`
reservation (which also covers every profile the archive writes into):
- Every member goes through the import's own normalize + resolved-root
checks. Only the root home's config.yaml/.env and the root's and each
profile's auth.json are merged; everything else, including a named
profile's config and a skill's files, is copied unchanged.
- config.yaml is written onto the archive's own document with the
comment-preserving `atomic_config_replace`; auth.json goes through the auth
store's lock and writer (`_auth_restore_target`, `_save_auth_store`);
.env under `_env_write_lock`. When the merge changes nothing (an undo), the
archive's bytes are published as they are.
- Replace: after a restore with no errors, files the archive lacks are
removed in the root home and in every profile the archive carries (the
backup's own walk, so links are never entered), and a missing auth.json/
.env/config.yaml leaves only the host-owned part. A profile only the
destination has is left untouched. Databases, logs, runtime records,
lock files, install_id, webapp/ and shared/nous_auth.json stay.
- A folder the archive writes into that is a symlink refuses the import
before any write.
- The undo point is taken after the gateway drained, under the reservation,
with the `hermes backup` collector (`_external/` memory-provider files
included, plus the external files the archive will overwrite). The import
owns its path and prints `Undo point: <path>`; the last 3 are kept. A
restore that wrote files and failed leaves a marker; the next keep-host
import reuses that first undo point. The hidden `--undo-point` flag is gone.
- "Import refused; no files restored" is printed only for a refusal before
the first write (`KeepHostRefused`, `OwnershipConflict`).
- `s6-svc -O` runs inside the try; an unprobeable s6 slot refuses.
Includes kvnloo's `_external/` undo-point fix (cherry-picked as the previous
commit) and BearHuddleston's root-only merge, both folded into this design.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
Co-authored-by: kvnloo <7121943+kvnloo@users.noreply.github.com>
The restore half of Settings > Backup & Transfer. `hermes import <zip> --keep-host` restores a
`hermes backup` archive over an agent whose host provisioned part of it (a Hermes Cloud agent):
- auth.json: the destination keeps its Nous Portal sign-in (providers.nous, nous pool rows,
active_provider when nous); every other login comes from the archive. Merged against the live
store under the auth lock; the archive's Nous tokens never land on disk.
- config.yaml: HOST_CONFIG_KEYS (model, providers, fallback*, auxiliary, nous, auth, web, image_gen,
video_gen, tts, stt, dashboard, webapp, cron, session caps) keep the destination's value.
- .env: NOUS_*, HERMES_*, TOOL_GATEWAY_*, API_SERVER_KEY keep the destination's lines, in place.
- skills/ and memories/ become exactly the archive's (replace, not merge).
- A full backup of the destination is written first (backups/pre-transfer-*.zip, the undo point);
`hermes import <it> --force --keep-host` puts the agent back.
- In the s6 container the gateway owns state.db, so a plain import refuses it. --keep-host marks the
gateway's slot run-once, asks it to drain and exit over its control socket (pause-for-update), waits
for the profile lock, restores, and starts the slot again.
REST: POST /api/ops/import-upload and /api/ops/import take keep_host and answer the undo archive;
the upload gets a 32 GiB bound instead of the 100 MB managed-file cap. GET /api/ops/backup/chunk reads
a dashboard-written backup in base64 slices (JSON-only clients such as Desktop OAuth connections).
GET /api/cloud/agents lists the Nous account's Hermes Cloud agents for a Webapp tab.
Co-authored-by: SHL0MS <SHL0MS@users.noreply.github.com>
Every consumer that needs "when does this session's cached prompt expire?" now reads one
answer, agent/prompt_cache_clock.py:cache_window(), instead of re-deriving it from _cache_ttl.
- Per successful attempt the clock records the tier actually on the wire (cache_control ttl,
prompt_cache_options.ttl, prompt_cache_retention, read from the sent payload), the send time,
and the tier the response proved: Anthropic cache_creation.ephemeral_5m/1h_input_tokens,
OpenAI Responses cache_write_tokens_details.ttl_30m/12h_tokens. normalize_usage keeps that
split as CanonicalUsage.cache_write_by_ttl instead of dropping it.
- Per-route rules are a dict of small handlers: native Anthropic proves via the split;
OpenRouter Claude is declared (live-probed to honour 1h); routes with a ceiling are clamped;
other Anthropic-wire gateways assume 5m; OpenAI GPT-5.6+ proves via ttl_30m/12h or declares
the documented 30m minimum; pre-5.6 assumes ~30m (5m on in_memory); implicit caches are
unknown. expires = latest read-or-write send time + the written tier. A route switch,
fallback, session rotation or compaction makes it unknown.
- Route TTL ceiling is data: ProviderProfile.prompt_cache_max_ttl (Nous ships "5m", because
the Portal's upstream drops 1h after ~7 min and bills 5m), overridden per provider by config
prompt_caching.route_ttl_ceilings. effective_cache_ttl uses the same helper, so Hermes stops
asking Nous for 1h. A custom endpoint at the Portal host gets the Nous ceiling.
- Persisted as nullable sessions.prompt_cache_clock (JSON) through the existing token batch;
restored lazily on resume, falling back to the newest assistant row (assumed).
- Codex app-server: read cacheWriteInputTokens instead of hard-coding cache_write_tokens=0.
- /context shows "Prompt cache: warm until HH:MM (…; 1h, proven)", "expired … ago" or
"unknown (…)". The surface is absorbed from #142387 (render/duration helpers, the
SessionContextBreakdownResult.prompt_cache contract and translations), reworked onto the clock.
Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
tickets --serve answers purpose interactive with the WebSocket ticket Desktop's local connection asks for (session-ticket, scope host, the store's 30 s TTL), so an SSH client's one socket selects every profile the gateway serves. The probe lists the purpose. A profile on such a request is invalid_request. The ticket attach returns is unchanged.
A --serve request line may name another profile the same gateway serves ("profile"), and --serve
also mints native-profile-create and native-profile-registry: the grants Desktop's local
connection uses for ?profile= routes and for profile create/rename/delete, asked of the same
control socket. Without "profile" a request is answered exactly as before. --probe lists the new
purposes and reports windows_service_session. The gateway is unchanged.
`--probe --json` prints the protocol version and the ticket purposes and touches no
gateway. `--serve --json` finds the running gateway as `attach` does (never starts one),
prints a hello line with its endpoint, then answers each stdin request line with one
single-use native-http ticket until stdin closes.
The mint is the one `attach` already uses, moved into `mint_ticket` so both commands
share its error mapping. Adds the client contract page for SSH clients.
A context file the containment check refused read as "", the same as a failed read, so the /context manifest stat'ed the path, followed the link to the refused target, and reported it as unreadable or empty. The refusal now returns None and the manifest lists it as skipped, without touching the target. The symlink tests skip on hosts without symlink privilege.
Finding 'Precedence advice is too broad': a setting an adapter reads from its environment directly
(WHATSAPP_REPLY_PREFIX) still prefers the environment; the new order covers the YAML bridge only.
The YAML -> env bridge skipped any name already present in os.environ unless
its ownership marker matched. A value merely inherited from the launcher
(TELEGRAM_REACTIONS=true from a parent process, not .env, not a previous
bridge write) therefore beat platforms.telegram.reactions: false, against
configuration.md's "config.yaml wins for non-secret settings".
Now only a .env / managed .env / external secret source value is kept over
the YAML key (#109032); any other preset value is replaced and the bridge
takes ownership via its marker. Removed-key retraction is unchanged: it only
drops the bridge's own marked values.
Fixes#110295
The post-start grace (HERMES_TELEGRAM_FOLLOWUP_GRACE_SECONDS, default 3s)
only held TEXT follow-ups. A voice note sent ~3s after the previous one
interrupted the turn already answering it: that turn's response was thrown
away, and only the merged later voices got a reply (voice 2 of 2-3-4 silently
lost). Voice now gets the same grace on both the legacy busy path
(_hm_busy_telegram_grace_queue) and the durable FIFO preempt path
(_hm_busy_preempt): it queues, merging its audio into the pending slot, and
the running turn finishes and sends.
Fixes#31328
Review fixes on #155524:
- systemd/launchd gateways are stopped through their supervisor from the start, so
Restart=/KeepAlive cannot respawn one while another is still being killed, and a
system unit gets the sudo path instead of a silently refused SIGTERM.
- Each gateway is stopped on its own thread against its own 12 s deadline, so the
bound no longer grows with the fleet.
- The kill of a supervised survivor goes through systemctl kill.
- Help and docs: the immediate stop is Linux/macOS (Windows keeps its drain), and
--force is chosen when starting an update, not to interrupt one already waiting.
- Tests gate on platforms("posix").
`hermes update` waits up to agent.restart_after_turn_timeout (30 min by default) for every
gateway's in-flight work before it moves the checkout. --force is the explicit "stop
everything now": the POSIX pre-swap pause names what each gateway was running, asks it to
stop immediately (the force control-socket verb when the gateway answers it, else the
planned-stop marker + SIGTERM, which enters stop() at once), SIGKILLs anything still alive
after 12 s, then the update runs and the paused set restarts on the new code as before.
The Windows meaning (proceed past a concurrent hermes.exe) is kept under the same flag;
--force-venv is unchanged.
Point readers at webhook_subscriptions.json for the full value, and fix
the troubleshooting step that sent them to `hermes webhook list`,
which never printed it.
Refs #68040
is_local_endpoint() reads process://<name> as an unqualified LAN host, so
DirectSDK and every other external_process provider took the single-slot
local-server branches: a "prompt is too long" with no token count failed the
turn with "wait and /retry" instead of compressing (the session stayed stuck
until /new), and init/context resolution ran the Ollama/llama.cpp probe
waterfall against a child process.
agent/process_transport.py adds two predicates keyed on the provider
profile's auth_type, never on the URL:
- is_local_server(base_url, provider): a local HTTP server. Used where the
call site means one request slot, a local server to probe, or local-server
copy (overflow rejection, stream load notice, Ollama num_ctx, local context
probes, minimum-context remedy copy, reasoning carriers, Ollama vision
probe, stale-aux pins, the dashboard local_endpoint flag, the local-model
metrics bucket, the CLI banner fix hint).
- waits_like_local(base_url, provider): silent before the first token. Used
where the call site means patience (stream stale ceiling, stream read
timeout, aux first-token window), so external-process providers keep the
900 s budget they had by accident, now on purpose.
Builds on the salvaged C#129157 (dskwe), which added the process:// string
check at the overflow site; that check is replaced by the auth_type rule and
its test now covers acp:// too.
A plugin with session-less background work (re-scoring its own data,
suggesting a cleanup) had to run its own timer. register_idle_task(name, fn,
*, interval_hours, min_idle_hours=2, first_run="defer") puts it on the skill
curator's scheduler instead:
- polled from every site that drives the curator (gateway housekeeping per
served profile, CLI/TUI startup maintenance, the hermes serve maintenance
tick) through one run_idle_jobs(): the curator, then the active profile's
plugin tasks;
- the curator's gates via agent/idle_schedule: the min-idle check, the
interval (floored to 1 h) whose first observation seeds last_run_at and
defers one interval (first_run="immediate" opts out), and the O_EXCL claim
file so a task never overlaps itself across threads or processes;
- state per (profile, plugin, task) in <plugin data dir>/idle-tasks/<name>.json
(last_run_at, run_count, paused, last_summary, last_status, last_error);
a manager polled outside its own home runs nothing;
- exceptions are logged and recorded, never raised into housekeeping;
- the registration is a PluginRegistration, so unload stops the polling;
- `hermes plugins idle-tasks [plugin] [--pause TASK | --resume TASK]`.
fn receives plain data (name, idle_for_seconds, last_run_at, run_count) and
reaches its ctx through its closure, so the payload also crosses the isolated
plugin host. No capability: the scheduler only calls the plugin's own
function; model calls inside it go through ctx.llm's existing gate.
plugins.py and gateway/run.py are over the file-size cap, so the mixin lives
in hermes_cli/plugins_idle_tasks.py and neither file grows.
Since #94876 bare /debug uploads nothing; tip t346 (all locales), the zh-Hans
/debug rows and the cli-commands /debug mention still said it did.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
Slash-command descriptions (all locales), tip t346, slash-commands docs and
the bug/setup issue templates still said the public paste carries logs.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
The public paste (hermes debug share, gateway /debug, dashboard
POST /api/ops/debug-share) uploaded secret-redacted log tails and full
logs. Subtractive redaction cannot recognise IPs, room IDs, display
names or message bodies, so those reached a public URL. The public
upload is now built from an allowlist in hermes_cli/debug_summary.py:
versions, install kind, platform/built-in toolset names, config.yaml
key shape (no values; user-named keys counted), and WARNING+/exception/
HTTP-status counts. --no-redact can no longer put logs on the public
paste; --nous and --local keep the full redacted bundle.
Refs #46006