@threadbase-sh/streamer 1.70.2 → 1.70.4

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
@@ -107551,6 +107551,13 @@ var init_detectPermissionGate = __esm({
107551
107551
  });
107552
107552
 
107553
107553
  // src/services/questions/detectQuestionFromScreen.ts
107554
+ function stripStateMarker(label) {
107555
+ if (KNOWN_STATE_MARKER_RE.test(label)) {
107556
+ return { label: label.replace(KNOWN_STATE_MARKER_RE, ""), marked: true };
107557
+ }
107558
+ if (UNKNOWN_STATE_MARKER_RE.test(label)) return { label, marked: true };
107559
+ return { label, marked: false };
107560
+ }
107554
107561
  function stripBoxGutter(line) {
107555
107562
  return line.replace(/^\s*[│|]\s?/, "").replace(/\s*[│|]\s*$/, "");
107556
107563
  }
@@ -107565,6 +107572,7 @@ function detectQuestionFromScreen(lines) {
107565
107572
  if (footerIdx === -1) return null;
107566
107573
  const options = [];
107567
107574
  let firstOptionIdx = -1;
107575
+ let sawStateMarker = false;
107568
107576
  for (let i = footerIdx - 1; i >= 0; i--) {
107569
107577
  const line = lines[i];
107570
107578
  const inner = stripBoxGutter(line);
@@ -107578,8 +107586,10 @@ function detectQuestionFromScreen(lines) {
107578
107586
  if (options.length > 0 && QUESTION_RE.test(trimmed) && !OPTION_RE2.test(inner)) break;
107579
107587
  const m2 = OPTION_RE2.exec(inner);
107580
107588
  if (m2) {
107581
- const label = m2[2].trim();
107582
- if (PERMISSION_LABEL_RE.test(label)) return null;
107589
+ const rendered = m2[2].trim();
107590
+ if (PERMISSION_LABEL_RE.test(rendered)) return null;
107591
+ const { label, marked } = stripStateMarker(rendered);
107592
+ if (marked) sawStateMarker = true;
107583
107593
  options.unshift({ label, description: "" });
107584
107594
  firstOptionIdx = i;
107585
107595
  }
@@ -107598,7 +107608,7 @@ function detectQuestionFromScreen(lines) {
107598
107608
  }
107599
107609
  if (!question) return null;
107600
107610
  return {
107601
- questions: [{ question, header: "", multiSelect: false, options }]
107611
+ questions: [{ question, header: "", multiSelect: sawStateMarker, options }]
107602
107612
  };
107603
107613
  }
107604
107614
  function isQuestionMenuOnScreen(lines) {
@@ -107607,7 +107617,7 @@ function isQuestionMenuOnScreen(lines) {
107607
107617
  function questionContentKey(questions) {
107608
107618
  return questions.map((q2) => `${q2.question} ${q2.options.map((o) => o.label).join(",")}`).join("::");
107609
107619
  }
107610
- var ASK_FOOTER_RE, ESC_FOOTER_RE, OPTION_RE2, QUESTION_RE, BOX_ONLY_RE2, PERMISSION_LABEL_RE;
107620
+ var ASK_FOOTER_RE, ESC_FOOTER_RE, OPTION_RE2, QUESTION_RE, BOX_ONLY_RE2, PERMISSION_LABEL_RE, KNOWN_STATE_MARKER_RE, UNKNOWN_STATE_MARKER_RE;
107611
107621
  var init_detectQuestionFromScreen = __esm({
107612
107622
  "src/services/questions/detectQuestionFromScreen.ts"() {
107613
107623
  "use strict";
@@ -107617,6 +107627,8 @@ var init_detectQuestionFromScreen = __esm({
107617
107627
  QUESTION_RE = /\?\s*$/;
107618
107628
  BOX_ONLY_RE2 = /^[\s│─┌┐└┘├┤┬┴┼╭╮╰╯╱╲=_-]+$/;
107619
107629
  PERMISSION_LABEL_RE = /^(Yes|No)\b/i;
107630
+ KNOWN_STATE_MARKER_RE = /^(?:\[(?:[ xX*]|✓|✔)\]|[☐☑☒])\s*/;
107631
+ UNKNOWN_STATE_MARKER_RE = /^(?:\[[^\]]{0,3}\]|\([^)]{0,3}\))\s*/;
107620
107632
  }
107621
107633
  });
107622
107634
 
@@ -157030,23 +157042,16 @@ var StreamerServer = class {
157030
157042
  * it.
157031
157043
  */
157032
157044
  async resolveConversationTarget(sessionId) {
157033
- let jsonlPath = this.conversationHandlers.findJsonlPath(sessionId);
157034
- let conv = await this.conversationHandlers.findConversationByUuid(sessionId);
157035
- let historyId = sessionId;
157036
- let registryProvider;
157037
- if (!jsonlPath && !conv) {
157038
- const row = this.managedSessionsRepo?.get(sessionId) ?? null;
157039
- const boundId = row ? resumeIdForRow(row) : null;
157040
- if (boundId != null && boundId !== sessionId) {
157041
- historyId = boundId;
157042
- registryProvider = row?.provider;
157043
- jsonlPath = this.conversationHandlers.findJsonlPath(boundId);
157044
- conv = await this.conversationHandlers.findConversationByUuid(boundId);
157045
- }
157046
- }
157045
+ const row = this.managedSessionsRepo?.get(sessionId) ?? null;
157046
+ const liveSession = this.sessionStore.getManaged(sessionId);
157047
+ const resumeId = (row ? resumeIdForRow(row) : null) ?? (liveSession?.provider === CODEX_CLI_PROVIDER ? liveSession.boundConversationId ?? null : null);
157048
+ const historyId = resumeId ?? sessionId;
157049
+ const managedProvider = row?.provider ?? liveSession?.provider;
157050
+ const jsonlPath = this.conversationHandlers.findJsonlPath(historyId);
157051
+ const conv = await this.conversationHandlers.findConversationByUuid(historyId);
157047
157052
  const cachedConvMeta = this.cache?.getMetaById(historyId);
157048
157053
  const cachedPath = cachedConvMeta?.filePath ? toNativeFilePath(cachedConvMeta.filePath) : null;
157049
- const cachedCodexPath = (registryProvider === CODEX_CLI_PROVIDER || cachedConvMeta?.provider === CODEX_CLI_PROVIDER) && cachedPath != null && (0, import_fs39.existsSync)(cachedPath) ? cachedPath : null;
157054
+ const cachedCodexPath = (managedProvider === CODEX_CLI_PROVIDER || cachedConvMeta?.provider === CODEX_CLI_PROVIDER) && cachedPath != null && (0, import_fs39.existsSync)(cachedPath) ? cachedPath : null;
157050
157055
  const jsonlCwd = jsonlPath ? await this.conversationHandlers.readCwdFromJsonl(jsonlPath) : null;
157051
157056
  const projectPath = jsonlCwd ?? conv?.projectPath ?? (cachedCodexPath ? cachedConvMeta?.projectPath : null);
157052
157057
  if (!projectPath) {
@@ -157056,7 +157061,7 @@ var StreamerServer = class {
157056
157061
  return { ok: false, reason: "no_project_path" };
157057
157062
  }
157058
157063
  const provider = coerceProviderForRunner(
157059
- conv?.provider ?? cachedConvMeta?.provider ?? registryProvider
157064
+ conv?.provider ?? cachedConvMeta?.provider ?? managedProvider
157060
157065
  );
157061
157066
  return {
157062
157067
  ok: true,