Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/memos-local-plugin/bridge.cts
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,11 @@ function createBridgeStatusTracker(statusFile: string, daemon: boolean): {
};
}

const HERMES_CHAT_PROCESS_PATTERN = "hermes(?:\\s+\\S+)*\\s+chat\\b";

function isHermesChatRunning(): boolean {
try {
const out = childProcess.execFileSync("pgrep", ["-f", "hermes chat"], {
const out = childProcess.execFileSync("pgrep", ["-f", HERMES_CHAT_PROCESS_PATTERN], {
encoding: "utf8",
timeout: 1000,
});
Expand Down
40 changes: 40 additions & 0 deletions apps/memos-local-plugin/tests/unit/bridge-status.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";

function matchesHermesChatProcess(command: string): boolean {
const bridgePath = path.resolve(__dirname, "../../bridge.cts");
const bridgeSource = fs.readFileSync(bridgePath, "utf8");
const match = bridgeSource.match(
/const HERMES_CHAT_PROCESS_PATTERN = "(?<pattern>.*)";/,
);
expect(match?.groups?.pattern).toBeTruthy();
const escapedPattern = match!.groups!.pattern;
const pattern = escapedPattern.replaceAll("\\\\", "\\");
return new RegExp(pattern).test(command);
Comment on lines +12 to +14
}

describe("Hermes chat process detection", () => {
it("matches the standard Hermes chat command", () => {
expect(matchesHermesChatProcess("hermes chat")).toBe(true);
expect(matchesHermesChatProcess("/usr/local/bin/hermes chat")).toBe(true);
});

it("matches global flags before the chat subcommand", () => {
expect(
matchesHermesChatProcess(
"/usr/local/lib/hermes-agent/venv/bin/hermes --skills memory-routing chat",
),
).toBe(true);
expect(
matchesHermesChatProcess(
"hermes -m gpt-4.1 --provider openai chat --skills memory-routing",
),
).toBe(true);
});

it("does not match non-chat Hermes commands", () => {
expect(matchesHermesChatProcess("hermes dashboard")).toBe(false);
expect(matchesHermesChatProcess("hermes --skills memory-routing gateway")).toBe(false);
});
});