From ff87022efe0427283681567fd7dc65bb6c0a2a54 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 19 Jun 2026 09:20:35 +0000 Subject: [PATCH] fix(bridge): derive profileId dynamically from MEMOS_HOME Fix: bridge.cts hardcoded profileId: "default", causing all profile-specific data to be invisible in the memOS web viewer for non-default profiles. The Python adapter already derives profileId correctly from HERMES_HOME. This change mirrors that logic in the Node.js bridge. - Add deriveProfileId() function that parses profile name from MEMOS_HOME path - Parse /profiles// pattern to extract profile identifier - Fallback to "default" if MEMOS_HOME is not set or path does not match - Impact: zero for single-profile/default setups (still resolves to "default") Fixes profile resolution issue reported by nova profile users. --- apps/memos-local-plugin/bridge.cts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/memos-local-plugin/bridge.cts b/apps/memos-local-plugin/bridge.cts index 81848acf7..8b68fc5c4 100644 --- a/apps/memos-local-plugin/bridge.cts +++ b/apps/memos-local-plugin/bridge.cts @@ -246,9 +246,27 @@ async function main(): Promise { ? resolveHome(args.agent, args.home) : undefined; + // Derive profileId dynamically from MEMOS_HOME. + // MEMOS_HOME points to /memos-plugin, so parent dir is hermes-home. + // e.g. /root/.hermes/profiles/nova/memos-plugin → profile = "nova" + // /root/.hermes/memos-plugin → profile = "default" + const deriveProfileId = (): string => { + const memosHome = process.env.MEMOS_HOME; + if (memosHome) { + const hermesHome = memosHome.replace(/memos-plugin\/?$/, ""); + const match = /\/profiles\/([^/]+)\/?$/.exec(hermesHome); + if (match?.[1]) { + const cleaned = match[1].toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, ""); + if (cleaned) return cleaned; + } + if (hermesHome.endsWith("/.hermes")) return "default"; + } + return "default"; + }; + const resolvedProfileId = deriveProfileId(); const { core, config, home } = await bootstrapMemoryCoreFull({ agent: args.agent, - namespace: { agentKind: args.agent, profileId: "default" }, + namespace: { agentKind: args.agent, profileId: resolvedProfileId }, pkgVersion, hostLlmBridge: args.daemon ? null : lazyHostLlmBridge, home: resolvedHome,