engine7 7.1.13 → 7.1.14

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/dist/cli.mjs +29 -6
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -114,10 +114,10 @@ function collectAllFiles(dir) {
114
114
  }
115
115
  return files;
116
116
  }
117
- function collectRecentSessions(agentsDir, days = 7) {
117
+ function collectRecentSessions(agentsDir, _days = 7) {
118
118
  const files = [];
119
119
  if (!fs.existsSync(agentsDir)) return files;
120
- const cutoff = Date.now() - days * 24 * 60 * 60 * 1e3;
120
+ const sessionGroups = /* @__PURE__ */ new Map();
121
121
  function scanSessionsDir(dir) {
122
122
  try {
123
123
  const entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -125,17 +125,40 @@ function collectRecentSessions(agentsDir, days = 7) {
125
125
  const fullPath = path.join(dir, entry.name);
126
126
  if (entry.isDirectory()) {
127
127
  scanSessionsDir(fullPath);
128
- } else if (entry.name.endsWith(".jsonl") || entry.name.match(/\.jsonl\.(archived|compaction)\./)) {
129
- const stat = fs.statSync(fullPath);
130
- if (stat.mtimeMs > cutoff) files.push(fullPath);
131
- } else if (entry.name === "platform-map.json" || entry.name === "session-index.json") {
128
+ continue;
129
+ }
130
+ if (entry.name === "platform-map.json" || entry.name === "session-index.json") {
132
131
  files.push(fullPath);
132
+ continue;
133
+ }
134
+ let sessionKey = null;
135
+ if (entry.name.endsWith(".jsonl")) {
136
+ sessionKey = entry.name.slice(0, -6);
137
+ } else {
138
+ const m = entry.name.match(/^(.+)\.jsonl\.(archived|compaction)\./);
139
+ if (m) sessionKey = m[1];
140
+ }
141
+ if (!sessionKey) continue;
142
+ if (!sessionGroups.has(sessionKey)) {
143
+ sessionGroups.set(sessionKey, { archived: [] });
144
+ }
145
+ const group = sessionGroups.get(sessionKey);
146
+ if (entry.name.endsWith(".jsonl")) {
147
+ group.jsonl = fullPath;
148
+ } else {
149
+ const stat = fs.statSync(fullPath);
150
+ group.archived.push({ file: fullPath, mtime: stat.mtimeMs });
133
151
  }
134
152
  }
135
153
  } catch {
136
154
  }
137
155
  }
138
156
  scanSessionsDir(agentsDir);
157
+ for (const [, group] of sessionGroups) {
158
+ if (group.jsonl) files.push(group.jsonl);
159
+ group.archived.sort((a, b) => b.mtime - a.mtime);
160
+ if (group.archived.length > 0) files.push(group.archived[0].file);
161
+ }
139
162
  return files;
140
163
  }
141
164
  async function doExport(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.13",
3
+ "version": "7.1.14",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — Self-hosted AI agent engine",
6
6
  "main": "dist/main.mjs",