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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
The documented chart.write handler called the model inline. A plugin RPC call
holds its client's request lane until the handler returns, so that client's
next requests on the connection (an interrupt, an approval answer) waited
for the model, which llm.oneshot never did.
The example now needs a session_id, starts the model call in a thread under
contextvars.copy_context() (ctx.llm reads the profile scope from there),
answers {"job"} at once and sends the chart or the error as the session
event chart.written. A semaphore caps it at 4 calls in flight like
llm.oneshot's per-owner cap; a fifth is refused busy, and a slot comes back
when Thread.start fails.
The route's test now runs the page's code block verbatim, in-process and
under plugins.isolation: host: a sessionless call is refused, 4 calls
return jobs while their model calls are held, a 5th is refused busy, the 4
chart.written events carry the jobs and the parsed JSON, and a 6th call is
accepted. In-process it also makes Thread.start fail 4 times and checks
the next call still gets a slot.
Suggested by @BearHuddleston in review.
The plugin LLM guide shows the route: the frontend calls
plugin.<id>.<name>; the handler, registered with ctx.register_rpc,
masks its input with redact_sensitive_text(..., force=True) and calls
ctx.llm.complete_structured on the task the plugin registered.
The test runs that route end to end on the session authority: a plugin
registers an auxiliary task and an RPC method, auxiliary.<task> points
at a loopback stub model, and a frontend-shaped call gets the parsed
JSON back. The stub saw the request on the task's model with a
json_schema response_format, and never the secret, with redaction
turned off for the profile (force=True). Without force=True it fails.
A plugin that sends user text to a model (ctx.llm) needs to mask the
secrets in it first. agent.redact.redact_sensitive_text does that, but
it was a private import, so `hermes plugins validate` warned on it.
List it in hermes_cli/data/plugin_api.json and regenerate the public
API page. A plugin can redact any text with it, which a `redact=` param
on ctx.llm would not give, and it adds no new parameter semantics.
plugin-llm-access.md documents when to pass force=True.
#142006 widened the core llm.oneshot gateway method with `schema` and
`redact` params and a `parsed` result field. Only one plugin's chart
writer would ever send them; Desktop, the bundled plugins and the TUI
never do. A plugin's frontend already has its own route for this: a
plugin RPC method (ctx.register_rpc, #142005) whose handler calls
ctx.llm.complete_structured on the plugin's own auxiliary task.
So both gateways and the contract go back to the pre-#142006 shape for
these params. Two parts of #142006 stand on their own and stay:
- client_task: an unknown `task` is refused (invalid_params field=task
on the shared gateway, 4031 on the sidecar). Before it, a typo ran
on the main model unnoticed (#141976).
- agent/plugin_llm.py parses the whole reply as JSON first, then the
fenced block, so a JSON value whose strings hold ``` fences parses.
That fixes ctx.llm.complete_structured. Its test now exercises
_parse_structured_text directly.
The ClientIdentity docstring and the programmatic-integration guide
called the client name a free-form label. A gateway that takes client
(#150286) refuses session.create unless name is 1-64 characters of
a-z, 0-9, ".", "_" or "-" starting with a letter or digit, version
(optional) is 1-64 printable ASCII characters without spaces, and the
object has no other keys. A client named after its npm package would
work today and stop creating sessions once its gateway takes client.
State the accepted shape in both places, worded like #150286's
"Naming the client" section.
Suggested by @BearHuddleston in review. Both suggestions are applied
with one addition, "no other keys", because the gateway also refuses
extra keys in client and the option is copied onto the wire as given.
A third-party client built on @hermes/shared/gateway-client always launched as `source: 'tui'`
and had no way to say who it is. GatewayClientOptions now takes:
- `source` (default 'tui'): the session.create policy label. The owner must list it in
runtime.describe `session_create.sources`, or session.create is refused.
- `client` ({name, version?}): the client's own name, sent on session.create only when the owner
lists `client` in `session_create.parameters` (the same gate as `client_env`); an older owner
gets the request without it.
canonicalRequest takes the identity as an optional last argument. A launch with another source or
a client name gets neutral refusals (new keys canonical.launch.noSourcePolicy and
canonical.launch.unsupportedSessionOptions, translated in every bundled TUI pack). Ink passes
neither option, so its session.create frame and refusals are unchanged; a new Ink test pins the
exact frame keys and both refusal texts, and passes on the tree before this change too.
#142166 is merged, so the shared-client paragraph links the `hermes gateway attach` section
instead of naming the issue, and loses the PR-history aside. BearHuddleston's suggested wording
from the #142183 review.
(cherry picked from commit 7798172ef3e28c9cf38a59e61cc62ac34dfb4e44)
resolve-profile followed a caller-supplied home's gateway.lock overlay link,
and narrowed the lock it named to 0600, before it decided whether the home
belonged to this gateway. A request answered profile_mismatch could already
have changed a lock outside the root.
The lookup now decides containment first: the home must be a plain absolute
spelling (no ".", "..", repeated or trailing separator), and its resolved path
must be the gateway's own home or a named profile directly under its root.
Only then is an overlay lock followed, and only to an owner home that passes
the same check (_overlay_owner_home takes an optional within= predicate and
raises OverlayOutsideScope before reading or tightening anything else).
Discovery and attach call it without the predicate and are unchanged.
A local client that dials the gateway itself had to spawn `hermes gateway
attach --json` (a Python start) for every connect, because only Python
could work out the endpoint, and it is subtle when a multiplexer serves the
profile. The gateway now answers that lookup itself with a new control verb,
`resolve-profile`, and the local control socket is documented as a public
client contract.
- gateway/control_resolve.py: `resolve-profile {home}` returns the verdict
`discover_gateway_endpoint` gives for that home (state, reason_code,
detail, endpoint plus ws_url/ws_protocol/ticket prefix), `attachable`,
`update_fenced` (the set `ensure` checks), `control` (self/host/null),
the CLI's failure `message`, and `install_code_sha` (read without
touching the gateway's cached boot identity). Built from the existing
discovery helpers; a strict envelope; no credential in the reply.
- gateway/control_socket.py: `resolve_handler` (None by default, so a bare
server keeps the unknown-verb answer) and one dispatch branch.
- gateway/run_bootstrap.py: install the handler over the `identify`
descriptor.
- hermes_cli/gateway_runtime.py: the missing-owner verdict moves into
`_missing_owner_verdict` so discovery and the verb share it.
- apps/shared/src/node/control-socket.vectors.json: request/reply vectors
for `session-ticket` (its current behavior), `resolve-profile` and the
legacy unknown-verb answer; tests/gateway/test_control_socket_vectors.py
runs them. tests/gateway/test_control_resolve.py proves parity with
discovery over real sockets.
- scripts/ci/classify_changes.py: a vectors-only edit runs the Python lane.
- gateway-internals.md: verbs, envelope, errors, rendezvous (POSIX, macOS
launchd, Windows), security model.
Existing verbs, replies, error strings and `supported_verbs` are unchanged.
Refs #141982
Third-party clients read the clipboard image by running the TUI's private
helper script with PYTHONPATH pointed at the source tree. This exposes the
same extractor (hermes_cli.clipboard.save_clipboard_image) as a documented,
device-local command with a JSON reply and stable reason codes:
ok / no_image (exit 1) / no_tool (exit 3) / write_failed (exit 4).
The TUI helper and the extractor's existing functions are unchanged; the
extractor gains clipboard_image_tools(), the per-platform tool list used to
tell "no image" from "no tool".
The duplicate check refused any overlapping registration in a profile, so a
plugin calling ctx.register_session_env twice for the same name now failed
to load, where it used to load with the later registration's value winning.
Registrations now record their owning plugin (PluginContext passes its
plugin id). Only another plugin claiming a held name is refused, naming the
holder. One plugin's overlapping registrations stack as before: the later
live one's value wins, and disposing either leaves the other's value.
Registrations are keyed by a token again, as before.
ctx.register_session_env merged every registration with out.update, so two
plugins of one profile declaring the same name were a silent last-wins by load
order. The later registration is now refused with the usual conflict error
("session env 'PANE' is already registered by 'holder'"). Unload frees the
name; the same plugin reloading declares it again. The check lives in
hermes_cli/plugins_session_env.py: the holder is read from the scope's plugin
manager ownership ledger, so PluginContext is unchanged.
Declared names were also one process-wide set, so on a multiplexed gateway a
plugin of profile A stopped profile B's own `export NAME=...` from carrying to
B's next command. The names are now kept per profile scope; a scope's names
still stay excluded after its plugin unloads, as before.
Under plugins.isolation: host, discover_and_load(force=True) (reload-plugins,
and every plugin install, enable or update) loads a plugin again into the same
host process under the same plugin_key. A task the first load spawned kept
running, and its emit_plugin_session_event was taken for the new load and
published to the session's viewers.
- Hermes numbers each load of a plugin in the host (load), sends it with the
load request, and forgets it at unload.
- The host binds that load, with the plugin, to each request it serves, so it
follows the request's code onto the tasks it spawns; session_event carries it.
- The gateway process publishes only when that load is the plugin's current
one; otherwise it logs and returns False, as the hosted call did before this
PR forwarded it. A category plugin's fresh instance keeps its key's load.
- ctx.emit_to_session reads the manager's home_path directly: every manager
sets it, as the other readers of the plugin's own profile assume.
Suggested by @BearHuddleston in review.
- The late-event test now covers a same-host reload and waits with
tests.waiting.wait_until and Events instead of sleep loops.
ctx.emit_to_session from such a task is unchanged (it reached viewers on
main too).
Refs #142005, #141982
Under plugins.isolation: host, the forwarded emit_plugin_session_event took
the plugin_id the caller passed: a hosted plugin could publish as another
plugin id, and a task it left running kept publishing after it unloaded.
- The host process records which plugin's code each request it serves runs
(the plugin_key of a load/unload, the owner of an invoked reference) and
sends that with session_event.
- The gateway process looks that plugin up among the loaded ones and
publishes only when plugin_id is its own; otherwise it logs and returns
False, as the hosted call did before it was forwarded.
- In-process, emit_plugin_session_event still takes plugin_id as given.
- Contract and guide wording: without plugin-rpc-v1, clients must not
assume plugin RPC is supported.
Refs #142005, #141982
A client could not tell "no such plugin method" from "this server has no
plugin RPC": runtime.describe advertised nothing, and plugin.* was in no
contract or ledger. Under plugins.isolation: host the module-level
emit_plugin_session_event returned False and sent nothing, and an
in-process ctx.emit_to_session from a plugin's own thread on a multiplexed
gateway looked the session up in the launch profile.
- runtime.describe lists plugin-rpc-v1.
- tui_gateway/contracts gains CANONICAL_NAMESPACES (canonical_namespace):
plugin.{plugin_id}.{name} with open params, rendered as
CanonicalRpcNamespaces in the TS contract and x-canonical-namespaces in
OpenRPC; the serve handler ledger gets one row for it.
- The plugin host forwards emit_plugin_session_event to the gateway process
(host->parent request session_event), looked up in the host's profile.
- ctx.emit_to_session binds the plugin manager's home before the lookup.
Refs #142005, #141982
cmd with delayed expansion enabled drops an unpaired `!`, so `ua!==want`
became `ua==want` and inverted the check on Windows. The preinstall now
exits 0 on a match and refuses otherwise, with no `!`. It names the
required pnpm for any other user agent (including an overridden one), says
when pm/lock.json is missing or pins no pnpm, and gives the PowerShell
activate. A real pnpm, made to report another version through
pnpm_config_user_agent, proves the root preinstall runs on a filtered
install and on one from inside a workspace folder.
The docs claimed every install refuses another pnpm. Only installs that
run lifecycle scripts do: --ignore-scripts, --lockfile-only and fetch skip
the root preinstall on pnpm 12. They now say so, name CI's frozen install
as the lockfile backstop, name pm/lock.json as the pin, and note that a
pnpm major re-pin must move engines.pnpm.
pmOnFail: ignore (needed to keep pnpm-lock.yaml one YAML document) also
turns off pnpm's devEngines check, so a direct or filtered `pnpm install`
ran with any pnpm. engines.pnpm `^12` makes pnpm 10 and 11 refuse with
ERR_PNPM_UNSUPPORTED_ENGINE under engineStrict. pnpm 12 never compares
engines.pnpm with itself, so an exact engines.pnpm would not stop another
pnpm 12: the root preinstall, which pnpm runs on filtered installs too,
now requires the exact pm/lock.json pnpm. Neither is a new pin to sync.
A memory provider could not tell a fresh session from one the agent is continuing (a CLI
--resume, a gateway chat picked up after a restart, a Desktop/TUI session reopened), so it
could not skip re-seeding or reconcile against what it already holds. Agent builds now pass
resumed (an earlier turn of this session id ran: an assistant row is stored) and
message_count (messages stored for it). Keying resumed on an answered turn, not the count,
keeps a fresh TUI/Desktop chat not-resumed: it stores the submitted prompt before the build.
A new session id (subagent, cron run) or no session store reads False; a /branch child
seeded with copied history reports the copy. Mid-process /resume still goes through
on_session_switch. The developer guide lists both, and on_turn_start's model.
Follow-ups from the memory-provider seam review (#149330):
- Profile hooks skip all setup when the profile names no external memory.provider (in its
config.yaml or the managed overlay): no secret scope, effective config or provider load on
the common create.
- The hook also hydrates the new profile's configured secret sources (1Password and the like)
before binding its scope, as the dashboard and cron workers do.
- Under plugins.isolation: host, a plugin host started only for the hook is stopped when the
hook returns, so a long-lived dashboard keeps no host per created or renamed profile.
- Dashboard config panel: an unknown storage value shows no panel and refuses saves instead
of writing a stray $HERMES_HOME/<name>/config.json; storage=provider without
write_config_fields is a 501 (no secret saved); a provider that declares a panel but fails
to load is a 503, not "unknown provider".
- A config_schema.py that fails to load logs its traceback once per file, then at debug: the
panel polls, and an outdated plugin fails the same way every time.
Tests cover each case, including the real plugin host (a refused save crossing it is a 400
with no secret saved; the hook runs in the host and its host is stopped); each fails with
its fix reverted.
Rename hermes_cli/plugin_context.py to hermes_cli/plugins_context.py (and its
test to tests/hermes_cli/test_plugins_context.py) so it sits in the
plugins_<topic>.py sibling family that the facade grep convention covers.
Regenerate the plugin_api.json source label and public-api.md.
Stop re-exporting _ignore_after_abandoned_load from hermes_cli.plugins:
nothing reads it through the facade, and internal moves do not get shims.
hermes_cli/plugins.py was 2,163 lines, about 800 of them the PluginContext
class. The class, its setattr-built provider registrars and the
abandoned-load guard loop now live in hermes_cli/plugin_context.py;
plugins.py drops to 1,345 lines.
hermes_cli.plugins keeps re-exporting PluginContext, _UNSET and
_ignore_after_abandoned_load, and every name it imported before is still
imported there. Functions and classes the ctx methods call
(load_config_readonly, _plugin_settings_entry, get_hermes_home, PluginState,
PluginToolOverrideError, ...) are read from hermes_cli.plugins at call time,
so a monkeypatch on the facade still reaches ctx methods. Log records keep
the hermes_cli.plugins logger name, and typing.get_type_hints on
PluginContext.__init__ still resolves PluginManager.
The public plugin API list names the new file as PluginContext's source.
Tools run in the shared gateway, so a variable of the terminal or pane that
shows a conversation (a pane id, its socket) never reaches the commands the
agent runs for it. A plugin could only rewrite each `terminal` command with
`tool_request` middleware to prefix an `export`, which changes the command
text and does not cover every spawn.
`ctx.register_session_env(names, resolver)` declares the names and a
`resolver(session_id) -> {name: str | None}`. The child-env bridge
(`tools/environments/local.py::_inject_session_context_env`) calls the active
profile's resolvers with the child's own HERMES_SESSION_ID each time it builds
a local child env: terminal foreground and background, `execute_code`'s
`terminal()`, and the other children that already get HERMES_SESSION_*.
`None` unsets a name; an omitted name keeps the gateway's value.
- Names must be valid env names outside HERMES_*, so core session vars stay
core's. Values pass the same internal-secret and provider-blocklist
predicates as the scrub, so a plugin cannot put a credential back.
- LocalEnvironment keeps the declared names out of the shared bash snapshot
(the existing save/restore + dump exclusion for passthrough names). Without
that, the snapshot sourced before each command replaces the fresh value with
a stale one when a session's pane changes or goes away.
- A resolver that raises is logged with its traceback and contributes nothing.
- Registrations are scoped to the plugin manager's profile and released on
unload through the registration ledger.
- Remote backends (Docker, SSH, Modal) are out of scope: they do not receive
session context vars today either.
The new registrar lives in the hermes_cli/plugins_session_env.py sibling; the
facade method is a delegate, offset by a duplicated docstring paragraph in
_delivery_manager so plugins.py does not grow.
Review of the move:
- `isTerminalConnectFailure` becomes `terminalConnectFailure`, which returns the line to report.
The shared client no longer parses Ink's `gateway unavailable:` format; Ink's subclass does, and
logs the same line as before.
- apps/shared/src/node/gateway-client.test.ts runs the client with only `connect` (no Ink
options): it dials the grant with its subprotocols, reads runtime.describe before readiness,
creates a `source: tui` session, rejects a pending request with the English close text, and
redials through `connect(false, true)`.
- Docs say sessions are created with `source: "tui"` and that `hermes gateway attach` comes with
#142159; option and file comments are corrected (connection fields, `text`, prompt-history's
HERMES_HOME, the i18n and helper comments that named the old files).
- Duplicate `@hermes/shared/gateway-types` imports are merged, and apps/shared/tsconfig.json keeps
its original formatting.
ui-tui/README.md's file map loses the moved modules and names Ink's wiring files. The
programmatic-integration guide shows a Node client built on the shared client with its
`connect` running `hermes gateway attach --json`, and no longer says Ink speaks stdio.
auxiliary_client resolves a task explicit args first, then auxiliary.<task>.*, then auto; the
session's route (main_runtime) only fills the auto case. The docs said a session_id lends the
session's model "instead of the task's", which reads as overriding an explicitly configured task.
Raised by Copilot on #142006.
jsonschema is not a core dependency (it arrives only through the mcp
extra and kittentts), and _parse_structured_text skips validation when
it is missing. oneshot_reply now raises ValueError before any model call
when a schema is given and jsonschema is not importable, so parsed is
always schema-checked.
A plugin frontend could not run its plugin's auxiliary task through the
gateway with structured output, so hermes-tern spawns a Python helper that
imports call_llm and the redactor directly.
- task: a built-in auxiliary slot or one a loaded plugin registered with
ctx.register_auxiliary_task, resolved through auxiliary.<task> as before.
An unknown key is now refused (invalid_params field=task on the shared
gateway, 4031 on the sidecar) instead of running on the main model.
- schema: a JSON Schema object. The call asks for JSON through the prompt
and the provider's JSON mode (the response_format ctx.llm already sends),
and the reply carries parsed. A non-JSON or non-matching answer is an error.
- redact: masks secrets in input with agent.redact before the model sees it.
Both servers (shared gateway, tui_gateway sidecar) share agent.oneshot's
client_task and oneshot_reply. Contract and generated TS/OpenRPC updated;
documented in the plugin LLM access guide.
Closes#141976
asyncio.to_thread only created the coroutine of an async def handler; the
await that followed ran its body on the gateway loop, so blocking work in it
stalled requests and event delivery for every client. The worker now resolves
the result with resolve_plugin_command_result, the rule plugin slash commands
already use: an async handler runs on its own loop in that worker thread.
A plugin frontend that is a JSON-RPC client of the gateway could not call
its own Python half, and the Python half could not reach the viewers of one
session. Plugins passed data through shared files and tool.complete payloads.
ctx.register_rpc(name, handler) serves plugin.<plugin_id>.<name> on the
session authority, after the core handler table, with the gate of a plugin
slash command: session:control, plus the session authorization when the call
names a session_id. The handler runs off the loop in the owning profile scope;
a failure answers 4001 plugin_rpc_failed. The ownership ledger removes the
methods on unload and force rediscovery.
ctx.emit_to_session(session_id, event, payload) (and
plugin_events.emit_plugin_session_event) publishes plugin.<plugin_id>.<event>
on that live session event stream only. The session is found by its
conversation id or its resident agent current id, so an id from after
compression still reaches the viewers.
Salvages the idea of #66874 as a smaller redo on the canonical gateway.
Co-authored-by: eiritsu <yoeiritsu@gmail.com>