Commit Graph

841 Commits

Author SHA1 Message Date
Froraut
b015e59fb9 fix(matrix): address review — budget edit mentions and move plugin tests
An edit carries m.mentions twice: once inside m.new_content and once at the
top level. When a budget-sized edit names many distinct Matrix IDs, that
fixed part alone could pass the content budget. Shortening the fallback body
then had no room to work with, and the edit still went out at about 54 KB,
which an encrypted room would reject with M_TOO_LARGE.

When the edit is still over budget with an empty fallback, it now drops the
top-level mentions copy. That copy only drives the edit's own notifications,
and m.new_content keeps the full list.

The event-size tests move to tests/plugins/platforms/matrix/test_event_size.py,
mirroring the plugin source tree, and gain a mention-heavy text. The
tests/gateway/test_matrix_message_length.py file is back to main apart from the
env-override value that the new ceiling requires.

(cherry picked from commit 4b06bcb7dbffb732bef6e877cb66dea2fbff8c73)
2026-10-03 16:31:35 +05:30
Benjamin Brumbaugh
d5cda9135c fix(disk-cleanup): fail closed on unresolved track paths 2026-10-02 21:21:36 -05:00
Benjamin Brumbaugh
cc2dd7016e test: harden disk cleanup path safety 2026-10-02 21:21:36 -05:00
Benjamin Brumbaugh
0ba4992c52 fix(disk-cleanup): accept macOS temp aliases 2026-10-02 21:21:36 -05:00
liuhao1024
e0daebeb6b fix(web/firecrawl): pass timeout to scrape API to match asyncio deadline
The Firecrawl scrape() call was missing the `timeout` parameter, so the
server-side used its 30s default.  The client-side asyncio.wait_for
expects 60s, causing SCRAPE_TIMEOUT on slow pages before the Python
deadline expires.

Fix: pass timeout=60000 (ms) to scrape() so both deadlines align.

Fixes #43272
2026-10-02 20:24:48 -05:00
teknium1
80455093bf test: drop the bundled supermemory provider's tests
The provider's own suite and the supermemory cases in the shared memory
suites (BOM-tolerant config reads, PM SDK admission, multiplex identity
scope, provider threads inheriting the profile, plugin-family secret scope,
cron agent_context) imported plugins.memory.supermemory, which is gone.
The other providers' cases in those suites are unchanged; the SDK-admission
test keeps its mem0 case.
2026-10-02 05:10:06 -07:00
teknium1
bbff6cdf68 test(memory): host-block router tests use a fixture provider, not the removed bundled honcho 2026-10-02 04:39:28 -07:00
teknium1
7e53b3ef82 chore(memory): remove bundled honcho provider; install from the plugin catalog 2026-10-02 04:39:28 -07:00
finn763
823385e5cb fix(agent): keep generated images/videos out of swept media caches (Closes #126445)
Generated image/video output now writes under cache/generated/images|videos
instead of the swept inbound caches (cache/images, cache/videos). The hourly
gateway housekeeping deletes 24h-old files in those dirs; for base64-returning
providers the swept file was the only copy, breaking transcript references,
the Artifacts panel and later edits.

Rebased onto current main, where the writers delegate to agent/provider_media,
so the media kind is now the generated/ subpath. cache/generated is added to
tools/credential_files._CACHE_DIRS: without a mount/sync entry the Docker,
SSH and Modal backends never receive the bytes and the provider result loses
agent_visible_image. All callers consume the returned absolute paths, so no
call-site changes were needed; inbound download paths (get_image_cache_dir /
get_video_cache_dir) and the sweeper are untouched.

RED: tests/agent/test_generated_media_durable.py (9 failed on main) — 25h-backdated
generated files deleted by the real cleanup_image_cache / cleanup_video_cache, and
no mount mapping for cache/generated. tests/tools/test_image_generation_artifacts.py
::test_real_generated_image_is_agent_visible_under_ssh_env covers the sandbox
regression with the real writer. Green: 533 passed, 19 skipped.

Co-authored-by: Froraut <79215537+Froraut@users.noreply.github.com>
(cherry picked from commit fd23181f22232f66aec7076d6bf0868ed45661f2)
2026-10-02 01:18:03 +05:30
kshitijk4poor
647ab0daad test(disk-cleanup): cover kanban exclusion on a call-created file; tidy imports
The kanban test's hook leg used to rewrite the pre-existing attachment, which
the created-paths snapshot already ignores, so the kanban exclusion was never
reached on that path. It now creates a NEW kanban file via the call and
asserts it survives session end. Without the kanban entry in
_NEVER_TRACK_TOP_LEVEL that file gets tracked and deleted.

Also moves the function-local `import os` to module level and replaces
iter(range(1, 10**6)) with itertools.count(1) for call IDs.
2026-10-02 00:55:59 +05:30
kshitijk4poor
91b68e3acc test(disk-cleanup): trim salvage tests to two invariants
Keep the headline invariant (a call never tracks paths it did not
create) and the cross-session snapshot isolation case; the rewritten-args
case exercises the same fail-closed branch as the headline test.
2026-10-02 00:55:59 +05:30
Froraut
c467053f52 fix(disk-cleanup): address review — key snapshots per session, fail closed on unsnapshotted paths
The pre/post snapshot handshake had two ways to mark a user's existing
file as created, which queues it for deletion when the turn ends:

- Snapshots were keyed by tool_call_id alone. llama.cpp sends one
  constant id for every call. When session B's pre hook ran between
  session A's pre and post, A consumed B's snapshot. A's
  already-existing test_user.py then looked "not in existing", and A
  tracked it.
- Every pre_tool_call hook sees the original args. Another plugin's
  `modify` directive is merged afterwards, and post_tool_call sees the
  final args. A path swapped in by that hook was never snapshotted, so
  "not in existing" held for it too. The file was tracked even when the
  write was refused.

Snapshots are now keyed by (task_id or session_id, tool_call_id), the
identity both hooks receive from the dispatcher. They store the paths the
call named that did not exist yet, instead of the ones that did. The post
hook tracks a path only if its own snapshot saw it absent and it exists
now. Any path the snapshot did not cover fails closed.

I reproduced both end to end through model_tools.handle_function_call
with a second plugin's modify hook and two interleaved sessions. The
user's file was deleted before this fix and survives after it, and a
file the call really created is still cleaned up. The README hook
contract is updated to match.

(cherry picked from commit 8d0b853981f1ab0775549f4831a3d4f733a46106)
2026-10-02 00:55:59 +05:30
Froraut
17d55a2032 fix(disk-cleanup): track only files a tool call created, never pre-existing ones
post_tool_call sent write_file/patch paths, every absolute path in a
terminal command AND every path in its output to dg.track(), gated only
on `p.exists()` plus the test_*/tmp_* name rule. Category 'test' is
deleted at age 0 by quick(), which on_session_end runs after every turn,
and directories are rmtree'd. So a user's cron script
$HERMES_HOME/scripts/test_uptime.py the agent merely patched, or a hook
dir $HERMES_HOME/hooks/test_notify it listed (`ls -la`, `find ... -name
'test_*'`), was irreversibly deleted when the turn ended — then the
emptied scripts/ and hooks/ dirs too. The plugin's contract is files
"created during Hermes sessions".

A pre_tool_call hook now snapshots which of the call's argument paths
already exist (keyed by tool_call_id; it never raises, since pre hooks
fail closed; entries expire after an hour if the post hook never
fires). post_tool_call tracks a path only when the call named it, it
did not exist before and exists now. Paths seen only in terminal output
carry no such proof and are no longer tracked; no snapshot means
nothing is tracked. Existing tests now drive the real hook order.

(cherry picked from commit e0e0e1f7450df0c75a8499fe57b63dc46c6d2af2)
2026-10-02 00:55:59 +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
4da1943d69 test(a2a): trim fail-closed tests to the two invariants
Keep non-loopback+empty allowlist -> closed (the #126756 headline) and
loopback+token+empty allowlist -> open (backward compat). Allowlist
membership and allow-all are already covered by existing TestTrustedPeers
cases.
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
de479f6469 fix(image_gen): keep legacy non-dict Krea refs passing through and cap the bytes actually read
The inlining step called ref.get() on every reference, so a legacy
image_style_references entry that is neither a string nor a dict raised
AttributeError out of generate() (main forwarded it to Krea). It now passes
through untouched.

The 3 MB budget was checked against stat() and the file read separately,
so a file that grew in between was sent in full. Each file is now read once,
at most one byte past the remaining budget, and the cap applies to those
bytes. The refusal test states each expected error_type and message
directly.
2026-10-01 16:22:28 +05:30
kshitijk4poor
68655270c7 fix(image_gen): run the credential guard before probing a local Krea style reference
The salvaged inlining checked is_file() and summed st_size before
raise_if_read_blocked(), so a denied path (e.g. HERMES_HOME/.env) answered
"not found" or "over 3 MB" and revealed whether it exists and how big it
is. The guard now runs first, and its denial comes back as the plugin's
normal error dict instead of an exception escaping generate().

Local files are inlined after the managed-gateway LoRA/moodboard fail-fast,
so a request about to be refused no longer reads and base64s up to 3 MB.
The size message is built from the constant. The four salvaged tests
become one embed test and one parametrized refusal test (missing file,
total over the cap, guard-denied path).
2026-10-01 16:22:28 +05:30
Mariano Nicolini
bf1bc78e63 feat(image_gen): expose the Krea 2 sliders to the agent only when the active backend declares them
(cherry picked from commit cbbd7f2b7b961fc822b47f4783b29fbc581f06b6)
2026-10-01 16:22:28 +05:30
Mariano Nicolini
87f3fa8881 fix(image_gen): cap local Krea style references by total size so multi-file requests fit the gateway limit
(cherry picked from commit 3e4e2bc4dbcd3143099455a9b604fb36af35f34a)
2026-10-01 16:22:28 +05:30
Mariano Nicolini
f5928fe003 fix(image_gen): embed local Krea style references so files from disk work outside a sandbox
(cherry picked from commit de6fe8e09002386786f6e64755d948a33c17bd89)
2026-10-01 16:22:28 +05:30
kshitijk4poor
a042567296 test: tighten the audit's new assertions after review
- relay-deliver-budget: the ceiling/timeout composition is checked
  against the imported constants (which the mirror tests already tie to
  the Python defaults) instead of re-reading config_defaults.py.
- terminal env sync: the key recorder also traps get()/[] and is an
  instance, the probe fails loudly if the bridge looks up no keys (so the
  gateway-only-key check cannot go vacuous), one _cli_env_map() helper
  serves both tests, and the docstring says what is actually driven.
- live_system_guard bypass reuses _live_system_guard_is_active().
- retaindb no-client prefetch asserts no thread is spawned through the
  module's spawn_context_thread seam, not a private list.

Each changed assertion re-proven red by its production mutation.
2026-09-29 15:58:55 +05:30
kshitijk4poor
b65972c1a5 test: give four vacuous tests an assertion that can fail
Each test passed with the behaviour it names removed (proven by mutating
the production owner on the old and new test):

- s6 hooks test_register_noop_on_host: the hook swallows the
  AssertionError into a printed warning, so reaching the manager never
  failed the test. Assert nothing was printed, as the sibling test does.
- live_system_guard bypass: signal 0 to our own PID passes the guard too.
  Assert os.kill is the unpatched builtin.
- retaindb queue_prefetch without a client: a missing guard fails only in
  background threads. Assert no prefetch thread was started.
- test_config golden migration parity: drop the `_config_version == 33`
  exact-match branch, which cannot run again now the version is 49; the
  subset check it fell through to is unchanged.

test_terminal_config_env_sync now drives gateway.run's
_bridge_terminal_config_to_env with every known terminal key instead of
parsing gateway/run.py's source for a dict literal. It asserts each key
reaches the same TERMINAL_* var as the CLI, which the key-set comparison
could not check, and removes the last inspect.getsource in tests/.
2026-09-29 15:58:55 +05:30
unsupportedpastels
99b24916ce fix(photon): don't read a signal-raced sidecar exit as a fatal crash
Same race as the WhatsApp bridge (#127047): a container/supervisor stop
signals the whole process tree, so the Photon sidecar (its own session)
can die before the gateway's stop flow reaches disconnect(), while
_inbound_running is still True. _supervise_sidecar() then reported
SIDECAR_CRASHED and queued a reconnect during shutdown.

Consult the runner's _stop_requested_by_signal, which the signal handler
sets before any stop work runs. A sidecar exit while the gateway keeps
running is unchanged: still a retryable fatal error.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
2026-09-28 21:06:08 -04:00
liuhao1024
11598aebe3 fix(kanban): dashboard Specify/Decompose resolve the profile's aux-LLM key (#123372, salvage #123384)
WHAT: regression test mounting the kanban plugin router exactly as
`_mount_plugin_api_routes` does (behind `_plugin_route_secret_scope`) and driving
Specify under `set_multiplex_active(True)` for launch profile A -> `?profile=workerb`
-> A, asserting the aux call's `get_secret` sees each profile's own key.

WHY: `_run_aux` / `_run_estimate` only pinned the board, never a profile scope, so the
aux client's provider-key read failed closed under multi-profile hosting. The scope is
now bound once at the plugin mount (previous commit) rather than per aux call inside the
plugin: one mechanism for every plugin router, and the `?profile=` request convention
works for the kanban routes too.

Fixes #123372

(cherry picked from commit 6f01ddc9e455b3eee7046d5b1ac969df3499cbeb)
2026-09-28 05:37:55 -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
b63c138d78 fix: Hermes never falls back to the user's node/npm/npx/uv
Maintainer ruling: only Hermes and only its packaged package managers
(uv/pip/node/npm) are ever used; no PATH fallback when the managed tool is
missing, no "prefer the user's if new enough".

- hermes_constants.find_node_executable: node/npm/npx resolve to PM's
  installed copy or None. Every caller already pm.ensure()s on None, so a
  missing runtime is now provisioned instead of silently borrowing the
  user's Node (native-addon ABI / npm cache mismatches).
- agent/lsp/install._install_npm: pm.ensure('npm') when PM npm is absent,
  instead of failing over to whatever npm is on PATH.
- gateway._append_node_dir_for_service: stop baking the invoker's PATH node
  dir into generated systemd/launchd units.
- main_install_repair._resolve_node_runtime_npm: drop the PATH re-scan for
  another npm.
- source_build.source_product_current: run the freshness reader only with
  PM's node.
- doctor: Node/npm rows and npm audit use PM's copies (Termux APT distro
  keeps its system Node).
- install.sh ensure_uv / install.ps1 Get-Uv: always stage the pinned uv
  artifact; delete the "uv on PATH if new enough" developer shortcut.
2026-09-27 22:04:26 -07:00
Kevin Rajan
0ebaf162cc fix(kanban): run clock ticks from the current run, not the task's first start
RunClock ticked from tasks.started_at (the task's first-ever start), so after
a review timeout + retry a healthy current run showed cumulative card age
(e.g. working · 2h for a minutes-old run).

_task_dict() now emits current_run_started_at from the run row
tasks.current_run_id points at (batched single query, same as latest
summaries), and RunClock prefers it, falling back to started_at for older
backends. Fixes #99819.
2026-09-26 16:51:19 -05:00
kshitijk4poor
064f2f6b09 fix(source-check): strip inherited pathspec modes from read-only git probes
GIT_LITERAL_PATHSPECS=1 turns disk-cleanup's ':(literal)' pathspec into filename text, so ls-files misses tracked files and the plugin deletes them.
2026-09-27 01:36:34 +05:30
kshitijk4poor
6e8a0a0f99 test(disk-cleanup): fold the untracked-scratch control into the checkout test
The control test only added one thing over the first new test: a quick()
deletion check for untracked scratch in a git-init'ed HERMES_HOME. It also
passed on base, so it pinned no new behaviour. Save both entries in the
first test's quick() call and assert the tracked file survives while the
scratch beside it is deleted, then drop the control. The stack now adds
one test, and that test is still red on base.

Update test_scratch_outside_git_trees_still_cleaned's docstring. It said
only a .git below HERMES_HOME marks a file git-owned, which stopped being
true once an enclosing repo that tracks the file counts too.
2026-09-27 01:36:34 +05:30
kshitijk4poor
b22c36d3bf test(disk-cleanup): fold late-commit and enclosing-repo cases into one test
Keep the stack at two invariant tests: the tracked-file test now also
covers a file committed after first classification in the same process
and a HERMES_HOME nested in an enclosing repo; the separate stale-cache
test is redundant now that there is no cache.

Co-authored-by: David Crandall <david@convergentdesign.dev>
2026-09-27 01:36:34 +05:30
David Crandall
9d6609a14b fix(disk-cleanup): the ls-files cache must not outlive the git index
`_git_tracked_index()` cached one `git ls-files` set per process, so a
long-lived process could keep classifying a file as untracked after git had
taken ownership of it. `guess_category()` runs on every post-tool-call, so the
gateway can cache the index while `test_scratch.py` is still untracked; an
auto-snapshot then stages and commits it, `quick()` re-validates the stored
"test" entry through `guess_category()`, the stale cache still reports the file
as untracked, and `_delete_item()` unlinks a file git now owns (`git status`
shows `D test_scratch.py`).

Key the cached set on the git index's stat signature as well as the home, so a
staged, committed or unstaged change is a new cache key and no invalidation
hook is needed anywhere. The index path comes from `git rev-parse --git-path
index`, cached per home — so the per-call cost stays a single `os.stat`, which
also covers a linked worktree (where `.git` is a pointer file) and an explicit
`GIT_INDEX_FILE`. Fail-open behaviour is unchanged: no index and no git mean the
empty set, and the guard never raises.

Regression test: classify an untracked `test_scratch.py`, then `git add` and
`git commit` it in the same process with no `cache_clear()`, and assert
`quick()` leaves it on disk while an untracked control beside it is still
cleaned.

(cherry picked from commit a3271750608ca4e02e5205311a09b906e16d33d5)
2026-09-27 01:36:34 +05:30
David Crandall
0e799da223 fix(disk-cleanup): a git-tracked file is never disposable, even when HERMES_HOME is the checkout
The `_inside_git_worktree()` guard sliced its parent chain at HERMES_HOME, so
`.git` entries strictly below the home were the only ones consulted. That misses
the case where HERMES_HOME IS a git checkout: on this install `~/.hermes` is the
userfiles repo, so `~/.hermes/scripts/` and any top-level `tmp_*` file sit inside
a worktree yet resolve to no `.git` below the home.

Observed live: the bundled disk-cleanup plugin classified two COMMITTED
regression tests in `~/.hermes/scripts/` as disposable session scratch and
unlinked them — `scripts/test_analyze_upstream_opportunities.py` and
`scripts/test_customization_protocol_v2.py`; the deletion was then committed by
the next auto-snapshot (ce8dc99), so the suite that would have caught a scanner
regression was silently gone. 13 tracked `test_*` files under `scripts/` plus 17
tracked top-level `tmp_*` files were in the same blast radius.

Fix: when HERMES_HOME itself carries `.git`, ask git whether it TRACKS the exact
path (`git ls-files`, one cached subprocess per process keyed on the home) rather
than treating the whole home as protected — a scratch file merely living beside
tracked ones must still be cleanable, or cleanup would be disabled entirely.

Tests: two regression tests — a git-tracked `test_*` file is never classified
disposable and a stale pre-fix tracked.json entry is dropped by quick()'s
re-validation instead of deleted; plus the control that an UNTRACKED `test_*`
file in the same repo is still cleaned. Existing suite 30 -> 32 passed.

(cherry picked from commit c5555940108286c4c1070e84d6d694ad9a35bb76)
(cherry picked from commit c7c39e60d4dc467bf9681c3dcb5781ac96557724)
2026-09-27 01:36:34 +05:30
kshitijk4poor
d24aadfdd1 refactor(copilot): one GitHub effort clamp for the profile and main agent
Follow-up to the #103857 salvage. The Copilot provider profile and the
main-agent GitHub reasoning path each carried the same clamp-then-medium
fallback. Both now call hermes_cli.models.clamp_github_reasoning_effort.

The offline Astra tests move next to the other Copilot effort tests, along
with a check that a structured catalog entry still wins. The main-agent
clamp now has a test pinning max/ultra -> high on the GPT-5 ladder. The
transport test no longer writes config.yaml. The two effort comments now
say the same thing.
2026-09-26 22:21:47 +05:30
brooklyn!
bfb1d952c0 fix(kanban): start the events stream at the board tail
Desktop opened /events with no since, and a missing cursor was read as
0, so every open replayed task_events history. Seed the socket from the
snapshot or this connection's last frame, and start a cursorless stream
at MAX(id). An explicit since still replays from there.

Fixes #81537
2026-09-25 11:26:40 -05:00
kshitijk4poor
e326520d50 refactor(codex): one credential/route authority for aux + image paths
Gate round-1 follow-ups on the #121486 fix:
- auxiliary_client: inline the pool route lookup (no dead try/except or
  fallbacks; HERMES_CODEX_BASE_URL short-circuits once) and read auth.json
  directly when the pool yields no token (no second uncached pool load,
  no re-select race pairing a new pool key with chatgpt.com).
- image plugin: _read_codex_credential() is the single source for both
  is_available() and generate(); _post_image_request requires base_url.
- auth_codex: drop the unused _pool_codex_access_token wrapper; the route
  helper's error fallback reads the profile-scoped override, not the raw
  process env.
- model setup flow: the confirm guards get the resolved Codex base, not
  the chatgpt.com constant.
- cli_model_switch_mixin: self.base_url is always set.
2026-09-25 21:27:06 +05:30
kshitijk4poor
e87f673faa fix(codex): send catalog/image credentials only to their own route
Follow-up to the two contributor commits for #121486. The picker, the
image plugin and the auxiliary Codex client still composed a pooled
gateway key with a base re-read from ambient state (HERMES_CODEX_BASE_URL
or the chatgpt.com default), so a model.base_url-only gateway (env unset)
still sent its key to chatgpt.com.

- auth_codex: resolve_codex_runtime_credentials reports the host a pooled
  credential actually routes to (runtime_provider._pool_entry_mode_and_url:
  env > model.base_url while the row is canonical > row URL) instead of the
  ambient default; get_codex_auth_status carries the same bound base_url.
- picker: get_codex_model_ids(access_token, base_url=) now receives the base
  resolved with the token from hermes_cli/models.py, the CLI default-model
  swap (self.base_url) and the `hermes model` Codex flow.
- aux/image: _resolve_codex_credential_and_base() returns (token, base) from
  one pool selection; the image plugin, _build_codex_client and the raw
  Codex client use it (profile-scoped override from #121497 still wins).
- model_metadata: the non-JWT refusal now applies only when the target is
  chatgpt.com; a gateway key may probe its own gateway's /models.

Adversarial regressions: model.base_url with env unset, env/route mismatch,
opaque + JWT gateway keys, pool-selected credential, pool row with its own
gateway URL, direct-ChatGPT positive control.

Addresses @andrexibiza's review on #121508.
2026-09-25 21:27:06 +05:30
liuhao1024
602aa9a55b fix(agent): keep custom-Codex-base credentials off chatgpt.com
Behind a custom Codex base URL (HERMES_CODEX_BASE_URL / model.base_url
gateway) three paths still hit the hard-coded chatgpt.com host with the
gateway's credential-pool key (#121486):

- the OAuth context-length probe (agent/model_metadata.py) and the
  /model picker's live discovery (hermes_cli/codex_models.py) both GET
  https://chatgpt.com/backend-api/codex/models with
  Authorization: Bearer <gateway key> whenever model.context_length is
  not pinned — the key is sent to a service it does not belong to and
  cannot answer for;
- the openai-codex image_gen plugin posts to the same hard-coded base.

Fix, mirroring the quota probe's existing gate in auth_codex:

- both catalog sites now decline to probe non-JWT credentials (real
  Codex access tokens are JWTs; a gateway key is not one) and fall
  back to the static table / offline sources — same outcome as the
  doomed request today, minus the credential leak;
- a JWT reached through a custom base now probes that base's own
  /models instead of chatgpt.com (catalog URLs are built from the
  resolved base; the per-token cache key includes the base);
- the image plugin resolves its base from HERMES_CODEX_BASE_URL the
  same way the text client does.

Fast-mode host gating in the /fast picker is intentionally left
untouched: lifting it needs an explicit opt-in design decision, not a
bug fix.

(cherry picked from commit 5d76ec525674d7b103ab53955ba5279605457ca1)
[salvage: plugins/image_gen/openai-codex/__init__.py hunk dropped in favour of #121497 (first submitter, profile-scoped override + base-aware Cloudflare headers)]
2026-09-25 21:27:06 +05:30
funky-xamarin
894db6a35b fix(image-gen): honor scoped Codex base URL for native images
(cherry picked from commit f09df8fffa7277bebe909abee5841fa3d0379237)
2026-09-25 21:27:06 +05:30
ethernet
0f65d698d0 Merge remote-tracking branch 'origin/main' into ethie/pm-clean 2026-09-24 13:10:14 -04:00
kshitijk4poor
1318d61b37 test(kimi): pin gzip-only Accept-Encoding on both Moonshot profiles (#28043) 2026-09-24 22:25:06 +05:30
ethernet
f91bd82286 fix: restore catalog Hindsight and harden installers and test guards 2026-09-24 02:03:59 -04:00
ethernet
16652eea18 Merge remote-tracking branch 'origin/main' into ethie/pm-clean
# Conflicts:
#	gateway/config.py
#	gateway/config_loader.py
#	gateway/readiness.py
#	hermes_cli/managed_scope.py
#	hermes_cli/plugin_python_deps.py
#	hermes_cli/plugins_cmd.py
#	hermes_cli/update_cmd_maint.py
#	plugin-catalog/hindsight.yaml
#	plugins/plugin_loader.py
#	providers/__init__.py
#	scripts/run_tests.sh
#	tests/gateway/test_control_socket_windows_live.py
#	tests/gateway/test_gateway_streaming_nested_config.py
#	tests/hermes_cli/test_doctor.py
#	tests/hermes_cli/test_plan_reconciliation_windows_live.py
#	tests/hermes_cli/test_update_apply_shallow_count.py
#	tests/hermes_cli/test_update_concurrent_quarantine.py
#	tests/hermes_cli/test_update_shim_self_lock.py
#	tests/hermes_cli/test_verify_console_scripts.py
#	tests/tools/test_lazy_deps.py
#	tests/tui_gateway/test_subprocess_encoding.py
#	tools/lazy_deps.py
2026-09-23 15:26:34 -04:00
teknium1
36bc4bb210 test: drop restored tests that run in no CI lane or read the bundle text
These came back in #120220 but exercise nothing in CI, so they are not
restored coverage:

- 12 Playwright specs under apps/desktop/e2e: the Desktop E2E job is
  `if: false` in ci.yaml, and the new core lane (#120287) only runs
  apps/desktop/e2e/core/*.spec.ts. Dropped rather than left for that lane.
- tests/plugins/platforms/test_discord_voice_receive.py: skips on the
  nacl/discord import (discord.py[voice] is only in the messaging extra CI
  does not install) and copied the production opus loader.
- electron/command-screenshot.test.ts: darwin-only; the JS lane is Linux.
- electron/wsl-path-bridge-gate.test.ts: faked process.platform = win32.
- test_kanban_dashboard_plugin markdown sanitiser case + probe fixture:
  sliced function text out of dist/index.js by brace counting and eval'd it.
  The plugin exposes no seam to reach MarkdownBlock behaviourally.
2026-09-23 10:34:54 -07:00
teknium1
53daae7e2f test: restore dashboard, provider and Desktop re-bind guards dropped by #120071
- test_kanban_dashboard_plugin::test_dashboard_markdown_html_is_sanitized_before_render:
  runs the real bundle's sanitizer and MarkdownBlock under node; script/event
  handler/javascript: HTML never reaches dangerouslySetInnerHTML (security).
- test_meta_ai_profile::test_images_ride_user_turns_not_tool_results: vision on,
  tool-message vision off, so screenshots never 400 in tool results (#101668).
- session-info.test.ts "rebuilt-runtime re-bind" (7 cases, replaces the regex
  test tests/desktop/test_bots_chat_stream_rekey.py): the pane adopts a rebuilt
  runtime id only when lineage matches and the old runtime is idle (#93942, #94417).
2026-09-23 10:34:54 -07:00
teknium1
f4b9694da4 test: restore regression coverage #120071 dropped as dead or redundant
Review on #120071 (yoniebans) found tests deleted as 'dead' that were only
mis-gated, and regression tests with no remaining equivalent:

- Discord voice receive (real NaCl/RTP: wrong-key drop, DAVE decrypt
  failure, malformed padding, non-allowlisted speaker) moves out of the
  never-selected tests/integration/ to tests/plugins/platforms/, where no
  conftest stubs discord.py; 34 pass with the messaging extra.
- Five *_windows_live.py files had a bare skipif(win32), so
  list_os_marked_tests.py never selected them; now windows_only.
- iron-proxy token-swap E2E (opt-in gate) is back.
- Gateway regressions: cached agent iteration cap (#48127), clarify JSON
  never renders as progress (#52374), handoff watcher DB work off the event
  loop, delivery ledger single connection, checkpoint prune and memory trim
  housekeeping ticks.
- Desktop: command-screenshot IPC rejection, inactive WSL bridge never
  spawns wsl.exe, bootstrap runner git binary.
2026-09-23 10:34:54 -07:00
ethernet
c13ea774e6 refactor: make install-stamp.json the single runtime version identity
Runtime identity resolved through hermes_cli.__version__ (a static 0.0.0
on source installs, rewritten by release stamping) leaked v0.0.0 into
About, /api/health, User-Agents, and plugin compat, and source updates
showed "couldn't reach update server" because identity and channel
authority disagreed with the checkout.

Now: get_version_info() resolves install stamp -> live git -> unknown,
never pyproject metadata, never a package constant. Source checkouts
derive identity from their reachable release tag; the completion tail of
every successful install/update/historical takeover atomically rewrites
install-stamp.json with that identity; a stale source stamp whose commit
no longer matches HEAD defers to live git. ACP/TUI use derived_version
for display and base_version for protocol fields; all ~44 runtime
__version__ consumers migrated; hermes_cli.__version__ and generated
_version.py are gone; release stamping only touches the native manifests
external builders consume (nix/tauri/cargo) and passes release identity
straight into write_install_stamp.py; pyproject.toml stays inert 0.0.0.
Desktop no longer synthesizes a competing install-stamp.json: the
checkout owns its stamp, and desktop-bootstrap classification keys on
the bootstrap-complete marker. verify-bootstrap-version-stamp.py now
cross-checks the checkout's stamp (baseVersion + commit == HEAD).

Validation: 31-file focused suite green (version identity, stamping,
adoption, providers, gateway, acp/tui runtime identity, api server via
extras env, release graph); desktop tsc + 25 vitest green; real-repo
probe: base=unknown derived=git.0635606.dirty source=git on this
checkout; clean-env imports resolve entirely from this tree; windows
footgun + compat-pointer scans clean.
2026-09-23 11:41:01 -04:00
ethernet
063560696e Merge remote-tracking branch 'origin/main' into ethie/pm-clean
# Conflicts:
#	tests/gateway/test_launchd_exit_timeout_drain_cap.py
2026-09-23 10:52:20 -04:00
teknium1
6b6c7f4a99 fix(web): a routed profile without an Exa/Parallel key is refused, not served on the launch key
Under multiplexing `get_provider_env` resolved a scoped miss (`get_env_value` -> None) by falling
through to a bare `os.getenv`, which is the LAUNCH profile's `.env`: a routed profile with no
EXA_API_KEY/PARALLEL_API_KEY of its own searched on another profile's key, and the (key, client)
cache in `cached_sdk_client` faithfully built it a client on that borrowed key. Independent-review
major on #120092 (pre-existing on main, but this PR's claim covered only the both-have-keys case).

The bare `os.getenv` rung now runs only when no profile secret scope is bound (stripped installs,
plain CLI, systemd-injected env keep working); with a scope bound a miss is "" and the provider
raises its usual missing-key error. Isolation is between profiles; no environ fallthrough on a
scoped miss.

Tests: the A->B->A row gains a no-key profile (refused, launch key never used) plus a
single-profile control; the openrouter video sibling gets the same absence row (already correct
on this PR's head, red on main).
2026-09-23 07:49:35 -07:00