Commit Graph

3224 Commits

Author SHA1 Message Date
Maciej Lisiewski
d352a19670 docs(debug): document debug-share consent, parity verdict and 1-day --expire default
Refs #94876
2026-11-13 14:05:03 +01:00
Teknium
513f8bfbfd ci: route default_plugins.py to the upgrade lane (the update tail imports it) 2026-11-13 02:36:06 -08:00
Teknium
7adcd5e76d feat(plugins): catalog entries marked default: true are installed in every home
A catalog entry at tier official or verified can now set `default: true`.
Every Hermes home then gets it installed at its catalog pin and enabled,
once:

- at the end of every source install and `hermes update` (the shared
  maintenance tail install.sh / install.ps1 / the updater all run), for
  every profile home;
- on first start, through the boot bootstrap, for installs that never run
  that tail (bundled Desktop payload, Docker, Nix, Termux); a failed fetch
  stays owed and is retried on later starts behind an hour-to-a-week
  backoff checked before any network;
- when a profile is created.

Each home records what it got in `_default_plugins_installed` (the way the
left-core migrator records its one-time install), so a user who removes or
disables a default plugin keeps that choice through later updates. Homes
with security.allow_lazy_installs off fetch nothing. The parser ignores
`default` on community entries and the catalog validator refuses it.

Lane B1.12 (default plugins installed and enabled from the catalog).
2026-11-13 02:36:06 -08:00
Teknium
4f2fd3b8c0 fix(plugin api): publish hermes_cli.urllib_security:open_credentialed_url
The redirect-safe opener (drops credential headers when a redirect leaves
the origin) is what plugins sending API keys should use, and the bundled
model providers already do; validate still warned on it as a private
import. List it in plugin_api.json with a short docs section, regenerate
public-api.md, and drop the three now-public crossings from the
boundary-lint baseline.
2026-11-12 22:33:52 -08:00
BearHuddleston
dbc135f5d0 fix(bundles): let the payload launcher run a named module
A bundle's bin/hermes could only start hermes_cli.main. The store launcher
that source installs publish (.hermes/bin/hermes) also takes
`--run-module <module>`, and services persist that form for the launchd
stderr wrapper (installation_command), so a service could not run through
a bundle's own launcher.

posix_launcher now handles `--run-module` the same way, with the same
interpreter, PYTHONPATH, site dir and outside-the-app bytecode cache as its
main entry. The module name is spliced into the -c source, so anything but a
dotted Python name exits 2 before Python runs. Keeping the name in the
source keeps the stderr wrapper's argv in the shape gateway/status already
matches for runtime_command's bootstrap.

The next commit makes a macOS app's gateway service use this.
2026-11-12 23:36:59 -06:00
BearHuddleston
58e0b85e91 fix(bundles): bake the interpreter's stdlib and every existing pyc as unchecked-hash
A sealed macOS bundle is user-writable, so any payload Python that runs without
a cache prefix rewrites stale bytecode inside the signed app. codesign then
reports "file modified", spctl rejects the app, and the next Squirrel.Mac
update waits on a Gatekeeper prompt. The shipped Nov 10 canary (da06acacc9),
inventoried on a real Mac, had:

- stdlib: 1,061 modules, 140 timestamp pycs (all stale: they record the
  2024-01-01 source mtime, the .py files carry the build time) and 921 with
  no pyc at all. bake_bytecode never compiled the interpreter's own library.
- venv site-packages: all 25,439 pycs timestamp-based and stale; pm-runtime:
  all 61. uv's --compile-bytecode writes timestamp pycs, and compileall
  without -f keeps a timestamp pyc whose mtime still matches, even in
  unchecked-hash mode, so the bake left them as they were. Packaging then
  moved the sources' mtimes.
- hermes-agent: unchecked-hash, as intended.

On that build, Desktop's ticket helper rewrote 94 stdlib pycs inside the app,
and a `python -I` import of the gateway (which ignores PYTHONPYCACHEPREFIX)
wrote 248 (103 stdlib, 145 venv).

The bake now also compiles the staged interpreter's library, found by
CPython's own landmark (os.py) beside the binary and refused when it lies
outside the payload, and forces every root (-f) so existing timestamp pycs
become unchecked-hash too. The same payload baked with this change on the Mac:
every module in all four roots unchecked-hash, nothing stale or missing, and
neither the ticket helper nor the `python -I` import wrote a file. The bake
took 25 s there; the stdlib grows by about 16 MiB. The prepared-payload
digests skip __pycache__, so they are unchanged.

Windows and Linux install trees are read-only, so their payloads never hit the
seal break. The Windows launcher reads these source-adjacent pycs (it sets no
cache prefix for a baked payload), so there the change only removes
recompiles.
2026-11-12 22:34:16 -06:00
BearHuddleston
7350e53f27 refactor(termux): name the tools the .deb payload records
payload_facts.py recorded the bionic payload's tools from an inline tuple,
and its assembly test kept its own copy. PAYLOAD_TOOLS names the set once,
so a test can check it against what PM requires on linux-arm64-bionic.
The assembly test's fixture moves into a helper for that reuse.
2026-11-12 18:57:08 -06:00
Maciej Lisiewski
efc7d5d9cf Merge pull request #154491 from NousResearch/sec/132195-docs-url-scheme
fix(plugins): reject non-https catalog docs_url end-to-end
2026-11-13 00:34:52 +01:00
Maciej Lisiewski
faef126c03 fix(plugins): require a hostname for catalog docs_url at admission
https://:443/docs and https://user@/docs matched the authority regex but
carry no hostname; the loader already dropped them, admission now refuses
them too (urlsplit ValueError counts as a rejection).

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-12 23:28:03 +01:00
Maciej Lisiewski
b545c8d95f fix(plugins): drop malformed catalog docs_url instead of failing the load
urlsplit("https://[") raises ValueError, which aborted load_catalog, the live parse and site extraction instead of dropping one link. Both https gates now treat a parse error as "not https". Admission also requires a non-empty authority so a hostless https:///docs is rejected up front rather than silently dropped after merge.

Refs #132195
2026-11-12 23:28:03 +01:00
Maciej Lisiewski
f62ffe0895 fix(plugins): drop non-https catalog docs_url at load and gate every docs href
The salvaged extractor/validator check covers the docs site build, but the
runtime loader re-validates the raw live catalog JSON and passed docs_url
through to the dashboard's <a href>, and the site rendered plugins.json
values verbatim. Drop non-https docs_url in entry_from_mapping (entry kept,
like image/version) and route the website and dashboard links through the
shared externalUrlTarget scheme gate. The validator's docs_url check moves
into _check_page_fields to keep validate_entry under its CC ratchet.

Fixes #132195
2026-11-12 23:28:03 +01:00
kokhlo
549c8dd634 fix(website): reject non-https plugin catalog docs_url before it reaches the site 2026-11-12 23:28:03 +01:00
Maciej Lisiewski
f2cadb13ae fix(whatsapp): launch bridge.js from the scrubbed child env
The gateway bridge and both pairing launches (dashboard, `hermes whatsapp`)
built their env with with_hermes_node_path(), which copies os.environ, so the
networked Node bridge and its third-party npm deps saw every provider key,
platform token and gateway allowlist. They now start from
hermes_subprocess_env(); the gateway path still re-injects every WHATSAPP_*
value bridge.js reads from the adapter's resolved settings, so the
blocklisted WHATSAPP_ALLOWED_USERS keeps reaching the bridge's DM gate.

Fixes #38079
2026-11-12 22:57:42 +01:00
Bear Huddleston
91b9cf805f fix(release): cap the canary draft body so Canary Release drafts again (#154321)
* fix(release): cap the canary draft body below GitHub's limit

Canary Release has failed at "Tag and draft" since 2026-11-11 (runs
42974584993 and 43170357147): `gh release create` got HTTP 422, "body
is too long (maximum is 125000 characters)". The daily changelog lists
every commit since the previous canary tag, and main now lands 800 to
1,300 commits a day: 1,314 commits made a 234,391-character body on
Nov 11 and 829 made 149,678 on Nov 12. Nov 10's 108,144 still fit.

The stable path has refused an oversized body before its claim since
74c365a85a; the canary path had no check, pushed its tag, and then
failed to draft. With no draft, no Desktop Bundled Release was
dispatched.

When the changelog would not fit, the canary now drafts the
--no-changelog body (title, builds-table marker, Full Changelog link).
The check keeps 10,000 characters for the builds table that the
builds-table job later splices into the marker, also under GitHub's
limit. A full matrix with diagnostics renders about 3,000.

* fix(release): recover an undrafted canary tag without GitHub-generated notes

When a canary tag exists with no release (a cut whose draft failed after
the tag push, as on Nov 11 and 12), the next run with no new commits
recovers the tag and drafts it with --generate-notes. GitHub builds
those notes server-side from every pull request since the last
published release and does not truncate them (cli/cli#7705). Every
canary since Oct 31 is still a draft, so that range starts at v0.23.1:
970 merged pull requests on Nov 12, about 131,000 characters at their
average line length, so the recovery would fail with the same 422. The
generated notes also carry no HERMES_BUILDS_TABLE marker, so the
builds table could never render into a recovered draft.

Recovery now drafts the --no-changelog body over stdin: title,
builds-table marker and changelog link.

* fix(release): link a recovered canary draft to its own repository

The recovered draft's only link came from generate_changelog's default
repo_url, NousResearch/hermes-agent, so a fork's recovered canary
pointed at a repository that lacks its tag. Build the link from the
repository the draft is created in, as the stable path does.

The cut path keeps the default: its commit lines link upstream pull
request numbers, which a fork does not have.

Raised by Greptile on #154321.
2026-11-12 14:48:36 -06:00
BearHuddleston
3944af0ea3 fix(bundles): build the Webapp in source desktop bundles too
Some checks failed
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
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
`pnpm run dist:bundled` stages its payload through scripts/bundles/stage.py,
not the prepared desktop builder. Its automatic route compiled only the TUI
and dashboard, so a payload stamped `bundled` shipped no Webapp and
`hermes webapp` stopped at "This desktop app ships no Webapp renderer".

Install the Desktop workspace in the frontend snapshot, compile the Webapp
there and pass it to stage_native. The native staging child takes its
products as flags and only knew --tui/--web, so it also learns --webapp;
without that, handing it the Webapp exits 2 on an unrecognized argument.

The regression test runs stage.main through the real stage_native argv into
native.main and asserts the planted payload: red on the PR head (no
dist-webapp), red with stage.py alone changed (argparse exit 2).

Reported by @kvnloo on #154325, whose b294b532 changed stage.py the same way.

Co-authored-by: Kevin Rajan <7121943+kvnloo@users.noreply.github.com>
2026-11-12 14:16:57 -06:00
BearHuddleston
f3ad28864a fix(bundles): ship the prebuilt Webapp in every desktop bundle
Desktop bundles (MSIX, Store, DMG/ZIP) plant prebuilt TUI and dashboard
products into the agent payload, but not the Webapp renderer, and the
payload drops apps/ and scripts/, so nothing in the app can build one.

desktop.py now compiles the Webapp with scripts/build/webapp.mjs from the
checkout whose apps/desktop dependencies the bundle job already installed,
and hands it to finish_native beside tui and web. The assembler plants it
at hermes-agent/apps/desktop/dist-webapp, where the gateway serves it.

- webapp.mjs gets the --source/--out CLI its sibling builders have.
  Compiling in place tripped its own overlap guard: the workspace's path
  relative to the source is '', which protected the whole checkout.
- The prepared payload's source digest ignores dist-webapp, as it does
  tui_dist and web_dist. Windows assembles the bundled and then the Store
  variant from one preparation; without this the Store pass fails with
  "prepared bytes changed: hermes-agent".

The renderer adds about 45 MB in 1,083 files to the payload, about 18 MB
deflated. It built in 23 s on linux-arm64.
2026-11-12 14:16:57 -06:00
unsupportedpastels
5c3421082d fix(gemini): replayed tool calls without a thought signature on Interactions
The Interactions API answers HTTP 400 ("Request contains an invalid
argument") when a model turn that calls tools does not open with a
thought step. A turn written by another provider has no signature to
replay, so a conversation switched to Gemini 3+ mid-session failed on
its first request.

Such a turn now opens with the placeholder signature Google accepts in
place of a real one, the same one the generateContent path already
sends. Turns that open with their own signature and text-only turns are
unchanged.
2026-11-12 14:32:53 -05:00
Maciej Lisiewski
02e67b7361 Merge pull request #154135 from NousResearch/sec/80096-whatsapp-bridge-auth
fix(whatsapp): require a per-session bearer on the bridge HTTP API; adopt a running bridge only after it proves the secret
2026-11-12 15:42:42 +01:00
Maciej Lisiewski
ccb6562066 Merge pull request #154129 from NousResearch/sec/81525-node-tarball-owner
fix(install): don't adopt the uv tarball's uid on root bootstrap
2026-11-12 15:42:23 +01:00
Teknium
d92c31ae65 feat(catalog): weekly check delists entries whose repo or pin is gone
A catalog entry whose repository was deleted, or whose pinned commit was
force-pushed away, can't be installed any more: `hermes plugins install` clones
the repo and checks out the pin, and both fail. Nothing noticed until a user
hit it.

scripts/ci/catalog_dead_repos.py looks up every entry (GitHub in GraphQL batches
of 50, with REST confirming each miss so a renamed or transferred repo is never
taken for deleted; other hosts via git ls-remote). Any unclear answer, or more
than 25 dead at once, aborts with nothing delisted, because that shape is an
outage, not a week of deletions. The weekly workflow deletes the dead entry
files on bot/catalog-dead-repos and opens one PR for review; nothing
auto-merges. It delists (deletes the file) and never touches removed.yaml,
which is the security blocklist.

First run, on today's catalog: 8 of 2,087 entries are dead (7 deleted repos,
1 force-pushed pin). Their files are deleted in a separate commit.
2026-11-12 02:21:17 -08:00
kshitijk4poor
0b29d8fe75 fix(config): stamp migrations to the last step that succeeded
A step that raised was logged and skipped, then migrate_config stamped the
latest version, so the step never ran again (v21 on a nested list in
plugins.disabled: plugins stayed off for good). Boot could not keep partial
progress either: any stamp below latest counted as a failed migration and
restored the backups.

- run_migrations stops at the first failing step and returns it; the
  stamp moves only to the step before it. Later steps wait, so a one-time
  step never runs twice over a value the user set in between. An
  unversioned file that fails stays unversioned.
- Boot keeps the steps that succeeded, records the failing step, and
  retries it on every start of the same revision (one warning per start,
  also kept for the next visible turn). Docker does the same.
- hermes doctor says why the version is behind, and --fix reports a pass
  that stopped instead of "migrated".
- A config stamped by a newer build runs no step, keeps unknown keys, and
  refuses whole-file saves; key-level writes (config set) still save.
- The remote backend migrates in memory and never writes back, so it
  keeps running the whole ladder.
- disable_suspicious_mcp_servers moves to config_migrations (size cap).
2026-11-12 14:09:07 +05:30
Teknium
9a735ca353 ci: run the cwd-restart Telegram E2E in the messaging-gated job
It probes for the real python-telegram-bot, which only the e2e job installs
(tests/ci/test_messaging_gated_selection.py).
2026-11-12 00:32:41 -08:00
Teknium
d5cf6deff4 ci: route gateway_runtime_start to the update suites now that the pause replay imports it
tests/ci/test_update_ci_routing.py requires every module an update entry point
imports to start its suite; _relaunch_bare now imports strip_supervisor_markers.
2026-11-11 23:20:47 -08:00
Teknium
a2620368c0 ci: run the paused-/new Telegram E2E in the messaging-gated job
It probes for the real python-telegram-bot, which only the e2e job installs
(tests/ci/test_messaging_gated_selection.py).
2026-11-11 23:09:40 -08:00
Teknium
753ea6bb16 fix(update): a sibling profile's gateway restarts with its own credentials, not the updater's
`hermes update` respawns each profile gateway through a detached restart
watcher that hands its own env to the gateway it starts. For a named
profile the watcher inherited the updater's os.environ, which already
holds the updater's profile .env. A profile with no TELEGRAM_BOT_TOKEN of
its own (an API-only profile) then started the root bot and took its
polling lock, and the default gateway's Telegram failed with "token
already in use".

The watcher env now follows the rule update_cmd_posix_pause._replay_env
already uses for the same respawn: the launcher's own named profile keeps
the launcher's env (an exported token may be its only credential); any
other home gets that home's own secrets via served_profile_child_env and
none of the launcher's. The host path is unchanged.

The env choice moves into hermes_cli/gateway_restart_env.py
(hermes_cli/gateway.py is over its line cap).

Fixes #135792.
2026-11-11 22:40:06 -08:00
Teknium
9788899694 fix(plugins): publish the path-check and YAML helpers reviews tell authors to use
Catalog reviews ask plugin authors to refuse credential paths with
agent.file_safety.get_read_block_error / raise_if_read_blocked and to read
YAML with hermes_yaml (core ships no PyYAML). `hermes plugins validate`
then warned on exactly those imports as "private core imports", so an
author who followed the review got a warning for doing so.

- plugin_api.json lists the four file_safety checks and
  hermes_yaml.safe_load/safe_dump; public-api.md regenerated.
- plugins/index.md gains a short section with the table and an example.
- boundary_lint baseline drops the 7 bundled-plugin crossings that are now
  public (no other line changes).
- Test: the guide's example validates clean, while a whole-module
  `import agent.file_safety` still warns. Red on main.
2026-11-11 22:17:18 -08:00
Teknium
9dc7e6a524 fix(ci): reject text files stored with CRLF line endings
.gitattributes asks git to store text with LF, but only a client that
honours it does: a GitHub web upload or an API commit lands bytes as sent.
plugin-catalog/board-insights.yaml arrived that way. Every fresh checkout
then showed it as modified, and the icon check (which needs a clean tree)
failed on every catalog PR until #154171 rewrote it.

- scripts/ci/check_line_endings.py reads `git ls-files --eol` and fails on
  any index blob that is crlf/mixed, except -text (binary) and eol=crlf
  (*.ps1) paths. `--fix` rewrites offenders with LF and stages them.
- Runs as a Repository guards step and as `scripts/check --only
  line-endings` (so the pre-push hook catches it locally too).
- `* text=auto` catch-all in .gitattributes, so text files outside the
  listed extensions are normalized at check-in too (renormalizing the
  whole tree with it changes nothing but the file below).
- Fixes the one remaining offender:
  contributors/emails/uperLu@users.noreply.github.com.

Co-authored-by: lancelotsh51sh <283335493+lancelotsh51sh@users.noreply.github.com>
2026-11-11 18:50:11 -08:00
Maciej Lisiewski
3bab836278 test(whatsapp): spawn bridge.js and pin every route but /auth-proof behind the bearer gate 2026-11-12 03:08:13 +01:00
Maciej Lisiewski
86c9bd9e53 test(whatsapp): passkey bridge test spawns with a session token; port-release probe refuses like a free port
bridge.js now refuses to serve without HERMES_WHATSAPP_BRIDGE_TOKEN, so the passkey
test (added on main) exited 1 before reaching the passkey path. The port-release
harness modelled a refused connect as a bare OSError; a refused connect is
ConnectionRefusedError/ClientConnectorError, and any other failure is now an
unproven holder that is never killed by port.
2026-11-12 03:08:12 +01:00
Teknium
57893add23 fix(whatsapp): challenge-first bridge auth on current main; cron senders read the token, bridge refuses without one
Builds on @fangliquanflq's #83432 (cherry-picked first commit; the remaining
eight commits were re-applied by hand because the adapter has since been
refactored into _probe_bridge_health / _reuse_running_bridge / _bridge_req /
_standalone_send). Port prompted by qwibitai/nanoclaw#4013, which closed the
same class (an unauthenticated loopback webhook) on their Discord bridge.

Why: the bridge binds 127.0.0.1 and checks the Host header, but loopback does
not identify the caller — any local process could GET /messages (read every
inbound) or POST /send (send as the user), and a process that bound the port
first and mirrored /health with the derivable scriptHash was adopted as the
bridge (#83395, #80096).

What:
- bridge.js: every route except GET /auth-proof requires
  `Authorization: Bearer <HERMES_WHATSAPP_BRIDGE_TOKEN>` (constant-time);
  /auth-proof answers HMAC(token, challenge); express.json() runs only after
  the gate; the bridge exits when spawned without a token; bridge_auth.js is
  folded into scriptHash so stale auth code is never adopted.
- adapter: per-session secret at platforms/whatsapp/session/.bridge-token
  (0600, created once under a cross-process lock), passed to the spawned
  bridge via env; _probe_bridge_health is challenge-first so an impostor
  never sees the bearer and is replaced; the long-lived aiohttp session
  carries the bearer as a default header, so every send/edit/media/typing/
  read/poll call is authenticated with no per-call-site change.
- _standalone_send (cron / `hermes send` out of process): READS the persisted
  token, never mints one (a bridge spawned without it would not know it) and
  reports "No WhatsApp bridge token" until the gateway has started once;
  pinned to 127.0.0.1 like the bridge's bind.
- docs: whatsapp.md "Bridge API authentication" + env-var reference row.

Live repro (real bridge.js + real impostor HTTP server, real aiohttp):
  origin/main: anon GET /messages 200, wrong bearer /health 200,
               impostor accepted by probe = true
  this branch: anon GET /messages 401, anon POST /send 401, wrong bearer 401,
               adapter probe real bridge ok=true / wrong token ok=false,
               impostor accepted = false, impostor saw bearer = false,
               impostor requests = [/auth-proof] only
Tests: 2 impostor invariants + adopted-with-bearer in test_whatsapp_stale_bridge
(red on origin/main adapter, green here); token lock + proof binding in
test_whatsapp_bridge_auth; standalone harness answers the challenge.
2026-11-12 03:08:11 +01:00
fangliquanflq
0494ea5a8a fix(whatsapp): authenticate local bridge API
(cherry picked from commit 2e0c5ba343849dba7217f5dd58b484ea89074123)
2026-11-12 03:08:11 +01:00
Maciej Lisiewski
b8ea6fe1ad fix(install): don't adopt the uv tarball's uid on root bootstrap
As root, tar restores the owner recorded in the archive, and astral's uv
release tarballs record uid 1001. A root install.sh / setup-hermes.sh
run therefore staged the uv binary root executes owned by whichever local
account holds uid 1001. Extract with -o (no-same-owner; the only spelling
busybox tar without long options accepts).

The Node tarball path the issue names now goes through pm.store's tarfile
data filter, which already drops archived owners.

Fixes #81525
2026-11-11 23:50:31 +01:00
Anthony Holten
8f12eb61fd fix(read_file): drop the SQLite extractor change; production never opens a live store
read_file fetches document bytes through the file backend (a `base64 <
path` subprocess) and extract_document_bytes runs _extract_sqlite on a
private temp copy, so the extractor never opens a live database. The
guarded header read cost more than it protected: it held _live_lock
across the open (a FIFO named *.db would stall every tracked open/close)
and folded missing-file, directory and permission errors into one
message. Restore tools/read_extract.py and drop its tests.

Also name DEFAULT_DB_PATH, _default_db_path() and session_db.db_path
among HX015's documented misses.
2026-11-11 17:20:00 +01:00
Anthony Holten
c50101e5f5 fix(state): route in-process state.db opens through connect_tracked
has_live_connection() and offline_file_access() decide when raw byte I/O
on a live database is safe (closing any raw fd cancels the process's
POSIX locks on the file; #100519). They only see connections opened
through connect_tracked, and several in-process readers used a bare
sqlite3.connect. The read_file SQLite extractor also open()/close()d the
file to check its magic bytes, which cancels the gateway writer's locks
when the agent reads its own state.db.

Route those opens through connect_tracked with tracking_path (same
URIs, timeouts and flags): gateway readiness, the lifecycle ledger's
integrity and journal-mode reads, the API server response store, the
spillover reference scan, install state, doctor, the repair damage
check, shared metrics, the worktree liveness reads cron's sweep runs in
the gateway, backup verification, the restore destination and epoch
reads, the downgrade guard, approvals suggest (whose hand-built URI also
skipped percent-encoding) and the journal-mode switch. The read_file
magic check goes through read_header_bytes_preopen. Offline opens
(snapshots, staging copies, the stdlib-only backup copier) take a
documented HX015 waiver.

Add HX015, "untracked sqlite3.connect on state.db", an advisory
heuristic rule until a replay shows it can block.

Fixes #149276
2026-11-11 17:20:00 +01:00
Ben Barclay
1bd13ebac8 feat(scope): the scope names the agent's owner and role; a turn carries its fence
A Scope now says who owns the agent and what the activity may do on it, and a TurnScope says
which claim the turn runs under:

- Scope gains keyword-only owner (Principal for a personal agent, Group for a shared one) and
  role ("owner" | "manager" | "member"). A personal agent is used only by its owner, so its only
  role is "owner"; a group agent's roles are "manager" and "member". can_administer is true for
  owners and managers. A hosted scope must name both; a local scope defaults to the local person
  as owner with role "owner", so every local caller is unchanged.
- TurnScope gains fence: Fence(epoch, generation), the owner epoch and runtime generation the
  admission claim stamped. bind_turn(session, turn, fence) requires it; claim_fence(row) reads it
  off a claimed session_admissions row. The authority's turn path, the owner-side cron run and
  the managed worker bind the real fence.
- Inside a hosted scope a bind must keep tenant, agent, actor, owner and role; changing any of
  them raises ScopeSwitchRefused.
- bind_profile_scope / scope_for_profile drop the unused turn= tuple: a turn is marked only with
  bind_turn, which has the fence.

Tests that executed a never-claimed admission row now claim it first, as the drain does
(tests/gateway/session_claims.py); hand-built cron rows carry the claim's columns.
2026-11-11 09:54:19 -05:00
Ben Barclay
b738747fe8 docs(code-health): HX016 grandfathers an existing setter call even when its function changes
The rule text promised migration when a function is next edited; the ratchet compares lines, so an
edit around an old call never required it. Say what it does, and pin it with a test.
2026-11-11 09:44:33 -05:00
Ben Barclay
ad90be9b08 fix(scope): terminal policies name their owner; binds copy what they keep
Round-2 review findings:

- A raw terminal mapping could still replace the bound profile's policy with
  another profile's. Raw policies now go through bind_terminal_policy(policy,
  profile_home=...): inside a bound scope only the bound agent's own policy is
  accepted. The four callers pass the session's owning profile.
- A partial bind (home_override=False) inherited the home override from an
  earlier change, so resetting that change took it away. A bind now copies the
  pieces it keeps, so it is whole on its own.
- bind_state switched directly between hosted agents and tenants. Inside a
  hosted scope only a bind of the same tenant and agent is allowed.
- Setters whose tokens are discarded grew the state chain without bound. Changes
  that can no longer be reset fold together on the next push.
- A cross-profile install_profile_terminal_scope dropped its env_overlay.
- HX016 flagged a bare 'from . import set_secret_scope', whose module it cannot
  know.
- The TUI heap-trim ordering test observes the whole-profile release.
2026-11-11 09:44:33 -05:00
Ben Barclay
f09f83088a fix(scope): hold scope, home, secrets and terminal policy as one value
Review found three ways around the guards in the first commit: set_terminal_scope
was unguarded (four production callers), set_secret_scope(None) cleared secrets
alone so get_secret fell back to the launch profile, and a stale or out-of-order
reset token moved one piece back while the others stayed. Guards around three
separate context variables leave every unguarded path able to split them.

The four pieces are now one immutable ScopeState in one context variable. Every
setter is a change to that value; a reset removes its own change and replays the
later ones, dropping those made inside a scope the result no longer has, so any
reset sequence lands on a state whole binds produce. Leaving a hosted agent by
any reset other than the bind that entered it refuses.

- set_terminal_scope narrows a bound local scope's own policy; clearing it, or
  setting it in a hosted scope, refuses. set_secret_scope(None) inside a scope
  refuses.
- bind_profile_scope and bind_state refuse a local bind inside a hosted scope.
- The TUI turn holds one token instead of four; housekeeping still runs under
  the session's whole profile scope and the release resets it at once.
- HX016 sees relative imports and no longer flags a local object named like a
  setter's module.
- The historical updater reads the override through get_hermes_home_override
  when hermes_constants no longer exposes the raw context variable.
2026-11-11 09:44:33 -05:00
Ben Barclay
151dc5fc3e feat(scope): one Scope value for home, secrets and terminal policy
Profile state lived in three independent globals (home override, secret
scope, terminal policy) that every entry point set separately, so they could
describe different profiles. 85 call sites set them by hand.

hermes_scope.Scope(tenant, agent, actor) is now the single value, in one
contextvar; actor is Principal(id) or System(reason), and TurnScope adds
session and turn. agent/runtime_scope.py is the one module that turns a scope
into profile state: bind_profile_scope binds and restores all of it together.
The process's own home keeps its launch semantics; any other home is hydrated
from that profile's sources and stamped as routed.

The legacy setters keep their signatures. Inside a bound scope, a call naming
another profile moves the whole scope (local) or raises ScopeSwitchRefused
(hosted). Gateway turns, cron, the TUI, model switch, kanban spawn and the
managed worker bind once at entry. HX016 blocks new direct setter calls;
existing ones migrate when their function is next edited.
2026-11-11 09:44:33 -05:00
Siddharth Balyan
3bcd071226 fix(ci): the supply-chain scan no longer counts a moved line as new (#153398)
* fix(ci): the supply-chain scan judges a moved file by what changed in it

The supply-chain pattern scan failed on a pull request that moves hermes_cli/_launchers.py to hermes_agent/hermes_cli/_launchers.py and leaves a small forwarding file at the old path. Git showed the old path as modified and the new path as an added file, so all 1,177 unchanged lines counted as added. Line 334, which builds a Windows launcher with exec and base64.b64decode and has been on main for a long time, was then reported as a critical finding.

The scan now runs git diff with --find-copies -l0. Git pairs the new file with its old path and shows only the lines that changed as added. -l0 removes git's file limit: on a diff of about 5,000 files git otherwise skips copy detection and also drops rename detection.

Copy detection alone would also hide a payload-shaped line that a pull request copies into a new file while the original file keeps it. The scan therefore still judges every line of a copied file that its source file still contains after the pull request. A line is treated as moved only when it left its old place.

It still reports a payload line added anywhere: new lines in a moved file, a new file, a copy of an existing file with a line inserted, and a copied line whose source still has it. Renamed files without a forwarding file were already judged by their changed lines and are unchanged. On the 5,230-file move range the scan takes about 8 seconds instead of 1.3.

* fix(ci): the supply-chain scan judges a moved line by whether the diff also removes it

The scan paired a moved file with its old path through git's copy detection and then re-read both files. That missed a payload line when one file was copied to two new paths, and it split lines at characters git does not treat as line ends.
The scan now diffs without rename detection and leaves out an added line only when the same diff removes a line with the same text, once per removed line. A second copy of a moved file and a copy whose source keeps the line are judged.
The copy detection, the name-status parser and the cat-file reader are removed, so the scan no longer needs git 2.38.

* fix(ci): the supply-chain scan treats a line as moved only between files of the same name

An added line was left out whenever the diff removed the same text anywhere, so a payload-shaped line deleted from a test fixture and added to another module produced no finding.
The removed line must now come from a file with the same file name, which is what a move to a new folder keeps. Text taken from a file of another name is judged.
2026-11-11 18:10:04 +05:30
Teknium
1fef533064 docs(config): drop documented keys nothing reads (agent.verbose, display.copy_shortcut, slack.reply_prefix)
- agent.verbose: the example config seeded it, but verbosity comes from
  --verbose / display.tool_progress (de5a88bd97 dropped the read).
- display.copy_shortcut: default added in 645a2f482d with no reader; the
  Ctrl+Shift+C binding never consulted it.
- slack.reply_prefix: the Slack docs promised a prefix on every message, but
  only the WhatsApp adapters read reply_prefix.

Part of #126448
2026-11-10 15:32:44 -08:00
John Paul Soliva
b80bb675a8 fix(gateway): cap image-URL downloads in agent replies at max_inbound_media_bytes
Image URLs in an agent reply are downloaded by Slack / Telegram / Feishu /
Mattermost / Weixin before upload, and those paths read the whole body into
memory with no cap, so a streamed unbounded body could OOM the gateway.
They now stream through the same capped reader the inbound path uses and
take the adapter's existing fallback when the cap is exceeded.

Rebased onto current main (adapters moved under plugins/platforms/, the
SSRF redirect guard went public as ssrf_redirect_guard). The capped reader
is made public too (read_httpx_body_with_limit) so the plugins do not add
new private-core imports; the Teams baseline entry for the old private
name is dropped.

Fixes #122667
2026-11-10 14:17:55 -08:00
unsupportedpastels
fbe9216c11 feat(gemini): Interactions API transport in the gemini provider plugin
Google's Interactions API is now the recommended Gemini interface and where
new Gemini capabilities launch. The gemini plugin now
supplies its own client (ProviderProfile.create_client), which sends each
call to Interactions or to generateContent per model:

- providers.gemini.gemini_api / providers.gemini.models.<m>.gemini_api:
  interactions | generate_content | auto (default). auto keeps
  generateContent except for INTERACTIONS_MODELS (empty for now, so
  default behavior is unchanged). Only the AI Studio host has Interactions,
  so Vertex express and proxy bases stay on generateContent.
- Stateless (store: false): the full history goes as typed steps, so
  compaction, branching and model switches behave as on generateContent.
  Thought signatures ride extra_content.google.thought_signature (the
  existing slot) and replay as thought steps.
- Streaming (step.start/delta/stop, arguments_delta, thought summaries and
  signatures), usage (thoughts folded into completion tokens), status to
  finish_reason, in-band errors mapped to HTTP-equivalent codes.
- Long decode continues requires_continuation hops with
  previous_interaction_id + continuation_token, which needs a stored
  interaction, so only those requests set store: true.
- A long-decode stream that drops resumes from its last mid-stream
  checkpoint token (same request, continued), as the generateContent path
  does. Output past the checkpoint voids it: resuming would repeat that
  output, so the turn is retried instead. The dropped hop is counted up to
  its checkpoint.

One core line: gemini_api joins the known providers.<name> keys, so setting
it no longer logs "unknown config keys ignored". Otherwise core is
untouched: the generateContent path is the existing GeminiNativeClient,
and the plugin rebuilds the same keepalive client and provider TLS settings
the core gives it.
2026-11-10 11:37:47 -05:00
kshitijk4poor
463044ae93 refactor(profiles): reuse the dashboard's config mutation lock; drop slop comments
config_mutation_lock.py duplicated web_server._CONFIG_MUTATION_LOCK (965a548788). The lock now lives
in web_server_profiles beside _SKILLS_PROFILE_LOCK; web_server re-exports it for the routers' LateState
lookups and profile_provision imports it with the scope helpers it already uses.

Comment pass: narration, move history and section banners removed from the
added code; long docstrings trimmed to their contract. The two now-identical create_profile name
checks in check_profile_create_entry.py merge into one branch, and _mirror_voice_sections runs
through _try (logged) instead of its own silent catch-all.
2026-11-10 14:09:08 +05:30
kshitijk4poor
96d816a10f refactor(profiles): one entry point for profile create
`hermes profile create`, `POST /api/profiles` and the Desktop/TUI
`profiles.create` RPC each called `create_profile()` and then ran their own
post-create steps (skills, alias, credentials, model, MCP servers, skill
selection). The same "new profile" therefore came out different
depending on where it was started, and a fix to one surface missed the
other two.

Add `hermes_cli/profile_provision.py` with
`provision_profile(ProfileCreateRequest) -> ProvisionResult`. Every surface
now builds a request and renders the result. `create_profile()` keeps the
folder work (validate, copy, strip channels, stage, publish, notify);
`provision_profile` runs every later step in one fixed order. A failing
later step never undoes the create: it is a warning in the result, as the
dashboard and RPC already treated it.

- The dashboard's model / MCP / skill-selection writers and the RPC's
  launch-credential mirroring moved into the module; the routers import
  them. Every config read-modify-write during create now holds the
  dashboard's `_CONFIG_MUTATION_LOCK` (MCP servers, voice sections,
  endpoint seed and base_url restore were unlocked on main).
- Plugins get no step here: since main's 6933155eaf the core create calls
  the selected memory provider's on_profile_created hook, so every surface
  already gets the provider's per-profile files.
- `scripts/check_profile_create_entry.py` (scripts/check, lint.yml) scans
  every production Python file and fails on any use of `create_profile`
  outside its definition and the new module: calls, imports, aliases, the
  function passed as a value, getattr by name, and files that do not parse.

Behaviour is unchanged on purpose: each surface passes the options it used
before (only the RPC mirrors launch credentials). Two small differences,
both on failure paths: a failing post-create step in the CLI prints a
warning instead of a traceback, and the RPC writes SOUL.md during the core
create (as the dashboard already did), so a failed write fails the create
instead of returning soul_written=false.
2026-11-10 14:09:08 +05:30
unsupportedpastels
bf4d330db0 fix(ci): only delegate to a twin from the same head branch and repository
A cancelled gate could pass on a live run of another PR that shares its head
SHA. Fork runs carry an empty pull_requests list, so the PR cannot be matched
without refusing every fork duplicate; require the twin's head_branch and
head_repository.id to match instead (both duplicates of one push share them).
Also soften the README: the last run to start never passes by delegation,
and a run cancelled while still pending never runs its gate.

Suggested by Greptile; narrowing from @BearHuddleston's review.
2026-11-09 22:16:54 -05:00
unsupportedpastels
d85c6f3974 fix(ci): fail closed with the report when a runs page is not an object
Catch AttributeError in the superseding-run lookup so a JSON list page keeps
the gate failing with its job report instead of a traceback.

Suggested by @BearHuddleston's review.
2026-11-09 22:16:54 -05:00
unsupportedpastels
6d84737945 fix(ci): delegate from approved fork duplicates by run start order
Order superseding runs by (run_started_at, id) so the later entrant to the
concurrency group, which is the one that cancels, carries the verdict. Let
attempt 2 delegate only when attempt 1 concluded action_required (a fork
run held for approval). Adds tests for a pending twin and the client-side
workflow/SHA/event check.

Patch from @BearHuddleston's review.
2026-11-09 22:16:54 -05:00
unsupportedpastels
3105eb1f6a fix(ci): page through event-filtered runs when looking for a superseding twin 2026-11-09 22:16:54 -05:00
unsupportedpastels
3bdbc97063 fix(ci): only let a cancelled duplicate run delegate forward to a newer twin
A cancelled run's gate may now pass only when a strictly newer run (higher id) of the same workflow, event and head SHA is live or succeeded, and only on the run's first attempt. Delegation is acyclic, so two cancelled duplicates can no longer vouch for each other and the newest cancelled run always fails.
2026-11-09 22:16:54 -05:00