Commit Graph

8455 Commits

Author SHA1 Message Date
calvinnwq
eb1d54ad76 fix(kanban): attribute worker turns to the dispatcher, not the operator
The dispatcher spawns `hermes chat -q "work kanban task <id>"` with no turn
author, so memory providers filed the dispatcher prompt and the worker's reply
under the human user's peer. Honcho, for example, derived facts such as
"the user mentioned kanban task t_..." and promoted worker progress notes into
the user's profile.

The spawn now sets HERMES_TURN_AUTHOR to a bot author (`bot:kanban`), and the
non-quiet `-q` one-shot path consumes it the same way `-Q` already does and
forwards it to every turn of the run, including recovery and goal follow-ups.
Providers that understand bot authors route these turns away from the human
peer; a human `-q` run keeps today's unattributed call shape.
2026-10-26 13:04:58 +05:30
Teknium
765933299d fix(compression): a prepared summary is never redone over a moved tail cut
With compression.prepare_ahead, compress() re-planned the tail cut and threw the
completed background summary away whenever the fresh cut landed before the
summary's boundary (the no-LLM prune made tail rows cheaper, tool-group
alignment moved the cut), then wrote a second summary inline while the user
waited. That breaks the one-summary rule: once the background summary exists it
is used, and everything after its boundary is the tail.

The splice check no longer consults the fresh cut at all. A summary is still
discarded only when the messages it covers changed (rewind, shape change, other
session, moved head). The pass planned its own window with a full tail, so the
tail is never empty. The now-unreachable inside_tail reason leaves the
(unreleased) prepared-compaction metric contract.
2026-10-26 00:10:23 -07:00
Teknium
be32e2110d test: read the takeover PTY through an end marker, not one read
test_takeover_revokes_waiting_workers_and_waits_for_an_admitted_write[True]
writes OLD then NEW to a pseudo-terminal's master and then read the slave
once. A write to the master returns before the slave can read it: Linux
hands the bytes to the slave's line discipline later, from a kernel worker,
so under load the first read returns b"OLD\n" with NEW still on its way.
An instrumented copy recorded both master writes returning in order, the
read seeing only OLD, and NEW arriving ~0.03-0.5 ms later (CI: #144804,
run 40274889783).

The test now writes an END marker to the master once every sink write has
finished and reads until it arrives. PTY delivery is ordered, so the marker
comes after everything the session wrote, and the assertion compares the
complete stream. That is also stricter: a revoked worker writing late (the
production race the [False] case guards) now shows up as NEW, OLD, END,
which the single read could miss.

Repro: a relay between the real slave and the test that delivers each line
0.5 s after the one before fails base on every [True] run (20/20) and passes
the fix (0/20).
2026-10-25 23:49:44 -07:00
Teknium
0107da5d2a fix(telemetry): the pre-os._exit flush drains the root profile's host-count store too
Follow-up to #144850. flush_before_hard_exit drained only the per-profile
runtime stores, so a deferred write to the root (default) profile's store,
where the host-level active-profiles accumulator lives and which no runtime
owns, was still lost at every graceful os._exit (gateway, compute host,
kanban worker, slash worker).

Each SharedMetricsStore now registers itself in a process-level list the
first time it defers a write (next to its atexit drain), and the bounded
exit flush drains that whole list within the same budget. Each deferred
write runs against the store that deferred it, so no profile's rows land
in another's database; collection off creates no store, so nothing is
registered.
2026-10-25 23:30:24 -07:00
Teknium
941d126393 test: fix the launchd job test's child source (stray brace) 2026-10-25 23:19:22 -07:00
Teknium
aa69f59fbc test: the launchd job test names what the job did when the command never reported 2026-10-25 23:19:22 -07:00
Teknium
b5a73d46a0 fix(gateway): a Desktop-started macOS gateway keeps LAN access after Desktop quits
macOS Local Network Privacy attributes a process to its responsible app. The gateway that
`hermes gateway ensure` (Desktop's launch path, CLI clients) and the update-time restart
watcher start is a plain detached child, so it is attributed to whichever app started it.
The gateway outlives that app by design; once the app quits, macOS holds every surviving
descendant responsible for itself, and a bare venv Python is denied: every connect to a
model server on another machine fails with `[Errno 65] No route to host`, even though Hermes
is allowed in Local Network settings. Reported in Discord: Test and chat against a LAN Ollama
broke on every Desktop quit/reopen and after in-app updates, and worked only with a gateway
run from Terminal or the installed launchd service (which already runs through osascript,
#71206).

On macOS both spawn sites now start the gateway as a one-off launchd job through the same
osascript JXA wrapper the installed service uses, so osascript (an exempt Apple platform
binary) stays the responsible code for the gateway's whole life. Nothing is installed: the
plist is loaded once and deleted, it never lives in ~/Library/LaunchAgents, has no KeepAlive
and is labelled outside ai.hermes.* so no fleet scan or restart route mistakes it for a
service; the gateway sees XPC_SERVICE_NAME=0 and still reads as unsupervised. When launchd
refuses the job (no GUI session, e.g. over SSH) the old plain-child spawn runs instead.
2026-10-25 23:19:22 -07:00
Teknium
9810951353 fix(gateway): stamp the clean exit before the bounded metrics flush
Review finding 3 on #144850. The flush (up to 3 s with a managed call wedged
in flight) ran before _mark_exited, so a supervisor kill during it recorded a
graceful stop as an unclean death. Order is now release locks, stamp the clean
exit, flush metrics, drain logs; the early-exit paths keep releasing the
PID/lock first. The wedge test now drives the real exit funnel with a real
Relay managed call in flight and asserts both the bound and the ordering.
2026-10-25 23:13:53 -07:00
Teknium
b991bd203b fix(telemetry): exit flush applies each profile's own send consent and collection gate
Review findings 1 (critical) and 2 on #144850, plus the send-pass sibling.

A multiplex gateway or compute host exits from the launch profile's scope, and
the os._exit flush (like main's atexit hook, which has the same flaw) shut down
every profile's runtime under it: profile B (send: false) got the launch
profile's send=True reconciled into its store, an open-ended consent window and
a send pass over its outbox; a profile that turned collection off since its last
turn still had its open sessions written at exit.

- _Runtime.shutdown binds its own profile home (host.profile_key) for every
  caller (atexit, shutdown_runtimes, tests) and checks enabled() inside that
  scope first: a revoked runtime is deactivated, dropping its data unexported.
- _flush_and_export exports under the owner's scope, whoever triggered it.
- The send pass thread inherits that scope (spawn_context_thread): on main it
  ran on a bare Thread, so still_consented() re-checked the LAUNCH profile's
  consent (B's pass read A's send:false; a B revoke would not stop its pass).
- Tests: wait_until replaces the sleep-poll; one three-profile invariant test
  through the real gateway exit funnel.
2026-10-25 23:13:53 -07:00
Teknium
7c4e069596 fix: flush opt-in shared metrics on the sibling graceful os._exit paths
The same skipped-atexit loss on the other graceful hard exits: the compute host's
shutdown frame and orphan exit (both via close()), a SIGTERMed kanban worker (whose
normal one-shot exit already runs shutdown_runtimes) and an orphaned slash worker
each now run the bounded flush_before_hard_exit before os._exit. One test file covers
every path with a real NeMo Relay runtime and an open session; red on main.
2026-10-25 23:13:53 -07:00
Teknium
7f64198bc1 fix(compression): a publish-then-discard race and a cancelled splice are counted right
Greptile on 815681917c3:
- a boundary landing after the pass published (and cleared its pending token) but before the
  waiting compaction read the summary still read as a failed pass; take() now notices a discard
  that happened during its wait and leaves the boundary's row as the only one;
- compaction_failed was lost when a pre-commit cancel restored the compressor's attempt telemetry
  (and its prepared_summary flag) before the record was emitted; the spliced attempt id now lives
  on the prepared-compaction state, outside the restored snapshot;
- the deadline-extension test starts its 2 s deadline only once the pass is running.
2026-10-25 22:55:11 -07:00
Teknium
d773589f7c fix(compression): every prepared summary ends counted as used or discarded
Re-review findings:
- a summary take() handed to compress() that the compaction then aborted or no-opped before
  adopt() spliced it was counted nowhere; it is now counted once at the next touch as
  discarded/compaction_aborted;
- a session boundary landing after the pass published but before the waiting compaction woke
  read as a failed pass (a second discarded row); the wake now reads the entry and the cancel flag
  under one lock, so the boundary's row is the only one.
2026-10-25 22:55:11 -07:00
Teknium
5bdf1de16f fix(compression): count each prepared summary once, at the splice
Independent review of the telemetry found:
- a session boundary that woke a waiting compaction was counted twice (the boundary's discard
  plus the woken wait's 'discarded_while_waiting'); the boundary's row is now the only one and the
  dead reason code is dropped from the vocabulary;
- 'used' was recorded in take(), before a stale-attempt abort could still drop the summary; it is
  now recorded by adopt(), the splice itself, with the wait carried on the entry;
- the cancel reason is set under the lock, so a pass finishing in that gap reports the real reason;
- skipped_busy counts once per refused window instead of every tool batch.
2026-10-25 22:55:11 -07:00
Teknium
4501b3f80b feat(compression): record every prepared-compaction pass and splice outcome
Wire hermes.prepared_compaction.count into the prepared-compaction state
machine so a profile that opts in to shared metrics reports whether its
passes pay off, and if not, why:

- pass side (pass thread): pass_started / skipped_busy (process slot
  cap) / pass_completed (summary published) / pass_failed (classified
  as an inline attempt would be, terminal summary failure first) /
  pass_cancelled (reason set by whoever cancelled: superseded,
  session_boundary, wait_timeout, host_cancelled) / internal_error.
- compaction side: used (wait bucket, aux_fallback_main when the pass
  fell back to the main model), discarded (closed miss code + wait),
  auto_disabled (first memory-provider compaction), and compaction_failed
  from the attempt telemetry when a spliced compaction did not commit.

Splice-miss reasons become a str subclass carrying a closed code, so the
log text is unchanged. The pass thread already copies contextvars, so its
rows land in the owning profile.
2026-10-25 22:55:11 -07:00
Teknium
4ea24baeb1 feat(shared-metrics): count prepared-compaction adoption and outcomes
Opt-in shared metrics could not say whether anyone turns on
compression.prepare_ahead, or whether the passes it starts pay off.

- hermes.install.snapshot gains compression_prepare_ahead (on/off), read
  from the profile config with the agent's own truthiness. Pre-upgrade
  snapshot rows keep a legacy field set and the v4 schema field is
  optional, so they still validate and package.
- New closed-enum counter hermes.prepared_compaction.count (mark name =
  metric name, projected by the decision-mark table): event, origin,
  reason, failure_class (compression vocabulary), wait_bucket.
  record_prepared_compaction() takes raw values, normalises inside, is a
  no-op unless collection is on and never raises.
- Vocabularies live in shared_metrics_prepared_compaction.py (the
  contract sits at the 2,000-line cap); the contract imports it.
- v4 schema extended in place (additive), docs row + snapshot bullet,
  relay smoke asserts the snapshot field.
2026-10-25 22:55:11 -07:00
Teknium
46adcf7d40 fix(sessions): Windows NUL stdin is unattended, not a terminal decline
The Windows CRT reports isatty() True for the NUL device, so
`hermes sessions delete s-old < NUL` read EOF as a Ctrl-D decline and
exited 0. EOF counts as a terminal decline only when the console API
confirms a real console (the gateway_windows check from #113977); else
it is nobody-could-answer and exits 1. A real stdin=DEVNULL child test
runs on every OS lane.
2026-10-25 22:36:59 -07:00
Teknium
2dfe39361d fix(sessions): Ctrl-D at a terminal is a no; an over-cap export exits 1
Independent review round:
- EOF at the prompt meant "nobody could answer" even on a real TTY,
  so Ctrl-D printed the non-interactive --yes hint and exited 1. At a
  terminal it is a decline again ("Cancelled.", exit 0, as on main);
  /dev/null and empty pipes still exit 1.
- sessions export refusing a session over sessions.max_export_messages
  printed an error and exited 0. It exits 1 on all three selection
  paths. The backup round-trip test never asserted the exit code (its
  helper serves the success legs too); its refusal leg now expects
  SystemExit(1) alongside the existing assertions.
2026-10-25 22:36:59 -07:00
Teknium
b9e5df60fd fix(sessions): Ctrl-C at a sessions confirmation exits 130, not 0
The shared prompt turned KeyboardInterrupt into a decline, so
`hermes sessions optimize-storage && next` ran `next` after the user
interrupted (main's inline optimize-storage prompt let Ctrl-C through).
An interrupt now says nothing was changed and exits 130 at every
sessions confirmation; an explicit "n" still exits 0.
2026-10-25 22:36:59 -07:00
Teknium
61e86c74ca test(sessions): one table per failure class for the exit-code contract
Folds the contributor's repair test into the failure-path table (adds the
optimize VACUUM failure row, drops the missing-id row main already
exits 1 on) and adds the no-answer table:
optimize-storage, delete, archive and prune exit 0 on an explicit "n",
exit 1 on EOF at the prompt, and change no row or table. All nine cases
are red on origin/main.
2026-10-25 22:36:59 -07:00
John Paul Soliva
204ccada74 fix(sessions): export's refusals and failures exit non-zero too
_cmd_export printed its usage errors, refusals (bulk export without a filter, --delete-after-verified without --yes or --session-id), not-found ids and failed verified deletes, then returned None, so hermes sessions export still exited 0 when it did nothing. Every such path now returns 1, as prune, archive, repair and optimize do; a --dry-run preview still exits 0.

Ported from #90970, which covers the same paths but targets the pre-split sessions_cmd.py.

Co-authored-by: pierrenode <298902573+pierrenode@users.noreply.github.com>
2026-10-25 22:36:59 -07:00
John Paul Soliva
c479245a60 fix(sessions): repair, optimize and refused bulk actions exit non-zero on failure
`hermes sessions repair` printed "Repair failed" and exited 0, so a
`hermes sessions repair && hermes gateway start` chain or a cron health
wrapper read a store that is still unopenable as fixed. `sessions optimize`
and `optimize-storage` did the same when VACUUM or the index rebuild failed,
when the disk preflight refused, or when FTS5 was unavailable, and
`sessions archive` with no filter and `prune --never-active` with an
unparsable --older-than refused the action but still exited 0.

aca40d1d63 moved delete/rename/prune/import to `return 1` and #103321 did
repair --check-only; these are the remaining maintenance paths that print a
failure and fall through to a bare return, which the dispatcher maps to 0.
2026-10-25 22:36:59 -07:00
Teknium
90e8b187ce test(telemetry): the closed-turn mark test proves its marks came after the turn closed
go.wait(5) ignored its result, so on a slow runner the worker could emit while the turn was
still open and the test passed without exercising the fix.
2026-10-25 22:28:13 -07:00
Teknium
65ee955417 fix(telemetry): keep process marks from background work that outlives its turn
A thread started with the turn's contextvars (spawn_context_thread, copy_context) still holds that
turn in relay_runtime._CURRENT_TURN after end_turn closes it. relay_instrumentation_enabled() reads
False for a closed turn, and record_process_mark / record_process_marks_saved / the
post_auxiliary_call hook returned on that gate before emitting anything. So every process-level
mark such a thread recorded after the turn ended was dropped silently: aux-token rows from title
generation finishing late, and any decision mark a turn-end background job reports when it is done.

The closed-turn check (e1caa611bf) stops new Relay scopes being pushed under a finished turn. A
process mark has no owning task and pushes no scope, so a closed turn now no longer gates it. A turn
Relay skipped (a concurrent turn on the same session) still gates, open or closed, as before.
Scope-creating hooks (task, model call, tool) keep the full gate.
2026-10-25 22:28:13 -07:00
Teknium
4d0d67ba38 fix: plugin-host profile extraction no longer imports hermes_cli from the launch directory
The one-shot profile extraction child ran as python -m hermes_cli.plugin_host_child with no
cwd and no safe-path flag, so the directory Hermes was launched from sat ahead of PYTHONPATH
on sys.path and a hermes_cli/ package there ran instead of the Hermes tree's. Spawn it with
-P and cwd=<hermes home>, matching the long-lived plugin host.
2026-10-25 21:57:29 -07:00
Teknium
5b32cfc230 Merge pull request #144665 from Adolanium/fix/webapp-host-terminal-close
fix(webapp): detach a host terminal whose tab closes behind a full input queue
2026-10-25 20:55:41 -07:00
Calvin Ng
5239b1323e fix(models): make GLM-5.3 the silent default model (#144810)
GLM-5.2 became the silent default (the model Hermes lands on when the user
never picked one) in #64635 as a capable low-cost pick. GLM-5.3 has since
superseded it at about the same price on Nous Portal and OpenRouter, with
the same 1M context, and both curated catalogs already list it.

Move every copy of the default together:

- PREFERRED_SILENT_DEFAULT_MODEL and the OpenRouter "default" description.
- The "default": true label in website/static/api/model-catalog.json,
  regenerated with scripts/build_model_catalog.py, so clients rotate from
  their cached catalog without a release.
- The TUI's _resolve_model last resort, which hardcoded "z-ai/glm-5.2" and
  would drift on every rotation; it now reads the constant from the
  data-only models_catalog_static module.
- The example manifest in the model catalog reference docs.

The new TUI test pins the no-model fallback to the constant, and the
manifest contract test is renamed since it checks whatever the constant is.
2026-10-26 03:50:53 +00:00
unsupportedpastels
49c34e1096 fix(webapp): ignore a kept LAN sign-in registration in --status on a private Webapp
Web Access keeps its LAN sign-in registration after webapp.host goes back to a
loopback bind. webapp-launch reads that registration only behind the sign-in
gate; a private Webapp opens its loopback launch link. --status still picked the
registration, so it warned that plain HTTP loses features while launch opened a
secure loopback address.

_browser_address now falls back to the registration only when the listener is
sign-in gated, using the condition gateway.run_api.start_gateway_api applies.
2026-10-25 23:49:14 -04:00
unsupportedpastels
86fa3afdf4 fix(webapp): list clipboard reads and the wake word among what plain HTTP loses
navigator.clipboard is undefined on a plain-HTTP origin other than loopback, so the browser terminal pastes nothing, its right-click Paste stays disabled and pasting an image finds no clipboard image. The remote wake word uses getUserMedia like dictation and live voice.
2026-10-25 23:49:14 -04:00
unsupportedpastels
c7bf749b7b fix(webapp): warn in --status about the plain-HTTP address browsers open
The gateway reports its loopback dial origin, so the --status note never fired. Work out the
browser-facing address as webapp-launch does (webapp.public_url, else the LAN address Web Access
registered sign-in for) and print the note for that address.
2026-10-25 23:49:14 -04:00
unsupportedpastels
477937cfb8 fix(webapp): say what plain HTTP loses when the Webapp's address is not secure
Browsers keep secure-context APIs from a plain-HTTP origin that is not
loopback: crypto.subtle (the bot screen viewer), mediaDevices (dictation
and live voice) and Notification (system notifications). Nothing told
the user before they hit the missing feature.

hermes webapp and hermes webapp --status now print a note naming those
features and the way to keep them (HTTPS through webapp.public_url, or
an SSH tunnel to 127.0.0.1) when the address they open or print is
plain HTTP on a host other than localhost, *.localhost, 127.0.0.0/8 or
::1, which browsers already treat as secure. The Webapp docs list the
same features.

Refs #144648 (WA-14)
2026-10-25 23:49:14 -04:00
Adolanium
71d4aac7cc Merge upstream main into fix/webapp-host-terminal-close
Keep both constants next to _INPUT_BATCH_FRAMES: _LIVENESS_PROBE_SECONDS from this branch and _RESIZE_ANSWER_SECONDS from main's terminal redraw fix.
2026-10-26 05:39:26 +02:00
unsupportedpastels
c2c5eef149 fix(webapp): keep -p <profile> in the --no-open hint after a private launch
-p re-homes only the process it is given to, so after `hermes -p work webapp` the hint's bare `hermes webapp --no-open` opened the sticky profile's Webapp instead. The hint now names the profile when -p chose one a bare rerun would not pick.
2026-10-25 23:32:04 -04:00
unsupportedpastels
395c673739 fix(webapp): point to --no-open when a private launch opened no visible browser
On macOS webbrowser.open can return True with no page the user sees: over SSH osascript opens the browser on the Mac's own screen, and a sandboxed browser may refuse a file: page in a hidden folder. After a private launch, say how to get the link. The docs no longer say an SSH session always prints the link: that holds on the BSDs and illumos. The private-launch docstring notes that on macOS the URL reaches osascript on stdin, so the page mainly protects the BSDs and illumos.
2026-10-25 23:32:04 -04:00
unsupportedpastels
e22287fe77 fix(webapp): create the port-claim lock and its folder user-only
The port-claim lock lives in the Hermes root's webapp folder, beside the Webapp's credentials. _file_lock created that folder with the umask's mode (0755/0775) and the lock 0644/0664. Create the folder 0700 and the lock 0600 before taking the lock, and close an existing folder other users can reach with the helper the credential writers use. _file_lock is shared by every Hermes lock and takes no mode, so the files are created here first.
2026-10-25 23:32:04 -04:00
unsupportedpastels
dcbbeeb3fe fix(webapp): refuse a Start with no Nous account before saving a port
plan() chose and saved a standalone profile's webapp.port before checking the Nous sign-in, so a Start refused with "Sign in to your Nous account under Providers first." still wrote the port to config.yaml. Check the sign-in first, so a precondition refusal writes nothing.
2026-10-25 23:32:04 -04:00
unsupportedpastels
0f4ff006c9 test(webapp): race two profiles' port claims in two processes
The threaded test swallowed its barrier's timeout, so if the second Start
was delayed until the first had saved, the unfixed code also saved 9123 and
9124 and the test passed. Threads also could not show that the lock holds
across gateway processes.

Each Start now runs in a spawned process with its own home under one root.
The first holds the port it chose, unsaved, in the faked probe until the
second reaches the port claim: it either waits for the port-claim lock or,
without a lock, probes the same port. Any synchronization timeout fails
the test. At 070c361b77c5 both save 9123. It is not POSIX-only: on Windows
the lock is a cross-process byte lock and spawn is the default start method.
2026-10-25 23:32:04 -04:00
unsupportedpastels
1f3da07f3a fix(webapp): save a standalone profile's port under a lock every gateway shares
Each standalone profile's gateway has its own change lock, so two first Web Access
starts could both probe the same free port before either saved it, and both kept it.
Web Access now chooses the port and writes it to that profile's webapp.port while
holding a file lock under the shared Hermes root (the auth file-lock helper .env writes
already reuse), before the bundle build and registration. A Start that fails after
that keeps the port as its own.
2026-10-25 23:32:04 -04:00
unsupportedpastels
a04e70e226 fix(webapp): pin that live previews can load their CDN libraries
The Webapp page CSP (WA-11) is reverted: ::preview widgets and artifacts
render in sandboxed srcdoc frames that inherit the page policy, and the
libraries they load from cdn.jsdelivr.net were blocked. Headless Chromium
showed a script-src-elem violation, and the CDN was never requested.

This test reads whatever policy the page sends, without importing it, and
fails if that policy blocks a widget's script or stylesheet from the CDN.
A future policy then has to move previews to documents of their own first.
2026-10-25 23:32:04 -04:00
unsupportedpastels
db2054f48e Revert "fix(webapp): send a Content-Security-Policy with the Webapp page"
This reverts commit 859db1d848de562b2396e490ec09fc11ecef2674.
2026-10-25 23:32:04 -04:00
unsupportedpastels
608998b759 fix(webapp): run the launch-page cleanup test on POSIX only
On Windows _open_privately() returns False at once and leaves the earlier
page in place, so the test could only fail there. Mark it posix like the
other page tests, which also puts it in the macOS lane's marked tests.
2026-10-25 23:32:04 -04:00
unsupportedpastels
24954409e0 fix(webapp): open the private launch page under a relative HERMES_HOME
With HERMES_HOME=./my-home the launch page's path stayed relative, so
Path.as_uri() raised ValueError after the page was written. That skipped
the printed fallback and left the page behind. Build the page path from
the absolute home.
2026-10-25 23:32:04 -04:00
unsupportedpastels
43349a8d07 fix(webapp): keep a managed webapp.port when Web Access picks a port
Web Access read a standalone profile's webapp.port from config.yaml as
written, so a port the managed scope sets read as none. Start then chose
9121 and registered the sign-in callback on it, saving dropped the port
because the managed layer pins it, and the gateway still bound the managed
one: sign-in returned to a port nothing served.

Read the port from the file with the managed overlay on top, as the
gateway loads it, still without the defaults. A managed port is kept,
nothing is written over it, and the callback names it.
2026-10-25 23:32:04 -04:00
unsupportedpastels
975446bb88 fix(webapp): give a standalone profile its own Web Access port
A standalone profile that turned on Web Access without its own webapp.port bound 9120, which the default gateway's Webapp holds, so nothing was served and the LAN sign-in callback was registered on the other gateway's address. Start now gives such a profile the first port above 9120 that no other Hermes home claims and nothing listens on, and writes it to that profile's webapp.port, so the gateway binds it, the launcher prints and opens it, the callback names it, and it stays across restarts. The default profile keeps 9120, a webapp.port the user set is never replaced, and with no free port Start refuses and names the setting.

Refs #144648 (WA-13)
2026-10-25 23:32:04 -04:00
unsupportedpastels
166bc0f822 fix(webapp): open private launch links through a user-only page
Where nothing checks who redeems a one-use launch link (macOS, the BSDs, illumos, WSL), hermes webapp printed it, and any local user who read it first could redeem it within its 60 s. TCP loopback has no peer-credential call on those platforms. The launcher now writes the link into a 0600 page in the gateway home's user-only webapp folder and opens that page, so the browser launcher's command line carries only the page's path and nothing is printed. It still prints the link where it cannot open a browser and on WSL.

Refs #144648 (WA-12)
2026-10-25 23:32:04 -04:00
unsupportedpastels
38e6d6fd13 fix(webapp): send a Content-Security-Policy with the Webapp page
The gateway served the Desktop renderer's page to browsers with no CSP, while the sign-in handoff pages carry one. The page now carries a policy derived from the built bundle: entry and lazy chunks, blob: plugin modules, Shiki's WebAssembly, same-origin REST and sockets, plugin HTTPS APIs, media, previews and embeds. Inline scripts stay allowed because sandboxed srcdoc previews inherit the page's policy and a nonce would stop their scripts. No eval, no object, no cross-origin base or form posts, and no page may frame the Webapp. The dashboard's page is unchanged.

Refs #144648 (WA-11)
2026-10-25 23:32:04 -04:00
unsupportedpastels
d436550831 fix(webapp): never resolve a shared container session's /workspace in its own cwd
With terminal.docker_shared_container_key set, every session reuses one
shared:<key> container, which mounts the cwd of the session that created
it. The previous commit took a cwd-mounted session's /workspace from that
session's own cwd, so a second session at another folder read that folder,
and Save (which own_sandbox_only allowed) overwrote it while the agent's
file in the container's real mount stayed unchanged.

Nothing records which cwd a shared container mounted: shared containers
carry no mount fingerprint label, and a cross-process attach never inspects
the container's mounts. So a session on a shared container reads from the
profile's cwd again, as before the previous commit, and a session Save that
resolves there answers 409 "File is no longer in this session's workspace".
Per-workspace containers still mount the session's own cwd.
2026-10-25 23:31:32 -04:00
unsupportedpastels
cdf1091ffc fix(webapp): resolve a cwd-mounted session's /workspace in its own workspace
With terminal.docker_mount_cwd_to_workspace on, a session bound to its own
workspace runs in a container that mounts that workspace at /workspace: the
gateway turn's TERMINAL_CWD is the session's cwd, which bind_turn_workspace
also registers and hashes into the :ws: key. The file routes still took the
mount root from the profile's terminal.cwd (or the process cwd), so a preview
showed that folder's copy and Save wrote it while the agent's file stayed
unchanged.

A session with a workspace key now mounts the cwd that key hashes (the live
binding's cwd, else the session row's), looked up in the session's profile
scope; a cwd whose digest does not match gives no mount root. Its sandbox
is still tried after the mount. MEDIA delivery and requests without a
session binding keep the profile's cwd.
2026-10-25 23:31:32 -04:00
unsupportedpastels
20ba4b2409 fix(webapp): answer a file: URL with an encoded NUL as an invalid path
_is_host_file now decodes a file: URL before it resolves the path, so
file:///tmp/clip%00.mp4 reached Path.resolve() with a NUL, whose ValueError
escaped as a 500 from the stream, read-data-url and download routes. A path
that cannot be resolved is not a host file: the request goes on to the
workspace, which answers 400 "Invalid path" as before the decoding.
2026-10-25 23:31:32 -04:00
unsupportedpastels
d8a472d04a fix(webapp): refuse a session Save once the session's whole sandbox is gone
The Save guard took the session's own sandbox to be the first one whose
directory still existed. When the session's whole sandbox directory was
deleted, the shared profile sandbox became that first one, so a Save the
read had resolved into the shared copy overwrote it. The session's own
sandbox is now the first name in the translator's order whether or not its
directory exists; a Save that resolves into any later sandbox answers the
same 409 as a missing file ("File is no longer in this session's
workspace"). Reads keep the fallback.
2026-10-25 23:31:32 -04:00
unsupportedpastels
db37888d8d fix(webapp): look a file request's session up once
Each session-scoped file route checked its session_id with _fs_owned_session,
discarded the row, and _fs_download_path loaded it again. The route now passes
the row it already has into path resolution, so the ownership check stays in
_fs_owned_session and runs once per request (stream, both ticket routes,
read-text, read-data-url, download and write-text). The lookup itself is still
get_session_detail: there is no lighter existing read that answers the same
404/503 for a session another profile owns.
2026-10-25 23:31:32 -04:00