mr-memory 3.7.5 → 3.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +53 -0
- package/index.ts +53 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -292,6 +292,44 @@ async function writeOpenClawConfigFile(config) {
|
|
|
292
292
|
await writeFile(configPath, `${JSON.stringify(config, null, 2)}
|
|
293
293
|
`, "utf8");
|
|
294
294
|
}
|
|
295
|
+
// ──────────────────────────────────────────────────────
|
|
296
|
+
// Full-replace: disable OpenClaw's native memory search so MemoryRouter
|
|
297
|
+
// owns the memory_search tool (no name conflict, no native embeddings 429).
|
|
298
|
+
// memoryFlush (durable MEMORY.md writes) is intentionally left untouched.
|
|
299
|
+
// Global + subagents: writes agents.defaults.memorySearch.enabled.
|
|
300
|
+
// ──────────────────────────────────────────────────────
|
|
301
|
+
async function setNativeMemorySearchEnabled(enabled) {
|
|
302
|
+
const config = await readOpenClawConfigFile();
|
|
303
|
+
config.agents ??= {};
|
|
304
|
+
config.agents.defaults ??= {};
|
|
305
|
+
config.agents.defaults.memorySearch ??= {};
|
|
306
|
+
if (config.agents.defaults.memorySearch.enabled === enabled) return false; // no-op
|
|
307
|
+
config.agents.defaults.memorySearch.enabled = enabled;
|
|
308
|
+
await writeOpenClawConfigFile(config);
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Boot-time self-heal: if a key is configured but native search is still on,
|
|
313
|
+
// flip it off so already-installed users are fixed on restart after updating
|
|
314
|
+
// (no need to re-run `openclaw mr <key>`).
|
|
315
|
+
async function selfHealNativeMemorySearch(api) {
|
|
316
|
+
try {
|
|
317
|
+
const config = await readOpenClawConfigFile();
|
|
318
|
+
const ms = config?.agents?.defaults?.memorySearch;
|
|
319
|
+
if (ms?.enabled === false) return; // already disabled — nothing to do
|
|
320
|
+
const changed = await setNativeMemorySearchEnabled(false);
|
|
321
|
+
if (changed) {
|
|
322
|
+
api.logger.info?.(
|
|
323
|
+
"memoryrouter: disabled native memory search (full-replace). Restart gateway to apply.",
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
} catch (err) {
|
|
327
|
+
api.logger.info?.(
|
|
328
|
+
`memoryrouter: self-heal skipped — ${err instanceof Error ? err.message : String(err)}`,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
295
333
|
async function updateOpenClawPluginEntry(api, patch) {
|
|
296
334
|
const config = await readOpenClawConfigFile();
|
|
297
335
|
config.plugins ??= {};
|
|
@@ -401,6 +439,8 @@ const memoryRouterPlugin = {
|
|
|
401
439
|
api.logger.info?.(`memoryrouter: active (key: ${memoryKey.slice(0, 6)}...)`);
|
|
402
440
|
if (agentKeys)
|
|
403
441
|
api.logger.info?.(`memoryrouter: ${Object.keys(agentKeys).length} agent key(s) configured`);
|
|
442
|
+
// Self-heal already-configured installs: disable native search if still on.
|
|
443
|
+
void selfHealNativeMemorySearch(api);
|
|
404
444
|
}
|
|
405
445
|
else {
|
|
406
446
|
api.logger.info?.("memoryrouter: no key configured — run: openclaw mr <key>");
|
|
@@ -881,6 +921,12 @@ If setting up MemoryRouter for another agent:
|
|
|
881
921
|
try {
|
|
882
922
|
await setPluginConfig(api, { key });
|
|
883
923
|
await setPluginEnabled(api, true);
|
|
924
|
+
try {
|
|
925
|
+
const changed = await setNativeMemorySearchEnabled(false);
|
|
926
|
+
if (changed) console.log(` • Native memory search disabled — MemoryRouter now owns memory_search`);
|
|
927
|
+
} catch (err) {
|
|
928
|
+
console.error(` ⚠ Could not disable native memory search: ${err instanceof Error ? err.message : String(err)}`);
|
|
929
|
+
}
|
|
884
930
|
console.log(`✓ MemoryRouter enabled. Key: ${key.slice(0, 6)}...${key.slice(-3)}`);
|
|
885
931
|
console.log(` • memory_search + memory_get tools registered via plugin`);
|
|
886
932
|
console.log(`\nRun: openclaw mr upload to upload your memories`);
|
|
@@ -913,6 +959,13 @@ If setting up MemoryRouter for another agent:
|
|
|
913
959
|
// This avoids the catch-22 where disabling the plugin removes the `mr` command
|
|
914
960
|
await setPluginConfig(api, {});
|
|
915
961
|
// Note: we intentionally do NOT call setPluginEnabled(api, false)
|
|
962
|
+
// Restore native memory search so the user isn't left with NO memory search.
|
|
963
|
+
try {
|
|
964
|
+
const changed = await setNativeMemorySearchEnabled(true);
|
|
965
|
+
if (changed) console.log(" • Native memory search restored");
|
|
966
|
+
} catch (err) {
|
|
967
|
+
console.error(` ⚠ Could not restore native memory search: ${err instanceof Error ? err.message : String(err)}`);
|
|
968
|
+
}
|
|
916
969
|
console.log("✓ MemoryRouter disabled (key cleared).");
|
|
917
970
|
console.log(" • CLI still available — run `openclaw mr <key>` to re-enable");
|
|
918
971
|
}
|
package/index.ts
CHANGED
|
@@ -320,6 +320,44 @@ async function writeOpenClawConfigFile(config: JsonObject): Promise<void> {
|
|
|
320
320
|
`, "utf8");
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
// ──────────────────────────────────────────────────────
|
|
324
|
+
// Full-replace: disable OpenClaw's native memory search so MemoryRouter
|
|
325
|
+
// owns the memory_search tool (no name conflict, no native embeddings 429).
|
|
326
|
+
// memoryFlush (durable MEMORY.md writes) is intentionally left untouched.
|
|
327
|
+
// Global + subagents: writes agents.defaults.memorySearch.enabled.
|
|
328
|
+
// ──────────────────────────────────────────────────────
|
|
329
|
+
async function setNativeMemorySearchEnabled(enabled: boolean): Promise<boolean> {
|
|
330
|
+
const config = await readOpenClawConfigFile();
|
|
331
|
+
config.agents ??= {};
|
|
332
|
+
config.agents.defaults ??= {};
|
|
333
|
+
config.agents.defaults.memorySearch ??= {};
|
|
334
|
+
if (config.agents.defaults.memorySearch.enabled === enabled) return false; // no-op
|
|
335
|
+
config.agents.defaults.memorySearch.enabled = enabled;
|
|
336
|
+
await writeOpenClawConfigFile(config);
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Boot-time self-heal: if a key is configured but native search is still on,
|
|
341
|
+
// flip it off so already-installed users are fixed on restart after updating
|
|
342
|
+
// (no need to re-run `openclaw mr <key>`).
|
|
343
|
+
async function selfHealNativeMemorySearch(api: OpenClawPluginApi): Promise<void> {
|
|
344
|
+
try {
|
|
345
|
+
const config = await readOpenClawConfigFile();
|
|
346
|
+
const ms = config?.agents?.defaults?.memorySearch;
|
|
347
|
+
if (ms?.enabled === false) return; // already disabled — nothing to do
|
|
348
|
+
const changed = await setNativeMemorySearchEnabled(false);
|
|
349
|
+
if (changed) {
|
|
350
|
+
api.logger.info?.(
|
|
351
|
+
"memoryrouter: disabled native memory search (full-replace). Restart gateway to apply.",
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
} catch (err) {
|
|
355
|
+
api.logger.info?.(
|
|
356
|
+
`memoryrouter: self-heal skipped — ${err instanceof Error ? err.message : String(err)}`,
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
323
361
|
async function updateOpenClawPluginEntry(api: OpenClawPluginApi, patch: JsonObject): Promise<void> {
|
|
324
362
|
const config = await readOpenClawConfigFile();
|
|
325
363
|
config.plugins ??= {};
|
|
@@ -426,6 +464,8 @@ const memoryRouterPlugin = {
|
|
|
426
464
|
if (hasAnyKey) {
|
|
427
465
|
if (memoryKey) api.logger.info?.(`memoryrouter: active (key: ${memoryKey.slice(0, 6)}...)`);
|
|
428
466
|
if (agentKeys) api.logger.info?.(`memoryrouter: ${Object.keys(agentKeys).length} agent key(s) configured`);
|
|
467
|
+
// Self-heal already-configured installs: disable native search if still on.
|
|
468
|
+
void selfHealNativeMemorySearch(api);
|
|
429
469
|
} else {
|
|
430
470
|
api.logger.info?.("memoryrouter: no key configured — run: openclaw mr <key>");
|
|
431
471
|
api.logger.info?.("memoryrouter: get your free API key at https://memoryrouter.ai");
|
|
@@ -935,6 +975,12 @@ If setting up MemoryRouter for another agent:
|
|
|
935
975
|
try {
|
|
936
976
|
await setPluginConfig(api, { key });
|
|
937
977
|
await setPluginEnabled(api, true);
|
|
978
|
+
try {
|
|
979
|
+
const changed = await setNativeMemorySearchEnabled(false);
|
|
980
|
+
if (changed) console.log(` • Native memory search disabled — MemoryRouter now owns memory_search`);
|
|
981
|
+
} catch (err) {
|
|
982
|
+
console.error(` ⚠ Could not disable native memory search: ${err instanceof Error ? err.message : String(err)}`);
|
|
983
|
+
}
|
|
938
984
|
console.log(`✓ MemoryRouter enabled. Key: ${key.slice(0, 6)}...${key.slice(-3)}`);
|
|
939
985
|
console.log(` • memory_search + memory_get tools registered via plugin`);
|
|
940
986
|
console.log(`\nRun: openclaw mr upload to upload your memories`);
|
|
@@ -966,6 +1012,13 @@ If setting up MemoryRouter for another agent:
|
|
|
966
1012
|
// This avoids the catch-22 where disabling the plugin removes the `mr` command
|
|
967
1013
|
await setPluginConfig(api, {});
|
|
968
1014
|
// Note: we intentionally do NOT call setPluginEnabled(api, false)
|
|
1015
|
+
// Restore native memory search so the user isn't left with NO memory search.
|
|
1016
|
+
try {
|
|
1017
|
+
const changed = await setNativeMemorySearchEnabled(true);
|
|
1018
|
+
if (changed) console.log(" • Native memory search restored");
|
|
1019
|
+
} catch (err) {
|
|
1020
|
+
console.error(` ⚠ Could not restore native memory search: ${err instanceof Error ? err.message : String(err)}`);
|
|
1021
|
+
}
|
|
969
1022
|
console.log("✓ MemoryRouter disabled (key cleared).");
|
|
970
1023
|
console.log(" • CLI still available — run `openclaw mr <key>` to re-enable");
|
|
971
1024
|
} catch (err) {
|