engine7 7.1.18 → 7.1.19

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/dist/cli.mjs CHANGED
@@ -115,11 +115,19 @@ function collectAllFiles(dir) {
115
115
  }
116
116
  return files;
117
117
  }
118
- function readMainSessionId(platformMapPath) {
118
+ function readMainEngineUuid(agentsDir) {
119
119
  try {
120
- if (!fs.existsSync(platformMapPath)) return null;
121
- const map = JSON.parse(fs.readFileSync(platformMapPath, "utf-8"));
122
- return map["scope:main"] || null;
120
+ const platformMapPath = path.join(agentsDir, "main", "sessions", "platform-map.json");
121
+ const indexMapPath = path.join(agentsDir, "main", "sessions", "session-index.json");
122
+ if (!fs.existsSync(platformMapPath) || !fs.existsSync(indexMapPath)) return null;
123
+ const platformMap = JSON.parse(fs.readFileSync(platformMapPath, "utf-8"));
124
+ const mainPlatformId = platformMap["scope:main"] || platformMap["main"];
125
+ if (!mainPlatformId) return null;
126
+ const indexMap = JSON.parse(fs.readFileSync(indexMapPath, "utf-8"));
127
+ const entry = indexMap[mainPlatformId];
128
+ if (!entry || !entry.file) return null;
129
+ const basename3 = path.basename(entry.file).replace(/\.jsonl$/, "");
130
+ return basename3;
123
131
  } catch {
124
132
  return null;
125
133
  }
@@ -164,9 +172,9 @@ function collectRecentSessions(agentsDir, _days = 7) {
164
172
  }
165
173
  }
166
174
  scanSessionsDir(agentsDir);
167
- const mainSessionId = readMainSessionId(path.join(agentsDir, "main", "sessions", "platform-map.json"));
175
+ const mainEngineUuid = readMainEngineUuid(agentsDir);
168
176
  for (const [sessionKey, group] of sessionGroups) {
169
- if (!mainSessionId || !sessionKey.includes(mainSessionId)) continue;
177
+ if (!mainEngineUuid || !sessionKey.startsWith(mainEngineUuid)) continue;
170
178
  if (group.jsonl) files.push(group.jsonl);
171
179
  group.archived.sort((a, b) => b.mtime - a.mtime);
172
180
  if (group.archived.length > 0) files.push(group.archived[0].file);
@@ -233,8 +241,13 @@ async function doExport(opts) {
233
241
  const relPath = path.relative(stateDir, srcFile);
234
242
  const destFile = path.join(stagingDir, relPath);
235
243
  fs.mkdirSync(path.dirname(destFile), { recursive: true });
236
- const content = fs.readFileSync(srcFile, "utf-8");
237
- fs.writeFileSync(destFile, sanitizeContent(content, dirs));
244
+ let content = fs.readFileSync(srcFile, "utf-8");
245
+ content = sanitizeContent(content, dirs);
246
+ const baseName = path.basename(srcFile);
247
+ if (baseName === "session-index.json" || baseName === "platform-map.json") {
248
+ content = content.split("\\\\").join("/");
249
+ }
250
+ fs.writeFileSync(destFile, content);
238
251
  fileCount++;
239
252
  totalSize += fs.statSync(srcFile).size;
240
253
  }