Commit Graph

575 Commits

Author SHA1 Message Date
Teknium
e11ec55b0d fix(cli): a mid-turn plugin command's clarify and the turn's never swap
Live on e7a7e414 (classic `hermes chat`, /sidecheck ask typed while the turn's
terminal ran, then the turn called clarify): the turn's pump took the command's
SIDE_Q and the command's waiter took the turn's MAIN_Q, because both consumed
any `clarify` server request for the session from the one events queue. When
slash.exec returned, call_unbounded withdrew the panel its waiter held, which
was the turn's: MAIN_Q never showed and the tool returned outcome=cancelled.

Route by owner instead of first-come:
- slash.exec takes an opaque `ask_owner`; the gateway echoes it as `owner` on
  every clarify its ctx.ask_choice sends (viewer_choices / _ask_viewers).
- GatewayConnection routes a server request whose `owner` it registered to that
  owner's inbox at ingestion, so neither the turn pump nor an idle drain
  (queue_admitted_turn, _drain_stale) ever sees it; untagged requests and
  another viewer's go to the session queue as before.
- _answer_choices reads only its inbox, so the command-end withdraw only ever
  closes the command's own question.
- A gateway older than ask_owner refuses the key (invalid_params) before it
  runs anything: the command is re-sent without it, and its untagged ask is
  taken between turns, as before (such a gateway runs no command mid-turn).

Contracts: SlashExecParams.ask_owner, ClarifyRequestParams.owner (regenerated).
2026-11-29 14:14:47 -08:00
Teknium
f476899bbd fix(plugins): a plugin slash command can opt in to run mid-turn
A plugin's side-thread command (/btw --explore as a plugin) is only useful
while the main turn runs, but the classic CLI queued every plugin command in
_pending_input until the turn ended, and a messaging chat read it as a
follow-up (interrupt or queue). The TUI and Desktop already ran it at once.

register_command(busy_policy="dispatch") is the opt-in, mirroring the
CommandDef vocabulary; the default is unchanged.

- hermes_cli/plugins.py::plugin_command_runs_mid_turn is the one lookup.
- Messaging: the busy fast path (_hm_busy_slash_or_photo ->
  _hm_busy_plugin_command) dispatches it under the slash access gate, and
  should_bypass_active_session lets it through the base adapter's own busy
  guard.
- Classic CLI: commands.catalog carries plugin_busy_commands (the CLI's
  plugin commands run in the gateway), and a busy Enter dispatches the
  command on its own thread so the clarify panel stays answerable.
2026-11-29 14:14:47 -08:00
Teknium
7881386177 feat(loop): /loop --forever and --later; interval loops queue behind a running reply; /heartbeat retires into /loop
- `--forever` drops the 100-run cap (loops.max_ticks); `/loop status` says
  "no limit". `--later` holds the first run one interval. Without them
  `/loop 10m X` is unchanged: first run now, 100-run cap.
- An interval loop that comes due while a reply is running is admitted into
  the session authority's durable FIFO behind it, as heartbeat ticks were,
  instead of waiting for the chat to go idle. With no committed input to
  queue behind (a command-only chat) it waits for idle and then takes main's
  command-only fallback, sender re-check and Relay egress warm-up. Self-paced
  loops keep waiting for idle. The gateway loop watcher scans every 5 s (the
  heartbeat poller's cadence) so a due tick is not up to 15 s late.
- `/loop` takes /heartbeat's interval spellings (1.5h, 10min, 2hours, 1d,
  90sec) and `off`.
- /heartbeat and /hb retire to "`/loop … --later --forever`", /proactive to
  "`/loop`" (RETIRED_COMMANDS); their handlers and locale strings go.
- A heartbeat saved before the upgrade keeps its row and engine and fires
  uncapped as before; `/loop status` shows it as a no-limit loop and
  `/loop pause|resume|stop|off` act on it once the session has no loop.
- The classic CLI's gateway loop proxy forwards --forever/--later.
- Docs (features/loops.md, heartbeat.md -> /loop, slash-commands.md renamed
  table), locales, Desktop strings and generated registries updated.
2026-11-29 03:38:00 -08:00
Teknium
f2b19fd37c refactor(slash): retire the folded command names
The folds Teknium approved are on main (/verbose focus, /statusbar battery|indicator,
/status's egress block, /model --runtime, /pet hatch, /goal add, /help <page>,
/billing topup|upgrade, TUI /verbose details|density), but the old names still ran.
They are now retired with RETIRED_COMMANDS: typing /focus, /battery, /indicator,
/egress, /codex-runtime, /hatch, /generate-pet, /subgoal, /commands, /topup,
/subscription or /upgrade (either _ or - spelling) runs nothing on the CLI, gateway,
TUI and Desktop and answers "`/old` is now `/new`.". The TUI answers its own /details,
/detail and /density the same way (slash.retired), since they never existed elsewhere.

The old names leave help, menus, completion, the Telegram menu priority, the Slack
/hermes-only set, the Desktop registry and description keys, and the docs tables (the
Renamed commands table lists each). Handlers only the old names reached are removed;
the umbrella commands still call the shared handlers.

Slash access: the folded forms check their own user_allowed_commands keys (goal-add,
model-runtime, status-egress, help-pages) instead of the retired names, and an
operator list that still names subgoal, codex-runtime, egress, commands or topup
grants what replaced it, so no existing config loses or gains access.
2026-11-29 03:22:20 -08:00
Teknium
05dea0ff76 fix: one cache deadline per viewer, a fresh Desktop clock, and room for the widest countdown
Review fixes for the time-left / reopened-chat indicator:

- CLI: the pre-agent read used only the attach snapshot, so a cold frame
  published before the first message (another viewer's /model or
  compaction) never reached the bar. SessionState now keeps one
  cache_warm_until, seeded by snapshots and moved by every usage frame
  that speaks for it (usage_warm_until, shared with GatewayAgent); the
  bar, /usage and the agent's first value all read it.
- Desktop: the hook's clock stood still while the cache was unknown or
  cold, so a new window could show its time left against a stale now.
  A changed deadline now resets the clock during render.
- TUI: the countdown is not monotonic in width (1m -> <1m, 2h -> 1h 59m),
  so pauseSegments reserves promptCacheWidestTimeLeft instead of the
  current label. The property test now also pins that bound.
2026-11-29 02:26:27 -08:00
Teknium
4b77529480 feat: the cache indicator shows the time left and works on a reopened chat
The live/cold indicator said only "live", so you could not tell whether you
could step away, and a chat reopened after a restart (--resume, the Desktop
session list) showed nothing until its first message: exactly the moment
the indicator exists for.

- CLI and TUI bars show "● live 4m" (whole minutes, "<1m" in the last
  one); Desktop shows "Cache live · 4m". The CLI arms one repaint per
  minute change, Desktop one timer per change, the TUI already ticks.
  One formatter rule on both sides (prompt_cache_time_left /
  promptCacheTimeLeft).
- A session no gateway agent holds yet answers from its saved clock:
  session.resume's snapshot usage and session.stats carry
  cache_warm_until (stored_prompt_cache_warm_until, validated against
  the stored context generation and the saved route, so a /model or
  compaction since reads cold). The CLI reads it from the attach
  snapshot before its first turn builds an agent, in the bar and /usage.
2026-11-29 02:26:27 -08:00
Teknium
83a92bb6ed fix(credits): one ownership rule for shared credits notices
Every credits notice has owners = (backend connection/profile, session). A
show adds its owner; a clear names what ended: scope 'session' (this
session no longer needs it) or 'account' (the account recovered, for every
owner of that backend only). The toast is dismissed only once no owner
remains; an unscoped clear from an older gateway still dismisses outright.

- notice_clear_scopes re-runs the policy on the pre-evaluation latch as a
  paid top-tier session: a free model hiding credits.depleted is a session
  clear, a paid-access flip back is an account clear.
- A replacement show of the same key (usage band change) no longer emits a
  clear first, so it ends no other session's claim.
- deliver_notice_clear reads a callback's signature once and calls it
  exactly once (scope= only when it takes it), in the agent emit and the
  CLI's gateway relay.
- The shown-lines memory is keyed by (profile home, session id).

Follow-up to #161327
2026-11-28 23:01:18 -08:00
Teknium
6b55c16b3c fix(desktop): an off-route credits clear withdraws only its own session's claim on the shared toast
Desktop shows one credits toast per notice key for every chat. When one chat
left the Nous route, clear_off_route_notices' notification.clear dismissed that
shared toast even while another chat was still on Nous and still depleted.

The off-route clear now carries scope: 'session' (NotificationClearPayload);
Desktop tracks, per key, which (backend, session) raised the toast and
dismisses on a session-scoped clear only once no session still claims it.
Unscoped clears (credits restored) still dismiss for everyone.

Follow-up to #161327
2026-11-28 23:01:18 -08:00
Teknium
8b2d6a592f refactor(slash): /reload mcp and /reload skills replace /reload-mcp and /reload-skills
/reload gains two subcommands on every surface (CLI, messaging gateway, TUI,
Desktop catalog, Discord native tree and relay manifest): `/reload mcp [now|always]`
runs the old /reload-mcp handler (same Approve Once / Always Approve / Cancel
confirmation, same approvals.mcp_reload_confirm gate) and `/reload skills` runs
the old /reload-skills handler. Bare /reload still reloads .env in the terminal
and TUI; in a chat (where it never existed) it lists the two subcommands.

/reload-mcp and /reload-skills (and their _ spellings) are retired with
RETIRED_COMMANDS: typing one runs nothing and answers "`/reload-mcp` is now
`/reload mcp`.". Every user-facing hint, locale string, doc and skill that said
/reload-mcp or /reload-skills now says the new form.
2026-11-28 21:00:57 -08:00
Teknium
02f955822a test(gateway): the /resume listing speaks the configured language; regenerate slash-exec verdicts
A German profile gets the translated current marker and footers (the
listing strings live in the locale catalogs). The rebuilt-on-main branch also
regenerates apps/shared/src/slash-exec-verdicts.json without /sessions.
2026-11-28 20:48:40 -08:00
Teknium
3341f6e2ea fix(slash): exact registered spelling first everywhere; Desktop /backup offers what it runs
Why: (1) Desktop offered /backup snapshot, which its backend refuses: desktop_subcommands is
export/import, and bare /backup or snapshot answers the forms that run here. (2) Desktop resolved a
typed name against one global catalog, so one profile could submit another's spelling: it now uses
the submitting session's catalog. (3) The TUI matched _/- before the exact key, so /foo_bar ran
/foo-bar: both surfaces share apps/shared lookupSlashName (exact first).
2026-11-28 19:42:51 -08:00
Teknium
084a1c1f00 chore(slash): regenerate the slash registries and parity table for the stacked PRs
Regenerated, not hand-merged: the desktop slash registry, the shared slash.exec verdicts and the
gateway command-parity page now reflect all seven PRs together (retired names gone, /backup and
/billing present, /pause execable on slash.exec, #161260's desktop surface classes kept).
2026-11-28 19:42:51 -08:00
Teknium
998f1ef7f9 refactor(slash): retired-name mechanism; _ = - in names; /platforms absorbs /platform; /backup
RETIRED_COMMANDS (hermes_cli/commands.py) maps an old slash name to the
invocation that replaced it. On every surface a retired name runs nothing
and answers one localized line (commands.retired): CLI process_command,
gateway idle and busy paths (busy bypass, never queued as a turn), TUI and
Desktop (commands.catalog carries the rendered notices; they are answered
before alias/fuzzy matching, so /platform no longer prefix-expands), and
slash.exec / command.dispatch as the backstop. Skills and plugins cannot
claim a retired name.

resolve_command normalizes `_` to `-`, so the underscore twins
(reload_mcp, reload_skills, codex_runtime) are deleted; /set-home is
retired for /sethome.

/platforms is now the one platforms command on every surface: bare or
`list` shows status, `pause|resume <name>` act on a failing adapter in a
chat (the CLI points to a chat). /platform and /gateway are retired.

/backup snapshot|export|import replaces /snapshot (/snap), /export and
/import; bare /backup lists the three.
2026-11-28 19:42:51 -08:00
Teknium
a30074a733 fix(tui): offer only commands that run, keep typed registry names on Enter
- Client checks move from TypeScript-parsing pytest to vitest. A generated dump of the
  owner's verdicts (apps/shared/src/slash-exec-verdicts.json,
  scripts/dump_slash_exec_verdicts.py) is the owner truth. The Python test checks only the
  catalog's slash_exec against command_verdict and that the dump is fresh.
- Ink: a handler that forwards its bare form to slash.exec (`forwardsBare`, bare /pet) no
  longer earns the local exemption. A vitest runs every offered registry command and asserts
  none is refused.
- Ink: Enter keeps a fully typed registry name instead of accepting the completer's top row
  (/platform no longer becomes /platforms); tested through the real composer and submit.
2026-11-28 19:42:51 -08:00
Teknium
1986a7b8d5 fix: slash commands are offered and described only where they work
- /discard: drop gateway_only; the CLI's /discard <admission_id> runs, so CLI /help lists it.
- CLI: a messaging-only command typed in full says it runs in messaging chats instead of a
  near-miss for a different command (/pause -> "Did you mean /paste?").
- Shared gateway: an unsupported_command refusal for a messaging-only command carries a
  detail naming where it runs (Ink prints it under the refusal).
- TUI: commands.catalog marks each registry command with slash_exec (the owner's verdict); Ink
  completion and /help offer a registry command only when Ink runs it itself or the owner
  does, and an exact registry name is never prefix-expanded into another command.
- Desktop: /prompt /battery /focus /tools get desktop="terminal", /subscription "settings",
  the messaging-only /start /topic /pause /mute /sethome /restart "messaging".
- /stop description and docs say what it does per surface (messaging keeps processes from
  earlier turns running); /platform docs say pause/resume act only on a failing adapter.
2026-11-28 19:42:51 -08:00
Teknium
7b5c7e939a fix: config.get's contract admits the boolean Daybreak switch
Both owners answer config.get daybreak with {value: true|false} (tui_gateway/methods_config.py,
gateway/session_config.py) and Desktop reads it as value === true (store/daybreak.ts), but
ConfigGetResult typed value as str | None. Strict contract checks turned every read into
-32603; in production the reply was logged as a violation and the generated client type said
string. Widen value to str | bool | None like ConfigSetResult already does, regenerate the
gateway contract, and sweep every config.get key through strict validation on both owners.
2026-11-28 17:33:29 -08:00
Teknium
1056d48b31 fix(tui_gateway): declare plugins.list toolset default_platforms on the wire
The gateway's plugins.list handler sends each toolset's default_platforms,
but PluginToolsetRow (extra=forbid) rejected it. Declare the optional field
and regenerate the contract.
2026-11-28 15:59:41 -08:00
Teknium
f34de3f227 feat: status bars and /usage show whether the prompt cache is live or cold
Before sending after a pause there was no way to tell if the provider's prompt
cache was still warm (cheap, fast next message) or had expired (full re-process).
The cache clock already knew; nothing showed it.

- agent: prompt_cache_warm_until(agent) gives the one end every surface judges
  against (the window's estimated end, pushed on by a keep-alive in flight; 0
  after a compaction, route switch or new session; None while unknown), plus
  render_prompt_cache_state for /usage.
- The warmer announces each folded keep-alive through agent.prompt_cache_callback;
  a local viewer's turn wires it to publish one session.usage frame on the
  session's own stream, so the deadline moves on between turns, when nothing
  else publishes.
- session.usage / session.stats / message.complete usage carry it
  (prompt_cache_warm_until flat, cache_warm_until in the Usage view); contracts
  regenerated. mergeUsage drops it from a complete payload that no longer has it.
- CLI (classic + modern layout): cache_state status-bar field, "● live" /
  "○ cold", judged at render time. TUI: same segment from 76 columns, ticking
  each second. Desktop: a Cache live / Cache cold pill that flips at the deadline.
- /usage: a Prompt cache line on the CLI, TUI, Desktop and messaging surfaces.
- Copy in every locale catalog; docs in configuration.md.
2026-11-28 12:51:03 -08:00
kshitijk4poor
0bb0a5b8bb fix(tui): OSC 7577 follow-ups for the Ink TUI
Follow-ups to freqyfreqy's OSC 7577 support, from review:

- `--resume ID` is reported only for a session the gateway confirmed saved:
  an inline turn's prompt.submit `streaming` answer (tui_gateway writes the
  row before answering) or a resume with stored history. Token usage, a built
  agent or a pending submit no longer count; an isolated compute-host turn,
  a queued prompt and a shared gateway's admission receipt do not either.
  Saved ids are tracked only when the pane reports. Nothing is reported while
  attached to a named gateway (HERMES_TUI_GATEWAY_URL).
- The record is cleared on exit only after a user quit (die(): /quit, Ctrl+C
  or Ctrl+D at an idle prompt; or SIGINT). /update (exit 42), a crash, a
  signal and a dead output stream keep it.
- The launcher's bypass flag (--safe-mode / --ignore-user-config) rides in
  the resume prefix, and such a launch reports only a saved session
  (HERMES_TUI_RESUME_SESSION_ONLY).
- SIGCONT reports again; turning display.program_resume off at runtime asks
  the reporter whether a record is out. argv[0] follows the Python rule.
2026-11-28 01:37:13 +05:30
freqyfreqy
2053d341e2 feat(cli,tui): support OSC 7577 program resume protocol 2026-11-28 01:37:13 +05:30
Victor Kyriazakos
6404021192 docs(plugins): specify ctx.post_card, a durable card with no model turn
Background plugin work can only show the user an actionable card by
injecting a user turn the model must answer with a tool call. That costs
a full model call over the whole session, waits behind the background
review, and depends on the model cooperating. ctx.post_message cannot do
it either: it needs a session bound in the calling context and, on a
local session, is a transient notice rather than a transcript row.

Document the contract for ctx.post_card: a card (text, optional
transcript directive, optional id) admitted into the session's FIFO and
written as a note at the turn boundary, never a turn. It needs its own
consent capability, targets only the plugin's own profile, is
idempotent by id, and shows the model one factual line. Desktop renders
the plugin's registered directive. Other surfaces show the text, and
messaging platforms keep the plugin's own native card.


Also folds, while rebasing onto main (their intermediate trees predate merges of main):
- feat(plugins): ctx.post_card admits a card as a note, with no model turn
- test(plugins): ctx.post_card lands one note, in FIFO order, own profile only
- fix(desktop/tui): render plugin cards
- fix(plugins): a card is admitted from the gateway context, never the caller's
- docs(plugins): mark ctx.post_card experimental and state the plugin-host behaviour
- refactor(desktop): plugin card row and its claim check in a thread sibling module
- fix(plugins): a card is display-only, the model is told it exists and never reads its text
2026-11-27 09:41:31 -05:00
kshitijk4poor
216e902226 fix(gateway): the receipt docstring names both never-admitted refusals; guard its validator
A refused receipt also comes from bot_relay.settle (settled as not sent), not only a
FIFO refusal. Three contract cases pin the admitted-or-refused validator.
2026-11-25 15:11:08 +05:30
kshitijk4poor
001ec55d78 refactor(gateway): one receipt model for both bot_relay.deliver doors
The canonical deliver/settle routes now register BotRelayDeliverResult
directly instead of an empty subclass, so the receipt has one owner and one
generated type. The shared model's docstring keeps the admitted-or-refused
invariant the old canonical class documented, the bot-relay module docstring
says deliver returns the receipt, and the invalid-request test asserts the
code and reason for every case, including a missing id.
2026-11-25 15:11:08 +05:30
martino
8764441dd9 fix(gateway): align the dashboard bot relay delivery contract
[Salvage: rebased onto current main; carried main's target_state field into the shared receipt and regenerated the contracts]
2026-11-25 15:11:08 +05:30
unsupportedpastels
18dcf1472f feat(desktop): tell the backend when the user is active in a session
A report is a claim that the user is at this computer and this window
can show them this session's reply. A false claim silences a phone for
a reply nobody sees, so the reporter corrects whatever it last told a
connection the moment it stops being true, and claims nothing whenever
it is not sure. The backend ages a record by itself; silence is safe.

The shared channel remembers `client_activity` from this connection's
own `client.capabilities` answer and forgets it on detach and attach;
the gateway client exposes it as `clientActivity`.

What is in view, and where to report it (`store/presence-view.ts`): the
chat on this window's HashRouter route, only when its runtime binding
is the one the composer would send to (route, selection and the
runtime's own stored id agree), and only on the connection a submit for
it would use (the composer's owner ladder and the registry's passive
route, never a dial). A draft, another page (Settings), a stale binding
or a profile riding a shared socket is nothing in view. Nothing is ever
created, resumed or bound to report.

Evidence (`store/presence.ts`): with main's OS idle clock, input
anywhere on the computer (`basis: system`); without it, pointer/key/
wheel/touch input inside this document while visible (`basis: page`).
Elapsed time is monotonic; a snapshot older than the newest adopted one
is ignored, a late delivery is aged from when main sampled it, and page
input from before a suspend is dropped on resume.

The reporter keeps what it last told each connection. It reports only
on an open, negotiated connection that advertised the feature, checked
at the moment of sending and never queued; at most once per 45 seconds
while active, and at once when the user becomes active, the session in
view changes or `can_alert` changes. When the session leaves view, the
owner moves, or nothing is in view, it sends `sessions: []` there; when
`can_alert` turns false on stale evidence, also `sessions: []`. Lock
or suspend sends one `away: true` per episode on every connection that
holds a statement or owns the session in view.

`can_alert` is the session in view in a visible, focused window whose
chat is the tab in front (another tab of its zone, a second
conversation, a preview or a tool, can cover it while the route and the
main session stay, and its zone can be minimized), or this client's
turn-done notification for it firing if the turn ended now: one non-consuming check shared with the notification dispatch
(preference and kind, the post-connect quiet interval, the background
and active-session condition, and in a browser the live permission).
The dispatch throttle cannot be predicted and is not.

A route move reaches the reporter at once through `usePresenceRoute`
(a location effect in the app shell): HashRouter pushes history without
a `hashchange` event, so opening Settings over a chat would otherwise
stay claimed until the next 15 second tick. The `hashchange` listener
stays for a hash edited from outside the router.

Input in this window that ends an idle spell is reported at once, not
at main's next 15 second poll. Without an OS clock the input is the
evidence. With one, that clock stays the only evidence: main is asked
for a fresh sample a quarter of a second later, once the OS has counted
the input, and at most once a second for input the OS does not count.

Page listeners are passive and capture-phase and only record a
timestamp. A refused report is swallowed. The gateway boot hook starts
one reporter per window; it lives in timers and listeners and never
renders.
2026-11-23 11:47:46 -05:00
unsupportedpastels
f208babb5e docs(shared): say when the client identity is announced
The hello goes out once per connection, on its first gateway.ready, not at
each socket open.
2026-11-23 11:34:19 -05:00
unsupportedpastels
09136943b6 fix(gateway): bound the session-id length presence keeps
Presence capped each connection at 16 records per source, but a session id
could be any length: one accepted client.activity report naming 16 ids of
1 MiB each stayed in memory for the life of the socket, and touch() kept
whatever session_id an input request carried, even one the request was then
refused for.

client.activity now refuses an id over 256 characters (4001, nothing changes)
and touch() ignores one. The limit is one named constant, MAX_SESSION_ID_CHARS;
the contract's sessions items and the developer guide state it.
2026-11-23 11:34:19 -05:00
unsupportedpastels
dcc20cede9 feat(gateway): advertise client identity and activity; Desktop and Webapp say hello
`runtime.describe` lists `client-identity-v1` and `client-activity-v1`,
so a client can tell an owner that keeps a connection's label and
activity reports from an older one.

The shared JSON-RPC channel takes an optional `clientIdentity` from its
host and, once per connection generation, right after its
`server_requests` call, sends `client.capabilities {client}` as a call
of its own, ignoring an error reply (an older backend refuses the
unknown param for that call only). A host that names none sends
nothing, so the TUI and other users of the channel stay unannounced.
The Desktop names itself `hermes-desktop` / `desktop` in Electron and
`hermes-webapp` / `webapp` behind the browser bridge. The version is
this machine's own build (the install's version, then the release it
was built from, then the display string), left out when it is a
placeholder or not a valid label version. Reading it asks the backend
and the local install, which takes seconds on a cold start, so the
hello waits at most one second for it and goes without; the read is
kept, and later connections of the window carry it.

The developer guide describes the hello, the kinds (sent on
`session.create` only to an owner with `client-identity-v1`) and
`client.activity`. All of it is attribution only and grants nothing.
2026-11-23 11:34:19 -05:00
unsupportedpastels
33a8ba6346 feat(gateway): track which attached clients were recently used
A notification plugin needs to know, at the end of a turn, whether the
user is at a client that shows the session, so a phone can stay quiet.
gateway/session_presence.py keeps that per connection and session, in
memory only: one "last input" time fed by input the owner sees on the
connection (prompt submit, queued steer/replace, approval and clarify
answers, interrupt, steer, redirect; touched once from dispatch, and a
person's accepted answer to a server request card) and by the client's
new `client.activity` reports (`now - idle_seconds`, with the basis of
the evidence and whether the client can alert the user). The newest
evidence wins. A report is the connection's whole statement: records of
sessions it does not list are dropped, owner-seen input included.
`away` clears the connection's records. A connection keeps at most 16
records of each source (reports, owner-seen input), so a report naming
16 sessions and input on them never push each other out.

One socket can serve several profiles and session ids are unique only
per profile: owner-seen input is kept for the profile that saw it, and a
report (ids only) counts at read time for the one profile the connection
is attached to that id in, for none when the id is ambiguous.

`viewers(authority, session_id)` lists the connections attached to a
live session right now, with the hello's name and kind. A detached or
closed connection is not a viewer. `client.capabilities` answers
`client_activity: true` so a client reports only to a backend that
keeps the reports.

Nothing here reaches a prompt, a permission or a toolset. The serve
handler ledger and its generated page list `client.activity`.
2026-11-23 11:34:19 -05:00
unsupportedpastels
fe6b7dc93d feat(gateway): clients announce themselves once per connection
`client.capabilities` takes an optional `client` label
(`{name, version?, kind?}`): a client sends it as its own call once per
connection, so an older backend refuses only that call. A valid label
is kept on the WebSocket transport (`client_identity`) with an unknown
kind removed; a malformed one answers 4001 before anything else in the
call takes effect, and the connection keeps the label it had. A later
call without `client` keeps it too. Transports that keep no identity
(stdio) ignore it.

The label grants nothing; it is attribution only. Its contract class
moves to contracts/common.py so the liveness contracts can use it
without importing the canonical catalog early.
2026-11-23 11:34:19 -05:00
unsupportedpastels
d7c3b2c23c feat(gateway): let a client label carry a kind
A client label may now say what sort of client it is: `kind` is a
string of 1-32 characters, and `desktop`, `webapp`, `tui` and `mobile`
are the kinds this owner knows. An unknown kind is not an error, since
a newer client may name a sort an older owner has never heard of: the
label is kept and read without it (`normalized_client`). The creation
request still carries the label as sent, so exact-retry identity is
unchanged.

The label stays attribution only.
2026-11-23 11:34:19 -05:00
emozilla
6a77b89465 docs(approval): the contract says who keeps a card on screen past its turn
A folder or site card can stay open after the turn that raised it. The desktop
asks approval.pending after every session.info and after every answer, and
removes a card that list does not name. A sender that leaves its card out of
the list loses it at the next check, and the contract did not say so.

The docstring of the approval request now states it in one sentence, and the
generated contract files carry it.
2026-11-23 11:11:48 -05:00
emozilla
eafc0baff0 fix(approval): refuse a folder or site request that names no folder or site
An approval request of kind access without a path, or of kind network without
a host, became a card titled "Folder access" or "Website access". It showed
the request's description, or "dangerous command" when the request had none,
and offered Allow and Always allow for something the person could not read.

The desktop now answers such a request with a JSON-RPC error, shows no card
and sends no notification. An entry of that shape in the pending list or in a
resume snapshot is not parked and not acknowledged. The contract model refuses
it as well, and its docstring says so; the generated contract files carry the
new sentence.

The test that pinned the old choice of the field reader keeps its assertion
and now says why the kind is kept: the request is refused as a folder or site
request and is never read as a command.
2026-11-23 11:11:48 -05:00
emozilla
90176566e1 feat(desktop): approval cards for a sandbox's folder and site requests
A sandbox plugin needs to ask the user about a folder or a website from
the chat when its sandbox refuses one. The desktop's approval card only
knew dangerous commands: it said Run, promised a config.yaml allowlist,
and was cleared at turn end while the sandbox still waited.

The approval server request gains an optional kind. Absent or "command"
keeps today's card. "access" (path, read or read_write) and "network"
(host, optional label) render a folder or site card with the risk line
under it and three buttons: Deny, Always allow... (confirm dialog) and
Allow (until the sandbox is switched off). Deny takes an optional
reason, sent as `reason` on the answer and on the approval.respond
fallback.

- Contract: kind, path, access, host, label and risk on
  ApprovalRequestParams; reason on ApprovalResult and approval.respond
  (command approvals ignore it). Generated TS and OpenRPC regenerated.
- Turn-end clears keep folder and site cards; Stop, close and reclaim
  still clear every kind. Only a command approval stands in for the
  turn's tool rows.
- Pending-list replay and resume snapshots keep the kind fields.
- OS notifications say "Folder access needed" / "Website access needed"
  and offer Allow / Deny.
- Copy in every locale. Each over-cap locale's approval block moves to
  an <locale>_approval.ts sibling unchanged; key manifest regenerated.
2026-11-23 11:11:48 -05:00
Teknium
08e86c59fd Port from block/goose#12928: OSC 7501 program status in the Ink TUI, spec-safe messages
Hardening on top of the classic-CLI reporter (salvaged from #138152):

- Ink TUI (`hermes --tui`) reports too. useProgramStatus derives the state from the
  stores every path already updates (busy, the approval/clarify/sudo/secret/vault/connection
  overlays, the turn outcome recorded in turnController), so no answer path has to remember
  to report "working" again. A 150 ms settle drops the busy flicker between submit and
  message.start that otherwise flashed working -> idle -> working on every turn.
- msg text: the spec discards a whole report whose decoded msg holds C0, DEL or C1
  controls; C1 (U+0080-U+009F) passed the old strip. Controls now collapse to one space.
- Config key moved to display.program_status beside bell_on_complete/bell_on_prompt (it is
  a display preference, and the TUI's config sync already reads display.*); documented.
- _report_program_status lives on CLIChatTurnMixin, the mixin that calls it, so surfaces
  composing the chat mixin without the modal mixin (TUI gateway CLI surface, stubs) do not
  AttributeError at turn end.
2026-11-21 16:54:29 -08:00
ghgoodreau
951efa9c39 feat(desktop): uncapped long-frame histogram under the shared-metrics opt-in
slow_frame friction caps at 5 per bucket per day (renderer) and 50 (backend)
and starts at 100 ms, so a janky day reads as "5" and mild stutter is
invisible. Add hermes.desktop.long_frames.sum: the existing
long-animation-frame/longtask observer now also folds every visible-window
frame into a per-UTC-day histogram (50-100 ms, 100-250 ms, 250 ms-1 s,
1-5 s, >=5 s; LoAF reports >=50 ms only, the first band sits below the
100 ms slow_frame threshold, the rest mirror slow_frame) plus the day's
visible time, kept in DayAggregate via withState and shipped once per finished day on its
own RPC, shared_metrics.desktop_long_frames (never per frame).

desktop_daily keeps main's contract. An older backend answers -32601 for the
new method; the renderer settles that day's histogram unrecorded so the day's
existing daily report still lands and the pending day clears. The visible-time
clock credits only visible spans and drops any span longer than the tick + 60 s,
so a suspend credits nothing.

Backend: a SUM_METRICS counter, one row per bucket whose value is the day's
frame count (uncapped), each carrying the visible-minutes bucket so a rate is
computable; a visible day with no long frames reports one `none` row.
update_rollup_state rows may carry an amount (SUM_METRICS only). Own
once-per-day latch, profile-scoped. Gated by
the renderer $desktopMetricsGate and the backend enabled(); upload by send.
slow_frame friction is unchanged.

Measured: a synthetic day of 300 frames at 120 ms reports
{bucket: 100ms_to_250ms, count: 300} and stores value 300 (was 5).
2026-11-20 14:42:55 -06:00
Jeffrey Quesnelle
4f03cea903 Merge pull request #156732 from NousResearch/fix/desktop-continued-reply-not-stopped
fix(desktop): a reply paused to be continued is not shown as stopped
2026-11-20 14:11:27 -05:00
kshitijk4poor
8e6de6153b refactor(profiles): one neutral TypeScript owner for the profile-id grammar
The TS profile-id grammar lived in electron/profile-id-guard.ts, so renderer
code imported an Electron module for a regex, and the Bot creation dialog plus
the dashboard ProfilesPage and ProfileBuilderPage still carried private copies.

apps/shared/src/profile-id.ts now holds the one literal (PROFILE_ID_ARG_RE),
exposed as the narrow @hermes/shared/profile-id subpath. Electron gates import
it relatively (esbuild bundles electron/ without tsconfig paths); the renderer
and the dashboard import the subpath; plugins get it through a one-line
@hermes/plugin-sdk utility re-export, since the plugin fence allows only the
SDK. profile-id-guard.ts keeps backendProfileArg and re-exports the regex.
Per-caller trimming, case-folding, default/reserved names and the bot slugifier
are unchanged.

Guards swap the shared owner and prove every gate follows it, including the
Bot dialog (owner-driven rejection on a reachable slug), ProfilesPage and
ProfileBuilderPage, and backendProfileArg.

Refs #155595
2026-11-20 17:36:20 +05:30
emozilla
7fffa193bb test(gateway): only a completed child is mirrored as complete
The child watch mirror now sends `status: "complete"` with a completed
child's `message.complete` (the previous commit). Pin the other outcomes:
a failed, errored, interrupted or timed-out child, and one that reports no
status, keep the status-less frame, so the desktop still reads an error
summary such as "HTTP 500 upstream" as a failure.

`MessageCompletePayload`'s docstring said the mirror sends `text` only; it
now names the status. The two generated contract files carry that sentence
(`scripts/gen_gateway_contracts.py`); no field or type changes.
2026-11-19 18:10:30 -05:00
Teknium
6190457161 feat(bot-mode): bot_delivery.list — read-only view of a bot's unsettled teammate deliveries
A bot that message_agent's a teammate gets nothing back until the reply lands or the wait times
out; if the teammate is parked on a clarify or approval only the user can answer, nobody sees it.

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

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

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

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

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

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

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

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

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

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

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

Behaviour is unchanged. Neither file has a logger.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; comments that named the old module stems were fixed
by hand; the two gateway contract files are regenerated from the
docstring that names the module.
2026-11-17 06:41:24 +05:30
emozilla
b26170d898 fix(desktop): a reply paused to be continued is not shown as stopped
Since 674f2d680d the closing row of a turn stopped during its tool run
carries display_metadata {"interrupted": true}, and hydration lends that
mark to the tool bubble it closes. Something can pause a running turn
(session.interrupt) and continue the same reply with a hidden prompt: a
host plugin does this to apply a sandbox grant, restarting or reloading
the sandbox in between. The finished reply read "Read example.com /
Response stopped / Read example.com / <the page>", and while the pause
lasted (1-4 s for a site grant, 10-20 s for a folder grant that restarts
the sandbox) the chat showed only "Response stopped" with an idle
composer. A user who took the reply for dead and sent again killed the
continuation: the gateway interrupts a running turn for a plain send.

A stopped mark says the reply ended there. When the same reply goes on,
it did not end there:

- Stored history (toChatMessages): a stopped bubble followed by a hidden
  user row and more assistant output loses the mark. A visible user or
  system row next (the user writing, the "resumed interrupted turn"
  notice) keeps it, so a real Stop still reads "Response stopped" after a
  reload.
- Once the reply goes on (live): a message.start that finds a stopped
  reply as the last visible row (no prompt drawn, no automation card on
  the start) sets ChatMessage.continued, and toRuntimeMessage then draws
  no mark. Display only: `interrupted` stays on the message, because the
  stopped turn's receipt bookkeeping (transcript-receipt-turns.ts) reads
  it.
- While it is paused: session.interrupt takes `resume: true` ("I pause
  this turn and continue it myself"). The turn ends like any interrupt,
  with the same stored rows; its message.complete says `paused: true`.
  The user's own Stop for the same turn wins. The desktop keeps the chat
  paused (store/paused-replies.ts, by stored session id, since a sandbox
  restart changes the runtime session) until the continuation's turn has
  completed, or 120 s pass without its start or completion. Until it
  starts, the newest reply reads "Continuing…" instead of "Response
  stopped". Throughout, Enter puts the message in the chat's local queue,
  also while a restart has the backend away (the composer is otherwise
  disabled then), and not in a gateway-owned queue, which would draw it in
  the thread between the paused reply and its continuation. It goes once
  the continuation has completed, as its own turn: never steered into the
  continuation and never interrupting it.
2026-11-16 18:56:28 -05:00
alt-glitch
611f0ab757 refactor(cron): three cron helper files move from tools/ to cron/
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
tools/ holds model tools. These three files register none and do cron's
work, so they move to the package that owns it:

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

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

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

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

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

- tools/browser_lightpanda.py::_record_path
- tools/computer_use/tool.py::get_computer_use_schema
- tools/computer_use/schema.py::get_computer_use_schema
- tools/computer_use/cua_backend.py::CuaDriverBackend.launch_app (and its test)
- tools/computer_use/cua_backend_session.py::_CuaDriverSession.capability_version
  and the _capability_version bookkeeping
- tools/computer_use/cua_backend_daemon.py::_CUA_DRIVER_BUNDLE_ID (callers use
  CUA_DRIVER_BUNDLE_ID)
- tools/computer_use_tool.py::__all__ and the two imports only it re-exported
- tools/bot_desktop/runtime.py::_allocate_display (its test now calls
  _pick_display, the live allocator)
- tools/bot_desktop/install.py::assert_not_running (its test checks release
  via claim/release)
- tools/close_preview_tool.py (whole module) and tests/tools/test_close_preview_tool.py;
  PreviewClosePayload docstring updated and gateway contract regenerated
2026-11-16 15:39:38 +05:30