mr-memory 3.5.1 → 3.6.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 +27 -6
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -246,6 +246,15 @@ function isSystemNoise(text: string): boolean {
|
|
|
246
246
|
return SYSTEM_NOISE_PATTERNS.some(pattern => pattern.test(trimmed));
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
/** Strip cron/system prefixes from prompts, keeping the actual task content.
|
|
250
|
+
* Used for prepare context building — we want the mission text, not the tag. */
|
|
251
|
+
function stripSystemPrefixes(text: string): string {
|
|
252
|
+
return text
|
|
253
|
+
.replace(/^\[cron:[^\]]+\]\s*/i, "")
|
|
254
|
+
.replace(/^A background task "[^"]*" just completed[^\n]*\n*/i, "")
|
|
255
|
+
.trim();
|
|
256
|
+
}
|
|
257
|
+
|
|
249
258
|
/**
|
|
250
259
|
* Detect OpenClaw compaction summary blobs — large user messages containing
|
|
251
260
|
* interleaved [USER] and [ASSISTANT] markers from conversation history dumps.
|
|
@@ -464,8 +473,12 @@ const memoryRouterPlugin = {
|
|
|
464
473
|
}
|
|
465
474
|
}
|
|
466
475
|
const cleanedPrompt = sanitizeForIngest(prompt);
|
|
467
|
-
if (cleanedPrompt
|
|
468
|
-
|
|
476
|
+
if (cleanedPrompt) {
|
|
477
|
+
// Strip cron/system prefixes but keep the task content for memory search
|
|
478
|
+
const taskPrompt = stripSystemPrefixes(cleanedPrompt);
|
|
479
|
+
if (taskPrompt && !isSystemNoise(taskPrompt)) {
|
|
480
|
+
contextPayload.push({ role: "user", content: taskPrompt });
|
|
481
|
+
}
|
|
469
482
|
}
|
|
470
483
|
|
|
471
484
|
|
|
@@ -575,8 +588,12 @@ const memoryRouterPlugin = {
|
|
|
575
588
|
|
|
576
589
|
// Add current user prompt (sanitized)
|
|
577
590
|
const cleanedPrompt = sanitizeForIngest(prompt);
|
|
578
|
-
if (cleanedPrompt
|
|
579
|
-
|
|
591
|
+
if (cleanedPrompt) {
|
|
592
|
+
// Strip cron/system prefixes but keep the task content for memory search
|
|
593
|
+
const taskPrompt = stripSystemPrefixes(cleanedPrompt);
|
|
594
|
+
if (taskPrompt && !isSystemNoise(taskPrompt)) {
|
|
595
|
+
contextPayload.push({ role: "user", content: taskPrompt });
|
|
596
|
+
}
|
|
580
597
|
}
|
|
581
598
|
|
|
582
599
|
// 4. Call /v1/memory/prepare (no session_id — always search core vault)
|
|
@@ -671,8 +688,12 @@ const memoryRouterPlugin = {
|
|
|
671
688
|
if (userText) {
|
|
672
689
|
// Sanitize: strip memory injections, envelope metadata, and system noise
|
|
673
690
|
userText = sanitizeForIngest(stripMediaReferences(userText));
|
|
674
|
-
if (userText
|
|
675
|
-
|
|
691
|
+
if (userText) {
|
|
692
|
+
// Strip cron/system prefixes but keep the task content for storage
|
|
693
|
+
const taskText = stripSystemPrefixes(userText);
|
|
694
|
+
if (taskText && !isSystemNoise(taskText)) {
|
|
695
|
+
toStore.push({ role: "user", content: taskText });
|
|
696
|
+
}
|
|
676
697
|
}
|
|
677
698
|
}
|
|
678
699
|
}
|