Commit Graph

392 Commits

Author SHA1 Message Date
alt-glitch
c5a3c0f876 fix(plugins): address review — dashboard scan override, feed and pin-aware update signal, subdir coverage
- Dashboard: the update route answered a scan block with a bare HTTP 400,
  so the browser page could not show the findings or send force. It now
  passes scan_blocked through (update route only; install is unchanged),
  and the page's update button runs the same consent-then-scan flow as
  Desktop through web/src/lib/plugin-update.ts. AgentPluginUpdateResponse
  moves to web/src/lib/api-plugins.ts (api.ts is over the size cap).
- Saved update checks now record the install they were checked against
  (source, revision, pin). A result is dropped once any of those changed,
  so a --ref pin or a reinstall from another source no longer shows an
  Update button that update refuses. An update_url feed's version target
  is offered too (the old match compared it to a commit and never hit);
  the row field is update_target, a commit or a version.
- Each finding in the Desktop dialog shows its description.
- Tests: a real subdirectory install exercises the re-clone path (caution
  needs force, dangerous refused even with it, refusals leave the tree and
  record alone); the dashboard route returns findings and applies with
  force; the saved signal drops on update, new source and pin.
- locales/_keys.desktop.json regenerated for the new Desktop strings.
2026-10-20 12:26:35 +05:30
alt-glitch
3ac037670a fix(plugins): Desktop and the dashboard update git-installed plugins through the CLI's path
Desktop's plugins.manage update refused every non-catalog install ("not a
catalog install — update it via the CLI") and kept its own third copy of
the re-pin logic. It now calls dashboard_update_user_plugin, the same
function the dashboard route uses, so catalog and git installs update the
same way on every surface.

A scan block comes back as ok=false + scan_blocked + scan_verdict +
scan_findings (the shape install already returns) with nothing changed;
the client retries a caution verdict with force. The dashboard route reads
force from its body next to accept_capabilities.

The Plugins tab can only offer Update when it knows an update exists. Git
installs had no such signal, so the row never showed a button. The gateway
already runs the update check every plugins.auto_update_check_hours, and
`hermes plugins check-updates` runs it on demand; both now save the results
next to the cadence marker. The plugin list reads that file (no network per
listing) and sets update_available + latest_sha on git rows. A saved result
is ignored once the install's revision moves past the one it compared.
2026-10-20 12:26:35 +05:30
yoniebans
ad7c5a1d88 fix(gateway,desktop): the live session poll names each session's source, so a messaging settle never lights unread before its row loads 2026-10-19 23:04:43 +02:00
yoniebans
4b12ad037e fix(desktop): a turn Desktop sends into a messaging session lights the unread dot
Messaging completions were all skipped for the unread dot, including a turn the
user sent from Desktop, which lit the dot before the shared gateway listed
messaging sessions in Desktop's live poll. Desktop now records the admission id
of each of its submits the owner accepted to run, and the turn's stamped
message.complete marks the session unread when its admission is one of those
and the conversation is not on screen. The busy-to-idle edge still never lights
a messaging session, so no settle path can attribute one turn's completion to
another.

Refs #134889 (RT-18)
2026-10-19 23:04:43 +02:00
Teknium
dfb4ecd911 fix: a stop typed as a busy correction ends the voice chat on the shared gateway
In Ink's interrupt and steer busy modes, text typed during a running turn
goes to session.redirect / session.steer, not prompt.submit. The typed
stop-phrase check only ran in prompt.submit, so a bare "stop" in a LOCAL
voice chat reached the running agent and voice chat stayed on.

The owner's correct() now makes the same _typed_voice_stop decision (attached
submitter, LOCAL session, voice on, bare stop phrase) after authorization and
before the generation fence, and answers {voice_stopped: true}. The canonical
CanonicalCorrectionResult becomes Ack | CanonicalVoiceStopped (generated TS
and OpenRPC regenerated); the dispatch test proves it through the real
contract parse.

Every client settles that reply instead of treating it as a refusal that
re-sends the text as a prompt (which would admit "stop" as a turn):
- Ink: settleControlReply renders the stop-phrase event and settles the
  item; the running turn's busy state is untouched.
- Desktop: redirectPrompt drops the optimistic bubble and reports accepted,
  so the composer does not re-queue it.
- ACP: /steer reports the stop-phrase notice and does not send a prompt.

Greptile review on #141508.

Refs #134889 (TUI-26)
2026-10-19 06:54:34 -07:00
Teknium
24b0b4d9a1 fix(voice): a typed stop phrase ends the voice chat on the shared gateway
Ink sends prompts to the canonical prompt.submit on the shared gateway, which
had no stop-phrase check. A bare stop phrase typed during a voice chat was
admitted as a turn and reached the agent. The spoken stop and push-to-talk
worked.

AuthorityConnection.submit now checks first, for a submitter attached to
the session whose gateway /voice mode is on. It reuses the sidecar's check
(methods_prompt._consume_typed_stop_phrase, split out of
_typed_stop_phrase_response) and _end_session_voice_chat, so the owner's
per-session mode goes off and that session's capture ends. Nothing is
admitted, and the reply is {voice_stopped: true}.

The canonical contract declares that shape: the prompt.submit result is now
AdmissionStatus | CanonicalVoiceStopped, and the shared artifacts are
regenerated. On a canonical reply, Ink settles the queue item, releases busy
and renders the existing voice.transcript stop_phrase event locally, so the
notice and mode flags are the ones the sidecar path already shows (existing
gatewayMsg.voice.stopPhrase string, no new text).

Refs #134889 (TUI-26)
2026-10-19 03:41:28 -07:00
Teknium
90b2022265 Merge pull request #141338 from NousResearch/fix/pkg12-acp-modes
fix(acp): restore Accept Edits / Don't Ask as a gateway-owned per-session edit policy
2026-10-19 01:34:21 -07:00
Teknium
fa2836d1ee Merge pull request #141331 from NousResearch/fix/pkg12-remote-replay
fix(gateway): replay waiting prompts after a legacy reconnect (salvage #140456)
2026-10-19 01:15:02 -07:00
Teknium
10a2956b15 test(shared): drop constructor parameter property from legacy replay fake socket
The web TypeScript project includes apps/shared/src and enables
erasableSyntaxOnly, so `constructor(public url: string)` failed its
build with TS1294. Use an explicit field and assignment.
2026-10-18 20:33:19 -07:00
Teknium
8930c3c632 feat(gateway): session.export returns the /save transcript for the client to write
/save on the shared gateway wrote the export on the gateway host
(session.save), and took no format or redact argument. That works for a
local Ink but not for a remote Desktop, where the gateway's disk is not
the user's.

New owner verb `session.export {session_id, profile?, format?, redact?}`
renders the stored transcript like the classic CLI's /save (format via
normalize_save_format: json (default) / md / markdown / html / snapshot;
the force-redaction pass when redact is true) and returns {format,
filename, content}. It writes nothing; the client decides where the file
goes. session.save stays for shipped clients.

session.export has no sidecar handler, so its contract is declared
owner-only (canonical_method) and the shared artifacts are regenerated.
The test runs through the real owner dispatch and contract parse and
checks that nothing is written on the gateway host.

Refs #134889 (T10, T11)
Refs #141321
2026-10-18 19:40:20 -07:00
Teknium
8729dd9e74 fix(acp): restore Accept Edits / Don't Ask as the session's owner-held edit policy
The gateway ACP projection advertised only Default and refused main's other modes with
acp_edit_policy_mutation_unavailable: the owner had no verb for an editor's edit policy.

The policy is now plain data on the session's frozen LocalSessionPolicy
(edit_approval_policy: ask / workspace_session / session, default ask), written by a
revision-fenced `session.mutate edit_policy` ({policy}), so it lives in the session's stored
receipt and survives an owner restart. Only an ACP session takes it. The owner's edit guard
(gateway/session_local_editor.py) applies it before the editor's consent with main's rule
(should_auto_approve_edit): Accept Edits lets workspace/temp edits run, Don't Ask any edit,
and sensitive paths (.env, .git, .ssh, keys) always ask. session.info reports it to every
attached surface; the ACP projection advertises all three modes, maps set_session_mode and
set_config_option(edit_approval_policy) onto the mutation, shows a new editor the session's
mode, and projects another surface's change as current_mode_update.

A receipt main minted has no field: it restores as ask, and policy_identity skips the field
at its default, so stored credential references still match. The commit keeps the cached
agent (the policy is read per edit, not by the agent).

Refs #134889 (ACP-7)
Refs #141321
2026-10-18 18:58:27 -07:00
Teknium
26d994b62b test(gateway): pin legacy replay_epoch refusal scope and restart detection
On top of the salvaged #140456: the production dispatch still refuses any
other unknown key on session.events.since, and a reconnect to a restarted
standalone serve (new `epoch` on the answer) still drops the stale cursor
without the client sending the process epoch.

Refs #134889 (DB-7)
Refs #140455
Refs #141321
2026-10-18 18:40:38 -07:00
David Dudok de Wit
6930e77a1b fix(gateway): replay missed events and prompts after a legacy reconnect
The shared client sent the process epoch on session.events.since when a
session had no epoch of its own. The legacy /api/ws contract refused that
key, so a reconnect replay never ran and a pending approval or clarify
request was lost. Send the epoch only when it belongs to that session, and
accept and ignore the key on the legacy contract so a client that still
sends it replays against an updated backend.

Refs #140455

(cherry picked from commit 2e6217148a1481a16703beec338f5bb0ea749315)
2026-10-18 18:40:38 -07:00
Teknium
5541fa6c29 Merge origin/main into fix/pkg10-creds-a
Resolves hermes_cli/gateway_agent.py's prompt.submit against main's stop-before-submit fence: keeps main's reattach and CallStopped guard, and a turn stopped before the submit gives back its /model --once pick, since nothing was sent.
2026-10-18 10:59:23 -07:00
Teknium
b0bb0d8749 fix(contracts): admit model_override.reasoning on prompt.submit
`/model first --once --reasoning high` failed its turn with `invalid_params`
(on main it ran at effort=high). The CLI has sent `model_override.reasoning`
since the one-turn reasoning fix, and the owner's turn code reads it
(`gateway/session_cli_turn.py`), but the canonical WS contract
`CanonicalModelOverride` declared only `model` and `provider`. `Params`
forbids extra keys, so the dispatcher's `canonical_param_problems` refused the
submit before admission and no request reached the provider. Unit tests
passed because they record the submit on a connection stub that sits below
contract validation.

Declare `reasoning: str | None` on the contract. Value checks stay with the
owner, which already refuses a level `parse_reasoning_effort` can't read, as
for every other canonical method. Regenerate the shared TS/OpenRPC artifacts.

The new test runs the recorded `prompt.submit` from a real
`/model ... --once --reasoning high` through the production
`canonical_param_problems` check, and pins every key the CLI puts in
`model_override` (`model`, `provider`, `reasoning`) to the contract.

Live-pass finding on #140969 (package 10)
Refs #134889 (CLI-36)
Refs #140719
2026-10-18 06:18:24 -07:00
Teknium
936ec14ee4 fix(tui): queue a Desktop prompt in the gateway owner's FIFO instead of refusing it
On a Bot Chat the gateway also owns, a legacy `hermes serve` backend refused the
user's own typed prompt with 4090 SESSION_NOT_OWNED whenever the gateway's
durable ledger held a running or queued turn (a message_agent delivery), and the
Desktop offered "Start new session".

#106742 is one owner and one FIFO, with clients that submit. prompt.submit now
hands such a prompt to the ready gateway serving the session's profile home
(tui_gateway/owner_forward.py): it attaches, admits the prompt into the owner's
durable FIFO with a fresh submission id and answers {status: queued,
forwarded: true}. The owner runs it after the current turn, exactly once;
nothing runs in the legacy backend. The owner's pending list (as
pending_submissions), message.start and message.complete for that admission are
relayed onto the Desktop's live session; a lost relay settles with an empty
completion and the client re-reads the stored transcript.

An `unknown` admission, or work with no running gateway, keeps the
SESSION_NOT_OWNED refusal (never forwarded past). A prompt the owner cannot take
(rewind, attachments, owner refusal) gets a named 4090 SESSION_OWNER_BUSY
refusal that says why and to send it again when the current turn ends.

Red on main: tests/tui_gateway/test_legacy_submit_forwards_to_owner.py (3 failed:
SESSION_NOT_OWNED / no forwarder). Real SessionDB, real started admission, real
SessionAuthority + AuthorityConnection as the owner; only discovery and the
socket dial are replaced.

Refs #134889 (RT-37)
Refs #140385
Refs #140719
2026-10-18 03:28:00 -07:00
yoniebans
756ed9c717 fix(gateway): serve the connection card with the legacy handlers' policy, errors and resume snapshot 2026-10-18 12:27:21 +02:00
unsupportedpastels
8196fbc124 fix(gateway): list a steer in transfer as steering so a returned prompt keeps its card
A transfer is terminal/steering in storage, so pending snapshots dropped
it. Desktop permanently retires an admission a newer snapshot no longer
lists. When a snapshot was published between the steer's commit and its
settlement (another submit, an attach) and the text then never reached the
turn, the owner put the same admission back to `queued`, Desktop rejected
that as older than `retired`, and the prompt still ran later with no card
to edit or delete.

The owner now lists every admission in transfer (from its claim's fence)
in session.info and attach snapshots: status `started` like its receipt,
no controls, and the new `steering: true`. Desktop hides that card but
never raises the admission's rank on a `steering` listing, so the owner's
later `queued` listing repaints it; an ordinary started row still only
moves forward. The contract gains the optional `steering` field and the
prompt.steer_queued doc now says that an interrupted transfer's completion
frame reports `cancelled`, as an interrupted turn's does. Contracts
regenerated.

Refs #134889 (RT-35)
Refs #140208
2026-10-17 14:25:35 -04:00
unsupportedpastels
98efa9dfad feat(gateway): steer and edit a canonical queued prompt from Desktop
Desktop's queue panel rendered only Delete for a server-owned (canonical)
queued row. The guard was deliberate: the gateway had no verb that could
steer or edit a queued admission, and composing prompt.cancel with
session.steer or with a resubmit is two writes. The drain can claim the row
between them, so the prompt either runs twice or is lost.

Add two owner verbs that consume the still-queued admission in the owner's
own write transaction:

- prompt.steer_queued {admission_id}: only while the running claim has
  adopted its agent (else steer_unavailable, before the row is touched: it
  stays queued and runs in FIFO order). The row goes queued -> terminal
  'steering' bound to that claim's (owner_epoch, generation), so the drain
  can never also claim it, and the text is then handed to the claim's agent
  while that execution still runs. The transfer settles in the claim's own
  terminal write: 'steered' when the claim completed with the text
  delivered, 'interrupted' when it ended any other way (never replayed),
  and queued again in its own FIFO place when the text never reached the
  agent (the turn ended first). An owner restart settles a transfer left
  open as 'interrupted'. Until settled the receipt reads 'started'. The
  fence is an in-memory transfer record changed under the session stream
  lock; the SQLite writes run outside that lock, so a held writer never
  stalls the owner loop (loop-side receipts, attaches and publication take
  it).
- prompt.replace_queued {admission_id, submission_id, text, ...}: cancel
  the queued row inside the admission write of its successor, which joins
  the back of the FIFO under a NEW admission identity. That write also
  binds the new identity to the row it retired; the exact-replay path
  checks the binding inside the same transaction, so a retry naming the
  same old admission answers the same replacement and any other old
  admission under that submission_id is admission_conflict. Ordinary
  prompt.submit payloads are unchanged.

Refusals: admission_started, session_idle, steer_unavailable,
admission_conflict, queue_full, unsupported_control, not_found.

Each pending row names the queued-row verbs its owner serves (controls:
steer/replace): text-only rows of sessions launched from an interactive
local surface (cli, tui, gui, acp), whose observers settle a steered or
cancelled row. Hosted-room, cron, kanban and a2a producers read a saved
result for any other outcome, so their rows are never offered either verb
and both verbs refuse them (unsupported_control). Desktop shows Steer and
Edit on a canonical row only when the row lists them, so an older gateway
keeps Delete only. Canonical rows never get Next: reordering would break
the owner's one FIFO. Local rows are unchanged.

Edit loads the row into the composer; Save calls prompt.replace_queued and
keeps the edit open until the owner answers. A refusal, or the owner
starting the row mid-edit, keeps the edited text in the composer as an
unsent draft (followed by the draft it interrupted) with a short notice.
The composer holds presentation state only; the owner's FIFO never pauses.

Both verbs are declared in tui_gateway/contracts (generated TS/OpenRPC
regenerated).

Refs #134889 (RT-35)
Refs #140208
2026-10-17 14:25:35 -04:00
unsupportedpastels
dffd733b15 fix(shared): key usageFromTick's compression count on context_source
usageFromTick decided whether a top-level tick carried a compression
count on context_length, so a session whose compressor has no known
window (context_length null) lost its count in Desktop and Ink. Its
Python twin, session_usage.tui_usage, keys on context_source, which
usage_stats sets exactly when a compressor exists (the embedded
_get_usage's "if comp"). Both readers now use the same rule.

Refs #134889 (RT-33)
Refs #140194
Refs #140208
2026-10-17 14:13:01 -04:00
unsupportedpastels
f09ade9340 fix(gateway): match the embedded ticker's usage view on session.usage; deprecate the flat counters
The salvaged commit (#140195) makes a local viewer's session.usage frame
carry tui_usage(stats) under `usage` next to the flat counters, so a
Desktop bundle that reads only `payload.usage` (anything before
usageFromTick) fills its context, cache-hit and t/s meters again.

That nested view must be what the embedded backend's ticker sends
(`{"usage": server._get_usage(agent)}`), field for field. It was not in
one case: _get_usage reports `compressions` whenever the agent has a
compressor, but tui_usage keyed it on `context_length`, which usage_stats
sets to None while the compressor does not know its window yet. Key it
on `context_source`, which usage_stats sets exactly when there is a
compressor. Same counters, no new state.

The top-level counters on session.usage are now documented as deprecated
in SessionUsagePayload and usage_frame (kept for hermes_cli.gateway_agent,
the Ink TUI and Desktop's usageFromTick); the generated contract files
are regenerated for the docstring.

Tests: the published nested view equals _get_usage(agent) for a steady,
an unsized-compressor and a fresh agent; Desktop's handleEvent paints the
meters from the dual frame, from its nested view alone (the pre-
usageFromTick reader) and from the deprecated counters alone.

Refs #134889 (RT-33)
Refs #140194
Refs #140208

Co-authored-by: herovivian <herovivian@gmail.com>
2026-10-17 14:13:01 -04:00
unsupportedpastels
be842aa2fd fix(gateway): a Bot Chat DM refused while another writer holds the chat is a definite no-send
A pre-upgrade Desktop backend (classic tui_gateway prompt path) can still
hold a 'desktop' lease on a legacy Bot Chat. The owner's first delivery
adopts that chat through resolve_local_target, whose liveness guard
correctly refuses runtime_coordination_required (one writer per
transcript). message_agent had already fsynced its live-delivery intent,
so it answered "ambiguous ... Do not resend" and kept the pinned intent
for a replay, though nothing was admitted.

The owner's bot_relay.deliver door marks that refusal admitted=false
(field session_writer) when the delivery id has no receipt. That marker
proves absence only while the request holds the mailbox lock: a same-id
attempt (the runner retrying the pinned intent) can admit right after.
So it is a hint, not the verdict. Before the tool says "NOT sent" it
calls the new bot_relay.settle verb with the same identity. Under the
same mailbox lock _admit holds, settle either writes the id's terminal
not-sent receipt (refuse_pin's refused/failed shape, reason
runtime_coordination_required, full identity) or answers with the
admission that won. deliver answers a refused id with that receipt
before anything else, so a not-sent answer and an admission of the same
id can't coexist. Only the tool calls settle: cron's same-id retry of a
refused record still admits once the writer closes.

The tool raises LiveTargetHeldError ("held by another session writer
... NOT sent; safe to resend after that session closes") only for that
settled receipt. A replayed intent that meets it gets the same answer.
_start_delivery and _run_delivery share _settled_no_send, which removes
the intent and the payload. If either file survives the unlink, the
answer is the unknown outcome instead. Any other refusal, an older owner
without the marker, or a failed settle call stays ambiguous. The
refusal itself and the one-writer rule are unchanged.

Refs #134889 (MSG-19)
Refs #140208
2026-10-17 14:11:42 -04:00
arcabotai
0c8d4b7363 fix(gateway): rollback.restore keeps hand-edits unless --all, like the other /rollback paths
The rollback.restore RPC (Ink TUI, desktop, gateway-attached classic CLI) called
CheckpointManager.restore() without safe=, so a whole-tree restore clobbered files the
user hand-edited after Hermes' last write, despite the help text's 'restores keep your
hand-edits; --all overrides'. The gateway text command and the in-process CLI already
pass safe=not restore_all.

Default whole-tree RPC restores to safe mode, add an optional 'all' param for the
override, forward the classic CLI's --all/--force as all=True instead of dropping it, and
print the kept-edits / oversize / failed-delete lines the in-process CLI shows.

Fixes #139375

(cherry picked from commit e51948575c84d2376174245db869109f5b91cf9c)
2026-10-17 13:31:15 -04:00
Teknium
adf44edf03 fix(gateway): declare clarify.lock as a canonical verb so the dispatcher checks its params
The owner served clarify.lock but only METHODS (the sidecar) declared it,
so AuthorityConnection.dispatch never applied the contract and
session_clarify_lock.py checked keys and types by hand. It is now in
CANONICAL_METHODS with the sidecar's own ClarifyLockParams /
ClarifyLockResult (same wire), so an unknown key or a mistyped field gets
4001 invalid_params naming the field before the handler runs. The handler
keeps only the empty-id check. Generated TS and OpenRPC regenerated.

Test: test_clarify_lock_params_are_checked_by_the_declared_canonical_contract
(KeyError: 'clarify.lock' -> green).

Review finding by @alt-glitch on #140472
Refs #134889 (TUI-18)
Refs #140337
2026-10-17 08:03:50 -07:00
Teknium
9f744be4b6 fix(gateway,tui): skills installed from another terminal appear as Ink /commands
The one gateway serves every local session for its whole lifetime, but
get_skill_commands() memoised the slash map per (platform, home, project)
for the life of the process. A skill installed or removed from another
terminal (`hermes skills install`, a dropped SKILL.md) stayed missing from
Ink's palette and `/foo` answered unsupported_command until /reload-skills
or a gateway restart.

- agent/skill_commands.py: each published map records the skill roots'
  stat signature (the catalog's own _skills_scan_signature: root + child
  dir mtimes, disabled set, platform). A lookup whose signature moved
  rescans; an unchanged one reuses the map.
- tui_gateway/change_watcher.py: new `skills.changed` watch (2 s, same
  signature) broadcast to attached clients; contract regenerated.
- ui-tui: on `skills.changed` the TUI refetches `commands.catalog` from the
  gateway for the live session. The client never reads the skills dir.

Red first (both red on origin/main):
tests/agent/test_skill_commands_freshness.py::test_skill_added_on_disk_after_the_first_scan_is_served_without_reload
ui-tui createGatewayEventHandler.test.ts "skills.changed refetches the slash catalog ..."
plus tests/tui_gateway/test_change_watcher.py::test_skill_installed_from_another_terminal_broadcasts_skills_changed

Refs #134889 (CFG-8)
Refs #140337
2026-10-17 08:03:49 -07:00
KoNit-K
d41b8aafdc fix: support session mutations on insecure origins
(cherry picked from commit e9b0c9cc5f727be592b1fab5af1b14327ca329b2)
2026-10-16 19:20:53 -07:00
unsupportedpastels
6928c538f9 docs(plugins): describe pre_command's per-delivery thread and Ink's command.observe
The hooks.md pre_command row still said callbacks run "on the gateway's
own observer workers"; that shared pool is gone and each delivery waits
on a thread of its own (session_commands._on_own_thread). The row, the
hung-callback test docstring, the observe_command docstring and the
command.observe contract doc (regenerated) now say so, and name the TUI
alongside the classic CLI as a command.observe caller.

Refs #134889 (PLG-7)
Refs #139523
2026-10-16 19:39:48 -04:00
unsupportedpastels
4b6a8edd6a fix(plugins): fire pre_command in the gateway for every local command
After the cutover no local surface fired pre_command where the command runs.
slash.exec and command.dispatch (classic CLI forwards, Ink TUI, Desktop) never
fired it, and the classic CLI fired it from its own second copy of the plugin.

- The gateway fires pre_command for every recognized command a local session
  runs, under the session's profile: before the handler for commands it runs
  itself (slash.exec, command.dispatch; an accepted TUI read fires once inside
  the read path), and for commands the classic CLI runs in its own process
  through the new command.observe (plain data: the command as typed and its
  arguments). command.observe replies first, so the CLI never waits on a
  plugin. The hook arguments keep main's values: surface and platform "cli"
  on every local surface, session_key the session id.
- It fires only for commands that run. A busy rejection or a named refusal
  fires nothing; during a turn it fires when the busy dispatcher accepts the
  command, so a refused /goal, /loop or empty /queue or /steer fires nothing
  either. Every command that does run mid-turn fires, as main's CLI did,
  except messaging's escape hatches (/stop and the approval controls).
- Each delivery waits out its callback on its own thread, never the shared
  executor, with at most one delivery in flight per session: one session's
  deliveries fire in order and a slow callback never holds up another
  session's. The hook dispatcher's existing bounds apply
  (plugins.hook_callback_timeout and its abandoned-worker cap), and with
  plugins.isolation: host the hook runs in the plugin host. pre_command takes
  that bounded path everywhere, so off the gateway its callbacks also run on a
  worker thread.
- On a gateway session the classic CLI loads no plugin code. It reads skills,
  plugin commands and plugin toolsets from the gateway (commands.catalog,
  scoped to the session's own folder, and plugins.list) for /help, skill
  dispatch and completion, /tools and the status and banner fallbacks. -s and
  skills.auto_load are rendered in the gateway, and /reload-skills and
  /skills install rescan there and drop the CLI's cached catalog. These reads
  are cached per gateway life and never served once the connection has hung
  up. The "Unknown toolsets" warning comes from the gateway (a new
  unknown_toolsets field when the session opens). An older gateway without
  command.observe gets one named notice, and nothing fires locally.
- The canonical gateway connection serves plugins.list for its profile:
  loaded plugins with tool/hook/command counts, load error, toolsets and
  portable MCP server names (optional fields added to the contract; TS and
  OpenRPC regenerated). On a gateway session the CLI's /plugins reads it
  instead of this process's plugin manager. Off the gateway the in-process
  paths are unchanged.

Key-less inject_message (B2-11), which the classic CLI's own plugin copy
used to serve, is handled in the next commit.

Refs #134889 (PLG-7)
Refs #139523
2026-10-16 19:39:48 -04:00
unsupportedpastels
41c58ee5d9 fix(gateway): a new MCP server reaches a session as a committed policy generation
A local session's toolsets and MCP server definitions are frozen in its launch
policy, so after `/reload-mcp` (or Desktop's MCP add) connected a server added to
config, the session's frozen selection filtered the new server out: the reload
answered "added: fixt" and the chat never got the tool, open or resumed. Main
merged newly enabled servers into the session's toolsets on reload.

- The MCP server set changes only through CFG-2's gateway-committed,
  generation-fenced refresh (idle checked inside the write transaction): the
  session's own selection (explicit pick or platform allowlist, `no_mcp`,
  disabled entries respected) of its profile's current servers, their names in
  the toolsets and their definitions in the session config, private values split
  into the session's config-secret scope as at creation. A managed worker binds
  that config, so it connects exactly the servers it names. Bypass and editor-MCP
  sessions keep their frozen set; config is read from the session's own profile.
- `reload.mcp` (CLI, Desktop) commits it for the calling session when idle
  (`session: applied | unchanged`); while a turn runs or waits it changes nothing
  and says so (`session: busy`): the tools apply once the turn finishes and reload
  runs again, or when the chat is reattached. Other sessions take the new servers
  when a client next attaches. A queued or running turn never gains a capability.
- `reload.mcp` names configured servers that did not connect: the
  `mcp_servers_unavailable` refusal when nothing took effect (no server
  registered or removed, no session generation committed; a server reconcile
  only attempted does not count), otherwise success with `unavailable`.
  `ReloadMcpResult` gains `session` and `unavailable` (TS and OpenRPC contracts
  regenerated). Desktop's save, connect and reconnect paths read both: a busy
  chat gets a notice that the change applies after its turn and another reload
  or on reattach, unavailable servers are named, and connect/reconnect claim
  success (and reconnect clears its failure marker) only when the chat runs the
  server. Messaging `/reload-mcp` appends a "did not connect: ..." line.
  `mcp_servers_not_connected()` ignores the connect cooldown, which hid a
  just-failed server.

The failed-server naming rebuilds the idea of #136778 (bfea327b) in the
gateway handler; that PR's backend targets the legacy tui_gateway sidecar
path.

Refs #134889 (CFG-3)
Refs #139523

Co-authored-by: fyzanshaik <fyzan.shaik@gmail.com>
2026-10-16 19:17:14 -04:00
Mark S.
be9427acc9 Merge pull request #139575 from unsupportedpastels/fix/gateway-p5-plugin-loading
fix(plugins): classic CLI plugin commands run in the gateway, and disable reaches the running gateway
2026-10-16 19:12:02 -04:00
unsupportedpastels
07e603e092 fix(gateway): declare config_warning on session.create's snapshot info
The session-start notice (project plugins the gateway does not load, or
the client-not-local notice) was declared on session.info's result only.
local_session_info also feeds the snapshot session.create returns, so
every session that got a notice logged a wire-contract violation
("info.config_warning Extra inputs are not permitted") and raised
ContractViolation under strict mode.

CanonicalSnapshotInfo now declares the optional field; the TypeScript
and OpenRPC contracts are regenerated. A new test sends session.create
through the strict contract registry for both notices.

Refs #134889 (LC-4)
Refs #139523
2026-10-16 17:49:54 -04:00
unsupportedpastels
027e62ed17 fix(plugins): say plainly that the gateway does not load project plugins
On main each `hermes` process scanned ./.hermes/plugins in its own cwd
when HERMES_ENABLE_PROJECT_PLUGINS was set. Every session now runs in the
one gateway, which discovers plugins once from its own directory, so a
project's plugins silently never load.

The plugins guide now says so in a Project-local plugins section. When a
CLI or TUI session starts with a forwarded HERMES_ENABLE_PROJECT_PLUGINS
in a folder whose ./.hermes/plugins has entries, the gateway logs a line
to gateway.log and session.info carries it as config_warning: the TUI
already renders that at session start, and the classic CLI now prints it.
A folder that can't be listed skips the notice; it never fails
session.create or session.info. Nothing is loaded; loading project
plugins in a plugin host is left for later.

Host-specific client values also need proof that the client is on this
host. A connection is native_owner only when it redeemed a ticket minted
over the gateway's private control socket, from loopback with no Origin
header; session.create passes that as client_local, and a client can't
send it (an unknown field). Without it only HERMES_EPHEMERAL_SYSTEM_PROMPT
and HERMES_INFERENCE_PROVIDER from client_env apply: the session keeps the
gateway's toolchain, prefill file and project-plugins check
(client_env_remote on its policy, left out of the policy identity when
false), and its config_warning says the client's environment was not
applied because the client is not attached to this gateway locally.

Refs #134889 (LC-4)
Refs #134889 (LC-8)
Refs #134889 (T3)
Refs #139523
2026-10-16 17:49:54 -04:00
unsupportedpastels
aa86cf6815 fix(gateway): apply a client's HERMES_* behaviour values to its own session only
On main each `hermes` process read HERMES_EPHEMERAL_SYSTEM_PROMPT,
HERMES_PREFILL_MESSAGES_FILE and HERMES_INFERENCE_PROVIDER from its own
shell. Since the one gateway runs every session, the values exported by
whichever client auto-started it became daemon-wide (messaging and cron
included), and every later client's exports were ignored.

The classic CLI and the Ink TUI now send an allowlisted `client_env` map
(plain strings) with session.create; the classic CLI takes the
allowlist's extra names from the profile's effective config (managed
layer included), as the gateway reads them, and a safe-mode or
ignore-user-config launch reads no profile. The gateway filters the map
again against the session profile's allowlist, freezes it with the
session's policy (outside launch_request, so viewers never see the
values) and binds it for that session's turns only: the ephemeral
prompt, the prefill file and the provider request read the session's
value, in-process and for a managed worker. Desktop sends nothing and
keeps the gateway's environment, as does a session created before this
change.

The auto-started daemon no longer inherits these variables (nor
HERMES_ENABLE_PROJECT_PLUGINS); a gateway the operator starts keeps its
own environment. Clients send the field only when runtime.describe lists
it.

An exact retry of a session created before this change returns its
original session; the retry and commit comparisons and the policy identity
treat an absent client_env as before. A retry is judged against the
committed, filtered map: every stored name must come back with its stored
value, and names dropped at creation don't count, whatever the allowlist
is now. Fresh creates use the current rules, and the unfiltered map is
never stored.

Refs #134889 (LC-8)
Refs #139523
2026-10-16 17:49:54 -04:00
Teknium
620f3b3b45 feat(plugin-catalog): add a Nous-granted verified tier
Verified entries come from the company that makes what the plugin integrates,
confirmed by the Nous team. Only maintainers set official/verified (CODEOWNERS
review; no CI check inspects the value). Tier order everywhere: official,
verified, community. Desktop's installed-plugin pill now reads the same
catalogInstall.tier map as the install card, dropping the duplicate
skills.plugins.tierOfficial/tierCommunity keys.
2026-10-16 14:31:11 -07:00
Teknium
d5a62eda48 fix(sessions): the low-disk prompt states what pruning will really do
Independent review fixes:

- Retention and VACUUM settings are read the way maintenance reads them
  (effective config: ${VAR} expansion, managed overlay, int() coercion)
  through the asked profile's own config path. A quoted or env "0" was
  described as 90 days while enabling pruned everything ended.
- An administrator-managed sessions.auto_prune is already decided: no
  prompt, /autoprune on|off|later is refused naming the administrator, and
  decide() confirms the effective value rather than a file write.
- TUI/Desktop notices carry a short status text plus the full question in
  a new optional `detail` (contract regenerated): Desktop shows it in the
  toast's expandable body, Ink prints it into the transcript.
- The per-process notice dedup re-arms after the snooze window, so "later"
  asks again in a week; an answered /autoprune clears the sticky notice on
  both the gateway session path and the legacy TUI path.
2026-10-16 13:56:20 -07:00
yoniebans
cf71b1aa30 refactor(shared): one session.usage tick mapper for Ink and Desktop
Desktop's canonicalUsage re-implemented Ink's usageFromTick and had already drifted: it dropped avg_latency_s and active_subagents. The mapper now lives in @hermes/shared (usage-tick), Ink re-exports it from domain/usage and Desktop calls it directly, so both clients project gateway/session_usage.py::usage_stats the same way. Desktop's zero-tick fallback is preserved by the shared first-non-zero counter rule.
2026-10-16 22:10:26 +02:00
unsupportedpastels
b16cd8f66f fix(cli): run classic CLI plugin slash commands in the gateway
The classic CLI ran a plugin's /command through its own in-process copy of
the plugin, while the plugin's hooks, tools and MCP servers live in the
gateway. ctx.call_mcp from the command therefore failed with "MCP server
'x' is not connected".

On a gateway session the CLI now sends the command to the gateway with
slash.exec, which already runs plugin commands through the messaging
gateway's own plugin dispatch, and prints the reply. The CLI reads plugin
command names (for dispatch and tab completion) from the gateway's
commands.catalog instead of importing plugin code: once per session and
gateway life (/new, resume and a redial read again), and once more when a
typed name misses, so a plugin the gateway enabled since still dispatches.
A read is cached only under the gateway epoch that served it (call_tagged)
and the session captured before the call; a reply that arrives after a
concurrent redial or session change is not cached as current.

When the catalog cannot be read, or the gateway answers but reports that its
plugin discovery failed (the new commands.catalog field
plugin_discovery_error; older gateways without it keep today's behaviour),
the CLI prints the gateway's error and runs nothing for that input (no
skill, bundle or prefix expansion stands in); completion degrades quietly.
Off the gateway (tests, the TUI slash worker's shadow CLI) the in-process
path is unchanged.

A daemon test runs the command through the real slash.exec handler and
checks that the handler and ctx.call_mcp run in the gateway process. PLG-7
is only partly fixed: the CLI process still loads plugin code for /plugins
and the pre_command hook. Nothing fires twice: the gateway's slash.exec path
does not fire pre_command, and the CLI suppresses on_session_finalize/reset
for gateway sessions.

Refs #134889 (CLI-13)
Refs #134889 (PLG-7)
Refs #139523
2026-10-16 12:47:19 +00:00
unsupportedpastels
fe0588bedc fix(gateway): declare a refused Bot delivery's receipt in the deliver contract
A same-id resend of a delivery the FIFO refused (nothing committed) answers
its terminal refused receipt, which has no admission. CanonicalBotDeliverResult
required admission_id, so through AuthorityConnection.dispatch the answer was a
ContractViolation under test isolation, and in production Desktop's
settleRelayDelivery() treated it as "identity unavailable" and kept the
envelope retained: the refusal never reached the sender.

The contract now declares the refused shape explicitly: admission_id is
optional and `refused: true` marks the receipt, with a validator that a result
either names its admission or is a refused `failed` receipt without one. The
resend carries `refused`; the generated TS/OpenRPC are regenerated with
scripts/gen_gateway_contracts.py. The relay settles a refused failed receipt
for its envelope as the sender's terminal answer (posted back, no longer
retained); an answer with neither an admission nor a refusal is still retained.

The first refusal is unchanged: a JSON-RPC 4001 refusal whose data.reason the
relay already forwards.

Refs #134889 (MSG-9)
Refs #139162
Refs #139138
2026-10-15 23:59:47 -04:00
unsupportedpastels
64f516c914 fix(cli): /diff session reads the session's checkpoint policy and renders in full
/diff session on a rewired classic CLI went through slash.exec to the
messaging /diff handler. That handler builds its CheckpointManager from the
profile config. A `hermes --checkpoints` launch enables checkpoints only in
the session's frozen policy, so with the default `checkpoints.enabled: false`
it answered "not enabled" even after the session's tools had saved
checkpoints. Its output was also chat text, cut to 60 lines / 3000 chars and
fenced, where the terminal renderer shows 400 lines.

The owner now serves rollback.session_diff next to rollback.list/diff/restore.
It resolves the manager from the session's frozen checkpoint policy, as
rollback already does, applies the same container-backend refusal, and
returns main's session_diff result as data. The body is bounded to stay
inside one frame, and diff_lines carries the full line count. The CLI hands
that result to main's terminal renderer: the session-diff tail of
_print_session_diff moves into print_session_diff, shared by the local and
gateway paths, and _print_diff_body takes the sender's uncut line count for
its "N more lines" note. The method is declared in CANONICAL_METHODS and the
generated TS/OpenRPC contracts are regenerated.

Refs NousResearch#134889
2026-10-14 20:47:20 -04:00
Teknium
0715474bfd Merge origin/main into feat/unified-gateway-runtime
375 commits from main (0e427d788d). 24 files conflicted; the resolutions that carry a decision:

- /initiate-setup: main removed the command (25bf722063). Its gateway rewrite, CLI handler and the
  Desktop kickoff go with main; this branch's command-layer admission of it is dropped too
  (gateway/session_commands.py _PROMPT_COMMANDS, its slash.exec test row, the parity doc row), and
  the Desktop slash dispatcher loses the `hidden` option that only the kickoff used.
- Code this branch moved out of its old file, carrying main's edits to the moved copy:
  first-contact notes (gateway/run_turn.py -> run_turn_prepare.py: no message/setup_command),
  the TUI agent factory (tui_gateway/server.py -> agent_factory.py: onboarding toolsets at build,
  setup_beat/set_theme lifecycle cards, no cli platform extras on a coding selection), the serve
  lifespan (web_server.py -> web_server_app.py standalone_lifespan: first-install probe before the
  state.db reconcile, onboarding due answer after the setup bootstrap), and the compression child
  publish (the shared _publish_compression_child_on_conn reads the parent's model_config).
- agent/auxiliary_client.py: both import changes (_route_key from main; this branch's move of
  _without_structured_output_format).
- Desktop: main's onboarding run (decideOnboarding, OnboardingEnd, card-waiting Send) replaces the
  kickoff; this branch's prepared-submission slash path, request_id on session.create and
  PreparedImageRecovery stay. Pool-limits imports are dropped (this branch removed the pool).
  createBackendSessionForSend takes main's (preview, overrides) signature.
- ci.yaml detect job: main's `ref: inputs.commit` plus this branch's sparse checkout.
- package.json / lock: main's vitest 4.1.11 plus this branch's ws 8.21.1.
- Generated: gateway-contract.openrpc.json regenerated; parity doc regenerated.
2026-10-14 05:52:49 -07:00
alt-glitch
afc4651c62 fix(onboarding): a blocked trial claim opens no chat that nothing can run 2026-10-14 00:48:50 +05:30
alt-glitch
b1aa179085 fix(onboarding): claim the trial after the run record, so a crash keeps onboarding due
onboarding.start claimed the welcome trial (mint the guest, mark the
machine) before start() wrote the run record and `onboarding.run: true`.
A crash in between left a guest and the marker, both of which make the
next launch's machine check read "used", with `onboarding.run` still
unset: auto-onboarding never opened again.

The run record and `onboarding.run: true` are now written first, then the
claim, so the marker only lands once the run is on disk and a crash at any
later point reopens onboarding. A refused claim (5079) still leaves no
guest and no chat: the just-created run is discarded.
2026-10-14 00:32:21 +05:30
alt-glitch
4920f87b3f feat(free-tier): the free model is a desktop first-install trial, claimed once per machine
HERMES_GUEST_ONBOARDING was a process-wide launch gate: with it set, every CLI,
gateway and serve boot minted an anonymous Nous account and any guest (a
connector guest included) carried inference. It is gone from Python.

- hermes_cli/welcome_trial.py: claim_desktop_free_tier() mints a guest, stamps
  welcome_claim on it and marks the machine. A table of blockers decides
  eligibility: the desktop's local backend only (never SSH, URL, cloud, CLI or
  gateway), nous.guest on, no Nous identity, no provider, and a machine that
  never used Hermes (install_state; the unpackaged desktop may pass
  assume_fresh). grandfather_existing_guest() keeps the trial for a guest that
  already chatted on nous/welcome; connector-only guests never qualify.
- anon_auth.free_inference_active() replaces guest_enabled(): a stamped guest on
  the local desktop backend. The resolver rung, the active-provider check, the
  picker row, the sign-in offer and guest_without_free_tier (inference, status,
  account, pool readers) all read it. ensure_portal_identity is connectors-only
  plus the claim; every token exchange names its purpose.
- No boot mint: free_tier_bootstrap only records who carries inference (and runs
  the grandfather check); the CLI and gateway boot hooks are deleted, and so is
  the inference re-mint after a dead credential (a lost claim is never
  re-claimed).
- onboarding.start claims for a new run before the chat exists; a failed claim
  is error 5079 and writes nothing, so the next launch tries again. A rerun
  never claims. onboarding.state answers eligible only on the local desktop
  backend when the trial or a configured provider can carry the first chat.
- Sign-in from any guest takes the promotion path (connected apps carry over).
- Deleted CLI/gateway free-tier copy: the startup line, both /status lines, the
  one-time CLI notice, the banner's route model and their locale keys.
  `hermes model` points a guest at `hermes auth upgrade`.
2026-10-14 00:32:21 +05:30
alt-glitch
3a867a9e65 refactor: delete the initiate-setup turn core, keep the scripted prelude
Salvage of 058b5c8158 from the static-onboarding stack, adapted: the
initiate-setup prompt, its facts builder and the first-task prompt go with
the setup_choose server request and callback, the initiate-setup branch of
the prelude wiring in prompt_turn and the intro auto-continue skip. Unlike
058b5c8158 the scripted prelude seam (agent/turn_scripted_prelude.py and
the prelude parameter on run_conversation) and gui_tour's preset stay: the
default-profile onboarding opening plays through them, and prompt_turn now
asks only _onboarding_prelude for one.

(cherry picked from commit 058b5c8158, adapted)
2026-10-14 00:29:11 +05:30
alt-glitch
bf9bea298a refactor: delete the onboarding and start_chat RPCs and the tool-row retry store
tui_gateway loses the five setup-profile onboarding.* handlers
(ensure_setup_profile, ensure_setup_session, record_failed_start,
mark_seen, reset_setup_profile) and their lock and helpers from
methods_onboarding.py, which keeps the new onboarding.state, set_run,
start and skip. session.start_chat goes with its handoff body
(methods_start_chat.py, start_chat.py), and the long-handler entries go
with them. hermes_state_tool_retries.py and its SessionDB mixin go with
their only caller; no schema change, and old rows that carry
display_metadata.retried stay inert. The per-turn retry note in
prompt_turn goes with them.

The old contract sections are removed and the shared contract is
regenerated.

(cherry picked from commit 1acd64a69c86f5547f0dcea62a689e67a48d0218, adapted)
2026-10-14 00:29:11 +05:30
alt-glitch
25bf722063 refactor: remove the /initiate-setup slash command
The command, its alias and every surface handler go together: the registry
entry, the Slack /hermes-only pin, the CLI handler, the gateway rewrite and
its canonical-command entry, the TUI builtin (_cmd_initiate_setup goes with
its only reference in _SLASH_BUILTINS) and the slash.exec pending-input pin.
The skill-invocation projection drops its /initiate-setup header in Python
(agent/skill_commands.py's module-top import of agent.initiate_setup_prompt
goes now, before 4.3 deletes that module) and in apps/shared.

run_inbound's handler lookup is back to f"_hm_cmd_{canonical}": no hyphenated
canonical command remains. The three locale keys go from all 17 packs, and
the desktop slash registry is regenerated.

(cherry picked from commit 3510c2c2428e18f226ee7628d34b35148a79c9b1)
2026-10-14 00:29:11 +05:30
alt-glitch
0e90cc7985 feat(onboarding): a new launch starts an unfinished onboarding over
Owner ruling 6: closing the app before onboarding finishes does not count.
The desktop's once-per-launch decideOnboarding now sends
onboarding.start {fresh_launch: true}. With the flag the backend starts a new
run at the name beat, then closes any chat of the unfinished run still live
on this backend and deletes it through onboarding_record.delete_chat (the
session.delete path), which ends the run as 'deleted' and tells every window.
The new run is open first, so the install flag never closes in between, and
the new chat takes the title the deleted one had. A delete the store refuses
ends the run as 'replaced' instead, so it is never resumed.

A start without the flag (a second start in the same launch) still reopens
the run; a reconnect only re-reads it through onboarding.state. Settings'
rerun keeps its own path (old chats stay, ended as 'replaced').

(cherry picked from commit 306884bcaafc44071c884f96e6c144f49987dbdf)
2026-10-14 00:06:58 +05:30
alt-glitch
4a23324a39 feat(onboarding): a message sent past a setup card ends its turn and runs as the next one
A setup_beat card answered with wrote_instead records Wrote (no text in the
result), and the inline executor interrupts the turn with the new-message
reason: setup_beat runs inline, so its result is kept and the loop stops
before another model call. The words reach the model as a real user turn,
whose turn note now says how a typed answer applies the closed card. The
name card keeps taking typed words as the name.

(cherry picked from commit 400e7b208bafb0b41ae24cc089a95595abfefafe)
2026-10-14 00:06:58 +05:30
alt-glitch
80bb9a0b14 feat(onboarding): the backend tells every window when a run ends (onboarding.ended)
Sid's ruling Q4 (event), on top of the explicit ends: a run that stops being in progress sends
onboarding.ended {run_id, stored_session_id, outcome} to every connected window. It is emitted from
one place, the active-to-ended edge in onboarding_record._transition, so done (first-task card
answered), skipped, replaced (a rerun from any window) and deleted all reach the window showing
the run, including one subscribed to another chat. A repeat end is not a second event. The event
goes out before the install-flag write, which can fail; the record already says the run ended.

Each run gets a run_id at start; onboarding.start and onboarding.state return it, so the desktop
matches the event by run and not by a runtime id that changes on every resume.
2026-10-13 23:55:49 +05:30
alt-glitch
8af55c1f75 fix(onboarding): a closed apps or plugins card reports what is connected or installed
Typing "done", a value given in words, a skip or the 5-minute deadline on the apps or plugins
card used to report nothing connected or installed, even after the user connected an app or
installed a plugin from the card. setup_beat now reads the machine's connected apps and installed
onboarding plugins for those closes and records them in the result and the run's picks.

The setup_beat request also carries its tool_call_id, so the desktop draws the card only on the
transcript row that owns it, and a build-pick refusal no longer names the beat (no card was shown,
so the transcript draws nothing for it).
2026-10-13 23:55:49 +05:30