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.
- package/package.json +1 -1
- package/upload.ts +18 -3
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
|
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;
|