mr-memory 2.11.2 → 2.11.4

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/package.json +1 -1
  2. package/upload.ts +18 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-memory",
3
- "version": "2.11.2",
3
+ "version": "2.11.4",
4
4
  "description": "MemoryRouter persistent memory plugin for OpenClaw — your AI remembers every conversation",
5
5
  "type": "module",
6
6
  "files": [
package/upload.ts CHANGED
@@ -123,7 +123,17 @@ async function sessionToJsonl(filePath: string): Promise<MemoryLine[]> {
123
123
  timestamp = Date.now();
124
124
  }
125
125
 
126
- lines.push({ content: text.trim(), role: msg.role, timestamp });
126
+ const trimmedText = text.trim();
127
+
128
+ // Chunk oversized messages to avoid blowing up the embedding service
129
+ if (trimmedText.length > MAX_ITEM_CHARS) {
130
+ const chunks = chunkText(trimmedText, TARGET_CHUNK_CHARS);
131
+ for (const chunk of chunks) {
132
+ lines.push({ content: chunk, role: msg.role, timestamp });
133
+ }
134
+ } else {
135
+ lines.push({ content: trimmedText, role: msg.role, timestamp });
136
+ }
127
137
  } catch {
128
138
  // Skip invalid lines
129
139
  }
@@ -170,7 +180,11 @@ async function discoverBrainFiles(stateDir: string): Promise<string[]> {
170
180
  const sessionsDir = path.join(stateDir, "agents", "main", "sessions");
171
181
  if (await exists(sessionsDir)) {
172
182
  const allSessionFiles = await fs.readdir(sessionsDir);
173
- const sessionFiles = (allSessionFiles as string[]).filter((f) => f.endsWith(".jsonl"));
183
+ // Match both active sessions (.jsonl) and soft-deleted ones (.jsonl.deleted.*)
184
+ // OpenClaw renames old sessions instead of deleting them — the data is still valid
185
+ const sessionFiles = (allSessionFiles as string[]).filter((f) =>
186
+ f.endsWith(".jsonl") || f.includes(".jsonl.deleted.")
187
+ );
174
188
  files.push(...sessionFiles.map((f) => path.join(sessionsDir, f)));
175
189
  }
176
190
 
@@ -260,7 +274,8 @@ export async function runUpload(params: {
260
274
  for (const file of files) {
261
275
  const displayName = path.basename(file);
262
276
  try {
263
- const lines = file.endsWith(".jsonl") ? await sessionToJsonl(file) : await fileToJsonl(file);
277
+ const isSession = file.endsWith(".jsonl") || file.includes(".jsonl.deleted.");
278
+ const lines = isSession ? await sessionToJsonl(file) : await fileToJsonl(file);
264
279
  if (lines.length === 0) {
265
280
  skippedEmpty++;
266
281
  continue;