mr-memory 3.13.1 → 3.13.2
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/README.md +11 -2
- package/index.js +27 -5
- package/index.ts +29 -8
- package/memoryrouter-api.ts +3 -1
- package/openclaw.plugin.json +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@ Use it when you want OpenClaw memory that does not restart from zero every sessi
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
openclaw plugins install npm:mr-memory@3.
|
|
12
|
+
openclaw plugins install npm:mr-memory@3.13.2
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
The explicit `npm:` source and version make the audited install deterministic. `mr-memory@3.
|
|
15
|
+
The explicit `npm:` source and version make the audited install deterministic. `mr-memory@3.13.2` is published on npm. A ClawHub listing has not been verified and is not required for this path.
|
|
16
16
|
|
|
17
17
|
## Setup
|
|
18
18
|
|
|
@@ -30,8 +30,17 @@ openclaw mr upload --brain ~/.notopenclaw # Upload from a different agent
|
|
|
30
30
|
openclaw mr off # Disable
|
|
31
31
|
openclaw mr delete # Clear vault
|
|
32
32
|
openclaw mr <key> # Enable with key
|
|
33
|
+
openclaw mr low # Up to 21 memories (12 raw + 6 tier 2 + 3 tier 3)
|
|
34
|
+
openclaw mr medium # Up to 43 memories (25 + 12 + 6), balanced default
|
|
35
|
+
openclaw mr high # Up to 87 memories (50 + 25 + 12)
|
|
33
36
|
```
|
|
34
37
|
|
|
38
|
+
## Memory Density
|
|
39
|
+
|
|
40
|
+
The current density choices are `low`, `medium`, and `high`. New installs and configs without an explicit density use `medium`, the balanced default. Existing explicit `low` or `high` settings are unchanged. Legacy `xhigh` configs remain valid so upgrades do not break the gateway, but the plugin normalizes `xhigh` to `high` and no longer advertises it as a current option.
|
|
41
|
+
|
|
42
|
+
The totals are tier-aware retrieval budgets, not raw-memory-only limits. Actual results can be lower when fewer relevant memories match.
|
|
43
|
+
|
|
35
44
|
## Upload Options
|
|
36
45
|
|
|
37
46
|
```bash
|
package/index.js
CHANGED
|
@@ -290,6 +290,25 @@ const WORKSPACE_FILES = [
|
|
|
290
290
|
"IDENTITY.md", "USER.md", "MEMORY.md", "HEARTBEAT.md",
|
|
291
291
|
"TOOLS.md", "AGENTS.md", "SOUL.md", "BOOTSTRAP.md",
|
|
292
292
|
];
|
|
293
|
+
// ──────────────────────────────────────────────────────
|
|
294
|
+
// Helpers
|
|
295
|
+
// ──────────────────────────────────────────────────────
|
|
296
|
+
/** Current densities are low, medium, and high. Legacy xhigh remains valid in
|
|
297
|
+
* existing configs but is deliberately hidden from current choices and sent
|
|
298
|
+
* to MemoryRouter as high. Missing or invalid values use the balanced medium
|
|
299
|
+
* default. */
|
|
300
|
+
function normalizeMemoryDensity(value) {
|
|
301
|
+
switch (value) {
|
|
302
|
+
case "low":
|
|
303
|
+
case "medium":
|
|
304
|
+
case "high":
|
|
305
|
+
return value;
|
|
306
|
+
case "xhigh":
|
|
307
|
+
return "high";
|
|
308
|
+
default:
|
|
309
|
+
return "medium";
|
|
310
|
+
}
|
|
311
|
+
}
|
|
293
312
|
function openClawConfigPath() {
|
|
294
313
|
return process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_CONFIG || join(os.homedir(), ".openclaw", "openclaw.json");
|
|
295
314
|
}
|
|
@@ -474,7 +493,7 @@ const memoryRouterPlugin = {
|
|
|
474
493
|
const cfg = api.pluginConfig;
|
|
475
494
|
const endpoint = cfg?.endpoint?.replace(/\/v1\/?$/, "") || DEFAULT_ENDPOINT;
|
|
476
495
|
const memoryKey = cfg?.key;
|
|
477
|
-
const density = cfg?.density
|
|
496
|
+
const density = normalizeMemoryDensity(cfg?.density);
|
|
478
497
|
const mode = cfg?.mode || "relay";
|
|
479
498
|
const logging = cfg?.logging ?? false;
|
|
480
499
|
const embeddings = cfg?.embeddings; // undefined = bge (default), "qwen" = qwen3-8b
|
|
@@ -688,6 +707,8 @@ If setting up MemoryRouter for another agent:
|
|
|
688
707
|
// On stock OpenClaw, the return value is ignored (fire-and-forget).
|
|
689
708
|
// When PR #24122 merges, OpenClaw will use the returned prependContext.
|
|
690
709
|
// This gives forward compatibility — no plugin update needed.
|
|
710
|
+
// Current stock SDK typings still mark llm_input as observation-only;
|
|
711
|
+
// runtime builds that support returned context consume this value.
|
|
691
712
|
api.on("llm_input", async (event, ctx) => {
|
|
692
713
|
// Auto-consolidation runs are single-purpose tool sessions: no memory
|
|
693
714
|
// injection (their prompt must stay exactly the consolidation
|
|
@@ -1499,11 +1520,12 @@ If setting up MemoryRouter for another agent:
|
|
|
1499
1520
|
console.log("Then restart gateway:");
|
|
1500
1521
|
console.log(" openclaw gateway restart");
|
|
1501
1522
|
});
|
|
1502
|
-
//
|
|
1523
|
+
// Current density commands. Legacy xhigh configs still load as high,
|
|
1524
|
+
// but xhigh is intentionally not advertised as a command.
|
|
1503
1525
|
for (const [name, desc] of [
|
|
1504
|
-
["
|
|
1505
|
-
["
|
|
1506
|
-
["
|
|
1526
|
+
["low", "Set density to low: up to 21 memories (12 raw + 6 tier 2 + 3 tier 3)"],
|
|
1527
|
+
["medium", "Set density to medium: up to 43 memories (25 raw + 12 tier 2 + 6 tier 3) [default, balanced]"],
|
|
1528
|
+
["high", "Set density to high: up to 87 memories (50 raw + 25 tier 2 + 12 tier 3)"],
|
|
1507
1529
|
]) {
|
|
1508
1530
|
mr.command(name)
|
|
1509
1531
|
.description(desc)
|
package/index.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { readFile, readdir, stat, lstat, writeFile, copyFile, mkdir } from "node:fs/promises";
|
|
12
|
-
import { commitReflections, consolidateCheckout, dateSearch, deleteMemories, deleteMemoryIds, getMemoryStats, ingestMemory, inspectMemory, prepareMemory, searchMemory, warmupMemory } from "./memoryrouter-api.js";
|
|
12
|
+
import { commitReflections, consolidateCheckout, dateSearch, deleteMemories, deleteMemoryIds, getMemoryStats, ingestMemory, inspectMemory, prepareMemory, searchMemory, warmupMemory, type MemoryDensity } from "./memoryrouter-api.js";
|
|
13
13
|
import { isAutoConsolidationSession, maybeTriggerAutoConsolidate } from "./auto-consolidate.js";
|
|
14
14
|
import { join, resolve, relative, isAbsolute, sep, dirname } from "node:path";
|
|
15
15
|
import path from "node:path";
|
|
@@ -316,7 +316,8 @@ const WORKSPACE_FILES = [
|
|
|
316
316
|
type MemoryRouterConfig = {
|
|
317
317
|
key: string;
|
|
318
318
|
endpoint?: string;
|
|
319
|
-
|
|
319
|
+
/** xhigh is accepted only for backward compatibility and normalizes to high. */
|
|
320
|
+
density?: MemoryDensity | "xhigh";
|
|
320
321
|
mode?: "relay" | "proxy";
|
|
321
322
|
logging?: boolean;
|
|
322
323
|
embeddings?: string;
|
|
@@ -334,6 +335,23 @@ type MemoryRouterConfig = {
|
|
|
334
335
|
// Helpers
|
|
335
336
|
// ──────────────────────────────────────────────────────
|
|
336
337
|
|
|
338
|
+
/** Current densities are low, medium, and high. Legacy xhigh remains valid in
|
|
339
|
+
* existing configs but is deliberately hidden from current choices and sent
|
|
340
|
+
* to MemoryRouter as high. Missing or invalid values use the balanced medium
|
|
341
|
+
* default. */
|
|
342
|
+
function normalizeMemoryDensity(value?: MemoryRouterConfig["density"]): MemoryDensity {
|
|
343
|
+
switch (value) {
|
|
344
|
+
case "low":
|
|
345
|
+
case "medium":
|
|
346
|
+
case "high":
|
|
347
|
+
return value;
|
|
348
|
+
case "xhigh":
|
|
349
|
+
return "high";
|
|
350
|
+
default:
|
|
351
|
+
return "medium";
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
337
355
|
type CompatApi = OpenClawPluginApi & {
|
|
338
356
|
updatePluginConfig?: (config: Record<string, unknown>) => Promise<void>;
|
|
339
357
|
updatePluginEnabled?: (enabled: boolean) => Promise<void>;
|
|
@@ -525,7 +543,7 @@ const memoryRouterPlugin = {
|
|
|
525
543
|
const cfg = api.pluginConfig as MemoryRouterConfig | undefined;
|
|
526
544
|
const endpoint = cfg?.endpoint?.replace(/\/v1\/?$/, "") || DEFAULT_ENDPOINT;
|
|
527
545
|
const memoryKey = cfg?.key;
|
|
528
|
-
const density = cfg?.density
|
|
546
|
+
const density = normalizeMemoryDensity(cfg?.density);
|
|
529
547
|
const mode = cfg?.mode || "relay";
|
|
530
548
|
const logging = cfg?.logging ?? false;
|
|
531
549
|
const embeddings = cfg?.embeddings; // undefined = bge (default), "qwen" = qwen3-8b
|
|
@@ -744,7 +762,9 @@ If setting up MemoryRouter for another agent:
|
|
|
744
762
|
// On stock OpenClaw, the return value is ignored (fire-and-forget).
|
|
745
763
|
// When PR #24122 merges, OpenClaw will use the returned prependContext.
|
|
746
764
|
// This gives forward compatibility — no plugin update needed.
|
|
747
|
-
|
|
765
|
+
// Current stock SDK typings still mark llm_input as observation-only;
|
|
766
|
+
// runtime builds that support returned context consume this value.
|
|
767
|
+
(api as any).on("llm_input", async (event: any, ctx: any) => {
|
|
748
768
|
// Auto-consolidation runs are single-purpose tool sessions: no memory
|
|
749
769
|
// injection (their prompt must stay exactly the consolidation
|
|
750
770
|
// mission) and no re-trigger loops.
|
|
@@ -1590,11 +1610,12 @@ If setting up MemoryRouter for another agent:
|
|
|
1590
1610
|
console.log(" openclaw gateway restart");
|
|
1591
1611
|
});
|
|
1592
1612
|
|
|
1593
|
-
//
|
|
1613
|
+
// Current density commands. Legacy xhigh configs still load as high,
|
|
1614
|
+
// but xhigh is intentionally not advertised as a command.
|
|
1594
1615
|
for (const [name, desc] of [
|
|
1595
|
-
["
|
|
1596
|
-
["
|
|
1597
|
-
["
|
|
1616
|
+
["low", "Set density to low: up to 21 memories (12 raw + 6 tier 2 + 3 tier 3)"],
|
|
1617
|
+
["medium", "Set density to medium: up to 43 memories (25 raw + 12 tier 2 + 6 tier 3) [default, balanced]"],
|
|
1618
|
+
["high", "Set density to high: up to 87 memories (50 raw + 25 tier 2 + 12 tier 3)"],
|
|
1598
1619
|
] as const) {
|
|
1599
1620
|
mr.command(name)
|
|
1600
1621
|
.description(desc)
|
package/memoryrouter-api.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const JSON_HEADERS = { "Content-Type": "application/json" };
|
|
2
2
|
|
|
3
|
+
export type MemoryDensity = "low" | "medium" | "high";
|
|
4
|
+
|
|
3
5
|
type PreparePayload = {
|
|
4
6
|
messages: Array<{ role: string; content: string }>;
|
|
5
|
-
density:
|
|
7
|
+
density: MemoryDensity;
|
|
6
8
|
embeddings?: string;
|
|
7
9
|
};
|
|
8
10
|
|
package/openclaw.plugin.json
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"density": {
|
|
20
20
|
"label": "Memory Density",
|
|
21
|
-
"placeholder": "
|
|
21
|
+
"placeholder": "medium",
|
|
22
22
|
"advanced": true,
|
|
23
|
-
"help": "
|
|
23
|
+
"help": "Current choices: low, up to 21 memories (12 raw + 6 tier 2 + 3 tier 3); medium, up to 43 (25 + 12 + 6), balanced default; high, up to 87 (50 + 25 + 12)."
|
|
24
24
|
},
|
|
25
25
|
"keepWarmMs": {
|
|
26
26
|
"label": "Keep Warm Window (ms)",
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"density": {
|
|
50
50
|
"type": "string",
|
|
51
|
-
"
|
|
51
|
+
"pattern": "^(low|medium|high|xhigh)$",
|
|
52
|
+
"default": "medium",
|
|
53
|
+
"description": "Current densities are low, medium, and high. Legacy xhigh configs remain valid and are treated as high."
|
|
52
54
|
},
|
|
53
55
|
"logging": {
|
|
54
56
|
"type": "boolean"
|
package/package.json
CHANGED