@threadbase-sh/streamer 1.67.3 → 1.67.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
@@ -121051,6 +121051,24 @@ var init_detectShellPrompt = __esm({
121051
121051
  }
121052
121052
  });
121053
121053
 
121054
+ // src/services/questions/permissionAnswerKeys.ts
121055
+ function permissionAnswerKeys(index) {
121056
+ if (!Number.isInteger(index) || index < 0) {
121057
+ throw new Error(`Invalid permission option index: ${index}`);
121058
+ }
121059
+ return `${index}${ENTER3}`;
121060
+ }
121061
+ function isPermissionAnswer(gate, keys) {
121062
+ return gate.options.some((o) => keys === (o.answerKeys ?? permissionAnswerKeys(o.index)));
121063
+ }
121064
+ var ENTER3;
121065
+ var init_permissionAnswerKeys = __esm({
121066
+ "src/services/questions/permissionAnswerKeys.ts"() {
121067
+ "use strict";
121068
+ ENTER3 = "\r";
121069
+ }
121070
+ });
121071
+
121054
121072
  // src/utils/deriveSessionName.ts
121055
121073
  function deriveSessionName(firstMessageText) {
121056
121074
  const firstLine = firstMessageText.split("\n", 1)[0]?.trim() ?? "";
@@ -121120,6 +121138,7 @@ var init_pty_manager = __esm({
121120
121138
  init_detectQuestionFromScreen();
121121
121139
  init_detectShellPrompt();
121122
121140
  init_parseAgentPhase();
121141
+ init_permissionAnswerKeys();
121123
121142
  init_debounce();
121124
121143
  init_deriveSessionName();
121125
121144
  OUTPUT_BUFFER_MAX2 = 65536;
@@ -121142,10 +121161,12 @@ var init_pty_manager = __esm({
121142
121161
  onLiveQuestion;
121143
121162
  onLiveQuestionGone;
121144
121163
  onUserMessage;
121145
- // Per-session permission-gate state. True between an OSC 777 (gate open) and
121146
- // the next prompt-ready without a fresh 777 (gate closed). Prevents
121147
- // re-broadcasting open/close on every chunk.
121148
- permissionOpen = /* @__PURE__ */ new Set();
121164
+ // Per-session permission-gate state: the gate currently open on a session's
121165
+ // screen. Set between an OSC 777 / paint-time claim (gate open) and the next
121166
+ // prompt-ready without a fresh 777 (gate closed). Prevents re-broadcasting
121167
+ // open/close on every chunk. Holds the gate itself rather than just the id so
121168
+ // sendKeys can tell whether the bytes it is writing are that gate's answer.
121169
+ permissionOpen = /* @__PURE__ */ new Map();
121149
121170
  // Last chunk's raw tail per session — prepended to the next chunk before
121150
121171
  // the OSC regex test so a split escape still matches. Consumed on match.
121151
121172
  oscTail = /* @__PURE__ */ new Map();
@@ -121380,6 +121401,11 @@ var init_pty_manager = __esm({
121380
121401
  );
121381
121402
  session.process.write(keys);
121382
121403
  session.lastActivityAt = /* @__PURE__ */ new Date();
121404
+ const openGate = this.permissionOpen.get(sessionId);
121405
+ if (openGate && isPermissionAnswer(openGate, keys)) {
121406
+ this.permissionOpen.delete(sessionId);
121407
+ this.onPermissionChange?.(sessionId, null);
121408
+ }
121383
121409
  }
121384
121410
  sendInput(sessionId, input) {
121385
121411
  const session = this.sessions.get(sessionId);
@@ -121726,7 +121752,7 @@ var init_pty_manager = __esm({
121726
121752
  }
121727
121753
  if (oscPermission && !askFooterOnScreen) {
121728
121754
  const gate = scrapePermissionGate(lines);
121729
- this.permissionOpen.add(sessionId);
121755
+ this.permissionOpen.set(sessionId, gate ?? { options: [] });
121730
121756
  this.onPermissionChange?.(sessionId, gate ?? { options: [] });
121731
121757
  } else if (this.permissionOpen.has(sessionId) && !askFooterOnScreen) {
121732
121758
  const gate = detectGateScreen(lines);
@@ -121740,6 +121766,7 @@ var init_pty_manager = __esm({
121740
121766
  this.closedGateKey.delete(sessionId);
121741
121767
  }
121742
121768
  } else if (gate) {
121769
+ this.permissionOpen.set(sessionId, gate);
121743
121770
  this.onPermissionChange?.(sessionId, gate);
121744
121771
  }
121745
121772
  } else if (!askFooterOnScreen && !oscWaitingForInput) {
@@ -121747,7 +121774,7 @@ var init_pty_manager = __esm({
121747
121774
  if (gate) {
121748
121775
  const key = permissionContentKey({ ...gate, cursor: void 0 });
121749
121776
  if (this.closedGateKey.get(sessionId) !== key) {
121750
- this.permissionOpen.add(sessionId);
121777
+ this.permissionOpen.set(sessionId, gate);
121751
121778
  this.onPermissionChange?.(sessionId, gate);
121752
121779
  }
121753
121780
  } else {