@threadbase-sh/streamer 1.52.4 → 1.52.5
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 +39 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +39 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13282,6 +13282,7 @@ function autoResumeSkipReason(row, opts) {
|
|
|
13282
13282
|
if (opts.now - row.status_updated_at > AUTO_RESUME_WINDOW_MS) return "too_old";
|
|
13283
13283
|
if (!opts.projectExists(row.project_path)) return "project_missing";
|
|
13284
13284
|
if (resumeIdForRow(row) == null) return "resume_identity_missing";
|
|
13285
|
+
if (!opts.historyExists(row)) return "history_missing";
|
|
13285
13286
|
return null;
|
|
13286
13287
|
}
|
|
13287
13288
|
function planAutoResume(rows, opts) {
|
|
@@ -13543,7 +13544,34 @@ var SessionRegistryBoot = class {
|
|
|
13543
13544
|
/** Resume only the recent sessions the user explicitly allowed us to start at boot. */
|
|
13544
13545
|
async autoResumePreviousSessions(rows) {
|
|
13545
13546
|
if (!this.autoResumeOnBoot) return;
|
|
13546
|
-
const
|
|
13547
|
+
const now = Date.now();
|
|
13548
|
+
const baseOptions = { now, projectExists: import_fs25.existsSync, historyExists: () => true };
|
|
13549
|
+
const historyExists = /* @__PURE__ */ new Map();
|
|
13550
|
+
const preflights = /* @__PURE__ */ new Set();
|
|
13551
|
+
for (const row of rows) {
|
|
13552
|
+
if (autoResumeSkipReason(row, baseOptions) != null) {
|
|
13553
|
+
historyExists.set(row.session_id, false);
|
|
13554
|
+
continue;
|
|
13555
|
+
}
|
|
13556
|
+
while (preflights.size >= AUTO_RESUME_CONCURRENCY) {
|
|
13557
|
+
await Promise.race(preflights);
|
|
13558
|
+
}
|
|
13559
|
+
const preflight = (async () => {
|
|
13560
|
+
try {
|
|
13561
|
+
const target = await this.deps.resolveConversationTarget(row.session_id);
|
|
13562
|
+
historyExists.set(row.session_id, target.ok || target.reason !== "history_file_missing");
|
|
13563
|
+
} catch {
|
|
13564
|
+
historyExists.set(row.session_id, true);
|
|
13565
|
+
}
|
|
13566
|
+
})();
|
|
13567
|
+
preflights.add(preflight);
|
|
13568
|
+
void preflight.then(() => preflights.delete(preflight));
|
|
13569
|
+
}
|
|
13570
|
+
await Promise.all(preflights);
|
|
13571
|
+
const plan = planAutoResume(rows, {
|
|
13572
|
+
...baseOptions,
|
|
13573
|
+
historyExists: (row) => historyExists.get(row.session_id) ?? false
|
|
13574
|
+
});
|
|
13547
13575
|
const skippedBy = {};
|
|
13548
13576
|
for (const { row, reason } of plan.skipped) {
|
|
13549
13577
|
skippedBy[reason] = (skippedBy[reason] ?? 0) + 1;
|
|
@@ -14675,7 +14703,8 @@ var StreamerServer = class {
|
|
|
14675
14703
|
selfPtyEndedAt: this.selfPtyEndedAt,
|
|
14676
14704
|
resumeSession: (opts) => this.sessionHandlers.resumeSession(opts),
|
|
14677
14705
|
watchConversationFile: (sessionId, historyId) => this.sessionWatchers.watchConversationFile(sessionId, historyId),
|
|
14678
|
-
broadcastSessionList: () => this.wsHub.broadcast(this.sessionListPayload())
|
|
14706
|
+
broadcastSessionList: () => this.wsHub.broadcast(this.sessionListPayload()),
|
|
14707
|
+
resolveConversationTarget: (sessionId) => this.resolveConversationTarget(sessionId)
|
|
14679
14708
|
});
|
|
14680
14709
|
this.includeAgents = parseIncludeAgentsEnv(process.env.THREADBASE_INCLUDE_AGENTS);
|
|
14681
14710
|
this.agentEntrypoints = parseAgentEntrypointsEnv(process.env.THREADBASE_AGENT_ENTRYPOINTS);
|
|
@@ -15884,13 +15913,17 @@ var StreamerServer = class {
|
|
|
15884
15913
|
conv = await this.conversationHandlers.findConversationByUuid(boundId);
|
|
15885
15914
|
}
|
|
15886
15915
|
}
|
|
15916
|
+
const cachedConvMeta = this.cache?.getMetaById(historyId);
|
|
15917
|
+
const cachedPath = cachedConvMeta?.filePath ? toNativeFilePath(cachedConvMeta.filePath) : null;
|
|
15918
|
+
const cachedCodexPath = (registryProvider === CODEX_CLI_PROVIDER || cachedConvMeta?.provider === CODEX_CLI_PROVIDER) && cachedPath != null && (0, import_fs27.existsSync)(cachedPath) ? cachedPath : null;
|
|
15887
15919
|
const jsonlCwd = jsonlPath ? await this.conversationHandlers.readCwdFromJsonl(jsonlPath) : null;
|
|
15888
|
-
const projectPath = jsonlCwd ?? conv?.projectPath;
|
|
15920
|
+
const projectPath = jsonlCwd ?? conv?.projectPath ?? (cachedCodexPath ? cachedConvMeta?.projectPath : null);
|
|
15889
15921
|
if (!projectPath) {
|
|
15890
|
-
if (!conv && !jsonlPath)
|
|
15922
|
+
if (!conv && !jsonlPath && !cachedCodexPath) {
|
|
15923
|
+
return { ok: false, reason: "history_file_missing" };
|
|
15924
|
+
}
|
|
15891
15925
|
return { ok: false, reason: "no_project_path" };
|
|
15892
15926
|
}
|
|
15893
|
-
const cachedConvMeta = this.cache?.getMetaById(historyId);
|
|
15894
15927
|
const provider = coerceProviderForRunner(
|
|
15895
15928
|
conv?.provider ?? cachedConvMeta?.provider ?? registryProvider
|
|
15896
15929
|
);
|
|
@@ -15904,7 +15937,7 @@ var StreamerServer = class {
|
|
|
15904
15937
|
// conversation. Kept separate from `jsonlPath` deliberately: feeding it to
|
|
15905
15938
|
// conversationBusy() would newly arm the mtime heuristic for Codex, which
|
|
15906
15939
|
// is exactly the over-broad signal the report ruled out.
|
|
15907
|
-
historyPath: jsonlPath ?? conv?.filePath ?? null,
|
|
15940
|
+
historyPath: jsonlPath ?? conv?.filePath ?? cachedCodexPath ?? null,
|
|
15908
15941
|
conv,
|
|
15909
15942
|
projectPath,
|
|
15910
15943
|
provider
|