@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 CHANGED
@@ -151047,6 +151047,7 @@ function autoResumeSkipReason(row, opts) {
151047
151047
  if (opts.now - row.status_updated_at > AUTO_RESUME_WINDOW_MS) return "too_old";
151048
151048
  if (!opts.projectExists(row.project_path)) return "project_missing";
151049
151049
  if (resumeIdForRow(row) == null) return "resume_identity_missing";
151050
+ if (!opts.historyExists(row)) return "history_missing";
151050
151051
  return null;
151051
151052
  }
151052
151053
  function planAutoResume(rows, opts) {
@@ -151308,7 +151309,34 @@ var SessionRegistryBoot = class {
151308
151309
  /** Resume only the recent sessions the user explicitly allowed us to start at boot. */
151309
151310
  async autoResumePreviousSessions(rows) {
151310
151311
  if (!this.autoResumeOnBoot) return;
151311
- const plan = planAutoResume(rows, { now: Date.now(), projectExists: import_fs36.existsSync });
151312
+ const now = Date.now();
151313
+ const baseOptions = { now, projectExists: import_fs36.existsSync, historyExists: () => true };
151314
+ const historyExists = /* @__PURE__ */ new Map();
151315
+ const preflights = /* @__PURE__ */ new Set();
151316
+ for (const row of rows) {
151317
+ if (autoResumeSkipReason(row, baseOptions) != null) {
151318
+ historyExists.set(row.session_id, false);
151319
+ continue;
151320
+ }
151321
+ while (preflights.size >= AUTO_RESUME_CONCURRENCY) {
151322
+ await Promise.race(preflights);
151323
+ }
151324
+ const preflight = (async () => {
151325
+ try {
151326
+ const target = await this.deps.resolveConversationTarget(row.session_id);
151327
+ historyExists.set(row.session_id, target.ok || target.reason !== "history_file_missing");
151328
+ } catch {
151329
+ historyExists.set(row.session_id, true);
151330
+ }
151331
+ })();
151332
+ preflights.add(preflight);
151333
+ void preflight.then(() => preflights.delete(preflight));
151334
+ }
151335
+ await Promise.all(preflights);
151336
+ const plan = planAutoResume(rows, {
151337
+ ...baseOptions,
151338
+ historyExists: (row) => historyExists.get(row.session_id) ?? false
151339
+ });
151312
151340
  const skippedBy = {};
151313
151341
  for (const { row, reason } of plan.skipped) {
151314
151342
  skippedBy[reason] = (skippedBy[reason] ?? 0) + 1;
@@ -152470,7 +152498,8 @@ var StreamerServer = class {
152470
152498
  selfPtyEndedAt: this.selfPtyEndedAt,
152471
152499
  resumeSession: (opts) => this.sessionHandlers.resumeSession(opts),
152472
152500
  watchConversationFile: (sessionId, historyId) => this.sessionWatchers.watchConversationFile(sessionId, historyId),
152473
- broadcastSessionList: () => this.wsHub.broadcast(this.sessionListPayload())
152501
+ broadcastSessionList: () => this.wsHub.broadcast(this.sessionListPayload()),
152502
+ resolveConversationTarget: (sessionId) => this.resolveConversationTarget(sessionId)
152474
152503
  });
152475
152504
  this.includeAgents = parseIncludeAgentsEnv(process.env.THREADBASE_INCLUDE_AGENTS);
152476
152505
  this.agentEntrypoints = parseAgentEntrypointsEnv(process.env.THREADBASE_AGENT_ENTRYPOINTS);
@@ -153679,13 +153708,17 @@ var StreamerServer = class {
153679
153708
  conv = await this.conversationHandlers.findConversationByUuid(boundId);
153680
153709
  }
153681
153710
  }
153711
+ const cachedConvMeta = this.cache?.getMetaById(historyId);
153712
+ const cachedPath = cachedConvMeta?.filePath ? toNativeFilePath(cachedConvMeta.filePath) : null;
153713
+ const cachedCodexPath = (registryProvider === CODEX_CLI_PROVIDER || cachedConvMeta?.provider === CODEX_CLI_PROVIDER) && cachedPath != null && (0, import_fs38.existsSync)(cachedPath) ? cachedPath : null;
153682
153714
  const jsonlCwd = jsonlPath ? await this.conversationHandlers.readCwdFromJsonl(jsonlPath) : null;
153683
- const projectPath = jsonlCwd ?? conv?.projectPath;
153715
+ const projectPath = jsonlCwd ?? conv?.projectPath ?? (cachedCodexPath ? cachedConvMeta?.projectPath : null);
153684
153716
  if (!projectPath) {
153685
- if (!conv && !jsonlPath) return { ok: false, reason: "history_file_missing" };
153717
+ if (!conv && !jsonlPath && !cachedCodexPath) {
153718
+ return { ok: false, reason: "history_file_missing" };
153719
+ }
153686
153720
  return { ok: false, reason: "no_project_path" };
153687
153721
  }
153688
- const cachedConvMeta = this.cache?.getMetaById(historyId);
153689
153722
  const provider = coerceProviderForRunner(
153690
153723
  conv?.provider ?? cachedConvMeta?.provider ?? registryProvider
153691
153724
  );
@@ -153699,7 +153732,7 @@ var StreamerServer = class {
153699
153732
  // conversation. Kept separate from `jsonlPath` deliberately: feeding it to
153700
153733
  // conversationBusy() would newly arm the mtime heuristic for Codex, which
153701
153734
  // is exactly the over-broad signal the report ruled out.
153702
- historyPath: jsonlPath ?? conv?.filePath ?? null,
153735
+ historyPath: jsonlPath ?? conv?.filePath ?? cachedCodexPath ?? null,
153703
153736
  conv,
153704
153737
  projectPath,
153705
153738
  provider