mr-memory 2.9.10 → 2.9.11

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 +25 -16
  2. 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${stripMediaReferences(context)}\n</mr-memory>`;
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.
@@ -229,7 +222,15 @@ const memoryRouterPlugin = {
229
222
  }),
230
223
  });
231
224
 
232
- if (!res.ok) return;
225
+ if (!res.ok) {
226
+ const errBody = await res.json().catch(() => null) as any;
227
+ if (errBody?.error?.code === "payment_required") {
228
+ api.logger.warn?.(`⚠️ MemoryRouter: Out of credits. Memory is NOT being injected. Add credits at https://app.memoryrouter.ai/settings/billing`);
229
+ } else {
230
+ log(`memoryrouter: prepare failed (${res.status})`);
231
+ }
232
+ return;
233
+ }
233
234
 
234
235
  const data = (await res.json()) as {
235
236
  context?: string;
@@ -330,7 +331,12 @@ const memoryRouterPlugin = {
330
331
  });
331
332
 
332
333
  if (!res.ok) {
333
- log(`memoryrouter: prepare failed (${res.status})`);
334
+ const errBody = await res.json().catch(() => null) as any;
335
+ if (errBody?.error?.code === "payment_required") {
336
+ api.logger.warn?.(`⚠️ MemoryRouter: Out of credits. Memory is NOT being injected. Add credits at https://app.memoryrouter.ai/settings/billing`);
337
+ } else {
338
+ log(`memoryrouter: prepare failed (${res.status})`);
339
+ }
334
340
  return;
335
341
  }
336
342
 
@@ -390,11 +396,11 @@ const memoryRouterPlugin = {
390
396
 
391
397
  const toStore: Array<{ role: string; content: string }> = [];
392
398
 
393
- // Add the user message (strip media refs so image paths don't get stored)
399
+ // Add the user message
394
400
  if (lastUserIdx >= 0) {
395
401
  const userMsg = msgs[lastUserIdx] as { content?: unknown };
396
402
  const userText = extractText(userMsg.content);
397
- if (userText) toStore.push({ role: "user", content: stripMediaReferences(userText) });
403
+ if (userText) toStore.push({ role: "user", content: userText });
398
404
  }
399
405
 
400
406
  // Collect ALL assistant messages after the last user message
@@ -407,8 +413,7 @@ const memoryRouterPlugin = {
407
413
  }
408
414
  }
409
415
  if (assistantParts.length > 0) {
410
- // Strip media refs so image paths don't get stored and re-injected
411
- toStore.push({ role: "assistant", content: stripMediaReferences(assistantParts.join("\n\n")) });
416
+ toStore.push({ role: "assistant", content: assistantParts.join("\n\n") });
412
417
  }
413
418
 
414
419
  if (toStore.length === 0) return;
@@ -429,8 +434,12 @@ const memoryRouterPlugin = {
429
434
  });
430
435
  if (!res.ok) {
431
436
  const details = await res.text().catch(() => "");
432
- const suffix = details ? ` — ${details.slice(0, 200)}` : "";
433
- log(`memoryrouter: ingest failed (${res.status})${suffix}`);
437
+ if (details.includes("payment_required")) {
438
+ api.logger.warn?.(`⚠️ MemoryRouter: Out of credits. Conversations are NOT being stored. Add credits at https://app.memoryrouter.ai/settings/billing`);
439
+ } else {
440
+ const suffix = details ? ` — ${details.slice(0, 200)}` : "";
441
+ log(`memoryrouter: ingest failed (${res.status})${suffix}`);
442
+ }
434
443
  } else {
435
444
  api.logger.debug?.(`memoryrouter: ingest accepted (${toStore.length} messages)`);
436
445
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-memory",
3
- "version": "2.9.10",
3
+ "version": "2.9.11",
4
4
  "description": "MemoryRouter persistent memory plugin for OpenClaw — your AI remembers every conversation",
5
5
  "type": "module",
6
6
  "files": [