mr-memory 2.4.0 → 2.5.1

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 -26
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -28,15 +28,6 @@ type MemoryRouterConfig = {
28
28
  mode?: "relay" | "proxy";
29
29
  };
30
30
 
31
- // ──────────────────────────────────────────────────────
32
- // Memory Context Formatting (matches proxy formatters)
33
- // ──────────────────────────────────────────────────────
34
-
35
- function wrapMemoryContext(context: string): string {
36
- if (!context) return context;
37
- return `<memory_context>\n${context}\n</memory_context>\n\nUse the above context from previous conversations to inform your response. Do not explicitly mention that you're using memory unless directly asked.`;
38
- }
39
-
40
31
  // ──────────────────────────────────────────────────────
41
32
  // Helpers
42
33
  // ──────────────────────────────────────────────────────
@@ -204,6 +195,7 @@ const memoryRouterPlugin = {
204
195
  },
205
196
  body: JSON.stringify({
206
197
  messages: contextPayload,
198
+ session_id: ctx.sessionKey,
207
199
  density,
208
200
 
209
201
  }),
@@ -221,7 +213,7 @@ const memoryRouterPlugin = {
221
213
  api.logger.info?.(
222
214
  `memoryrouter: injected ${data.memories_found || 0} memories on tool iteration (${data.tokens_billed || 0} tokens billed)`,
223
215
  );
224
- return { prependContext: wrapMemoryContext(data.context) };
216
+ return { prependContext: data.context };
225
217
  }
226
218
  } catch {
227
219
  // Silent fail on tool iterations — don't block the agent
@@ -299,6 +291,7 @@ const memoryRouterPlugin = {
299
291
  },
300
292
  body: JSON.stringify({
301
293
  messages: contextPayload,
294
+ session_id: ctx.sessionKey,
302
295
  density,
303
296
 
304
297
  }),
@@ -319,7 +312,7 @@ const memoryRouterPlugin = {
319
312
  api.logger.info?.(
320
313
  `memoryrouter: injected ${data.memories_found || 0} memories (${data.tokens_billed || 0} tokens billed)`,
321
314
  );
322
- return { prependContext: wrapMemoryContext(data.context) };
315
+ return { prependContext: data.context };
323
316
  }
324
317
  } catch (err) {
325
318
  api.logger.warn?.(
@@ -385,26 +378,32 @@ const memoryRouterPlugin = {
385
378
 
386
379
  if (toStore.length === 0) return;
387
380
 
388
- // Fire and forget don't block the response
389
- fetch(`${endpoint}/v1/memory/ingest`, {
390
- method: "POST",
391
- headers: {
392
- "Content-Type": "application/json",
393
- Authorization: `Bearer ${memoryKey}`,
394
- },
395
- body: JSON.stringify({
396
- messages: toStore,
397
- session_id: ctx.sessionKey,
398
- }),
399
- }).then(async (res) => {
381
+ // Await the fetch so OpenClaw's runVoidHook keeps the event loop alive.
382
+ try {
383
+ const res = await fetch(`${endpoint}/v1/memory/ingest`, {
384
+ method: "POST",
385
+ headers: {
386
+ "Content-Type": "application/json",
387
+ Authorization: `Bearer ${memoryKey}`,
388
+ },
389
+ body: JSON.stringify({
390
+ messages: toStore,
391
+ session_id: ctx.sessionKey,
392
+ model: "unknown",
393
+ }),
394
+ });
400
395
  if (!res.ok) {
401
- api.logger.warn?.(`memoryrouter: ingest failed (${res.status})`);
396
+ const details = await res.text().catch(() => "");
397
+ const suffix = details ? ` — ${details.slice(0, 200)}` : "";
398
+ api.logger.warn?.(`memoryrouter: ingest failed (${res.status})${suffix}`);
399
+ } else {
400
+ api.logger.debug?.(`memoryrouter: ingest accepted (${toStore.length} messages)`);
402
401
  }
403
- }).catch((err) => {
402
+ } catch (err) {
404
403
  api.logger.warn?.(
405
404
  `memoryrouter: ingest error — ${err instanceof Error ? err.message : String(err)}`,
406
405
  );
407
- });
406
+ }
408
407
  } catch (err) {
409
408
  api.logger.warn?.(
410
409
  `memoryrouter: agent_end error — ${err instanceof Error ? err.message : String(err)}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-memory",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "MemoryRouter persistent memory plugin for OpenClaw — your AI remembers every conversation",
5
5
  "type": "module",
6
6
  "files": [