mr-memory 2.9.4 → 2.9.6

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.
Files changed (2) hide show
  1. package/index.ts +18 -3
  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.
@@ -235,7 +242,11 @@ const memoryRouterPlugin = {
235
242
  log(
236
243
  `memoryrouter: injected ${data.memories_found || 0} memories (${data.memory_tokens || 0} tokens)`,
237
244
  );
238
- return { prependContext: wrapForInjection(data.context) };
245
+ // Return both fields for forward/backward compat:
246
+ // - Old OpenClaw: ignores appendSystemPrompt, uses prependContext
247
+ // - New OpenClaw (PR #25866): same content → uses appendSystemPrompt only
248
+ const wrapped = wrapForInjection(data.context);
249
+ return { appendSystemPrompt: wrapped, prependContext: wrapped };
239
250
  }
240
251
  } catch {
241
252
  // Silent fail on tool iterations — don't block the agent
@@ -337,7 +348,11 @@ const memoryRouterPlugin = {
337
348
  log(
338
349
  `memoryrouter: injected ${data.memories_found || 0} memories (${data.memory_tokens || 0} tokens)`,
339
350
  );
340
- return { prependContext: wrapForInjection(data.context) };
351
+ // Return both fields for forward/backward compat:
352
+ // - Old OpenClaw: ignores appendSystemPrompt, uses prependContext
353
+ // - New OpenClaw (PR #25866): same content → uses appendSystemPrompt only
354
+ const wrapped = wrapForInjection(data.context);
355
+ return { appendSystemPrompt: wrapped, prependContext: wrapped };
341
356
  }
342
357
  } catch (err) {
343
358
  log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-memory",
3
- "version": "2.9.4",
3
+ "version": "2.9.6",
4
4
  "description": "MemoryRouter persistent memory plugin for OpenClaw — your AI remembers every conversation",
5
5
  "type": "module",
6
6
  "files": [