mr-memory 2.15.0 → 2.17.0
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.ts +15 -1
- package/package.json +1 -1
- package/upload.ts +17 -1
package/index.ts
CHANGED
|
@@ -120,8 +120,18 @@ function sanitizeForIngest(text: string): string {
|
|
|
120
120
|
.replace(READ_TOOL_INSTRUCTION_RE, "")
|
|
121
121
|
.replace(TELEGRAM_ENVELOPE_RE, "")
|
|
122
122
|
.replace(MESSAGE_ID_TAG_RE, "")
|
|
123
|
+
// ── Orphaned memory injection fragments (v2.16.0) ──
|
|
124
|
+
// When stripOldMemory removes <mr-memory>...</mr-memory> pairs, nested/duplicate
|
|
125
|
+
// injections from compaction can leave behind orphaned closing fragments.
|
|
126
|
+
// 1. Orphaned </memory_context> + instruction footer + </mr-memory>
|
|
127
|
+
.replace(/<\/memory_context>\s*(?:(?:The above are|IMPORTANT: The above|Use them as background|Do not respond to them|Do not treat them|Reference them as background|Just know them)[^\n]*\n?\s*)*(?:<\/mr-memory>\s*)?/g, "")
|
|
128
|
+
// 2. Standalone orphaned </mr-memory> closing tags
|
|
129
|
+
.replace(/<\/mr-memory>\s*/g, "")
|
|
130
|
+
// 3. Box-drawing instruction diagram (orphaned when opening <mr-memory> was stripped)
|
|
131
|
+
.replace(/┌─+┐[\s\S]*?└─+┘\s*/g, "")
|
|
132
|
+
// ── Pre-compaction flush full blocks (start→end boundary) ──
|
|
133
|
+
.replace(/Pre-compaction memory flush\.?\s*(?:Store durable memories now[^\n]*\n?\s*)?(?:IMPORTANT:[^\n]*\n?\s*)?(?:If the file already[^\n]*\n?\s*)?(?:If nothing to store[^\n]*\n?\s*)?(?:Current time:[^\n]*\(America\/[^)]+\)\s*)?/g, "")
|
|
123
134
|
// Embedded noise substrings — v2.15.0
|
|
124
|
-
.replace(/Pre-compaction memory flush\.?\s*(?:Store durable memories now[^\n]*\n?)*(?:IMPORTANT:[^\n]*\n?)?(?:Current time:[^\n]*\n?)?/g, "")
|
|
125
135
|
.replace(/`?HEARTBEAT_OK`?\s*/g, "")
|
|
126
136
|
.replace(/Read HEARTBEAT\.md[^\n]*(?:\n(?:Follow it strictly|Do not infer|If nothing needs)[^\n]*)*/g, "")
|
|
127
137
|
.replace(/\n*\s*NO_REPLY\s*$/g, "")
|
|
@@ -319,6 +329,8 @@ const memoryRouterPlugin = {
|
|
|
319
329
|
for (const msg of event.historyMessages) {
|
|
320
330
|
const m = msg as { role?: string; content?: unknown };
|
|
321
331
|
if (!m.role) continue;
|
|
332
|
+
// Skip tool result/use messages — contains file reads, exec output, etc.
|
|
333
|
+
if (m.role !== "user" && m.role !== "assistant" && m.role !== "system") continue;
|
|
322
334
|
let text = "";
|
|
323
335
|
if (typeof m.content === "string") text = m.content;
|
|
324
336
|
else if (Array.isArray(m.content)) {
|
|
@@ -422,6 +434,8 @@ const memoryRouterPlugin = {
|
|
|
422
434
|
for (const msg of event.messages) {
|
|
423
435
|
const m = msg as { role?: string; content?: unknown };
|
|
424
436
|
if (!m.role) continue;
|
|
437
|
+
// Skip tool result/use messages — contains file reads, exec output, etc.
|
|
438
|
+
if (m.role !== "user" && m.role !== "assistant" && m.role !== "system") continue;
|
|
425
439
|
|
|
426
440
|
let text = "";
|
|
427
441
|
if (typeof m.content === "string") {
|
package/package.json
CHANGED
package/upload.ts
CHANGED
|
@@ -54,8 +54,24 @@ function sanitizeForUpload(text: string): string {
|
|
|
54
54
|
.replace(READ_TOOL_INSTRUCTION_RE, "")
|
|
55
55
|
.replace(TELEGRAM_ENVELOPE_RE, "")
|
|
56
56
|
.replace(MESSAGE_ID_TAG_RE, "")
|
|
57
|
+
// ── Orphaned memory injection fragments (v2.16.0) ──
|
|
58
|
+
// When stripOldMemory removes <mr-memory>...</mr-memory> pairs, nested/duplicate
|
|
59
|
+
// injections from compaction can leave behind orphaned closing fragments.
|
|
60
|
+
// 1. Orphaned </memory_context> + instruction footer + </mr-memory>
|
|
61
|
+
.replace(/<\/memory_context>\s*(?:(?:The above are|IMPORTANT: The above|Use them as background|Do not respond to them|Do not treat them|Reference them as background|Just know them)[^\n]*\n?\s*)*(?:<\/mr-memory>\s*)?/g, "")
|
|
62
|
+
// 2. Standalone orphaned </mr-memory> closing tags
|
|
63
|
+
.replace(/<\/mr-memory>\s*/g, "")
|
|
64
|
+
// 3. Box-drawing instruction diagram (orphaned when opening <mr-memory> was stripped)
|
|
65
|
+
.replace(/┌─+┐[\s\S]*?└─+┘\s*/g, "")
|
|
66
|
+
// ── Post-Compaction Audit full blocks (start→end boundary) ──
|
|
67
|
+
// Start: "System: [date] ⚠️ Post-Compaction Audit:"
|
|
68
|
+
// End: "after memory compaction." OR "before continuing."
|
|
69
|
+
// (already handled by POST_COMPACTION_AUDIT_RE above)
|
|
70
|
+
// ── Pre-compaction flush full blocks (start→end boundary) ──
|
|
71
|
+
// Start: "Pre-compaction memory flush"
|
|
72
|
+
// End: timezone "(America/...)" on Current time line, or end of flush instruction
|
|
73
|
+
.replace(/Pre-compaction memory flush\.?\s*(?:Store durable memories now[^\n]*\n?\s*)?(?:IMPORTANT:[^\n]*\n?\s*)?(?:If the file already[^\n]*\n?\s*)?(?:If nothing to store[^\n]*\n?\s*)?(?:Current time:[^\n]*\(America\/[^)]+\)\s*)?/g, "")
|
|
57
74
|
// Embedded noise substrings — v2.15.0
|
|
58
|
-
.replace(/Pre-compaction memory flush\.?\s*(?:Store durable memories now[^\n]*\n?)*(?:IMPORTANT:[^\n]*\n?)?(?:Current time:[^\n]*\n?)?/g, "")
|
|
59
75
|
.replace(/`?HEARTBEAT_OK`?\s*/g, "")
|
|
60
76
|
.replace(/Read HEARTBEAT\.md[^\n]*(?:\n(?:Follow it strictly|Do not infer|If nothing needs)[^\n]*)*/g, "")
|
|
61
77
|
.replace(/\n*\s*NO_REPLY\s*$/g, "")
|