Commit Graph

5467 Commits

Author SHA1 Message Date
Teknium
97ad1dae82 docs(plugins): inject_message no longer interrupts a busy session
The plugins guide still described the pre-gateway classic CLI host: an
injected message sent mid-turn "interrupts the current operation". Since
plugins load in the gateway on every local surface (PLG-7), injection goes
through the session's durable FIFO (gateway/run_plugin_injection.py
_admit_plugin_injection) or the TUI/Desktop prompt queue
(tui_gateway/plugin_inject.py), and a busy session keeps the message for
its next turn.

Prompted by the review of #85279 and #118906 by @Sahil-SS9, which asked
for exactly this queue-safe behaviour; main already has it.
2026-11-08 11:45:37 -08:00
helix4u
618b0d6bbe fix(whatsapp): stop passkey retry loops and tighten pairing setup 2026-11-08 15:52:48 +05:30
helix4u
d37547bf73 fix(whatsapp): package pinned passkey runtime and refresh stale dependencies 2026-11-08 15:52:48 +05:30
Hermes Agent
177dbc1bcb fix: a reply to a clarify question over Hermes Cloud no longer waits an hour
A Telegram user on Hermes Cloud (relay) was asked a clarify question with
choices and typed a new question instead of picking one. Relay deliveries
commit straight to the session's durable FIFO, skipping the gateway's
inbound checks, so the message queued behind the very turn waiting on the
question, which sat out the full clarify_timeout (3600 s) before replying
"user did not respond within 60 minutes" and only then ran the message.

- Relay deliveries now pass the same live-turn checks a native adapter
  message does before admission (gateway/session_ingress_live_turn.py):
  a typed answer resolves a pending clarify / slash-confirm / /update
  prompt, a bare yes/no answers a blocking command approval, and
  busy_input_mode applies. Such a delivery admits off the socket reader
  (answering can send, and only the reader delivers send results).
- Free text sent instead of picking a choice cancels the question and now
  always interrupts the turn, on every platform, so the agent carries on
  with that message rather than continuing without an answer
  (queue/steer modes no longer apply to that message).
- agent.clarify_timeout defaults to 90 s (was 3600 s); config v53 lowers
  a still-default 3600 to 90 and keeps any value the user picked.
2026-11-07 16:44:24 -08:00
BearHuddleston
a27d2259f4 fix(webapp): open saved SSH terminals over SSH
Saved SSH connections target headless serve --isolated, which intentionally refuses Webapp host-terminal tickets. The relay therefore rejected terminal WebSocket upgrades before a shell could start.

Use the saved SSH master for a remote login-shell PTY and reuse retained host-terminal ownership, reconnect, resize and close handling. Fence attachments by identity, saved connection and remote profile; retire shells when their saved target changes. Keep local and HTTP-Webapp terminal policy unchanged.

Add behavioral startup, ownership and admission regressions. Isolated OpenSSH reproduction rejects the base upgrade with 403; the fix runs remotely, resizes, reattaches to the same PID and closes.

Refs #150864.
2026-11-07 17:54:05 -06:00
Teknium
c782e9623d docs(desktop): saved gateways live in the Hermes home, imported once
The user guide still said saved-gateway tokens are encrypted with the OS
keyring and that connections.json and the tokens live in Electron userData.
Since the shared store they live in gateway-connections.json and
gateway-connection-tokens.json under the Hermes home (0600, plaintext,
shared with the Webapp), imported once from the old files, which are left
untouched.

Co-authored-by: soymarketing <yo@soymarketing.org>
2026-11-07 15:44:05 -08:00
Maciej Lisiewski
ef806ae3d0 Update website/docs/developer-guide/contributing.md
Co-authored-by: Bear Huddleston <bear@bearhuddleston.dev>
2026-11-07 15:18:03 -08:00
Maciej Lisiewski
6dfdd7231b Update website/docs/reference/package-management.md
Co-authored-by: Bear Huddleston <bear@bearhuddleston.dev>
2026-11-07 15:18:03 -08:00
Maciej Lisiewski
d4c15db2ba fix(js): refuse npm installs in the JS workspaces, keep npx and npm run
Inside a workspace folder npm treats the folder as its own project and
resolves it from the registry, past pnpm-workspace.yaml's overrides and
release-age gate; the root preinstall never runs there, and
--ignore-scripts skips it at the root. Each workspace folder and the root
now carry an .npmrc with engine-strict=true and an engines.npm that no
npm satisfies. npm checks engines only when it builds a dependency tree,
so install (with --ignore-scripts, --package-lock-only or --force), ci,
update, dedupe, uninstall and link fail with EBADENGINE on npm 10 to 12,
while npx, npm exec and npm run work. pnpm reads neither.

The root refusal needs the root devEngines gone (npm skips root engines
while it is set), so this builds on the single-source pnpm pin. The root
.npmrc also makes npx strict about engines anywhere in the checkout.
npm-shrinkwrap.json joins package-lock.json in .gitignore.
2026-11-07 15:18:02 -08:00
Hermes Agent
143cde35df docs(webapp): SSH Test's remote serve also stops on the idle timeout
Review fix (Greptile): an SSH-isolated serve retires itself after
dashboard.ssh_isolated_idle_grace_s (900 s default) with no WebSocket
client and no running work (web_server_idle_exit.DEFAULT_IDLE_GRACE_S),
and Test only makes HTTP requests, so the docs named too few stop events.
2026-11-07 15:14:57 -08:00
BearHuddleston
d05ca3c203 docs(desktop): note that Webapp SSH Test leaves the remote serve running
Since #150901, Test on an SSH row in the Webapp goes through the managed
tunnel, which starts or reuses `hermes serve` on the remote host and keeps it
until the connection is removed or the gateway stops.
2026-11-07 15:14:57 -08:00
Maciej Lisiewski
28ad7672fe Merge pull request #150419 from NousResearch/fix/termux-pnpm-android-arm64
fix(pm): pin pnpm's android-arm64 executable for linux-arm64-bionic
2026-11-07 23:38:20 +01:00
Teknium
44901b1db9 feat(webapp): Saved connections in the Webapp, reached through the forwarding proxy
The Webapp's Settings → Gateways now shows native Desktop's own Saved
connections page over the machine's one list (/api/gateway-connections):
Add, Test, Make primary, Remove and the launch-mode toggle. The browser
bridge's `connections` is REST-backed, publishes what changed on every read
(focus, and every 5 s while the page is open) as Desktop's
connections:changed reasons, and uses the registry's own ids, so profile
routes, Bot Mode and group-chat records name the same gateway on both hosts.

The forwarding proxy (/api/relay/<connection id>/...) keeps every response
hardening rule (header allowlist, sandbox CSP, no-store, redirects kept
inside the gateway, no cookie jar, close on remove) and now reaches each
saved gateway as an ordinary client with the credential saved for it:
X-Hermes-Session-Token or ?token= for token mode, a refreshed native bearer
and a one-use ws-ticket for oauth mode, plus the entry's extra headers.
The other gateway needs no code or config.

Removed the pairing machinery: consent page, grants, the hub key and
scopes, webapp/relay-gateways.json, the webapp.relay config key, and the
relay hooks in the sign-in gate, the upgrade gate, display tickets and
the RPC dispatcher; plus the relay settings UI and its strings.
2026-11-07 12:01:04 -08:00
BearHuddleston
916bbda323 docs(webapp): say a relayed chat's pop-out is refused, not hidden
ec53d514f6 described chat pop-outs as offered only for the serving
gateway's chats. The pop-out is still offered for a relayed chat; the
bridge answers it with an error that says the chat stays in the tab.
Say that instead.
2026-11-07 12:01:04 -08:00
BearHuddleston
2dcdf2d6c5 fix(desktop): offer Webapp window and default actions for its own gateway only
The connection registry put a relayed gateway's profiles in front of the
profile menu's Open in new window and Set as default, but a Webapp tab and
every window it opens run on the gateway serving the page
(servingOriginConnection), and its startup profile names that gateway's
profiles. Both actions on a Mini profile failed in requireProfileRoute.
Chat pop-outs dropped the session's connection, so a Mini chat opened in a
window on this gateway, which does not have it.

On the browser host the profile menu now offers those two actions only
for the serving gateway's profiles; a relayed one opens from the switcher.
The bridge answers a pop-out of another gateway's chat with an error that
says so instead of opening the wrong window. Native Desktop, whose windows
can boot on any registry connection, is unchanged.
2026-11-07 12:01:04 -08:00
BearHuddleston
af02c72274 fix(webapp): gate relayed Git review, image uploads and attachments by file access
A grant that left files unchecked still reached the Webapp's other file
operations on the paired gateway: /api/git/* (status, diffs, revert,
commit, worktrees) reads and changes a repository's files,
/api/chat/image-upload writes the image to disk, and on the gateway's own
socket file.attach, image.attach, image.attach_bytes, pdf.attach and
input.detect_drop read a path there or write the browser's bytes there,
while complete.path lists its directories.

The files scope now covers the whole /api/git namespace and both chat
upload routes, and relay_rpc_refusal checks those socket methods against
it too. The composer's path completion already falls back to no
suggestions on an error, and Bot Mode lists an attachment it could not
pass on.
2026-11-07 12:01:04 -08:00
BearHuddleston
7068a28433 fix(webapp): keep relayed responses out of the browser cache
The relay forwarded the gateway's Cache-Control, ETag, Last-Modified
and Expires onto the hub's origin. A gateway could mark a response
public for a year. The browser could then serve it after the grant
was revoked, or to another account signed in later.

Send Cache-Control: no-store on relayed responses and drop the
gateway's cache headers.
2026-11-07 12:01:04 -08:00
BearHuddleston
4e223983d8 fix(webapp): gate relayed shell, CLI and wake-word RPCs by scope
The gateway's own /api/ws also runs shell.exec and cli.exec and arms
the wake word, outside any chat turn. The scope gate on relayed
sockets covered only display.* and voice.*, so a grant without
terminal or voice access could still run commands, read their output
and arm the microphone.

Gate the shell and cli namespaces by the terminal scope and wake by
voice. Bot Mode's profile edits through cli.exec (describe, delete,
reset the model) stay open, because the profile and settings routes
every grant reaches make the same changes. Any other command line is
refused.
2026-11-07 12:01:04 -08:00
BearHuddleston
0cc53201d0 fix(webapp): remove a relayed gateway only once its grant is revoked
Remove forgot the gateway here first, then revoked its grant on the
other gateway as best effort: a transport failure was logged and an
error status ignored. Settings reported the gateway removed while its
grant still worked, and the record needed to retry was gone.

Revoke on the other gateway first, and forget the gateway only after a
2xx. Otherwise keep it and answer `removed: false` with the reason.
Settings shows that reason and offers "Remove here only" (`?forget=1`),
which warns that the grant stays until it is revoked there. A pairing
approved as another account now also says when its grant could not be
revoked.

Reported in review of #147291.
2026-11-07 12:01:04 -08:00
BearHuddleston
635a3a8f9b docs(webapp): reach other gateways from one Webapp
How to turn the relay on, pair and revoke, and what a grant does and
does not allow.
2026-11-07 12:01:04 -08:00
Teknium
21cd0af57d feat(desktop): make every new group chat run on a gateway
There is one kind of group chat. New group chat always plans a room its
gateway owns, whether the bots are on this computer or on others, so it
keeps running with Desktop closed. When that is not possible (Hermes too
old on the owner, an owner that cannot seat peers, a lender missing its
API server, address or approvals, an unreachable computer), the dialog
says what is missing on which computer, keeps the draft and offers Retry;
it never falls back to a Desktop-driven room.

Bots from a named profile on another computer now join too: lender
checks are keyed per connection and profile, the pin carries the profile
the lender's catalog names, and the invite asks that profile.

Removed: the Desktop-driven creation path, the "Start a group chat that
runs without Desktop" upgrade (canonical-group-upgrade.tsx) and the copy
only it and the courier note used. Existing Desktop-driven rooms keep
their history and composer, and a membership edit keeps them that way;
no edit makes a room Desktop-driven.
2026-11-07 12:00:23 -08:00
Teknium
9a7931dc31 feat(groups): lend any served profile to another gateway's group chat
A gateway could seat only its `default` profile as a cross-gateway group
chat member. Now any profile it serves can be lent:

- room_link()/groups.peer.invite advertise and mint for the connection's
  own served profile (the grant's target_profile).
- A named profile that inherits the gateway's room_link_url advertises
  `<room_link_url>/p/<profile>` in its catalog (covered by the digest), so
  every lender call runs under that profile's /p/ prefix scope: its home,
  config, .env secrets and state.db. A profile that sets its own
  room_link_url advertises it as is.
- Grants answer only on their own profile's route: the run routes
  (POST/GET /v1/runs, stop, approvals, events) now check
  claims.target_profile against the request profile, as the room-member
  routes already did. An unprefixed request is the listener's own profile.
- The owner no longer refuses a non-default peer target in
  groups.peer.register; the pinned target profile must still equal the
  catalog's execution_policy.target_profile.

test_session_group_peers.py::test_room_link_is_enabled_only_when_this_gateway_can_host_a_member
changes deliberately: a named profile now reports the next missing piece
(endpoint_required) instead of default_profile_required.
2026-11-07 12:00:23 -08:00
dokterdok
db786b1ce6 docs(desktop): explain peer group chats and their limits 2026-11-07 12:00:23 -08:00
kshitijk4poor
16f70a2b33 fix(memory): previous_message is the typed ask after a multimodal turn
On a turn with an image, Hermes appends the injected context (recalled
memory, pre_llm_call and gateway notes) to the message as a text part
(#71998, bb87e6abce). The next turn's previous_message, added in
#150569, read that part back as part of the ask. The stored row keeps
the parts as one flattened string, so after a restart nothing in content
separates the ask from the injection.

The turn now records its ask in display_metadata under typed_ask before
the first part is appended. That is a persistence-only field, so it
never reaches the wire. The ask is the human-authored view of what the
row will persist (durable_user_row_content, so a TUI list override's
dropped API-only parts stay out), with a todo snapshot that turn-start
compaction folded onto the turn stripped, so a turn already wrapped in a
summary still stamps just the ask. previous_message reads the stamp and
normalises it the same way as unstamped text (gateway timestamp, memory
fence), and gateway replay carries that one key through
(replay_metadata_fields, next to the scaffolding flags), so a resumed
gateway, CLI and TUI all see the clean ask. A row written before this
change falls back to stripping the memory fence; its notes stay, and the
docs say so.

The in-place backfill writes the stamp (only that key) with the part,
also when only gateway notes landed on the parts. That row can exist
before the turn (a TUI submit row) and take a reaction meanwhile, so the
row-addressed rewrite (set_user_message_content, direct and through the
runtime worker) now JSON-merge-patches the given metadata into the row's
instead of replacing it (a null deletes a key); the veto passes
typed_ask: null to remove a backfilled stamp. Its existing api_content
clear is unchanged and only ever sees list rows here, which carry no
string sidecar.

A later compaction that only wraps the row keeps the stamp, including
when the next compaction restates the still-unanswered turn on its own
(copied whole, or rebuilt from the task text of an earlier
restatement).
Any fold (record_absorbed_message, the merge witness every host fold
calls: repair, micro-compaction, a summary carrier absorbing the
in-flight turn, an anchor led into a scaffolding turn) that brings
content drops it, because the row then holds more than that one ask; an
empty turn folded in changes nothing, so the stamp stays. Such a row
reads as it does on main, after a restart too: the transcript flush
rewrites only the columns a turn owns, keeping metadata other writers
add, so when it writes new content for a row whose live dict no longer
carries the stamp it removes that one key (a reaction stays), and hands
the row's metadata back as written. A pre_llm_call veto and the
expired-confirmation redaction drop the stamp too, keeping vetoed or
redacted text away from providers.

The display_metadata set/read idiom this would copy again in
message_metadata.py becomes two private helpers, which stamp_data_use,
mark_inflight_restatement and withheld_prompt_text there now use too.

Reported by Greptile on #150569.
2026-11-08 00:41:35 +05:30
Hermes Agent
6ec4f029fd fix(vault): trusted-click autofill for resolve + MDX-safe docs
- resolve_login_password dispatches a TRUSTED CDP Input.dispatchMouseEvent on
  the sign-in field instead of a scripted DOM MouseEvent: Chrome's
  PasswordAutofillAgent ignores untrusted events, so the scripted click never
  filled the password. Verified live end-to-end: the real-profile browser
  autofills its own saved password on the item's origin and it is read back
  over CDP (no decryption in our code).
- Escape the "Browser profile — <browser>" placeholder in the docs with a code
  span so MDX does not parse it as a JSX tag (docs-site build failure).
2026-11-07 09:46:07 -08:00
Hermes Agent
5c57517be4 docs(vault): document real-profile saved passwords as a login source 2026-11-07 09:46:07 -08:00
kshitijk4poor
a08f2418cd docs(memory): previous_message in the provider guide; tighten its contract
The memory-provider developer guide lists on_turn_start's other keywords but
not previous_message, and plugin authors work from that page. It now says what
the value is (the person's last message, secret-scrubbed, "" on a first or
image-only turn), which known runtime rows and /steer messages are skipped,
that it is best-effort (a replayed notice without a known prefix can come
through), why a resumed process needs it, and that older Hermes omits it. The
MemoryProvider docstring says the same. _memory_turn_start_and_prefetch's one
caller always passes both values, so they are required, and its docstring no
longer repeats the provider-facing rationale.
2026-11-07 14:29:26 +05:30
alt-glitch
0a0dab0686 refactor(state)!: remove the CJK FTS5 tokenizer from core
Delete native/fts5_cjk/ and the messages_fts_cjk integration: the
tokenizer loader, the sessions.cjk_fts key and its HERMES_CJK_FTS bridge,
HERMES_FTS5_CJK_SO, the cjk table and triggers, its stale breadcrumb,
quarantine, backfill and reset paths, and the cjk_unicode61 cases in the
FTS error classifiers and the repair probe.

No installer, package or image ever shipped libfts5_cjk.so, so the loader
returned False on every install and CJK queries already took the trigram
and LIKE routes. Those routes are unchanged. The integration had about
40 code sites that every FTS change had to keep correct, and its
triggers made writers that never load the tokenizer (the sqlite3 CLI)
fail with "no such tokenizer: cjk_unicode61".

A store that built the index is cleaned up on the next read-write open
and at the start of the repair health probe: drop the three triggers
first so outside writers work again, then the source view, the
fts_cjk_* markers and the table. SQLite before 3.47 cannot drop an FTS5
table whose tokenizer is not loaded; there the schema row is deleted
under writable_schema and the shadow tables are dropped. One warning
says the .so can be deleted. The drop does nothing when no
messages_fts_cjk object exists, so a second open is a no-op.

BREAKING CHANGE: sessions.cjk_fts, HERMES_CJK_FTS and HERMES_FTS5_CJK_SO
no longer have an effect. 1-2 character CJK terms use the LIKE scan on
every install.
2026-11-07 02:46:16 -05:00
Jimmy_bob
5b55585157 fix(desktop): bind vault autofill to the selected preview page 2026-11-06 22:59:41 -08:00
alt-glitch
807b3f1081 fix(update): rewrite gateway launch files before any gateway starts
`hermes update` started paused gateways (and restarted the fleet) from the
service definitions the previous release wrote. A systemd user unit was only
regenerated by the new gateway at boot, after systemd had already started it
with the old unit's environment, and that boot-time rewrite ran while the
Node dependency step was recreating node_modules/.bin, so the unit it wrote
was already outdated.

Add hermes_cli/update_launch_files.py: one step that regenerates every
profile's launch files that differ from what the updated checkout generates
(systemd user units with daemon-reload, the system unit when run as root,
the plist of a launchd job that is not loaded, Windows .cmd/.vbs launcher
scripts compared by content). Each file is independent; a failure is
reported as the `launch_files` follow-up and the rest are still rewritten.

The update calls it once, from a new `after_dependencies` hook in
build_update_products: after the Python and Node dependencies are prepared
and before the paused-gateway restart and the product builds. A tail that
ends before that hook, and the historical-takeover finish, run it before the
fleet restart. Generated file contents are unchanged.
2026-11-07 00:01:43 -05:00
Teknium
0acc079a01 refactor: move the Yuanbao optional skill out of core with the platform
The skill drives the yb_* tools, which now ship in the yuanbao Labs plugin; the plugin carries
the skill (ctx.register_skill). Regenerated the skill pages, catalogs and sidebar with
website/scripts/generate-skill-docs.py, dropped yb_* from the ACP TOOL_KIND_MAP as the Home
Assistant move did for ha_*, and the boundary baseline's stale Yuanbao entries
(scripts/boundary_lint.py --update).
2026-11-06 20:39:14 -08:00
Teknium
e1f7b59ec2 refactor: move Yuanbao out of core into the yuanbao Hermes Labs plugin
The Yuanbao gateway platform (plugins/platforms/yuanbao) and its yb_* tools
(tools/yuanbao_tools.py) now ship as the `yuanbao` plugin in
NousResearch/hermes-labs-plugins, a community-tier, Nous-built, unsupported
plugin. Platform name, toolset name (`yuanbao`), tool names, env vars,
config keys (platforms.yuanbao.*, legacy gateway.yuanbao) and
YUANBAO_HOME_CHANNEL are unchanged.

Migration: a LEFT_CORE row (hermes_cli/left_core_migration.py) installs the
catalog plugin for every home core ran Yuanbao for: YUANBAO_APP_ID (or the
legacy YUANBAO_APP_KEY) plus YUANBAO_APP_SECRET in its dotenv layers (the
process env too for the launch home), platforms.yuanbao on through the
gateway's own config loaders, or the yuanbao / hermes-yuanbao toolset
selected for another platform. The shipped `yuanbao: [hermes-yuanbao]`
platform_toolsets row is not use. The row keeps the yb_* tools off on every
platform whose core composite never carried them, keeps YUANBAO_APP_SECRET
stripped from children (secret_env) and the other YUANBAO_* settings on the
provider blocklist (private_env) while the plugin is absent, and its notice
carries the unsupported sentence.

Core wiring removed: toolsets (yuanbao, hermes-yuanbao, the hermes-gateway
include), Platform.YUANBAO (Platform('yuanbao') resolves once the plugin
registers it), the platform/toolset menu rows, the TUI special case, the
static session note (the plugin's platform_hint carries it), env/config-key
lists, webhook deliver set, startup allowlist list, locales strings and
yuanbao-only tests. Telemetry enum values stay.
2026-11-06 20:39:14 -08:00
alt-glitch
3caa45f370 fix(update): remove the directories a dropped package leaves behind
When a commit moves or deletes a package, git removes its tracked files
but keeps the directory while __pycache__ is still in it. The bytecode
sweep then removes __pycache__ and leaves the directory empty. An empty
directory at an old package path imports as an empty namespace package,
which wins over the editable finder and hides the package at its new
location: `from pkg.mod import f` fails with "No module named pkg.mod".

Both sweeps (the update completion and the launch-time sweep after a
manual pull) now diff the commit recorded in .bytecode-fingerprint
against HEAD, take the parent directories of every dropped file, and
rmdir them deepest first after the bytecode is gone. rmdir only removes
an empty directory, so one that still holds a user's file or ignored
state is kept. No recorded commit means nothing is removed.
2026-11-06 23:01:26 -05:00
alt-glitch
85b43c1f0b fix(update): refuse a target that lacks a startup file it declares
The pre-move syntax preflight and the post-move check skipped any listed
startup file the target did not contain. A change that moved or dropped
one of those files therefore passed both checks, and the next launch
failed on the import.

The list of startup files now lives in the tree it describes:
pyproject.toml [tool.hermes] update-startup-files. Both checks read the
target's own list, so a commit that moves a startup file updates its
path there and updates to it are judged by the new path. A declared
file the target lacks refuses the update before anything moves, and
rolls the pull back after it.

A target that declares no list (every release before this one) is still
judged by the running updater's list with absent files skipped, so
rollbacks and channel switches to older releases keep working: releases
up to v2026.9.24 lack five of the nineteen listed files.

The post-pull guard now always goes through tree_syntax_error, which
already chose the interpreter by requires-python, so the separate
same-interpreter path (_validate_critical_files_syntax) is removed.
2026-11-06 23:00:58 -05:00
unsupportedpastels
a8b0bc1505 fix(gateway): a newest-first walk restarts when its tip rotates, and a quoted count never replaces the footer's
Past sessions.max_resume_messages a rotated lineage pages only its current
segment, and a newest-first cursor from that read held no segment. Once a
compaction rotated the tip to a new segment, the old key was looked up in
the new one, the walk ended with an empty page and reset: false, and the
reader kept the old segment's rows. A tip-only newest-first cursor now
holds its segment; when the current segment differs, the reply starts
again from the newest page with reset: true. Whole-lineage newest-first
cursors are unchanged (they page across rotations inside the lineage). A
tip-only cursor issued before this change has no segment, so it resets
once, as an unscoped t3 cursor does.

compaction_summary took the compacted-message count from the first match
over the whole summary, before the quoted user messages were cut, so a
quoted message spelling out the footer's sentence won. The count now comes
from the Context Recovery footer when there is one, else from the summary
with the quotes cut.

Contract doc and gateway-local-sessions.md describe the new reset; the
gateway contract outputs are regenerated.

Reported by Greptile in review.
2026-11-06 22:07:09 -05:00
unsupportedpastels
ee53ce461f fix(gateway): a transcript poll never loses a rewritten row or keeps rows a read past the resume guard drops
Two ways a poller could end up holding something other than what a fresh read shows:

- A rewrite (a queued prompt's prologue rewriting its user row with set_user_message_content)
  committing between the display-index backfill and the read snapshot left the row without a
  display slot. The page skipped it while the cursor stored the rewrite's revision, and the next
  poll's backfill moved no cursor counter, so the row never came back. The read now checks the
  index inside the snapshot (SessionDB.transcript_display_index_complete); when a slot is missing
  it leaves the snapshot, backfills and reads again. When every attempt finds a slot missing the
  reply is reset: true, as an unproven read already is.
- Appends that take a rotated lineage past sessions.max_resume_messages switch the read from the
  whole lineage to the current segment, but the cursor did not record which one its page read, so
  a poller kept the ancestor rows with reset: false. The cursor now holds the scope (format t4);
  a read in the other scope answers reset: true in either order. A t3 cursor from an earlier head
  of this unreleased read is still accepted and resets.

Regression tests for both suggested by @BearHuddleston in review (appended verbatim).
2026-11-06 22:07:09 -05:00
unsupportedpastels
57c3630e16 fix(gateway): a transcript read without a pooled reader resets when unproven, and a shared handoff shows once across pages
Review fixes for session.transcript:

- A store without a pooled reader (not WAL, a read-only handle, a reader
  that failed to open, the pool's ceiling) pinned nothing, and its
  consistency check was always true: a row deleted between the page read
  and the cursor-state read stayed in the client forever (reset: false).
  transcript_read_snapshot now checks there that no write landed in the
  database during the block (_write_generation: the writer connection, its
  total_changes for this process's writes and PRAGMA data_version for
  every other connection's commits), holding no lock across the block.
  _poll reads once more when one did; when the retry also overlaps a
  write, the reply is reset: true with the first page and a cursor state
  no transcript has, so the next poll resets again. The pooled path is
  unchanged. The yielded check gains .pinned.
- page_handoffs deduplicated a handoff only within the current window, so
  two carriers holding the same uid-less handoff each showed it once the
  window moved past the first (also limit 1, oldest order). A handoff is
  now shown before the first row in the whole transcript that holds it: a
  rotated lineage checks the rows before the window it already read; one
  segment asks the new SessionDB.transcript_handoffs_shown_before for the
  display rows before the window's first slot.

Tests: tests/gateway/test_session_transcript_handoff_owner.py (seeded
transcripts with identical uid-less handoffs on several carriers, re-wraps,
in-place compactions and rotations: every limit 1-5, both orders, equals
the full read; two identical uid-less carriers, limit 1 and 2, both
orders). tests/gateway/test_session_transcript_snapshot.py: append-then-
clear and delete-during-page, each pooled and without a pooled reader; a
read that never settles resets twice, then converges.
tests/hermes_state/test_transcript_read_snapshot.py: without a pooled
reader a write from this process or another connection makes the block
inconsistent.
2026-11-06 22:07:09 -05:00
unsupportedpastels
857464b871 fix(gateway): a transcript cursor vouches for its own page, covers every segment, and limit counts handoffs
Review fixes for session.transcript (all behind SessionDB methods now):

- One read generation per poll. The cursor check, the page and the state the
  next cursor stores are read in one read transaction
  (SessionDB.transcript_read_snapshot: _read_ctx hands the thread's pinned
  pooled reader to every nested read). Before, a row appended after the poll
  started could land on the page and be deleted (clear_messages moves neither
  the inactive count nor transcript_revision) before the state was sampled;
  the cursor then certified the post-deletion state while the reader held the
  deleted row, and later polls answered reset: false forever. A store without
  a pooled reader (not WAL, read-only, pool ceiling) is not pinned, so a write
  from inside can never wait on its own lock.
- transcript_cursor_state's live count spans the whole displayed lineage: the
  segment's own rows up to the cursor, plus every live row of its earlier
  segments. Deleting an earlier segment's rows now resets a poller, as its
  reactions already did.
- limit bounds the rows sent, compaction rows included. A row's handoffs and
  the row can fall on two pages; the cursor then names the row and how many
  of its group were sent (a third key part), so no handoff is dropped or
  sent twice, both orders, several handoffs on one carrier included.
- Storage interface: every new store read is a narrowly named SessionDB method
  in one module, hermes_state_stored_reads.py (was
  hermes_state_transcript_cursor.py; hermes_state_display_set.py folds in as
  _display_set / _with_removed_identities, the worker calls the latter as on
  main): transcript_read_snapshot, transcript_segment_page (with the cursor
  slot and durable-id lookups), transcript_tool_calls_before,
  sessions_in_workspace, picker_session_facts, session_current_segments,
  subagent_session_ids. get_messages and _fetch_conversation_rows gain their
  port lines. The gateway and tool modules keep their function names.

Tests: tests/gateway/test_session_transcript_snapshot.py (append+delete during
a page read; an earlier segment's deletion and, separately, its reaction;
limit 1 and 2 across a carrier with two handoffs, oldest and latest) and
tests/hermes_state/test_transcript_read_snapshot.py (one generation inside a
snapshot; a DELETE-journal store is not pinned). One consistency test's first
page now ends at the handoff, which counts toward limit.
2026-11-06 22:07:09 -05:00
unsupportedpastels
4d89901ef4 feat(gateway): one session.transcript pages, polls and reads delegated children; handoffs are rows
session.transcript becomes the one stored-transcript read; session.compactions
and subagent.transcript never ship.

- Forward polling: an oldest-order cursor is never null. It also holds the
  segment it read and transcript_cursor_state of the rows it covered; while
  both hold, the next read continues after it (reset: false, only appends).
  An in-place compaction, a rotation, a rewind, or a rewrite or deletion of a
  covered row answers reset: true from the first page. The stored state is
  read between two snapshots around the page read, and a non-append change in
  between reads the page again. A page is empty only when caught up (windows
  that project to nothing are read past). Latest order keeps its relocating
  cursor and ends with a null cursor.
- An oldest-order page continues at the next display slot instead of
  filtering by durable id, which is not monotonic in display order (a
  handoff's new row sits before the carried copies of older messages).
- Every row carries row_kind: "message" (the session.resume display row) or
  "compaction" (a handoff at its position: role system, the readable summary
  as text, compacted_messages, timestamp, row_id). Older handoffs on earlier
  copies of a re-wrapped or unwrapped carrier still show, each once
  (SessionDB.transcript_handoff_rows).
- subagent_id reads a delegated child of session_id with the ownership rule
  from #140477 (running: the parent's live roster; finished: the _subagent_id
  marker and a lineage of delegate-child or compression hops). The reply adds
  subagent_id, available, running and child_session_id; a foreign or unknown
  child is available: false with no rows, a null cursor and reset: true.
- runtime.describe advertises session-transcript-v1 and
  session-list-picker-v1.
- Contracts, OpenRPC/TS and the serve handler ledger regenerated; docs
  updated. Storage-interface port names on every new or changed SessionDB
  method.

Tests: the stored-read suites move to the one method (resets where a
compaction lands between pages, handoffs as rows); new poll tests drive
appends, compaction, rotation, rewind and rewrites between polls, plus a
seeded random sequence checked against a fresh read after every poll. The
subagent ownership, lineage, multiplex-scope and live E2E tests are adapted
from #140477 to session.transcript with subagent_id.
2026-11-06 22:07:09 -05:00
alt-glitch
5c1cfbb498 fix(gateway): page stored transcripts in one read generation on indexed lookups, with resume's normalization
Fourth review round on session.transcript:

- The cursor's slot lookup OR'd a primary-key match with an identity match, so SQLite walked the
  whole segment on every page (a full walk of 30k rows at limit 100 took 2.9 s). It is now one
  primary-key read plus an equality read on idx_messages_display_identity (0.6 s).
- The slot lookup, the page read and the durable-id lookup ran as separate statements, so a
  compaction committing between them could apply an old boundary to a new generation and skip a
  message. They now run in one explicit read transaction (still one read context).
- A reply a later compaction wraps in a summary carrier changes identity; the slot and durable-id
  lookups now also follow a carrier's message_uid (carriers only, so a pruned tool result keeps its
  own identity), so oldest-first paging no longer shows it twice.
- Tool-result context paired results with every older call of a reused provider id, and a later call
  on the page hid an opening result's call. Each result is now paired with its own occurrence: its
  stored tool-call uid (tool_call_uids maps id to uid), else the nearest earlier call.
- Cursor ints outside SQLite's signed 64-bit range raised OverflowError at binding; they are now
  invalid_params.
- SQL-paged rows skipped the conversation normalization a resume applies; they now go through
  _rows_to_conversation with the display row before the page as context, so a background-review
  harness prompt and its curator reply split across pages are both dropped, and stale [memory]
  markers stay blank. The cursor advances past rows the normalization drops at the page edge.
2026-11-06 22:07:09 -05:00
alt-glitch
5fbe550378 fix(gateway): stored reads never nest a store read, bound every row, and keep tool labels across cuts
Third review round on the stored reads:

- session.compactions resolved the lineage inside its own read context. Without the WAL pool a read
  runs on the writer under SessionDB._lock, which is not reentrant, so that nested read deadlocked
  (the 6bb377a51d boot wedge). The lineage is read first; every new read path is checked by a
  test that fails on any nested read.
- A row too large for a page alone was only clipped in text/content and measured escaped but cut by
  characters. It now keeps its role, time and ids plus the head of its text, sized by its serialized
  JSON, and carries truncated.
- Halving a page could leave a tool call on one page and its results on the next, where they lost
  their name and arguments. Cuts fall between tool groups, and results whose call sits on another
  page are projected with that call (found on the assistant-calls index) as unseen context.
- Newest-first paging resumed at the cursor message's old display slot, so a compaction that
  carried it moved its copy above the cursor and the next page skipped the message before it. The
  keyset now starts at the message's current slot, in both orders.
- Compaction copies collapse by occurrence (message_uid and stored content), never by the cleaned
  summary text, so two compactions with the same prose are both listed.
2026-11-06 22:07:09 -05:00
alt-glitch
4a481f84dd fix(gateway): stored reads judge old rows at their tip, page in bounded SQL, and keep every compaction
Review of the first cut found a hole and several costs:

- Auth: an old local row was checked on the id the caller sent, then its tip's lineage was read, so
  transcript(root) showed a tip another principal owns. The read now judges the compression tip, as
  the stored list and resume do.
- Cost: every page re-read and deduplicated the whole lineage (0.4-0.8 s a page at 30k rows, a
  full walk ~127 s). A single-segment conversation is now keyset-paged on its display index (a few ms
  a page, full walk 0.6 s); a rotated lineage is deduplicated whole only under
  sessions.max_resume_messages, and past it only the current segment is paged.
- Size: a page stops at 2 MiB of projected JSON (one larger row is cut and marked truncated) and
  images read [image] unless inline_images is asked, so no page reaches the 8 MiB client frame.
- Cursor: bound to the session and order, length-capped before decoding, keyed by each message's
  first durable row with a carried tail's superseded original included, so a boundary inside the
  carried tail no longer repeats a row. order: latest reads the newest page first.
- session.compactions reads the handoff rows themselves (live, archived, or superseded by a later
  compaction that carried or unwrapped them) instead of the display dedupe, which lost a handoff
  whose carrier a later compaction reused. Summaries drop the model-facing parts and carry
  compacted_messages.
- session.list picker fields are opt-in (picker: true), one batched read (receipt targets in SQL,
  tip walks on the same connection, one indexed probe per segment for the last reply, a pure
  handoff skipped); the stored feed reuses list_sessions_rich's columns. The live poll is back to
  its batched reads.
- The reads run on the socket's concurrent read lane. get_messages_as_conversation keeps its
  keywords (RuntimeSessionStore parity); the lineage path composes the store's own steps.
2026-11-06 22:07:09 -05:00
alt-glitch
95973b61d2 feat(gateway): read a stored session without attaching (picker fields, transcript pages, compactions)
A gateway client's session picker had to read state.db itself: session.list carried no folder,
activity or last reply, session.history and session.events.since serve only an attached session,
and a session.resume subscribes the caller. hermes-tern copied Hermes' listing, lineage and
compaction rules into Node to work around it.

session.list (both scopes) now takes a `workspace` filter (hermes -c's workspace_key rule, the
same SQL clause on the stored feed) and returns the current segment's preview, last_reply, cwd,
git_branch, workspace, last_active_at and pinned, in one batched read per page.

session.transcript pages a stored conversation's display rows across its compression lineage:
the same deduped display read and display_messages projection session.resume uses. Its opaque
cursor is keyed by each logical message's first stored row (now exposed by the one display
dedupe), so a page boundary holds across later compactions and rotations.

session.compactions returns the handoff summaries the display rows leave out, without the
model-facing preamble (compaction_summary_text).

Both reads use session.resume's own session:read authorization and build no agent and subscribe
nobody; an old CLI/TUI/GUI row is read by the stored feed's own rule (legacy_readable, extracted
from stored_picker_sessions) and never adopted.

Closes #150091
2026-11-06 22:07:09 -05:00
Maciej Lisiewski
8153953654 Merge pull request #150430 from NousResearch/chore/pnpm-switch-leftovers
chore(js): pnpm switch leftovers (cache inputs, undeclared deps, lock attributes, Nix hash docs)
2026-11-07 03:23:47 +01:00
Teknium
a710172509 fix(groups): Stop and Discard publish a recovered completed answer, never a cancel
Resolving an unknown canonical attempt commits a retained captured result as
`completed` (resolve_unknown_as_owner), but the hosted `discard` RPC always
answered `cancelled`. Stop recovery then marked the room task cancelled and
the finished answer was never published; Discard of an indeterminate task
did the same.

`discard` now reads the admission back and reports the receipt it actually
committed. A saved Stop that finds a committed answer settles the stopping
task with it (published once; a later pass finds the task terminal), and
Discard resolves the indeterminate task with it. The unknown-discard path
applies only to stopping tasks of a transport that can discard, so a
deferred peer's confirmation keeps main's behaviour. Docs: the control
executors use ThreadPoolExecutor defaults with unbounded queues.
2026-11-06 18:09:43 -08:00
Gille
b90a4f6d97 fix(groups): complete stopped member recovery before room preparation
A persisted Stop now recovers before historical publication/checkpoint work,
and an unknown canonical attempt is discarded only for its exact task and
execution generation.

Rebased onto main: the per-room preparation lock from the original commit is
dropped, since main's tests/tui_gateway/test_hosted_room_prepare_fence.py
requires preparation to hold the service policy lock.
2026-11-06 18:09:43 -08:00
Gille
336c9f81bc fix(gateway): isolate hosted control request dependencies 2026-11-06 18:09:43 -08:00
unsupportedpastels
d0b49116ec feat(gateway): a client can name itself on session.create
A third-party client can now say who it is: session.create takes an optional
client {name, version?}. It is attribution only. source still picks the
policy, and no toolset, approval, permission, prompt text or telemetry reads
the label.

- Validated beside the editor check (bounded, safe charset); a malformed value
  is invalid_params on field client.
- Kept inside the frozen creation request, so there is no new column, receipt
  key or policy field: an older owner restores the session, and the label is
  part of the exact-retry identity.
- session.info.client echoes it (absent when none was sent); runtime.describe
  lists client in session_create.parameters and capability session-client-v1.
- Plugins read it with hermes_cli.plugin_session.session_client() (published
  in plugin_api.json) and the client / client_version keys of prompt-section
  session info ("" when none). No PluginContext method, no hook kwarg.
- The classic CLI's /new copies the frozen launch request but never the
  creating client's label: the new session belongs to the terminal.
- Contracts regenerated; docs say the label is self-declared and must never
  grant anything.
2026-11-06 20:48:57 -05:00
Maciej Lisiewski
3581b52e5e docs(nix): note the dev-shell hook rewrites the lock but not the hash
mkPnpmDevShellHook runs pnpm install --lockfile-only when a manifest
changes, which leaves nix/pnpm-deps-hash stale like the other two paths.
2026-11-07 02:44:24 +01:00
Maciej Lisiewski
e97bd85859 docs(nix): say how to refresh nix/pnpm-deps-hash after a lock change
`hermes pm update --pnpm` rewrites pnpm-lock.yaml but not the flake's
fixed-output store hash, and no doc named the second step. Document
`nix run .#update-pnpm-lockfile` (what it does and the CI fallback) in the
Nix setup guide, its zh-Hans translation, and the PM maintainer commands.
2026-11-07 02:44:23 +01:00