mr-memory 2.10.0 → 2.11.1

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.
Files changed (2) hide show
  1. package/index.ts +49 -4
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -549,6 +549,30 @@ const memoryRouterPlugin = {
549
549
  // CLI Commands
550
550
  // ==================================================================
551
551
 
552
+ // ── Helper: Optimize OpenClaw's built-in memorySearch config
553
+ // When MR is active, disable session transcript scanning (MR handles it)
554
+ // but keep workspace file search (local, fast, no conflict)
555
+ async function optimizeMemorySearchConfig(): Promise<void> {
556
+ try {
557
+ // Set sources to only "memory" (workspace files), remove "sessions"
558
+ await runOpenClawConfigSet("agents.defaults.memorySearch.sources", JSON.stringify(["memory"]), true);
559
+ // Disable experimental session memory
560
+ await runOpenClawConfigSet("agents.defaults.memorySearch.experimental.sessionMemory", "false", true);
561
+ } catch {
562
+ // Non-fatal — config optimization is best-effort
563
+ }
564
+ }
565
+
566
+ // ── Helper: Restore OpenClaw's built-in memorySearch config when MR is disabled
567
+ async function restoreMemorySearchConfig(): Promise<void> {
568
+ try {
569
+ await runOpenClawConfigSet("agents.defaults.memorySearch.sources", JSON.stringify(["memory", "sessions"]), true);
570
+ await runOpenClawConfigSet("agents.defaults.memorySearch.experimental.sessionMemory", "true", true);
571
+ } catch {
572
+ // Non-fatal
573
+ }
574
+ }
575
+
552
576
  api.registerCli(
553
577
  ({ program }) => {
554
578
  const applyKey = async (key: string) => {
@@ -559,7 +583,12 @@ const memoryRouterPlugin = {
559
583
  try {
560
584
  await setPluginConfig(api, { key });
561
585
  await setPluginEnabled(api, true);
586
+ // Optimize OpenClaw's built-in memorySearch: keep workspace file search
587
+ // but disable session transcript scanning (MR handles conversational memory)
588
+ await optimizeMemorySearchConfig();
562
589
  console.log(`✓ MemoryRouter enabled. Key: ${key.slice(0, 6)}...${key.slice(-3)}`);
590
+ console.log(` • Session memory scanning disabled (MR handles this)`);
591
+ console.log(` • Workspace file search kept active`);
563
592
  console.log(`\nRun: openclaw mr upload to upload your memories`);
564
593
  } catch (err) {
565
594
  const message = err instanceof Error ? err.message : String(err);
@@ -582,12 +611,18 @@ const memoryRouterPlugin = {
582
611
  .action(async (key: string) => { await applyKey(key); });
583
612
 
584
613
  mr.command("off")
585
- .description("Disable MemoryRouter (removes key)")
614
+ .description("Disable MemoryRouter (removes key, keeps CLI available)")
586
615
  .action(async () => {
587
616
  try {
617
+ // Soft disable: clear key but keep plugin enabled so CLI remains available
618
+ // This avoids the catch-22 where disabling the plugin removes the `mr` command
588
619
  await setPluginConfig(api, {});
589
- await setPluginEnabled(api, false);
590
- console.log("✓ MemoryRouter disabled.");
620
+ // Note: we intentionally do NOT call setPluginEnabled(api, false)
621
+ // Restore OpenClaw's built-in session memory scanning
622
+ await restoreMemorySearchConfig();
623
+ console.log("✓ MemoryRouter disabled (key cleared).");
624
+ console.log(" • Session memory scanning restored");
625
+ console.log(" • CLI still available — run `openclaw mr <key>` to re-enable");
591
626
  } catch (err) {
592
627
  console.error(`Failed to disable: ${err instanceof Error ? err.message : String(err)}`);
593
628
  }
@@ -657,7 +692,17 @@ const memoryRouterPlugin = {
657
692
  .description("Show MemoryRouter vault stats")
658
693
  .option("--json", "JSON output")
659
694
  .action(async (opts) => {
660
- if (!memoryKey) { console.error("Not configured. Run: openclaw mr <key>"); return; }
695
+ if (!memoryKey) {
696
+ if (opts.json) {
697
+ console.log(JSON.stringify({ enabled: false, key: null }, null, 2));
698
+ } else {
699
+ console.log("MemoryRouter Status");
700
+ console.log("───────────────────────────");
701
+ console.log(`Enabled: ✗ No (no key configured)`);
702
+ console.log(`\nRun: openclaw mr <key> to enable`);
703
+ }
704
+ return;
705
+ }
661
706
  try {
662
707
  const res = await fetch(`${endpoint}/v1/memory/stats`, {
663
708
  headers: { Authorization: `Bearer ${memoryKey}` },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-memory",
3
- "version": "2.10.0",
3
+ "version": "2.11.1",
4
4
  "description": "MemoryRouter persistent memory plugin for OpenClaw — your AI remembers every conversation",
5
5
  "type": "module",
6
6
  "files": [