mr-memory 2.14.0 → 2.16.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 +33 -1
- package/package.json +1 -1
- package/upload.ts +39 -1
package/index.ts
CHANGED
|
@@ -80,6 +80,16 @@ const SYSTEM_NOISE_PATTERNS = [
|
|
|
80
80
|
/^Please read them now using the Read tool/,
|
|
81
81
|
/^GatewayRestart:\s*\{/,
|
|
82
82
|
/^This ensures your operating protocols are restored/,
|
|
83
|
+
// Cron job prompts — automated system instructions, not human conversation
|
|
84
|
+
/^\[cron:[^\]]+\]/,
|
|
85
|
+
// Sub-agent completion announcements (system-generated)
|
|
86
|
+
/^A background task "[^"]*" just completed/,
|
|
87
|
+
// Sub-agent stats lines
|
|
88
|
+
/^Stats: runtime \d+/,
|
|
89
|
+
// Summarize instruction for sub-agent completions
|
|
90
|
+
/^Summarize this naturally for the user/,
|
|
91
|
+
// Session reset greet prompts
|
|
92
|
+
/^Greet the user in your configured persona/,
|
|
83
93
|
];
|
|
84
94
|
|
|
85
95
|
/** Strip OpenClaw envelope metadata from user messages */
|
|
@@ -109,7 +119,29 @@ function sanitizeForIngest(text: string): string {
|
|
|
109
119
|
.replace(POST_COMPACTION_AUDIT_RE, "")
|
|
110
120
|
.replace(READ_TOOL_INSTRUCTION_RE, "")
|
|
111
121
|
.replace(TELEGRAM_ENVELOPE_RE, "")
|
|
112
|
-
.replace(MESSAGE_ID_TAG_RE, "")
|
|
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, "")
|
|
134
|
+
// Embedded noise substrings — v2.15.0
|
|
135
|
+
.replace(/`?HEARTBEAT_OK`?\s*/g, "")
|
|
136
|
+
.replace(/Read HEARTBEAT\.md[^\n]*(?:\n(?:Follow it strictly|Do not infer|If nothing needs)[^\n]*)*/g, "")
|
|
137
|
+
.replace(/\n*\s*NO_REPLY\s*$/g, "")
|
|
138
|
+
.replace(/You can respond with NO_REPLY[^\n]*\n*/g, "")
|
|
139
|
+
.replace(/If nothing to store,? reply (?:with )?NO_REPLY[^\n]*\n*/g, "")
|
|
140
|
+
.replace(/Store durable memories now[^\n]*\n*/g, "")
|
|
141
|
+
.replace(/This ensures your operating protocols are restored[^\n]*\n*/g, "")
|
|
142
|
+
.replace(/Current time:[^\n]*\n*/g, "")
|
|
143
|
+
.replace(/\bset:\s*\n\s*-\s*WORKFLOW_AUTO\.md[^\n]*\n(?:\s*-\s*memory[^\n]*\n)*/g, "")
|
|
144
|
+
.replace(/Do not mention technical details[^\n]*\n*/g, "");
|
|
113
145
|
// 3. Collapse excessive whitespace from removals
|
|
114
146
|
cleaned = cleaned.replace(/\n{3,}/g, "\n\n").trim();
|
|
115
147
|
return cleaned;
|
package/package.json
CHANGED
package/upload.ts
CHANGED
|
@@ -53,7 +53,35 @@ function sanitizeForUpload(text: string): string {
|
|
|
53
53
|
.replace(POST_COMPACTION_AUDIT_RE, "")
|
|
54
54
|
.replace(READ_TOOL_INSTRUCTION_RE, "")
|
|
55
55
|
.replace(TELEGRAM_ENVELOPE_RE, "")
|
|
56
|
-
.replace(MESSAGE_ID_TAG_RE, "")
|
|
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, "")
|
|
74
|
+
// Embedded noise substrings — v2.15.0
|
|
75
|
+
.replace(/`?HEARTBEAT_OK`?\s*/g, "")
|
|
76
|
+
.replace(/Read HEARTBEAT\.md[^\n]*(?:\n(?:Follow it strictly|Do not infer|If nothing needs)[^\n]*)*/g, "")
|
|
77
|
+
.replace(/\n*\s*NO_REPLY\s*$/g, "")
|
|
78
|
+
.replace(/You can respond with NO_REPLY[^\n]*\n*/g, "")
|
|
79
|
+
.replace(/If nothing to store,? reply (?:with )?NO_REPLY[^\n]*\n*/g, "")
|
|
80
|
+
.replace(/Store durable memories now[^\n]*\n*/g, "")
|
|
81
|
+
.replace(/This ensures your operating protocols are restored[^\n]*\n*/g, "")
|
|
82
|
+
.replace(/Current time:[^\n]*\n*/g, "")
|
|
83
|
+
.replace(/\bset:\s*\n\s*-\s*WORKFLOW_AUTO\.md[^\n]*\n(?:\s*-\s*memory[^\n]*\n)*/g, "")
|
|
84
|
+
.replace(/Do not mention technical details[^\n]*\n*/g, "");
|
|
57
85
|
cleaned = cleaned.replace(/\n{3,}/g, "\n\n").trim();
|
|
58
86
|
return cleaned;
|
|
59
87
|
}
|
|
@@ -76,6 +104,16 @@ const SYSTEM_NOISE_PATTERNS = [
|
|
|
76
104
|
/^Please read them now using the Read tool/,
|
|
77
105
|
/^GatewayRestart:\s*\{/,
|
|
78
106
|
/^This ensures your operating protocols are restored/,
|
|
107
|
+
// Cron job prompts — automated system instructions, not human conversation
|
|
108
|
+
/^\[cron:[^\]]+\]/,
|
|
109
|
+
// Sub-agent completion announcements (system-generated)
|
|
110
|
+
/^A background task "[^"]*" just completed/,
|
|
111
|
+
// Sub-agent stats lines
|
|
112
|
+
/^Stats: runtime \d+/,
|
|
113
|
+
// Summarize instruction for sub-agent completions
|
|
114
|
+
/^Summarize this naturally for the user/,
|
|
115
|
+
// Session reset greet prompts
|
|
116
|
+
/^Greet the user in your configured persona/,
|
|
79
117
|
];
|
|
80
118
|
|
|
81
119
|
function isSystemNoise(text: string): boolean {
|