Commit Graph

1297 Commits

Author SHA1 Message Date
Maciej Lisiewski
16c0e2a5b3 Merge pull request #154567 from NousResearch/sec/145968-memory-claim-cross-home
fix(memory): refuse a cross-home claim on a live provider instance (#146293)
2026-11-13 18:58:09 +01:00
Maciej Lisiewski
3ab3b20b48 Merge pull request #154503 from NousResearch/sec/126755-a2a-callback-ssrf
fix(a2a): put push callbacks behind the shared SSRF guard
2026-11-13 17:30:19 +01:00
BearHuddleston
69a1ad5c08 fix(bundles): refuse a macOS update ZIP of 1 GiB or more
v0.22.0 ships Electron 40, whose Squirrel.Mac reads the whole update
ZIP into one NSData. From 1 GiB, CFData's growth asks Electron's
allocator for 2 GiB, which refuses, and the app dies with SIGTRAP
partway through the download (electron/electron#55089, fixed in
Electron 44.7). Measured with the real signed v0.22.0 app on macOS: a
1,070,000,000-byte ZIP downloads, a 1,080,000,000-byte one crashes it
at 1,076,887,552 bytes. rc.2-v0.23.2 shipped a 1,447,529,425-byte ZIP
and its macos-packaged-arm64 upgrade job crashed exactly this way.

Recording a macOS build now refuses a ZIP of 1,073,741,824 bytes or
more and prints the margin otherwise, so an oversized build fails in
its own job instead of in the upgrade gate or on users' Macs.
2026-11-13 10:17:50 -06:00
BearHuddleston
e9607bf4e9 perf(bundles): leave Chromium out of the macOS bundle; install it on first use
v0.22.0 on macOS cannot update in-app to a bundle whose update ZIP is
1 GiB or more: its Electron 40 Squirrel.Mac reads the whole ZIP into one
buffer and dies past 1 GiB (electron/electron#55089). The rc.2-v0.23.2
ZIP is 1,447,529,425 bytes, and its Chromium alone is 177 MB compressed.

Chromium is already an optional default: `install.sh --skip-browser`
declines it, and the browser tool installs PM's pinned build once per
process when none is found (browser_launcher._maybe_autoinstall_chromium,
under security.allow_lazy_installs). On a sealed payload that install
lands in the writable store (tests/pm/test_store_extensions.py).

The macOS payload now leaves it out, so the first browser use downloads
it (195 MB). Windows and Linux bundles still ship it.
2026-11-13 10:17:18 -06:00
BearHuddleston
96e4107167 perf(bundles): ship the payload uv cache's venv-identical files once, as links
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
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
v0.22.0 on macOS cannot update in-app to any bundle whose update ZIP is
1 GiB or more. It ships Electron 40, whose Squirrel.Mac reads the whole
ZIP into one NSData; past 1 GiB CFData asks Electron's allocator for
2 GiB, which refuses, and the app dies with SIGTRAP (electron/electron
#55089, fixed in Electron 44.7). Measured with the real signed v0.22.0
app: a 1,070,000,000-byte ZIP downloads, a 1,080,000,000-byte one kills
it. The rc.2-v0.23.2 ZIP is 1,447,529,425 bytes.

Most of that is the payload uv cache shipping a second copy of the
venv: 31,771 of its archive-v0 files (297 MB compressed) are byte for
byte the venv's installed files.

Off Windows, staging now replaces each archive-v0 file the payload venv
holds byte for byte with a relative link to the venv copy. Files the
installer rewrote (RECORD) or placed elsewhere (.data) stay. The uv
seed recreates links that stay inside the cache, as before, and copies
the bytes of a link that leaves it, so the machine cache keeps no link
into a payload an update will replace. MSIX packages hold no links, so
Windows is unchanged.
2026-11-13 10:16:38 -06:00
Maciej Lisiewski
7d94f141b7 fix(a2a): put push callbacks behind the shared SSRF guard
is_safe_callback_url compared the host text against private prefixes, so
integer/hex IPv4 literals (http://2852039166/) and DNS names resolving to
metadata or RFC1918 passed; urlopen then followed redirects the check never
saw and re-resolved the name for the socket.

Non-loopback callbacks now go through tools.url_safety: is_safe_url for the
pre-flight (resolves and checks every answer) and create_ssrf_safe_client for
the POST (connect-time re-validation, dials the vetted IP). Redirects are not
followed. Loopback stays allowed only in localhost-only mode, proxy-free.
create_ssrf_safe_client joins the published plugin API next to its async twin.

Fixes #126755
2026-11-13 16:56:09 +01:00
Maciej Lisiewski
ef34b140a6 test(memory): pin no-weakref claim release; drop dead _Recording check
Drop the never-instantiated _Recording subclass whose assertion could not
fail, end the slots test by dropping alpha's managers and rebinding to beta
(kills the strong-manager-ref and no-cleanup mutants), and say in the plugin
docs that the shared-instance refusal applies on any multi-profile host.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-13 16:54:40 +01:00
Maciej Lisiewski
13f0fd8e51 Merge pull request #154512 from NousResearch/sec/126294-media-redirect-ssrf
fix(gateway): re-check every redirect hop for Mattermost and Weixin media downloads
2026-11-13 16:21:27 +01:00
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
Maciej Lisiewski
f69a049eae fix(gateway): serve the aiohttp redirect guard from gateway.platforms.helpers
The Mattermost and Weixin plugins imported tools.url_safety.ssrf_checked_aiohttp_get,
a core name outside the published plugin API, which raised two new module_to_core
crossings in scripts/boundary_lint.py. Move the helper next to platform_http_client
in gateway.platforms.helpers (already published), keep tools.url_safety's
async_is_safe_url as the per-hop check, and document it under the platform-adapter
public helpers. No baseline change.
2026-11-13 13:57:43 +01:00
Sahil-SS9
6600bde0d9 feat(plugins): ctx.redact_text() so plugins scrub secrets without importing agent.redact
Plugins that store or upload text (session sharing, edit capture) need Hermes's
own scrubber at its strongest setting, and today the only way is a private
import of agent.redact, which the catalog flags. Add a thin PluginContext
method: non-reusable sentinels for prefixed keys, masked credential
assignments, plugin-registered patterns included, security.redact_secrets
honoured unless force=True.
2026-11-13 00:56:05 -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
Teknium
4bad741311 fix(file_safety): published read check refuses device and /proc files
get_read_block_error is the path check plugins are told to call, but only
read_file consulted the device/proc table, so a plugin following the docs
could still read /proc/<pid>/environ (process secrets) or hang on /dev/zero.
The path-only table and is_blocked_device_path move into agent/file_safety;
get_read_block_error checks the literal and resolved path; read_file keeps
its symlink-hop walk and imports the table from there.
2026-11-12 22:33:52 -08:00
Maciej Lisiewski
232e4e7d6d Merge pull request #153681 from NousResearch/sec/91308-aux-openai-key-host-gate
fix(aux): gate OPENAI_API_KEY on OpenAI hosts for custom endpoints
2026-11-12 22:23:57 +01: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
e94a35ca6c fix(webapp): serve a desktop bundle's prebuilt renderer as shipped
`hermes webapp` and the Desktop's Web Access Start reuse a renderer only
when scripts/build/freshness.mjs certifies it, and a bundle's sealed
payload ships no scripts/. Even with the Webapp planted they took the
build lock in the install root (Permission denied inside WindowsApps; a
lock file written into the signed macOS app) and then tried to build
from sources the payload does not have.

A bundled payload (install stamp payload "bundled") now serves its
planted dist-webapp as it is, like the Nix package's HERMES_WEBAPP_DIST:
no freshness check, no lock, no build, and --force-build says it cannot
be rebuilt. The Termux .deb stamps payload "runtime" and is unchanged.
2026-11-12 14:16:57 -06:00
Maciej Lisiewski
75db00e04c docs(aux): OPENAI_API_KEY fallback now reaches OpenAI hosts only
Follow-up to the host gate: four more places still promised an
unconditional OPENAI_API_KEY fallback for custom endpoints.
2026-11-12 15:55:53 +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
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
c94ac05b54 docs(plugin-catalog): admission rule 19, no plugins built to reach infringing content
A plugin whose main purpose is streaming or downloading copyrighted
material from unlicensed sources could pass review on clean code alone;
no rule covered what a plugin is for. Rule 19 declines those while
keeping general-purpose browsers, downloaders and players welcome.
Mirrored into the catalog-submission guide (rules mirror test).
2026-11-11 18:49:49 -08:00
yoniebans
509d122b37 fix(desktop): let inline HTML previews fill the transcript column
An inline ::preview frame took its width from the first size report its page sent and kept it, capped at 640px. A page that fills its frame reports whatever width it was given, so a preview opened in a narrow window stayed narrow after the window widened, and a chart drawn after load kept the width it had before drawing.

The frame now spans the transcript column up to 960px and CSS follows the column on resize. The injected script reports height only, which still tracks live within the existing 120 to 1200px band. The 960px cap keeps a square graphic drawn at full width inside that height band instead of scrolling inside the frame. Frame and document are transparent with no border, so a small fixed-size widget laid out from the left edge still reads as a small card; a centered one now sits mid-column.

The desktop platform hint described the old width rule to agents; it now gives the frame's width cap and height band, keeps the advice to lay content out flush left with no centering wrappers, and asks for charts sized from the frame's current width and redrawn on resize. The prompt-surface snapshot carries the same change, and the desktop plugin SDK guide's sentence on how the frame sizes itself now says the same.
2026-11-11 21:12:00 +01:00
kshitijk4poor
6e9f696ee6 refactor(profiles): one create receipt type; config outages and 4064 read as unknown
Round-3 review of the gateway create path found three defects and one
structural duplication.

- A config backend outage mid-create read as "nothing was created".
  ConfigBackendUnavailable is a SystemExit, so it escaped the handler's
  `except Exception` and the dispatcher answered 4064, which the client
  read as refused-before-create, even when the profile had already been
  published. The handler now catches it (and builds the receipt inside
  the same try) and answers 5062. The client no longer treats a bare
  4064 as "nothing was created"; only 4061 (no name) is.
- Every `hermes profile create` loaded gateway.platforms (~225 modules,
  about +105 ms median) even with no gateway URL, because the
  safe_proxy_url_for_log import sat above _where's early return. It now
  loads only when a URL is set; a test pins that a URL-less create loads
  neither gateway.platforms nor pydantic.
- A newer gateway that added a key under `mirrored` turned a successful
  create into "may have created": the strict check forbade extra keys
  there. `mirrored` is now a mapping of known value types, so new keys
  are kept and never printed.

The receipt had two definitions: the CreateReceipt dataclass and the
contract's ProfileCreateReceipt pydantic model, kept in step by a
field-name test and a hand-written check that skills_seeded["copied"] was
a list. There is now one: the stdlib dataclass ProfileCreateReceipt in
hermes_cli.profile_provision, which the contract uses directly as
ProfilesCreateResult.receipt (pydantic validates dataclasses), so the
generated TS/OpenRPC still describe it. from_wire validates it strictly
with a TypeAdapter (pydantic only on the gateway path). The receipt
carries what the CLI prints, skills_synced (a count) and
skills_opted_out, instead of the raw sync-result dict, which removes the
`copied` check; RECEIPT_FIELDS and the parity test are gone.

Also:
- The refusal chunk limits are imported from gateway_client
  (ERROR_DATA_TEXT / ERROR_DATA_ITEMS, now named there) instead of
  copied, so lowering the client cap can't silently drop every part.
- A typed refusal with no text is still a refusal ("nothing was
  created"), not "may have created".
- POST /api/profiles uses CREATE_REFUSALS.
- The wrapper check reuses profiles.profile_matches_home.
- The developer guide states the wrapper rule the code enforces.
2026-11-12 01:17:05 +05:30
kshitijk4poor
f12c33d0f8 refactor(profiles): one typed create receipt; gateway creates report what they can't confirm
The gateway route for `hermes profile create` returned a hand-built dict that
three places listed by key (receipt(), receipt_defaults(), the contract), and
dropped which route made the profile, so the CLI re-read
HERMES_TUI_GATEWAY_URL to decide the alias. Several outcomes were also
reported wrongly.

- CreateReceipt (profile_provision) is the one receipt: CreateReceipt.of()
  after a local create, to_wire() on the gateway, from_wire() on the client.
  A test keeps its fields equal to the contract's ProfileCreateReceipt, and
  every contract field is now required.
- create_through_gateway returns a CreateReceipt and writes the
  ~/.local/bin wrapper itself after a create on this machine: a discovered
  local owner or a loopback HERMES_TUI_GATEWAY_URL (the dashboard's chat
  terminals). Before, a loopback URL never got a wrapper. write_alias
  returns (path, collision) instead of filling a result object, and a
  wrapper failure after a gateway create is a warning, not a traceback.
- profiles.create no longer cuts refusal text at 200 characters for every
  client (Desktop showed "...create bad-"): error.message carries the whole
  redacted text, and error.data repeats it in short parts gateway_client
  keeps. The client redacts refusal text and receipt warnings again before
  printing.
- Outcomes the CLI can't confirm say "may have created ...; check hermes
  profile list" instead of "could not create" or a traceback: an untyped
  handler error, any exception after the request went out, a non-dict
  answer, and a receipt with missing or malformed fields.
- HERMES_TUI_GATEWAY_URL must be ws:// or wss:// with a host (what
  connect_gateway accepts); IPv6 hosts are bracketed in messages.
- One lock per profile name around the core create, not one for every name:
  the core create includes the multiplexer rescan (up to 8 s), so creates of
  different names waited on each other and held gateway pool workers.
- A gateway create reports why skill seeding failed: seed_profile_skills
  collects its failure lines (problems=), and a quiet create's receipt
  carries them as warnings.
- GatewayRPCError.unknown_method replaces four copies of
  `code == -32601 or str(exc) == "unknown_method"`.
2026-11-12 01:17:05 +05:30
kshitijk4poor
332ac8000e feat(profiles): hermes profile create goes through the running gateway
The CLI was the last create surface that made profiles in its own process.
It now asks the gateway that serves its profile, over the same
profiles.create RPC Desktop uses, and prints the receipt the gateway reads
where it made the profile:

- a ready gateway for the terminal's profile (discovery only; one is never
  started for this) takes the create; with none, or a local one that
  predates these fields (-32601 / 4000), the CLI creates in-process as
  before;
- HERMES_TUI_GATEWAY_URL names a gateway: the profile is made there, and
  an unreachable or older gateway is an error, never a local create. The
  URL's token is never printed;
- a refused create keeps its type (error.data.type), so the CLI prints the
  same "already exists" / "does not exist" errors;
- a socket lost after the request was sent is reported as unknown, with a
  pointer to `hermes profile list`, never retried.

profiles.create gains optional clone_config (`--clone` with no source:
copy the caller's profile), sync_imports and report. On /api/ws it already
runs in the connection's profile (dispatch_legacy binds the ticket's), so
`hermes -p work profile create x` against the multiplexer copies work's
keys, model and (with --clone) SOUL.md.

provision_profile now holds a per-name lock around the core create. The
gateway takes every terminal's create in one process, and create_profile
stages in profiles/.<name>.staging-<pid>, so two same-name creates there
shared and removed each other's staging dir; the loser failed with a raw
OSError (Errno 66 / ENOENT) instead of "already exists". The staging path
came from b47fb2eba3 (teknium1, 2026-09-13).

Review folds: a retiring gateway (5035) or an older one naming
unknown_method creates locally; a gateway that made the profile without
a receipt is reported, never re-created here; Ctrl-C after the request
says the create may still finish; the ~/.local/bin wrapper is written by
the CLI (this terminal's PATH and hermes), none for a URL gateway; the
gateway URL is named as scheme://host[:port] only (never its token,
userinfo or a hostless path), and recovery hints point at the gateway's
machine; refusals and 5062 carry the gateway's message, redacted (a parse error
can quote a config line); `--clone-from ""` is refused before any create. One
process lock around the core create (not seeding or the alias).
2026-11-12 01:17:05 +05:30
Ben Barclay
e8bd5bb626 fix(sandbox): stop_idle is required of a hosted backend; an idle sandbox is never destroyed (round-2 finding 6)
stop_idle moves from the optional to the required hosted operations, so a backend
without suspension support is refused with HostedSandboxRequired when its sandbox is
created, before any tool runs. The idle reaper always takes the suspend path for a
hosted sandbox key. If stop_idle is missing at reap time the call fails and is
logged, and cleanup() is never called instead, so idleness never destroys a
workspace. The docs and the provider docstring say so.
2026-11-11 10:22:54 -05:00
Ben Barclay
99a69efede fix(sandbox): an acquired process stream stays its agent's (round-2 finding 16)
start_process and attach_process returned the backend's raw stdin/stdout/poll, so a
stream acquired under A could be read or written by anyone holding it under B. They
now return ScopedPipe proxies and a scoped poll. Every pipe operation (read, write,
flush, close, fileno, iteration, attribute access) and poll() checks the bound scope
against the sandbox's identity first, and refuses with CrossAgentHandleRefused under
another agent or with no scope bound. The foreign_handle_refused conformance check
drives the real stub process stream under B. A unit test covers start and attach.
2026-11-11 10:22:54 -05:00
Ben Barclay
468e1628c5 fix(sandbox): a hosted scope refuses every tool that would run on this host
browser_exec ran the model's Python in a host subprocess (a cloud browser
moves Chromium, not the interpreter), and it was not the only tool the
sandbox routing never reached. Tools with no route through the agent's
environment yet now fail closed in a hosted scope, before any setup, file or
process, with an error naming why (tools/hosted_tool_policy.py):

- by toolset, at ToolRegistry.dispatch: the browser tools, computer use and
  desktop UI, desktop projects, image and video generation, text to speech,
  skills, cron jobs, delegation, kanban, catalog and connection management,
  onboarding, and every MCP server's tools (they come from the profile's
  config and run for it);
- directly, on the paths the registry never sees: the browser_exec entry,
  checkpoint take and restore, inline skill shell, @-references, the
  workspace git probe in the system prompt, cron scripts, MCP stdio spawns,
  media delivery by host path, connector file inputs, document extraction in
  read_file, voice transcription and delegate_task's inline dispatch.

Routing each of these through the sandbox is follow-up work; refusing them
keeps the hosted guarantee that nothing tenant-supplied runs or is read here.
Local installs are unchanged (every check is a no-op with no hosted scope),
which a permanent test now pins: env maps and built-in backend constructor
arguments are byte-identical, unscoped and under the local scope, to the
same calls with the hosted machinery switched off.

The developer guide describes the hosted operation interface, what runs in
the sandbox, and what is refused.
2026-11-11 10:22:54 -05:00
Ben Barclay
178b1d0349 feat(sandbox): a hosted scope's tools reach only its agent's sandbox
Hosted Hermes serves many tenants' agents from one process, and each agent's
commands, code, background processes and files must live in that agent's own
remote sandbox. Until now the environment a tool reached was keyed by task id,
session key or profile path, so nothing tied it to the agent the bound scope
names, and a hosted scope could fall back to running on this host.

The sandbox an operation reaches is now derived from the bound scope's
(tenant, agent) alone (tools/environments/sandbox_scope.py). In a hosted scope:

- every environment key is the agent's sandbox key, whatever task id a call
  carries; the terminal.backend provider must declare serves_hosted_scopes
  (built-ins are refused) and receives scope= and sandbox= at creation, with
  task_id set to the identity's key;
- core wraps the returned environment in ScopedEnvironment, which refuses any
  call made under another agent's scope (or none) and passes the bound scope
  to execute/fetch_* when the backend declares it; a cached environment that is
  not the agent's own is refused at lookup;
- terminal, execute_code (always the remote kernel), background processes and
  read/write/patch/search go through that environment; file-tool bookkeeping
  never stats or opens the requested path on the host;
- background processes carry the sandbox key they were started under, and
  another agent's process is indistinguishable from a missing one (get, list,
  prefix lookup, kill sweeps).

Environments gain start_process/attach_process/stop_process with a
bidirectional byte stream (ProcessStream), implemented for the local backend
and exec-prefix backends; a ProcessRef naming another sandbox is refused.
Credentials are typed as broker references only (CredentialRef); no broker
exists yet, so none are passed.

Local installs are unchanged: with no hosted scope bound every branch keeps
today's keying and backends. A conformance module with a recording stub
backend runs the isolation checks through the real tool registry, so a hosted
backend plugin can run the same checks against its own provider.

process_registry.py's handoff handler moves to process_registry_handoff.py to
keep the facade under its size cap.
2026-11-11 10:22:54 -05:00
Ben Barclay
396a43ec6d docs(scope): reflow the docstrings and docs left broken by the administration rename 2026-11-11 09:54:19 -05:00
Ben Barclay
a618df2379 fix(scope): replace the owner/manager/member role with one administration right
Who administers an agent is decided where the signed claim is made (in Hermes Cloud: a personal
agent's owner, and the org's owners and admins for an agent owned by the org or a group), so the
scope carries only the result. A personal agent its owner shared runs a teammate's turn as that
teammate, unable to administer it.
2026-11-11 09:54:19 -05: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
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
Teknium
bf77c21427 fix(gateway): picker cards and the /update prompt answer only to their opener
A picker card (/model, /reasoning, /fast, the usage-limit switch offer)
and the /update Yes/No prompt only checked the chat allowlist on a tap,
and a pending /update prompt took the next message ANY admitted member
sent in the session as its answer. In a shared group with
group_allow_admin_from set, a member refused /reasoning or /model could
tap the admin's open card and apply it, and anyone's chat text answered
the admin's "Restore local changes now?".

The gateway now records the opener (sender id, name, chat scope) when it
sends the card (prompt_authority on the selection callback) and in the
/update pending marker. Every renderer refuses another member's tap with
the existing localized "Only <name> can answer this approval." note and
leaves the card open: Telegram mp:/cp:/update_prompt:, Discord
ModelPickerView/ChoicePickerView/UpdatePromptView (one _gate), Slack
model picker (ephemeral), Matrix picker reactions, Feishu choice picker
and update card (toast). A non-opener's typed text during a pending
/update prompt falls through as an ordinary message. The check is
gateway.approval_actor.may_answer, the same rule exec approvals use:
the opener and the chat scope's admins always pass; a sender-less card
(shared observed route) keeps the old anyone-admitted behaviour.

QQBot's update button already accepts only the session's own user.
picker_refusal / update_prompt_refusal join approval_refusal in the
published plugin API so platform plugins can apply the same check.
2026-11-10 14:06:57 -08:00
Teknium
17dd06937e fix(gateway): a non-admin cannot answer a prompt where they could not type its command
With `allow_admin_from` set and the default `approvals.approvers: ["*"]`, a non-admin was
refused `/approve` but could still answer an admin's blocked command by typing a bare
`always` (which also writes the profile-wide allowlist), tapping Allow on any adapter, or
answering a `/reset`-style slash confirm.

`gateway.approval_actor.may_answer` now takes the answer's command (`approve` / `deny`, or
the confirmed command) and the chat's full slash policy, so one decision covers every path
main already routes through it: `/approve` and bare words, typed confirm replies, relay,
and the Telegram/Discord/Slack/Matrix/Feishu/Teams/WhatsApp Cloud buttons; QQ Bot's settle
now passes the clicker too. Precedence: a narrowed `approvers` decides on its own
(requester, listed ids, admins); under `["*"]` the slash policy decides (admins plus
`user_allowed_commands`). No admin list, admins and clarify answers behave as on main.

Fixes #120506

Co-authored-by: Froraut <79215537+Froraut@users.noreply.github.com>
Co-authored-by: John Paul Soliva <soliva.johnpaul@icloud.com>
2026-11-10 13:52:56 -08:00
unsupportedpastels
f13f5bfc35 fix(platforms): keep picker catalog reads in the owning profile and list a v12 endpoint once
Use the built-in /model picker's non-blocking catalog path, so no prefetch
thread pool runs outside the conversation's profile scope, and pass the
merged custom-provider view so a current endpoint defined under providers:
is not listed a second time as a synthetic custom row.

Both changes and their tests are patches from @BearHuddleston's review.
2026-11-10 09:16:04 -05:00
unsupportedpastels
f0557ff9a6 feat: expose conversation-scoped platform model picker catalogs
Keep raw endpoint matching and config inputs inside core; return detached presentation rows. Share profile-scoped resolution with the display accessor and persisted-pick fallback. Custom endpoint live probes are disabled to avoid config writes.
2026-11-10 09:16:04 -05:00
unsupportedpastels
871f909889 fix: show persisted model picks before the first turn
Patch from @BearHuddleston's review. Also cover scheme-only endpoint redaction.
2026-11-10 09:16:04 -05:00
unsupportedpastels
0e23a00b44 fix: honor independent channel model display defaults 2026-11-10 09:16:04 -05:00
unsupportedpastels
e0f3723ada feat(platforms): expose read-only session model settings
Add a detached display snapshot for Inline's native conversation settings sheet without exposing credentials or allocating sessions. Keep the legacy override view unchanged.

Verification: canonical focused runner, 4 workers, 51 passed; unchanged base plus new tests: 35 passed, 16 failed for the missing accessor. scripts/check: 15 checks ok; boundary lint: exit 0. Pre-commit hook unavailable (just not installed); equivalent lint gates run directly.
2026-11-10 09:16:04 -05:00
BearHuddleston
48f1a15f9c docs(gateway): note that ensure re-renders a dead Windows launcher
The developer guide said `hermes gateway ensure` never rewrites service definitions. Since this PR it re-renders the Windows launcher scripts the Scheduled Task and the Startup entry run, when they are the installer's own and their interpreter is gone, and leaves the task and the Startup entry unchanged. The paragraph now names that exception.

Reported by @jquesnelle on #152232.
2026-11-10 06:25:43 -06:00
kshitijk4poor
f2187d2743 docs(terminal): state the cleanup() raise rule; tidy the reaper tests
- `BaseEnvironment.cleanup()` documents the contract teardown relies on:
  raise only while the sandbox may still be live, since a raise skips
  settling its background processes.
- The plugin guide matches it: settlement also runs when cleanup reports
  the sandbox already gone, and `cleanup_stops_processes = True` means the
  processes are gone for that env object (ended or unreachable).
- The reaper tests share one env-cache fixture (the two hand-copied blocks
  skipped `_calls_in_flight`), the SSH-like double initialises its cleanup
  count, and the settlement race patches `_finish_exited` via monkeypatch.
2026-11-10 15:47:18 +05:30
kshitijk4poor
861f0c5f10 fix(terminal): a cleanup failing after the sandbox is gone still settles its processes
Teardown settles a closed env's background processes only when cleanup()
returned, so a cleanup that raises while the sandbox is still up leaves
them polling. Two backends could raise after the sandbox was already gone:

- Vercel: snapshot() stops the sandbox, then saving the snapshot id
  (disk full) raised out of cleanup(), skipping the stop/close and leaving
  the processes unsettled; the next poll tried to recreate a sandbox.
  The save is now caught and logged, like a failed snapshot.
- Modal: terminate succeeded, then stopping the async worker could raise
  on a closed loop before the sandbox handle was cleared. The handle is
  dropped first and a worker-stop failure is logged.

Also: eviction logs the key it actually evicted (the image switch passed
no task id), the settlement tests no longer swap the registry lock, and
the terminal-environment plugin guide documents `cleanup_stops_processes`
for plugin backends whose jobs survive cleanup().
2026-11-10 15:47:18 +05:30
Teknium
709748aeca fix: count replayed reasoning at the provider's billed size so compression sees it
Codex/xAI encrypted reasoning and Claude signed thinking from earlier turns are
resent on every request and billed as input at the reasoning count the provider
reported for that turn (live A/B: gpt-5.6-sol 2,765 -> +2,767, grok-4.7 73 -> +76,
claude-opus-5.5 3,959 -> +3,959). Hermes priced the ciphertext at 0 (and Claude
at its ~1/4-size summary), so long reasoning-heavy sessions looked small:
compression found nothing to cut while the real bill sat over the window.

Each assistant row now records its response's reported reasoning count in
display_metadata, and the preflight trigger, tail-budget walk and native
Anthropic projection charge it. Compaction checkpoints still cost 0. Anthropic's
output_tokens_details.thinking_tokens is now read (it was always 0).

Fixes #125920
2026-11-09 23:23:46 -08:00
unsupportedpastels
6835dd55da refactor(gateway): read turn timestamps, overflow queues and stale approvals from SessionState
Drop the _running_agents_ts, _busy_ack_ts, _queued_events and
_pending_approvals legacy dict views from GatewayRunner. The stall
watchdog, shutdown flush/cleanup, /agents and the stale /approve-/deny
path now read SessionState directly (peek, never creating a row), and
tests set SessionState fields instead of the views.
2026-11-09 23:04:25 -05:00
unsupportedpastels
a2eb175f62 feat(plugins): publish the browser-vault seams LoginBackend, VaultItemMeta and BrowserPageBackend on the plugin API
browser-vault-plugin.md tells plugin authors to subclass LoginBackend, return VaultItemMeta and
subclass BrowserPageBackend, and ctx.register_login_backend / register_browser_page_backend accept
only instances of those classes, yet hermes plugins validate warned on all three imports. List them
name-only in plugin_api.json, regenerate public-api.md and drop their docs import seam entries.
LocalEnvironment stays a seam: it is the host implementation class, not a stable base.
2026-11-09 22:18:11 -05:00
unsupportedpastels
0d292cf9ac docs(plugins): list the missing callers of the finalize, approval and pre_tool_call helpers
Patch from @BearHuddleston's review.
2026-11-09 22:17:43 -05:00
unsupportedpastels
ba7dd8d95d docs(plugins): name _reset_session_off_loop as the gateway on_session_reset fire site
Suggested by Greptile.
2026-11-09 22:17:43 -05:00
unsupportedpastels
b33912c24f docs(plugins): list every event that fires gateway_platform_event in the hook reference 2026-11-09 22:17:43 -05:00