Commit Graph

12636 Commits

Author SHA1 Message Date
Teknium
dbde5a991a fix(kanban): the owner refuses a worker that dials into a restart wait opened after discovery
connect_gateway's restart-wait refusal read the state discovery returned. A restart that began
between discovery and the WebSocket dial still admitted the Kanban worker on its interactive
ticket into the after-turn wait, where each prompt.receipt answer refreshed its silence budget
and held `hermes update` until the forced-restart deadline.

The policy now rides the ticket: inside outside_restart_wait() the session-ticket request carries
`restart_wait: "refuse"`, the ticket store records it on the grant, and GatewayRuntimeAPI decides
admission from the grant at redeem time, so the owner closes the socket (1013) whenever its
restart wait is open by the time the worker connects. Interactive clients still attach (#139041).
An owner older than the client refuses the unknown parameter; the client re-mints without it and
keeps the pre-dial check rather than stranding the worker until that owner restarts.
2026-10-28 20:40:14 -07:00
Teknium
eace3e056e fix(kanban): a worker cut by a restart's after-turn wait waits for the next owner outside it
`hermes update` with a Kanban card in flight sat in "still draining ... waiting on 1 active
work unit(s): managed run" until agent.restart_after_turn_timeout. The restart wait cuts every
socket opened before it (d710b2e346) so its client goes to the next owner. Since c480d67e5f
the worker redials on any transport loss, and connect_gateway attaches to an owner in its
restart wait (that window admits clients so a human can answer a parked prompt, #139041).
The worker re-entered the wait and kept polling prompt.receipt. Every answer refreshed its
silence budget, so the worker never exited, `_watch_submitter` never ended the card's
managed turn, and the drain waited on that turn until its cap.

connect_gateway now refuses an owner in restart wait as `draining`/`restart_wait` inside
`outside_restart_wait()`, and the Kanban worker dials inside it. The worker waits outside the
wait like any other transient owner state. Either the turn finishes and the next owner holds
its receipt, or OWNER_WAIT_S of silence ends the worker, which ends the turn and releases the
restart. Interactive clients still attach to the wait.

Found on CI E2E dispatch (tests/e2e/core/upgrade/handoff/test_handoff_from_head.py).
2026-10-28 20:40:14 -07:00
Teknium
01dfee9a41 fix(webapp): a Webapp tab installs a desktop plugin from any source the CLI takes
Private plugins live behind ssh keys or in local folders. The Webapp's
host-side desktop install accepted https only; it now takes git@/ssh://,
file:// and http:// like the agent installer and native Desktop, per the
maintainer ruling on #146189.
2026-10-28 19:53:28 -07:00
Teknium
43ee1b0872 revert(plugins): Desktop, Webapp and dashboard installs take every source the CLI takes
Maintainer ruling: Desktop and the Webapp must keep installing private
plugins. The https-only source rule this branch added
(guiInstallSourceRefusal in the native install IPC, gui_install_source_refusal
in plugins.manage install and POST /api/dashboard/agent-plugins/install)
refused git@/ssh:// private repos, http:// and file:// local folders. It
goes, with its tests, and the user guide says Install from Git takes any
git source `hermes plugins install` accepts.

The symlink / plain-tree / 64 MB refusal in publishDesktopTree, the
reconcile refusal report in the install dialog and the forced-reinstall
fix stay.
2026-10-28 19:53:28 -07:00
Teknium
12944611f0 fix(plugins): Desktop and Webapp agent-plugin installs clone https only
plugins.manage install (native Desktop, the Webapp) and the dashboard's
POST /api/dashboard/agent-plugins/install handed any identifier to
dashboard_install_plugin, so a click could clone a file:// folder, an
ssh/git@ source through the host's ssh-agent, or plain http://. Both GUI
doors now refuse a non-https custom source before cloning, through one
helper (gui_install_source_refusal). A catalog_name install clones the
catalog's own source and is unchanged; `hermes plugins install` keeps
every scheme it documents.
2026-10-28 19:53:28 -07:00
Teknium
c70876b9fe fix(dashboard): cron create accepts timezone/grace_minutes
CronJobCreate had no such fields, so POST /api/cron/jobs silently dropped them (a bad zone returned 200 and stored an unpinned job) while PATCH validated them. Pass both to create_job, which validates.
2026-10-28 19:40:40 -07:00
yliu325
b81e71addd feat(cron): optional per-job grace_minutes override
The catch-up window (how late a missed cron occurrence may run instead of being skipped) was
half the job's period, clamped to 120s-2h, for every job. A job can now override it outright:
0-1440 minutes, `0` meaning never catch up.

`grace_minutes` is a real 0, not "unset" — and the obvious write pattern would eat it:
`v in {None, "", False}` (the `workdir` update lambda) and `if value:` both treat `0` as
False in Python. Both doors therefore share `jobs_time.normalize_grace_minutes`, reads test
`is None`, and the renderer formats before testing truthiness.

The override moves the dispatch stamp too: `_classify_dispatch_lateness` and the dispatch
health metric read the same window, so a job the scheduler calls "late" is never reported
overdue by the dashboard.

Refused on `once`/`interval` schedules: the window describes a missed wall clock, and a
duration has none.

Split from the timezone commit so it can be reverted alone.
2026-10-28 19:40:40 -07:00
yliu325
bfa67878cd fix(cron): per-job timezone drives schedule compute and due-scan
A job may pin its own IANA timezone; its cron expression is then that zone's wall clock,
independent of the profile's configured timezone. Absent/None inherits the profile, so an
existing jobs.json keeps byte-identical behaviour and needs no migration.

The dispatch path needs the pin as much as the compute does. `compute_next_run()` resolves
the zone as job pin -> profile zone -> base offset, and every site that writes `next_run_at`
now passes it (advance, claim, resume, re-arm, recovery, and the quota/unreachable
planners); one missed site re-fires or skips a slot because the stored instant and the
expression would be read in different zones.

`_evaluate_due_job()` normalizes the stored instant into the JOB's zone, which hands every
downstream cron predicate the job's clock, and a pinned job skips
`_repair_timezone_shifted_cron` outright. That repair exists for jobs that FOLLOW the profile
zone across a zone change: on a pinned job its wall-clock comparison reads a due occurrence
as still-in-the-future and re-anchors past it.

Failing shape this fixes (profile America/Los_Angeles, job 0 9 * * 1-5 pinned to
America/New_York, scanned at 09:00 New York): `get_due_jobs()` returned [] and the job was
re-anchored to the next day, i.e. job zones east of the profile zone silently never fired.
The regression test drives the public store API and asserts both the fire and the absence of
the repair, and is proven red on main ([] and a rewritten instant).

Knobs live in the new sibling `cron/jobs_time.py`; `cron/jobs.py` stays over the file-lines
ratchet and only gained the call-site plumbing.
2026-10-28 19:40:40 -07:00
Victor Kyriazakos
fa2befeed7 fix(gateway): join delegations in the turn when interim messages are off
On a messaging chat with display.interim_assistant_messages off, a top-level
delegate_task still produced two messages: a "checks are running, I don't have
the findings yet" reply and, later, the real answer. Top-level model
delegations always run in the background (ea8a8b4af8), and the tool text tells
the model to "give a one-line status and END YOUR TURN" (c89f3b8800). That
status is the turn's final answer, not interim text, so no display setting
held it back.

New key delegation.gateway_mode: auto | inline | background (alias async).
auto (default) joins the children inside the turn on a messaging chat whose
resolved interim setting is off (global, display.platforms.<p> override or
platform default). The parent waits in the tool call, gets the results there
and sends one answer. API, local and webhook surfaces keep the background
path under auto. Chats with interim messages on are unchanged: same schema
bytes, same async dispatch.

How it works:
- The gateway resolves the mode from the turn's own profile-scoped config
  when it builds a session's agent (gateway/session_execution.py), and the
  agent's first tool build freezes it (like the one-shot pin).
- An inline session carries the joined delegate_task variant the one-shot
  path already uses: "results return in this tool call", no live-control
  parameters, no END YOUR TURN.
- Dispatch follows the delegate_task schema the session carries
  (session_joins_delegation), so schema and behaviour cannot disagree. The
  schema rides the session's tools[] pin: a config change applies from the
  next session (/new), as delegation.backend does, and a cache eviction or
  restart never flips a running chat.
- Inline children run on the existing synchronous path: attached to the
  parent, so /stop and an interrupting follow-up stop them; the per-child
  heartbeat keeps the parent's activity fresh for the inactivity watchdog;
  the async completion registry is not used. Nested and one-shot delegation
  are unchanged.

Refs #95522.
2026-10-28 19:35:16 -07:00
Teknium
0216b1a320 fix(sessions): refresh epoch survives compression rotation; --session targets the tip
With compression.in_place: false a rotation creates a child whose
model_config did not carry prompt_refresh_epoch, so after any past
profile-wide refresh-prompts request the child looked stale and rebuilt its
prompt (an extra prefix-cache break) on the first restore after eviction or
restart. Carry the key as conversation-wide state.

--session with a compressed conversation's original id wrote the request
for the ended root, which the live tip never reads: the CLI reported
success and nothing refreshed. Resolve to the compression tip first.
2026-10-28 19:30:48 -07:00
Victor Kyriazakos
e240d617e8 feat(sessions): refresh-prompts lets continuing sessions adopt updated prompt sources
A continuing session replays its stored system prompt verbatim on every turn
so the provider prefix cache stays warm. The gateway restores that prompt from
the session row on each fresh agent, and warm cached agents keep it in memory,
so SOUL.md edits, new or edited skills and project-context changes never
reach a long-running conversation until /new, which also drops the history.
Operators who push profile updates and restart the gateway had no way to make
existing conversations pick them up.

`hermes sessions refresh-prompts [--session ID] [--json]` records a refresh
epoch in the profile's state.db (state_meta, one counter orders profile-wide
and per-session requests). At the start of a continuing session's next turn,
_restore_or_build_system_prompt compares that epoch with the one stamped in
the session's model_config when its prompt was built. When the stored prompt
is older it follows the Bot Chat capability-refresh precedent in the same
function: tools[] pin restored first, skills prompt cache and snapshot
cleared, prompt rebuilt through _build_system_prompt (memory reloaded and
plugin sections re-rendered, as at a compaction boundary), cache break
recorded, on_session_start not fired, new bytes and epoch persisted so the
following turns restore them verbatim. One cache break per request.

Warm agents (gateway agent cache, TUI/Desktop) run the same check from
build_turn_context against the epoch they saw when their prompt was set, so
the verb works with the gateway running. A session first built after a
request is stamped with it and does not rebuild again.

With no request recorded, the stored prompt is reused byte-identically. The
only added work per continuing turn is one state_meta point read. No file
scanning, no config key, no watcher, no mid-turn mutation.

The tools[] pin is kept on purpose: the refresh is about instructions, and
tool changes already reach long sessions at the compaction boundary. The
cache break is recorded as the existing system_prompt_rebuild cause rather
than a new one, which would change the shared-metrics contract and schemas.

Related: #141154 (per-turn source hashing, alternative design), #74622.
2026-10-28 19:30:48 -07:00
Teknium
50f259a83f fix(webapp): refuse an unbound profile ticket and bind explicit profiles on launch sockets
Follow-up to the Webapp socket profile scope fix (#146097):

- chat_ws.gateway_ws: a ticket that names a profile while the gateway has
  no session authority bound (the listener unbinding window) closes 1013
  instead of serving the socket as the launch profile.
- ws_legacy_fallback.dispatch_legacy: on a launch-profile socket, a legacy
  verb with an explicit `profile` now runs in that profile's runtime scope
  (refused 4064 when the name does not resolve), as it already did on a
  non-launch ticket. Now that the socket runs in the launch scope, a
  handler that ignores `profile` would otherwise read the launch
  profile's secrets instead of refusing the unscoped read.
- test_webapp_socket_profile_scope: drive the real gateway_ws + handle_ws
  + session authorities + legacy billing.state over the socket (only the
  upgrade gate and HTTP substituted) instead of a stubbed handle_ws.
2026-10-28 19:09:39 -07:00
Teknium
62f79a434d docs(security): allow_private_urls guards cloud browsers and web tools, not the local sidecar
security.allow_private_urls: false refuses private URLs for web_extract, vision/media
fetches and cloud/CDP browsers, but browser_exec under a cloud provider routes them to
a local Chromium sidecar (browser.auto_local_for_private_urls, default true), and the
plain local Chromium with a local terminal skips the guard by design. Say so in the
security and browser docs, configuration reference, DEFAULT_CONFIG comments and
cli-config.yaml.example, and name auto_local_for_private_urls: false as the way to
refuse. Also correct browser.md's claim that redirects to private hosts are blocked:
routing is decided from URL literals, and a redirect stays on the cloud browser.
2026-10-28 19:07:59 -07:00
Teknium
669df020d9 fix(cli,tui): a stalled event loop no longer submits a held Enter ahead of a waiting paste chunk
The held trailing Enter decides on a 250 ms timer. When the event loop
stalls past that window with the next paste chunk already in stdin, the
timer ran before the chunk was read and submitted the first line alone:

- Ink: Node runs the timers phase before the poll phase, and
  stdin.readableLength cannot see bytes libuv has not read yet. The flush
  now hops to setImmediate (after this turn's poll) and runs only if no
  read replaced keyParseState in between.
- Classic: a signal handler that interrupts the selector past its deadline
  returns no events (PEP 475), so the due call_later ran before the reader.
  The settle now runs two call_soon hops later, after the next selector
  pass's readers. Text arriving while an Enter is held also keeps the paste
  burst alive however late it is read, so the paste's own trailing Enter
  stays a newline instead of submitting the joined text.
2026-10-28 19:05:57 -07:00
Teknium
7745fa7f92 fix(cli,tui): a paste still arriving keeps its trailing newline
Paste detection expired BURST_END_QUIET_S after the last pasted newline,
not after input went quiet. A non-bracketed paste delivered in reads
100 ms apart, with newlines only in the first and last read, therefore
treated its trailing Enter as a scripted text+Enter and submitted (and
cleared) the multi-line draft. Any input inside the quiet window now
keeps the paste burst alive, in the classic CLI (note_text_change) and
the Ink parser (pasteBurstAt). One-write text+Enter and a lone Enter
still submit.
2026-10-28 19:05:57 -07:00
Teknium
4889361215 fix(cli,tui): keep the draft and split pastes intact in the burst-Enter submit
Review round on the one-write text + Enter submit:

- Classic: the provisional newline goes in at the cursor, so settling restores
  the exact pre-Enter document (text + cursor) instead of dropping the last
  character. A scripted edit inside a draft now submits the whole draft.
- Ink: the decision is kept across stdin reads. A single-line read ending in CR
  emits its text and holds the CR in the parser state; App's flush timer
  releases it as return after BURST_END_QUIET_MS (250 ms) of no input, and any
  read inside the window turns it into paste content. A CR-ending read within
  250 ms of a pasted line break stays content. A paste split across reads (both
  directions) no longer submits itself. The textInput submit re-sync is no
  longer needed (text and return land in separate batches) and is reverted.
- Tests: injected clock (cli_enter_burst.monotonic, also read by
  _tui_on_text_changed); the single-write test proves the delayed callback
  path; new mid-draft and split-read cases.
2026-10-28 19:05:57 -07:00
Teknium
2432e31e2b fix(cli,tui): text + Enter in one write submits instead of inserting a newline
Scripted drivers deliver the text and its Enter in ONE read (`tmux send-keys
'text' Enter`, a PTY write of `text\r`). The classic CLI's #10994 guard treats
every Enter within 50 ms of a buffer change as a pasted newline, so the burst
never submitted; the Ink TUI routed the CR-carrying token through the paste path
and dropped it.

Classic: an Enter with more keys of the same read queued, or the tail Enter of a
burst that already held one, stays a newline (unbracketed multi-line paste is
unchanged). The lone Enter that ends a burst inserts a provisional newline and
submits once input stays quiet for 250 ms; input in that window (a paste split
across reads) keeps the newline. New sibling hermes_cli/cli_enter_burst.py.

Ink: a single-line text token ending in CR peels the CR into its own return key;
multi-line tokens keep it as paste content. TextInput re-syncs its local draft on
every submit, since text + submit in one React batch left the parent value
unchanged and the submitted text stuck in the composer.
2026-10-28 19:05:57 -07:00
Teknium
0a93a2341f fix(vault): fill saved logins on Camofox pages through a browser page backend seam
browser_vault reached pages only through the task's CDP supervisor. Camofox (now a plugin) has no
CDP endpoint, so every fill on a Camofox tab ended with "Could not determine the current page
origin": the username from browser_vault list worked, the password never filled.

ctx.register_browser_page_backend lets a plugin browser carry the vault's origin read, form
inspection and fill script to its own page. Core keeps the secret contract: the exact-origin
pre-check and in-page re-check, the Bot Desktop takeover check, an in-page try/catch around the
secret script, and fixed failure text on that path. Registration follows the login-backend
provenance rule (bundled, or catalog verified/official at its pin) and is refused under
plugins.isolation: host.

Consolidates the core half of #127179 and #135204 (the Camofox halves already shipped in the
official plugin); the in-page wrapper follows #114414.

Co-authored-by: Jonathan Bruce <jonathan.bruce369@gmail.com>
Co-authored-by: clsferguson <cferguson@live.ca>
Co-authored-by: Benjamin PERRY <benjaminperry6@yahoo.fr>
2026-10-28 19:00:07 -07:00
skyeyesec333
32633eb963 fix(billing): bind RPC profile scope and honor scoped Portal routing 2026-10-28 18:55:56 -07:00
Teknium
8b55721189 fix(webapp): run the Webapp's gateway socket in the served profile's scope
A browser tab's /api/ws reaches a gateway through the dashboard mount
(chat_ws.gateway_ws), not the native ticket path (gateway/run_api.py) that wraps
the socket in owner_scope(authority). Legacy handlers the socket falls back to
(billing.state, subscription.state, usage.bars, and the account reads they spawn
on worker threads) bind no scope of their own, so on a multiplexed gateway every
Webapp billing/usage read resolved the Nous Portal override with no profile
secret scope: errors.log logged "HERMES_PORTAL_BASE_URL/NOUS_PORTAL_BASE_URL
unreadable — no profile secret scope on a multiplexed call", the override was
dropped, the stored non-production portal_base_url was then refused by the
allowlist ("ignoring invalid portal_base_url ... using default") and the token
resolution fell back to the production Portal.

gateway_ws now binds owner_scope() of the authority it serves (the ticket's
profile when the tab named one), exactly as the native ticket path does, so
every handler on the socket (and every thread it copies its context into) reads
the right profile's secrets.

Found on Hermes Cloud staging.
2026-10-28 18:55:56 -07:00
Teknium
a4b2ba62dc fix(update): a checkout-lock probe never reads another probe as a running update
After a killed update, the first launch could refuse with "Gateway draining:
update_paused" although nothing was updating. A killed update always leaves a
dead .hermes-update-in-progress marker; while it is there, every ensure poll
probes the checkout kernel lock, and the gateway that ensure just started
probes the same lock while it boots (its launch reclaims that marker). The
probe took the lock exclusively, so two probes in the same instant read each
other as a holder, and the client's single sample fenced the launch.

checkout_lock_held now takes a SHARED lock (POSIX flock LOCK_SH; Windows
LockFileEx without LOCKFILE_EXCLUSIVE_LOCK over the owner byte and the 16
lease bytes). Holders still lock exclusively, so a real holder (or a leased
child of a dead one) still fences; probes never conflict with each other.
2026-10-28 18:53:42 -07:00
Teknium
e0c52c4fbf fix(plugins): catalog installs keep the inspected commit; older backends ask; partial installs need Force
Three follow-ups to the install dialog holding an install to the commit it showed.

- Catalog picks. The backend reloads the live catalog entry at Install, so a
  re-pin between the dialog's inspection and the click installed (and, through
  the one checkout, published the desktop half of) a tree nobody reviewed;
  the renderer sent no inspected_sha for catalog sources and neither the
  catalog install nor reuse of a disabled tree read it. Now the catalog
  install compares the commit it actually checked out with the inspected sha
  peeled through the clone (annotated-tag pins still install), a disabled tree
  is reused only at that commit (or its recorded tag pin), and catalog dialogs
  send it: the backend's inspect sha in the Webapp, the shown reviewed pin on
  native Desktop (whose Electron probe reads the branch tip). After a re-pin
  refusal the native dialog re-reads the catalog for the new pin. The record
  stays the catalog's pinned record. Electron's desktop clone uses the same
  reviewed commit and peels a tag pin.
- Older backends. A backend that refuses inspected_sha at admission is no
  longer retried without it behind the user's back: the dialog explains that
  this backend cannot guarantee the reviewed version is what gets installed
  (update it for that guarantee) and installs only on an explicit
  "Install anyway" (profile kept); Cancel installs nothing.
- Partial installs. Native Desktop on a remote backend could install the agent
  half at commit A, fail the desktop half (source moved), re-review to B and
  let a second Install put the desktop half down at B beside the agent half at
  A. That is now reported as a partial install (agent half in at A, desktop
  half not); Install stays disabled until Force reinstall, which replaces both
  halves with the version shown.
2026-10-28 17:21:32 -07:00
Teknium
e4b0ab2365 fix(plugins): retry only a real admission refusal; re-review a moved source
Two follow-ups to the install dialog holding an install to the commit it
inspected.

- An install is resent without `inspected_sha` only for an older backend's
  admission refusal: a JsonRpcGatewayError with code 4000 whose message
  opens with `validate_params`' prefix. Matching the text anywhere also
  matched a 5026 install failure that forwards a git server's clone error,
  so that server could get the reviewed commit dropped.
- A refusal because the source moved past the reviewed commit now carries a
  structured marker: the backend raises PluginSourceMoved and
  `plugins.manage` answers 5026 with `data.reason == "source_moved"` (agent
  install and `install_desktop`); Electron's desktop install returns
  `sourceMoved: true` when the reviewed commit cannot be checked out. The
  dialog answers it by dropping its inspection, reading the source again
  and naming the new commit; Install waits for it. Retry used to resend the
  old commit and fail the same way every time. A pin the user typed is not
  re-reviewed, and nothing from the stale review installs (the desktop half
  is skipped when the agent half was refused).
2026-10-28 17:21:32 -07:00
Teknium
2c64c7fdb7 fix(plugins): an install dialog installs only the commit it inspected
The dialog inspects a source and shows its commit, but the agent half
cloned the branch tip at Install time: a branch that moved in between put
down a tree nobody reviewed, and the desktop half copied out of that
checkout followed it. Native Electron's probe returned no commit at all, so
its desktop clone had the same gap.

- plugins.manage install takes `inspected_sha` (custom sources without a
  pin). The clone stays an ordinary branch checkout and is refused when its
  tip is not that commit: "The source changed since you reviewed it ...
  Re-open the install dialog". Not `ref`, which records a pin that refuses
  every later `update`; not a detached checkout at the old commit, which
  `git pull` cannot update. Catalog picks keep their pin.
- That install drops inspect's kept answer for the source, so re-opening
  the dialog reads the moved branch instead of the stale commit.
- Electron: probePluginRepo returns the commit it read; installDesktopPlugin
  takes it and installs exactly that tree (fetch + verify) or refuses.
2026-10-28 17:21:32 -07:00
Teknium
ccba14cb75 fix(desktop-plugins): real copies of linked root checkouts; desktop success from disk; layout moves need no consent
- A dev checkout linked at plugins/<name> with a root plugin.js: Electron's
  publish copied the link itself (fs.cp keeps a top-level link), so the
  "copy" was the checkout, the marker was written into it, and the prune
  (which skipped linked folders) left a ghost after the link went. Copy from
  the resolved folder; never keep or stamp a link at <root>/<name>; the prune
  follows links and drops only the link. The host twin gets the same
  link-target and prune handling (its copytree already copied the files).
- The install dialog decided desktop success from the reconcile's touched
  list, which also names folders the pass deleted: a force reinstall whose
  new tree dropped its desktop entry read as installed. Read the folder
  (Electron fs bridge, or the host's /api/desktop-plugins) instead.
- Re-pin consent: the desktop half is a presence surface, so moving it
  between plugin.js and desktop/plugin.js widens nothing.
2026-10-28 17:21:32 -07:00
Teknium
990bfbdf6c fix(plugins): re-pin consent sees a root-layout desktop half too
plugin_surface only recognised desktop/plugin.js, so a catalog re-pin
that added a root plugin.js (a layout every installer accepts) was not
reported as a widened desktop surface. Read the installers' shared
desktop_source rule instead.
2026-10-28 17:21:32 -07:00
Teknium
ca8e43aea7 fix(desktop-plugins): copy root-layout desktop halves; no false desktop success
A mixed package with plugin.yaml + __init__.py and a ROOT plugin.js is
reported by the install probe as carrying both halves, so a browser tab
(and native Desktop on a local backend) installs the agent half alone and
leaves the desktop half to the reconcile pass. Both reconcilers (the host's
desktop_plugin_halves.py and Electron's desktop-plugins-root.ts) only read
desktop/plugin.js, so nothing was copied while the dialog still said
"Desktop plugin <name> installed".

- One entry rule for every reader: desktop_source / desktopHalfSource (root
  plugin.js wins, else desktop/plugin.js), used by both reconcilers, the
  Webapp installer, findDesktopEntry, plugins.manage list's has_desktop_half
  and the plugin doctor's stale-copy check.
- A root-layout half publishes the package root as the installers do,
  without .git and __pycache__, held to the installer's plain-tree rule
  (no links, 64 MB cap); a refused tree is logged and not copied. The
  marker's source is the package root, so the prune follows it.
- The install dialog reports the desktop half only when the reconcile
  copied it or <root>/<name>/plugin.js is already there; an agent install
  that left no desktop half reports "Desktop plugin install failed".
2026-10-28 17:21:32 -07:00
Teknium
c95dfcb3ae fix(webapp): a tab installs a mixed package once; tag pins and read-only trees install
Review follow-ups on the Webapp desktop-plugin install:

- A package with an agent half was cloned twice from a browser tab: the agent
  install, then a second install_desktop clone into the folder the host's
  5-second scan also copies that package's desktop half into, so the clone
  could answer "already exists" or the two copies could be different commits.
  A tab's backend is the host that serves it, so the package lands where the
  tab's plugins load from: the desktop half now comes out of that one checkout
  through the host's reconcile, as native Desktop does with a local backend.
  install_desktop stays for desktop-only repositories.
- A catalog pin naming an annotated tag never matched the commit inspect
  reports. The clone now fetches the catalog's own pin (as the agent installer
  does) and requires HEAD to be the commit the dialog reviewed.
- The published folder no longer carries the clone's .git (nothing reads it),
  and removal / force replacement use rmtree_readonly, so a folder holding Git's
  read-only objects (a native or hand install) can be deleted on Windows.
2026-10-28 17:21:32 -07:00
Teknium
8c5895cec1 fix(webapp): a tab's desktop-plugin install takes only the reviewed https commit
Hardening on top of the contributor's Webapp install path (salvage #146132). A browser tab asks the
serving host to clone code onto it, so the host now decides what lands, not the tab:

- `ref` is required: the 40-hex commit the dialog showed (or the user's pin). The clone is checked
  out at exactly that commit and the halves are read from that checkout, instead of re-using a
  ten-minute inspection cache and installing whatever it named; a catalog install whose pin moved is
  refused. `forget_inspection` goes away with the cache dependency.
- https only: `file://` would copy any folder of the host, `ssh`/`git@` spends the host's keys,
  `http://` can be rewritten in transit. Native Desktop keeps those for a user at their own machine.
- The published tree may hold no symbolic link (a `desktop -> /anywhere` link in a repository
  published that host folder) and is capped at 64 MB.
- A standalone plugin's in-tree `.hermes-package.json` is dropped as Electron's installer drops it:
  only an installer writes the marker that pairs a folder with an agent package.
- `desktop_plugin_halves`: the helpers the installer shares become public names instead of
  wrapper functions around private ones.
- Renderer sends `ref: plan.ref ?? plan.probe.sha`.
- Tests: the contributor's installer/RPC/route cases now run through an https identifier at a real
  commit (only the clone's network leg points at the local repository); RPC cases folded into one
  round trip; two added invariants (https only, link escape), each proven red with its guard removed.
2026-10-28 17:21:32 -07:00
Decrux
abfe2876f3 feat(webapp): install a desktop plugin on the host that serves the tab
In the browser-hosted app, installing a desktop plugin dead-ended: the install dialog could inspect a
repository through the gateway (`plugins.manage inspect`, #145770) but had nothing to install with.
A desktop-only package answered "This package has nothing to install here." and the desktop half of a
mixed one was skipped with a toast, because the only clone lived in Electron
(`installDesktopPluginFromGit`). Since #145072 the Webapp *loads* whatever sits in
`<root>/desktop-plugins/`, so the last mile was missing: no way to put it there from the UI.

This adds `plugins.manage` `install_desktop` / `remove_desktop` — the backend half of that install —
and points the dialog at them when it is not running in Electron.

- `hermes_cli/desktop_plugin_install.py`: clones a repository's desktop half into the app-level
  `desktop-plugins/` root. Same resolution, folder name and package-marker rules as Electron, and the
  same staged-copy-then-rename publication under the root's writer lock, so a reconcile pass cannot
  copy a folder underneath it. The clone is held to the commit the inspection read, so a repository
  that moves after review cannot install a tree nobody looked at; `force` re-inspects (a forced
  reinstall means the repository moved). `remove_desktop_plugin` refuses a package's own half unless
  forced, and refuses a linked folder it would only half-delete.
- `plugins_cmd_inspect.forget_inspection`: drops the ten-minute answer cache, used by a forced
  reinstall.
- `desktop_plugin_halves`: `ROOT_WRITER` and `publish_desktop_tree`/`read_package_marker`/`mtime_ms`
  go public (the installer shares the root's lock), a standalone plugin publishes with no marker, and
  the Webapp's read router imports the root from the one place that defines it.
- `plugins.manage install_desktop|remove_desktop` + contract (`tools_mcp_plugins`), regenerated.
- Renderer: `desktopInstallSupported()` is also true in a browser-hosted tab, `cloneDesktopHalf` falls
  back to the gateway, and a backend that predates the action keeps the old "unavailable in this
  environment" wording. Uninstalling a disk plugin uses the same fallback.
- Docs: the Webapp install/remove paragraph now describes the working path.

Tests: 10 installer (real local clones: standalone vs package marker, force, sha pinning, path-shaped
names, linked folder, removal rules), 6 gateway RPC (incl. contract validation), 3 browser-modal cases
(desktop-only, both halves, old backend) beside the 6 existing ones, and one route test that installs
through the backend and then reads the plugin back over `/api/desktop-plugins/*` — the whole trip the
browser makes.
2026-10-28 17:21:32 -07:00
Teknium
8e0b489266 fix(config): exempt only known platforms' own bundles from the toolset warning
The own-bundle exemption compared name == hermes-<platform> for any key, so a
misspelt platform key naming its own bundle (telegarm: [hermes-telegarm]) went
silent in both the session-time warning and `hermes config check`, where main
reported it. is_known_platform_bundle() exempts the bundle only for a builtin,
shipped plugins/platforms, left-core or registered platform.
2026-10-28 13:10:38 -07:00
Teknium
bde889a523 fix(tools): judge registered toolsets before the profile resolver in the platform warning
A bypass launch (ignore_user_config) must never read profile plugin state;
the warning now short-circuits on the own bundle or any registered toolset
and only builds saved_toolset_resolver for names those cannot place.
2026-10-28 13:10:38 -07:00
Teknium
06662ba995 fix(config): stop seeding and flagging plugin-platform toolset rows (teams, google_chat)
cli-config.yaml.example seeded `teams: [hermes-teams]` and
`google_chat: [hermes-google_chat]` into every install (install.sh,
install.ps1, the Docker stage2 hook, `hermes doctor --fix`). Both are
bundled plugin platforms with no static toolset, so every schema build
(the kanban gate resolves every saved row) logged "platform 'teams' has
no valid toolsets configured" to errors.log on homes that never set up
Teams or Google Chat, and still did once Teams was enabled.

- Drop the two rows from the example: a plugin platform falls back to
  hermes-<platform> on its own (resolution identical with and without
  the row, before and after plugin discovery).
- The runtime warning and `hermes config check` count a platform's own
  hermes-<platform> bundle as valid, so existing homes (incl. the
  homeassistant row pre-left-core homes carry) stay quiet; a typo in the
  row still warns. The own-bundle check runs before the resolver, so the
  hot path does no manifest scan, and the catalog scan from the salvaged
  commit is dropped (862 catalog YAMLs parsed per call).

Found on Hermes Cloud staging.
2026-10-28 13:10:38 -07:00
Kuxin
3935c04c0f fix(tools): recognize unloaded platform plugins 2026-10-28 13:10:38 -07:00
Teknium
35a7d34036 fix(config): a selected memory provider parked in plugins.disabled declares no live keys
The memory loader refuses a provider listed in plugins.disabled; the runtime-key lookup now
applies the same check, so its declared keys warn again like any unknown key.
2026-10-28 13:09:00 -07:00
Teknium
e1be6fcfe0 fix(config): config_keys come from the loader's discovery, count only for active plugins, never widen a section
Review findings on the config_keys seam:

- Discovery: drop the glob scan. config_keys is parsed onto PluginManifest
  (plugin.yaml, and extensions.com.nousresearch.hermes in a portable
  plugin.json) and read from the loader's own collect_directory_manifests +
  entry points + resolve_manifest_winners, so skip rules, precedence and the
  project-plugin gate are the loader's.
- Only active plugins count: gate_manifest must load the plugin (disabled wins,
  plugins.enabled opt-in, requires_hermes); memory providers count when
  memory.provider selects them.
- Bounded: a declared path is at least two segments deep and is ignored when
  DEFAULT_CONFIG already defines it; runtime keys are consulted only after the
  schema walk refused a key, so a plugin declaring [agent] no longer hides
  agent.max_turnz.
- No lru_cache: a plugin installed or enabled in a long-running process counts
  on the next config get/set (the lookup runs only for refused keys).
- computer_use.backend (read by the plugins/computer_use selector) and
  dashboard.kanban move to a core table with their readers; the selection
  sections derive from read_selection's own _SELECTION_NAME_KEYS.
- Tests use fixture plugins (enabled/disabled, hostile [agent], selected memory
  provider, portable plugin.json, project opt-in).
2026-10-28 13:09:00 -07:00
Teknium
6df187b4f8 fix(config): an enabled project plugin's config_keys are recognized too
Same opt-in gate (HERMES_ENABLE_PROJECT_PLUGINS) and directory
(./.hermes/plugins) as plugin discovery, so a project plugin declaring
config_keys stops drawing the unrecognized-key notice once enabled.
2026-10-28 13:09:00 -07:00
Teknium
fb8b9bf4b0 fix(config): catch only manifest read/parse errors in config_keys scan 2026-10-28 13:09:00 -07:00
Teknium
e402afa783 fix(config): recognize runtime-read selection and plugin-declared keys in config get/set
`hermes config get browser.cloud_provider` / `browser.use_gateway` warned "not a recognized
config key" although the runtime selects the browser provider from them. The validator only
walks DEFAULT_CONFIG, and provider selections stay unseeded on purpose (a stored key is the
explicit pick), as do core-section keys plugins read.

- tools.tool_backend_helpers.selection_config_keys(): the keys read_selection() honours
  (<category>.use_gateway, browser.cloud_provider, stt/tts/image_gen/video_gen provider keys,
  web.backend/search_backend/extract_backend).
- plugin.yaml / dashboard manifest.json `config_keys`: a plugin names the core-section paths it
  reads; declared for retaindb, byterover, computer_use/cua, kanban dashboard.
- hermes_cli/config_runtime_keys.py consults both before the DEFAULT_CONFIG walk.

Found on Hermes Cloud staging.
2026-10-28 13:09:00 -07:00
ethernet
780d5a3313 fix(auth): login surfaces share one interactive-provider query
Review follow-up (#146139). The native authorize route still counted
every session provider: with session-token beside one password/OAuth
provider an unnamed request 404'd instead of auto-selecting the only
interactive one, and with session-token alone (or named explicitly) it
fell into its start_login stub -> uncaught NotImplementedError -> 500.

registry.list_interactive_providers() is now the single query every
sign-in surface uses: native selection + chooser, the login page,
/api/auth/providers, auto-SSO and the /api/status native_pkce
advertisement (a token-only gate no longer tells Desktop to try a
browser flow it doesn't have). An explicitly named non-interactive
provider is rejected with 400 before any pending broker state exists.
The verify/refresh loops keep list_session_providers.

Tests: native authorize auto-select / token-only / explicit-name cases
and the native_pkce advertisement against the real routes (red without
the fix: the 404 and the 500 above); the dashboard.session_token_auth
opt-out read from a real config.yaml under a temp HERMES_HOME; the REST
bearer test now asserts an exact 200 + provider on /api/auth/me (the old
/api/session target was unrouted, so its 'not 401' passed on a 404).
Docs: the deployment check curls /api/auth/me, not /api/me.
2026-10-28 13:49:47 -04:00
ethernet
2edfd0d369 feat(auth): the deployment session token authorizes the gated dashboard
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.
2026-10-28 13:49:47 -04:00
ethernet
9fc982ecd0 Merge pull request #146104 from NousResearch/feat/nix-session-token-unit-env
feat(nix): the session token rides the unit environment as a path
2026-10-28 12:43:13 -04:00
ethernet
493b19d931 refactor(backend): the token resolver moves to a web_server sibling
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.
2026-10-28 12:18:46 -04:00
ethernet
20f2654429 refactor(backend): a file: prefix instead of a second token variable
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.
2026-10-28 12:09:46 -04:00
Teknium
fd9ff2a0cd fix(webapp): a signed-out /api/status on the Webapp shows no profile names or install id
/api/status is public so the native-app login probe and uptime checks can
read it without a session. On the gateway's Webapp behind its sign-in gate
(a wildcard bind reaches everyone on the network) it also answered every
caller with the profile names (profiles, parked_profiles,
gateway_shared_with), the install id, host memory and disk figures, the
Nous session state and session counts, and its ?profile= 404 told which
profile names exist.

The Webapp now answers a caller it cannot verify with liveness and the
sign-in shape only (version, release_date, gateway_running, gateway_state,
overall, components, auth_required, auth_providers, auth_flows) and ignores
?profile= for it. A signed-in browser or a native app's bearer gets the full
payload: the route checks the session the gate would accept (sign-in
binding included) through the existing _require_token, with a side-effect
free peek, since the gate skips public paths. The standalone dashboard and
every loopback listener answer as before: Hermes Cloud lists profiles from
the dashboard's public body (#60585).

Reported by @kshitijk4poor. The public-path session check follows the
approach in #97303.

Refs #144648
Refs #97302

Co-authored-by: Alexandre Mallet <alexandre.mallet@buldee.com>
2026-10-28 08:56:59 -07:00
ethernet
18c4b372a8 fix(backend): BOM-tolerant token file reads; decoding errors name the variable
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.
2026-10-28 11:53:09 -04:00
ethernet
de4a083d6c feat(backend): read the dashboard session token from a file
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.
2026-10-28 11:29:01 -04:00
Teknium
72ffcb9788 fix(providers): look up an alias owner only when a loaded profile claims the alias
The home-aware owner lookup ran for every non-static canonical id, so a
registry stub (and any profile object without aliases) reached
`owner.aliases`. Ask the listed profiles first: an id no profile names
as an alias keeps what normalize_provider gave it, without calling
get_provider_profile at all.
2026-10-28 08:27:39 -07:00
Teknium
5dca2def3a fix(providers): resolve a plugin alias through the home-aware registry lookup
The alias owner scan took the first profile in list order, so a bound
home plugin declaring an alias (my-meta aliases=("meta",)) lost to the
bundled meta-ai even though get_provider_profile picks the home plugin.
Ask the registry for the owner instead; built-in and exact-name guards
stay.
2026-10-28 08:27:39 -07:00
Teknium
72bb27236b fix(providers): a plugin alias names the same provider whether or not models.dev loads
`--provider meta` (and `/model ... --provider meta`) persisted provider `meta`
when the models.dev catalog loaded and `meta-ai` when it did not.
`hermes_cli.providers.get_provider` asked models.dev for the raw alias before
consulting provider plugins, so a plugin alias that is also a models.dev id
resolved to the bare catalog entry online and to the plugin offline. The
credential resolver (`hermes_cli.auth.resolve_provider`) always answers the
plugin id. Same shape for `azure` (azure-foundry), `google` (gemini) and
`google-vertex` (vertex).

get_provider now folds an id that is only a registered plugin's alias onto
that plugin's name before the models.dev lookup (built-in ids, registered
profile names and overlay profiles keep normalize_provider's answer;
user `providers.<name>` entries still win in resolve_provider_full).

This was the CI flake in test_stale_chat_overridden_on_meta_direct
(`assert 'meta-ai' == 'meta'`, file 33.9 s): the file's first test fetched
models.dev live, the fetch failed on the runner, and the meta test fell
through to the plugin. Repro: block getaddrinfo for non-loopback hosts and
the unmodified test fails with CI's exact message; with the network it
passes. The test now seeds the registry (catalog and offline legs) and
asserts the plugin id; a new test pins every colliding alias in both
registry states against the credential resolver.
2026-10-28 08:27:39 -07:00