Skip to content

sync: bring main into the salvage branch (resolves both conflicts) + the reviewed deliver fixes - #447

Open
Bendak wants to merge 124 commits into
NousResearch:salvage/199-ha-deliverfrom
Bendak:sync/salvage-on-main
Open

Bendak wants to merge 124 commits into
NousResearch:salvage/199-ha-deliverfrom
Bendak:sync/salvage-on-main

Conversation

@Bendak

@Bendak Bendak commented Nov 20, 2026

Copy link
Copy Markdown

Purpose: un-block this branch. #433 is dirty against main (base e726eb7d, main now 80025332), so it cannot merge. This PR merges main into the salvage branch, resolves the two conflicts, and carries the four reviewed fixes from #440. Merge this and #433 becomes mergeable with the fixes already inside — no rebase work left on your side.

Conflicts, and how each was resolved

Only two files conflicted, both mechanical:

File Conflict Resolution
homeassistant/README.md both sides inserted rows at the same anchor (after ws_heartbeat_seconds): main added notification_id, the salvage added deliver + deliver_mode keep all three rows; the #### Cross-platform delivery section stays
homeassistant/adapter.py __init__: main adds self._notification_id before _last_event_time; the salvage inserts its deliver init block after the same line keep both, _notification_id → _last_event_time → deliver block

A duplicate self._last_event_time = {} that the merge initially kept twice was found by review and removed.

What comes along

  • Main's intervening work (this PR necessarily pulls it in — 169 files): the WebSocket lifecycle/teardown refactor, notification_id, and everything else since e726eb7d. All of it is byte-identical to main in the reviewed tree; nothing was dropped (AST and import parity checked).
  • The four fixes from fix(homeassistant): route to the configured home thread and honour send refusals #440: caller thread-routing aliases win over the home-thread default, SendResult(success=False) degrades to the HA notification, gateway_runner reads degrade instead of raising, and unknown silence markers deliver a plain alert with no model turn.
  • The ported deliver feature itself, unchanged.

Verification

  • pytest homeassistant/tests: 323 passed, 2 skipped, zero failures (run with a clean HOME — the one environment-sensitive test reads a real HASS_TOKEN from the host's secret scope; it passes on CI).
  • AST parity with main: no function, method, class or import missing; notification_id present and consumed, with main's own notification tests green.
  • Mutation check on the fixes: reverting adapter.py makes the routing/refusal/marker tests fail.
  • Reviewed adversarially (cross-vendor model) at e1ab0f1: final verdict GO, no findings.

Note on bubblewrap

Unrelated and untouched. bubblewrap · ubuntu-latest already fails on main at e726eb7d (run 44478782362) with the same 43 tests; macos/windows pass. Nothing in this branch changes that plugin.

Prepared with AI assistance (Hermes agent), reviewed by the account owner.

teknium1 and others added 30 commits November 19, 2026 10:37
Core main changed three seams the backend overrides; feature-detected, so
0.23.2 keeps its old paths:

- _wrap_command takes cwd_fallback (0ee90ecc, 8f95f721): pass extra kwargs
  through instead of raising TypeError on every terminal/execute_code call.
- LocalEnvironment._recover_cwd is gone (e979ba31); the spawn dir now comes
  from _spawn_cwd() without moving the tracked cwd. Use it when present.
- _extract_cwd_from_output became _parse_cwd_marker + _update_cwd
  (065f5abb): override _update_cwd, which both cores have.
- Secret exports now ride an fd channel whose tokens LocalEnvironment._run_bash
  swaps for open fds (c085276f and follow-ups). Our _run_bash replaced it, so
  the tokens reached bash raw ("ambiguous redirect") and the snapshot
  bootstrap failed. Do the same swap when core has _secret_handoff and pass
  the fds through prlimit + bwrap.

Tests: dead-cwd tests opt into allow_cwd_fallback when core has it; the
cross-sandbox state test uses a non-secret-shaped name (main keeps secrets
off disk); new test pins that a secret export reaches the next command and,
where core has the channel, never the snapshot file.
… host

The missing-CLI discovery tests pass only on hosts with no claude in a
system prefix: _resolve falls back to /opt/homebrew/bin and /usr/local/bin,
so a host with Claude Code installed there finds the real binary and the
'no claude' assertions fail. Patch _SYSTEM_PREFIXES empty on both the flat
and package-relative directsdk_setup copies, and add a positive test that
the prefix stays a fallback that never overrides an explicit command.

The no-uid workspace case deletes os.getuid. In an environment without
USER, _with_login_identity then falls back to pwd.getpwuid(os.getuid())
and raises AttributeError before the workspace branch under test runs.
Give that case a synthetic USER.
…esearch#381)

Hermes core's plugin re-discovery evicts the plugin package from
sys.modules; the registered profile survives, but its methods did a
lazy relative import at call time. After eviction that fails as
"No module named 'directsdk'", surfaced to gateway-served surfaces
(mobile/desktop) as "Failed to initialize OpenAI client".

Import directsdk and directsdk_setup once at module load and
reference them from create_client/setup_status/discover_models/
fetch_account_usage, so no import runs at call time.

tests/test_sysmodules_eviction.py: red on main (4 failed), green
on this change (4 passed); full suite passes.
Hermes core can pass an OpenRouter-style canonical id such as
anthropic/claude-sonnet-5 even when the config names claude-sonnet-5.
_route_base only stripped a leading claude-, so the vendor prefix reached
the native CLI, which 404s. A 404 is not an auth error, so the admission
guard denied every retry and the turn silently fell back to another
provider. Strip anthropic/ and openrouter/ before routing; leave other
namespaces alone.

Fixes NousResearch#377
…laude

A systemd service PATH can put an old Claude Code install ahead of the
current one. With 2.1.148 the tool payload is dropped from the request and
the model answers as a title generator. When the bare claude found on PATH
is below the supported minimum, look for a newer executable in the install
prefixes first. An explicit command override is never second-guessed.

Fixes NousResearch#380
… CLIs through which()

_resolve runs on every turn, so the version check spawned `claude --version`
before every request. Cache it per (realpath, mtime, size), so `claude update`
is noticed and a transient failure is retried. The prefix scan used a bare
os.path.join(prefix, 'claude'), which misses claude.exe / claude.cmd on
Windows; use shutil.which per prefix and skip the PATH hit itself. Test
fakes are named claude.cmd on Windows. CHANGELOG line for NousResearch#380.
Hermes' auxiliary client cache closes a client bound to another live event
loop. Client.close() cancelled every in-flight request on it, so two tool
calls running in parallel (two vision_analyze calls in one step) could fail
with 'Claude request cancelled' or 'Claude client is closed'. Each request
owns and reaps its own native process, so closing needs no cleanup; Stream.close()
and cancel() remain the explicit per-request stop paths.

Fixes NousResearch#378
…-contract test on the stream's own close

Client.close() no longer cancels running requests (NousResearch#378), so the _closed flag
only made a cached client refuse every later call with 'Claude client is
closed', the second symptom in the issue. Drop it. test_fail_closed_and_cancellation
relied on Client.close() finalizing an unstarted stream; it now closes that
stream itself. CHANGELOG line for the fix.
A 200 cut short raised ClaudeAPIError with status_code=None and the transport
label only inside the prose, so core's message-based classifier saw an
unknown error: no same-provider retry, no fallback chain, and no compression
network-failure guard. Append the canonical wording core already matches
(server disconnected, connection reset by peer, ...) for known relay failures,
keeping the original label for reports. Unknown failures are unchanged.

Fixes NousResearch#396
…-close wording

'server disconnected' / 'connection reset by peer' / 'incomplete chunked read'
are core's _SERVER_DISCONNECT_PATTERNS, which a large session on a non-reasoning
model (claude-haiku-4-5, haiku-5-5) classifies as context_overflow with
should_compress=True, so a dropped stream would have compressed the
conversation. Use core's premature-close / connection-reset wording instead,
which is always a connection timeout retry. The test now runs the wrapped
error through core's real classify_api_error for both a non-reasoning and a
reasoning model (red on the previous mapping: 4 Haiku cases compress).
CHANGELOG line for NousResearch#396.
…illed request

The request that first crosses a plan limit is already billed; ask/stop
only act on the next one. Add extra_usage_reserve_percent (e.g. 97): under
ask/stop, refuse once an account-wide plan window reaches that percent,
using the same zero-inference get_usage probe. Unset or invalid keeps 100,
so existing installs are unchanged. notify/allow never probe.

Refs NousResearch#398
…imit_event; declare and document it

The reserve only took effect on a get_usage probe, which runs only with no
current answer. After any turn the process holds the turn's own
rate_limit_event answer (using_overage false below 100%) for up to 15
minutes, so a running gateway kept sending past the reserve until the plan
wall: the setting worked only on a fresh process. The event summary now
carries the fuller account-wide window's utilization (unifiedWindows
five_hour/seven_day), and under ask/stop with permitted overage a window at
the reserve counts as spilling. The refusal says it was the reserve. The
setting is declared in plugin.yaml (Desktop settings form) and documented in
the README; CHANGELOG line under Added.
…hread per replayed frame

Every replayed frame is one stdin write, and each write started a threading.Timer
(one thread) as its stall guard: 602 thread starts for a 300-round history.
One watchdog thread per request now guards every write. A write records when it
began; the thread never sleeps past the timeout, so it wakes before the deadline
of any write that began while it slept, then sleeps until exactly that deadline.

Plugin CPU per call (4 vCPU Linux, Claude Code 2.1.327, loopback upstream):
100 rounds 0.19 -> 0.10 s, 300 rounds 0.42 -> 0.23 s. Claude Code's own CPU is
unchanged.
… at 5m, not 1h

Core clamps a delegated child to the 5m cache tier (_apply_child_cache_ttl: a
subagent calls every few seconds for minutes and is gone, so the 2x write buys
retention it never collects). Core can only clamp the cache_control markers it
builds. On this route native places them, and a `claude -p` turn is Claude
Code's main-conversation bucket, which asks for the one-hour tier on a
subscription within plan usage. Every child request therefore wrote at 1h:
2x the input rate instead of 1.25x.

The profile hook reads the cache scope core stamps on a child (sub_<hash>,
prompt_cache_scope.is_sibling_cache_scope) and returns hermes_cache_ttl=5m; the
spawn then starts native with CLAUDE_CODE_PROMPT_CACHE_TTL=5m (documented,
Claude Code 2.1.242+). A tier the user exported wins. Every other request keeps
native's default.

CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL is deliberately not used: it governs
requests outside the main bucket, and a -p turn is inside it.
teknium1 and others added 26 commits November 19, 2026 14:41
…import (exit 1)

After the user accepted one profile per Bot, a failed 'hermes profile create' returned
an empty target list and the import silently fell back to merging every Bot into the
current profile: the merge they had just declined, reported as success. It now exits 1
with nothing imported.

(cherry picked from commit b2dc996)
browser_navigate succeeded, then every following call failed with No browser session. The session map is process-local: wherever calls do not share that process, each call minted a fresh random userId, so the tab the previous call opened was invisible to the next one.

Derive the ephemeral userId from (state dir, task_id) instead of uuid4, so every call in the same task resolves to the same browser user, and allow tab adoption for that reproducible identity. Unkeyed calls keep a random id, so they never collapse onto one shared profile.

Closes NousResearch#215.

(cherry picked from commit beac51d)
…g_tab

NousResearch#255 made the per-task userId reproducible, but the rebuilt session entry
only re-adopted the tab when adopt_existing_tab was set, so the default
config still answered 'No browser session' after navigate in another
process (NousResearch#215). A task-scoped userId only ever holds this task's tabs, so
the rebuild always looks for one; the per-call adopt_existing_tab gate is
unchanged (a tab gone after a restart is still recreated).

(cherry picked from commit c19ac0f)
…t values at the tool boundary

Two gaps in the secret-bearing vault path:

1. `proxies={"http": None, "https": None}` does not disable an `ALL_PROXY` /
   `all_proxy` from the environment. requests merges environment proxies
   first and then drops None-valued keys, so the "all" entry survives and
   the fill script (which carries the saved password) is sent through the
   proxy, past the loopback/HTTPS transport check. Use empty strings for
   http, https and all: "" survives the merge and means "no proxy".

2. Registered vault values could still reach the model through
   page-controlled fields of a tool result (for example a page that echoes
   the filled value into its title or into a navigate URL). `_dumps` and
   `_fail` now pass every result through `policy.scrub_vault_values`, which
   applies core's `redact_registered_vault_values` to every string in the
   payload. When core also provides `redact_registered_vault_number`, JS
   Number-coerced numeric secrets (PINs read back via Number(...)) are
   scrubbed as well; without it numbers pass through unchanged.

Tests: camofox/tests/test_vault_secret_hygiene.py. Against hermes-agent
v0.23.0: 113 passed, 10 skipped (the numeric cases skip when core lacks the
optional helper). Without the proxy change the ALL_PROXY/all_proxy cases fail.

(cherry picked from commit f1eee59)
…xist

redact_registered_vault_number is in no hermes-agent branch or PR, so the
getattr branch never ran and its 10 tests always skipped. Numbers pass
through unchanged, as they did; the string scrub is unchanged.

(cherry picked from commit f0486b8)
…x host

secret_transport_ok() refused plain HTTP to anything but loopback, so a
Docker deployment running Camofox in its own container could never fill
logins: users resorted to network_mode: service: to make the container
look like localhost, which breaks whenever the Hermes container is
replaced (NousResearch#291).

The vault fill script already goes to the host named in CAMOFOX_URL — the
same host every other Camofox call trusts — so that exact hostname is now
acceptable for secret evaluates as well. HTTPS stays accepted, the
loopback rule stays for every other host, and userinfo, query, fragment
and redirects keep being refused. No new configuration.

(cherry picked from commit 317f31d)
Review on NousResearch#292 made the flaw clear: trusting whatever host CAMOFOX_URL
names would make the transport check meaningless, since every deployment
sets it. danielhunt proposed the right shape: keep the default
(HTTPS anywhere, plain HTTP on loopback only) and add an explicit option
that admits plain HTTP to any host when the operator opts in.

CAMOFOX_ALLOW_INSECURE_TRANSPORT (browser.camofox.allow_insecure_transport
in config.yaml) now does that, replacing the host-trust approach; the
manifest declares the knob, the README documents it, and the default
behavior is test-pinned as unchanged.

(cherry picked from commit 70b4582)
…ents

Review on NousResearch#292: resolve the opt-in flag up front and keep the return a
one-liner, describe the flag in two lines without narrative or issue
references in code, and use a distinct test host name. README now
describes the knob without the workaround history.

(cherry picked from commit 49c5a21)
urlsplit().hostname already returns lowercase with IPv6 brackets
stripped, so the strip/strip/lower chain does nothing. Back to the
plain hostname check from main, plus the opt-in flag.

(cherry picked from commit 0c98ab5)
…only

- Drop the CAMOFOX_ALLOW_INSECURE_TRANSPORT env var: non-secret behaviour
  lives in config.yaml (browser.camofox.allow_insecure_transport), not in
  .env, and a stray env value can no longer widen a secret transport.
- Only a YAML true opts in (a quoted "false" stays off).
- The opt-in admits plain http only; before, it short-circuited the scheme
  check, so any scheme passed once it was on.
- README config-reference row for the setting.

(cherry picked from commit faf3518)
The swatch grid used the Tailwind utility `grid-cols-8`, but the Hermes desktop app does not emit CSS for that class (its Tailwind build only scans the app's own source, which uses `grid-cols-6` but never `grid-cols-8`). The container therefore got `display: grid` with no `grid-template-columns` and collapsed to a single column, stacking the 8 preset swatches vertically. Replace the utility class with an inline CSS grid so the swatches always lay out in one row regardless of which utilities the host app has generated.

(cherry picked from commit 6ff693b)
…act, drop the fork patch script

- Every pick goes through setAccentOverride/normalizeHex; typed text that is
  not a colour no longer lands raw in $accentOverride or in storage.
- One persist() in register() writes ctx.storage at once and the data-folder
  copy once a drag settles (was a file write per pointer move).
- Disabling the plugin clears the live override again (the saved pick stays
  and comes back on re-enable), so no colour is stranded without a control.
- Remove patch/: its script rewrote the user's catalog entry to a personal
  fork and sha.
- plugin.yaml 1.1.0; README text no longer says the colour is never persisted.

(cherry picked from commit 7c52a96)
…ed yet

The catalog entry has been published for weeks (plugin-catalog/blender.yaml,
pinned to 0.4.1), so 'becomes available only after its catalog entry is
merged' sends readers looking for a step that does not exist. The rest of the
original change (0.1.0 vs 0.2.0, the app.win32.location note) no longer applies:
0.4.0 dropped the app declaration and the location-list support shipped in
Hermes v0.23.1.

Co-authored-by: alt-glitch <balyan.sid@gmail.com>
(cherry picked from commit db55e79)
…e-on-main

# Conflicts:
#	homeassistant/README.md
#	homeassistant/adapter.py
…nd refusals

- broadcast: forward the home channel's thread_id in the send metadata, so a
  home pinned inside a forum topic receives the alert in that topic instead of
  the root chat (core does exactly this in gateway/delivery.py)
- session mode: derive the session key with the home channel's thread_id; the
  key layout carries the thread slot, so omitting it targeted the root chat's
  conversation while a topic session existed
- send: inspect SendResult.success - adapters report a transport refusal by
  returning success=False instead of raising, so an unchecked return dropped
  the event with no HA fallback and no warning from this plugin
- read gateway_runner with getattr so a core rename degrades to the HA
  notification instead of raising outside the compatibility wrapper
- warn when the gateway's silence-marker import fails: it silently disabled
  marker stripping on injected payloads for the module's lifetime

Tests: 5 new cases (thread routing, metadata pass-through control, refused
send, topic session key, missing gateway_runner attribute, marker-import
warning); each behavioural one fails with adapter.py reverted.
…s are unknown

Review findings on 6c332f4:

- broadcast: the home-thread default shadowed caller routing aliases. Core treats
  thread_id, message_thread_id, direct_messages_topic_id and
  telegram_direct_messages_topic_id as the same routing decision and only adds
  its default when NONE is present (gateway/delivery.py:30,340-344); adding
  thread_id beside a caller's message_thread_id diverted the alert. The same key
  set is now checked.
- markers: a failed import returned (), which reads as "no markers exist" and let
  injection proceed with an entity value's own marker intact - an entity could
  suppress its own alert once the model echoed it. It now returns None ("unknown")
  and session-mode injection degrades to broadcast, which never routes the text
  through the model.

Tests: 2 added (caller alias preserved; injection degrades on unknown markers).
Both fail with the adapter reverted; 303 passed, 2 skipped otherwise.
…known

Round 3 finding: returning False from the injection path does not avoid the model.
The caller falls through to the source-session turn, which hands the unsanitized
text to the agent - so an entity value carrying a marker could still suppress its
own alert. With unknown markers the text now goes out through the same tested
cross-platform broadcast arm (home thread preserved, SendResult inspected, HA
fallback on failure) and no turn is dispatched in the source session.

Test: the marker-unknown case now asserts the plain delivery happened and that
handle_message was never called; it fails on 8bf9c99.
…cated

Both parents introduced `self._last_event_time`; the merge kept both, at
adapter.py:214 (main) and :341 (salvage). Nothing reads the map between them, so
the second assignment was redundant. Keep main's, drop the salvage duplicate.
@Bendak

Bendak commented Nov 20, 2026

Copy link
Copy Markdown
Author

CI note: the tests workflow on this PR sits at action_required — a fork PR needs a maintainer to approve the run before it executes (same as the earlier fork PRs). Local results on the reviewed tree (e1ab0f1): 323 passed, 2 skipped, zero failures, with HOME pointed at an empty dir so the host's real HASS_TOKEN cannot leak into the environment-sensitive test.

If the run is approved, expect the same pre-existing bubblewrap · ubuntu-latest failure that main already has at e726eb7d (43 tests, unrelated to this branch).

Prepared with AI assistance (Hermes agent), reviewed by the account owner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.