@threadbase-sh/streamer 1.15.0 → 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/README.md +15 -1
- package/dist/cli.cjs +95 -79
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +46 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +46 -31
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -5063,28 +5063,37 @@ var StreamerServer = class {
|
|
|
5063
5063
|
projectName: body.projectName,
|
|
5064
5064
|
branch: body.branch
|
|
5065
5065
|
});
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
session.
|
|
5079
|
-
session.
|
|
5066
|
+
this.sessionStore.addManaged(session);
|
|
5067
|
+
void this.watchConversationFile(sessionId);
|
|
5068
|
+
const resp = this.sessionStore.get(session.id, this.ptyAttachedIds());
|
|
5069
|
+
this.broadcastOrUnicastSessionList(req);
|
|
5070
|
+
json(res, 201, resp ?? session);
|
|
5071
|
+
this.enrichResumedSessionAsync(sessionId, projectPath, conv);
|
|
5072
|
+
}
|
|
5073
|
+
enrichResumedSessionAsync(sessionId, projectPath, conv) {
|
|
5074
|
+
try {
|
|
5075
|
+
const session = this.sessionStore.get(sessionId, this.ptyAttachedIds());
|
|
5076
|
+
if (!session) return;
|
|
5077
|
+
if (conv) {
|
|
5078
|
+
session.sessionName = conv.sessionName ?? void 0;
|
|
5079
|
+
session.messageCount = conv.messageCount ?? 0;
|
|
5080
|
+
session.account = conv.account ?? void 0;
|
|
5081
|
+
session.filePath = conv.filePath ?? void 0;
|
|
5080
5082
|
}
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5083
|
+
if (!this.cache || !this.projectsRepo || !this.conversationsRepo) return;
|
|
5084
|
+
const cached2 = this.cache.getMetaById(sessionId);
|
|
5085
|
+
if (cached2) {
|
|
5086
|
+
session.model = cached2.model ?? void 0;
|
|
5087
|
+
session.preview = cached2.preview ?? void 0;
|
|
5088
|
+
const first = cached2.firstMessage ? JSON.parse(cached2.firstMessage) : null;
|
|
5089
|
+
const last = cached2.lastMessage ? JSON.parse(cached2.lastMessage) : null;
|
|
5090
|
+
session.firstMessageText = first?.text ?? void 0;
|
|
5091
|
+
session.firstMessageAt = first?.timestamp ? new Date(first.timestamp).toISOString() : void 0;
|
|
5092
|
+
session.lastMessageText = last?.text ?? void 0;
|
|
5093
|
+
session.lastMessageAt = last?.timestamp ? new Date(last.timestamp).toISOString() : void 0;
|
|
5094
|
+
}
|
|
5095
|
+
let resolvedProjectId = cached2?.projectId ?? null;
|
|
5096
|
+
if (!resolvedProjectId) {
|
|
5088
5097
|
const project = this.projectsRepo.upsertProjectByPath(projectPath);
|
|
5089
5098
|
resolvedProjectId = project.id;
|
|
5090
5099
|
this.conversationsRepo.updateConversationProjectId({
|
|
@@ -5096,12 +5105,9 @@ var StreamerServer = class {
|
|
|
5096
5105
|
session.projectId = resolvedProjectId;
|
|
5097
5106
|
session.resumedFromConversationId = sessionId;
|
|
5098
5107
|
}
|
|
5108
|
+
} catch (err) {
|
|
5109
|
+
console.error(`[enrichResumedSessionAsync] ${sessionId}:`, err);
|
|
5099
5110
|
}
|
|
5100
|
-
this.sessionStore.addManaged(session);
|
|
5101
|
-
void this.watchConversationFile(sessionId);
|
|
5102
|
-
const resp = this.sessionStore.get(session.id, this.ptyAttachedIds());
|
|
5103
|
-
this.broadcastOrUnicastSessionList(req);
|
|
5104
|
-
json(res, 201, resp ?? session);
|
|
5105
5111
|
}
|
|
5106
5112
|
async handleSendInput(sessionId, req, res) {
|
|
5107
5113
|
if (this.agentConfig.enabled) {
|
|
@@ -5404,20 +5410,29 @@ var StreamerServer = class {
|
|
|
5404
5410
|
cleanup();
|
|
5405
5411
|
return;
|
|
5406
5412
|
}
|
|
5407
|
-
|
|
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;
|
|
5408
5423
|
cleanup();
|
|
5409
|
-
this.sessionFileMap.set(sessionId,
|
|
5410
|
-
this.fileWatcher.watch(
|
|
5424
|
+
this.sessionFileMap.set(sessionId, resolvedFilePath);
|
|
5425
|
+
this.fileWatcher.watch(resolvedFilePath);
|
|
5411
5426
|
if (this.scannerReady) {
|
|
5412
5427
|
this.scannerStale = true;
|
|
5413
5428
|
} else {
|
|
5414
5429
|
this.scanner = null;
|
|
5415
5430
|
}
|
|
5416
|
-
this.linkSessionToProject(sessionId, projectPath,
|
|
5431
|
+
this.linkSessionToProject(sessionId, projectPath, resolvedFilePath);
|
|
5417
5432
|
this.cache?.markAsStreamer(sessionId);
|
|
5418
5433
|
this.log.info(
|
|
5419
5434
|
`[startFresh] wired JSONL for ${sessionId}`,
|
|
5420
|
-
{ event: "session.jsonl_wired", sessionId, filePath },
|
|
5435
|
+
{ event: "session.jsonl_wired", sessionId, filePath: resolvedFilePath },
|
|
5421
5436
|
"pino"
|
|
5422
5437
|
);
|
|
5423
5438
|
};
|