Commit Graph

5246 Commits

Author SHA1 Message Date
unsupportedpastels
b51e4272ea fix: Daybreak follows the launch policy and reaches isolated turns
Platform.LOCAL is the canonical transport, not the owner: hosted rooms
(bot_room) and A2A peers stage LOCAL sessions too, so the platform gate
still sent Daybreak on their turns. The gateway now reads the route's
frozen launch policy and allows only the owner's own creation labels
(cli, tui, gui, oneshot; gateway.session_policy.DAYBREAK_LABELS). Third-
party tool integrations, editor (ACP) clients and an unreadable policy
get standard requests.

With turn isolation the live agent is in the compute-host child, which
read the switch once at build; the parent's live flip only reaches its
own process. The child now re-reads it from its profile's config.yaml on
every reused turn, with the same local-surface gate.
2026-11-02 15:06:27 -05:00
unsupportedpastels
7dbe1bff8f fix: keep Daybreak to the owner's local surfaces
The profile switch reached every turn the gateway ran, so turning it on in
Desktop also sent Daybreak on that profile's Telegram, Discord and Slack
chats. OpenAI allows Daybreak no third-party or downstream access, and a
bot's chats can be other people.

- gateway: _load_daybreak(source) is true only for Platform.LOCAL turns
  (Desktop, TUI, CLI).
- standalone hermes serve: agents built for a non-local source (a plugin
  session tagged telegram) never carry it, and a live flip skips them
  (agent.session_source.DAYBREAK_SOURCES).
- docs: say who gets it and why messaging chats don't.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-02 15:06:27 -05:00
unsupportedpastels
60f5029394 feat: Daybreak switch for catalog-listed ChatGPT subscription models
OpenAI Daybreak (Trusted Access for Cyber) reduces cyber refusals for
approved accounts. Codex's model picker has a Daybreak toggle; Hermes had
no way to request it.

The signed-in account's Codex /models catalog already lists, per model,
which cyber programs that account may use
(available_access_programs.cyber). Hermes reads that catalog for Fast and
Ultrafast; it now keeps the cyber list from the same fetch.

- agent.daybreak (default false) is one profile-wide switch, like Codex's.
- Desktop shows a Daybreak switch in a model's options submenu, next to
  Fast, only when this account's catalog lists daybreak_blue for that
  model. Unknown or unreachable catalog: hidden.
- Each Responses request adds access_programs.cyber=daybreak_blue only
  when the switch is on AND the request's credential and model are listed.
  Checked per request, so a /model switch, credential rotation or expired
  catalog never carries it to a model or account without it.
- The gateway re-reads the switch every turn, so a flip applies to the
  next turn of a running chat without rebuilding its agent.
- The opt-in codex app-server runtime does not send it, so the switch is
  hidden there.

Co-authored-by: FroRaut <79215537+Froraut@users.noreply.github.com>
2026-11-02 15:06:27 -05:00
unsupportedpastels
5e7c2b254d fix(desktop): keep the dev renderer origin out of the local gateway Desktop starts
runGatewayEnsure layered the Desktop process env under the child, so a dev build's `gateway ensure` (and `gateway restart`) handed HERMES_DESKTOP_DEV_SERVER to the per-host gateway it starts. That gateway outlives the dev session and kept trusting the renderer port (Vite's 5174 fallback) for CORS and sockets afterwards. Desktop never needs it there: its HTTP to the local gateway goes through main-process requests with no Origin, and its socket dials have Origin stripped. The variable is now removed from the ensure client env; SSH-spawned serve backends still receive it.

local-gateway.test.ts: the new case reported the inherited value before this change and none after.
2026-11-02 13:56:48 -05:00
unsupportedpastels
a4847138bb fix(dashboard): trust a loopback public_url's exact origin behind a Host-rewriting proxy
With webapp.public_url: https://localhost:8443 in front of a Webapp on
127.0.0.1:9120, a proxy that rewrites Host to the backend's address
sends Host 127.0.0.1:9120 with Origin https://localhost:8443. That
Origin names neither the bound port nor the Host it dials, so CORS gave
no grant and every WebSocket upgrade got 4403. The loopback port check
never read the configured public URL, and a loopback public URL does not
turn on sign-in.

_configure_auth_gate now also records the public URL's exact loopback
origin (scheme, host, port; default ports filled in) as
app.state.trusted_public_origins, from listener_public_url (the
Webapp's webapp.public_url) or dashboard.public_url, and
is_trusted_local_origin accepts an Origin equal to it. Nothing else is
widened: another loopback port, scheme or host on the same proxy is
still refused, and a non-loopback public URL adds nothing (its Origin
never reaches the port check).

The port check keeps running on 0.0.0.0 / :: binds. Sign-in cookies are
SameSite=Lax and http://localhost:3000 is same-site with
http://localhost:9119, so sign-in alone does not keep another local
page on the same host off the sockets; a new test pins that.

The public_url cases fail on the previous sources (4 failed: every
trusted case) and pass with this change. web-dashboard.md describes the
proxy setup.
2026-11-02 13:56:48 -05:00
unsupportedpastels
3d9a230d57 fix(dashboard): forward the Vite dev page's socket Origin unchanged
The /api proxy rewrote a WebSocket upgrade's Origin to HERMES_DASHBOARD_URL.
Pointed at a port forward (http://127.0.0.1:8000 forwarded to the backend on
9119), that Origin names neither the backend's bound port nor the Host the
proxy keeps (localhost:5173), so the backend refused the dev page's sockets.

The proxy sets no changeOrigin, so Host stays the page's own authority and
the browser's Origin already names it, which the backend admits as
same-origin. Drop the rewrite and its helper, pin the proxy options, and
pin both header pairs in the backend test.
2026-11-02 13:56:48 -05:00
unsupportedpastels
20ec0bae9f docs(dashboard): a dev build keeps using an already-running local gateway
The sockets Desktop opens to a gateway on the same machine are one-use,
ticketed native dials whose Origin is stripped before the upgrade, and
the boundary admits an upgrade with no Origin. A dev build therefore
needs no restart of a local gateway that was started without
HERMES_DESKTOP_DEV_SERVER. Say so, note that SSH backends spawned for
another renderer are replaced, and narrow the remaining requirement to
backends Desktop did not start that see the dev renderer's Origin.
2026-11-02 13:56:48 -05:00
unsupportedpastels
1dc0e05bfc docs(dashboard): describe port forwards and dev builds on current Desktop
The CORS section described the desktop attaching to the host's running
backend only when it accepted the renderer origin. main no longer has
that attach flow: a local Desktop reaches the gateway through
`hermes gateway ensure`. Describe what a dev build does now, and that a
dashboard reached through a port forward still opens its own sockets.
2026-11-02 13:56:48 -05:00
FroRaut
cb837e10a5 fix(dashboard): stop trusting fixed dev-server ports for CORS and WebSockets
_TRUSTED_LOCAL_ORIGIN_PORTS (9119, 5173, 5174, 4174) was trusted on every
backend, including packaged Desktop backends on an ephemeral port. A Vite app
on 5173, or on 5174 when 5173 is taken, could still read the session token
from / and open /api/ws. _is_trusted_local_origin() now accepts only the bound
port and the desktop dev renderer this backend was spawned for
(HERMES_DESKTOP_DEV_SERVER). `hermes dashboard` keeps working on 9119 because
that is its bound port.

The dashboard's Vite dev server was the only client that relied on a fixed
port: the browser's Origin on proxied /api upgrades is Vite's. The /api proxy
now presents upgrades from Vite's own page (Origin host equals Host) with the
backend's origin, and passes every other Origin through for the backend to
refuse, so it does not launder foreign pages the way Vite's rewriteWsOrigin
would. Vite's default CORS grants every localhost port and would hand another
local page the token hermesDevToken() injects into index.html, so it is off.

(cherry picked from commit 66de028a3ce39ec49a32205855dc269d30bf3942)
2026-11-02 13:56:48 -05:00
FroRaut
e45b32ac48 fix(dashboard): stop trusting loopback port 3000 for CORS and WebSockets
_TRUSTED_LOCAL_ORIGIN_PORTS kept :3000 because web-dashboard.md listed
it, but nothing in the repo serves the dashboard or the desktop renderer
there. It is the default port of many local web apps and dev servers,
and it is the origin used in the original report: with :3000 trusted, a
page on http://localhost:3000 still got the CORS grant on `/` (the
session token) and on /api/files/download?token=, and still passed the
WebSocket Origin gate.

Drop :3000 from the trusted ports and from the documented list. The
dashboard's own origins (the bound port, :9119, the Vite dev server
:5173, the desktop renderer's :5174/:4174 and HERMES_DESKTOP_DEV_SERVER)
are unchanged.

(cherry picked from commit 0fc889ab9b1826c5062eb88959f96099258ab056)
2026-11-02 13:56:48 -05:00
Froraut
67e0e1940a fix(dashboard): address review — trust the desktop dev renderer's own origin
The fixed loopback-port allowlist refused every documented hgui slot
past 0: worktree-ui-dev.md runs slot N's renderer on 5174+N. That
renderer talks to its backend directly, so slot 1 (:5175) got no CORS
grant and a 4403 on its WebSocket upgrades.

Electron hands its HERMES_DESKTOP_DEV_SERVER down to the backend it
spawns: profileBackendParentEnv copies process.env. So
_is_trusted_local_origin now also trusts that exact origin when it is
loopback. Any other loopback port is still refused, including another
slot's renderer. The CORS middleware and the WebSocket Origin gate
share this check, so both honour it. No new setting: the variable
already exists and is documented.

(cherry picked from commit fb08ccb4ef9a130469fc0d203917fcc0e5e200ef)
(cherry picked from commit d921624b8339f693067dec1495fd6afe38ad4093)
2026-11-02 13:56:48 -05:00
Froraut
bd9328f969 fix(dashboard): trust only the documented loopback origins for CORS and WebSocket upgrades
Any page served from another local port could steal the dashboard
session token and open /api/pty — a full shell.

- CORS used allow_origin_regex ^https?://(localhost|127\.0\.0\.1)(:\d+)?$,
  i.e. every port. CORS wraps the SPA catch-all too, so a fetch of `/`
  from http://localhost:3000 (or Live Server :5500, a previewed
  agent-built site, a compromised local dev app) got
  Access-Control-Allow-Origin reflected and could read index.html's
  window.__HERMES_SESSION_TOKEN__. The ?token= download route was
  readable the same way.
- WebSocket upgrades skip preflight, and _ws_host_origin_reason checked
  the Origin through _is_accepted_host, which drops the port and accepts
  any loopback alias. So ws://127.0.0.1:9119/api/pty?token=<stolen>
  from Origin http://localhost:3000 passed the gate.

The docs (web-dashboard.md § CORS) already promise a fixed list: 9119,
3000, 5173 and the configured port. Both gates now trust exactly that —
plus the desktop renderer's strictPort dev/preview servers (5174/4174)
— via one _is_trusted_local_origin(). Non-web origins (packaged
Electron file://) are unaffected; trusted public hosts keep their
existing exact-host rule.

(cherry picked from commit 8a5f1dcee82e2a020b72d7bd7e9b5a0e6f11f390)
(cherry picked from commit 9dad5f4cd0988ad60ae4883541b68efb9092bb1a)
2026-11-02 13:56:48 -05:00
mnajafian-nv
f301e86fe4 chore(relay): upgrade to 0.11.0
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
2026-11-03 00:14:24 +05:30
kshitijk4poor
0aab6dcf8b docs(skills): correct the projects reference against the live CLI
Running the documented commands against a scratch HERMES_HOME showed several
claims in the new reference were wrong:

- `hermes project bind-board` does not link a board's tasks to the project. It
  records the board on the project and, when the board exists and the project has a
  primary folder, sets the board's default workdir (from the CLI only a bare
  `--workspace worktree` task uses it). The board's project_id stays null, so tasks
  get no project link or deterministic branch; only the kanban dashboard's Project
  selector or `hermes kanban create --project` links tasks. Unbinding clears only
  the project's record.
- The CLI resolves `<project>` by an exact id or a slug in any case, not by display
  name; name matching is only in the desktop_project tool.
- `set-primary` normalizes paths, so the "spell it the way show prints it" tip was
  wrong.
- A desktop_project move leaves the active-project pointer alone only when the
  project has a folder, and the desktop sidebar following the viewed chat can still
  select the new project.

Also: the worktree + branch default applies to linked non-dir tasks of a project
with a primary folder; an unknown `--project` creates an unlinked task without an
error; complete the exit-code list; note desktop delete (folders and chats kept),
the sidebar's automatic groups, and the Windows HERMES_HOME default; drop internal
table/function names and the raw sqlite queries; replace troubleshooting advice
that made two projects own one folder; point background-systems.md at the
reference; shorten the routing row; and regenerate the bundled-skill docs page.

website/docs/reference/cli-commands.md made the same bind-board claim; its summary
rows and `hermes project` section now describe what the CLI does, and `--project`
is listed among the `kanban create` flags.
2026-11-02 16:20:57 +05:30
Teknium
5351ed71d4 fix(mem): cap malloc arenas before any server thread exists; honour .env MALLOC_ARENA_MAX
Review fixes for the arena cap:
- serve/dashboard/gateway apply runtime.malloc_arena_max at hermes_cli.main import, right
  after the profile .env and config load and before logging/plugins start any thread
  (glibc latches its arena limit once threads allocate; the old serve call ran after
  plugin discovery). Legacy python -m gateway.run and cli.py --gateway apply it first too.
- MALLOC_ARENA_MAX / glibc.malloc.arena_max present only because Hermes loaded the
  profile .env (absent from /proc/self/environ) is applied via mallopt with the
  operator's number; one present at exec is already glibc's and wins.
- exact tunable-key match, C-int range check, glibc capability gate (gnu_get_libc_version
  + mallopt) instead of sys.platform; tests gate on glibc and drive the real entry point.
2026-11-01 21:54:15 -08:00
Teknium
fcbf94c2e7 perf(mem): cap glibc malloc arenas in the gateway and serve processes
glibc gives each new thread its own malloc arena, up to 8 x CPU cores, and keeps
every arena's freed pages. A long-lived gateway churns through ~1,100 short-lived
Python threads an hour (tool heartbeats, turn watchdogs, stream monitors, pipe
drains) on top of native pools (the relay plugin's tokio runtime, anydoc's rayon
pool), so it fills every slot: 157 of 160 arena heaps on a 20-core host after 10 h.

runtime.malloc_arena_max (default 4) sets mallopt(M_ARENA_MAX) in-process at
gateway bootstrap and web_server.start_server (serve / dashboard), next to the
existing RLIMIT_NOFILE floor. In-process rather than MALLOC_ARENA_MAX in the
unit/plist/spawn env, so commands the server runs (terminal tools, MCP servers,
builds) keep glibc's default, and every launch path (systemd, launchd, Desktop,
detached auto-start, docker) is covered by one call. An operator's own
MALLOC_ARENA_MAX / glibc.malloc.arena_max tunable wins; 0/false/null keeps
glibc's default; non-glibc hosts are untouched.
2026-11-01 21:54:15 -08:00
Teknium
fcee404be6 fix(sessions): old phone-app chats continue in Desktop instead of opening read-only
Before the gateway owned sessions, `hermes serve` stored whatever `source` a client
sent, so phone apps signed in through the dashboard login left routeless rows labelled
`mobile`, `ios` and the like. Resume only adopted the local surfaces' labels, so those
chats opened read-only (#143601) and the next prompt answered `session_read_only`.

Adopt any routeless, owner-owned row whose label is not a local surface, a built-in
messaging platform, or an automation / foreign-writer label (cron, subagent, kanban,
bot_room, a2a, webhook, api_server, import, recovered, webui, local, unknown). It
resumes as a `gui` chat, and binding relabels it `desktop` (created_source keeps the
app's label), because once bound the row has a route and its old label would read as
a messaging chat. Routed rows never qualify, so the hermes-mobile plugin platform,
which registers `mobile`, keeps its messaging route. Third-party WebUI rows stay
read-only: that process runs its own agent on the same state.db.

The same predicate feeds the read-only mount (skips them), sidebar edits, the stored
picker and `hermes sessions adopt`.

Refs #146814, #144814.
2026-11-01 21:30:21 -08:00
Ben Barclay
67d3d5076c fix(pm): a corrupt cached package no longer blocks every install
A machine stop during an install can leave an unpacked wheel in PM's uv
cache whose files are NUL bytes: uv renames its unpack directory into
archive-v0 without flushing the data. uv reuses that entry on every sync, so
every later plugin enable, repair or install failed with "The wheel is
invalid", and neither a retry nor the suggested `hermes pm doctor` helped.

When uv's install step fails on a cached artifact (invalid wheel, invalid
RECORD, or a cache pointer to a missing archive), PM now removes the named
package(s) plus any other entry that fails the same validation through
`uv cache clean`, deletes leftover corrupt archives, and retries. A retry
only follows a failure naming a package not purged yet (at most three), so a
source that serves a broken wheel fails once more with a message naming the
package and the cache directory. Other failures are untouched.

`hermes pm doctor` now reports corrupt uv cache entries, and
`hermes pm doctor --repair` removes them.
2026-11-01 20:07:30 -08:00
Teknium
06433066f4 fix: bare hermes migrate passes no setup-only flags; an import that ran with errors gets its own warning 2026-11-01 19:53:24 -08:00
Teknium
43cc73f12d fix: hermes migrate openclaw imports secrets only with --migrate-secrets
First-run setup keeps passing --migrate-secrets (what core's old OpenClaw step did); the named
command forwarded setup's choice too, so API keys and bot tokens came over without being asked.
2026-11-01 19:53:24 -08:00
Teknium
afc5c55d47 feat: setup and hermes migrate offer the OpenBot import too 2026-11-01 19:53:24 -08:00
Teknium
3053b9dd92 feat: hermes migrate and setup move Grok Bot users over; hermes migrate <agent> installs the importer
Grok Bot joins setup's "Coming from another agent?" step (detected from its desktop app
or a downloaded grok-bot-export file). Bare `hermes migrate` offers the same import on an
existing install; `hermes migrate <agent>` imports from one agent, installing the
agent-importers plugin from the catalog when missing. A plugin too old for the picked
importer is updated once and the import retried, for setup and migrate alike.
2026-11-01 19:53:24 -08:00
Teknium
f3686eeb0a docs(desktop): per-gateway terminals 2026-11-01 18:35:23 -08:00
Teknium
91c51e04f4 feat(skills): a locked skill can't be changed by the agent through any write path
Builds on the per-skill lock record (`hermes curator lock`): the lock now holds against the
agent everywhere, not only the background passes.

- skill_manage refuses every mutating action on a locked skill for every origin (normal turns,
  cron, subagents, review fork, curator); a corrupt sidecar still fails closed only for the
  autonomous passes so one broken file can't freeze every skill edit.
- write_file / patch hard-refuse any path inside a locked skill's directory and the lock
  record (skills/.usage.json) while any skill is locked (tools/skill_lock.path_refusal, wired
  into _check_sensitive_path).
- terminal refuses, before approvals and under --yolo, commands that write into a locked skill:
  redirections/tee, cp/mv/rm/touch/mkdir/chmod, sed/perl -i, git changes in its tree, archive
  extraction into it, inline python/bash code naming it, including after a cd into it; and the
  agent running `hermes curator unlock`. Reads and running the skill's own scripts still work.
- The curator never auto-archives a locked skill.
- Docs: "Locking a skill" rewritten for the new contract.
2026-11-01 15:47:21 -08:00
Davis Ford
b694c7d907 feat(skills): per-skill content lock against autonomous writes (#25083)
`hermes curator lock <skill>` records `locked: true` beside `pinned` in the
active profile's skills/.usage.json. While locked, skill_manage refuses
patch/edit/write_file/remove_file/delete on that skill when the write origin
is the background review fork or the curator consolidation pass, for the
whole skill directory and on both the single-op and the batch path. The
skill stays readable, listed and auto-loadable; foreground user-directed
writes are not gated; unlocked siblings keep learning.

- tools/skill_usage.py: set_locked / is_locked (strict: a corrupt sidecar
  raises instead of reading as unlocked) / locked_skill_names
- tools/skill_manager_guards.py: _locked_guard, wired into
  _background_review_preflight ahead of the delete guard; fails closed on
  an unreadable sidecar instead of silently relaxing the lock
- hermes_cli/curator.py: `curator lock|unlock`, locked list in `status`
- agent/background_review.py: one prompt sentence so the fork does not
  retry or recreate a refused locked skill
- docs: curator.md "Locking a skill's content" section, line 47 corrected
  (pins block deletion only, #141673), skills.md pointer

Related: #140332, #142933, #89961
2026-11-01 15:47:21 -08:00
Teknium
9a56be3d86 test(desktop): a relay lease still defers an edit on a kept gateway; doc the launch-time cost
Follow-ups from the deep review:
- Cover the drain rule: a kept gateway with a relay lease defers an edit
  redial until the lease is released, and the keep pin alone never defers it
  (red with the keep pin counted in the drain).
- The keeper comment no longer claims a throttle it does not have: a down
  gateway is redialed every 30 s.
- Docs: SSH tunnels and (with a remote primary) the local gateway now start
  at launch, and terminals on a gateway keep running when you pick another.
2026-11-01 14:27:53 -08:00
Teknium
13bd44e4a4 fix(desktop): every gateway stays connected; picking one is instant, with no switch prompt
Desktop treated registered gateways as one-at-a-time: picking another gateway
ran a "switch" (barrier, session-list wipe, a "Switch to This device? This
opens a fresh session on this computer..." confirm), and a gateway that was
unreachable when Desktop started never showed up in the All profiles session
list after it came back.

- store/gateway-persistence: every registered gateway's home socket is dialed
  at launch, pinned against the idle pruner (retainGatewayForRelay now takes
  includeLocal so This device is kept too when a remote is primary), redialed
  every 30 s while down, and the session list is re-pulled when one connects.
- selectConnection is a live activation like a profile pick: the target is
  opened first (a dead gateway fails there and touches nothing), then the old
  runtime is unbound and a fresh draft started synchronously right before the
  target is published (#93937 invariant kept). No barrier, no list wipe, no
  machine-context reset; an in-flight Settings apply is superseded.
- This device prompts only when picking it would start the installer; the
  switchDevice* copy is gone and "Switch to" reads "Open". Other gateways'
  rail squares use the normal unselected weight instead of an "at rest" dim.
- Docs: multi-connection-desktop.md describes always-connected gateways.
2026-11-01 14:27:53 -08:00
Teknium
343a5f7f58 fix(gateway): background completions that pile up behind a busy turn run as one turn
While a turn runs, every background process that finishes is admitted to the
session FIFO as its own queued turn, so ten finished jobs meant ten
back-to-back "[IMPORTANT: Background process ... completed]" turns after the
current one, each re-reading the whole context and answering one result.

A completion now folds into a completion still waiting at the very end of the
FIFO: the new admission carries both texts, every producer identity and a
"N background process results" header, and cancels the waiting row in the
same transaction (the `replaces` path heartbeat ticks already use). Only the
tail folds, so a prompt queued between two completions keeps its place; a
waiting row claimed first leaves the new completion to queue alone.
2026-11-01 14:17:45 -08:00
Teknium
bd47fe3b63 fix(telemetry): count busy messages that wait behind a running FIFO turn; cancelled rows read as dropped; per-profile home and closing-day peak
- A message the adapter sees as idle (its earlier message's adapter task ended while a queued
  turn runs as a FIFO turn, outside the adapter's session guard) is stamped by the runner's
  running-turn check at FIFO admission and settled there, so a busy chat counts every waiting
  message once. A queued row cancelled later (/stop, /new, refused head, edit) settles dropped
  through SessionAuthority._settle_cancelled.
- A row that is already terminal when admit_message re-reads it counts as reached only for a
  turn outcome (completed / interrupted / failed / steered); cancelled, rejected or deleted is
  dropped / never.
- The arrival's home is the routing identity's runtime profile, not the profile that last ran a
  turn in that chat id (two bots of different profiles in one channel).
- The day's peak of running chats is kept per UTC day, and a day closing after midnight folds
  its own peak before its row is written.
2026-11-01 13:50:05 -08:00
Teknium
a41d1dfca0 fix(telemetry): a busy message saved behind a pause or restart is not dropped; auto-resumed chats count toward their own profile's peak
A graceful stop/restart (runtime_draining) and the session_busy /
unknown_execution pause notices tell the user the message is saved while its
FIFO row stays queued, but the busy-arrival settle recorded dropped/never.
Park the arrival instead: it counts as queued if this process later runs the
row, and not at all across a restart (the existing doc promise). A row read
back as unknown right after commit already started, so it counts as reached.

The startup auto-resume loop claims chats from the launch profile's scope;
pre-assign each claimed chat to the home its turn resolves to, so a resumed
secondary-profile chat no longer counts toward the launch profile's peak.
2026-11-01 13:50:05 -08:00
Teknium
6f55623cc9 feat(telemetry): count messages that arrive while a chat's agent is busy, and the day's peak of busy chats
hermes.gateway.busy_arrival.count: one row per human message that reaches a
chat whose turn is still running (the shared runtime's busy dispatch),
recorded once its fate is known: queued (ran later as its own turn),
steered (steer or interrupt-mode redirect into the running turn),
interrupted (hard interrupt, then ran next), merged (folded into another
busy message of the same burst), dropped (/stop, /new, refused, queue cap),
with the wait from arrival to the moment it reached the agent.

hermes.engagement.day.count gains gateway_peak_busy_chats_bucket: the most
chats of the owning profile with a turn running at once that UTC day, kept
in memory from the runner's running-turn set at every turn boundary
(_persist_active_agents, moved to the agent-cache mixin so the gateway.run
facade does not grow) and folded into the profile's engagement day state.

Both are opt-in through the existing shared-metrics gate; no chat ids or
session keys leave the process.
2026-11-01 13:50:05 -08:00
Teknium
b7ab3f7d85 fix(telemetry): tool names a stable release shipped stay valid after leaving core
Spotify left core (#135389) and the five browser_vault_* tools folded into one
browser_vault after v0.21.6/v0.21.7 shipped them, which dropped spotify,
spotify_* and browser_vault_* from the shared-metrics contract (and spotify /
spotify_* from the v3/v4 schema enums). Pending rows older releases stored
with those names no longer exported as recorded: the drift re-bucket turned
toolset=spotify into custom and tool_name=spotify_search into unknown, and a
tool_unavailable row (no fallback bucket) was left out entirely.

They join RETIRED_TOOL_NAMES / RETIRED_TOOLSET_NAMES, the existing legacy set
for removed core names; recording still maps through the live sets, so no new
row carries them. The v3/v4 schema enums regain the removed values, and the
v4 tool_unavailable enum also gains the contract values it never listed
(browser_vault, set_theme, setup_beat, setup_choose, start_chat).

Tests: the retired-name packaging test gains spotify and browser_vault cases,
and the schema-equals-contract test covers tool_unavailable; both red on
origin/main.
2026-11-01 13:38:10 -08:00
Teknium
005fbe8058 fix(update): stash only what the update collides with, and ask before stashing
`hermes update` ran `git stash push --include-untracked` on every dirty tree,
so any untracked folder in the checkout was hashed into git objects and
deleted from disk, then written back on restore. A 55 GB leftover worktree
copy (2.8M files) made the "stashing before update" step take minutes, and
declining the restore left the whole folder parked in git stash.

- Untracked entries are stashed only when a ref the update can land on
  (target, origin/<branch>, local <branch>) has a file at that path, or a
  parent/child of it; the rest stay on disk via exclude pathspecs, because a
  pull or checkout never refuses on them. Comparison is casefolded so a
  case-insensitive filesystem still counts Config.py vs config.py. Forks and
  unreadable target trees keep the old stash-everything behaviour (the
  upstream sync lands on a ref fetched later).
- An interactive terminal now asks "Keep these changes after updating?"
  BEFORE anything is stashed. Yes stashes and restores without a second
  prompt; no deletes exactly what would have been stashed, so no stash
  entry is left behind. A run with nothing to pull does not ask. Gateway
  /update, --yes and non-interactive (Desktop) paths are unchanged apart
  from the scoped stash.
2026-11-01 10:08:01 -08:00
kshitijk4poor
840d104031 fix(telegram): an uncaptioned video note keeps the group silence notice
group_reply_expected treats an uncaptioned voice note or audio file as spoken
(its words are not in the message text), so it returns None and the silence
notice stays. Video notes now reach the agent too, and a circle without a
caption is the same case: the question is in the audio. Without this it came
out reply_expected=False, so in a group with require_mention off a spoken
question in a circle could vanish behind a bare silence marker.

Tests: the new video-note row of
test_reply_expected_follows_who_the_group_message_addresses fails without the
change (False != None) and passes with it. Docs updated in the same sentence
that lists voice notes and audio files.
2026-11-01 19:35:16 +05:30
kshitijk4poor
94bd083712 fix(mattermost): tidy the user-ID setup hint and move the plugin test
Follow-up to the cherry-picked setup-text fix (salvage of #147215).

- Wizard step 4 and the plugin's security hint now share the same lines.
  Before this they had drifted: only the wizard said where on the page
  the ID is. Step 4 now says what the step is for instead of opening
  with "the profile dialog does not show your user ID".
- Add a route for non-admins: a logged-in browser tab can open
  /api/v4/users/me with its session cookie and get the user's own ID.
  Mattermost reads the session cookie on API requests and only checks
  CSRF on non-GET requests, so a plain GET works.
- The allowlist help text points back at step 4 again rather than
  repeating one of the lookups.
- Docs (en + zh-Hans): indent the curl block under its list item so the
  list no longer splits in two, add the browser route, note that
  `mmctl user list` needs `--all` past 200 users, and use the canonical
  docs URL (the .html form redirects).
- Move the plugin setup test into tests/gateway/test_mattermost_plugin_setup.py
  next to the existing plugin setup tests and its _patch_setup_io helper,
  so it no longer writes a real .env. Drop the assertions that pinned the
  new wording; keep the ones that pin the old, wrong advice and the two
  documented lookups.

Both setup tests fail on origin/main and pass here.
2026-11-01 19:24:04 +05:30
xxxigm
4e89a6d585 fix(mattermost): stop sending setup to a profile dialog that has no user id
Mattermost documents the id on the System Console user page and on
GET /api/v4/users/username/<username>. /users/me with the bot token is the bot.
2026-11-01 19:24:04 +05:30
Teknium
9ed1a7371b docs(hooks): what a pre_llm_call block stores, and that only a returned block blocks
The block sections now say the prompt is stored as the withheld placeholder
(later turns, compaction, session_search, memory providers and review read
only that; transcripts still show what was typed), that the hook runs before
turn-start compaction, and that a callback which raises or times out is
skipped, so the turn goes ahead. observer-hooks.md lists the block return.
2026-10-31 22:59:20 -07:00
Teknium
ad9229c843 feat(hooks): pre_llm_call can block a turn before any inference request
A pre_llm_call callback (Python plugin or shell hook) may now return
{"action": "block", "message": "..."} to veto the turn: no model call is made,
the message is the reply the user sees and the transcript keeps a normal
user -> assistant pair, and the result carries
turn_exit_reason=blocked_by_plugin_pre_llm_call. This is the supported seam for
DLP / privacy / policy plugins that previously had to patch core (#57364).

The vetoed prompt also stays on the host for that turn: no session titling call,
no external-memory prefetch or sync, no background memory review. Its user row
gets an api_content placeholder for the main-loop replay. That alone does not
keep the prompt out of later turns (compaction, session_search and memory
providers read the row's content); the next commit stores the placeholder as
the content.

First valid block wins; a Python block without a message is ignored (same as
pre_tool_call). Shell hooks accept both the Hermes {"action": "block"} and the
{"decision": "block", "reason": ...} shapes, mirroring pre_tool_call.
2026-10-31 22:59:20 -07:00
Teknium
b484be5610 fix(agent): configure stream_max_lifetime through config.yaml only
Drops the HERMES_STREAM_MAX_LIFETIME override (non-secret behaviour settings
belong in config.yaml) and its docs row; tests now set agent.stream_max_lifetime
in a temp HERMES_HOME config.yaml and read it through the real loader.
2026-10-31 22:44:47 -07:00
Teknium
eee418e089 fix(streaming): cap kills name agent.stream_max_lifetime and skip the stale breaker
A stream cut by agent.stream_max_lifetime was counted as a stale kill, so two
capped long replies latched HERMES_STREAM_STALE_GIVEUP and the next healthy
request was refused with nothing sent. The cut also surfaced as a transport
error ("stream attempt N was superseded", "the endpoint looks unreachable").

- cap kills are marked accounted in the stale breaker but never counted;
- the killed attempt's error becomes StreamLifetimeExceeded (a TimeoutError,
  so still retried) naming the setting, and the exhausted notice uses it;
- docs say which transports the cap covers (Chat Completions and Anthropic
  Messages; not Codex/Responses or Bedrock) and that it skips the breaker.
2026-10-31 22:44:47 -07:00
Teknium
ac8037c05b feat(streaming): opt-in cap on a streaming response's total lifetime
The stale-stream detector bounds the gap BETWEEN chunks and resets on every
chunk, so a stream that keeps sending data but never finishes (a gateway
trickling chunks, a runaway generation) is never cut and the turn sits there.

New opt-in agent.stream_max_lifetime (env HERMES_STREAM_MAX_LIFETIME), default
0 = off, so long reasoning streams keep today's behaviour unless the user sets
it. When set, the cap is charged from the start of the current stream attempt,
never resets on chunk arrival, restarts for each retry attempt, and is floored
at the effective stale timeout. Tripping it kills the attempt like a stale
kill: cancel the attempt, abort the request-local client, shut down its socket,
count it once in the cross-turn stale breaker; the retry loop or the
partial-delivery continuation takes over.

Logic lives in agent/stream_max_lifetime.py; the stream monitor calls it from
its poll loop. The Bedrock poll loop is not covered (chat_completion_helpers.py
may not grow).

Port of an upstream idea.
2026-10-31 22:44:47 -07:00
Teknium
66c48cb158 feat(cli): /model reset in the classic CLI, help hint and queued-pick display (salvage #74899)
- Classic CLI (and the Desktop slash worker, which runs this handler): `/model reset` switches
  back, session-scoped (never --global, even under model.persist_switch_by_default), to
  config.yaml's model read fresh at the command, through the normal typed path (guards, confirm,
  session-row persist), and drops an armed --once restore. Already on the default: says so; no
  model.default: says there is nothing to reset to.
- The /model args_hint lists `reset`.
- TUI: a `/model reset` queued mid-turn shows the default it will adopt, not the word "reset",
  and skips the pick-time selection guard (adopting the configured default is not a new pick).
- cli.model.reset_none / reset_no_default in all 17 locales; slash-command and messaging docs.
- Tests: parser invariants, gateway reset of a store-only override after a restart, TUI reset
  that adopts config without re-pinning.
2026-10-31 22:08:49 -07:00
Teknium
25e7f5fc21 test(kanban): pin post-commit kanban_task_blocked for dependency waits
One invariant test (dependency + needs_input control): during the hook a
second connection sees the committed transition and can take the write
lock. Trimmed from the 17-test file in #81339 (Marc D'Aoust). Docs no
longer say the dependency-wait path fires inside its transaction.

Co-authored-by: Marc D'Aoust <daoust.marc@gmail.com>
2026-10-31 22:04:21 -07:00
kshitijk4poor
c419cf7c86 fix(telegram): replies to a channel or anonymous-admin post keep the notice
Telegram fills from_user with a service account (777000 for a linked
channel's auto-forward, GroupAnonymousBot for an anonymous admin) and sets
sender_chat on posts signed by a chat. Those counted as replies to another
member, so in a discussion group with require_mention off a question
commenting on a channel post (including the bot's own channel's post) came
out reply_expected=False and could vanish behind a bare silence marker. A
reply to a chat-signed post is now treated like a reply to an unknown author
(None, the notice stays). Only a reply to another known member is chatter.

_replies_to_other_member had a single caller whose earlier branches already
settle its reply-to-bot and unknown-author checks, so the reply decision is
now one branch in group_reply_expected; _quoted_reply gains its return type.
Behaviour for every existing test row is unchanged.

Tests: the channel auto-forward and anonymous-admin rows fail on the previous
commit and pass here (68 passed with test_telegram_thread_fallback.py).
2026-10-31 15:33:49 +05:30
kshitijk4poor
5bb0e7d87d fix(telegram): uncaptioned voice notes and audio files keep the silence notice in groups
group_reply_expected judges the message text or caption, and a voice note or
audio file without a caption has none: no "?", so it came out
reply_expected=False. In a group with require_mention off, a spoken question
to the bot could then vanish behind a bare silence marker. Voice and audio
without a caption now return None (the notice stays); a captioned one is
judged by its caption, and photos, stickers, documents and locations are
unchanged.

Tests: the voice-note and audio-file rows fail on the previous commit and pass
here; the captioned-voice and uncaptioned-photo rows are controls.
2026-10-31 15:33:49 +05:30
Diego Sánchez
e97cdd16fe fix(telegram): match the WhatsApp rule on unknown reply authors and indented commands
Review follow-ups from a standards audit:
- A reply whose quoted author is unknown is no longer treated as a reply to
  another member, so a question there keeps the notice, as in #133672.
- A command with leading whitespace counts as addressed to the bot, matching
  how the gateway parses commands.
- _merge_into_pending keeps the original seed semantics (get/None) instead of
  setdefault, while staying at the adapter's line cap.
- The photo-batch test now runs the merged turn through the runner's delivery
  path: unaddressed silence is not sent, the addressed batch gets the notice.
- Docs note the unknown-identity, unknown-author and forum-root cases.
2026-10-31 15:33:49 +05:30
Diego Sánchez
dc6519da4a fix(telegram): let a silence marker stand on group messages not addressed to the bot
The Telegram adapter never set MessageEvent.reply_expected, so silence_allowed()
always saw None and every bare [SILENT] / NO_REPLY on a group message became the
"returned only a silence marker" notice, posted to the whole group (#120051).

group_reply_expected (telegram_context.py) sets the per-message signal from #123271,
with the same rule the WhatsApp adapter gets in #133672:
- True for DMs and for a group message addressed to this bot: @mention, reply to
  the bot, wake word (mention_patterns) or /command, in text or a caption. The
  #110952 fallback stays.
- False for a group message addressed to someone else (a reply to another member,
  or one that opens by @mentioning someone else) and for plain chatter. A forum
  topic's root anchor is not a reply to a person.
- None for channel posts, an unknown bot identity, and an unaddressed message with
  a "?", which may be a question for the bot.

Photo bursts and albums merge through absorb_reply_expected, so a batch that
includes a photo addressed to the bot stays True.
2026-10-31 15:33:49 +05:30
kshitijk4poor
e2d8f3606c docs(gateway): two allow_silence limits the room docs did not state
- A thread entry that sets only other keys (e.g. just `model:`) is the first
  matching channel override, so it hides the parent's `allow_silence`; say to
  repeat the key there.
- Since 5cba2718c0 the agent ends a turn on a reply it wrote beside a
  housekeeping-only tool call (memory, todo list, skill management or session search)
  when a complete, addressed turn ends on a bare marker.
  That flag is computed before the room policy is known, so that reply is
  delivered in opted-in rooms too; documented rather than changed, because
  dropping a written answer is the bug that commit fixed.
2026-10-31 15:32:42 +05:30
Nico Suarez
33cf20374d feat(gateway): allow intentional silence per room 2026-10-31 15:32:42 +05:30
kshitijk4poor
4003c210cc docs(security): say which raw CDP params the metadata check reads
The allow_private_urls table and the metadata paragraph now say that raw
CDP checks the URLs a call fetches (url params, injected scripts and
HTML), not text input, dialog answers, cookie scope URLs or request
blocking and interception patterns, and that a URL assembled at run time
is not seen. The old wording claimed every raw CDP param was screened
and that the table row covered only private page URLs. The zh-Hans
browser page drops the claim that a redirect from a public URL to a
private address is still blocked, which the English page already
removed as false.
2026-10-31 14:33:38 +05:30