Commit Graph

102 Commits

Author SHA1 Message Date
Teknium
74cc8a105f fix: a refused skill_manage write reads neutral, not as a red failure
skill_manage refusals (size cap, stale old_string, guards) are the agent's
own retry loop, but every surface painted them as failures: the glyph CLI
led the row with a red ✗ and red reason, Desktop showed the destructive
error glyph and counted it in "N tool calls failed", and answer-only mode
force-surfaced it on TUI/Desktop as a failure the user must see.

One display-only list, agent/display.py::NEUTRAL_FAILURE_TOOLS (mirrored in
Desktop's fallback-model/format.ts), now keeps those rows neutral: the CLI
row keeps its emoji with a dim reason, Desktop renders the existing
"notice" status and leaves it out of the failed count, and tool.complete is
no longer forced through when tool progress is off. The failure still
reaches the model and the loop guardrail unchanged.
2026-10-21 00:14:33 -07:00
Teknium
85188e61c3 Merge origin/main into fix/pkg13-ink-leftovers
Resolves the hermes_cli/cli_tui_mixin.py conflict from #141501 landing: main moved _Panel to
hermes_cli/cli_panel.py and this branch moved the wrap helpers to hermes_cli/cli_tui_wrap.py.
Keep both moves: import _Panel and the wrap helpers, define neither here.

Refs #134889 (N8)
2026-10-19 12:55:27 -07:00
Teknium
c0015464f0 Merge pull request #141501 from NousResearch/fix/pkg13-cli-queue
fix(cli): classic CLI /queue goes into the gateway's durable FIFO (#134889 N5)
2026-10-19 12:12:46 -07:00
Teknium
d439b578d1 docs(cli): /queue's shared gateway queue, move refusal, lost-answer note
The /queue docs said move acts on the pending queue mid-run; it is
refused for prompts the gateway holds. They now also say that
/queue list|rm|edit|clear act on the session's shared gateway queue
(every window's and automation's queued prompts), that queue-mode Enter
uses the same queue, and that a slash command typed after your own
/queue prompt waits briefly for its turn.

Code notes: what a QueueOutcomeUnknown leaves behind (the turn runs
once but is not painted live here), and why an unknown /queue admission
stays tracked and is re-read once per pending list.

Refs #134889 (N5)
2026-10-19 11:56:22 -07:00
Teknium
9e49003893 fix(cli): a resume recreates the --tui -w worktree quit removed, so its turns run
Quitting a clean, idle `hermes --tui -w` session removes its tree and
branch (N8). The session's policy froze that cwd, so a later resume
had every turn refused workspace_unavailable.

The launcher now records each tree it creates in the profile's
tui_worktrees.json. A resume (`--tui --resume`, `--tui -c`, classic
`--resume`/`-c`; all go through _resolve_chat_session_args) whose
session cwd is such a missing tree recreates it at the same path
before attaching. It uses the branch when that survived, else a new
branch of the same name from the repo's current HEAD, and locks the
tree for the session. Only a recorded path directly under the repo's
.worktrees/ is created. Any other missing directory is left alone.

The CLI docs list every keep reason, the resume recreate, and the
remaining quit-time race.

Refs #134889 (N8)
2026-10-19 11:46:26 -07:00
Teknium
fa10b9cb24 fix(cli): glyph layout tool rows keep the classic tool emoji
The glyph layout replaced every finished tool row's emoji (📖 read, 💻 terminal,
🐍 exec...) with a plain ●, and its "preparing" spinner text dropped the emoji too.
Rows now lead with the same emoji the classic ┊ row shows (skin tool_emojis
overrides included); a failed entry still swaps it for the red ✗.
2026-10-19 09:50:06 -07:00
Teknium
2aef21193c fix(cli): glyph layout keeps classic parity for the status line, spinner and reasoning
The glyph layout had dropped things the classic CLI shows:

- the status line rendered a private default subset: context detail, cache
  hit, latency, tokens/s, duration and prompt/idle timers were gone. It now
  renders the classic segments unchanged (same fields, tiers and
  display.status_bar.fields filter) plus cwd and key hints when they fit.
- the composer rule stripped the kaomoji/tool emoji and lost the streamed
  token count (the classic spinner suffix). Both are back.
- reasoning no longer streamed: it was buffered and collapsed to a single
  summary line. It streams live again as in classic, under the dim bar,
  closed by the summary line; post-hoc reasoning keeps classic first-10-lines.
- unset busy_input_mode silently switched to steer in this layout. It is
  interrupt in both layouts again (Tab still queues).
2026-10-19 07:12:58 -07:00
Teknium
e1ac43a4cc fix(cli): keep the full welcome banner in the glyph layout
The launch banner (logo, tools, skills, session) is part of the CLI identity: both layouts now
print it exactly as main does. show_banner and the /clear redraw are back to main byte-for-byte;
the two-line header is removed.
2026-10-19 07:12:58 -07:00
Teknium
e2bb757eba feat(cli): glyph transcript, status line under the composer, two-line header
The classic CLI's scrollback was built from width-sized frames (reasoning and
answer boxes, 40-column rules around every message), so a terminal resize
re-wrapped and garbled everything already printed, and the status bar sat above
the input where the spinner row made the composer jump.

display.cli_layout (new, default "modern") switches to a grammar where every
scrollback row starts with one glyph and never depends on the width:

  ❯ user message            ∴ reasoning collapsed to "Thought for Ns · title"
  ● Verb target  0.2s       ✗ failed call in red, with its exit code
  │ diff under its row      ☤ Hermes answer label, no frame
  ─ turn summary · time

Width-dependent chrome moves into prompt_toolkit's live region: the composer's
top rule carries the spinner, current activity and elapsed time (left) and the
session title (right); the status line renders under the composer with model,
context gauge, live badges (stash, background work, goal, YOLO) and cwd/branch
on the left and the keys that work right now on the right. Launch prints a
two-line header instead of the full banner.

With busy_input_mode unset, the modern layout steers (Tab queues); classic keeps
interrupt. display.cli_layout: classic restores the previous look unchanged.

Also: panel rows wrap per source line, so a heredoc command no longer breaks the
approval panel's right border (both layouts); docs drop the stale claim that
classic chat always queues (steer and interrupt reach the gateway).
2026-10-19 07:12:58 -07:00
Teknium
1e55d1ca87 fix(tui): hermes --tui -w removes a clean worktree on quit again
Since the shared gateway landed, quitting `hermes --tui -w` retained every
worktree, clean ones included, so they piled up. Before #106742 a clean tree
was removed with its branch on quit.

The launcher now removes the tree through `_cleanup_worktree` when it is
clean, no queued or started admission targets a session inside it, and no
other process still works in it. A dirty tree, one with unpushed commits, or
one the gateway still has a turn for is kept and re-locked for its session,
as before. `_retained_tree_is_live` gains `pending_only` so the launcher can
ask "does the gateway still owe work here" without counting plain history.

Refs #134889 (N8)
2026-10-19 03:40:39 -07:00
Teknium
06671b7075 fix: worktree removal treats ignored files as disposable
Ignored files in a worktree (.env copies, caches, build and test output,
launcher scripts) are never meant to be preserved: removing a worktree
deletes them, the same as every other worktree tool. The keep-ignored-work
rule kept 461 of 574 real trees forever, so it is removed with its
regenerable-dir list and main-checkout byte comparison.

Kept: keep-large-untracked, keep-unarchivable (embedded repos, including
ones inside ignored dirs, whose commits may exist nowhere else; an
over-budget ignored walk now reports keep-unarchivable), keep-worktree-refs,
the submodule rule, the showUntrackedFiles=no and skip-worktree fixes, and
the staged-edit recheck.
2026-10-17 21:49:14 -07:00
Teknium
ab1c29d8bb fix: worktree sweep keeps any tree holding work an archive cannot restore
The second review found trees deleted with bytes or commits that were in
neither git nor the archive: untracked files over archive_max_file_mb
(skipped from the snapshot, tree still removed), gitignored embedded
repositories (ls-files --exclude-standard never lists them) and every
ignored file (.env edits, *.secret, info/exclude notes). The classic
pruner had three older gaps of the same class: status.showUntrackedFiles=no
made new files invisible, skip-worktree/assume-unchanged edits read clean,
and commits held only by refs/worktree/* or refs/bisect/* died with the
tree's admin dir.

Rule now enforced at one decision point (worktree_retention.removal_blocker)
used by archive_preflight, the post-snapshot removal boundary in
archive_then_remove (sweep, exit Archive, subagent finalize), the classic
clean-tree pruner, the attended `hermes worktree prune` and the clean exit
path: a tree is removed only when everything irreproducible is in git or the
archive. Kept: keep-large-untracked (archive ref stays), keep-unarchivable
(embedded repo, ignored or not), keep-worktree-refs, keep-ignored-work
(ignored files outside a regenerable-dir allowlist that are not
byte-identical to the main checkout's copy, so .worktreeinclude .env copies
never block). Exit Archive and the subagent note name the reason. Every
dirty check forces --untracked-files=normal and counts flagged-index edits.
The ignored-path walk skips dependency stores without descending and is
capped per tree (unverifiable -> keep).
2026-10-17 21:49:14 -07:00
Teknium
71a83d74d5 fix: worktree sweep honours --older-than, re-gates each tree, archives exact bytes
Review of the snapshot-then-delete sweep found paths where it could remove
work it should keep or store bytes that differ from the working files:

- `hermes worktree prune --older-than N` ran the sweep before applying N; the
  plan now marks any tree idle < N days skip-young before anything runs.
- execute_plan checked liveness once per batch, then archived trees one by one.
  Each tree is now re-gated (lock, /proc cwd/fds, fresh activity) right before
  it is touched, and archive_then_remove re-checks after the snapshot, keeping
  the tree when a process entered or a file changed during capture.
- _last_activity ignored deleted paths; it now stats each changed path's
  nearest surviving folder, so a fresh deletion counts as activity.
- `--attr-source` does not cover info/attributes or core.attributesFile, so
  eol rules still rewrote bytes. Every blob is re-hashed with
  `hash-object --no-filters` and restore writes blob bytes directly.
- The classic CLI applied the exit Archive answer in atexit, after the exit
  watchdog was armed; it is now applied synchronously in _tui_shutdown, with
  a progress line, before _run_cleanup. A failed or interrupted archive keeps
  the tree.
- web_git.worktree_add's existingBranch path skipped the repo registry.
- subagent-* trees got the 72h named-tree tier; one prune_tier_hours helper
  now gives hermes-* and subagent-* the 24h tier in both planners.
- worktree_sweep.py had a text=True git call without encoding="utf-8" (CI red).
2026-10-17 21:49:14 -07:00
Teknium
3882113085 feat: archive stale dirty worktrees before removing them, sweep every repo, ask on dirty exit
The worktree pruner never removed a dirty or unpushed tree at any age, so leftovers of finished
lanes (stray probe files, WIP commits on closed PRs) accumulated forever: 658 trees / ~1 TB on
one machine, 553 of them named lane trees. Approved design (Teknium, 2026-10-17):

- Snapshot-then-delete: an idle tree past its tier (hermes-*/subagent-* 24h, named 72h) with
  uncommitted changes or unpushed commits is archived to refs/hermes/archive/<tree> (HEAD +
  staged + unstaged + non-ignored untracked bytes, built with a temporary index; large untracked
  files skipped and listed) and then removed. A failed archive keeps the tree. Branch kept when
  published on a remote, otherwise the archive anchors its commits.
- Never touched at any age or budget: live hermes lock owners, any live process whose cwd/open fd
  is inside the tree (/proc on Linux, psutil cwd elsewhere), trees with recent file/ref activity,
  Kanban t_<hex> trees.
- No count cap; optional worktrees.max_total_gb evicts the oldest idle trees first.
- Per-profile registry (<HERMES_HOME>/worktree_repos.json) of every repo Hermes made a worktree
  in (hermes -w, /worktree new, subagent isolation, Desktop git pane); the 6h cron sweep unions
  it with its existing sources, scoped and throttled per profile.
- Subagent worktrees with commits/edits are archived and removed at child finish (branch kept).
- Interactive `hermes -w` (CLI and --tui) exit with a dirty/unpushed tree asks Keep (default) /
  Archive & remove / Remove and discard; non-interactive exits never ask.
- `hermes worktree restore <name> [--path]`, archives in `hermes worktree list`, a full
  decision table in `hermes worktree prune --dry-run`, archive retention (30 days).
- worktrees.archive_dirty: false restores the classic never-delete-dirty pruner exactly.
2026-10-17 21:49:14 -07:00
Teknium
bbfe8991c5 docs(cli): Ctrl+D during a gateway turn leaves the turn running
The key table still said Ctrl+D is plain "Exit". It now says that during a
gateway turn it exits and the gateway finishes the turn and ends the session,
that --resume shows the reply, that an approval or clarify asked meanwhile
waits for its timeout or a resume, and that Ctrl+C stops the turn.

Review finding by @alt-glitch on #140489
Review finding by @unsupportedpastels on #140489
Refs #134889 (LC-6b)
Refs #140337
2026-10-17 08:03:48 -07:00
Teknium
a89f374d7c Merge origin/main (#45: 255 commits to 3b63f7b0a4) into feat/unified-gateway-runtime
Conflicts (2 files, 1 hunk each); every main-side change is kept, ported to
where the branch moved the code:

hermes_cli/kanban_db.py (build_worker_context helpers _ctx_cap .. _ctx_comments)
  main:   f5a6651231c/d56e357556f coerce foreign/text timestamps on read; in
          _ctx_role_history the "Recent work" stamp became
          _ctx_stamp(_to_epoch(row['ended_at']) or 0, now) instead of int().
  branch: moved the whole _ctx_* helper block into hermes_cli/kanban_db_context.py
          (kanban_db.py imports it back), deleting it from kanban_db.py.
  merged: kept the branch's deletion in kanban_db.py and applied main's change in
          kanban_db_context.py::_ctx_role_history as
          _ctx_stamp(_kb._to_epoch(row['ended_at']) or 0, now). Main's other
          timestamp coercions in kanban_db.py (Task/Run/Comment/Attachment/Event
          from_row, _TASK_EPOCH_COLUMNS, release_stale_claims,
          _extend_live_stale_claim, task_age) auto-merged unchanged.

hermes_cli/web_server.py (_lifespan)
  main:   d7830c6f42 reworded one comment in the free-tier bootstrap block
          ("the ONE place its identity is created" -> "the one boot-time creator
          of its identity"; guests are now also created on first connector use).
  branch: moved _lifespan's body into hermes_cli/web_server_app.py::app_lifespan.
  merged: kept the branch's relocation and applied main's comment rewording in
          web_server_app.py.

Merge-induced health fix (no conflict marker; the combination tripped the ratchet):
apps/desktop/src/app/session/hooks/use-cwd-actions.ts::changeSessionCwd
  main:   63ed3caa4ba/dbc538547fc grew the function (statusbar cwd change for the
          focused chat / tile runtime ids) to CC 20.
  branch: added the session_busy refusal mapping (sidebar.projects.moveBusy) in
          its catch, +1 branch -> CC 21 > target 20 (scripts/check health blocking).
  merged: both behaviours kept; the busy-error mapping moved verbatim into a
          module-level cwdChangeError(err) helper. Health back to 0 blocking.

Check: every line main added between 1fd1827726 and 3b63f7b0a4 (317 files) is
present in the merged tree.
2026-10-12 16:55:20 -07:00
Teknium
bfa443c033 fix(cli): Ctrl+C clears a typed draft before interrupting a running turn
In the classic CLI, Ctrl+C and Ctrl+Q checked "is the agent running" before
"is there a draft", so pressing Ctrl+C to wipe a half-typed follow-up killed
the in-flight turn and left the text in the prompt. The Ink TUI already
gives the draft priority (resolveCtrlCComposerAction); this brings the
classic CLI to parity: first press clears the draft and the turn keeps
running, the next press on an empty prompt interrupts, a third within 2s
force-exits.

Salvage of #89606, re-applied onto hermes_cli/cli_tui_mixin.py after the
cli.py split.

Co-authored-by: pierrenode <298902573+pierrenode@users.noreply.github.com>
2026-10-12 03:17:33 -07:00
Teknium
129234cee6 docs(cli): classic chat resumes latest and queues at the gateway
Docs follow code (round-13 ruling for stale docs):
- cli.md said classic `hermes chat` refuses bare --continue and --resume latest
  (exit 2). gateway_chat.wants_latest/_resume_latest resolve both through the owner
  and _UNSUPPORTED holds neither; the developer guide already documents them. The
  refused list also omitted --compact, which _UNSUPPORTED refuses. Examples and the
  info box now match _UNSUPPORTED.
- The busy_input_mode `queue` row said the classic CLI queues in-process.
  GatewayChatView.submit sends every line to prompt.submit, never reads
  busy_input_mode and has no steer/redirect path: classic chat always queues at the
  gateway; interrupt/steer are TUI/Desktop behaviours.

Docs only; no test.

Review: ahrazzle B2-23
Review: ahrazzle B2-24
2026-10-11 19:31:40 -07:00
Teknium
0190774d73 docs(gateway): describe the launch options and slash commands the client actually has
The developer guides still listed skills, checkpoints, YOLO, hook acceptance,
pass-session-id, safe mode, ignored rules/user config, title selection,
create-if-missing, usage reports and API credentials as refused by `hermes chat`,
and said other slash commands reject. At this head gateway_chat forwards all of
those as frozen creation policy (`_POLICY`, advertised by runtime.describe from
session_policy.CREATE_FIELDS), and the view dispatches /discard, /branch, /model,
/compress (session.mutate) and /yolo (config.set). Probe
(lanes/docs/probe_chat_flags.py, real parser + validate_options): 13 accepted,
only -w, --image, --run-budget, -v, --no-restore-cwd, bare -c, --resume latest
and a nameless --create-if-missing refuse.

- gateway-classic-cli.md: accepted vs refused table with the reason and
  replacement per refused flag; slash surface; resume may repeat creation flags.
- user-guide/cli.md: same refusal list and frozen-at-creation list; /yolo.
- gateway-local-sessions.md: all six sources; the full CREATE_FIELDS launch
  contract instead of "still return invalid_params"; runtime.describe shape.
- session-storage.md: the gateway is the only canonical session writer; the four
  runtime-ledger tables (ON DELETE RESTRICT, unknown never replayed) and why
  `sessions recover` excludes them.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5458083694
Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5462648005
2026-10-08 19:09:50 -07:00
David Dudok de Wit
b660815f86 fix(cli): recover viewers blocked behind unknown execution
Track dynamic session-wide pending state before filtering admission events; preserve settled outcomes and detach accepted queued input without resending. Treat expected websocket closure as an unknown outcome. Existing settled CLI exit contracts remain intact.

Testing-context: Teknium, https://github.com/NousResearch/hermes-agent/issues/134889
Review finding: additional queued-follower and terminal-precedence probes by GPT-6 Astra.

Validation: tests/acp_adapter/test_adversarial_clarify_disconnect.py, tests/acp_adapter/test_adversarial_client_session_identity.py, tests/acp_adapter/test_adversarial_unknown_follower.py, tests/acp_adapter/test_gateway_queued_unknown.py, tests/hermes_cli/test_gateway_queued_unknown.py, tests/hermes_cli/test_gateway_disconnect_outcome.py, tests/hermes_cli/test_gateway_chat_failures.py

Implementation and additional regression probes were AI-assisted with GPT-6 Astra.

(cherry picked from commit dfcfc00fb45ffde878b4170f534c1c8dfee4a0e3)
2026-10-08 09:10:26 -07:00
David Dudok de Wit
22275bb226 fix(tui): retain session worktrees when the viewer detaches
Closing the TUI must not delete the clean checkout an accepted gateway turn still uses. Retain it for execution and later resume.

Testing-context: Teknium, https://github.com/NousResearch/hermes-agent/issues/134889

Validation: tests/hermes_cli/test_gateway_launch_lifetime.py, tests/hermes_cli/test_tui_resume_flow.py

Implementation and additional regression probes were AI-assisted with GPT-6 Astra.

(cherry picked from commit 53a5baf44083ff27c2ade31546bb38b94ce18560)
2026-10-08 09:10:26 -07:00
teknium1
444dd0af3b Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution
# Conflicts:
#	apps/desktop/electron/main.ts
#	apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts
#	apps/desktop/src/plugins/hermes-bots/i18n.ts
#	gateway/run_shutdown.py
#	gateway/run_startup.py
#	gateway/run_turn.py
#	gateway/session_lifecycle.py
#	tools/bot_mode_dm.py
#	tui_gateway/server.py
#	website/docs/user-guide/features/acp.md
2026-09-23 17:42:41 -07:00
brooklyn!
65ad5296ea fix(cli): make function-key workflows reliable on macOS (#120666)
* fix(tui): preserve function-key events

* fix(cli): add portable dock shortcut

* test: update dock shortcut expectations
2026-09-23 22:05:49 +00:00
teknium1
e91a458d8a fix(pricing): price direct OpenAI/xAI/Anthropic/Google models missing from the snapshot
A direct first-party route whose model is absent from the bundled
official-docs snapshot fell through to the provider's own /models listing,
which carries no prices on api.openai.com or api.x.ai, and recorded the
turn as cost_status=unknown / $0 despite real billed usage (gpt-5-nano on
OpenAI, grok-4.3 on xAI in the live provider canary).

Widen the trusted models.dev fallback from Xiaomi to every pay-per-token
first-party API (openai, xai, anthropic, google, deepseek, xiaomi), keyed
by billing-route provider -> the vendor's API domain. The price applies
only on HTTPS:443 to that domain (or with no base URL, i.e. the provider
default), so relays, downgraded origins, custom endpoints and
subscription routes (xai-oauth, openai-codex) keep their own policy.
Drops the blanket try/except: get_model_info(allow_network=False) reads
only the memory/disk cache and does not raise.
2026-09-23 11:33:09 -07:00
teknium1
086ed22464 Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution
# Conflicts:
#	apps/desktop/src/store/gateway-spawn-priority.test.ts
#	tests/cron/test_cron_bot_chat_delivery.py
#	tests/hermes_cli/test_web_server_sessiondb_eventloop.py
2026-09-23 10:41:05 -07:00
teknium1
43455f5670 feat(cli): live dock shows the standing /goal and queued prompts
The classic CLI dock above the status bar painted subagents and background
processes only. A standing /goal (and whether it is active, parked or
paused) was visible only as a "⊙ goal N/M" status-bar segment, and prompts
waiting in /queue could not be seen at all while the agent worked.

The dock now paints the goal's status line on its top row and a Queue block
(count, first three previews, +N more) on its bottom rows, closest to the
input they will be sent from; F7's summary line carries "goal active|parked|
paused" and "N queued". Goal state comes only from the GoalManager the CLI
already holds for the current session, so the 1 Hz dock refresh never opens
state.db and never shows a previous session's goal after /new.

/queue now dispatches inline while the agent runs, honouring its
busy_policy="dispatch": typed mid-run it was queued as the raw command, so
"/queue X" only re-enqueued X after the turn and /queue list|rm|edit could
not inspect the queue until it had drained.
2026-09-23 10:05:40 -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
teknium1
066c9dca9f docs: describe the Processes block in the CLI/TUI live-work dock 2026-09-20 13:55:03 -07:00
teknium1
2fbcd8b0ea docs(website): link pages by relative Markdown path so they open on GitHub (#114428)
Mechanical `check_doc_links.py --fix` pass over website/docs (hand-authored
and generated pages) and the zh-Hans mirror: 1,868 route-style links
(`](/section/page#anchor)`, `](/docs/...)`) become `](../section/page.md#anchor)`.
Every target was asserted to exist on disk; anchors and query strings are
preserved; fenced code blocks and inline-code examples are untouched.

Two dead targets found by the converter were fixed by hand first:
memory-providers.md linked `/user-guide/plugins` (page is
`user-guide/features/plugins`), and the zh-Hans learning-path still linked the
removed `rl-training` page — ported the EN treatment (external Atropos link).

Docusaurus build after: EN locale 0 unresolved Markdown links, 0 broken links,
0 broken anchors.
2026-09-18 14:27:04 -07:00
teknium1
cbf2d2e598 Merge remote-tracking branch 'origin/main' into fix/106742-thread-resolution
# Conflicts:
#	apps/desktop/electron/main.ts
#	hermes_cli/web_server.py
#	tests/tools/test_bot_retry_policy.py
#	tools/bot_mode_dm.py
#	tools/bot_relay.py
#	tui_gateway/methods_bot_relay.py
#	tui_gateway/server.py
2026-09-16 17:34:01 -07:00
teknium1
0bac33901c fix(tui): complete.path follows terminal.backend from config and keeps ~ remote; docs say where ! runs
Follow-up to the salvaged hunk:
- decide "local vs backend" with _effective_terminal_backend() (config-aware) instead of
  _is_local_terminal_backend() (TERMINAL_ENV only): the Desktop's in-process gateway never
  bridges terminal.backend into the env, so it would have kept listing the host.
- leave `~` unexpanded for a non-local backend (the gateway host's home is the wrong one) and
  let the listing script expand it there; drop the tab-separated protocol for a `name[/]` line.
- docs: shell mode (`!`) deliberately runs on the host where Hermes runs (9704ed86c1),
  never inside a remote/sandbox backend — the old "runs where the terminal tool runs" line
  promised otherwise; tui_gateway/AGENTS.md records the completion rule.
2026-09-16 17:09:12 -07:00
teknium1
43c477571e Merge origin/main (61154b6f68) into feat/unified-gateway-runtime
1,446 upstream commits; 84 conflicted files resolved per family, porting
every post-branch main fix onto the cutover architecture rather than
dropping it or resurrecting replaced pre-cutover code:

- gateway/cron/kanban/a2a: #111988 hygiene bound, silence-marker rejection,
  UX copy, clarify-card retirement on explicit no-answer, Slack task-card
  publication_suppressed, webhook per-route coalescing (wrapping the durable
  admit_producer), kanban dead-worker last output + fingerprint boot witness,
  migrate-profile-identity control verb, SupervisedTickerThread, api-server
  terminal_run_status; config migration 45 kept from main, ours renumbered 46.
- hermes_cli/hermes_state/tools/tui_gateway: read_only SessionDB alongside
  explicit db_path, sessions_cmd observational flag, #111958 served-profile
  skips service install, #111999 usage source upsert repair, archived Bot Chat
  title release, find_canonical_owner, #111151 serves_routed_profile MCP scope,
  session_search after/before/exclude, server.py hunks into session_registry/
  agent_factory siblings, #111775 runtime_check resolve hook, Bot Chat
  silence rule on delivery reply.
- Desktop/apps/shared: pool modules stay deleted; SSH teardown fencing,
  default-profile + peer-window routing, per-session remote headers,
  server->client requests, generated gateway contract with our owner stamps
  and session.replay_gap retained.
- Ink: canonical WebSocket client kept; storedSid reconnect recovery, server
  request store, generated contract types, plain-language copy ported.
2026-09-16 13:20:14 -07:00
teknium1
0a3e792942 fix(worktree): judge no-remote repos against the local trunk instead of reaping everything
`hermes worktree prune` (and the startup/cron pruner) classified every clean tree in a
repository with no remote as "clean and fully merged/pushed" and force-deleted its branch,
even when the branch carried commits that exist nowhere else. `audit_branches` returned []
in the same repos, so a unique local-only branch was invisible to the audit as well.

Root cause: `_worktree_has_unpushed_commits` answered False when `refs/remotes` was empty
("nothing to be unpushed against") and both consumers — `worktree_gc._classify_tree` and
`worktree_ops._classify_prune_candidates` — read False as "safe to reap".

The preceding commit (#111897) flips that branch to True, which is safe but also means a
no-remote repo can never reclaim anything (a tree sitting at trunk, or squash-merged into
it, stays "unpushed" forever because `_worktree_commits_all_merged_upstream` finds no
origin/* base). This commit replaces the unconditional True with a real baseline:

- `_worktree_local_trunk`: `main`/`master`, else the branch checked out in the main
  worktree; None when no trunk exists.
- `_worktree_merge_base_ref`: origin/HEAD|origin/main|origin/master, falling back to the
  local trunk ONLY when the repo has no remote-tracking refs at all. Single resolver used
  by `_worktree_commits_all_merged_upstream` and `worktree_gc.audit_branches`.
- `_worktree_has_unpushed_commits`: with no remote refs, `git log HEAD --not <trunk>`;
  no trunk -> True (preserve), matching the docstring's fail-safe promise.

Net effect in a no-remote repo: unique work is kept ("unpushed commits not found
upstream"), trees at/merged into the local trunk still reap, branch audit reports unique
branches as keep and merged ones as delete, and `git branch -D` can only run on a branch
whose every commit is reachable from or patch-equivalent to the trunk.

Tests: the salvaged no-remote keep test now uses a shared `local_repo` fixture; a control
test proves trunk-merged trees still reclaim and the branch audit reports in the same
repo; `test_merged_predicate_fails_safe_without_upstream` now pins both halves of the
contract (trunk resolves -> merged; no trunk at all -> False/preserve).
2026-09-15 18:27:06 -07:00
Carl Taylor
075a256597 fix(skills): auto-load resolves once per agent and dedupes against -s
The system prompt must stay byte-stable for the life of a conversation:
`_auto_load_skills_result` is seeded in `_SESSION_STATE` and filled on
the FIRST prompt build only (HERMES_IGNORE_RULES captured then too), so
model switches, compression and static-prefix restoration reuse the
exact rendered bytes rather than re-reading config or skill files.

CLI: auto_load renders in the existing background `--skills` preload
thread (real session id for ${HERMES_SESSION_ID}), `-s` names dedupe
against the auto-loaded canonical names via
`build_preloaded_skills_prompt(excluded_loaded_names=)`, the activated
skills line shows auto_load first, and the lazily built agent is seeded
with the pre-resolved bytes. `--ignore-rules` skips auto-load with the
rest of the auto-injected context.

Re-implementation of #74060 by @ctaylor86 against current main.
2026-09-15 03:34:20 -07:00
Teknium
65a6b6831e Port from code-yeongyu/oh-my-openagent#7151: worktree audit gains --json, --older-than, and external-tree visibility
omo's omo-agent-toolkit worktree-sweep (their PR #7151) added three
capabilities our hermes worktree command lacked:

- --json on list and prune: machine-readable audit/result payloads so
  scripts and agents can consume verdicts without scraping table output.
- --older-than DAYS: an age floor that only ever RESTRICTS reaping
  (young-but-reapable trees are kept); it never widens eligibility, so
  the existing safety invariants are untouched.
- External-tree visibility: linked worktrees registered outside
  .worktrees/ are now reported read-only in the audit (branch, locked,
  missing) instead of being invisible, and registrations whose
  directory has vanished are dropped via git worktree prune (metadata
  only, no files touched) during prune.

Not ported: omo's ancestor-of-default-branch merge test (our git cherry
patch-equivalence is strictly stronger under rebase/squash merges), and
their hardcoded external-root exclusion list (we exclude by location:
everything outside .worktrees/ is hands-off).

Tests: 9 new contracts in tests/hermes_cli/test_worktree_gc.py (age gate
restrict-only, external trees never reaped, stale-registration prune
dry-run/real, JSON shapes, negative --older-than rejected). Live E2E on
a scratch repo verified all three flags end to end.
2026-09-13 20:55:29 -07:00
teknium1
80052ce8ac fix(gateway): canonical /compress honours --preview, here [N] and refuses --aggressive
The canonical mutation path (hermes chat, Ink, Desktop, ACP) forwarded the raw
`/compress` argument as `session.mutate(compress, {'focus': '<arg>'})` and
`prepare_compress` passed it straight to `ContextCompressor.compress(force=True,
focus_topic=...)`. `/compress --preview` therefore summarized the transcript and
prepared replacement history under the focus topic "--preview"; `here 3` became a
focus topic too, and `--aggressive` was silently misparsed. Every in-process
surface already routes through `parse_compress_args`; the canonical seam bypassed it.

- `slash_mutation` parses `/compress` with the shared parser and emits a
  structured payload (`preview`, `partial`+`keep_last`, `focus`); `--aggressive`
  is refused with AGGRESSIVE_UNSUPPORTED before any RPC.
- `prepare_compress` builds a `CompressRequest` from the payload. A focus-only
  payload is still the raw argument string (Ink/Desktop wire contract unchanged)
  and goes through the same parser, so `{'focus': '--preview'}` from an older
  client is a preview too. `preview=True` returns the shared
  `summarize_compress_preview` report and touches nothing; `mutate_session`
  short-circuits on that status — no receipt, no revision bump, no publication,
  no eviction, no event. Partial requests summarize the head and rejoin the
  verbatim tail like every other surface.
- `validate_action` admits the structured fields with type checks; `keep_last`
  requires `partial`.
- ACP, gateway CLI, Ink and Desktop render the preview lines instead of
  re-resuming a transcript that did not change.

Invariant tests (red on base): slash_mutation payload shape; a preview
mutation through AuthorityConnection against a real SessionDB reaches no
summarizer, leaves revision/generation/messages/receipts/events unchanged, and
`--aggressive` is refused with `unsupported_compress_options`.

Review #106742 finding F10.
2026-09-13 15:38:28 -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
teknium1
d10bb2ab6f test: make tests/ mirror the source tree; drop issue numbers from filenames
`scripts/run_tests.sh tests/<dir>/` is how a change gets its regression
coverage run, so a test filed under the wrong directory is a test nobody
runs when that code changes. Two kinds of drift had accumulated.

Parallel directories for one source package, folded into the mirror:
  tests/acp        -> tests/acp_adapter   (its __init__/conftest move with it)
  tests/cli        -> tests/hermes_cli    (prompt_toolkit fixture merged into
                                           hermes_cli/conftest.py)
  tests/run_agent  -> tests/agent         (backoff fixture becomes
                                           agent/conftest.py)
  tests/relay      -> tests/gateway/relay
  tests/state      -> tests/hermes_state

246 loose files at tests/ root, routed by the package they import/patch:
hermes_cli, hermes_state, agent, gateway, tools, plugins, tui_gateway, cron.
Installer and desktop-update script tests go to tests/scripts/{install,
desktop_update}/. 43 tests of root-level modules (batch_runner, utils,
hermes_constants, packaging) stay at the root.

Filenames drop their issue numbers (95 files: test_89315_x.py -> test_x.py);
the number stays in the module docstring where it has context.

Collisions: test_cli_skin_integration.py existed in both tests/ and tests/cli
with different subsets — merged into one (10 tests, all kept);
run_agent/test_pre_compress_memory_context.py -> agent/..._handoff.py;
tests/test_account_usage.py -> agent/test_account_usage_fetch.py;
tests/test_web_server.py -> hermes_cli/test_web_server_ws_ping.py.
Deleted: test_minisweagent_path.py (empty since PR #2804),
test_model_picker_scroll.py (tested a private copy of the logic, imported
nothing), test_process_loop_event_loop_warning.py (asserted asyncio behaviour,
imported nothing from Hermes).

Repo-root path arithmetic (Path(__file__).parents[N], dirname chains) is
bumped for the 202 files that changed depth and verified by evaluating every
such expression against the new location. classify_changes' desktop-updater
lane prefix, tests-os.yml's ignore glob and every in-tree path comment follow
the moves. tests/test_tests_tree_layout.py keeps the tree from drifting back.
2026-09-13 09:18:02 -07:00
teknium1
e3c497f04f Merge origin/main into feat/unified-gateway-runtime (Sep 12)
# Conflicts:
#	agent/subdirectory_hints.py
#	gateway/run.py
#	gateway/run_turn.py
#	hermes_cli/config_migrations.py
#	tests/hermes_cli/test_config.py
2026-09-12 11:31:43 -07:00
teknium1
2f92545709 fix(cli): gateway-chat refusals say where each flag went and show a runnable safe-mode command
Review (yoniebans): exit-2 refusals of in-process-only flags now append one
line per flag naming its replacement (TUI flag, config.yaml key or hermes
subcommand), and the --safe-mode 'pass --model' refusal prints a complete
example command that parses through the real CLI parser.
2026-09-12 09:40:10 -07:00
bixycler
70d0f556d7 fix(branding): use the Caduceus ☤ (U+2624), not the Rod of Asclepius ⚕ (U+2625)
Every inline glyph — CLI banner/status bar/response labels/goodbye, setup
and doctor boxes, gateway update prompts, WhatsApp reply prefix, TUI theme,
locale strings and the docs — used ⚕, the staff of Asclepius (medicine).
Hermes carries the Caduceus ☤. The ASCII-art logo was already correct.

Mechanical swap across 60 files (no logic change); both glyphs are
East-Asian-width Neutral so no layout shifts. Skins that set their own
`response_label` / `goodbye` are unaffected.

Direction from PR #7064 (@bixycler), the earliest of #7064 / #9611 / #15574,
redone against current main.

Fixes #9565
2026-09-12 08:25:54 -07:00
Teknium
c6c4161cbf docs(cli): classic chat resolves --resume <title> and -c <title> --create-if-missing at the gateway; bare -c stays refused 2026-09-09 11:02:57 -07:00
Teknium
877bac46e3 docs(cli): classic chat attaches to the gateway; list frozen options, refused flags, and the gateway slash surface 2026-09-09 09:49:32 -07:00
Teknium
adcf70f870 docs(tui): busy-time input is gateway-queued, durable and shared across viewers
Describe the canonical queue-mode behaviour (immediate admission, crash
durability, pending list parity with Desktop, deferred bubble) and that
Ctrl+X on a gateway-queued row cancels it via prompt.cancel.
2026-09-09 06:33:15 -07:00
Teknium
b2aa855b62 fix(cli): open subagent monitor with the TUI Ctrl+T shortcut 2026-09-08 10:37:36 -07:00
Teknium
3863d13440 docs: describe one-line docks and consistent transcript controls 2026-09-08 03:42:08 -07:00
Teknium
23fa4ae748 docs: explain live subagent monitoring across chat surfaces 2026-09-08 03:06:30 -07:00
Teknium
04767e7aaa fix(display): distinguish estimated context from provider usage 2026-09-07 08:13:01 -07:00
Teknium
d8a07768c5 fix(cli): keypad Alt+Enter inserts a newline instead of escape text
Slim rework of despotak's modified-keypad fix in #97290. Mirror existing
non-keypad mappings for modified keypad keys, including lock-state variants,
so Alt+keypad Enter reaches the existing newline handler rather than leaking
[57414;3u into the draft. Preserve installed twin mappings before consulting
pending aliases, matching first-writer-wins registration.

Replace the source PR's keyed branch ladder with a format table and verify
parser parity plus real buffer insertion with two invariant tests. Document
keypad multiline support in English and Chinese.

Live PTY: the exact doubled leak after a real collapsed paste reproduces on
main; all 21 editor cases pass with the fix, including ordinary Enter and
legacy Alt+Enter controls. Whitespace also reproduces on main: adjacent
characters are not the root cause.

Co-authored-by: Christos Despotakis <christos@despotak.is>
2026-09-07 02:09:34 -07:00
Teknium
463292351f fix: mid-turn user message no longer waits behind a foreground terminal command
A message typed while the agent runs (CLI busy_input_mode=interrupt, gateway
priority redirect, ACP redirect) goes through AIAgent.redirect(). During tool
execution redirect() degrades to steer(), whose delivery rides the tool result
— so a long foreground command (a `sleep 285` CI poller, a build) parked the
user's message until it exited. The UI printed "Redirected current turn" while
nothing happened for minutes.

redirect() now also asks the tool workers to YIELD (tools/interrupt.request_yield).
The local terminal backend's wait loop honours it: the drain thread is stopped, the
still-running Popen is adopted by the process registry as a notify_on_complete
background session (ProcessRegistry.adopt_local — output so far seeds the buffer,
the registry reader continues from the pipe), and the tool returns immediately with
status "yielded_to_background" + session_id. The command is never killed; the
completion notification arrives as usual and process(poll/wait/log/kill) work on it.

Non-local backends and internal env.execute() consumers pass no yield_handler and
are unaffected; a stale yield bit is cleared with the interrupt bit per worker tid.
2026-09-05 13:51:06 -07:00