mr-memory 2.9.6 → 2.9.7
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 +3 -16
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -15,17 +15,10 @@ 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
|
-
|
|
25
18
|
/** Wrap raw memory context in XML tags with a strong instruction */
|
|
26
19
|
/** Wrap API response in extraction markers so we can strip it next turn. */
|
|
27
20
|
function wrapForInjection(context: string): string {
|
|
28
|
-
return `<mr-memory>\n${
|
|
21
|
+
return `<mr-memory>\n${context}\n</mr-memory>`;
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
/** Strip previous memory injections from message text to prevent stacking.
|
|
@@ -242,11 +235,8 @@ const memoryRouterPlugin = {
|
|
|
242
235
|
log(
|
|
243
236
|
`memoryrouter: injected ${data.memories_found || 0} memories (${data.memory_tokens || 0} tokens)`,
|
|
244
237
|
);
|
|
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
238
|
const wrapped = wrapForInjection(data.context);
|
|
249
|
-
return { appendSystemPrompt: wrapped
|
|
239
|
+
return { appendSystemPrompt: wrapped };
|
|
250
240
|
}
|
|
251
241
|
} catch {
|
|
252
242
|
// Silent fail on tool iterations — don't block the agent
|
|
@@ -348,11 +338,8 @@ const memoryRouterPlugin = {
|
|
|
348
338
|
log(
|
|
349
339
|
`memoryrouter: injected ${data.memories_found || 0} memories (${data.memory_tokens || 0} tokens)`,
|
|
350
340
|
);
|
|
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
341
|
const wrapped = wrapForInjection(data.context);
|
|
355
|
-
return {
|
|
342
|
+
return { prependContext: wrapped };
|
|
356
343
|
}
|
|
357
344
|
} catch (err) {
|
|
358
345
|
log(
|