@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.cjs
CHANGED
|
@@ -5104,28 +5104,37 @@ var StreamerServer = class {
|
|
|
5104
5104
|
projectName: body.projectName,
|
|
5105
5105
|
branch: body.branch
|
|
5106
5106
|
});
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
session.
|
|
5120
|
-
session.
|
|
5107
|
+
this.sessionStore.addManaged(session);
|
|
5108
|
+
void this.watchConversationFile(sessionId);
|
|
5109
|
+
const resp = this.sessionStore.get(session.id, this.ptyAttachedIds());
|
|
5110
|
+
this.broadcastOrUnicastSessionList(req);
|
|
5111
|
+
json(res, 201, resp ?? session);
|
|
5112
|
+
this.enrichResumedSessionAsync(sessionId, projectPath, conv);
|
|
5113
|
+
}
|
|
5114
|
+
enrichResumedSessionAsync(sessionId, projectPath, conv) {
|
|
5115
|
+
try {
|
|
5116
|
+
const session = this.sessionStore.get(sessionId, this.ptyAttachedIds());
|
|
5117
|
+
if (!session) return;
|
|
5118
|
+
if (conv) {
|
|
5119
|
+
session.sessionName = conv.sessionName ?? void 0;
|
|
5120
|
+
session.messageCount = conv.messageCount ?? 0;
|
|
5121
|
+
session.account = conv.account ?? void 0;
|
|
5122
|
+
session.filePath = conv.filePath ?? void 0;
|
|
5121
5123
|
}
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5124
|
+
if (!this.cache || !this.projectsRepo || !this.conversationsRepo) return;
|
|
5125
|
+
const cached2 = this.cache.getMetaById(sessionId);
|
|
5126
|
+
if (cached2) {
|
|
5127
|
+
session.model = cached2.model ?? void 0;
|
|
5128
|
+
session.preview = cached2.preview ?? void 0;
|
|
5129
|
+
const first = cached2.firstMessage ? JSON.parse(cached2.firstMessage) : null;
|
|
5130
|
+
const last = cached2.lastMessage ? JSON.parse(cached2.lastMessage) : null;
|
|
5131
|
+
session.firstMessageText = first?.text ?? void 0;
|
|
5132
|
+
session.firstMessageAt = first?.timestamp ? new Date(first.timestamp).toISOString() : void 0;
|
|
5133
|
+
session.lastMessageText = last?.text ?? void 0;
|
|
5134
|
+
session.lastMessageAt = last?.timestamp ? new Date(last.timestamp).toISOString() : void 0;
|
|
5135
|
+
}
|
|
5136
|
+
let resolvedProjectId = cached2?.projectId ?? null;
|
|
5137
|
+
if (!resolvedProjectId) {
|
|
5129
5138
|
const project = this.projectsRepo.upsertProjectByPath(projectPath);
|
|
5130
5139
|
resolvedProjectId = project.id;
|
|
5131
5140
|
this.conversationsRepo.updateConversationProjectId({
|
|
@@ -5137,12 +5146,9 @@ var StreamerServer = class {
|
|
|
5137
5146
|
session.projectId = resolvedProjectId;
|
|
5138
5147
|
session.resumedFromConversationId = sessionId;
|
|
5139
5148
|
}
|
|
5149
|
+
} catch (err) {
|
|
5150
|
+
console.error(`[enrichResumedSessionAsync] ${sessionId}:`, err);
|
|
5140
5151
|
}
|
|
5141
|
-
this.sessionStore.addManaged(session);
|
|
5142
|
-
void this.watchConversationFile(sessionId);
|
|
5143
|
-
const resp = this.sessionStore.get(session.id, this.ptyAttachedIds());
|
|
5144
|
-
this.broadcastOrUnicastSessionList(req);
|
|
5145
|
-
json(res, 201, resp ?? session);
|
|
5146
5152
|
}
|
|
5147
5153
|
async handleSendInput(sessionId, req, res) {
|
|
5148
5154
|
if (this.agentConfig.enabled) {
|
|
@@ -5445,20 +5451,29 @@ var StreamerServer = class {
|
|
|
5445
5451
|
cleanup();
|
|
5446
5452
|
return;
|
|
5447
5453
|
}
|
|
5448
|
-
|
|
5454
|
+
let resolvedFilePath = (0, import_fs11.existsSync)(filePath) ? filePath : null;
|
|
5455
|
+
if (!resolvedFilePath && (0, import_fs11.existsSync)(projectsDir)) {
|
|
5456
|
+
try {
|
|
5457
|
+
const now = Date.now();
|
|
5458
|
+
const recent = (0, import_fs11.readdirSync)(projectsDir).filter((f) => f.endsWith(".jsonl")).map((f) => ({ f, mtime: (0, import_fs11.statSync)((0, import_path11.join)(projectsDir, f)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).sort((a, b) => b.mtime - a.mtime)[0];
|
|
5459
|
+
if (recent) resolvedFilePath = (0, import_path11.join)(projectsDir, recent.f);
|
|
5460
|
+
} catch {
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
if (!resolvedFilePath) return;
|
|
5449
5464
|
cleanup();
|
|
5450
|
-
this.sessionFileMap.set(sessionId,
|
|
5451
|
-
this.fileWatcher.watch(
|
|
5465
|
+
this.sessionFileMap.set(sessionId, resolvedFilePath);
|
|
5466
|
+
this.fileWatcher.watch(resolvedFilePath);
|
|
5452
5467
|
if (this.scannerReady) {
|
|
5453
5468
|
this.scannerStale = true;
|
|
5454
5469
|
} else {
|
|
5455
5470
|
this.scanner = null;
|
|
5456
5471
|
}
|
|
5457
|
-
this.linkSessionToProject(sessionId, projectPath,
|
|
5472
|
+
this.linkSessionToProject(sessionId, projectPath, resolvedFilePath);
|
|
5458
5473
|
this.cache?.markAsStreamer(sessionId);
|
|
5459
5474
|
this.log.info(
|
|
5460
5475
|
`[startFresh] wired JSONL for ${sessionId}`,
|
|
5461
|
-
{ event: "session.jsonl_wired", sessionId, filePath },
|
|
5476
|
+
{ event: "session.jsonl_wired", sessionId, filePath: resolvedFilePath },
|
|
5462
5477
|
"pino"
|
|
5463
5478
|
);
|
|
5464
5479
|
};
|