mr-memory 2.4.0 → 2.5.0
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 +10 -14
- 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:
|
|
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:
|
|
315
|
+
return { prependContext: data.context };
|
|
323
316
|
}
|
|
324
317
|
} catch (err) {
|
|
325
318
|
api.logger.warn?.(
|
|
@@ -385,8 +378,8 @@ const memoryRouterPlugin = {
|
|
|
385
378
|
|
|
386
379
|
if (toStore.length === 0) return;
|
|
387
380
|
|
|
388
|
-
// Fire
|
|
389
|
-
fetch(`${endpoint}/v1/memory/ingest`, {
|
|
381
|
+
// Fire-and-forget: don't block agent completion on memory ingestion.
|
|
382
|
+
void fetch(`${endpoint}/v1/memory/ingest`, {
|
|
390
383
|
method: "POST",
|
|
391
384
|
headers: {
|
|
392
385
|
"Content-Type": "application/json",
|
|
@@ -395,10 +388,13 @@ const memoryRouterPlugin = {
|
|
|
395
388
|
body: JSON.stringify({
|
|
396
389
|
messages: toStore,
|
|
397
390
|
session_id: ctx.sessionKey,
|
|
391
|
+
model: "unknown",
|
|
398
392
|
}),
|
|
399
393
|
}).then(async (res) => {
|
|
400
394
|
if (!res.ok) {
|
|
401
|
-
|
|
395
|
+
const details = await res.text().catch(() => "");
|
|
396
|
+
const suffix = details ? ` — ${details.slice(0, 200)}` : "";
|
|
397
|
+
api.logger.warn?.(`memoryrouter: ingest failed (${res.status})${suffix}`);
|
|
402
398
|
}
|
|
403
399
|
}).catch((err) => {
|
|
404
400
|
api.logger.warn?.(
|