Commit graph

2605 commits

Author SHA1 Message Date
Pi Agent
07ce1279fa Drop persist_user_timestamp kwarg for older hermes-agent compatibility
The pinned hermes-agent@sha256:2f1f2f1... doesn't support
persist_user_timestamp in AIAgent.run_conversation(). The webui
expects this parameter, so any prompt fails with:
  TypeError: AIAgent.run_conversation() got an unexpected keyword
  argument 'persist_user_timestamp'

Same pattern as the existing moa_config workaround above each call
site: drop the kwarg, accept the feature gap (timestamp not persisted
on user messages) until the agent is bumped to a version that adds
the parameter.

Co-authored-by: Orca <help@stably.ai>
2026-08-05 17:07:09 +02:00
Pi Agent
0c33c835f4 Disable Hermes auth for WFDASH iframe embedding
is_auth_enabled() now always returns False, which:
- Hides the login screen
- Lets the WebUI load directly in an iframe
- Bypasses password/passkey/OIDC checks

WARNING: This makes Hermes publicly accessible to anyone who hits the URL.
Don't use this patch on any deployment you want to keep private.

Co-authored-by: Orca <help@stably.ai>
2026-08-04 20:12:21 +02:00
Pi Agent
da85fc8db3 Allow iframe embedding: X-Frame-Options SAMEORIGIN, frame-ancestors 'self' + localhost
Co-authored-by: Orca <help@stably.ai>
2026-08-04 18:53:51 +02:00
nesquena-hermes
07b33505fd
Merge branch 'master' into franksong2702/fix-gateway-terminal-persistence 2026-07-31 11:47:43 -07:00
happy5318
f52be26610 docs: update comments to reflect preflight exclusion reasoning
Clarify that preflight compression is intentionally excluded because
the later authoritative 'Compacting context' marker from
conversation_compression is the real signal that compression
proceeded. The preflight status can fire even when compression
exits before compaction (e.g. durable guard refresh, Codex-Hermes
mode with no active thread).
2026-08-01 01:47:51 +08:00
happy5318
9c1c1d8063 fix: stop false Compressing-context card for preflight compression
PR #6184 narrowed the agent-status-to-SSE bridge to real compression
start notices, but the 'preflight compression:' pattern matches the
Hermes agent's preflight check message ("Preflight compression: ~X
tokens >= Y threshold"). This fires on every new session where the
system prompt alone exceeds the threshold, showing a "Compressing
context" card before any model output — a false positive.

Remove 'preflight compression:' from the pattern. The preflight check
is a one-time pre-model-call estimate, not a mid-conversation
compression event that the user needs to see.
2026-08-01 01:07:12 +08:00
Frank Song
dadffe0e02 fix: bind gateway terminal recovery to run identity 2026-07-31 17:31:12 +08:00
Frank Song
ded12e48c5 fix: recover unsaved gateway terminal errors 2026-07-31 12:05:39 +08:00
Frank Song
2f17d1c74c fix: mark failed gateway terminal saves as unpersisted 2026-07-31 09:57:51 +08:00
Rod Boev
4a7b851c8c fix(#6481): materialize pending turns without borrowed display indexes 2026-07-29 18:36:24 +00:00
Rod Boev
9b0506d31d fix(#6481): keep display ownership out of context indexes 2026-07-29 18:36:24 +00:00
Rod Boev
525edef5f7 Fix silent-result ownership for repeated prompts 2026-07-29 18:36:24 +00:00
Rod Boev
66438f07bc Settle verification turns from exact turn ownership 2026-07-29 18:36:24 +00:00
Rod Boev
920b48d709 fix(#6481): preserve repeated pending turns through verification cleanup 2026-07-29 18:36:24 +00:00
Rod Boev
5e447683f8 fix(#6481): keep verification cleanup from duplicating the current turn 2026-07-29 18:36:24 +00:00
Rod Boev
ad3770fd6e fix(#6481): restore marker-only verification cleanup 2026-07-29 18:36:24 +00:00
Rod Boev
663aec682e fix(#6481): prevent verification follow-up context contamination 2026-07-29 18:36:24 +00:00
pxxD1998
cc6c87903a fix(session): bound delete lock wait 2026-07-29 18:22:22 +00:00
pxxD1998
e2b052a637 fix(workspace): persist recovered session bindings 2026-07-29 18:22:22 +00:00
happy5318
a57d576805 fix: make prefixed Qwen detection positive-only to avoid shadowing hybrid IDs
Gate review found that the broadened token-prefix check caused
deepseek-r1-distill-qwen2.5-bakeneko-32b to enter the Qwen branch
(qwen2 token), return False, and prevent the DeepSeek detector from
running — a silent regression.

Fix: split into two phases:
1. Positive-only scan: any token matching qwen(\d+) with major >= 3
   immediately returns True. No False path — Qwen 2.x in hybrid IDs
   falls through to subsequent detectors.
2. Terminal guard (original behavior): standalone "qwen" token or
   normalized.startswith("qwen") still applies the 3+ gate with
   return False for 2.x, since those ARE pure Qwen models.

Add regression test for deepseek-r1-distill-qwen2.5-bakeneko-32b.
2026-07-29 18:07:55 +00:00
happy5318
90250adfb7 fix: address review — remove redundant guard, add regression tests
- Drop the now-subsumed `normalized.startswith("qwen")` guard
  (token-prefix matching already covers the bare case)
- Add test_qwen_prefixed_alias_reasoning_detection covering:
  prefixed Qwen 3+ (al-/sn-), bare Qwen 3+, and Qwen 2.x exclusion
2026-07-29 18:07:55 +00:00
happy5318
041e311f1e fix: Qwen reasoning heuristic fails for prefixed model IDs
The Qwen branch in _candidate_supports_reasoning() checks
"qwen" in token_set, but model IDs like "al-qwen3.8-max-preview"
(New-API alias prefixes) normalize to tokens ["al", "qwen3", "8", ...]
where "qwen" is not a standalone token. This causes the reasoning
effort toggle to disappear for any prefixed Qwen model.

Switch to token-prefix matching (token.startswith("qwen")), consistent
with the position-independent approach already used for DeepSeek
(tokens.index). This handles arbitrary vendor/alias prefixes while
still correctly excluding Qwen 2.x via the existing version gate.
2026-07-29 18:07:55 +00:00
StefanPieter
8db75f8b78 fix: keep SIGUSR1 stack dumps non-terminating 2026-07-29 17:41:46 +00:00
nesquena-hermes
b145f59312 fix(titles): reject trivial-echo new session titles (gate-rebase of #6529)
Co-authored-by: Hermes Agent <hermes@nousresearch.com>
2026-07-26 20:22:25 +00:00
nesquena-hermes
c49568101c fix(sse): close relays on apperror terminal events (gate-rebase of #6527)
Co-authored-by: Hermes Agent <hermes@nousresearch.com>
2026-07-26 19:45:38 +00:00
nesquena-hermes
44877274da Release exp-v0.52.151: repair admin model reload rebinding (#6477, @mspgle-dotcom) 2026-07-26 02:08:30 +00:00
ai-ag2026
a31cdb7765 fix(terminal): unsubscribe when the SSE header write fails after attaching
Adversarial review of the previous commit found a leak it introduced.

`attach_terminal()` subscribes and only then are the response headers written.
A client that dropped in that instant makes `end_headers()` raise
BrokenPipeError/ConnectionResetError, and because the `try/finally` started
*after* those writes, the exception escaped `_handle_terminal_output` with the
queue still in `_subscribers`. That pins `unwatched_since` at None — only
`unsubscribe()` on an empty subscriber list resets it — so the terminal became
permanently unreapable: the exact fd/thread leak (#4633) this reaper exists to
prevent, and strictly worse than the TOCTOU the previous commit fixed, since
that at least still allowed cleanup.

The try now starts immediately after the attach, so every exit path
unsubscribes. Regression test drives a handler whose `end_headers()` raises and
asserts the subscriber list is empty, `unwatched_since` is restored, and the
terminal is reapable again once the grace elapses. It fails against the
previous ordering.
2026-07-25 03:17:30 +02:00
ai-ag2026
07d110a064 fix(terminal): close the reaper's selection→reconnect→close TOCTOU
`_terminals_to_reap()` snapshots victims under `_LOCK` and then releases it,
but `subscribe()` clears `unwatched_since` and appends to `_subscribers` under
the terminal's own `_sub_lock`, which the selection pass never held. A viewer
reconnecting in that gap left object identity — all `close_terminal(expected=…)`
ever checked — still true, so the reaper killed a terminal that now had a live
viewer.

- `_claim_reap_victim()` re-establishes the *whole* selection predicate while
  holding `_LOCK` and the terminal's `_sub_lock`, and removes the registry
  entry in that same critical section: same object, no subscribers, and
  `unwatched_since` still set and still expired. A dead process is still
  reaped unconditionally — it cannot come back, and a viewer watching a corpse
  must not pin the entry forever.
- `attach_terminal()` does the registry lookup and the subscribe atomically
  under `_LOCK`, replacing `get_terminal()` + `term.subscribe()` in the SSE
  route. It takes the same two locks in the same order as the claim, so
  exactly one side wins: the viewer attaches (and the reap is refused), or the
  entry is already gone (and the route answers "terminal not running" before
  committing a 200, instead of streaming from a corpse). Registration is the
  authority — a registered-but-`closed` terminal still attaches so the viewer
  receives `terminal_closed`.
- Teardown moved to `_teardown_terminal()` and runs after both locks are
  released; `killpg`+`wait` can block ~2.5s and must not pin the registry.
- Dropped the duplicated `self.last_activity = time.time()` the rebase left in
  `put_output()`.

Tests: a barrier regression that pauses the reaper after selection, attaches a
viewer through the production path, resumes, and asserts the terminal stays
registered/live and still receives output; the inverse where the reap claims
first and the attach reports not-running; refreshed-grace and replaced-entry
claims; dead-with-viewer; and a probe that `_LOCK` is free during teardown.
Three of them fail against an identity-only claim.
2026-07-25 00:33:41 +02:00
ai-ag2026
932e858994 feat(terminal): reap idle abandoned terminals so #4633 can't accumulate
The fd-leak fix retires a terminal whose shell EXITS, and _MAX_TERMINALS bounds
the worst case, but an interactive shell abandoned by its client (tab closed
without POSTing /api/terminal/close, browser crash, network drop) keeps running
forever — there is deliberately no PDEATHSIG. A background reaper now closes any
terminal that has had zero attached output streams for longer than a 15-minute
idle grace, plus any dead-process terminal as a belt-and-suspenders for the
reader-loop retire.

Attachment is tracked on the subscriber model from the output-broadcast change:
subscribe() clears unwatched_since, the last unsubscribe() sets it. A terminal
is born unwatched, so a spawn nobody ever attaches to is reaped too; the grace
spans a tab refresh / brief drop so a real reconnect keeps the session. Eviction
uses close_terminal(sid, expected=term) so a restart replacement is never torn
down. The reaper thread is a lazily-started daemon singleton like the spawn
supervisor.

Stacked on the terminal fd-leak + output-broadcast changes (same file).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 00:30:06 +02:00
ai-ag2026
1603eb8611 fix(terminal): stop leaking fd + thread + shell on client/​shell exit
Two embedded-terminal resource leaks (#4633):

1. fd + dict entry on shell exit. When a shell exited on its own (user typed
   `exit`, the process died), _reader_loop broke out of its loop but only set
   `closed` and emitted terminal_closed — it never closed the pty master_fd nor
   removed the _TERMINALS entry. Only an explicit close_terminal / restart /
   atexit did that, so every self-exited shell leaked its master fd and dict
   entry for the rest of the WebUI's uptime. The reader loop now retires the
   session (close_terminal with an `expected=` identity guard so a restart's
   replacement is never torn down).

2. Unbounded accumulation of abandoned terminals. A client that drops its output
   stream without POSTing /api/terminal/close (tab close, crash, network drop)
   leaves the shell running (no PDEATHSIG, by design). _MAX_TERMINALS (32) now
   caps the live population, evicting a dead-proc terminal first, else the
   least-recently-active one, to make room.

Also hardens an fd-reuse TOCTOU that #1 would otherwise make reachable on the
common `exit` path: write_terminal / resize now re-check `closed` and touch
master_fd under a per-terminal io_lock that close_terminal also holds around
os.close, so input can never land on a closed-and-recycled fd number.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 00:30:05 +02:00
Hermes Agent
b104abeae6 fix(admin): repair model reload rebinding 2026-07-24 18:05:17 +08:00
b3nw
e93b0c352a
feat: render process wakeups as collapsed summary cards (#6350)
Render structured background-process completions and watch matches as accessible collapsed cards while preserving raw fallback, verbatim output, and full watch patterns.

Co-authored-by: b3nw <b3nw@duck.com>
2026-07-23 20:52:51 +00:00
nesquena-hermes
0d06ae3467 Merge remote-tracking branch 'origin/master' into stage/6040 2026-07-23 02:26:42 +00:00
webtecnica
02b5f885c8 fix(share): harden _embed_share_media with path allow-list + mime validation (#6174)
Embed local MEDIA: image refs as inline base64 at snapshot-build time,
gated by a workspace/attachment-root allow-list, 512KiB cap, image-MIME
allow-list, and magic-byte content validation. Everything else (traversal,
symlink-escape, file://, non-image, SVG, oversize) becomes a static
placeholder. Closes P0 #6174 (public shares no longer emit authenticated
/api/media requests for local paths).

Co-authored-by: webtecnica <webtecnica@users.noreply.github.com>
2026-07-23 01:21:59 +00:00
nesquena-hermes
bbb417b3f1 stage: merge #6113 (per-turn used-model chip in transparent footer) 2026-07-22 22:13:08 +00:00
Rod Boev
8119d91dc3 fix(#6008): serialize identity-less approval relays 2026-07-22 15:06:33 -04:00
nesquena-hermes
f39cedafca stage: merge #5797 2026-07-22 18:45:24 +00:00
nesquena-hermes
65a3f795eb stage: merge #6372 2026-07-22 18:45:24 +00:00
Rod Boev
5a954c79d3 fix(#6008): keep gateway cancel authority stable across startup teardown 2026-07-22 12:33:26 -04:00
Rod Boev
2c6ce96596 fix(#6008): wait for gateway stop acknowledgement 2026-07-22 12:33:26 -04:00
Rod Boev
4a71e407b1 fix(gateway): keep retained no-run approvals visible 2026-07-22 12:31:12 -04:00
Rod Boev
0a3a630856 fix(gateway): keep approval and stop acknowledgements honest 2026-07-22 12:31:12 -04:00
Rod Boev
918b9ddb63 test(gateway): align approval lifecycle regressions 2026-07-22 12:31:12 -04:00
Rod Boev
fb88095530 fix(gateway): require agent-issued approval identities 2026-07-22 12:31:12 -04:00
Rod Boev
a91bd88c70 fix(gateway): preserve approval identity provenance 2026-07-22 12:31:12 -04:00
Rod Boev
f30178e18a fix(gateway): fall back safely without approval identities 2026-07-22 12:31:12 -04:00
Rod Boev
b481dfea13 fix(#6008): keep retained approvals visible in session attention 2026-07-22 12:31:12 -04:00
Rod Boev
5826d76da0 fix(#6008): publish the authoritative approval head 2026-07-22 12:31:12 -04:00
Rod Boev
6460c48ce6 fix(#6008): keep gateway approvals attached to the right run 2026-07-22 12:31:12 -04:00
Rod Boev
b907630f8f fix(#6008): keep gateway approvals attached to the right run 2026-07-22 12:31:11 -04:00