@threadbase-sh/streamer 1.15.1 → 1.15.2

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/index.js CHANGED
@@ -5410,20 +5410,29 @@ var StreamerServer = class {
5410
5410
  cleanup();
5411
5411
  return;
5412
5412
  }
5413
- if (!existsSync6(filePath)) return;
5413
+ let resolvedFilePath = existsSync6(filePath) ? filePath : null;
5414
+ if (!resolvedFilePath && existsSync6(projectsDir)) {
5415
+ try {
5416
+ const now = Date.now();
5417
+ const recent = readdirSync3(projectsDir).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, mtime: statSync5(join12(projectsDir, f)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).sort((a, b) => b.mtime - a.mtime)[0];
5418
+ if (recent) resolvedFilePath = join12(projectsDir, recent.f);
5419
+ } catch {
5420
+ }
5421
+ }
5422
+ if (!resolvedFilePath) return;
5414
5423
  cleanup();
5415
- this.sessionFileMap.set(sessionId, filePath);
5416
- this.fileWatcher.watch(filePath);
5424
+ this.sessionFileMap.set(sessionId, resolvedFilePath);
5425
+ this.fileWatcher.watch(resolvedFilePath);
5417
5426
  if (this.scannerReady) {
5418
5427
  this.scannerStale = true;
5419
5428
  } else {
5420
5429
  this.scanner = null;
5421
5430
  }
5422
- this.linkSessionToProject(sessionId, projectPath, filePath);
5431
+ this.linkSessionToProject(sessionId, projectPath, resolvedFilePath);
5423
5432
  this.cache?.markAsStreamer(sessionId);
5424
5433
  this.log.info(
5425
5434
  `[startFresh] wired JSONL for ${sessionId}`,
5426
- { event: "session.jsonl_wired", sessionId, filePath },
5435
+ { event: "session.jsonl_wired", sessionId, filePath: resolvedFilePath },
5427
5436
  "pino"
5428
5437
  );
5429
5438
  };