mr-memory 2.9.7 → 2.9.8
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 +9 -2
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -15,10 +15,17 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
|
15
15
|
|
|
16
16
|
const DEFAULT_ENDPOINT = "https://api.memoryrouter.ai";
|
|
17
17
|
|
|
18
|
+
/** Strip media-attached references so OpenClaw's image detection doesn't
|
|
19
|
+
* load old screenshots/photos from file paths embedded in memories. */
|
|
20
|
+
const MEDIA_ATTACHED_RE = /\[media attached:\s*[^\]]*\]/gi;
|
|
21
|
+
function stripMediaReferences(text: string): string {
|
|
22
|
+
return text.replace(MEDIA_ATTACHED_RE, "[media reference removed]");
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
/** Wrap raw memory context in XML tags with a strong instruction */
|
|
19
26
|
/** Wrap API response in extraction markers so we can strip it next turn. */
|
|
20
27
|
function wrapForInjection(context: string): string {
|
|
21
|
-
return `<mr-memory>\n${context}\n</mr-memory>`;
|
|
28
|
+
return `<mr-memory>\n${stripMediaReferences(context)}\n</mr-memory>`;
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
/** Strip previous memory injections from message text to prevent stacking.
|
|
@@ -236,7 +243,7 @@ const memoryRouterPlugin = {
|
|
|
236
243
|
`memoryrouter: injected ${data.memories_found || 0} memories (${data.memory_tokens || 0} tokens)`,
|
|
237
244
|
);
|
|
238
245
|
const wrapped = wrapForInjection(data.context);
|
|
239
|
-
return {
|
|
246
|
+
return { prependContext: wrapped };
|
|
240
247
|
}
|
|
241
248
|
} catch {
|
|
242
249
|
// Silent fail on tool iterations — don't block the agent
|