Commit Graph

13814 Commits

Author SHA1 Message Date
alt-glitch
7c9b019ab5 fix(plugin api): publish hermes_cli.version_info:hermes_user_agent
Eight bundled plugins already build their User-Agent header with
hermes_user_agent: six model providers, the Slack adapter and the
Perplexity web provider. Each was a baselined private import. The name is
now on the published plugin list, with a section in the plugin guide, and
those eight baseline rows go.

The xAI plugins need the same name before tools/xai_http.py can be split:
its hermes_xai_user_agent returns the string
hermes_user_agent("Hermes-Agent") returns.
2026-11-17 15:38:46 +05:30
Teknium
2fee28289b fix: pair the resumed model with its saved route after /model then fallback
A /model switch before the first reply saved the nested gateway_runtime route,
then a fallback serving that first call rewrote only the model column, and
resume read the fallback model with the switched provider. Every route writer
now stamps its model into gateway_runtime, and session_resume_route returns the
model and route together from one record (no replacement row for callers).
2026-11-17 00:22:38 -08:00
Teknium
73523661af fix(cli): --resume restores the picked model after a fallback served the first call
Same bug class as the commit before, on the CLI reader: stored_session_route took the
model from the sessions.model column, which the first accounted call rewrites to the
fallback that served it, and the provider from the pick. A Desktop chat whose picked
model failed once and fell back resumed under `hermes --resume` on the fallback model
sent to the picked provider.

Move the model choice into one shared seam, SessionDB.session_resume_model, beside
session_gateway_runtime, and read it from both resume paths (TUI/Desktop
_stored_session_runtime_overrides and CLI stored_session_route) so the two cannot drift.

Live A/B on the CLI reader against a row a real serve run wrote (pick-qwen picked,
pick 404'd, main-grok fallback served): main -> ('main-grok', 'pickprov'),
head -> ('pick-qwen', 'pickprov').
2026-11-17 00:22:38 -08:00
alt-glitch
69cddd08f4 fix(plugin api): publish agent.retry_utils:parse_retry_after_seconds
Plugins that call a rate-limited HTTP API need to read the Retry-After
header. Discord, Signal and Slack already import Hermes's parser as
baselined private crossings, and the Microsoft Graph client needs it to
move into the teams_pipeline plugin.

- plugin_api.json lists the one name; public-api.md is regenerated.
- plugins/index.md gains a short section with the contract and an example.
- boundary_lint baseline drops the three crossings that are now public
  (Discord, Signal, Slack). No other line changes; a full --update would
  also drop two unrelated stale rows, so it was not used.
- Test: a plugin importing the parser validates with no private-import
  warning, while another name from agent.retry_utils still warns. Red on
  main.
2026-11-17 09:09:45 +05:30
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
Teknium
57c9569047 fix(cli): the session title stays on the status bar after the chat compresses
The classic CLI talks to the gateway and keeps the conversation's creation id
for its whole life. Each compression moves the live segment, and the title with
it, to a new row, so after the first compression the status bar, the glyph
layout's top rule and /title all read an untitled row: the name disappeared and
/title said "no title". A /title set afterwards wrote that stale row, so the
name never came back.

- The CLI reads and writes the title on the conversation's compression tip
  (_title_session_id), for the status bar, /title, /branch's default name and
  the exit summary.
- The gateway store's rename sends the named row's own revision when that row
  is a later compression segment. The resume snapshot carries the owner's
  revision, so a tip rename was a revision_conflict every time.
- A manual /compress that rotates moves the conversation's name onto the new
  segment, as the automatic rotation already does (_title_follows_head).
2026-11-16 12:19:49 -08:00
teknium1
ae2a81ccc0 fix(cloud): answer 'not signed in to Nous Portal' with 409, not 401
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
Live provider canaries / Live provider canaries (push) Has been cancelled
GET /api/cloud/agents answered 401 portal_signin_required when the install
has no Nous Portal sign-in. Every dashboard client reads a 401 as its own
session being refused: the Webapp transport turns any 401 on a no-auth
dashboard into 'sign in to the Webapp', and the dashboard auth contract e2e
(test_scraped_token_opens_every_get_route) flags the route as refusing the
dashboard's own token. Use 409 (state conflict on this install) and keep
detail.code/message, which is what the Settings consumers display.
2026-11-16 11:28:45 -08:00
Teknium
acb28cd184 fix(import): a bot --messaging-off switched off comes back on from the Messaging page
messaging_off() wrote `enabled: false` into every block that set it, but the Messaging page's
switch writes only platforms.<id>.enabled, and gateway.<id> / a top-level <id>: block win later
in the gateway's merge, so a bot spelled there stayed off after the user switched it on. The
other blocks now lose their `enabled` key and platforms.<id>.enabled: false alone holds it off.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
bfc0f9a75b fix(transfer): a gateway that does not start again after the restore is reported, not hidden
If the s6 gateway failed to start after the restore, the import only printed a warning, the
action status reported success and Desktop showed "Transferred" while the agent's bots and
scheduled jobs were not running. The import now prints a GATEWAY_DOWN_LINE the action status
reads into `gateway_down`, and the Desktop done screen says the files arrived but the agent did
not start again and needs a restart (one new string, settings.backup.gatewayDown).
2026-11-16 10:29:52 -08:00
Teknium
f73903b9a4 fix(import): undo removes a profile the transfer brought via profile delete, after its lock is released
Undo rmtree'd a profile home while exclusive_maintenance still held its gateway.lock: on
Windows the open handle fails the delete, on POSIX unlinking the held lock lets another gateway
take a fresh one mid-delete. Undo now tombstones the profile under the reservation (nothing
starts in it), and once the reservation is released (the root gateway still paused) removes it
with delete_profile(yes=True), the `hermes profile delete` flow: service and multiplexer
teardown, identity purge, owner wait, rmtree. A failure there is an import error.
2026-11-16 10:29:52 -08:00
Teknium
ed5ac0dae7 fix(import): merge_env's shortcut compares every host-key assignment
The "already agree" shortcut compared only the first assignment of each host-owned name, but
.env loading takes the last, so a backup with API_SERVER_KEY=cloud then API_SERVER_KEY=laptop
matched a host holding only API_SERVER_KEY=cloud and replaced the cloud's effective key. The
shortcut now compares all host-owned lines in order; anything else takes the normal merge.
2026-11-16 10:29:52 -08:00
Teknium
9d70683b82 fix(transfer): name the Messaging page, not "Settings → Messaging"
Messaging is its own page (sidebar, command palette), not a Settings tab, so a user who opened
Settings looking for it would not find it. Every line this PR adds now names the Messaging page:
the confirm and done screens, the user guide, the CLI reference, the import's printed hint.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
1463df1d22 fix(transfer): a late retried chunk can no longer truncate newer bytes
A dropped request could land after its retry and the next chunk, then truncate at its own
offset and cut the archive. Writes to one upload are now serialized, and nothing is truncated:
a chunk below the current size must match the bytes already there (the rest is appended), a
differing one is refused, and a gap is still refused with offset_gap.
2026-11-16 10:29:52 -08:00
Teknium
0dbd683ae9 fix(transfer): starting an upload reclaims abandoned ones
A canceled or failed transfer never reaches restore, the only place stale uploads were pruned,
so its partial zip (up to 32 GiB) stayed in backups/. A new upload now prunes them too, with the
same one-hour rule, so a live upload from another client is left alone.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
826d9a878b fix(import): a transfer never removes the cloud agent's workspace or HOME dotfiles
Hermes Cloud runs with HOME set to the Hermes home, so the agent's workspace/, home/ and the
container's dotfiles (.ssh, .gitconfig, .config, ...) sit in the root home, and no backup from
another machine carries them. The replace pruned them all. The root's workspace/, home/ and
non-Hermes dot-entries are now never pruned (transfer and undo alike); Hermes' own root
dot-files (.env, .op.env, .anthropic_oauth.json, .hermes_history) are still replaced.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
5342a0a91f feat(import): transferred messaging bots arrive switched off on the cloud agent
A bot token answers to one running Hermes at a time. The transfer now
brings Telegram, Discord, Slack and every other messaging bot over with
its token and settings but switched off, so the computer it came from
keeps answering until the user switches each bot over by hand.

`hermes import --keep-host --messaging-off` (the Desktop transfer route
always passes it; the undo never does): in the root home and in each
profile the archive carries, every bot the archive would run (an
`enabled: true` block, or a token in that home's .env with no `enabled`
set) gets `platforms.<id>.enabled: false`, the switch Settings >
Messaging writes, inside the same merged config.yaml the keep-host
restore publishes. The explicit false sets the gateway's
_enabled_explicit marker, so the env token cannot re-enable it, and
turning the switch on in Settings > Messaging is the only step needed.

The import prints `Messaging switched off: <names>`, the action status
returns them as `messaging_off`, and the Desktop done screen names them.
The confirm note says the bots come over switched off.
2026-11-16 10:29:52 -08:00
Teknium
cb40908b32 fix(import): undoing a transfer removes the profile it brought
Found on the Docker stand-in: after transfer + undo, a named profile the
transfer created stayed behind as a runtime shell (the gateway had started
serving it: cron ticker, logs), because the undo point simply had no files for
it and a profile the archive does not carry is left alone.

The undo point now records which profiles the agent had
(`.keep-host-profiles.json`, never restored as a file). Restoring an undo point
removes, under the same reservation and only after a clean restore, each
profile that is not in that list and not in the undo point: the ones the
transfer brought. A linked profile folder refuses the undo before any write.
2026-11-16 10:29:52 -08:00
Teknium
7473d5dd40 fix(dashboard): chunked transfer routes, bounded at ingress; undo path in import status
- `POST /api/ops/transfer/chunk` + `/api/ops/transfer/restore` (new sibling
  `web_routers/transfer.py`): the transfer arrives as base64 JSON chunks that
  are appended to a file, so every client transport carries it (including the
  Desktop OAuth cookie leg, which cannot do multipart) and nothing holds the
  archive in memory. Each request body is bounded before it is buffered
  (Content-Length check, then a counted stream; 413). The 32 GiB bound applies
  to transfer uploads only; `import-upload` is back to main's form and cap.
- `GET /api/ops/backup/chunk` moved there and reads off the event loop.
- `GET /api/actions/import/status` carries `undo_archive`, read from that
  import's own log section, as soon as the import has written it, also when
  it later fails.
- `GET /api/status` advertises `import_keep_host: 1`, so a client can tell an
  older cloud agent before it uploads anything.
- `keep_host` is accepted once (the JSON body of `/api/ops/import`); the
  server no longer predicts an undo filename.
2026-11-16 10:29:52 -08:00
Teknium
08e252dd29 fix(import): --keep-host is one restore pipeline; undo is a faithful replace
`--keep-host` was a second restore wrapped around `hermes import`: a
`_KeepHostZip` proxy merged every member named config.yaml/.env, a separate
writer published auth.json members without the import's path checks, and a
prune ran after the maintenance reservation was released. Reviews of #156330
reproduced the results: a `../x/auth.json` member written outside the home, a
symlinked skills/ emptied through the link (and missing from Undo), a skill's
templates/config.yaml stripped, a destination-only profile half-emptied while
its gateway ran, comments lost, and an Undo that left the source's
cron/jobs.json behind.

Now keep-host is a per-member policy (`KeepHostImport`) inside
`_import_members_exclusive`, under the same `exclusive_maintenance`
reservation (which also covers every profile the archive writes into):

- Every member goes through the import's own normalize + resolved-root
  checks. Only the root home's config.yaml/.env and the root's and each
  profile's auth.json are merged; everything else, including a named
  profile's config and a skill's files, is copied unchanged.
- config.yaml is written onto the archive's own document with the
  comment-preserving `atomic_config_replace`; auth.json goes through the auth
  store's lock and writer (`_auth_restore_target`, `_save_auth_store`);
  .env under `_env_write_lock`. When the merge changes nothing (an undo), the
  archive's bytes are published as they are.
- Replace: after a restore with no errors, files the archive lacks are
  removed in the root home and in every profile the archive carries (the
  backup's own walk, so links are never entered), and a missing auth.json/
  .env/config.yaml leaves only the host-owned part. A profile only the
  destination has is left untouched. Databases, logs, runtime records,
  lock files, install_id, webapp/ and shared/nous_auth.json stay.
- A folder the archive writes into that is a symlink refuses the import
  before any write.
- The undo point is taken after the gateway drained, under the reservation,
  with the `hermes backup` collector (`_external/` memory-provider files
  included, plus the external files the archive will overwrite). The import
  owns its path and prints `Undo point: <path>`; the last 3 are kept. A
  restore that wrote files and failed leaves a marker; the next keep-host
  import reuses that first undo point. The hidden `--undo-point` flag is gone.
- "Import refused; no files restored" is printed only for a refusal before
  the first write (`KeepHostRefused`, `OwnershipConflict`).
- `s6-svc -O` runs inside the try; an unprobeable s6 slot refuses.

Includes kvnloo's `_external/` undo-point fix (cherry-picked as the previous
commit) and BearHuddleston's root-only merge, both folded into this design.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
Co-authored-by: kvnloo <7121943+kvnloo@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
32bd105fc3 fix(import): --keep-host merges only the root home's config.yaml/.env
A named profile the cloud agent does not have yet arrived without its model,
provider and voice sections: config.yaml/.env were merged by basename, so
profiles/<name>/config.yaml (and a skill's templates/config.yaml) were
stripped against an empty host file. Only the root home is host-provisioned.
auth.json stores are picked by normalized path and the target must resolve
inside the home, so a crafted ../x/auth.json member is refused.

Patch from BearHuddleston's review of #156330.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Kevin Rajan
b3ce5df081 fix(backup): include overwritten external memory files in transfer undo
The --keep-host undo point snapshots HERMES_HOME but its incoming archive
can also replace _external/ provider data under the user's home. Preserve
existing targets in the undo ZIP so undo restores them instead of leaving
the source's data behind. Fail closed if that snapshot cannot complete.

Regression: real import/undo with an external memory-provider archive member
previously left the cloud file overwritten. Thanks to teknium1 for the
backup-and-transfer carrier PR #156330.

(cherry picked from commit d2e2d57711a1487e268e0548e396223290ac64fa)
2026-11-16 10:29:52 -08:00
Teknium
0695cbbbab feat(import): hermes import --keep-host replaces a cloud agent, keeps its host setup
The restore half of Settings > Backup & Transfer. `hermes import <zip> --keep-host` restores a
`hermes backup` archive over an agent whose host provisioned part of it (a Hermes Cloud agent):

- auth.json: the destination keeps its Nous Portal sign-in (providers.nous, nous pool rows,
  active_provider when nous); every other login comes from the archive. Merged against the live
  store under the auth lock; the archive's Nous tokens never land on disk.
- config.yaml: HOST_CONFIG_KEYS (model, providers, fallback*, auxiliary, nous, auth, web, image_gen,
  video_gen, tts, stt, dashboard, webapp, cron, session caps) keep the destination's value.
- .env: NOUS_*, HERMES_*, TOOL_GATEWAY_*, API_SERVER_KEY keep the destination's lines, in place.
- skills/ and memories/ become exactly the archive's (replace, not merge).
- A full backup of the destination is written first (backups/pre-transfer-*.zip, the undo point);
  `hermes import <it> --force --keep-host` puts the agent back.
- In the s6 container the gateway owns state.db, so a plain import refuses it. --keep-host marks the
  gateway's slot run-once, asks it to drain and exit over its control socket (pause-for-update), waits
  for the profile lock, restores, and starts the slot again.

REST: POST /api/ops/import-upload and /api/ops/import take keep_host and answer the undo archive;
the upload gets a 32 GiB bound instead of the 100 MB managed-file cap. GET /api/ops/backup/chunk reads
a dashboard-written backup in base64 slices (JSON-only clients such as Desktop OAuth connections).
GET /api/cloud/agents lists the Nous account's Hermes Cloud agents for a Webapp tab.

Co-authored-by: SHL0MS <SHL0MS@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
teknium1
605037755a fix(update-check): the passive check's git ls-remote dies with the CLI
`hermes chat` starts check_for_updates in a daemon thread. On an official
source checkout (stable by default since 6a92a2aa49) it verifies the
release tag with `git ls-remote --tags origin`, which forks
`git remote-https`. Spawned with a plain subprocess.run, it shared the
CLI's process group and nothing owned it: a /exit while GitHub was slow
abandoned the thread, and git + its helper reparented to init (the 0.23.2
release E2E caught them, test_terminal_transcript_pty[cli-turns]). Its
60s timeout also killed only git, not the helper.

Both remote-touching probes (the stable tag check and _branch_tip's
ls-remote) now go through source_check.remote_git_run ->
bounded_probe_run(owned=True): own process group, handed to the
owner-death supervisor while it runs, the whole group killed on timeout.

The PTY harness sandbox now sets updates.check: false, as tui_pty's
does: the attached `gateway run` (which outlives /exit by design) runs
the same check, and the E2E must not talk to real GitHub.
2026-11-16 10:12:09 -08:00
alt-glitch
43dc9a0a28 refactor(delegation): siblings read config from its owner, not back through the facade
The delegate_tool_* siblings imported names back from tools.delegate_tool
inside functions only so tests could patch `tools.delegate_tool.<name>`
(routes said so: "the facade is the patch seam"). That kept a facade <->
sibling import cycle and a function-level import at each read.

- child_run owns the heartbeat/stale-grace constants (only it reads them)
  and imports _get_child_timeout, _get_subagent_approval_callback,
  _get_worktree_isolation, _resolve_workspace_hint and terminal_tool's
  set_approval_callback at module top.
- config drops `_cfg()` (a loop back to its own `_load_config`) and the
  loop back for `_get_max_concurrent_children`, defined in the same file.
- routes, dispatch and continue import their config getters at module top.
- `_load_config` is read through `delegate_tool_config._load_config` by the
  facade, continue, results and process_registry_notifications, so one
  patch target reaches every reader, as the facade target did before.
- cronjob_tools, process_registry_notifications and subagent_lifecycle read
  these names from their owner; the facade stops importing the names its
  body never used, so a stale facade patch now fails instead of silently
  doing nothing.

Tests move their patches to the module whose code reads the name. Two
worktree tests that patched `_resolve_workspace_hint` on the facade relied
on it reaching both the facade's prompt build and child_run's worktree
setup, so they now patch both readers. Every delegate_tool* module imports
cleanly as the first import in a fresh interpreter.
2026-11-16 21:58:16 +05:30
alt-glitch
c1b2b9c433 refactor(core): stop restating the legacy toolset map in tools_config
_disabled_entry_tools rebuilt the "what does this name select" universe by
hand (resolve_toolset plus a private import of model_tools._LEGACY_TOOLSET_MAP).
It now asks _apply_toolset_selection in enable mode, the same function the
runtime uses, so model_tools stays the single reader of the legacy map.

Identical for every input: valid names resolve through resolve_toolset in both
versions; legacy names (web_tools, terminal_tools, ...) give the legacy tool
list in both; for any other name the disable pass skips it, so the result was
and is empty. A probe over all 73 static, legacy, plugin and unknown names
gives byte-identical results before and after.

A full merge (one LEGACY_TOOLSET_ALIASES expanded by
validate_toolset/resolve_toolset, absorbing tools_config's "hermes" alias) is
left out: it changes the non-quiet "Enabled legacy toolset" label and makes
validate_toolset accept names it rejects today, which every caller of
validate_toolset would see.
2026-11-16 21:57:49 +05:30
alt-glitch
5cc66d503d refactor(core): drop the registry's stale toolset-check map and TOOL_TO_TOOLSET_MAP
ToolRegistry._toolset_checks, its four upkeep sites and _snapshot_state are
gone. The snapshot already overlaid every live entry's check_fn on that map, so
the map could only contribute an entry for a toolset that no longer has a
check_fn member. Such a toolset holds a tool without check_fn and is therefore
always available, and its only reader (banner.py, presence of check_fn on an
unavailable toolset) never sees it. get_toolset_requirements now derives
check_fn from the live entries (last one wins, as before); the
model_tools.TOOLSET_REQUIREMENTS dict at import is byte-identical before and
after (probe).

model_tools.TOOL_TO_TOOLSET_MAP had one reader, batch_runner, which used only
its keys; it now uses get_all_tool_names() and gets the same 73-name set. The
doctor printed TOOLSET_REQUIREMENTS[tid]["name"], which is always tid; it
prints tid. Doc references and the doctor's model_tools stubs follow.
2026-11-16 21:57:49 +05:30
alt-glitch
ec5d1fbc1d refactor(skills): stop swapping skills-module SKILLS_DIR in the dashboard profile scope
_profile_scope wrote HERMES_HOME/SKILLS_DIR onto tools.skills_tool and
tools.skill_manager_tool for every scoped request. Its premise, that both
modules bind the skills dir at import, stopped holding when both gained
_skills_dir(), which resolves get_hermes_home()/"skills" at call time.
_config_profile_scope already sets that home, so the swap wrote the same
dir the resolver returns.

The one import-time reader left, hermes_cli/commands_platforms.py
_iter_gateway_skills, now calls _skills_dir() and so keeps the scoped dir
it got from the swap.

_SKILLS_PROFILE_LOCK stays. Reading every _profile_scope body found
config.yaml read-modify-writes that take no CONFIG_MUTATION_LOCK (MCP
catalog install, platform toggles, PUT /api/config/raw, credential mirror
scrubs); the lock is what keeps them from losing a concurrent
config_write_scope update. Its docstring now says so, and comments that
described the swap are corrected.

test_scope_restores_module_globals tested only the swap and is deleted.
The listing and create cases in test_web_server_skills_profiles.py fail
when _skills_dir() is made import-bound, so they guard the behaviour.

tests/hermes_cli/test_gateway_skill_commands_profile.py covers the Discord /skill list for two
profiles served by one process: each lists its own skill. It fails without this change (the
second profile lists none).
2026-11-16 21:57:07 +05:30
alt-glitch
b3f468205e refactor(code-files): resolve the checkpoint base per call, drop CHECKPOINT_BASE
tools.checkpoint_manager read get_hermes_home() at import into
CHECKPOINT_BASE and kept _CHECKPOINT_BASE_AT_IMPORT so that
_resolve_checkpoint_base() could tell whether a test had patched it. The
constant existed only for tests; product code wants the live profile home.
_resolve_checkpoint_base() now returns get_hermes_home() / "checkpoints".

The one other reader, `hermes checkpoints clear`, checked the import-time
constant for "nothing to clear" while store_status() used the live base, so
under an in-process profile scope it could act on the launch profile's
directory. It now calls _resolve_checkpoint_base(). In a separate CLI
process the import-time and live homes are the same, so its output is
unchanged there.

Tests drop the 37 CHECKPOINT_BASE patches and use the per-test HERMES_HOME
that tests/conftest.py already isolates.

tests/hermes_cli/test_checkpoints_clear_profile.py covers `hermes checkpoints clear` for a profile
with no checkpoints in a process that loaded the module under another profile: exit 0 and
"Nothing to clear". It fails without this change (exit 2).
2026-11-16 21:55:16 +05:30
alt-glitch
6b0e9a0203 refactor(speech): drop the STT lease holder set; the route only warms
The /api/audio/stt-lease route kept a process-global set of lease names
(acquire_stt_lease, release_stt_lease, stt_lease_holders,
_reset_stt_leases_for_tests). Release never unloads anything by design, so
the set's only output was the holder count echoed as `leases` in the
response. No client reads it: the desktop typed the field in
AudioSttLeaseResponse and syncSttLease awaits the call as a readiness
barrier, ignoring the body (rg `leases` under apps/, web/, ui-tui/ hits
only that type). The set was also shared by every profile in the process.

The route now calls warm_stt_provider() under the profile scope when
`active` is true and returns the same envelope without `leases`; release
is acknowledged and does nothing. The request model is unchanged, so
older desktops still send a valid body. The TS response type drops the
unread field in the same commit.
2026-11-16 21:53:44 +05:30
alt-glitch
f8acc26834 refactor(gateway): outbound send files move from tools/ to gateway/outbound/
tools/ holds model tools. These three files register none: they send a
message to a platform for `hermes send` and for cron delivery, through
gateway adapters and gateway config. They move to the gateway package:

  tools/send_message_tool.py    -> gateway/outbound/send.py
  tools/send_message_senders.py -> gateway/outbound/senders.py
  tools/send_message_targets.py -> gateway/outbound/targets.py

Twelve test files move with them to tests/gateway/outbound/. Every importer
changes its import line in place. 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.

Behaviour is unchanged. The logger name stays tools.send_message_tool in
the three files and in the QQ Bot sender that shares it, so the lines stay
under `hermes logs --component tools`. The boundary-lint baseline changes
12 keys and no count, because its keys carry the module path of the
underscore names five bundled plugins import.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 18:09:07 +05:30
alt-glitch
611f0ab757 refactor(cron): three cron helper files move from tools/ to cron/
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
tools/ holds model tools. These three files register none and do cron's
work, so they move to the package that owns it:

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

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

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

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

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; the two gateway contract files are regenerated from
the docstring that names job_args.py.
2026-11-16 17:43:16 +05:30
alt-glitch
c4635985a0 refactor(core): delete unreached send_message actions, clarify/session helpers and backend aliases
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/send_message_tool.py: _handle_list, _handle_react and the action
  dispatch in send_message_tool (every caller, including the external
  hermes-snooze plugin, passes action="send")
- tools/bot_failure_reasons.py: is_auto_retryable
- tools/clarify_gateway.py: _notify_cbs, _coerce_text_response,
  attempt_text_response_for_session, resolve_text_response_for_session
- tools/cronjob_tools.py: the unused task_id parameter of cronjob()
- tools/interrupt.py: is_thread_yield_requested
- toolsets.py: create_custom_toolset
- tools/tool_backend_helpers.py: prefers_gateway, REMOVED_BACKENDS,
  removed_backend_note, normalize_modal_mode (callers use coerce_modal_mode)
- hermes_cli/config_value_checks.py: _validate_web_backends (only read the
  always-empty REMOVED_BACKENDS map)

Tests that existed only for these symbols are deleted; tests that also
cover live behaviour now call the canonical live names
(attempt_text_response, _coerce_text_response_detailed, consume_yield).

The shared-bot route-gate tests that reached the gate through the deleted
react action now call _shared_bot_target_allowed directly, so the origin
rules (guild-only, thread-under-channel and user_id routes, Telegram topics,
the turn's sender in a shared channel) keep their coverage. The two error
hints and one comment that named send_message(action='list') now name
`hermes send --list`; the stale send_message row in the zh-Hans tools
reference goes.

Also:
- test_messaging_slash_command_fifo spies on clarify_gateway.attempt_text_response,
  the name gateway/run_inbound.py calls, so its [clarify] case can fail again
- send_message_tool: an action other than 'send' returns an error that names
  `hermes send --list` for listing targets
- multi-profile-gateways.md no longer says send_message sends reactions; the zh-Hans
  simplex.md and tools-reference.md match the English pages
2026-11-16 15:40:08 +05:30
alt-glitch
dd478aa3f3 refactor(connectors-mcp): delete unreached connector and MCP OAuth 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/openrouter_client.py (whole module; check_api_key had test callers only)
- tools/connectors/gateway/__init__.py: re-exports and __all__ (every importer names a submodule)
- tools/connectors/gateway/wire.py::WIRE_BATCH_MAX
- tools/managed_gateway_auth.py::managed_gateway_origin
- tools/discord_tool.py::_detect_capabilities
- tools/mcp_tool_health.py::MCPServerHealthMixin.ensure_healthy
- tools/mcp_oauth.py::build_oauth_auth, HermesOAuthClientProvider, _oauth_port
- tools/mcp_dashboard_oauth.py::DashboardOAuthFlow.profile (write-only field)
- tools/mcp_tool_events.py::EVENT_UTILITY_KEYS
- agent/tool_guardrails.py: mcp_filesystem_* entries in IDEMPOTENT_TOOL_NAMES
  (MCP tools register as mcp__<server>__<tool>)

Tests that covered live code through a deleted symbol now call the live path
(MCPOAuthManager().get_or_build_provider, _fetch_capabilities,
build_vendor_gateway_url); tests that only exercised deleted code are removed.

Kept on purpose: _SSH_HINT_PROXY, its branch, the redirect_uri parameters and
build_provider_kwargs' ssh_proxy_hint. Nothing reaches them today, but they are the
proxy-user hint from d0afcb125ce; wiring it into MCPOAuthManager is a separate fix.

test_cache_is_keyed_by_token now covers _detect_capabilities_nonblocking (two tokens,
memory and disk). ensure_healthy leaves the SuspectableBackend Protocol, which no
backend implements any more.
2026-11-16 15:39:10 +05:30
alt-glitch
40492aca4e refactor(environments-terminal): delete unreached vercel helpers, CredentialRef, failed_start and exit-137 hint
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/environments/vercel_sandbox.py: _exception_chain, _extract_status_code,
  _RETRY_BACKOFF_STEP, _MIN_SANDBOX_TIMEOUT, _MIN_RUNNING_WAIT,
  _RUNNING_WAIT_POLL_INTERVAL, _STOP_TIMEOUT, _STOP_POLL_INTERVAL,
  _SNAPSHOT_STORE_NAME
- tools/environments/sandbox_scope.py: CredentialRef (docstring in
  agent/terminal_env_provider.py and the terminal-environment-plugin guide no
  longer name it)
- tools/environments/streams.py: supports_streams() (the provider attribute of
  the same name stays)
- completion_reason "failed_start": its producer left in cd818a4d054; drop the
  lookups in process_registry_notifications._REASON_STATUS (and its
  "Failed to Start" branch), cli_process_dock._STATUS_BY_REASON,
  ui-tui processRoster REASON_STATUS, and the field comments
- tools/terminal_hints.py: _EXIT_CODE_HINTS[137] (exit 137 always carries a
  SIGKILL exit note, which gates annotate_failure off)
- ProcessRegistry._config_value: unread `fallback` parameter
2026-11-16 15:23:37 +05:30
alt-glitch
782e0b42c9 refactor(code-files): delete unreached sandbox gate, checkpoint helpers, py shell linter
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/code_execution_tool.py::SANDBOX_AVAILABLE (constant True) and its
  two `if not SANDBOX_AVAILABLE` branches; the duplicated gateway-lifecycle
  comment in execute_code
- tests: test_windows_returns_error (only flipped the constant) and the
  constant's monkeypatch in test_execute_code_lifecycle_guard_deadline
- tools/checkpoint_manager.py: the no-op `store = _store_path(base)` /
  `_ = store` pair in _migrate_legacy_store; unused imports
  clear_stale_tmp_packs, rmtree_readonly, Dict, List, Set, Tuple;
  _list_project_refs (test-only) and its one assertion
- hermes_cli/cli_auto_maintenance.py::_run_checkpoint_auto_maintenance
  (imported by cli.py, never called), its cli.py import, its orphaned
  `threading` import and its no-op test monkeypatch
- tools/file_operations.py::ShellFileOperations._run_python_snippet
- tools/file_operations_lint.py: the '.py' entry in LINTERS (the in-process
  LINTERS_INPROC['.py'] always answers first)

- test_profile_rename_checkpoints: assert the migrate-identity retry deletes the leftover old checkpoint ref (via _ref_tip), replacing the deleted _list_project_refs check.
- docs(checkpoints-and-rollback): auto-prune runs only on the gateway housekeeping tick; the CLI never runs it.
2026-11-16 15:22:48 +05:30
alt-glitch
4b7b02e51d docs: imports go at module top; drop the late-import advice
The package recipe told topic modules to late-import their facade inside
functions and named PEP 562 __getattr__ as the cure for an import cycle.
A cycle is fixed by moving the shared name into a lower module both
import; __getattr__ stays for a measured startup cost. Four more lines in
agent/, hermes_cli/ and tools/ AGENTS.md described in-function imports as
the way siblings reach their facade; they go too.
2026-11-16 14:55:12 +05:30
alt-glitch
a54c755ce3 refactor: make the utils file metadata helpers public
Rename _preserve_file_mode, _preserve_file_owner, _restore_file_mode and
_restore_file_owner in utils.py to preserve_file_mode, preserve_file_owner,
restore_file_mode and restore_file_owner. hermes_cli/backup_restore.py
imports all four, and the repo rule forbids importing private names across
modules. Bodies are unchanged; the importer, its docstrings and the tests'
patch targets use the new names. No alias for the old names.
2026-11-16 14:12:51 +05:30
alt-glitch
56f44c6f7a refactor: read JSON sidecars through utils.read_json_or_empty
Six private readers repeated the body of utils.read_json_or_empty
line for line: read utf-8-sig, return {} on OSError or ValueError,
return {} for a JSON value that is not an object.

rich_sent_store._load and stuck_loop_counts._read_counts only took a
path, so they are deleted and their callers call read_json_or_empty.
prune_advisor._read_estimate, webapp_access._registration,
left_core_migration._auth_store and local_runtime.recovery.read_state
compute their path, so they keep their names and read through the
shared helper. utils is imported inside the function where the module
already imports utils lazily, so module import cost is unchanged.

boot_bootstrap.read_last_known stays: it is boot code that imports no
utils, and it is a public name other modules import.
environments/base._load_json_store stays: modal.py and
vercel_sandbox.py import it.
2026-11-16 13:56:35 +05:30
alt-glitch
a6498a999b refactor: utils drops its sys.modules lookup of the worker config policy
utils._frozen_config_worker read sys.modules['agent.safe_worker_policy'] so that
file_cache_version and racy_content_digest kept a config.yaml key stat-only inside a
worker whose config is a frozen snapshot. That reached a first-party module with no
import statement, and gave utils a dependency on the agent package.

The config layer now owns the decision at the two sites that key a profile's
config.yaml inside such a worker: FileBackend.cache_version (behind
config_cache_version) and free_tier_bootstrap._config_stamp. Each keeps the key's
layout and leaves the digest empty. utils' own keys are now the same in every process.

Inside such a worker, three readers that open a config.yaml anyway (the managed
overlay, load_yaml_file_readonly, a parse-failure record) now hash it while it is
under 2 s old, as they do in every other process.
2026-11-16 13:55:18 +05:30
Gille
6606ba3345 refactor(desktop): read the SSH timeout keys in their own module
The code-health check caps main.ts, config_defaults.py and
readDesktopLaunchConfig at their size and complexity on main.

The two keys are now read by desktop-ssh-budgets.ts, which main.ts calls
once with the config.yaml text it already has. The Windows env slice for
the ssh resolver moves into ssh-binary.ts so main.ts does not grow. The
launch-config reader and config_defaults.py are back to what they were.

Refs #132508
2026-11-16 00:47:42 -05:00
Gille
8a349cc3ae fix(desktop): take the SSH connect and forward timeouts from config.yaml
Moves the override from two HERMES_* environment variables to
desktop.ssh_connect_timeout and desktop.ssh_forward_timeout, in whole
seconds up to 120. These are non-secret behavior settings, so they belong
in config.yaml. They are read once before the first window, the same way
desktop.ssh_path is, and passed to every SSH connection the app opens.

The value is validated in full. Only a positive whole number counts.
Values like "45s" or "1.5" are ignored with a startup warning and the
15 second default is kept, instead of being read as a numeric prefix.

Refs #132508
2026-11-16 00:47:42 -05:00
Teknium
4a89bc6c02 feat(cache): one prompt-cache clock per session; Nous 5m ceiling as data
Every consumer that needs "when does this session's cached prompt expire?" now reads one
answer, agent/prompt_cache_clock.py:cache_window(), instead of re-deriving it from _cache_ttl.

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

Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
2026-11-15 12:04:54 -08:00
Maciej Lisiewski
94f991f473 fix(approval): prompt before shell verbs destroy the Hermes home or its stores
rm/unlink/shred/truncate/mv of HERMES_HOME itself or a protected store
(state.db, sessions/, vault/, mcp-tokens/, ...), and cp/install/rsync/dd/tee/
redirection onto a store, were auto-approved: the patterns only special-cased
config.yaml and .env, and the resolved-home fold skipped the bare home word.
sqlite3 write verbs on a store prompt too, keyed on the verb rather than a
missing WHERE (`where 1=1` wipes the same rows).

The protected-store list moves to hermes_cli.home_data_layout so the file
tools' write deny and the shell gate share one source of truth. Prompt-grade
(DANGEROUS), not hardline: backup/doctor flows legitimately touch these paths.
Hardening (SECURITY.md §3.2), not a boundary.

Fixes #109367
2026-11-15 20:10:41 +01:00
Maciej Lisiewski
066208f43b fix(approval): prompt on registry writes, not just registry deletes
Only `reg delete` and `Remove-ItemProperty -Force` were gated, so
`reg add/import/copy/restore/load`, `setx` and `Set-/New-ItemProperty`
changed persistent machine state (Run keys, HKCU\Environment) with no
approval prompt. Add them next to the delete rules; read verbs stay
quiet. `approvals suggest` treats any registry class as unsafe, since a
registry write outlives the session that approved it.

Hardening (SECURITY.md §3.2), not a new boundary.

Fixes #132202

Co-authored-by: Sahil Vishnalya <222165401+Sahilvishnaliya@users.noreply.github.com>
2026-11-15 16:02:32 +01:00
Maciej Lisiewski
4df12d720e Merge pull request #155345 from NousResearch/sec3/95311-files-home-cred-denylist
fix(dashboard): hide OS/CLI credential stores from the managed Files API
2026-11-15 15:35:27 +01:00
Maciej Lisiewski
5f7e3501e7 Merge pull request #155348 from NousResearch/sec3/102317-eval-hardline
fix(approval): surface eval payloads to the hardline floor
2026-11-15 15:35:04 +01:00
Maciej Lisiewski
d445e56014 Merge pull request #155458 from NousResearch/sec3/129165-secret-line-redaction
fix(redact): mask every line of an applied secret-source key (stacked on #155274)
2026-11-15 15:34:19 +01:00
alt-glitch
7defffc296 fix(lint): clear the findings ruff preview reports
Turning on ruff preview (needed for PLW1514, unspecified-encoding) also
widens some stable rules. Clearing what it reports first lets the config
change that enables it land with no ignore list:

- evals workers: 20 text-mode open() calls get encoding="utf-8".
- a2a and weixin adapters: legacy "# type:" comments become annotations.
- agent/lsp/client.py, gateway/run_turn.py: two prose comments started a
  line with "type:", which type checkers read as a type comment.
- sorted(x)[0] becomes min(x) (plugins_session_env, one test).
- test_plugin_session_fork: the attempts default is built per call
  instead of a shared list inside a tuple.

The pinned ruff 0.15.22 passes with today's config and with preview on.
2026-11-15 14:02:40 +05:30
Siddharth Balyan
b2c6bc4e1e fix(usage): provider limits first, Nous balance apart
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Canary Release / Tag, draft, and start the canary build (push) Has been cancelled
Canary Release / Prune canaries older than 14 days (push) Has been cancelled
Squashed onto main (#151819). The session.usage conflict with #141859 keeps the
branch side: _usage_nous_fields already reads the Nous fields inside the
session profile scope.

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

agent.account_usage keeps the names that moved to agent.account_usage_nous (and
BP_FULL): plugin_api.json publishes the whole module, and catalog plugins import
build_credits_view and build_nous_credits_snapshot from it.
2026-11-15 08:20:26 +05:30