@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 +24 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +24 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1189,7 +1189,14 @@ import {
|
|
|
1189
1189
|
ConversationScanner,
|
|
1190
1190
|
search
|
|
1191
1191
|
} from "@threadbase-sh/scanner";
|
|
1192
|
-
import {
|
|
1192
|
+
import {
|
|
1193
|
+
createReadStream,
|
|
1194
|
+
existsSync as existsSync6,
|
|
1195
|
+
watch as fsWatch,
|
|
1196
|
+
readdirSync as readdirSync3,
|
|
1197
|
+
readFileSync as readFileSync6,
|
|
1198
|
+
statSync as statSync5
|
|
1199
|
+
} from "fs";
|
|
1193
1200
|
import { realpath as realpath2 } from "fs/promises";
|
|
1194
1201
|
import { createServer } from "http";
|
|
1195
1202
|
import { homedir as homedir5 } from "os";
|
|
@@ -5410,20 +5417,39 @@ var StreamerServer = class {
|
|
|
5410
5417
|
cleanup();
|
|
5411
5418
|
return;
|
|
5412
5419
|
}
|
|
5413
|
-
|
|
5420
|
+
let resolvedFilePath = existsSync6(filePath) ? filePath : null;
|
|
5421
|
+
if (!resolvedFilePath && existsSync6(projectsDir)) {
|
|
5422
|
+
try {
|
|
5423
|
+
const now = Date.now();
|
|
5424
|
+
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];
|
|
5425
|
+
if (recent) resolvedFilePath = join12(projectsDir, recent.f);
|
|
5426
|
+
} catch {
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
if (!resolvedFilePath) return;
|
|
5414
5430
|
cleanup();
|
|
5415
|
-
this.sessionFileMap.set(sessionId,
|
|
5416
|
-
this.fileWatcher.watch(
|
|
5431
|
+
this.sessionFileMap.set(sessionId, resolvedFilePath);
|
|
5432
|
+
this.fileWatcher.watch(resolvedFilePath);
|
|
5433
|
+
try {
|
|
5434
|
+
const existing = readFileSync6(resolvedFilePath, "utf8").split("\n").filter(Boolean);
|
|
5435
|
+
if (existing.length > 0) {
|
|
5436
|
+
this.wsHub.broadcast({ type: "conversation_events", sessionId, lines: existing });
|
|
5437
|
+
for (const line of existing) {
|
|
5438
|
+
this.wsHub.broadcast({ type: "conversation_event", sessionId, line });
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
} catch {
|
|
5442
|
+
}
|
|
5417
5443
|
if (this.scannerReady) {
|
|
5418
5444
|
this.scannerStale = true;
|
|
5419
5445
|
} else {
|
|
5420
5446
|
this.scanner = null;
|
|
5421
5447
|
}
|
|
5422
|
-
this.linkSessionToProject(sessionId, projectPath,
|
|
5448
|
+
this.linkSessionToProject(sessionId, projectPath, resolvedFilePath);
|
|
5423
5449
|
this.cache?.markAsStreamer(sessionId);
|
|
5424
5450
|
this.log.info(
|
|
5425
5451
|
`[startFresh] wired JSONL for ${sessionId}`,
|
|
5426
|
-
{ event: "session.jsonl_wired", sessionId, filePath },
|
|
5452
|
+
{ event: "session.jsonl_wired", sessionId, filePath: resolvedFilePath },
|
|
5427
5453
|
"pino"
|
|
5428
5454
|
);
|
|
5429
5455
|
};
|