engine7 7.1.17 → 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 +22 -8
- package/dist/engine-startup.mjs +915 -561
- package/dist/main.mjs +918 -564
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -38,6 +38,7 @@ function sanitizeContent(content, dirs) {
|
|
|
38
38
|
if (original) {
|
|
39
39
|
result = result.split(original).join(placeholder);
|
|
40
40
|
result = result.split(original.replace(/\//g, "\\")).join(placeholder);
|
|
41
|
+
result = result.split(original.replace(/\//g, "\\\\")).join(placeholder);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
return result;
|
|
@@ -114,11 +115,19 @@ function collectAllFiles(dir) {
|
|
|
114
115
|
}
|
|
115
116
|
return files;
|
|
116
117
|
}
|
|
117
|
-
function
|
|
118
|
+
function readMainEngineUuid(agentsDir) {
|
|
118
119
|
try {
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
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;
|
|
122
131
|
} catch {
|
|
123
132
|
return null;
|
|
124
133
|
}
|
|
@@ -163,9 +172,9 @@ function collectRecentSessions(agentsDir, _days = 7) {
|
|
|
163
172
|
}
|
|
164
173
|
}
|
|
165
174
|
scanSessionsDir(agentsDir);
|
|
166
|
-
const
|
|
175
|
+
const mainEngineUuid = readMainEngineUuid(agentsDir);
|
|
167
176
|
for (const [sessionKey, group] of sessionGroups) {
|
|
168
|
-
if (!
|
|
177
|
+
if (!mainEngineUuid || !sessionKey.startsWith(mainEngineUuid)) continue;
|
|
169
178
|
if (group.jsonl) files.push(group.jsonl);
|
|
170
179
|
group.archived.sort((a, b) => b.mtime - a.mtime);
|
|
171
180
|
if (group.archived.length > 0) files.push(group.archived[0].file);
|
|
@@ -232,8 +241,13 @@ async function doExport(opts) {
|
|
|
232
241
|
const relPath = path.relative(stateDir, srcFile);
|
|
233
242
|
const destFile = path.join(stagingDir, relPath);
|
|
234
243
|
fs.mkdirSync(path.dirname(destFile), { recursive: true });
|
|
235
|
-
|
|
236
|
-
|
|
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);
|
|
237
251
|
fileCount++;
|
|
238
252
|
totalSize += fs.statSync(srcFile).size;
|
|
239
253
|
}
|