@threadbase-sh/streamer 1.15.1 → 1.15.3

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.cjs CHANGED
@@ -139407,20 +139407,39 @@ var StreamerServer = class {
139407
139407
  cleanup();
139408
139408
  return;
139409
139409
  }
139410
- if (!(0, import_fs14.existsSync)(filePath)) return;
139410
+ let resolvedFilePath = (0, import_fs14.existsSync)(filePath) ? filePath : null;
139411
+ if (!resolvedFilePath && (0, import_fs14.existsSync)(projectsDir)) {
139412
+ try {
139413
+ const now = Date.now();
139414
+ const recent = (0, import_fs14.readdirSync)(projectsDir).filter((f2) => f2.endsWith(".jsonl")).map((f2) => ({ f: f2, mtime: (0, import_fs14.statSync)((0, import_path14.join)(projectsDir, f2)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).sort((a, b2) => b2.mtime - a.mtime)[0];
139415
+ if (recent) resolvedFilePath = (0, import_path14.join)(projectsDir, recent.f);
139416
+ } catch {
139417
+ }
139418
+ }
139419
+ if (!resolvedFilePath) return;
139411
139420
  cleanup();
139412
- this.sessionFileMap.set(sessionId, filePath);
139413
- this.fileWatcher.watch(filePath);
139421
+ this.sessionFileMap.set(sessionId, resolvedFilePath);
139422
+ this.fileWatcher.watch(resolvedFilePath);
139423
+ try {
139424
+ const existing = (0, import_fs14.readFileSync)(resolvedFilePath, "utf8").split("\n").filter(Boolean);
139425
+ if (existing.length > 0) {
139426
+ this.wsHub.broadcast({ type: "conversation_events", sessionId, lines: existing });
139427
+ for (const line of existing) {
139428
+ this.wsHub.broadcast({ type: "conversation_event", sessionId, line });
139429
+ }
139430
+ }
139431
+ } catch {
139432
+ }
139414
139433
  if (this.scannerReady) {
139415
139434
  this.scannerStale = true;
139416
139435
  } else {
139417
139436
  this.scanner = null;
139418
139437
  }
139419
- this.linkSessionToProject(sessionId, projectPath, filePath);
139438
+ this.linkSessionToProject(sessionId, projectPath, resolvedFilePath);
139420
139439
  this.cache?.markAsStreamer(sessionId);
139421
139440
  this.log.info(
139422
139441
  `[startFresh] wired JSONL for ${sessionId}`,
139423
- { event: "session.jsonl_wired", sessionId, filePath },
139442
+ { event: "session.jsonl_wired", sessionId, filePath: resolvedFilePath },
139424
139443
  "pino"
139425
139444
  );
139426
139445
  };