Commit Graph

1124 Commits

Author SHA1 Message Date
Teknium
e1be6fcfe0 fix(config): config_keys come from the loader's discovery, count only for active plugins, never widen a section
Review findings on the config_keys seam:

- Discovery: drop the glob scan. config_keys is parsed onto PluginManifest
  (plugin.yaml, and extensions.com.nousresearch.hermes in a portable
  plugin.json) and read from the loader's own collect_directory_manifests +
  entry points + resolve_manifest_winners, so skip rules, precedence and the
  project-plugin gate are the loader's.
- Only active plugins count: gate_manifest must load the plugin (disabled wins,
  plugins.enabled opt-in, requires_hermes); memory providers count when
  memory.provider selects them.
- Bounded: a declared path is at least two segments deep and is ignored when
  DEFAULT_CONFIG already defines it; runtime keys are consulted only after the
  schema walk refused a key, so a plugin declaring [agent] no longer hides
  agent.max_turnz.
- No lru_cache: a plugin installed or enabled in a long-running process counts
  on the next config get/set (the lookup runs only for refused keys).
- computer_use.backend (read by the plugins/computer_use selector) and
  dashboard.kanban move to a core table with their readers; the selection
  sections derive from read_selection's own _SELECTION_NAME_KEYS.
- Tests use fixture plugins (enabled/disabled, hostile [agent], selected memory
  provider, portable plugin.json, project opt-in).
2026-10-28 13:09:00 -07:00
Teknium
e402afa783 fix(config): recognize runtime-read selection and plugin-declared keys in config get/set
`hermes config get browser.cloud_provider` / `browser.use_gateway` warned "not a recognized
config key" although the runtime selects the browser provider from them. The validator only
walks DEFAULT_CONFIG, and provider selections stay unseeded on purpose (a stored key is the
explicit pick), as do core-section keys plugins read.

- tools.tool_backend_helpers.selection_config_keys(): the keys read_selection() honours
  (<category>.use_gateway, browser.cloud_provider, stt/tts/image_gen/video_gen provider keys,
  web.backend/search_backend/extract_backend).
- plugin.yaml / dashboard manifest.json `config_keys`: a plugin names the core-section paths it
  reads; declared for retaindb, byterover, computer_use/cua, kanban dashboard.
- hermes_cli/config_runtime_keys.py consults both before the DEFAULT_CONFIG walk.

Found on Hermes Cloud staging.
2026-10-28 13:09:00 -07:00
Teknium
714eab92e9 fix(config-remote): an explicit config set is stored even when it equals the inherited value
`hermes config set display.skin ares` with `ares` already supplied by an
upper level printed "Set ... in Remote Config" but sent no PATCH: the
document save diffed the key away as unchanged. A later upper-level
change then replaced the user's choice.

Keyed Changes.set and keys named in a new `pinning_keys()` block (the
CLI's `config set` document save) are now sent even when unchanged,
matching the file backend, which always writes them to config.yaml.
A key a lock already freezes is skipped, not refused.
2026-10-27 17:33:48 -07:00
Ben Barclay
fd44f481ef fix(config-remote): hermes config edit exits 1 when the backend has no config file
The refusal printed to stderr and exited 0, so a script could not tell it from a successful edit.
It now exits 1 like the other config refusals (_exit_invalid). The managed-install refusal next
to it still exits 0: every managed_error caller (set, unset, save, update) shares that behaviour,
and changing it is outside this PR.

Addresses teknium1's P3 (config edit refusal exits 0) on #122509.
2026-10-27 17:33:48 -07:00
Ben Barclay
e4374020bd fix(config-remote): adapt the remote backend to the seam as merged in #134362
puts back what that build deliberately left for the remote backend, on
main's seam shape:

- RemoteBackend implements main's protocol (read_user_doc, probe_readable)
  and is not a FileBackend; _route returns (backend, home) and explicit
  files go through _ExplicitFile, so the is_layer branches are gone.
- One bootstrap: _ensure_bootstrap_env / bootstrap_deployment select the
  backend from the process env, the launch home's .env and the managed .env.
  #134362's _dotenv_backend_override did not survive its file-only refactor,
  so nothing stacks; its rules are now tests (stale shell remote + .env file
  boots file; empty .env value resets to file; .env-only remote selects
  remote; an absent key keeps the shell value).
- The file-tooling gates main removed (backup/import/snapshot restore,
  config edit, migration write-back, config backups, profile clone and
  distribution install, raw config editor, xAI migration, gateway --config).
- profile_serve_signature uses the backend version for config.yaml.
- restore_config_model_settings_if_rewritten is a no-op without file tooling.
- PM's dependency runtime reads a home's selection from the local file it
  publishes to (config_backend.local_file_layer), so a remote deployment
  never needs the plane there or fails PM closed.
- Ratchet: _container_slots/_validate_quoted_containers move to
  config_value_checks, _count_cron_jobs to backup_restore, the gateway
  --config load to gateway/config_loader.
2026-10-27 17:33:48 -07:00
Ben Barclay
b8a41f7bf2 fix(config-remote): review round 9b: guard reads keep the caller's read base, dashboard model saves mask inherited route keys, MCP ack checks every toggle field
1. _write_config_state (atomic_config_write: /verbose, /footer, ...) runs its no-omission guard
   read under keeping_read_base, like save_config, so a poll between the caller's read and its
   save no longer becomes the base its stale document is diffed against.
2. Dashboard / profile model assignments (_apply_main_model_assignment: POST /api/model/set,
   profile builder, custom endpoints) share persist_model_selection's semantics under Remote
   Config: apply_model_selection(mask_cleared=True) stores null for a cleared key the effective
   block holds, and remote_model_selection_guard refuses the whole assignment when any changed
   model.* key is locked (a bulk save would otherwise omit it and land a half route).
   persist_model_selection now builds its keyed write from the same _merge_selection_updates.
3. profiles.configure MCP acknowledgement compares enabled AND the legacy disabled field per
   server, so a lock that kept disabled: true reports mcp_servers unapplied.

Regressions (each fails with the production change reverted):
test_poll_between_read_and_atomic_config_write_sends_only_the_callers_edit,
test_dashboard_model_switch_masks_inherited_endpoint_credentials,
test_dashboard_model_switch_refuses_whole_assignment_on_a_locked_route_key,
test_profile_editor_reports_mcp_unapplied_when_legacy_disabled_cleanup_is_locked.
2026-10-27 17:33:48 -07:00
Ben Barclay
b1bbb51e21 fix(config-remote): review round 9 blockers: read-based save diff, masked inherited route keys, honest editor acks, UTF-16 bootstrap parse
1. A document save is diffed against the base the saving context READ (per-context
   _READ_BASE recorded by read_user_layer / read_user_doc_readonly / version and after the
   context's own acknowledged write), not against whatever a poll installed between the read and
   the save. save_config's fail-closed guard read keeps the caller's read base. A poll before save
   no longer turns its changes into our unsets/sets with the current expectedVersion.
2. persist_model_selection (remote): a key the switch clears that the effective model block
   still holds is stored as null ("no value", contract 5.4), not unset at the profile level, so
   an upper-level old-endpoint api_key/key_env/api_key_env/context_length stops applying at the
   new endpoint. New config_backend.write_changes carries explicit nulls.
3. profiles.configure: skills / toolsets / MCP sections report applied only when the section
   reads back as written; a bulk save that dropped a locked key is no longer acknowledged.
4. _dotenv_assignments decodes UTF-16 (BOM) and strips NULs as the runtime sanitizer does, so
   stage2 / first-read selection agrees with the backend the runtime boots.

Regressions (each fails with the production change reverted):
test_poll_between_read_and_save_sends_only_the_callers_edit,
test_model_switch_masks_inherited_endpoint_credentials,
test_profile_editor_reports_a_locked_skills_edit_as_not_applied,
test_stage2_decides_like_the_runtime_for_utf16_dotenv[utf16-bom|utf16-no-bom].
2026-10-27 17:33:48 -07:00
Ben Barclay
2e36106171 fix(config-remote): config set/unset name Remote Config, not a config.yaml that is never written
With HERMES_CONFIG_BACKEND=remote the success line printed get_config_path() although the write
went to the plane's profile level and no local file exists. The backend now names its write
destination (ConfigBackend.destination); the file backend keeps the path byte for byte.
2026-10-27 17:33:48 -07:00
Ben Barclay
69d037b349 feat(config): remote config backend (HERMES_CONFIG_BACKEND=remote)
plugins/config_backends/remote serves each profile's user layer from the
config plane: boot fetch inside load_hermes_dotenv with bounded retry and
fail-closed exit (D2), per-process ETag poller (D9), key-level diff writes
with CAS and one conflict retry (D10), client-side lock and secret-literal
checks (D7, D17), in-memory migrations (D12), managed config.yaml ignored
(D18), plane credential from auth.json or IdP client credentials only and
never from a secrets: source (D26, D32). Vendored gg conformance fixtures
run against the lock matcher, secret rule and _deep_merge.
2026-10-27 17:33:48 -07:00
Teknium
76f2fdb794 fix(cache): a rotated key, token or same-size edit is never served stale from a file cache
Every cache keyed on a file's stat signature had the bug the config caches had: a same-size
in-place rewrite in one coarse timestamp tick keeps mtime, ctime, size and inode, so the older
parse was served for the rest of the process. Move the helper to utils.file_cache_version
(file_signature + content digest while the file is under 2 s old; always_digest for signatures
compared much later, where the racy digest going empty would read as a change) and key every
cache that can hold a secret, token, pairing/allowlist, route or config on it:

- auth.py: global auth-store memo, Nous auth-status memo (was mtime only)
- gateway/pairing.py approved-users cache (a revocation kept access)
- run_profile_reconcile: served-profile signature (always_digest: a false change reconnects
  adapters) and the hook-consent signature
- webhook dynamic routes (route HMAC secrets), Feishu comment pairing/rules cache (mtime only)
- MCP OAuth tokens-file reload check (mtime only; always_digest: a reload tears the session down)
- config parse-failure record (always_digest), named-custom-provider memo, model aliases,
  gateway.standalone memo, profile model read, MoA preset, agent raw config,
  tui_gateway raw config cache, onboarding due stamp, free-tier inventory stamp,
  provider model-list credential fingerprint, git safe.directory key, skills prompt
  manifest

config_cache_version takes its stat through config_version, so its errors and seams are unchanged.
Left alone: the tool-definition cache key and the platform manifest stamp (a safe worker must
never open config.yaml or a plugin file; the MoA preset cache is skipped in one instead) and the
CLI MCP watcher seed (pinned to file_signature by a main test).
2026-10-27 12:57:09 -07:00
Teknium
5f02a8c19e fix(config): a same-size config.yaml rewrite in one timestamp tick is no longer served stale
Every config parse cache (load_config, read_raw_config, load_user_config_effective,
read_config_doc_readonly, the managed overlay) keyed on the stat tuple
(mtime_ns, size, ino, ctime_ns). On kernels without multigrain timestamps a
same-length in-place rewrite (port 3 -> 5, k-old -> k-new) in the tick of an
earlier read keeps all four, so the older parse was served for the rest of the
process: a rotated api_key never reached a follow-profile session and the
route stayed on the old endpoint. That is the CI flake in
test_rotated_key_reaches_follow_and_held_pick_on_a_fresh_owner_and_routes_are_never_mixed
(got port 3, expected 5).

Caches now key on config_cache_version(): the backend's version plus a content
digest while the mtime is racy (younger than utils.RACY_MTIME_WINDOW_NS, the
same "racily clean" rule the change watcher and roster already use), read
before the parse it guards. Settled files cost no extra read; config_version()
itself is unchanged, so change watchers and the parse-failure record see no
spurious change when a file settles.
2026-10-27 12:57:09 -07:00
Teknium
2f644f3fed Merge origin/main into copilot-seams/integration
Conflict: hermes_cli/env_loader.py import block. Kept the branch's
left_core_migration.profile_env_names import and main's ConfigBackend
switch (load_yaml_file_readonly no longer imported; _load_secrets_config
reads through config_backend.read_config_doc_readonly).

No main commit since 0c771d7a5b touches Copilot code; nothing to port.
2026-10-25 21:02:41 -07:00
Teknium
889d753725 feat(left-core): migration rows for a model provider that moved to a plugin
LEFT_CORE rows gain three generic fields for a model-provider plugin:

- providers: the ids and aliases the plugin's profiles register. A name
  nothing resolves to gets the install line appended on every "unknown
  provider" surface (runtime resolution / Desktop error text via
  auth.resolve_provider, /model, `hermes model`, `hermes auth add`);
  resolve_runtime_provider installs the plugin first for a home that uses it
  (the CLI and Desktop resolve the provider before the agent whose start runs
  the migration exists); and hermes_cli.providers.get_provider never lets the
  models.dev catalog stand in for such a name while the plugin is not loaded
  (models.dev lists `github-copilot` at api.githubcopilot.com with
  GITHUB_TOKEN: it would have sent a raw GitHub token there).
- profile_env: env names core kept profile-managed. env_loader's
  _PROFILE_MANAGED_ENV_KEYS and config._EXTRA_ENV_KEYS read them statically
  (env_loader runs before discovery), and the generic env writers refuse them
  while the plugin is absent (the executable/argv authority its profile
  declares once installed).
- notice: one more per-home sentence on every migration outcome.

First consumer: the github-copilot row (providers copilot + copilot-acp and
every alias). It is in use when copilot/copilot-acp is a provider the home
routes through: model, fallback chain, auxiliary tasks, delegation and its
fallback chain, MoA presets, cron job pins, auth.json active_provider, or
HERMES_INFERENCE_PROVIDER. A GH_TOKEN alone is not use. COPILOT_GITHUB_TOKEN
and the two base-URL overrides stay out of children as provider env (Tier 2),
as when core shipped Copilot. Its notice tells a profile with no token the
plugin reads (no COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN, no `manual`
credential-pool row or providers.copilot login: a gh_cli pool row was seeded
from `gh auth token`) to run `hermes auth add copilot`; the plugin no longer
reads gh or the Copilot CLI's token files. Read-only, never runs gh.

The unknown-provider hint helper moves out of auth.py (over the size cap)
into auth_error_copy.unknown_provider_hint.
2026-10-25 20:47:10 -07:00
Teknium
bbe207c593 refactor(config): ship the seam with the file backend only
The seam had a selector and reserved members that nothing in this PR
uses: HERMES_CONFIG_BACKEND accepted only `file` (every other value
exited), the .env override existed only to decide when to refuse,
UserLayer.locks/provenance and ConfigBackend.locked() were always empty,
and the supports_file_tooling()/require_file_tooling() checks at ten
file-copy sites were always true. All of it is for the remote backend
(#122509), so it lands there with the code that makes it real.

get_config_backend() now returns the file backend. The env var, its
docs row, the dotenv override, ConfigBackendUnavailable and the
file-tooling gates are gone, with the tests that covered them. The
explicit-file routing test now proves a non-config.yaml path never
consults the backend.

probe_config_readable() calls a probe_readable() protocol method
instead of an isinstance(FileBackend) check, and version_token()
documents how it treats an int-led version.
2026-10-25 18:54:09 -07:00
kshitijk4poor
adebe1f8be fix(config): gate the readers main added since the rebase; adopt main's lint rules
Rebasing onto current main brought in direct config.yaml readers that the
seam's reader gate (scripts/check_config_yaml_readers.py) now rejects:

- gateway/session_config.py: the session `config.get mtime` getter uses
  config_exists/config_version + the TUI's _version_token, like
  tui_gateway/methods_config.py already does.
- hermes_cli/profiles.py: _strip_multiplex_flag checks config_exists.
- hermes_cli/config_backups.py: the byte comparison sits inside the
  supports_file_tooling()-gated block; marked like its siblings there.
- hermes_cli/update_receipt.py: _bare_collection_enabled runs in the bare
  bootstrap interpreter with no config stack; presence stat marked.

Main also turned on UP006/RUF100/B009 since the branch base: builtin
generics in the seam's new modules, stale noqa comments dropped, and the
newly unused typing imports removed.
2026-10-25 18:54:09 -07:00
kshitijk4poor
8c63d46098 fix(config): address Greptile's third review of the config backend seam
- pm read_home_selection: only a missing config.yaml means "no config". A symlink loop or
  permission error used to look like "no file" (config_exists is Path.exists), so PM published a
  dependency generation without that home's plugins; it now refuses like any unreadable config.
  The stat runs before the YAML stack (FileBackend.version_path stats before importing utils),
  so PM's bare runtime tree still needs no YAML for a home without config.
- check_config_yaml_readers: alias bindings iterate to a fixed point instead of two passes, so
  `first = home / "config.yaml"; second = first; third = second` binds `third` too.
- ConfigIssue/_issue move to hermes_cli/config_issues.py, imported by the facade and its check
  siblings, so config_value_checks.py / config_home.py no longer import the facade at all.
2026-10-25 18:54:09 -07:00
kshitijk4poor
ab3e4affd6 fix(config): meet the code-health ratchet and keep pm's runtime tree off the YAML stack
CI on the salvage was red on the code-health ratchet (over-cap facades grew; two blind excepts)
and on the pm observer fixture, whose isolated source tree carries pm/ + hermes_cli/ but no utils.

- config_backend imports become module-level in the facades (it imports only stdlib); gateway,
  auth and telegram take config_exists through the hermes_cli.config import they already have.
- Pure helpers move to topical siblings, offsetting the growth: _csv_or_list_to_set ->
  gateway/run_common.py, the dotted config-path pair -> hermes_cli/backup_restore.py, the
  voice/timezone/web-backend checks -> hermes_cli/config_value_checks.py, _load_config_dict ->
  hermes_cli/profile_memory_config.py (both callers are memory-provider code).
- _load_config_dict catches YAMLError/OSError/UnicodeError instead of Exception.
- _load_config_cache_hit probes readability with config_backend.probe_config_readable (a 1-byte
  read through the backend's open) instead of a full parse plus a blind except.
- pm/plugins_state.read_home_selection checks config_exists before importing the YAML stack, so
  a home with no config never needs utils.
- developer-guide/config-backend.md describes this build (file backend only).

Same approach as @benbarclay's 74421be709 in #122509, which does not cherry-pick onto current main.
2026-10-25 18:54:09 -07:00
kshitijk4poor
5300dced68 refactor(config): drop the unused config_exists import from hermes_cli.config
The version-stamp read moved to config_version_stamp.py in the rebase, leaving config.py
importing config_exists with no caller (ruff F401). Also drop a DEFAULT_TREES membership
assert that rode inside every parametrized binding-form case.
2026-10-25 18:54:09 -07:00
Ben Barclay
871900df63 feat(config): route every user config.yaml read and write through a ConfigBackend seam
Add hermes_cli/config_backend.py (config-config design §4.1, D10/D11): a
ConfigBackend protocol, the FileBackend (today's behaviour), selection by
HERMES_CONFIG_BACKEND only (default file; 'remote' and unknown values fail
closed with ConfigBackendUnavailable), and path-level helpers
(read_config_doc, read_config_doc_readonly, config_version, config_exists,
write_config_key, write_config_document, supports_file_tooling).

Migrate every direct reader/stat/exists/bypass writer of a user config.yaml
to the helpers (config.py loaders + caches, config_effective, env_loader,
gateway, TUI, CLI watchers, cron, tools, profiles, logging, time). File
tooling (config edit, backups, xAI migration rewrite, raw dashboard editor)
checks supports_file_tooling() first; migrations skip write-back without it.

Add scripts/check_config_yaml_readers.py (CI lint next to the writers gate)
that rejects a direct read of a config path outside the backend.
2026-10-25 18:54:09 -07:00
Teknium
cd4433dd0e refactor(acp): delegation.command and launch-env policy come from external_process profiles
A pinned delegation.command used to force provider "copilot-acp" whenever the selected
provider was not external_process. It now resolves the external_process profile whose
process_command names the same binary, else the profile flagged with the new
ProviderProfile.process_command_fallback (copilot-acp sets it, so every Copilot setup
resolves as before), else the spawn fails loudly. A kimchi binary now lands on kimchi-acp.

The env-writer denylist's hardcoded HERMES_COPILOT_ACP_* pair becomes
hermes_cli.auth_external_process.external_process_launch_env_names(): every registered
external_process profile's process_command_env_vars + process_args_env_var. This also
closes the gap for out-of-tree providers (KIMCHI_ACP_COMMAND/ARGS) and COPILOT_CLI_PATH,
which select the executable too.
2026-10-25 18:14:42 -07:00
Teknium
c225308275 fix(config): legacy AGENT_BROWSER_* settings survive homes that skip the v52 step
The runtime reads only browser.* now and the AGENT_BROWSER_* -> browser.* move
lived only in the versioned v52 config step, so three kinds of home lost their
engine, headed mode and persistent profile without a word: a missing
config.yaml (reads as current), an unstamped one (boot skipped it as below the
support floor) and one first stamped by an ordinary save before any migration.

The move is now done once, at the home's first stamp:
- note_first_stamp (every save_config first stamp, and left-core's created
  file) moves the settings along with the left-core rows it already records;
- stamp_missing_config creates config.yaml with that first stamp when a
  missing config's .env still carries them, before the missing-config shortcut
  in boot (post_update.step_migrate_config), migrate_config and the Docker
  entrypoint;
- boot migrates an unstamped config whose .env still carries them through
  migrate_config (legacy-key steps, v52 among them, then the stamp); other
  unstamped configs are left alone as before.

The conversion reuses the v52 step's code (move_agent_browser_env) and only
ever runs while a home is unstamped or missing, so a retained .env never
overrides a later config edit.
2026-10-23 01:43:17 -07:00
Teknium
5294a6cce6 fix(migration): convert Camofox homes with a missing or unstamped config.yaml
N3 (re-review of #143146). _predates_split read a missing or unstamped config.yaml as "a
home from after the split", so main's Camofox users with CAMOFOX_URL in .env alone, or with
a hand-written config, silently fell back to the packaged Chromium. Worse, any plain config
write before the first left-core pass (`hermes config set`, a model switch) stamped an
unstamped config at 52 without running the v52 step, so the home looked new for good.

- A missing or unstamped config.yaml now predates the split: every config.yaml Hermes writes
  carries a stamp, so only a pre-split home lacks one.
- The first save that stamps a config.yaml outside a migration
  (config_version_stamp.note_first_stamp, called from save_config) records the left-core
  rows the skipped steps would have found in use, exactly as the v52 step does. A frozen
  worker never reads profile files there; its owner migrates the home.
2026-10-23 01:42:39 -07:00
Teknium
8237c7f8ec fix(config): config set/get still recognise terminal.singularity_image
The key left DEFAULT_CONFIG with the backend, but the singularity plugin reads it
and its setup text says `hermes config set terminal.singularity_image <image>`;
set and get now flagged it "not a recognized config key ... Hermes may not read
it". A seeded default would hide the plugin's TERMINAL_SINGULARITY_IMAGE fallback,
so _validate_config_key accepts left_core_migration.LEFT_CORE_TERMINAL_KEYS (the
renamed RETIRED_TERMINAL_ENV_COPIES, which unset already consults) instead.

The wrong-prefix refusal text moves to hermes_cli/config_key_notices.py to keep
config.py under its line cap.

Review: https://github.com/NousResearch/hermes-agent/pull/142561#pullrequestreview (kshitijk4poor, item 2)
2026-10-22 05:26:10 -07:00
Teknium
a71a76ff65 fix(config): config unset terminal.singularity_image still removes its .env copy
While core shipped the backend, `hermes config set terminal.singularity_image`
also wrote TERMINAL_SINGULARITY_IMAGE to .env (TERMINAL_CONFIG_ENV_MAP), and the
plugin still falls back to that copy. Dropping the key from the runtime bridge
also dropped it from `config unset`, so a reset removed only the YAML and the old
image came back instead of the default. left_core_migration.RETIRED_TERMINAL_ENV_COPIES
keeps the cleanup without restoring the bridge.

Review: https://github.com/NousResearch/hermes-agent/pull/142561#discussion_r4345291204
2026-10-22 05:26:10 -07:00
Teknium
d99af4187b refactor: move the Singularity terminal backend out of core into the singularity catalog plugin
The Singularity/Apptainer backend (tools/environments/singularity.py) now ships
as the official 'singularity' plugin in NousResearch/hermes-official-plugins,
registered through the terminal-environment provider seam under the same
backend name and config keys (terminal.backend: singularity,
terminal.singularity_image / TERMINAL_SINGULARITY_IMAGE, terminal.container_*).

- 'singularity' leaves BUILTIN_BACKEND_NAMES so the plugin can register it;
  every hardcoded classification set drops it (the provider declares
  is_remote/is_container/supports_streams instead).
- LEFT_CORE gains a singularity row: homes whose terminal.backend (or .env
  TERMINAL_ENV) is singularity get the catalog plugin once, on hermes update
  or agent/gateway start. An unknown-backend error for 'singularity' names
  the install command (new row field terminal_backend).
- A plugin backend receives its per-task '<backend>_image' override; batch
  runs register one for the active backend.
- BaseEnvironment's sudo-probe knob is renamed _passwordless_sudo_probe_supported:
  plugin backends set it, and the old spelling trips the install scanner.
- Core's scratch-dir disk warning and process-exit sweep were Singularity-only
  and move to the plugin; the singularity setup row, dashboard probe/row and
  config defaults/bridges go too. Docs point at the plugin.
2026-10-22 05:26:10 -07:00
Teknium
a89f374d7c Merge origin/main (#45: 255 commits to 3b63f7b0a4) into feat/unified-gateway-runtime
Conflicts (2 files, 1 hunk each); every main-side change is kept, ported to
where the branch moved the code:

hermes_cli/kanban_db.py (build_worker_context helpers _ctx_cap .. _ctx_comments)
  main:   f5a6651231c/d56e357556f coerce foreign/text timestamps on read; in
          _ctx_role_history the "Recent work" stamp became
          _ctx_stamp(_to_epoch(row['ended_at']) or 0, now) instead of int().
  branch: moved the whole _ctx_* helper block into hermes_cli/kanban_db_context.py
          (kanban_db.py imports it back), deleting it from kanban_db.py.
  merged: kept the branch's deletion in kanban_db.py and applied main's change in
          kanban_db_context.py::_ctx_role_history as
          _ctx_stamp(_kb._to_epoch(row['ended_at']) or 0, now). Main's other
          timestamp coercions in kanban_db.py (Task/Run/Comment/Attachment/Event
          from_row, _TASK_EPOCH_COLUMNS, release_stale_claims,
          _extend_live_stale_claim, task_age) auto-merged unchanged.

hermes_cli/web_server.py (_lifespan)
  main:   d7830c6f42 reworded one comment in the free-tier bootstrap block
          ("the ONE place its identity is created" -> "the one boot-time creator
          of its identity"; guests are now also created on first connector use).
  branch: moved _lifespan's body into hermes_cli/web_server_app.py::app_lifespan.
  merged: kept the branch's relocation and applied main's comment rewording in
          web_server_app.py.

Merge-induced health fix (no conflict marker; the combination tripped the ratchet):
apps/desktop/src/app/session/hooks/use-cwd-actions.ts::changeSessionCwd
  main:   63ed3caa4ba/dbc538547fc grew the function (statusbar cwd change for the
          focused chat / tile runtime ids) to CC 20.
  branch: added the session_busy refusal mapping (sidebar.projects.moveBusy) in
          its catch, +1 branch -> CC 21 > target 20 (scripts/check health blocking).
  merged: both behaviours kept; the busy-error mapping moved verbatim into a
          module-level cwdChangeError(err) helper. Health back to 0 blocking.

Check: every line main added between 1fd1827726 and 3b63f7b0a4 (317 files) is
present in the merged tree.
2026-10-12 16:55:20 -07:00
Teknium
cdf5732af6 refactor: move Langfuse out of core into the langfuse catalog plugin
The bundled observability/langfuse plugin now ships as the official catalog plugin `langfuse`
(NousResearch/hermes-official-plugins, subdir langfuse) with the same hooks, HERMES_LANGFUSE_* /
LANGFUSE_* env vars and capture modes. Same pattern as the Home Assistant and Spotify moves: a
LEFT_CORE row installs and enables the plugin on `hermes update` / first start for every profile
home that had observability/langfuse (or its bare name) in plugins.enabled and not in
plugins.disabled. Keys alone are not use: the plugin was opt-in.

- left_core_migration: langfuse row + langfuse_in_use; HERMES_LANGFUSE_SECRET_KEY stays a stripped
  child-process secret and the public key / base URL stay private env, exactly as core stripped them
  while it shipped the plugin. New plugin_key field: `hermes plugins enable observability/langfuse`
  (what every pre-move doc said) now names `hermes plugins install langfuse` for this home.
- Core drops the plugin, the `hermes tools` Langfuse category and its post-setup hook (the plugin
  prompts for its keys at install), the OPTIONAL_ENV_VARS / _EXTRA_ENV_KEYS rows, the `langfuse`
  extra + its PM anchor (uv.lock regenerated with CI's uv 0.12.13), and the
  plugin's tests (they moved to the plugin repo).
- Docs (en + zh-Hans): built-in plugins and env-var reference point at the catalog plugin.
2026-10-12 14:00:32 -07:00
Teknium
b1ccce898b Merge origin/main (#38: 70 commits to c57331677d) into feat/unified-gateway-runtime
Conflicts: tests/hermes_cli/test_finite_chat_delegation.py and
tests/tools/test_completed_process_results.py, where main's lint sweep (0006a5e229) added
check=False to subprocess.run calls this branch had rewritten. Kept the branch's test bodies
and carried check=False onto their subprocess.run calls.
2026-10-10 17:47:35 -07:00
Maciej Lisiewski
0006a5e229 ci: fix PLW1509, PLW1510, PLW2101 linter errors 2026-10-10 15:20:13 +02:00
Teknium
408cc0d12e Merge origin/main (#32: 36 commits to cf23a1a5cc) into feat/unified-gateway-runtime
17 conflicts, all from main's lint sweep (ruff UP007/UP017/UP022/UP028/UP031/UP037/UP041,
FURB188/FURB192); no other main commit touches a conflicted file. Resolution: the branch side
of each file plus main's exact autofix (ruff 0.15.10, main's ruff.strict.toml, --fix
--unsafe-fixes). ruff.strict.toml takes main's copy. The pool-retirement live fixture stays
deleted with the pooled backend this branch retires.
2026-10-09 10:24:04 -07:00
Maciej Lisiewski
2ff58849f4 ci: ruff UP037 fixes 2026-10-09 17:34:38 +02:00
Teknium
749102ac35 fix(worker): ordinary managed workers serve the frozen session config
The owner already hydrates the session's creation-time config into the bootstrap, but
bind_bypass_policy returned without binding anything for ordinary (non-bypass) sessions.
discover_profile_mcp -> tools/mcp_tool_config._load_mcp_config -> load_config() then read the
LIVE config.yaml, so editing an already-selected MCP server's transport after session creation
changed what an existing session's next fresh worker connected to.

bind_worker_policy now binds the snapshot for every worker before any config import:
- ordinary sessions bind it through the new safe_worker_policy._bind_worker_config, which
  makes worker_config_snapshot() return the frozen config while safe_worker_enabled() stays
  False, so plugins, MCP, hooks and providers keep their ordinary behaviour (ignore_user_config
  is NOT set on ordinary sessions);
- bypass sessions bind exactly as before.

Two consequences of the now-frozen readers are handled at their root:
- save_config in a frozen worker rebases the caller's edit (desired vs the snapshot it loaded)
  onto the LIVE raw file (hermes_cli/config_worker_save.py), so an `always` approval or a
  connector enable lands only its own change instead of writing the snapshot back over every
  profile edit made since the session was created;
- the owner overlays the live `command_allowlist` onto the hydrated snapshot of ordinary
  sessions (gateway/session_managed_worker._worker_config): it is approval state, so a grant an
  earlier worker persisted (or one the operator removed by hand) reaches the next worker, as it
  did when the child read the live file.

Red/green (tests/gateway/test_managed_worker_frozen_config.py, real daemon + real stdio MCP):
- test_existing_session_keeps_frozen_mcp_transport_after_profile_edit: on r6-base
  `assert ['echo_LIVE_B'] == ['echo_FROZEN_A']` (existing session followed the edit); green:
  the existing session sees FROZEN_A, a session created after the edit sees LIVE_B.
- test_ordinary_worker_binding_freezes_readers_but_keeps_customizations: load_config /
  read_raw_config / load_user_config_effective / _load_mcp_config all serve the snapshot, the
  plugin still executes, safe_worker_enabled() is False, and a worker save_permanent_allowlist
  keeps the live file's later edits (red on r6-base: no ordinary binding exists).
Safe/config-only controls: tests/agent/test_safe_worker_policy.py and
test_managed_worker_bypass.py unchanged and green (renamed binding import only).

Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5461749257
2026-10-08 19:08:59 -07:00
Teknium
65bec86e37 Merge origin/main (#27: 19 commits to 517b5e10fe) into feat/unified-gateway-runtime
45 conflicts, all from #135177 (lefthook + `ruff check --fix` over 2,366 files). No other main commit
touches a conflicted file. Resolution: the branch side of each file, then main's exact autofix
(ruff 0.15.10, `--config ./ruff.strict.toml --fix`) on it — rewrites only (typing generics, noqa
drops, import forms), no import removed. tests/cron/test_bot_chat_cli_home.py stays deleted
(1cc9cb9199 retired its lane).
2026-10-08 12:09:24 -07:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
Teknium
a070a5be33 refactor(health): offset FILE_LINES growth by moving cohesive groups into topical siblings
main's ratchet caps every >2000-line facade at its main value; the PR grew seven.

- config.py: `hermes config show` rendering -> hermes_cli/config_show.py (reads config names via
  the module at call time so hermes_cli.config.<name> patch seams hold).
- backup.py: the cron prompt-field safety net -> hermes_cli/backup_cron_prompts.py; also drops a
  dead duplicate _PROTECTED_CONFIG_PATHS left by an earlier merge (the later definition won).
  restore_config_model_settings_* stay in backup: they are on the frozen old-updater surface.
- profiles.py: Honcho host migration on rename -> hermes_cli/profiles_honcho.py.
- plugins.py: resolve_plugin_command_result -> plugins_dispatch.py (re-exported from plugins,
  the public import path for cli/tui_gateway/plugins).
- main.py: --query-file reader -> hermes_cli/main_query_file.py.
- kanban_db.py: worker-context section renderers (_ctx_* + caps) -> hermes_cli/kanban_db_context.py;
  build_worker_context stays in kanban_db.
- config_defaults.py: drop the blank line the gateway block gained.

Patch-target retargets (moved symbols only): test_plugins.py (asyncio / await timeout now in
plugins_dispatch), test_managed_scope_surfacing.py (show_config import), test_backup.py
(restore_cron_prompt_fields_if_degraded import).

(cherry picked from commit 4079d422e0c2283c500c16885e959f5c170eb6cf)
2026-10-07 10:57:35 -07:00
Teknium
ca38632fc0 Merge origin/main (#17: 454 commits to e6757f2029) into feat/unified-gateway-runtime
12 conflicted files, resolved in three lanes:
- gateway/run.py: take the branch split; main's tirith removal and spool-replay
  ordering ported into run_runtime_init.py / run_bootstrap.py.
- config migrations: main keeps v50 (tirith); the branch's bot-chat timeout removal
  becomes v51 (_config_version 51, template + test updated).
- hermes_state_usage.py: main's voice_chat task route threaded through the branch's
  owner transaction; worker.persist usage allowlist accepts task.
- tui_gateway/server.py: branch side; main's edits applied where the code now lives
  (agent_factory, session_registry). Desktop sessions get the catalog toolset on the
  authority path; daemon-run finite CLI turns are not watched turns; lazy session info
  reports nous/welcome on the free tier.
- Desktop/Ink: one branch-child spinner fix (main's route-token check); main's
  uninstall i18n keys kept, pool keys stay removed; voice_turn forwarded and accepted
  by the authority submit (surface_v1.voice_turn).
- chat_ws / PTY keepalive test: main's stricter test kept.
2026-10-07 06:48:09 -07:00
Teknium
1e500ebce2 Merge origin/main (#16: 4,465 commits to 9dcab1e440) into feat/unified-gateway-runtime
99 conflicted files resolved in nine area lanes (Desktop composer, Desktop renderer/shared
client, Electron main, Ink, tui_gateway, gateway, state, CLI/config, cron/tools/CI). The
unified runtime's architecture wins where it deliberately replaced a mechanism (pool,
fallback lanes, claim poller, renderer queue); every orthogonal main change is kept, ported
into the <stem>_<topic> sibling that now owns relocated code.

Notable ports and repairs in this merge:
- tui_gateway/server.py relocated regions: atomic _attach_built_agent (#49852), slash ranking
  registry names, minted-key helpers methods_session.py calls, request_overrides, service tier.
- gateway/run_turn*.py: i18n accessors for the removed reply constants, first-contact
  internal/DM rule, rotated-compression persist, fast-mode tiers, prompt-pin rehydration.
- webhook: route_from_chat_id decodes main's opaque webhook:v2 chat ids (old ids still read).
- ws.py: main's per-connection dispatch queue with authority-first dispatch inside it.
- state: schema event for runtime revision renumbered to 31; worker mirrors updated for
  main's message uid/merge fields, on_contended lease arg, compression columns.
- config: branch's bot_chat_delivery_timeout removal renumbered v47 -> v50.
- Electron: primary-profile pin, redirect header scoping, remote fetchJsonForBackend, SSH
  teardown on profile delete, held-update dial gate restored (lost in earlier merges).
- Desktop: canonical clarify.request mapped to main's questions[] card; replay truncation vs
  snapshot_required; periodic secondary prune tick restored; DELETE already_absent restored.
- cron/tools: diagnostic category on cron failure notices restored; owner_holds_delivery
  ported onto the authority; admitted receipts can no longer be cancelled locally.
2026-10-06 14:24:24 -07:00
Teknium
911da42e9e refactor(security): remove the bundled tirith scanner from core
tirith ran `tirith check` on every terminal command, default-on with fail-open, as a
pinned PM binary auto-downloaded at startup. Measured against the shipped 0.4.2 binary
it caught 14/16 attack commands but flagged 12/24 everyday agent commands
(`echo $((6*7))`, `"$VAR/x.sh"`, `gh api | python3`, LAN curls, `.dev` hosts,
`pip install` via analysis_incomplete), and in cron/-q deny mode each of those is a
hard block. It only ever saw terminal strings (execute_code, writes and the browser
bypass it), fail-open meant no protection wherever the binary could not install
(Windows, Termux, x64 musl), and it produced a steady issue/PR stream (fail_open
semantics four times, install loops filling disks, a SIGSEGV hang, session-approval
scoping, third-party promo text on approval cards).

Removed: tools/tirith_security.py, the tirith branches of the command guard (the
is_tirith tuple, session-only "always" downgrade, import-error/fail-open paths,
unattended tirith pass), the CLI and gateway startup installers, the PM package and
lock pins, the nix runtime dep, security.tirith_* defaults, the CLI warning string
and three tirith tips (gaps refilled from the tail so translations survive), plus
the gateway's "no automated assessor" warning that only existed to point at tirith.

Config v50 drops security.tirith_* and enables nothing in its place. Hermes ships
no tirith plugin; if tirith upstream publishes one, it goes through normal catalog
admission under their name.
2026-10-06 14:22:13 -07:00
Brooklyn Nicholson
81c2145c8d refactor(cli): move the config version stamp into config_version_stamp
Offset the FILE_LINES growth the moa preset fixes add to hermes_cli/config.py
(4283 > its 4274 cap): the version-stamp trio (raw read of _config_version
plus check_config_version) moves verbatim into topical sibling
hermes_cli/config_version_stamp.py; config.py re-exports the two public
names (callers and tests import them from hermes_cli.config), the internal
_read_config_version_stamp callers now use read_config_version_stamp, and
scripts/docker_config_migrate.py imports from the new module directly.
2026-10-06 14:57:23 -05:00
Brooklyn Nicholson
ee91fdc84d fix(moa): drop PyYAML from the deletion tests and offset config.py growth
CI has no PyYAML and the repo is ruamel-only: the new deletion tests'
seed/parse helpers now use ruamel.yaml (round-trip) instead of yaml.
hermes_cli/config.py FILE_LINES ratchet: the new _apply_user_moa_presets
moves verbatim into the topical MoA sibling hermes_cli/moa_config.py as
apply_user_moa_presets; both call sites (last-known-good fallback and the
load merge) late-import it, keeping no facade growth.
2026-10-06 14:57:23 -05:00
Tharanee
35f398eb5e fix(moa): preserve legacy preset updates and suppress warnings 2026-10-06 14:57:23 -05:00
Tharanee
d2c96d4ffb fix(moa): keep explicit preset names authoritative on load 2026-10-06 14:57:23 -05:00
liuhao1024
0742b460a3 fix(runtime): let a raw op:// reference in .env yield to the resolved scoped key
Lift the credential pool's op:// carve-out into
hermes_cli.config.get_env_value_prefer_dotenv so the OpenRouter/OPENAI
fallback rungs added here cannot send an unresolved op:// reference as
the API key when the 1Password source already resolved the key into the
active scope. Mirrors the pool's precedence test on the resolver path
and covers the OPENAI_API_KEY .env rung.
2026-10-05 16:42:43 -05:00
Brooklyn Nicholson
ca8f8dd5d8 fix(config): serialize .env read-modify-write cycles with a file lock
save_env_value, remove_env_value and sanitize_env_file each read
~/.hermes/.env, rewrite it in memory, then atomically replace it, with
no lock spanning the cycle. Two concurrent writers (setup wizard +
dashboard save, gateway + CLI) both snapshot the pre-write file and the
loser's replace silently drops the winner's key; a remove racing a save
can resurrect the removed key. _CONFIG_LOCK cannot help: it guards
in-memory config only.

Serialize each cycle with hermes_cli.auth._file_lock (the same fcntl
flock / msvcrt byte lock auth.json already uses), keyed on the .env
path so multiplexed profiles stay independent. The import is call-time
because hermes_cli.auth imports this module at import time. Nothing
under the lock takes other locks, so no ordering cycle exists.

Fixes #77187

Co-authored-by: joaomarcos <joaomarcosdias444@gmail.com>
2026-10-05 16:41:00 -05:00
kshitijk4poor
a9cd8de4ee refactor(cli): move _guard_section_overwrite into config_section_guard to keep config.py under its size cap
Code-health ratchet: hermes_cli/config.py was 4268 lines > its 4249 cap after the bare-model
container refusal grew the section guard. Move the guard verbatim into a topical sibling;
set_config_value late-imports it, and the sibling late-imports _exit_invalid, so there is no
module-level facade<->sibling cycle. No shim left behind; no test patches the old path.
2026-10-05 19:36:32 +05:30
kshitijk4poor
8b2fb08dfd refactor(cli): fold the forced model-container notice into the force branch
#131435 gate reuse finding: _guard_section_overwrite computed the
mapping/list label twice and carried a second copy of the
"Replacing entire 'model' section" notice for forced containers. Past
the refusal, a container reaching the model branch implies --force, so
one `if force:` branch prints the notice with the right noun. Output
is unchanged. The docstring now names the container refusal, and the
inline comment is cut to one line.
2026-10-05 19:36:32 +05:30
kshitijk4poor
1ceaec27c6 refactor(cli): match bare model by exact key in the coerce exception
The coerce exception compared `key.strip().lower() == "model"` while
_guard_section_overwrite, which gates the parsed value, compares
`key == "model"` (#131435 gate finding). set_config_value already
rejects keys with surrounding whitespace, and a differently-cased key
has no string default in DEFAULT_CONFIG so it never reaches the
exception. Use the same exact compare as the guard; behaviour is
unchanged.
2026-10-05 19:36:32 +05:30
kshitijk4poor
824c2ad446 fix(cli): refuse a list under bare model even with no model section
The container refusal for the bare `model` shorthand only ran when the
existing `model` value was a mapping. With `model` absent or a string
shorthand, `hermes config set model '[a, b]'` wrote `model: [a, b]`,
a shape no model reader accepts (#131435 gate finding).

Hoist the refusal ahead of the mapping-section early-out: a list is
refused whenever --force is not given; a mapping is still refused only
over an existing section, since a mapping over an absent/string model
is a valid section write. Extends the kept refusal test with
absent/string-model list rows.
2026-10-05 19:36:32 +05:30
kshitijk4poor
992e80a158 refactor(cli): parse bare-model literals in the shared coerce path
The salvaged fix re-ran yaml.safe_load in set_config_value with its own
copy of the invalid-literal error, because _coerce_config_set_value
returns string-default keys verbatim and bare `model` has a string
default. Exempt bare `model` structured literals from that early return
instead, so one parse site (and one error message, including the
quoting hint) serves every key. Behaviour is unchanged: the section
guard still refuses a mapping/list under bare `model` without --force.
2026-10-05 19:36:32 +05:30
liuhao1024
a03d0f8e7d fix(cli): refuse a mapping literal under the bare model shorthand
`hermes config set model '<json>'` printed a success line while
redirecting the raw JSON text into `model.default` as the model id
(#131435, item 6): `model` is seeded as a string default, so the
generic coerce kept the literal verbatim, the bare-name shorthand rode
it into `model.default`, and every runtime reader then failed to
resolve the route while `config get` echoed it back.

Parse the literal first so the section guard sees the real shape:

- bare `model` + a mapping/list literal without --force is refused with
  a pointer to `model.provider` / `model.default` (the same fail-closed
  shape the container-slot guard took in #114471)
- with --force the validated mapping replaces the whole section, which
  is the documented force meaning for section writes

(cherry picked from commit c08983182745c3eae395834a1fd5081a3b0267e7)
2026-10-05 19:36:32 +05:30