8000 feat(hermes): Hermes Agent integration (notifications, approvals, questions, run state) by DoCurry · Pull Request #480 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

feat(hermes): Hermes Agent integration (notifications, approvals, questions, run state) - #480

Open
DoCurry wants to merge 2 commits into
amirlehmam:masterfrom
DoCurry:feat/hermes-integration
Open

DoCurry wants to merge 2 commits into
amirlehmam:masterfrom
DoCurry:feat/hermes-integration

Conversation

@DoCurry
@DoCurry DoCurry commented Nov 28, 2026 •
Copy link
Copy Markdown

What

This PR adds a Hermes Agent (NousResearch/hermes-agent) integration. A pane running hermes gets the same status as a Claude Code pane:

  • desktop notifications
  • Needs you on approval, clarify, sudo and elicitation prompts
  • working and idle state
  • subagent lines (delegate_task)
  • the prompt log
  • the diff refresh

How

Hermes has no Claude-style hook file, but its Python plugins can register lifecycle hooks. resources/hermes-plugin/ is a small plugin of wmux's own. It translates Hermes hooks into the Claude Code hook events that wmux-hook.js already handles, so a Hermes pane takes the same path a Claude Code pane does and nothing changes in main or the renderer.

Hermes hook wmux event
on_session_start SessionStart
pre_llm_call (main session) UserPromptSubmit (with the prompt)
pre_tool_call / post_tool_call PreToolUse / PostToolUse (tool names mapped, tool_call_id as tool_use_id so the block retracts per #399)
on_human_input_request Notification (permission_prompt / elicitation_dialog)
on_session_end Stop, or SubagentStop for a delegated child
on_session_finalize SessionEnd
subagent_start marks the child session (sends nothing)

Which pane: the session's client, not the gateway

Hermes runs every session in one shared gateway (a managed worker per session), whatever terminal hermes was typed into. That process's environment belongs to whichever pane started the gateway, so WMUX_SURFACE_ID there names the wrong pane for every other session.

A shell-launched Hermes client sends its allowlisted environment with the session (agent.session_client_env). The plugin takes the pane from that environment on every hook, and remembers it per session id for hooks that fire off the turn's thread. A delegated child reports into its parent's pane. A session with no client environment (Hermes Desktop, messaging platforms) reports nothing. The pipe token is a credential and never travels, so the plugin reads it from wmux's token file.

src/main/hermes-context.ts installs the plugin under the Status hooks consent (agent-integration.ts, #132). The rules it follows:

  • It writes only when the Hermes home already exists. That is HERMES_HOME if absolute, otherwise %LOCALAPPDATA%\hermes (~/.hermes elsewhere). It installs into the root profile and every named profile (profiles/<name>/), since each profile loads only its own plugins.
  • It never edits config.yaml itself. Both config changes go through Hermes's own CLI, resolved by absolute path inside the Hermes home:
    • hermes -p <profile> plugins enable wmux --no-allow-tool-override. This also runs after every update of the plugin files, as a precaution: a plugin that is listed as enabled but never went through plugins enable is not loaded, and it's unconfirmed whether an update needs re-admitting.
    • hermes -p <profile> config set terminal.client_env_passthrough [...] adds the WMUX_* routing names, merged with the user's own list. None of them is a credential.
  • Removal takes the routing names back out of that list.
  • It never re-enables a plugin the user turned off with hermes plugins disable wmux.
  • Updates go through the wmux-plugin-version marker. Removal takes back only files that carry it, and leaves alone a same-named plugin of the user's.
  • The plugin does nothing outside a wmux pane, never blocks or raises into Hermes, and never forwards a session id (it would be filed as Claude's and typed into claude --resume).
  • It runs hook processes one at a time so wmux sees them in order. It drops only tool events when wmux falls behind, never Stop, SessionEnd or Notification.
  • It ignores tool events outside a turn, which come from Hermes's post-turn memory/skill review fork, so the pane doesn't stay "working" after Stop.

Smaller changes:

  • hermes is now an agent kind in agent-argv.ts.
  • write_file counts as an edit tool.
  • .gitignore now ignores __pycache__/ and *.pyc.
  • electron-builder.json ships the plugin directory without bytecode.

Session restore for Hermes isn't part of this PR. It can follow the *-resume.ts pattern later.

Testing

  • tests/unit/hermes-context.test.ts (39 tests):
    • Install and removal, the gate on the Hermes home, and the consent text.
    • The config enabled/disabled parsing.
    • Ownership: a user's plugin is left alone, and an interrupted install is completed.
    • Profiles, the passthrough merge and its removal, and re-enabling after an update.
    • The real Python plugin, run with a fake ctx, a stand-in for Hermes's per-session client env and a fake wmux-hook.js. The process env plays the gateway's and names another pane. Cases:
      • each session reports into its client's pane, and two panes' sessions stay apart
      • hooks fired without the client env are routed by session id
      • desktop sessions and non-wmux clients report nothing, and older Hermes versions fall back to the process env
      • event order and payloads
      • no session id is ever sent, and only the file path of an edit (never its content)
      • subagents, including a child's SessionStart
      • the background review fork
  • End to end against a real Hermes gateway (Windows, Hermes Agent, November 2026): a hermes chat typed into one pane sent SessionStart → UserPromptSubmit → PreToolUse(Bash) → PostToolUse → Stop → SessionEnd to that pane, while the gateway's own WMUX_SURFACE_ID named another.
  • Live against wmux 2.70: the plugin drove the pane's agent state idle → working → blocked ("Hermes needs your approval: …") → working → idle.
  • hermes plugins validate resources/hermes-plugin passes. Hermes's loader confirms the plugin loads and its declared hooks match what it registers.
  • npm run typecheck, npm run verify:resources and npm run build (NSIS) pass. eslint reports no new problems.
  • npm test: the only failures are in orchestrator-*, orchestration-status-vocab and powershell-shim. They fail the same way on master without this change on the test machine, so they depend on the environment.
  • A reviewer pass checked the hook names and kwargs against the Hermes source. Its findings are fixed and covered by the tests above.

Hermes Agent (NousResearch) panes now get the same status the Claude Code
integration gives: notifications, Needs you on approval/clarify/sudo prompts,
working/idle, subagent lines, the prompt log and the diff refresh.

- resources/hermes-plugin: a Python Hermes plugin that maps Hermes plugin
  hooks onto the Claude Code hook events wmux-hook.js already handles.
  It does nothing outside a wmux pane and never forwards a session id.
- hermes-context.ts: installs it to <HERMES_HOME>/plugins/wmux under the
  Status hooks consent, only if Hermes is installed. It enables the plugin
  with Hermes's own 'hermes plugins enable', never edits config.yaml, and
  respects 'hermes plugins disable wmux'. Removal takes back only files
  that carry the marker.
- 'hermes' is an agent kind and Hermes's write_file counts as an edit.
Hermes runs every session in one shared gateway (a managed worker per
session), whose environment belongs to whichever pane started it. The
plugin read WMUX_SURFACE_ID from that environment, so every Hermes
session reported into one unrelated pane.

- The plugin now takes the pane from the session's client environment
  (agent.session_client_env), remembers it per session id for hooks fired
  off the turn's thread, and routes a delegated child into its parent's
  pane. A session with no client env (desktop, messaging) reports nothing.
  The pipe token is read from wmux's token file.
- wmux adds the WMUX_* routing names to Hermes's
  terminal.client_env_passthrough via `hermes config set`, merged with the
  user's list, and takes them back out on removal.
- Hermes pins an admitted plugin's contents, so wmux re-runs
  `hermes plugins enable wmux` after every update of the plugin files.
  Without that, an updated plugin is never loaded again.
- The plugin is installed into every Hermes profile, since each loads only
  its own plugins.

Verified end to end against a real Hermes gateway: a `hermes chat` in one
pane reported SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop
and SessionEnd into that pane, while the gateway's own environment named
another.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0