You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(memos-local-plugin): bridge status detection misses hermes chat with global flags #1915
In apps/memos-local-plugin/bridge.cts, the isHermesChatRunning() function uses pgrep -f "hermes chat" to detect whether a Hermes chat session is active. This pattern only matches when "hermes" and "chat" are adjacent tokens in the process command line.
However, the hermes CLI supports global flags that are placed before the subcommand. For example, the --skills flag (and others like -m, --provider) can be used either as chat-level flags:
hermes chat --skills memory-routing
or as global flags:
hermes --skills memory-routing chat
In the latter case, the process command line becomes:
The substring "hermes chat" does not appear contiguously here, so pgrep -f "hermes chat" returns no match even though a chat session is actively running.
Impact
This only affects the daemon mode bridge (--daemon flag), where applyStaleRule() uses isHermesChatRunning() to upgrade the status from "disconnected" to "reconnecting". The stdio mode (the default when started via memtensor provider or systemd) is not affected — it manages its own lifecycle via the stdio connection directly.
Suggested Fix
Replace the fixed-string pattern with a regex that allows optional flags between "hermes" and "chat":
- const out = childProcess.execFileSync("pgrep", ["-f", "hermes chat"], {+ const out = childProcess.execFileSync("pgrep", ["-f", "hermes\\s.*chat\\b"], {
This pattern matches "hermes" followed by a whitespace character, then any characters (including flags), then "chat" at a word boundary. It covers both:
hermes chat (adjacent, no flags)
hermes --skills memory-routing chat (global flags before subcommand)
hermes chat --skills memory-routing (flags after subcommand, already matched by the original pattern)
The risk of false positives is minimal — matching a process that contains "hermes" and "chat" in unrelated positions on the same command line is unlikely in practice.
Environment
Hermes Agent: any version supporting global flags before subcommands
memos-local-plugin: any version (confirmed in v2.0.19 / npm v2.0.7)
Summary: Fixes #1915. isHermesChatRunning() in apps/memos-local-plugin/bridge.cts was using pgrep -f "hermes chat" as a literal substring, so it silently missed any session launched with global flags before the subcommand (e.g. hermes --skills memory-routing chat). In daemon mode this left applyStaleRule() permanently stuck on "disconnected" instead of upgrading to "reconnecting". Stdio mode was unaffected (it manages its own status via markConnected / markDisconnected).
The pattern + helper were extracted into a new ESM module apps/memos-local-plugin/bridge/hermes-process.ts, exporting HERMES_CHAT_PROCESS_PATTERN = "hermes\\s.*chat\\b", a JS-side matchesHermesChatCommandLine(cmd) predicate, and an isHermesChatRunning(execFile?) wrapper with injectable execFile for testing. bridge.cts now loads the helper via the same runtimeModule() / importEsm() machinery as its other dependencies and threads it into createBridgeStatusTracker via DI. The new regex covers hermes chat, hermes chat --…, and hermes --… chat while still rejecting hermesctl, hermes status, and unrelated processes thanks to the \s anchor and the \b word boundary.
Verification: pnpm exec vitest run tests/unit/bridge/ → 28 passed (13 new regex / pgrep-wrapper assertions + 15 existing methods/stdio); pnpm run lint (tsc --noEmit) → exit 0; live-fire on Linux spawned a fake /usr/local/bin/hermes --skills memory-routing chat process and confirmed the old literal pattern missed it while the new regex matched it. Two unit failures in tests/unit/storage/{migrator,traces-count}.test.ts were confirmed pre-existing on the base branch (stashed this diff and re-ran) and are unrelated.
Activity
SunayKulkarni commentedon Jun 12, 2026
hey can i work on this issue?
fix(bridge): detect hermes chat with global flags (MemTensor#1915)
fix(bridge): detect hermes chat with global flags in status check
Memtensor-AI commentedon Jun 15, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
0ab7858ed9b05e2bWorking branch:
bugfix/autodev-1915Target branch:
latest dev* branchWorkflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
fix(memos-local-plugin): detect hermes chat with global flags
Memtensor-AI commentedon Jun 15, 2026
✅ AutoDev task
0ab7858ed9b05e2bcompleted.Summary: Fixes #1915.
isHermesChatRunning()inapps/memos-local-plugin/bridge.ctswas usingpgrep -f "hermes chat"as a literal substring, so it silently missed any session launched with global flags before the subcommand (e.g.hermes --skills memory-routing chat). In daemon mode this leftapplyStaleRule()permanently stuck on"disconnected"instead of upgrading to"reconnecting". Stdio mode was unaffected (it manages its own status viamarkConnected/markDisconnected).The pattern + helper were extracted into a new ESM module
apps/memos-local-plugin/bridge/hermes-process.ts, exportingHERMES_CHAT_PROCESS_PATTERN = "hermes\\s.*chat\\b", a JS-sidematchesHermesChatCommandLine(cmd)predicate, and anisHermesChatRunning(execFile?)wrapper with injectableexecFilefor testing.bridge.ctsnow loads the helper via the sameruntimeModule()/importEsm()machinery as its other dependencies and threads it intocreateBridgeStatusTrackervia DI. The new regex covershermes chat,hermes chat --…, andhermes --… chatwhile still rejectinghermesctl,hermes status, and unrelated processes thanks to the\sanchor and the\bword boundary.Verification:
pnpm exec vitest run tests/unit/bridge/→ 28 passed (13 new regex / pgrep-wrapper assertions + 15 existing methods/stdio);pnpm run lint(tsc --noEmit) → exit 0; live-fire on Linux spawned a fake/usr/local/bin/hermes --skills memory-routing chatprocess and confirmed the old literal pattern missed it while the new regex matched it. Two unit failures intests/unit/storage/{migrator,traces-count}.test.tswere confirmed pre-existing on the base branch (stashed this diff and re-ran) and are unrelated.Branch
bugfix/autodev-1915pushed to origin at commitccb369da. Reviewers @MatthewZhuang @CarltonXiang @syzsunshine219.Base branch:
mainBranch:
bugfix/autodev-1915Commit:
ccb369dPR: #1925
Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219
Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219
Fix #1915: fix(memos-local-plugin): bridge status detection misses he…
fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for h…
fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for h…
Fix MemTensor#1915: fix(memos-local-plugin): bridge status detection …
fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for h…
fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for h…