Commit Graph

546 Commits

Author SHA1 Message Date
Teknium
6190457161 feat(bot-mode): bot_delivery.list — read-only view of a bot's unsettled teammate deliveries
A bot that message_agent's a teammate gets nothing back until the reply lands or the wait times
out; if the teammate is parked on a clarify or approval only the user can answer, nobody sees it.

bot_delivery.list reads the existing receipts under each target profile's
runtime/bot_live_delivery (author bot:<sender>) and reports each unsettled delivery as
queued / claimed / working / waiting_on_you / failed (typed reason; unknown_outcome for an
ambiguous receipt, which must never be resent). The canonical owner joins each target's
admission row and its open prompts (PendingControls.waiting_kinds, a non-pruning read) under
that target's owner scope; the legacy sidecar handler reports the durable admission state only.

Nothing is written, claimed, cancelled or resent.
2026-11-19 00:41:03 -08:00
Teknium
df702cab6b feat(cache): backtest rulings — upstream-aware misses, 5m->1h tier at the first pause, learning-store guards
Teknium approved every improvement the usage backtest found:

- A keep-alive miss served by another upstream than the reply that cached the prefix (Nous serves one
  Claude model from chatcmpl-* and gen-* upstreams; 70 switches broke a warm cache in the window), or
  one that still read the stable system prefix, is routing, not lifetime. Real misses end warming only
  on the second in a row (three misses of any kind end it too). The upstream key is data
  (prompt_cache_clock.response_upstream: a gateway's upstream field, else the response id family),
  stored on the clock event; a retried miss's rewrite is not charged to the money limit.
- cache_ttl auto: a person's chat starts on 5m and asks for 1h from the first message after an idle gap
  past five minutes, for the rest of the session (kept per session id, carried to the compaction child,
  re-derived from a stored clock that asked for 1h). The upgrade fires only when the clock holds no
  guarantee and the last cache touch is over 300 s old, so markers never change on a warm prefix. No
  idle keep-alives before the upgrade. /context names the pending tier. Explicit pins and machine
  sessions unchanged. Wire snapshot regenerated: fresh cli agents now send 5m markers.
- Route store: a downgrade needs samples from two different sessions, an upstream switch is never a
  sample, and a learned lifetime never undercuts the longest hit ever seen (kept outside the trimmed
  recent gaps).

Tests pinning the single-miss stop and the 1h start are rewritten to the new ruling (assertions only).
2026-11-18 03:40:34 -08:00
Teknium
579e25e022 feat(caching): learn how each route really caches, across sessions, from usage already received
agent/prompt_cache_routes.py: a per-profile store (<HERMES_HOME>/cache/prompt_cache_routes.json, atomic,
<= 500 routes, 7-day expiry) keyed by provider, host, model and marker use, fed by the clock from every
folded response (normal replies and keep-alives; no probes). After two consistent samples: never reads
back -> no keep-alives and no markers; re-writes the prefix on every hit -> no keep-alives; early misses
-> keep-alives on the learned lifetime (never past the tier) or none under a minute; an automatic cache
that dies early while the explicit one reads -> markers. /context shows 'Learned: <rule>.'
2026-11-18 03:40:34 -08:00
Teknium
3a4fe9c53c feat(caching): cache rules follow the API spec; first keep-alive miss ends warming for the session; keep warming while a tool runs
Teknium's rulings on PR #156455:
1. A request with cache_control markers is Anthropic spec on any wire or gateway: the 5m/1h it asks
   for is declared and trusted (route ceilings still clamp); 'gateway_1h_untrusted' is gone. Every
   unmarked request is OpenAI spec (30m, renewed by a read), Nous non-Claude models included.
2. The first keep-alive that misses disables warming for the rest of the session on that route (new
   user messages and compactions do not re-arm it; a model/provider switch or a fresh session does).
   The compact/offload fallthrough still runs; /context appends 'Keep-alives: off (one missed).'
3. While a tool call executes, keep-alives continue until it returns, uncounted against the idle
   budget of 3 and bounded only by one rewrite's cost for that tool wait.
2026-11-18 03:40:34 -08:00
yoniebans
d321a00e91 docs(repo): docs, desktop app, skills and native code for the persistence interface
Documentation, the desktop app, skills and native code follow the interface. The published plugin API lists the storage interface names the plugin guide's replacement table gives, so the guide's examples and the bundled plugins that import them stay on the published list.
2026-11-17 17:51:21 +01:00
alt-glitch
458a0046ad refactor(agent): six checkpoint files move from tools/ to agent/checkpoints/
tools/ holds model tools. These six files register none: they snapshot and
restore a working directory for the agent loop, /rollback, /undo's
changed-files line and `hermes checkpoints`. They move next to the agent
loop that takes the checkpoints:

  tools/checkpoint_manager.py                -> agent/checkpoints/manager.py
  tools/checkpoint_maintenance.py            -> agent/checkpoints/maintenance.py
  tools/checkpoint_pruning.py                -> agent/checkpoints/pruning.py
  tools/checkpoint_refs.py                   -> agent/checkpoints/refs.py
  tools/checkpoint_undo_hint.py              -> agent/checkpoints/undo_hint.py
  tools/checkpoint_manager_profile_rename.py -> agent/checkpoints/manager_profile_rename.py

agent/checkpoints/__init__.py is a docstring only. Nine test files move to
tests/agent/checkpoints/. Every importer changes its import line in place,
inside the same function. Nothing stays at the old paths: none of the six
names is on the plugin API list, the shipped-release list or the
old-updater list.

Behaviour is unchanged. The four loggers keep their tools.checkpoint_*
names, so the lines stay under `hermes logs --component tools`. The folder
is not a root checkpoints/ package because the checkpoint store is
HERMES_HOME/checkpoints, which is the same directory as such a package on an
install whose checkout root is HERMES_HOME. agent.* is already packaged, so
pyproject.toml and the lists of root packages do not change.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 19:21:55 -06:00
alt-glitch
5b7b215a0d refactor(plugins): plugin install scan moves from tools/ to hermes_cli/
tools/ holds model tools. These two files register none: they are the
security scan that `hermes plugins install`, `update` and `validate` run
on a plugin tree, and every caller is a hermes_cli plugin command. They
move to hermes_cli:

  tools/plugin_guard.py         -> hermes_cli/plugins_install_scan.py
  tools/plugin_guard_context.py -> hermes_cli/plugins_install_scan_context.py

Their three test files move with them to tests/hermes_cli/. Every importer
changes its import line in place, so no module is imported earlier or
later than before.

tools.plugin_guard keeps working. tests/compat/old_updater_surface.json
lists three of its names, because a `hermes update` from v0.21.6 to
v0.23.1 keeps running old code after the checkout swap and imports
tools.plugin_guard from the new tree (hermes_cli/plugins_cmd.py:209 at
v0.23.1). This is the first use of the compat table: one MOVES key, one
REQUIRED_NAMES row, and tools/plugin_guard.py written by
scripts/move/generate_shims.py. That file makes the old name the same
module object as the new one, so an old updater still runs the real scan.
tools.plugin_guard_context is on no frozen list and gets nothing.

Behaviour is unchanged. Neither file has a logger.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; comments that named the old module stems were fixed
by hand; the two gateway contract files are regenerated from the
docstring that names the module.
2026-11-17 06:41:24 +05:30
alt-glitch
611f0ab757 refactor(cron): three cron helper files move from tools/ to cron/
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
tools/ holds model tools. These three files register none and do cron's
work, so they move to the package that owns it:

  tools/cronjob_job_args.py    -> cron/job_args.py
  tools/cronjob_prompt_scan.py -> cron/prompt_scan.py
  tools/blueprints.py          -> cron/skill_blueprints.py

Their tests move with them to tests/cron/. Every importer changes its
import line in place, so no module is imported earlier or later than
before. Nothing stays at the old paths: none of the three names is on the
plugin API list, the shipped-release list or the old-updater list.

skill_blueprints, not blueprints: cron/blueprint_catalog.py already holds
Automation Blueprints, a different thing. This file reads the blueprint
block of a skill's frontmatter.

Behaviour is the same except two strings. The report of a run the
injection scanner blocked names cron/prompt_scan.py. The one debug line
in skill_blueprints logs as cron.skill_blueprints, so it shows under
`hermes logs --component cron`. job_args and prompt_scan keep the logger
name tools.cronjob_tools.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; the two gateway contract files are regenerated from
the docstring that names job_args.py.
2026-11-16 17:43:16 +05:30
alt-glitch
70c6db1eae refactor(browser-desktop): delete unreached browser and desktop tool code
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:

- tools/browser_lightpanda.py::_record_path
- tools/computer_use/tool.py::get_computer_use_schema
- tools/computer_use/schema.py::get_computer_use_schema
- tools/computer_use/cua_backend.py::CuaDriverBackend.launch_app (and its test)
- tools/computer_use/cua_backend_session.py::_CuaDriverSession.capability_version
  and the _capability_version bookkeeping
- tools/computer_use/cua_backend_daemon.py::_CUA_DRIVER_BUNDLE_ID (callers use
  CUA_DRIVER_BUNDLE_ID)
- tools/computer_use_tool.py::__all__ and the two imports only it re-exported
- tools/bot_desktop/runtime.py::_allocate_display (its test now calls
  _pick_display, the live allocator)
- tools/bot_desktop/install.py::assert_not_running (its test checks release
  via claim/release)
- tools/close_preview_tool.py (whole module) and tests/tools/test_close_preview_tool.py;
  PreviewClosePayload docstring updated and gateway contract regenerated
2026-11-16 15:39:38 +05:30
Teknium
58886fc81e fix(cache): coverage deadlines, guaranteed vs estimated ends, durable generation
The clock modelled every route as "expires = last touch + tier", which is wrong for OpenAI
GPT-5.6+: a read refreshes coverage to at least 30 minutes after it and never restarts a
12h write. It also treated documented minimums as expiries and lost or revived saved state.

- Coverage deadlines per tier with per-route refresh rules: Anthropic family restarts the tier
  on read; OpenAI keeps max(existing, read + 30m) and a 12h deadline stays at write + 12h.
- Windows carry guaranteed_until (earliest deadline, so mixed tiers in one response are only as
  warm as the shorter) and estimated_until (OpenAI: last touch + 24h retention ceiling; pre-5.6
  in_memory 1h). cache_certainly_warm / cache_certainly_cold are the two consumer helpers.
  /context: warm until / may still be warm until / expired / unknown.
- Events bind to the session's durable context generation (rows a compaction or prune archived,
  SessionDB.prompt_cache_generation), kept as saved on restore; a resumed agent restores and
  validates the saved event before folding its first response.
- Route identity is provider + normalize_route_base_url (scheme, host, port, path) + model.
- Agentless session.context_breakdown reads the saved clock (stored_cache_window).
- Codex app-server activity is recorded as an explicit unknown (it sets its own cache options).
- MoA records the resolved aggregator route and the payload the MoA client sent.
- effective_cache_ttl applies the route ceiling on the measured-provider path too.
2026-11-15 12:04:54 -08:00
Teknium
4a89bc6c02 feat(cache): one prompt-cache clock per session; Nous 5m ceiling as data
Every consumer that needs "when does this session's cached prompt expire?" now reads one
answer, agent/prompt_cache_clock.py:cache_window(), instead of re-deriving it from _cache_ttl.

- Per successful attempt the clock records the tier actually on the wire (cache_control ttl,
  prompt_cache_options.ttl, prompt_cache_retention, read from the sent payload), the send time,
  and the tier the response proved: Anthropic cache_creation.ephemeral_5m/1h_input_tokens,
  OpenAI Responses cache_write_tokens_details.ttl_30m/12h_tokens. normalize_usage keeps that
  split as CanonicalUsage.cache_write_by_ttl instead of dropping it.
- Per-route rules are a dict of small handlers: native Anthropic proves via the split;
  OpenRouter Claude is declared (live-probed to honour 1h); routes with a ceiling are clamped;
  other Anthropic-wire gateways assume 5m; OpenAI GPT-5.6+ proves via ttl_30m/12h or declares
  the documented 30m minimum; pre-5.6 assumes ~30m (5m on in_memory); implicit caches are
  unknown. expires = latest read-or-write send time + the written tier. A route switch,
  fallback, session rotation or compaction makes it unknown.
- Route TTL ceiling is data: ProviderProfile.prompt_cache_max_ttl (Nous ships "5m", because
  the Portal's upstream drops 1h after ~7 min and bills 5m), overridden per provider by config
  prompt_caching.route_ttl_ceilings. effective_cache_ttl uses the same helper, so Hermes stops
  asking Nous for 1h. A custom endpoint at the Portal host gets the Nous ceiling.
- Persisted as nullable sessions.prompt_cache_clock (JSON) through the existing token batch;
  restored lazily on resume, falling back to the newest assistant row (assumed).
- Codex app-server: read cacheWriteInputTokens instead of hard-coding cache_write_tokens=0.
- /context shows "Prompt cache: warm until HH:MM (…; 1h, proven)", "expired … ago" or
  "unknown (…)". The surface is absorbed from #142387 (render/duration helpers, the
  SessionContextBreakdownResult.prompt_cache contract and translations), reworked onto the clock.

Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
2026-11-15 12:04:54 -08:00
Siddharth Balyan
b2c6bc4e1e fix(usage): provider limits first, Nous balance apart
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Canary Release / Tag, draft, and start the canary build (push) Has been cancelled
Canary Release / Prune canaries older than 14 days (push) Has been cancelled
Squashed onto main (#151819). The session.usage conflict with #141859 keeps the
branch side: _usage_nous_fields already reads the Nous fields inside the
session profile scope.

main's #141859 test now stubs both Portal reads: a session off a Nous route reads
with the stored token only (stored_token_account_info).

agent.account_usage keeps the names that moved to agent.account_usage_nous (and
BP_FULL): plugin_api.json publishes the whole module, and catalog plugins import
build_credits_view and build_nous_credits_snapshot from it.
2026-11-15 08:20:26 +05:30
teknium1
7f4e5e68a8 fix(contracts): declare upstream_repo on catalog install rows; map contributor email
ConnectionOperationTarget forbids unknown keys, so the upstream_repo the
skill install row now carries made connection.update / operation.status
reject every chat-catalog install of an upstream stub (brag, brag-slim,
impeccable, archify) with extra_forbidden. Declare it, regenerate the TS
contract, and validate the row against the contract in the test.

Map milgoff@gmail.com -> dmytrodanilenkov for the repository guards.
2026-11-14 19:54:21 -05:00
Siddharth Balyan
77567404e5 fix(providers): publish an updated provider plugin only once it imported whole
Review round 1 (#153318). The reload dropped the live registrations before the
new tree finished importing, tracked ownership loosely, trusted the in-tree
catalog sidecar as identity, and could reuse a failed import's submodules.

Each tree now imports under its own module name (base + file fingerprint) into
a staging layer; a complete import is published in one step (per-name owner,
generation bumped), a failed one leaves the previous version serving and drops
its half-loaded submodules. The old package stays loaded, so clients built from
it run that version end to end. Identity is a fingerprint of the plugin's files.
The activation summary keeps the dependency check on a failed import, carries
the gateway's own load_error, and the field is in the PluginActivation contract.
2026-11-14 05:45:02 +05:30
alt-glitch
f3303638f8 feat(gateway): session.list pages the stored listing with a cursor and filters it by text
session.list returned at most 200 stored conversations and had no way to ask for more, so a
picker could not reach older conversations or search beyond the rows it loaded. The stored
scope now takes `query` (title or id text, the storage rule behind `hermes sessions list
--search`) and `cursor`, and returns `next_cursor` until the listing is exhausted. The cursor
holds the storage offset after the last examined row and is bound to `workspace`, `query` and
`include_hidden`; runtime.describe advertises `session-list-cursor-v1`.
2026-11-14 01:21:49 +05:30
kshitijk4poor
d95b255d29 chore(contracts): regenerate with the locked pydantic
pydantic 2.14 (uv.lock, CI) applies the result model's extra="forbid" to the
nested ProfileCreateReceipt dataclass in the JSON schema; the previous
regeneration ran under 2.13 and left additionalProperties out.
2026-11-12 01:17:05 +05:30
kshitijk4poor
6e9f696ee6 refactor(profiles): one create receipt type; config outages and 4064 read as unknown
Round-3 review of the gateway create path found three defects and one
structural duplication.

- A config backend outage mid-create read as "nothing was created".
  ConfigBackendUnavailable is a SystemExit, so it escaped the handler's
  `except Exception` and the dispatcher answered 4064, which the client
  read as refused-before-create, even when the profile had already been
  published. The handler now catches it (and builds the receipt inside
  the same try) and answers 5062. The client no longer treats a bare
  4064 as "nothing was created"; only 4061 (no name) is.
- Every `hermes profile create` loaded gateway.platforms (~225 modules,
  about +105 ms median) even with no gateway URL, because the
  safe_proxy_url_for_log import sat above _where's early return. It now
  loads only when a URL is set; a test pins that a URL-less create loads
  neither gateway.platforms nor pydantic.
- A newer gateway that added a key under `mirrored` turned a successful
  create into "may have created": the strict check forbade extra keys
  there. `mirrored` is now a mapping of known value types, so new keys
  are kept and never printed.

The receipt had two definitions: the CreateReceipt dataclass and the
contract's ProfileCreateReceipt pydantic model, kept in step by a
field-name test and a hand-written check that skills_seeded["copied"] was
a list. There is now one: the stdlib dataclass ProfileCreateReceipt in
hermes_cli.profile_provision, which the contract uses directly as
ProfilesCreateResult.receipt (pydantic validates dataclasses), so the
generated TS/OpenRPC still describe it. from_wire validates it strictly
with a TypeAdapter (pydantic only on the gateway path). The receipt
carries what the CLI prints, skills_synced (a count) and
skills_opted_out, instead of the raw sync-result dict, which removes the
`copied` check; RECEIPT_FIELDS and the parity test are gone.

Also:
- The refusal chunk limits are imported from gateway_client
  (ERROR_DATA_TEXT / ERROR_DATA_ITEMS, now named there) instead of
  copied, so lowering the client cap can't silently drop every part.
- A typed refusal with no text is still a refusal ("nothing was
  created"), not "may have created".
- POST /api/profiles uses CREATE_REFUSALS.
- The wrapper check reuses profiles.profile_matches_home.
- The developer guide states the wrapper rule the code enforces.
2026-11-12 01:17:05 +05:30
kshitijk4poor
f12c33d0f8 refactor(profiles): one typed create receipt; gateway creates report what they can't confirm
The gateway route for `hermes profile create` returned a hand-built dict that
three places listed by key (receipt(), receipt_defaults(), the contract), and
dropped which route made the profile, so the CLI re-read
HERMES_TUI_GATEWAY_URL to decide the alias. Several outcomes were also
reported wrongly.

- CreateReceipt (profile_provision) is the one receipt: CreateReceipt.of()
  after a local create, to_wire() on the gateway, from_wire() on the client.
  A test keeps its fields equal to the contract's ProfileCreateReceipt, and
  every contract field is now required.
- create_through_gateway returns a CreateReceipt and writes the
  ~/.local/bin wrapper itself after a create on this machine: a discovered
  local owner or a loopback HERMES_TUI_GATEWAY_URL (the dashboard's chat
  terminals). Before, a loopback URL never got a wrapper. write_alias
  returns (path, collision) instead of filling a result object, and a
  wrapper failure after a gateway create is a warning, not a traceback.
- profiles.create no longer cuts refusal text at 200 characters for every
  client (Desktop showed "...create bad-"): error.message carries the whole
  redacted text, and error.data repeats it in short parts gateway_client
  keeps. The client redacts refusal text and receipt warnings again before
  printing.
- Outcomes the CLI can't confirm say "may have created ...; check hermes
  profile list" instead of "could not create" or a traceback: an untyped
  handler error, any exception after the request went out, a non-dict
  answer, and a receipt with missing or malformed fields.
- HERMES_TUI_GATEWAY_URL must be ws:// or wss:// with a host (what
  connect_gateway accepts); IPv6 hosts are bracketed in messages.
- One lock per profile name around the core create, not one for every name:
  the core create includes the multiplexer rescan (up to 8 s), so creates of
  different names waited on each other and held gateway pool workers.
- A gateway create reports why skill seeding failed: seed_profile_skills
  collects its failure lines (problems=), and a quiet create's receipt
  carries them as warnings.
- GatewayRPCError.unknown_method replaces four copies of
  `code == -32601 or str(exc) == "unknown_method"`.
2026-11-12 01:17:05 +05:30
kshitijk4poor
332ac8000e feat(profiles): hermes profile create goes through the running gateway
The CLI was the last create surface that made profiles in its own process.
It now asks the gateway that serves its profile, over the same
profiles.create RPC Desktop uses, and prints the receipt the gateway reads
where it made the profile:

- a ready gateway for the terminal's profile (discovery only; one is never
  started for this) takes the create; with none, or a local one that
  predates these fields (-32601 / 4000), the CLI creates in-process as
  before;
- HERMES_TUI_GATEWAY_URL names a gateway: the profile is made there, and
  an unreachable or older gateway is an error, never a local create. The
  URL's token is never printed;
- a refused create keeps its type (error.data.type), so the CLI prints the
  same "already exists" / "does not exist" errors;
- a socket lost after the request was sent is reported as unknown, with a
  pointer to `hermes profile list`, never retried.

profiles.create gains optional clone_config (`--clone` with no source:
copy the caller's profile), sync_imports and report. On /api/ws it already
runs in the connection's profile (dispatch_legacy binds the ticket's), so
`hermes -p work profile create x` against the multiplexer copies work's
keys, model and (with --clone) SOUL.md.

provision_profile now holds a per-name lock around the core create. The
gateway takes every terminal's create in one process, and create_profile
stages in profiles/.<name>.staging-<pid>, so two same-name creates there
shared and removed each other's staging dir; the loser failed with a raw
OSError (Errno 66 / ENOENT) instead of "already exists". The staging path
came from b47fb2eba3 (teknium1, 2026-09-13).

Review folds: a retiring gateway (5035) or an older one naming
unknown_method creates locally; a gateway that made the profile without
a receipt is reported, never re-created here; Ctrl-C after the request
says the create may still finish; the ~/.local/bin wrapper is written by
the CLI (this terminal's PATH and hermes), none for a URL gateway; the
gateway URL is named as scheme://host[:port] only (never its token,
userinfo or a hostless path), and recovery hints point at the gateway's
machine; refusals and 5062 carry the gateway's message, redacted (a parse error
can quote a config line); `--clone-from ""` is refused before any create. One
process lock around the core create (not seeding or the alias).
2026-11-12 01:17:05 +05:30
kshitijk4poor
4ed14253ea perf(bots): one groups.changed on every open socket is one room read
Follows #149210. A window holds several sockets to one backend (the primary,
the room's lease, others), and _broadcast_global_event writes the same
groups.changed frame to each, so every push queued one extra groups.state
read that found nothing new (live: 30 state reads for 15 pushes).

- The change watcher stamps each groups.changed with broadcast_id: the
  process's replay epoch (the token gateway.ready already carries) and a
  counter, unique for the process's life.
- The room view skips a push whose broadcast_id it already read for (the
  SDK's LruCache, last 64). A push without one (an older backend) reads as
  before.

Copies are told apart by identity, not timing: a later broadcast with the
same rooms, or another backend's, always reads.

Also, from the #149210 review: groups.state's change_events flag (it moves
the view to the 15 s backstop) is now pinned by a test, and the check that the
room service's status sets match the driver's shown rows moves from an
import-time assert to a test.
2026-11-11 16:53:19 +05:30
kshitijk4poor
cfe09695de perf(bots): the room view reads only the log delta and moves on groups.changed
Plan step 2 of the Bots architecture.

- groups.changed (change watcher) moves an open room on push; the poll is a
  15 s backstop on backends that push, 2 s on older and forwarded ones. Any
  failed read, a route reconnect, or a lease that failed retries at 2 s / at
  once.
- One room read at a time for every caller; a caller resolves after its own
  read. A mutation's settle supersedes the read in flight, so a pre-action
  answer never lands after it. A read's own reconnect (before its state
  answer) is not a re-read; one after it is. A state with nothing past the
  cursor reads no log page.
- The log is read from the cursor with a contiguity check; a new authority
  epoch or a shorter log reads it all again.
- The signature covers everything groups.state projects from memory:
  approvals, routes, stall and last error per service (under _state_lock),
  and member progress once per process, including main's live-attempt
  confirmation (task_is_active) and progress to 30 s.
- The store part (hosted_room_driver.room_change_rows) reads each live room's
  rows through the status index and skips disbanded rooms.
- status() reads the shown rows and the counts in one snapshot
  (room_task_summary); both room kinds list approval cards before Retry.
- The bot driver is woken by a room write instead of waiting for its 5 s
  idle poll.
2026-11-11 16:38:01 +05:30
kshitijk4poor
e52e117c0a test(profiles): profiles.create with clone_all alone gets no bundled skills
The RPC's one behaviour change in #152574 had no test that goes through
the RPC. The contract docstring (and its generated TS / OpenRPC copies)
and the handler docstring now say what clone_all alone does: a full copy
of the active profile.
2026-11-11 15:26:19 +05:30
kshitijk4poor
6f70d08669 fix(profiles): refuse --no-credentials with a clone; return create warnings
--no-credentials promises no keys from the launch profile, but --clone /
--clone-from / --clone-all copy the source's .env and config (and auth.json)
by request. The CLI now refuses the combination before creating anything.

POST /api/profiles and profiles.create return provision_profile's
warnings (e.g. a named launch profile's subscription logins not carried
over), so the dashboard and Desktop can show what the CLI prints.
2026-11-10 15:30:14 +05:30
kshitijk4poor
cbc254f1e6 fix(profiles): shared logins mean the root's; report what the profile actually reads
Review of the new create defaults found that share_auth works by not copying
auth.json, so the new profile reads the default root's (hermes_cli.auth
fallback). From a named launch profile that paired its API keys with the
root's logins and hid its own. A named launch profile's auth.json is now
copied (single-use OAuth grants stripped, as before).

mirrored["auth"] is now derived from the outcome: "shared" when the new
profile has no auth.json of its own. --clone-all no longer reports shared
logins it does not have, and --no-credentials says the root's logins stay
readable.

The CLI names the profile keys and model came from, uses cloned (so
--clone-from without --clone no longer says "no API keys yet"), and the
opt-out tests parse real argv. Docs list the new default and both flags.
2026-11-10 15:30:14 +05:30
kshitijk4poor
fe7e28b843 feat(profiles): every create surface uses the bot page's defaults
After #149075 every surface creates through provision_profile, but each still
passed its old options: only the Desktop/TUI RPC copied the launch profile's
keys, so a profile made with `hermes profile create` or from the dashboard had
no provider and failed its first chat until `<name> setup` ran.

ProfileCreateRequest now defaults to the Desktop bot page's "Share keys &
accounts with the main profile" (ticked): provider/tool keys copied into the
new .env (bot tokens and allowlists stripped), auth.json shared rather than
copied, model inherited unless one is picked. Clones keep their own .env.

Each surface has the same two opt-outs:
- isolated logins (auth.json copied once, single-use OAuth grants dropped):
  `--isolated-auth`, `share_auth: false` (REST and RPC);
- nothing from the launch profile: `--no-credentials`,
  `mirror_credentials: false`.

The CLI now says what it copied, and only warns "no API keys yet" when it
copied none. The RPC's share_auth default flips to true (the bot page already
sent it explicitly, so its behaviour is unchanged).
2026-11-10 15:30:14 +05:30
kshitijk4poor
110afdd60e chore(shared): keep the desktop-plugin-files export in sorted order
perfectionist/sort-exports: the module was renamed from plugin-catalog-name in the previous commit, so its export moves to its alphabetical place.
2026-11-08 16:47:03 +05:30
kshitijk4poor
7bed52779f refactor(desktop): one folder read per plugin, shared install-file names, no copied harnesses
Pre-arm review of #151193 (correctness reviewer plus reuse, quality and efficiency passes on the full
diff):

- The loader reads what a plugin folder is (package marker or install origin) with one helper and one
  listing, for a new folder and again on reload. The reload path used to list the folder twice and
  refresh only some fields: a reload that turned a folder into a linked package half never re-read
  `sourceFile`, so edits to that checkout weren't watched until restart.
- `PACKAGE_MARKER`, `INSTALL_ORIGIN` and the catalog-name pattern live together in
  `apps/shared/src/desktop-plugin-files.ts` (was `plugin-catalog-name.ts`); Electron re-exports the two
  file names. The Webapp router reads them from `desktop_plugin_halves`. `PackageOrigin` is one type in
  plugins-store, and the desktop half's install answer is one `DesktopHalfInstallResult` instead of a
  third hand-written copy.
- `standaloneCatalogName` is the one place that says a package's half answers for no catalog entry.
- `refusalReason` reads the reason through a shared `jsonRpcErrorReason` beside `JsonRpcGatewayError`.
- Electron records the HEAD `checkoutReviewedCommit` already verified instead of asking git again;
  `sameFile` is private again.
- The Webapp host checks the package marker without following a link, as Electron's lstat does: a
  dangling marker link no longer reads as a plain standalone folder that can be adopted.
- The new Python and loader tests import the sibling suites' Git fixtures and the blob-import reroute
  (`runtime-loader.test-helpers.ts`) instead of copying them.

New tests: a reload that finds a linked package half watches its source; a dangling marker link is not
adopted; a catalog install with no pin records the commit it cloned. Each fails with its fix reverted.
2026-11-08 16:47:03 +05:30
kshitijk4poor
2ff6a34400 fix(desktop): a desktop-only catalog plugin shows as installed and turns on
Accent Picker (reported on X on 2026-11-07) installs from its catalog card as a standalone
desktop plugin. The install worked, but three things went wrong after it:

- The card kept its "+". The Plugins page matches an installed plugin to its catalog card only
  by catalog_name, taken from the agent row or from the package marker. A desktop-only entry has
  neither: no agent half, and the installer leaves the package marker out on purpose so the
  folder stays standalone.
- The plugin loaded switched off. Its plugin.js sets defaultEnabled: false, but the dialog had
  said "turns on right away".
- Clicking "+" again stopped at "Desktop plugin 'accent-picker' already exists. Enable force
  reinstall to replace it." On a catalog pick the Force switch is never shown and Advanced
  starts collapsed, so the dialog gave the user no way forward.

Fix:

- The installer (Electron and the Webapp host) writes `.hermes-origin.json`
  ({catalogName, repo, sha}) into a standalone plugin it installs from a catalog entry. The sha
  is the commit checked out, so a tag pin is peeled. A copy of that file shipped inside the
  repository is always dropped, the same way the package marker is. The loader puts the entry
  on the record's packageOrigin, which the card already matches. It re-reads it on a forced
  reload, and the Webapp read route serves the file.
- If a catalog install finds a plain standalone folder whose plugin.js is byte-identical to the
  tree it would publish, it records the origin and keeps the folder as is, instead of answering
  "already exists". That repairs installs made before this change without replacing what the
  folder keeps. A different plugin under that name still needs Force.
- After a catalog install with "turn on" set, the plugin installed from that entry is turned on.
- An "already exists" refusal is marked as such (Electron `exists`; the gateway's error data
  `reason: "exists"`). Only that refusal opens Advanced and shows Force; a clone or network
  failure does not.
- A forced reload waits for a scan already running and then runs, instead of returning at
  once. The install's own folder rename starts a background scan, so the reload that follows
  could otherwise return before the new plugin was read, and nothing would be turned on.
- The deep-link and setup-card "installed" checks also read the catalog names recorded on disk,
  so a desktop-only entry reads as installed there too.
- installDesktopPluginFromGit takes its options as one object. The catalog name pattern moves to
  apps/shared so Electron validates the name it records with the same rule.

The card's catalog_name-only matching came in with the Capabilities redesign (#138820,
adcea47191, Brooklyn Nicholson, 2026-09-29). It surfaced for this plugin when accent-picker moved
from bundled into the catalog as a desktop-only entry (#136444, Teknium, 2026-10-10, d4d2ab7b5d).
The related repo-install case is #143522; this change does not close it.
2026-11-08 16:47:03 +05:30
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
alt-glitch
b52b8b00f0 docs(shared): keep the handleFrame doc on handleFrame
The settleResponse extraction left handleFrame's doc block on the private
helper. Move it back, mention the onUncorrelatedError route, and give
settleResponse a one-line doc.

Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-07 02:52:17 -05:00
alt-glitch
6d54f96ed2 fix(shared): an error frame with no request id is reported, not dropped
handleFrame matched an error frame only to a pending request by id, so the
backend's -32700 parse-error reply (id null) fell through every branch and
was dropped. The channel now hands it to an onUncorrelatedError sink; the
Desktop client logs it to the devtools console and the TUI client to its
protocol log, next to their existing unhandled-request sinks.

The pending-response branch moves into settleResponse so handleFrame stays
under the complexity limit.
2026-11-07 02:06:52 -05:00
Teknium
e82f0967ef feat(desktop): fill a saved login from the in-app Browser bar's key button
A key button in the Browser bar opens a picker of vault logins saved for the
page's exact origin, from every login source `vault.list` returns (Hermes
vault, unlocked Bitwarden / 1Password, any other registered source). Locked
managers get an Unlock row through the existing `vault.unlock` RPC; the empty
state links to Settings -> Credential Vault prefilled with the origin.

Picking a login calls the new `vault.preview.fill {handle, target}` RPC. The
renderer only mints an opaque binding for the clicked tab's live document; the
backend runs the same browser_vault fill (origin guard before any secret read,
re-asserted in the page; nonce-bound fields; redaction registration), also
writing the login's identifier, and sends each page script as a session-less
`preview.act` request on the calling socket. The result carries counts and the
origin only. Nothing is submitted.

New RPC contract + regenerated apps/shared files; VaultItem gains the
allowed_origins metadata manager items already emit. i18n in en + 8 overlays.
2026-11-06 22:59:41 -08:00
Jimmy_bob
5b55585157 fix(desktop): bind vault autofill to the selected preview page 2026-11-06 22:59:41 -08: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
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
2216779700 feat(delegate): a delegated child stays addressable by subagent_id; subagent.list rows name its session
Ports the store and roster half of #140477 (subagent.transcript) so the one
session.transcript read can address a delegated child:

- tools/delegate_tool_sessions.py: _build_child_agent stamps the child's
  model_config with `_subagent_id` beside `_delegate_from`, and
  stored_child_session() finds a finished child's newest segment only when its
  parent_session_id chain reaches the conversation through delegate-child or
  compression-continuation hops.
- subagent.list rows carry `child_session_id` on both transports (the canonical
  owner's subagent_row and tui_gateway's methods_subagents) and on the shared
  SubagentSnapshot contract (optional, null when unknown).
- The canonical roster also lists a running worker of an orchestrator it owns
  after the parent agent is rebuilt (_below_owned), and exposes
  locked_projection for a read that needs the roster under the event lock.
- hermes_state_transcript_cursor.py: transcript_lineage_ids (a queued child's
  reserved row never borrows a rotated delegator's segments) and
  transcript_cursor_state (a count check that tells an append from a
  compaction, rewind, deletion or rewrite).
- The transcript_revision trigger also fires on display_kind,
  display_metadata and codex item rewrites (a reaction, checkpoint pruning).

Adapted from #140477: its conversation_tail keyset read and the
_fetch_conversation_rows after_id keyword are not ported; the stored-read
pager pages instead. The subagent.transcript RPC itself is not ported.
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
unsupportedpastels
cb71f7506e fix(gateway): a named session.create or resume matches its snapshot contract
session.create and session.resume return local_session_info as the
snapshot's info, and that info now carries client for a named session.
Only CanonicalSessionInfo declared the field, so the closed
CanonicalSnapshotInfo model refused it: a named create raised
ContractViolation under HERMES_TEST_ISOLATION and logged a wire-contract
error in production. Declare client on the snapshot info too and
regenerate the contracts with scripts/gen_gateway_contracts.py.

The new test drives create and resume through AuthorityConnection.dispatch
and validates each result against its declared model.

Suggested by @BearHuddleston in review (patch applied as written), after
the Greptile finding on canonical.py.
2026-11-06 20:48:57 -05: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
unsupportedpastels
f4c1473f22 fix(gateway): llm.oneshot runs any task key again, as the last release did
#142006 made llm.oneshot refuse a task that is not a built-in or
plugin-registered auxiliary slot. The released gateway ran such a task:
a key with its own auxiliary.<task> block in config.yaml used that
block, and any other key used the default auto route. Clients that
relied on that got an invalid_params error instead of text.

Both llm.oneshot routes (the shared gateway and the TUI gateway) pass
the task through again, agent.oneshot.client_task goes away with the
refusal, and the contract text no longer says unknown keys are refused.
llm.oneshot is now the released shape: no schema/redact/parsed (Sid's
commits) and the released task handling.
2026-11-06 20:38:46 -05:00
alt-glitch
9fc5a33631 refactor(gateway): llm.oneshot drops schema, redact and parsed again
#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.
2026-11-06 20:38:46 -05:00
unsupportedpastels
bcc04fce03 refactor(shared): take LaunchSource from the generated create contract
LaunchSource is now NonNullable<CanonicalCreateParams['source']> (a
type-only import), so a new session surface reaches the shared client
when the contracts are regenerated, not through a second hand edit. The
source and client option docstrings now say that a non-canonical
attachUrl listener gets session.create without them. A new test passes
a client both in the params and as the option, which pins that the
option replaces it and that neither reaches an owner that does not
take client.

Suggested by @BearHuddleston in review (three suggestions applied as
written).
2026-11-06 20:33:25 -05:00
unsupportedpastels
ce820f0e4b docs(shared): say which client names a gateway accepts
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.
2026-11-06 20:33:25 -05:00
unsupportedpastels
9b939d4761 feat(shared): the gateway client takes its session source and client name
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.
2026-11-06 20:33:25 -05:00
alt-glitch
5cf4774df8 fix(shared): canonicalRequest mints its request_id outside a secure context
gateway-canonical.ts says it is browser-safe, but session.create's request_id came from
crypto.randomUUID, which a plain-HTTP page (the Webapp opened from another machine) does not
have. Use the package's own randomUuid (session-http-mutations.ts), which falls back to
getRandomValues. Nothing that ships breaks today (only the Node client imports this module);
this keeps the docstring true. From BearHuddleston's #142183 review.

(cherry picked from commit 895e304f6b36b1a791c930992a5fed18d018cdd5)
2026-11-06 20:33:25 -05:00
unsupportedpastels
46234c975e fix(gateway): resolve-profile checks the root before it touches a home
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.
2026-11-06 20:23:34 -05:00