Commit Graph

358 Commits

Author SHA1 Message Date
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
alt-glitch
3568acf580 fix(onboarding): the first-task answer completes the run, and every end is explicit
Sid's rulings Q4a and Q6 on the run lifecycle:
- Answering the build (first-task) card completes the run; its result carries completed.
  setup_beat(done) is the close step and returns completed on a completed run; a skip on an
  ended run returns skipped_all. The quiet-spell expire is deleted: it ended runs under a user
  still answering the closing question.
- One End(outcome) event replaces SkipAll: skipped (Skip setup), replaced (a rerun closes the
  old run; it was recorded as a skip) and deleted (session.delete ends the onboarding chat's
  run first, so the install flag closes instead of a fresh run opening next launch).
- A general tool that settles the beat a card waited on clears waiting, so the turn note no
  longer asks to bring back a settled card.
- onboarding.intro_seen and the state field are deleted (Q1): the intro ends on the layout
  card's Continue, and a resumed run reopens without the demo.
2026-10-13 23:55:49 +05:30
alt-glitch
c798b37aa1 feat(onboarding): leaving the intro is kept on the run, so a relaunch skips the demo
onboarding.intro_seen marks the run in progress, and onboarding.state
returns intro_seen. It lives on the run record, so a rerun plays the intro
again. The old onboarding.mark_seen wrote the setup profile's state, which
onboarding.state never read.
2026-10-13 23:55:12 +05:30
alt-glitch
2f0d97f22a feat(connectors): words typed in the composer answer the connector directory card
The directory card's review dropped the typed answer. It comes back on
top of the composer registry: the card registers with
registerParkedCardAnswer, the answer carries said on the wire
(ConnectionAnswer.said), and the display action settles like Continue and
returns said next to what is connected. The receipt reads Answered in chat.
The tool description is unchanged, so the prompt cost stays as reviewed.
2026-10-13 23:55:11 +05:30
alt-glitch
72e7085e9e feat: set_theme replaces apply_layout and reports what the desktop applied
set_theme (desktop_ui, deferred like apply_layout was) sets the accent,
light/dark mode and layout preset, or with `picker` shows an accent or
layout card and waits up to 300 s. apply_layout emitted a layout.apply
event and returned success whether or not the renderer applied anything;
set_theme asks the renderer through the theme.apply server request and
returns its answer, so an unknown preset or a chat that is not on screen
comes back as an error with the available ids.

theme.pick waits for a person; the backend tells a dismissed card
({cancelled}) from an expired one ({timed_out}). The tool description
lists the Simple and Advanced preset ids from one constant, which fixes
the old description that named neither sidebar preset. The layout.apply
event and its renderer handler are deleted with the tool.
2026-10-13 23:55:10 +05:30
alt-glitch
88f8e115f9 fix(onboarding): option clicks keep their label; a layout in words goes through set_theme
Greptile on #137429:
- the desktop card sends the option's label with a tour, build or plugins
  answer for the transcript, and the strict answer check refused it, so a
  click brought the same card back. The answer models take an optional
  label; the flow ignores it and records only the ids.
- for a layout typed in words the reminder told the model to record it
  with setup_beat(value=...), which never applies it, then reported it as
  on. Theme and layout are applied by set_theme, whose result settles the
  beat; setup_beat refuses a value for either and names set_theme.
2026-10-13 22:08:21 +05:30
alt-glitch
7801375572 fix(onboarding): typed setup_beat cards and answers; no note after the last card
Greptile on #137429:
- setup_beat cards and answers were open JSON objects, so a renderer that
  sent a misspelled key or an id outside the card settled the beat with
  nothing recorded. The contract now has one model per card and per
  answer, and the flow refuses an answer whose keys are not the beat's
  picks or whose id is not one of the card's options; the beat stays
  open and the model is told to bring the card back.
- once the build card was answered every later user turn got a note to
  reopen the build picker, because the waiting beat fell back to "build".
  The note is empty when no card is left.
2026-10-13 22:08:21 +05:30
alt-glitch
177a764aca docs(onboarding): document onboarding.run; salvaged reads say first-run onboarding
onboarding.run gets its entry in user-guide/configuration.md (null on a
fresh install, true while onboarding is open, false once finished or
skipped; always the default profile's config).

The questionnaire the host summary, machine.facts and onboarding.run were
written for was dropped; their docstrings and contract docs now name the
first-run onboarding that reads them.
2026-10-13 22:08:21 +05:30
alt-glitch
1589fec62c feat(onboarding): onboarding.start / onboarding.skip and the gateway wiring
onboarding.start opens the onboarding chat in the default profile: it
creates the session row and writes the run record first, then resumes
the session, so the agent build always sees an active run and folds the
onboarding toolset in (no race with the build timer). A new chat gets
the opening prompt as a hidden user turn; its prelude plays the scripted
greeting and the name card with no model call. A run already in progress
is reopened instead of minted twice; rerun starts a fresh one. Result:
{session_id (runtime), stored_session_id, resumed}.

onboarding.skip ends the session's run (every open beat skipped, the
install flag written) and withdraws only the waiting setup_beat card;
server_requests.cancel gains a method filter for that.

onboarding.state and onboarding.set_run answer session_id: the stored
id of the onboarding chat in progress, so a relaunch reopens it.

Gateway seams, all decided per session:
- _make_agent adds "onboarding" to the toolsets only when the session's
  record says a run is in progress; a tool refresh keeps it, so the tool
  array never changes mid-chat.
- setup_beat's card is the "setup_beat" server request, 300 s.
- before a user turn, while no card waits, a note names the closed card
  and how to bring it back (API-only, like the first-contact note).
- setup_beat joins the lifecycle-rendered card tools.
2026-10-13 22:08:20 +05:30
alt-glitch
9fb5e24c9f refactor(platform): machine.facts names the NVIDIA platform from nvidia_platform()
The salvaged host summary kept its own Spark detector: win32 + arm64 +
an NVIDIA GPU, or a dgx|spark|gb10 regex on the CPU name. That is one
of the readers the previous commit's products.nvidia_platform() replaces,
and the two disagree (the regex calls any CPU string with "spark" in it a
DGX Spark).

summary() now asks nvidia_platform() once and answers it as
nvidia_platform (rtx_spark | dgx_spark | discrete | null) instead of the
is_spark bool. machine_kind is "Spark" for the two Spark platforms.
machine.facts has no client yet, so the contract field is renamed, not
kept beside the new one.
2026-10-13 22:08:20 +05:30
alt-glitch
3399df06b5 feat(plugins): presence by catalog name; plugins.manage action presence
The questionnaire names the plugin apps it may offer by catalog name and
shows one only when its desktop app is installed. presence_for(names)
answers those names from the live catalog in the order asked: names the
catalog no longer carries and entries for another OS are dropped, each
row carries the app state and sentence from the pinned plugin.json, and
the catalog description's Disclosure sentence. Manifests are read in
parallel, so the answer waits one 5 s read timeout, not one per name; an
unreadable manifest is unknown.

plugins.manage {action: "presence", names} serves it; the contract and
the shared TypeScript are regenerated. The onboarding action stays until
the catalog drops its onboarding flag.

(cherry picked from commit 1c6d51a9e8fc46566a207f676bb6e32121e5823c)
2026-10-13 22:08:20 +05:30
alt-glitch
c5b80f3f23 feat(onboarding): onboarding.state answers {run, eligible}; onboarding.set_run
onboarding.state now answers whether the desktop questionnaire is due:
run = hermes_cli.onboarding_run.should_run(), eligible =
anon_auth.guest_enabled(). onboarding.set_run {run, mark_profile_offered?}
writes onboarding.run; with mark_profile_offered it also latches
onboarding.seen.profile_build_offered, so the first chat after Start gets
the plain intro instead of the profile offer. Skip sends false and leaves
that flag alone. Both read and write the root profile's config.yaml and
are deliberately not profile-scoped.

The old renderer gate (components/onboarding-chat/gate.tsx and
store/onboarding-gate.ts beginOnboardingFlow) reads intro/profile from
onboarding.state; with the new shape intro is undefined, so it never
starts the agentic guide. The questionnaire renderer replaces both.
record_failed_start and mark_seen keep the old result shape until the
agentic backend is deleted.

guest_enabled is again the only reader of HERMES_GUEST_ONBOARDING and
nous.guest: setup_profile.onboarding_eligible now delegates to it, and
the invariant comments in anon_auth.py are restored.

(cherry picked from commit 47e44f73ab044186b32405c5df30d06a1b3954ff)
2026-10-13 22:08:15 +05:30
alt-glitch
b6abf6f503 feat(tui-gateway): machine.facts RPC
The desktop questionnaire branches on the machine (Spark, Windows with
an NVIDIA GPU, Mac) and pre-fills the user's name. machine.facts returns
hermes_platform.host.summary() through a declared contract; the shared
TypeScript contract is regenerated.

The method takes no profile: hardware and the OS account belong to the
host, so every profile a pooled backend serves gets the same answer.

(cherry picked from commit 80f75a7eb34e1fd9292ee65a6e82d5548e6523d8)
2026-10-13 22:08:15 +05:30
Teknium
2cd0ec8686 Merge origin/main into feat/unified-gateway-runtime
215 commits from main (c70332f888). One textual conflict: the generated
apps/shared/src/gateway-contract.generated.ts, regenerated with scripts/gen_gateway_contracts.py
rather than hand-merged. Brings main's fix for the dated shared-metrics install-receipt test
(783637e370).
2026-10-13 05:15:48 -07:00
Brooklyn Nicholson
d8e94b5694 fix(desktop): catalog deep links ask the backend for the entry
hermes://plugin/install?catalog=<name> fetched /docs/api/plugins.json from
the renderer. The docs host answers that URL with a cross-origin 301 that
carries no Access-Control-Allow-Origin, so the browser rejects the redirect
and every link reported the catalog as unreachable.

The backend already reads the live catalog (cache, failure window, in-tree
fallback, kill list) and resolves catalog installs from it. A new
plugins.catalog.lookup {name} gateway method returns the entry from there,
and lookupPluginCatalogEntry calls it. A backend that predates the method
falls back to the old direct fetch, so nothing regresses on skew.

Fixes hermes-agent 136483
2026-10-13 05:10:29 -07:00
Teknium
ada38db216 fix(gateway,tui,desktop): the setting writes Ink and Desktop still refused run on the owner
config.set on the owner now serves the keys the clients refused before the wire, each through the
code its slash command runs:

- `reasoning` (show/hide/reset/levels, `scope=global` = `/reasoning --global`): the /reasoning
  handler's _apply_reasoning_selection for this session.
- `yolo` with `scope=global` (Desktop's Shift+click zap): approvals.mode off / manual, as main.
- `approvals.mode` / `approval_mode`: /approvals' run_approval_mode_command for the profile.
- `display.message_reactions|in_app_tips|in_app_tours` and `voice.voice_chat_mode`: config.yaml
  leaves with main's validation (tui_gateway/server.py::_DISPLAY_TOGGLE_KEYS).

Ink drops its /reasoning (--global, display words) and `/voice tts` refusals: the first goes through
config.set reasoning, the second through slash.exec to the /voice handler (gateway state; recording
and playback stay in the terminal). Desktop's CANONICAL_CONFIG_KEYS opens those keys and the
`reasoning`/`yolo` scope. Contracts regenerated (CanonicalConfigSetParams.scope).

(cherry picked from commit 8f5fe27957d7636b5209692a2d57509381e0527e)
2026-10-13 02:43:13 -07:00
Teknium
ee8bd1160f fix(gateway,cli): only a turn the classic CLI submitted gets the batch clarify request
Wave B (4d73ffa0de) sent the clarify tool's whole batch as one `clarify` server request whenever
the turn was a local-viewer turn on a `cli`-source session (classic_cli_turn). That predicate names
the session's surface, not the viewer: an ACP editor and raw WebSocket viewers also drive
`source='cli'` sessions and answer per-question `clarify.request` cards (prompts in
session.resume). They got a server request they never answer and no card, so the turn sat out the
clarify timeout: test_gateway_editor_clarify (3), test_local_session[clarify] and
test_journey_restart_open_prompts [crash, graceful] ("no open clarify prompt").

- prompt.submit gains an optional `clarify_batch: bool`, committed with the admission in
  `cli_turn_v1` (validated like the other per-turn CLI fields; contract TS/OpenRPC regenerated).
- GatewayAgent sets it when main's HermesCLI registered its clarify callback (the batch panel).
- The runner takes the batch path only for that admission (session_cli_turn.clarify_batch_turn);
  every other turn keeps main's one card per question. The classic CLI keeps main's batch panel.

Red first: test_local_viewer_clarify_batch.py::
test_a_cli_source_turn_the_classic_cli_did_not_submit_keeps_one_card_per_question.
2026-10-13 00:56:48 -07:00
Teknium
831dcba863 feat(gateway): serve TUI display prefs, /theme and /indicator config.set on the owner
The shared owner's config.set refused every key but busy/verbose/yolo, so a
canonical TUI dropped /statusbar /mouse /density /details /focus /battery
("not saved on the shared gateway") and refused /theme and /indicator.

gateway/session_tui_config.py now serves those keys with main's per-key
semantics, writing the owning profile's config.yaml (raw round-trip, off
the loop, under its runtime scope). Profile-level like config.get: a
session is optional; /focus with one also pins that session's tool-progress
mode. Session controls still dispatch to busy_config; model stays refused;
other keys are invalid_params. The canonical config.set contract opens its
key set and makes session_id optional.

The TUI drops the refusals and prefNotSaved notice and saves through
config.set on both backends, as on main.

(cherry picked from commit 0b392863d30f542b70b7f5a139eb064e4f61cce5)
(cherry picked from commit c4babc97d5c672c731dad5fba86cdd3c92218756)
2026-10-13 00:31:47 -07:00
Teknium
f25a5dfe29 feat(gateway,tui): /reload re-reads the profile .env on the shared gateway
Ink's /reload refused on the canonical gateway: reload.env was a sidecar verb
kept off the shared owner because main's handler rewrites os.environ, which
on a multiplexed owner is every served profile's.

The owner now serves reload.env (gateway/session_tui_ops.py) for one session
the caller controls (session_id required, capability session:control,
profile-checked):

- single-profile owner: main's hermes_cli.config.reload_env() verbatim. The
  owner's os.environ is what its turns read, exactly as the TUI's own sidecar
  process was; built agents keep their credential pool until /new (main).
- multiplexed owner: os.environ is left alone (turns read profile secrets
  from their per-profile scope, which re-reads .env every turn). The verb
  drops the .env memo and re-pulls the profile's external secret-source
  snapshot; `updated` counts keys whose value in that profile's scope
  changed.

A sessionless frame stays refused (4001), so a bare grant still cannot
rewrite the shared environment (test_session_process_scope updated from
-32601 to 4001; environ untouched). ReloadEnvParams gains the optional
session_id/profile the TUI now sends; generated TS/OpenRPC regenerated.

TUI: the canonical refusal is removed; /reload sends {session_id} on the
shared gateway and prints main's "reloaded .env (N vars updated)".

Tests: tests/gateway/test_session_tui_ops.py::test_reload_env_* (real owner
daemon; red on base with unknown_method), ui-tui canonicalTuiOps.test.ts
(red before the TUI change); stale refusal assertions updated.

(cherry picked from commit 574737ccd1ee9adf55d4d24ae2b14a879f29f68d)
(cherry picked from commit 27cf4b4171f41df0535b9fcd64be174fe76052ca)
2026-10-13 00:31:41 -07:00
Teknium
ac93134d03 fix(tui): closing a canonical view stamps the row as main's session.close did
Main's TUI closed its session on /new or a resume switch (`tui_close`) and on
exit (`tui_shutdown`); on the canonical owner the view only detached, so every
row stayed `ended_at NULL` after /quit and the picker kept closed sessions as
"live ✓ idle" with `model?` (FINDINGS rows 28, 35, 38).

- `session.detach` takes an optional `end_reason`; the owner stamps it once no
  viewer remains and the FIFO is idle (same txn as the ACP end stamp).
- The TUI sends it where main called `session.close`, and on /quit / Ctrl+D
  for every held view (bounded at 1.5 s).
- The live feed drops closed, idle, unviewed sessions; the stored feed lists
  them as resumable. Both carry the row's model.

(cherry picked from commit 39d7118f3a9dbe0102f85c8c75bad0f779fabd50)
(cherry picked from commit 3a7abbf8bcc3f151f51937bc89b8c3d95e79b401)
2026-10-13 00:31:12 -07:00
Teknium
0c51167630 fix(tui): boot the profile's skin on the canonical gateway
Main's TUI themed itself from gateway.ready.skin (resolve_skin()). On the
session authority the client publishes its own ready after runtime.describe
with an empty payload, so `hermes -p work --tui` with display.skin: ares booted
the default gold theme (FINDINGS row 3).

runtime.describe now returns `skin`: resolve_skin()'s dict for the owning
profile (gateway/session_skin.py, read inside the dispatcher's owner_scope).
GatewayClient keeps it and puts it on the client-local gateway.ready unless the
listener's own ready already carried one. Contract: RuntimeDescribeResult.skin
(SkinPayload | None); generated TS/OpenRPC regenerated.

(cherry picked from commit ccb5a3bf3fafa8df0cfecdfd278ae90f76fa8408)
(cherry picked from commit 5680dbd1967b3978d7cea1ddd61ca874cb3a9101)
2026-10-13 00:30:44 -07:00
Teknium
607f67bfae fix(tui): resumed canonical sessions render main's display projection
`session.resume` on the canonical owner returned raw stored rows, so the Ink TUI
replayed the compaction handoff verbatim, showed /steer rows as the
OUT-OF-BAND marker, and lost tool-row argument labels (FINDINGS rows 12b, 31,
32). A renderer now asks for `display_projection` and gets `display_messages`
from the sidecar's own `_history_to_messages` over the same rows; the raw rows
stay as `stored_messages` for the rewind controls. Desktop is unchanged (it
never asks).

(cherry picked from commit 7d5660139f4016525285b0e3aeb927b13823eea6)
(cherry picked from commit d91976d38ad1ff79e6d5da6c673006e3bcce0253)
2026-10-13 00:30:35 -07:00
Teknium
83960b47df feat(gateway): session.automation runs the classic CLI's /goal, /loop, /heartbeat managers
Main's HermesCLI built GoalManager / LoopManager / HeartbeatManager in its own process: every
mutation wrote state_meta through a read-write SessionDB and the goal judge (auxiliary.goal_judge)
ran in the CLI pid. On the session authority the gateway is the single writer and runs every model
call, so the owner now serves one canonical verb, session.automation {kind, call, args, kwargs},
that runs an allowlisted manager call on the session's physical row, under the owning profile's
runtime scope and the session's own workspace (quality gates run in its cwd). It returns the
persisted state and the call's value, or main's manager exception (type + text).

A session whose CLI viewer drives its automation this way (while that viewer still holds its
subscription) is skipped by the gateway's own post-turn goal/loop hooks: the live harness showed
every goal turn judged twice and continued twice (CLI + gateway), painting the reply twice.

Red tests: tests/gateway/test_session_viewer_automation.py (owner row writes, judge on the owner,
loop/heartbeat ticks, refusals, the post-turn skip).
2026-10-13 00:11:42 -07:00
Teknium
e504e030e3 fix(gateway,cli): the session row's cwd is main's stamp, split from the execution cwd
Main stamps sessions.cwd only from the agent's own lazy create
(run_agent._launch_cwd_for_session: the process cwd, CLI-family label, local terminal
backend). /new and --create-if-missing rows stay empty, and -w records the repo root
because main never chdirs into the worktree (it sets TERMINAL_CWD). The gateway wrote
the policy cwd (the execution dir) on every row, so a piped bare `-c` (workspace-scoped
MRU) picked a newer /new or titled session that main skips as cwd-less.

Split row metadata from runtime cwd rather than changing execution:
- session.create takes an optional `row_cwd` (canonical contract + CREATE_FIELDS; absolute
  or "" = none). It is frozen in request_json; hermes_state_local._row_cwd writes it to
  the row at the creation commit, else the execution cwd as before (every other surface
  is unchanged). policy.cwd / TERMINAL_CWD are untouched: -w tools still run in the tree.
- GatewaySessionStore.create sends main's stamp: os.getcwd() for a CLI-family label on a
  local backend, "" for /new (CLIInitMixin._new_session_id) and --create-if-missing
  (create_titled_session, record_cwd=False) and for remote backends.
- TS/OpenRPC regenerated with gen_gateway_contracts.py.

Reset/compress/branch children keep copying policy['cwd'] (main's children inherit the
parent's row cwd via the compression/branch path; not exercised by the harness).

Red first: tests/gateway/test_session_row_cwd.py (row vs policy cwd, contract) and
test_gateway_session_store::test_row_cwd_is_mains_stamp... failed before the change.

(cherry picked from commit 532c257783f20ebe603a74b81e3551a7091feecf)
2026-10-12 22:50:09 -07:00
Teknium
492bd4a72b feat(gateway,cli): /fast reaches the gateway session as its service-tier override
Main's /fast rebuilds AIAgent(service_tier=tier). The GatewayAgent stand-in now
sends the tier as the session's override (config.set key=service_tier, sent only
when it changed; `normal` clears to an explicit normal; an unset tier never
overrides the session's own default). The gateway handler writes the runner's
per-session override that current_service_tier() reads for the next turn; it is
never a config.yaml write (--global stays the client's own config write).

Why the gateway refused it: the canonical config.set contract
(tui_gateway/contracts/canonical_projections.py) declares a closed key Literal,
so `service_tier` was rejected as invalid_params/fields=[key] before any handler
ran. Added to the Literal; TS/OpenRPC regenerated with gen_gateway_contracts.py.

Red first: the gateway test answered invalid_params; the CLI test now filters
on key == service_tier (the stand-in also sends show_reasoning at build).

(cherry picked from commit b9e5acc745ca4eb36835368c24d882c814a8e433)
2026-10-12 22:50:09 -07:00
Teknium
bf94644b99 fix(cli): the process dock, status-bar ⚙ count and /stop read the gateway session's processes
Background processes now run in the gateway, so the CLI process's own tools.process_registry
is empty: main's dock showed nothing, `⚙ N` never appeared and /stop printed "No running
background processes." while a job ran.

- hermes_cli/gateway_tools.py: GatewayProcessView answers the registry calls main's dock,
  status bar and /stop make (list_sessions / get / count_running / kill_process / kill_all)
  from process.list / process.kill / process.stop; polled at most once a second and only while
  a tool just finished or a listed process is live or recently exited; the status bar reads the
  cached count (no RPC on a repaint). Bound when the CLI builds its gateway-backed agent.
- process.list rows gain started_epoch / exited_at / completion_reason (dock elapsed, exit age,
  killed/lost verdict) and a 32k output tail (main's dock tail view).
- process.stop also interrupts the async delegations THIS session dispatched (main's /stop
  interrupted them), reported as `delegations`; the status bar's subagent count reads
  session.usage.active_subagents.
- Main's dock / status-bar / /stop code is unchanged apart from where the registry comes from.

LEDGER: W11 (IPS-078, IPS-079, IPS-081, IPS-084, IPS-085, SLASH-E1-020).
(cherry picked from commit 4d6b1dd25793b51fa1e70eb4c563a4f36862bf72)
2026-10-12 22:50:08 -07:00