Commit Graph

85 Commits

Author SHA1 Message Date
unsupportedpastels
1ae3c55e4b test(a2a): cover token-mode Host, malformed Host and missing Content-Type
Add tests that a token-authenticated listener still serves a foreign Host, that malformed Host values fail closed, and that a no-token POST without a Content-Type is refused. Give the no-token Host rule its own README bullet and document every 403 refusal message.
2026-10-26 23:21:53 -04:00
unsupportedpastels
544edcf794 fix(a2a): serve loopback literals and the A2A_PUBLIC_URL host in the no-token Host check
The no-token Host check accepted only localhost, 127.0.0.1 and ::1, so other loopback literals and a local reverse proxy forwarding the configured A2A_PUBLIC_URL host were refused. Accept any loopback literal and the A2A_PUBLIC_URL host, name both in the 403 message and docs, and document the Content-Type refusal.
2026-10-26 23:21:53 -04:00
John Paul Soliva
53d28d9b85 fix(a2a): accept the absolute form localhost. in the no-token Host check
Keeps the loopback-name check consistent with the hermes proxy one: a
trailing dot names the same host, while a rebound name stays refused
with or without it.

(cherry picked from commit 5d1c94588affb445638426653e2230132c741ec6)
2026-10-26 23:21:53 -04:00
John Paul Soliva
3846641765 fix(a2a): refuse a non-loopback Host in no-token mode
Without a token the listener trusts whatever reaches 127.0.0.1. A page on a hostname
that re-resolves to 127.0.0.1 is same-origin to it and could read /health (the
served-agent list), the Agent Card and /metrics. parse_request now refuses such a
Host with 403 before any route runs; a malformed Host fails closed. Token mode is
unchanged.

Fixes #126203

(cherry picked from commit 7d71a6082e325eee0880ea82542cce7db2459517)
2026-10-26 23:21:53 -04:00
John Paul Soliva
881eb6c252 fix(a2a): refuse browser-originated POSTs in no-token mode
Without a token the A2A listener identifies callers by the loopback
socket alone, which a web page open in the operator's browser can also
reach. In that mode, refuse a POST that carries an Origin header, a
Sec-Fetch-Site other than none/same-origin, or a non-JSON Content-Type
(the body types a page can send without a CORS preflight). Token mode
is unchanged.

(cherry picked from commit cfb36d3c5f30fc205c5d0ef122e43dd482bcfc91)
2026-10-26 23:21:53 -04:00
Teknium
95505c60e9 docs(tools): lead every tool description with its key capability
The deferred tool_search catalog shows each tool's first sentence clipped to
60 chars, so lines like 'image_generate: Generate high-quality images from
text prompts, or edit /…' hid that it edits with reference images on the
user's configured model. An agent skipped it and called FAL directly with a
hardcoded model.

- catalog line cap 60 -> 80 (CATALOG_SUMMARY_MAX_CHARS); every built-in
  tool's first sentence now fits and leads with what it does
- image_generate/video_generate say they use the configured model;
  image_generate says to use it rather than direct API calls/scripts
- web_search/web_extract/browser_exec name when to use each other
- drop a duplicated cronjob sentence and filler in skill_view/video_generate
- regenerate tests/fixtures/prompt_surface
2026-10-23 16:04:50 -07:00
Teknium
d2b3446b1e fix(a2a): one IPv6 server class; dual-stack peers keep their IPv4 identity
Folds the two IPv6 server classes into one: every IPv6 host gets
AF_INET6, and V6ONLY=0 makes the :: wildcard answer IPv4 too.

A dual-stack socket reports an IPv4 peer as ::ffff:a.b.c.d, so the
shared-token / no-token identity became ip:::ffff:127.0.0.1 and an
A2A_TRUSTED_PEERS entry written as ip:127.0.0.1 no longer matched
(403 "peer not trusted"). _client_ip unmaps it. The test drives a
token-gated :: bind over both stacks plus an IPv4 tasks/list call
behind an IPv4 allow-list.
2026-10-20 04:05:08 -07:00
John Paul Soliva
1f0981bd8e fix(a2a): accept the bracketed [::1] spelling of an IPv6 A2A_HOST
A2A_HOST=[::1] was not recognised as loopback (no-token runs fell back
to 127.0.0.1 with a misleading warning), failed to bind with a token, and
advertised http://[[::1]]:port/. Strip URL brackets when capturing the
host, and pin the Host-less advertised URL in the IPv6 test.
2026-10-20 04:05:08 -07:00
John Paul Soliva
9f908ca3dd fix(a2a): bind and advertise IPv6 hosts such as ::1
A2A_HOST=::1 is an accepted loopback bind, but ThreadingHTTPServer is
AF_INET only, so the listener failed with bind_failed. An IPv6 host now
uses the AF_INET6 server, and the Agent Card URL brackets the literal.
2026-10-20 04:05:08 -07:00
chatchap-2nd-of-chartup
36a6c85c46 fix(a2a): dual-stack (AF_INET6, V6ONLY=0) bind when A2A_HOST=::
What this fixes: A2A_HOST=:: is the conventional IPv6 wildcard (one socket,
both stacks). stdlib ThreadingHTTPServer is AF_INET-pinned and cannot bind
:: at all (gaierror 11001 on Windows) - A2A stays down. The AF_INET pin is
the root cause.

Change: when host == ::, swap in an AF_INET6 + IPV6_V6ONLY=0 subclass; one
dual-stack socket, matching the aiohttp DM bind on 8642. Other hosts keep
the standard family. Failed binds stay loud via the existing bind_failed
fatal/retry path.

Test: regression test - with A2A_HOST=::, connect a live adapter, assert
dual-stack class + AF_INET6 + V6ONLY=0, GET the agent card over [::1] on
the bound port. Placed in TestBindSafety (default lane) because the repo
addopts -m "not integration and not live" deselect the integration class;
self-skips on hosts without IPv6. Verified against the upstream adapter
before the change: the same live bind fails (getaddrinfo EAFNOSUPPORT on
Linux; the same failure class as gaierror 11001 on Windows).

Related work: complements #126285 (IPv6 literal bind + bracketed agent
card URL) by making the A2A socket dual-stack (V6ONLY=0) so :: answers on
both stacks.

Base: 865ba906 (main).
2026-10-20 04:05:08 -07:00
Teknium
9b681c38c3 fix(a2a): a forwarded message refused before admission is refused again on resend
Mechanism: _prepare_task recorded a fresh forwarded messageId in the process retry
LRU before the anti-loop and empty-text guards ran. A fresh over-budget message was
rejected once, but its exact resend then looked like a retry, was assigned turn 0,
and was forwarded to the owner (COMPLETED -> REJECTED -> COMPLETED, two owner calls).

Fix: when a fresh (non-retry) input is refused by a pre-admission guard, drop its id
from the retry LRU so the resend is classified as fresh and refused again. Accepted
inputs keep their retry entry.

Test: tests/plugins/test_a2a_rejected_resend.py (red on r14-base: third state COMPLETED).

Review: andrexibiza 4243963753
2026-10-11 23:38:03 -07:00
Teknium
8693fa6914 Revert the tasks/cancel half of "fix(a2a): a forwarded task's cancel is refused; retries survive the id LRU"
This partially reverts 702f87906a4 under the regression-only scope ruling.

On origin/main, _rpc_tasks_cancel is byte-identical: it marks the task CANCELED, resets the
turn counter and resolves the local future, and never reaches the profile the task was
forwarded to. On main that forward is a `hermes chat` subprocess the adapter also cannot
stop. The cancel behaviour is therefore PRE-EXISTING and goes to the follow-up issue.

Kept: the retry identity. _note_forwarded_input, its 1000-entry LRU and the owner admission
input_id are new in this PR (none of them exist on main). The durable context-log fallback
for an evicted id therefore stays, along with its test
test_a_resend_evicted_from_the_process_memory_is_still_a_retry. The task record's input_id
field stays because the forward path stamps it.

Review: andrexibiza 5480715949-P2c (cancel half: pre-existing)
(cherry picked from commit b3a6b3ff1b2698869ca8702ad72628146cd15f20)
2026-10-10 22:49:19 -07:00
Teknium
ec881ef75b fix(a2a): a forwarded task's cancel is refused; retries survive the id LRU
tasks/cancel on a task forwarded to its profile owner marked the A2A
task CANCELED, reset the turn counter and resolved the local future,
but never reached the owner: the admitted turn ran to completion while
the peer was told it was canceled. Separately, the retry check for a
forwarded resend (the message's input_id) lived only in a 1000-entry
process LRU, so an evicted (or pre-restart) id was treated as a new
message: it spent the anti-loop turn budget and logged the user text
again.

The task record now carries the input_id it was forwarded as, and
tasks/cancel answers TaskNotCancelable for a forwarded task (the
adapter cannot stop owner work; a2a.forward has no cancel verb and
forward_to_owner's contract is that accepted work is never cancelled).
The context log stores the forwarded input_id with the user message,
and the retry check falls back to it when the LRU misses, so the
owner's exact-retry dedup and the local bookkeeping agree.

Tests (red on r11-base: cancel answers CANCELED; the evicted resend
spends turns and logs twice):
tests/plugins/test_a2a_forwarded_cancel_retry.py

Review: andrexibiza 5480715949-P2c
(cherry picked from commit 702f87906a4110c50c891a9e852b086062f8c701)
2026-10-10 22:49:19 -07:00
Teknium
e1a10b0bc2 ci: bring the branch's own code under main's strict ruff config
Main made the strict ruff config the default (`ruff check .`, blocking), and
the branch's code carried 278 findings under it (main itself is clean). Fixed:

- PLW1510 (86): `check=False` on each subprocess.run, preserving behaviour,
  as main's own sweep (0006a5e229) did.
- ASYNC220 (9, test fixtures only): `noqa` with the reason, main's convention
  for a Popen that returns at once and whose handle the test drives.
- ruff's safe autofixes plus the narrow unsafe ones (UP006/UP037/RUF100/RUF013/
  PLR0402/RUF059 underscore renames/UP031/UP041/UP017/FURB167/PIE807/RUF007/
  RUF015/RUF022/FURB162), and by hand: four %-formats to f-strings, three
  unused unpacked names, one fixture loop over `.items()`.

No behaviour change. `ruff check .` passes; scripts/check passes; the 412 test
files mirroring every edited file pass (3 tests/pm files that fail only under
that batch's uv lookup pass solo, before and after this commit).
2026-10-10 17:59:08 -07: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
Maciej Lisiewski
9eab688b42 ci: ruff UP017 fixes 2026-10-09 17:34:36 +02: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
b6bf0183ba refactor(gateway): narrow or log blind excepts; time out eval subprocesses
Code-health ratchet on PR #106742 (BLE001/S110/HX006), no behaviour change:
- narrow per-row JSON skips: hosted_room_attachments.reconcile_room_events
  (ValueError/TypeError/AttributeError/RecursionError), hermes_state_gateway
  routing-entry lookups (ValueError/TypeError/RecursionError)
- approval_context: only the gateway import is optional (ImportError);
  finite_turn_required() is a ContextVar read that cannot fail
- deliberate boundaries keep their behaviour and now log the traceback:
  profile park (exc_info), session-store init (module logger, same
  "gateway.run" name, still WARNING), a2a profile dispatch (local log;
  outbound reply stays redacted), readiness probe and session_search
  profile open (debug), Windows control-pipe thread hand-off (debug; start()
  re-raises), eval harness top level (logger.exception)
- managed_worker.main: traceback goes to the worker's own stderr (the owner
  spawns it with stderr=DEVNULL) via a non-propagating handler, never the
  channel or profile log files; the owner still gets only
  managed_worker_failed
- evals/shared_gateway: timeout=30 on git rev-parse/diff calls

(cherry picked from commit dfc56cdd5ab875bd14b921de71be4a5bc8afc57f)
2026-10-07 10:57:34 -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
kshitijk4poor
4fb768fcda refactor(a2a): name the fail-closed dispatch predicate once
connect() and is_trusted_peer() each spelled out the same
"network-exposed token bind with no allow-list" condition; drift between
the two would let the startup warning and the actual refusal disagree.
Extract A2ASecurityContext.dispatch_fails_closed() and use it in both
places (truth table unchanged). Also hoist the is_loopback_host import to
module top (no cycle) and drop the restating docstring.
2026-10-02 00:45:30 +05:30
kshitijk4poor
66ed823b5c fix(a2a): keep no-token localhost peers trusted when an allow-list is set
The fail-closed change dropped the localhost_only() short-circuit from
is_trusted_peer. In no-token mode authenticate() always yields ip:<addr>,
so any install with A2A_TRUSTED_PEERS / a2a.trusted_peers configured
started 403-ing every local dispatch. Restore the short-circuit and pin it
in test_localhost_trusts_all.

Also:
- log the non-loopback/no-allow-list misconfiguration once in
  A2AAdapter.connect() instead of an ERROR on every refused request;
- is_loopback_bind reuses agent.proxy_bypass.is_loopback_host instead of a
  hand-rolled loopback check;
- fold the loopback backward-compat test into
  test_no_allowlist_trusts_authenticated (now explicit A2A_HOST=127.0.0.1)
  and drop implementation asserts on is_loopback_bind().
2026-10-02 00:45:30 +05:30
kshitijk4poor
0e2271b832 docs(a2a): document A2A_TRUSTED_PEERS requirement on non-loopback binds
Operators exposing the adapter with a token now get dispatch refused
without an allow-list (#126756); say so in the env table.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
2026-10-02 00:45:30 +05:30
kshitijk4poor
9878bf9696 refactor(a2a): collapse duplicated loopback branch in is_trusted_peer
The loopback branch repeated the final `identity in self.trusted_peers`
membership check. Only the empty-allowlist case depends on the bind, so
branch on that alone: loopback stays open, non-loopback logs and fails
closed. Behaviour is unchanged (probe: 0 fails).

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
Co-authored-by: Sahil Vishnalya <sahilvishnaliya250@gmail.com>
2026-10-02 00:45:30 +05:30
JerryLiu369
a0cad39f5d fix(a2a): fail closed on non-loopback bind with empty trusted-peers allowlist (#126756)
(cherry picked from commit 26a8dca575cd86a693e6f3be57caa449f9e8a032)
2026-10-02 00:45:30 +05:30
kshitijk4poor
ee942a7bbf fix(terminal-env): adapter secrets are the declared ones, not any platform-named variable
The shape rule (a platform prefix plus _TOKEN/_SECRET/_PASSWORD/_KEY) also
matched variables Hermes never reads: the platform list holds plain words
(LOCAL, GATEWAY, WEBHOOK, SLACK), so a user's SLACK_USER_TOKEN,
LOCAL_LLM_API_KEY or GATEWAY_API_KEY vanished from the terminal and
terminal.env_passthrough could not bring them back. The prefix census it
leaned on also failed open (an unreadable plugins dir cached an empty set).

Adapter secrets now come from what adapters declare: password entries of
the messaging OPTIONAL_ENV_VARS (built-ins plus every platform plugin
manifest) and secret-named keys of the gateway env-override table, both
Tier 1 and refused by passthrough; plus the secret-named required_env of
adapters registered in the current profile scope, read per spawn without
loading deferred adapters, Tier 2 only because required_env is an
unchecked setup list. Secrets nothing declared get a manifest entry
(TELEGRAM_WEBHOOK_SECRET, PHOTON_SIDECAR_TOKEN, A2A_PUSH_SECRET,
TEAMS_GRAPH_ACCESS_TOKEN, TEAMS_INCOMING_WEBHOOK_URL) or join the
policy's read-in-code list (QQ_STT_API_KEY, the two MSGRAPH names).
2026-09-29 02:06:58 +05:30
Teknium
a5bd246865 Old pre-decomposition import paths are gone: plugin compat layer removed on schedule (#126164)
* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule

The PLUGIN-COMPAT layer (2776813df3 + d63e380324 + 0a5164cebe) kept pre-#102117 import paths
alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader
has already been skipping plugins that use the old paths. This removes the layer itself:

- 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party
  names, restored dead definitions) and the three re-export stub modules
  (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils)
- COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step
- the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section,
  the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the
  `plugins.allow_deprecated_imports` escape hatch

An external plugin that still imports an old path now fails to load with its ImportError as the
reason in `hermes plugins list`, the same path as any broken plugin.

hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect,
summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout
swap (tests/compat/old_updater_surface.json).

In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its
`shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for
the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed
`run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the
seam production reads, like every sibling test in that file.

* chore: retrigger CI (zero-job startup_failure phantom)

* test: drop resolution allowlist rows for the two deleted which() sites

hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available
(a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires
their allowlist entries go with them.
2026-09-28 10:21:41 -07:00
teknium1
75b6d946cd fix(a2a): scope the client-tools A2A_PORT gate and prove A→B→A under multiplex (#122126, salvage #122128)
Follow-up trim to @JE4NVRG's salvaged commit (is_connected → env_is_connected("A2A_PORT")):

- plugins/platforms/a2a/tools.py::_a2a_tools_available read os.getenv("A2A_PORT") too — the
  same unscoped gate in the same plugin, so every secondary profile also paid for the a2a
  toolset whenever the launch profile set A2A_PORT. Now get_scoped_secret, same policy as
  the adapter's port read (scoped miss fails closed; default/T1 reads its own environ).
- Tests trimmed to two invariants: A→B→A over two temp profile homes under
  set_multiplex_active(True) with the launch value in os.environ (profile B with no
  A2A_PORT of its own is NOT connected and gets no tools; red on origin/main at index 1),
  and the standalone T1 case where os.environ IS the profile.

Row L1 (boot-time platform enablement probe), topologies T2/T3 (multiplexed host serving
secondary profiles). No other plugins/platforms/*/__init__.py is_connected/check_requirements
does an unscoped env read (buzz #125985 is handled separately).

Co-authored-by: JE4NVRG <jean.v1803@gmail.com>
2026-09-28 05:24:26 -07:00
JE4NVRG
68c205b5b9 fix(a2a): resolve the inbound enablement gate through the profile-scoped reader
is_connected() gated on a raw os.getenv("A2A_PORT"), which under multiplexing
holds the launch (default) profile's value. Every secondary profile therefore
instantiated the inbound A2A server, all of them fell back to the module
default port 9900, and all but one died with "could not bind ... Address
already in use" (fatal / bind_failed in gateway_state.json) on every boot.

Resolve the gate through gateway.platforms._shared.env_is_connected, the same
scope-aware idiom the sibling adapters use -- the adapter's own port read
already goes through _get_scoped_secret for exactly this reason.

Tests: tests/plugins/test_a2a_plugin.py pins the behavior. A profile with no
A2A_PORT in its own scope is not connected and never reads os.environ (a raw
os.getenv fails the test), a scoped port connects, and extra.enabled still
short-circuits.

Fixes #122126
2026-09-28 05:24:26 -07:00
teknium1
c6dc7ab120 Merge remote-tracking branch 'origin/main' into feat/unified-gateway-runtime
Merge #8: 2,771 commits from main (4b05f764fa). Ports main's moved code into the
unified runtime (run.py/run_turn.py splits, tui_gateway server, backup/restore
split), keeps the detached-daemon Desktop lifecycle, and adapts main's new tests
to the owner/authority contracts (canonical session deletes, retired-id
tombstones, zero-writer browsing, hermes_yaml, platforms() markers).
2026-09-27 02:30:04 -07:00
teknium1
eec5bd6673 Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution
4,048 upstream commits (Sep 16-23) composed onto the unified gateway runtime by six
per-domain conflict lanes (gateway, desktop/shared, cli/state, cron, bots/tui_gateway, ink).
Retired lanes stay retired (Desktop secondary pool + exit supervisor, deferred Bot Chat
pending queue, subprocess retry adoption); main's gateway.standalone, host-role claim,
clarify capability gate, config-read caches and idle gates ride on top.
2026-09-23 03:25:31 -07:00
ethernet
9f2ba1b74d merge origin/main (779 commits) into ethie/pm-clean
Branch semantics kept where main and PM disagree: update_cmd_deps.py,
constraints-termux.txt, the Electron update-api-check module and the
post-swap hand-off test stay deleted; the pending-fleet-restart catch-up
and the local_runtime tag/download ladder stay retired (PM owns engines).

Ported from main onto the branch's shape: profile_scoped_chore for the
auto-archive and plugin-update housekeeping chores, the local-runtime
cross-process boot lock and residency cap, the checkpoint tmp_pack sweep,
the cua daemon-liveness status probe, the remote-served Desktop update
flag (posix.sh / windows.ps1), sign-in for env-pinned remote gateways
(urlDisabled on RemoteSetupFields), the uvloop extra split (uvicorn
without [standard]), and the umask-scoping spawn test.

uv.lock regenerated with pm.build_env --lock-only; new utf-8 reads from
main switched to utf-8-sig (check-windows-footguns).
2026-09-21 00:58:39 -04:00
chelsealong
7efacc8f62 fix(a2a): recover the streamed reply text instead of resolving empty
When streaming already delivered the final reply, gateway/run_turn.py's
_hmwa_deliver_turn_response suppresses the normal adapter.send() and returns
None, so A2AAdapter.send() — the only path that ever carries reply text —
never runs. on_processing_complete() then resolves the pending A2A task
future through its SUCCESS default, which was hardcoded to "", so every
streamed A2A reply lands as TASK_STATE_COMPLETED with no status.message and
no artifacts (#116944).

_hmwa_deliver_turn_response already stashes the true final text on
event._streamed_final_response for exactly this situation (the same stash
_final_text_for_post_turn_hooks reads for /goal and /loop). Read it as the
SUCCESS-path fallback text instead of "".

(cherry picked from commit 638041af046ab149a356a7e5107d52c2e6a3c9a8)
2026-09-20 18:45:42 -07:00
ethernet
a6ae6ace51 Merge remote-tracking branch 'origin/main' into ethie/pm-clean
# Conflicts:
#	.github/workflows/js-tests.yml
#	agent/model_metadata.py
#	apps/desktop/electron/main.ts
#	apps/desktop/scripts/bundle-electron-main.mjs
#	apps/desktop/src/app/settings/about-settings.tsx
#	apps/desktop/src/app/settings/gateway-settings.test.tsx
#	apps/desktop/src/app/settings/gateway-settings.tsx
#	apps/desktop/src/app/updates-overlay.tsx
#	gateway/shutdown_flush.py
#	hermes_bootstrap.py
#	hermes_cli/local_runtime/binaries.py
#	hermes_cli/main.py
#	hermes_cli/managed_uv.py
#	hermes_cli/update_cmd.py
#	hermes_cli/update_cmd_deps.py
#	hermes_cli/update_cmd_fleet.py
#	hermes_cli/update_cmd_maint.py
#	hermes_cli/update_receipt.py
#	hermes_cli/update_serve_obligations.py
#	hermes_constants.py
#	tests/hermes_cli/test_doctor.py
#	tests/hermes_cli/test_managed_uv.py
#	tests/hermes_cli/test_pending_supervisor_recovery.py
#	tests/hermes_cli/test_startup_fast_guards.py
#	tests/hermes_cli/test_update_desktop_stale_warning.py
#	tests/hermes_cli/test_update_fleet_restart_pending.py
#	tests/hermes_state/test_hermes_state.py
#	tests/tools/test_tirith_security.py
#	tools/bot_relay.py
#	tools/checkpoint_manager.py
#	tools/write_approval.py
#	website/docs/getting-started/updating.md
#	website/docs/reference/environment-variables.md
2026-09-18 17:26:10 -04:00
beardthelion
9ac4e76e0f fix(tools,tui_gateway,cli,plugins): parseable non-dict JSON no longer crashes the remaining file scans
Same class as the Bot Chat drain wedge already on this branch: every JSON-file
scan guarded "did it parse?" and then assumed the value was a dict. A file
holding `42`, `"oops"` or `[1,2,3]` (corruption, truncated write, foreign tool)
passed the guard and raised AttributeError/TypeError at the first `.get()`,
usually before a single healthy sibling was processed. Each site now treats a
non-object payload like a corrupt file under that subsystem's existing policy:

- tools/bot_relay.py::_expire_if_stale / claim_pending_envelopes — the
  envelope is skipped by the sweep and not claimed (same as unparseable).
- tools/browser_lightpanda.py::reap_orphaned_lightpanda — record unlinked,
  scan continues.
- tools/write_approval.py::list_pending / get_pending — record skipped with
  the existing "unreadable pending record" warning / None.
- tui_gateway/methods_session.py::_legacy_spawn_tree_entry / spawn_tree.load —
  scalar snapshot reads as empty / returns the existing 5000 error instead of
  violating the SpawnTreeLoadResult contract.
- hermes_cli/local_runtime/binaries.py::manifest_verified — False.
- plugins/platforms/a2a/protocol.py::load_conversation — non-dict lines are
  dropped, keeping the declared list[dict] return.
- batch_runner.py::_load_dataset / _scan_completed_prompts_by_content /
  _combine_batch_files — line skipped and counted as filtered.
- trajectory_compressor.py::process_entry_async — scalar entry passed through
  unchanged.

Ported from the source hunks of PR #114241; its gateway/shutdown_flush.py
drain_transcript_spool hunk is left to open PR #84785, and its
recover_pending_to_db / cron / bot_live_delivery / bot_mode_dm hunks are
already on this branch or on main.

(cherry picked from commit d4b54568887e69b3ee3d363ebe4dcd657ccf64f9)
2026-09-18 09:19:04 -07:00
ethernet
b4a294fff9 Merge origin/main; keep PM as plugin dependency owner
Reconcile plugin declarations and validation through PM's atomic generation publication; preserve external runtimes, target markers, and conflict refusal. Keep one source-update completion owner and port upstream lifecycle changes to the PM desktop/runtime paths.
2026-09-17 13:52:05 -04:00
Erosika
11f9027242 fix(a2a): a resend without a contextId reopens its context and spends no turn
A peer retrying its first send repeats the messageId and omits the
contextId it never received. The adapter opened a fresh random context per
attempt, so the forwarded input id and the owner session differed and both
attempts executed. A first message without a contextId now opens a context
named by (agent, tenant, peer, messageId), and a message without an id
keeps a random one.

The adapter also remembers the admission ids it has forwarded. A resend of
one skips the anti-loop counter, the conversation log and the inbound
metric, so a peer can keep retrieving accepted work past the turn limit.
Distinct messages in the context still count.
2026-09-16 09:16:19 -07:00
erosika
b2968fb1c4 fix(a2a): a peer's messageId keys the forwarded admission
The adapter minted a fresh task id per inbound message and used it as the
forwarded input id, so a peer resending after a timeout queued a second
execution behind the accepted one. Hash context and messageId into the
input id; a message without an id keeps the per-task id.
2026-09-16 09:16:18 -07:00
teknium1
d1794d5539 fix(multiplex): children spawned for a served profile start from that profile's env
Under gateway.multiplex_profiles (and the Desktop/dashboard backend serving named
profiles) os.environ holds the LAUNCH profile's .env. Five spawn sites built a
child's env from it while acting for another profile, so the child saw the
launch profile's HERMES_HOME (bot_relay, key_cmd), its credentials, HERMES_MODEL
and TERMINAL_* policy, and none of the served profile's own .env:

- tui_gateway/server.py _SlashWorker: pinned HERMES_HOME but kept the launch
  base with tier-2 credentials + settings.
- tools/bot_relay.py delivery_env (relay RPC + --run-delivery): dict(os.environ).
- tools/browser_tool.py _build_browser_env: re-added BROWSERBASE/FIRECRAWL/
  BROWSER_USE keys from os.environ after the scrub.
- plugins/platforms/a2a/adapter.py _forward_to_profile: {**os.environ}.
- agent/command_token_source.py _mint: key_cmd helper inherited os.environ.

tools.environments.local.served_profile_child_env is the one builder: pin the
target home, drop the launch profile's .env residue and bridged TERMINAL_*
(strip_launch_profile_env), and for children that legitimately run with the
profile's credentials (agent worker, token helper) overlay the target profile's
own secrets - what a standalone `hermes -p X` loads itself, never a sibling's.
The browser keeps the provider scrub and re-adds only its passthrough keys via
get_secret. Outside multiplex the env is unchanged.

Live proof from inside the child (launch A, served B, multiplex on): all five
children print HERMES_HOME == B, see B_MARKER=b from B's .env and do not see
A_MARKER; the browser child gets B's FIRECRAWL_API_KEY. On base every one leaked
A_MARKER and lacked B_MARKER; bot_relay and key_cmd also had A's HERMES_HOME.
2026-09-15 03:47:15 -07:00
ethernet
612d542281 Merge remote-tracking branch 'origin/main' into ethie/pm-clean
# Conflicts:
#	.gitignore
#	Dockerfile
#	agent/onboarding.py
#	apps/desktop/electron/main.ts
#	apps/desktop/electron/pool-stop.ts
#	apps/desktop/src/components/model-picker.test.tsx
#	apps/desktop/src/store/updates.ts
#	apps/desktop/vite.config.ts
#	datagen-config-examples/run_browser_tasks.sh
#	docs/rca-ssl-cacert-post-git-pull.md
#	gateway/run.py
#	hermes_cli/backup.py
#	hermes_cli/credential_lifecycle.py
#	hermes_cli/dashboard_procs.py
#	hermes_cli/doctor_state.py
#	hermes_cli/env_loader.py
#	hermes_cli/gateway_windows.py
#	hermes_cli/local_runtime/endpoint.py
#	hermes_cli/psutil_android.py
#	hermes_cli/update_cmd.py
#	hermes_cli/update_cmd_windows.py
#	hermes_cli/web_routers/local_models.py
#	hermes_cli/web_server_config.py
#	hermes_cli/web_server_cron.py
#	plugins/memory/hindsight/__init__.py
#	plugins/memory/holographic/__init__.py
#	plugins/memory/honcho/cli.py
#	plugins/memory/mem0/__init__.py
#	plugins/platforms/google_chat/oauth.py
#	plugins/platforms/photon/adapter.py
#	scripts/ci/list_os_marked_tests.py
#	scripts/run_tests.sh
#	tests/agent/test_compression_stall_fallback.py
#	tests/agent/test_create_openai_client_ssl_verify.py
#	tests/gateway/test_google_chat_oauth_dependencies.py
#	tests/hermes_cli/conftest.py
#	tests/hermes_cli/test_cli_init.py
#	tests/hermes_cli/test_gateway_migrate_multiplex.py
#	tests/hermes_cli/test_psutil_android_extract.py
#	tests/hermes_cli/test_relaunch.py
#	tests/hermes_cli/test_update_check.py
#	tests/hermes_cli/test_update_handoff_desktop_rebuild.py
#	tests/hermes_cli/test_worktree_gc.py
#	tests/scripts/desktop_update/test_desktop_update_windows_python_handoff.py
#	tests/scripts/desktop_update/test_desktop_update_windows_retry_policy.py
#	tests/scripts/desktop_update/test_desktop_update_windows_timestamp.py
#	tests/scripts/install/test_install_autostash_conflict_recovery.py
#	tests/scripts/install/test_install_clone_throttle_fallback.py
#	tests/scripts/install/test_install_commit_pin_rollback.py
#	tests/scripts/install/test_install_diverged_update.py
#	tests/scripts/install/test_install_lockfile_churn.py
#	tests/scripts/install/test_install_macos_launcher.py
#	tests/scripts/install/test_install_no_initial_commit.py
#	tests/scripts/install/test_install_ps1_ascii_only.py
#	tests/scripts/install/test_install_ps1_browser_install.py
#	tests/scripts/install/test_install_ps1_managed_node_swap.py
#	tests/scripts/install/test_install_ps1_native_stderr_eap.py
#	tests/scripts/install/test_install_ps1_node_path_for_npm.py
#	tests/scripts/install/test_install_ps1_python_fallback_venv.py
#	tests/scripts/install/test_install_ps1_resolver_strictmode.py
#	tests/scripts/install/test_install_ps1_uv_install_fallback.py
#	tests/scripts/install/test_install_ps1_uv_powershell_host.py
#	tests/scripts/install/test_install_ps1_venv_process_tree.py
#	tests/scripts/install/test_install_ps1_venv_recreate_safety.py
#	tests/scripts/install/test_install_ps1_venv_rename_abort.py
#	tests/scripts/install/test_install_ps1_venv_transaction_boundary.py
#	tests/scripts/install/test_install_ps1_web_server_syntax_probe.py
#	tests/scripts/install/test_install_scripts_computer_use.py
#	tests/scripts/install/test_install_sh_acp_launcher.py
#	tests/scripts/install/test_install_sh_bootstrap_marker.py
#	tests/scripts/install/test_install_sh_browser_install.py
#	tests/scripts/install/test_install_sh_install_method_stamp.py
#	tests/scripts/install/test_install_sh_node_deps_failure.py
#	tests/scripts/install/test_install_sh_node_deps_workspaces.py
#	tests/scripts/install/test_install_sh_node_global_prefix.py
#	tests/scripts/install/test_install_sh_node_npm_check.py
#	tests/scripts/install/test_install_sh_node_prerelease.py
#	tests/scripts/install/test_install_sh_node_probe.py
#	tests/scripts/install/test_install_sh_node_tarball_without_xz.py
#	tests/scripts/install/test_install_sh_pythonpath_sanitization.py
#	tests/scripts/install/test_install_sh_reuse_supported_python.py
#	tests/scripts/install/test_install_sh_root_fhs_uv_python_path.py
#	tests/scripts/install/test_install_sh_setup_wizard_tty_probe.py
#	tests/scripts/install/test_install_sh_symlink_stomp.py
#	tests/scripts/install/test_install_sh_termux_network_prereqs.py
#	tests/scripts/install/test_install_sh_termux_python_bounds.py
#	tests/scripts/install/test_install_sh_uv_lock_config.py
#	tests/scripts/install/test_install_unmerged_index.py
#	tests/scripts/test_run_tests_parallel.py
#	tests/test_managed_runtime_resolution.py
#	tests/test_project_metadata.py
#	tests/tools/test_browser_use_cli.py
#	tests/tools/test_tts_pythonpath_fallback.py
#	tests/tui_gateway/test_hosted_room_driver_runtime.py
#	tests/tui_gateway/test_tui_gateway_server.py
#	tools/lazy_deps.py
#	tools/voice_mode.py
#	uv.lock
#	website/docs/developer-guide/macos-bundle-updates.md
#	website/docs/developer-guide/pm-audit-status.md
#	website/docs/developer-guide/shared-bundle-builds.md
#	website/docs/developer-guide/source-update-completion.md
#	website/docs/developer-guide/stable-releases.md
2026-09-14 15:38:34 -04:00
teknium1
2d23cfcf69 Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution 2026-09-13 15:45:13 -07:00
EloquentBrush0x
8c58e4f976 fix(a2a): scope A2A_PUBLIC_URL per multiplex profile
A2A_PORT and A2A_ADVERTISED_TOOLSETS are already captured at
construction time (inside _profile_runtime_scope) via
_get_scoped_secret(), but A2A_PUBLIC_URL was still read with a bare
os.getenv() inside A2ARequestHandler._request_public_url() - which
runs on ThreadingHTTPServer's per-connection OS thread, not the
constructing thread.

Raw threading.Thread never inherits contextvars, so even swapping the
reader to _get_scoped_secret() at that call site would not help: the
request thread has no scope, secret_scope falls back to os.environ
either way. The value must be captured once at construction time
(which does run in profile scope) and threaded through as instance
state instead - same fix shape as A2A_PORT above.

A secondary multiplex profile without its own A2A_PUBLIC_URL now
falls back to the X-Forwarded-Host/Host-derived URL (or the bind
host) instead of silently advertising the default profile's public
URL in its Agent Card / discovery response.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 0c36aca5de53d88bbbc0b4cfceaed8307c744f7a)
2026-09-13 15:39:11 -07:00
teknium1
bb193b2047 Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution
# Conflicts:
#	apps/desktop/src/app/settings/pool-limits-setting.tsx
#	plugins/platforms/a2a/adapter.py
#	tests/hermes_cli/test_kanban_worker_spawn_toolsets.py
#	tools/terminal_scope.py
#	tui_gateway/session_notifications.py
2026-09-13 15:04:39 -07:00
teknium1
138e426f62 fix: bound A2A orphan grace and clear _active_tasks on disconnect
`_orphan_timeout()` was `max(300, A2A_REPLY_TIMEOUT)` with no ceiling, so
an absurd value (1e18) meant the watchdog sweep could never fail an
orphan — the reply window is a floor for the grace, not a licence to
disable the sweep. Cap it at 86400s.

`disconnect()` failed and cleared `_pending`/`_pending_order` but left
`_active_tasks` populated, so a reconnected adapter would keep excluding
dead task ids from the orphan sweep forever. Clear it in the same locked
block.
2026-09-13 14:43:35 -07:00
teknium1
8abe6ab8ff docs(a2a): say the orphan sweep follows A2A_REPLY_TIMEOUT and live waiters
The troubleshooting entry told users to raise A2A_REPLY_TIMEOUT for long tasks,
which did nothing against the hardcoded 300s orphan sweep (#106972). Now that the
sweep derives its grace from the reply window and skips tasks with a live waiter,
state that contract next to the variable.
2026-09-13 14:43:35 -07:00
fangliquanflq
36f43c2706 fix(a2a): finalize tasks after stream disconnect 2026-09-13 14:43:35 -07:00
fangliquanflq
9c728ec30d fix(a2a): retain task ownership through completion 2026-09-13 14:43:35 -07:00
fangliquanflq
d441708886 fix(a2a): preserve live waiters during orphan cleanup 2026-09-13 14:43:35 -07:00
teknium1
caa329904c Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution
# Conflicts:
#	apps/desktop/src/app/session/hooks/use-message-stream/steer-arrival-order.test.tsx
#	apps/desktop/src/store/composer-queue.ts
#	apps/desktop/src/types/hermes.ts
#	apps/shared/src/json-rpc-gateway.ts
#	cron/jobs.py
#	cron/scheduler.py
#	gateway/hosted_room_policy_checkpoint.py
#	gateway/run.py
#	hermes_cli/env_loader.py
#	tests/acp_adapter/test_catalog_read_only.py
#	tests/acp_adapter/test_gateway_cancel_admission.py
#	tests/acp_adapter/test_gateway_catalog_cwd.py
#	tests/acp_adapter/test_gateway_client_boundary.py
#	tests/acp_adapter/test_gateway_controls.py
#	tests/acp_adapter/test_gateway_editor_cwd.py
#	tests/acp_adapter/test_gateway_editor_mcp.py
#	tests/acp_adapter/test_gateway_editor_policy.py
#	tests/acp_adapter/test_gateway_editor_v4a.py
#	tests/acp_adapter/test_gateway_editor_wire.py
#	tests/acp_adapter/test_gateway_entry_lifecycle.py
#	tests/acp_adapter/test_gateway_new_cold.py
#	tests/acp_adapter/test_gateway_prompt_content.py
#	tests/acp_adapter/test_gateway_sessions.py
#	tests/acp_adapter/test_gateway_terminal_projection.py
#	tests/acp_adapter/test_gateway_tool_projection.py
#	tests/acp_adapter/test_gateway_wire_controls.py
#	tests/acp_adapter/test_policy_identity_compat.py
#	tests/acp_adapter/test_session_mcp_frozen.py
#	tests/acp_adapter/test_session_mcp_policy.py
#	tests/cron/test_scheduler.py
#	tests/hermes_state/test_ledger_delete_consistency.py
#	tests/hermes_state/test_runtime_admission.py
#	tests/hermes_state/test_runtime_adoption.py
#	tests/hermes_state/test_runtime_destructive_mutations.py
#	tests/hermes_state/test_runtime_import_mutations.py
#	tests/hermes_state/test_runtime_mutation_actions.py
#	tests/hermes_state/test_runtime_mutation_retired_import.py
#	tests/hermes_state/test_runtime_mutations.py
#	tests/hermes_state/test_runtime_recovery.py
#	tests/hermes_state/test_runtime_rewind_mutations.py
#	tests/hermes_state/test_runtime_schema.py
#	tests/hermes_state/test_runtime_worker.py
#	tests/hermes_state/test_runtime_worker_compaction.py
#	tests/hermes_state/test_runtime_worker_compression.py
#	tests/hermes_state/test_runtime_worker_compression_admission.py
#	tests/hermes_state/test_runtime_worker_compression_annotations.py
#	tests/hermes_state/test_runtime_worker_compression_cleanup.py
#	tests/hermes_state/test_runtime_worker_compression_flush.py
#	tests/hermes_state/test_runtime_worker_context.py
#	tests/hermes_state/test_runtime_worker_history.py
#	tests/hermes_state/test_runtime_worker_lifecycle.py
#	tests/hermes_state/test_runtime_worker_metadata.py
#	tests/hermes_state/test_runtime_worker_operations.py
#	tests/hermes_state/test_runtime_worker_rotation_automation.py
#	tests/hermes_state/test_runtime_worker_title_retry.py
#	tests/hermes_state/test_runtime_worker_turn_cleanup.py
#	tests/hermes_state/test_runtime_worker_usage.py
#	tests/hermes_state/test_terminal_retirement.py
#	tests/tui_gateway/test_bot_relay_methods.py
#	tools/async_delegation.py
#	tools/bot_relay.py
#	tui_gateway/server.py
#	ui-tui/src/app/createGatewayEventHandler.ts
#	ui-tui/src/app/useSessionLifecycle.ts
#	ui-tui/src/app/useSubmission.ts
#	ui-tui/src/gatewayClient.ts
#	ui-tui/src/gatewayTypes.ts
#	ui-tui/src/types.ts
#	web/src/lib/api.ts
#	website/docs/developer-guide/gateway-classic-cli.md
#	website/docs/developer-guide/gateway-local-sessions.md
#	website/docs/user-guide/sessions.md
2026-09-13 12:27:55 -07:00