@adhdev/daemon-standalone 0.9.82-rc.268 → 0.9.82-rc.269

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/index.js CHANGED
@@ -29973,10 +29973,10 @@ var require_dist3 = __commonJS({
29973
29973
  }
29974
29974
  function getDaemonBuildInfo() {
29975
29975
  if (cached2) return cached2;
29976
- const commit = readInjected(true ? "9da2b92afe11e5b813734c9f389479542e25a41f" : void 0) ?? "unknown";
29977
- const commitShort = readInjected(true ? "9da2b92a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29978
- const version2 = readInjected(true ? "0.9.82-rc.268" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29979
- const builtAt = readInjected(true ? "2026-06-14T21:47:30.810Z" : void 0);
29976
+ const commit = readInjected(true ? "025d8bef81a66e7b44a5ba5d5a04e063db46db4e" : void 0) ?? "unknown";
29977
+ const commitShort = readInjected(true ? "025d8bef" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29978
+ const version2 = readInjected(true ? "0.9.82-rc.269" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29979
+ const builtAt = readInjected(true ? "2026-06-14T22:12:06.668Z" : void 0);
29980
29980
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
29981
29981
  return cached2;
29982
29982
  }
@@ -39276,7 +39276,7 @@ Next step: ${nextStep}`;
39276
39276
  "@adhdev/ghostty-vt-node"
39277
39277
  ];
39278
39278
  cachedBindingError = null;
39279
- GhosttyVtTerminalBackend = class {
39279
+ GhosttyVtTerminalBackend = class _GhosttyVtTerminalBackend {
39280
39280
  kind = "ghostty-vt";
39281
39281
  terminal;
39282
39282
  rows;
@@ -39298,17 +39298,30 @@ Next step: ${nextStep}`;
39298
39298
  if (!data || this.disposed) return;
39299
39299
  this.terminal.write(data);
39300
39300
  }
39301
+ formatLines() {
39302
+ const raw = this.terminal.formatPlainText({ trim: false }) || "";
39303
+ if (!raw) return [];
39304
+ return raw.split("\n").map((row) => row.replace(/\s+$/, ""));
39305
+ }
39306
+ static trimBlankEnds(lines) {
39307
+ let first = 0;
39308
+ let last = lines.length;
39309
+ while (first < last && !lines[first]) first += 1;
39310
+ while (last > first && !lines[last - 1]) last -= 1;
39311
+ return lines.slice(first, last).join("\n");
39312
+ }
39301
39313
  getText() {
39302
39314
  if (this.disposed) return "";
39303
- const raw = this.terminal.formatPlainText({ trim: false }) || "";
39304
- if (!raw) return "";
39305
- const lines = raw.split("\n").map((row) => row.replace(/\s+$/, ""));
39315
+ const lines = this.formatLines();
39316
+ if (lines.length === 0) return "";
39306
39317
  const viewport = lines.length > this.rows ? lines.slice(-this.rows) : lines;
39307
- let first = 0;
39308
- let last = viewport.length;
39309
- while (first < last && !viewport[first]) first += 1;
39310
- while (last > first && !viewport[last - 1]) last -= 1;
39311
- return viewport.slice(first, last).join("\n");
39318
+ return _GhosttyVtTerminalBackend.trimBlankEnds(viewport);
39319
+ }
39320
+ getTextWithScrollback() {
39321
+ if (this.disposed) return "";
39322
+ const lines = this.formatLines();
39323
+ if (lines.length === 0) return "";
39324
+ return _GhosttyVtTerminalBackend.trimBlankEnds(lines);
39312
39325
  }
39313
39326
  getCursorPosition() {
39314
39327
  if (this.disposed) return { col: 0, row: 0 };
@@ -39361,6 +39374,10 @@ Next step: ${nextStep}`;
39361
39374
  getText() {
39362
39375
  return this.terminal.getText();
39363
39376
  }
39377
+ /** Full buffer including scrollback history (see backend doc). */
39378
+ getTextWithScrollback() {
39379
+ return this.terminal.getTextWithScrollback();
39380
+ }
39364
39381
  getCursorPosition() {
39365
39382
  return this.terminal.getCursorPosition();
39366
39383
  }
@@ -58938,6 +58955,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
58938
58955
  snapshot() {
58939
58956
  return this.lastScreen || this.computeScreen();
58940
58957
  }
58958
+ /**
58959
+ * Full-buffer snapshot including scrollback history. Unlike snapshot()
58960
+ * (visible viewport only), this survives a tall prompt whose top has
58961
+ * scrolled off-screen — used for content-pattern extraction (modal
58962
+ * buttons / approval anchors), NOT for cursor-relative conditions.
58963
+ */
58964
+ snapshotWithScrollback() {
58965
+ return this.screen.getTextWithScrollback();
58966
+ }
58941
58967
  getCursorPosition() {
58942
58968
  const pos = this.screen.getCursorPosition();
58943
58969
  return { row: pos.row, col: pos.col };
@@ -59110,6 +59136,18 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59110
59136
  getScreen() {
59111
59137
  return this.adapter.snapshot();
59112
59138
  }
59139
+ /** Scrollback-inclusive screen as line array — used only for modal/button
59140
+ * content extraction so a tall prompt's off-screen anchors stay matchable.
59141
+ * Falls back to the viewport snapshot if scrollback read is unavailable. */
59142
+ scrollbackLines() {
59143
+ let screen = "";
59144
+ try {
59145
+ screen = this.adapter.snapshotWithScrollback();
59146
+ } catch {
59147
+ }
59148
+ if (!screen) screen = this.adapter.snapshot();
59149
+ return screen.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
59150
+ }
59113
59151
  getSpecPath() {
59114
59152
  return this.opts.specPath;
59115
59153
  }
@@ -59291,9 +59329,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59291
59329
  const screen = this.adapter.snapshot();
59292
59330
  const lines = screen.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
59293
59331
  const sections = resolveSections(this.spec.sections ?? {}, lines);
59294
- const modal = this.deriveModal(state, sections, lines.join("\n"));
59332
+ const modalLines = state.modal ? this.scrollbackLines() : lines;
59333
+ const modalSections = state.modal ? resolveSections(this.spec.sections ?? {}, modalLines) : sections;
59334
+ const modalFullScreen = modalLines.join("\n");
59335
+ const modal = this.deriveModal(state, modalSections, modalFullScreen);
59295
59336
  const controls = this.deriveControls(state.id);
59296
- const title = modal?.title ?? this.deriveTitle(state, sections, lines.join("\n"));
59337
+ const title = modal?.title ?? this.deriveTitle(state, modalSections, modalFullScreen);
59297
59338
  const next = {
59298
59339
  // status is derived from the FSM state itself (statusForState), NOT from
59299
59340
  // whether a modal was parsed this frame. A modal state whose buttons briefly
@@ -61152,7 +61193,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61152
61193
  }
61153
61194
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
61154
61195
  }
61155
- var CliProviderInstance = class {
61196
+ var CliProviderInstance = class _CliProviderInstance {
61156
61197
  constructor(provider, workingDir, cliArgs = [], instanceId, transportFactory, options) {
61157
61198
  this.provider = provider;
61158
61199
  this.workingDir = workingDir;
@@ -61172,6 +61213,18 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61172
61213
  }
61173
61214
  type;
61174
61215
  category = "cli";
61216
+ /**
61217
+ * Quiet period an approval modal's signature must be stable before
61218
+ * auto-approve sends the approve key. Guards against firing on a prompt
61219
+ * that is still streaming into the PTY (the "resolves too fast" symptom):
61220
+ * while the modal text/buttons are still changing, every frame yields a
61221
+ * new signature and the settle clock restarts. Once the prompt finishes
61222
+ * rendering the signature holds and the key is sent after this window.
61223
+ * Bounded + small so genuine approvals stay timely. The FSM is already
61224
+ * authoritative over the `waiting_approval` state; this only delays the
61225
+ * keystroke until the modal *content* has settled.
61226
+ */
61227
+ static AUTO_APPROVE_SETTLE_MS = 600;
61175
61228
  adapter;
61176
61229
  context = null;
61177
61230
  events = [];
@@ -61185,6 +61238,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61185
61238
  autoApproveBusy = false;
61186
61239
  autoApproveBusyTimer = null;
61187
61240
  lastAutoApprovalSignature = "";
61241
+ // Settle gate: the approval modal's signature + the wall-clock when this
61242
+ // exact signature was first observed. Auto-approve only fires once the
61243
+ // SAME signature has been stable for AUTO_APPROVE_SETTLE_MS, so a prompt
61244
+ // still streaming into the PTY (its buttons/message changing frame to
61245
+ // frame) keeps resetting the timer and is never approved half-rendered.
61246
+ pendingAutoApprovalSignature = "";
61247
+ pendingAutoApprovalSince = 0;
61248
+ autoApproveSettleTimer = null;
61188
61249
  controlValues = {};
61189
61250
  summaryMetadata = void 0;
61190
61251
  appliedEffectKeys = /* @__PURE__ */ new Set();
@@ -61619,6 +61680,14 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61619
61680
  dispose() {
61620
61681
  this.adapter.shutdown();
61621
61682
  this.monitor.reset();
61683
+ if (this.autoApproveSettleTimer) {
61684
+ clearTimeout(this.autoApproveSettleTimer);
61685
+ this.autoApproveSettleTimer = null;
61686
+ }
61687
+ if (this.autoApproveBusyTimer) {
61688
+ clearTimeout(this.autoApproveBusyTimer);
61689
+ this.autoApproveBusyTimer = null;
61690
+ }
61622
61691
  this.appliedEffectKeys.clear();
61623
61692
  try {
61624
61693
  this.cachedSqliteDb?.close();
@@ -61969,6 +62038,12 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61969
62038
  const autoApproveActive = adapterStatus?.status === "waiting_approval" && this.shouldAutoApprove();
61970
62039
  if (!autoApproveActive) {
61971
62040
  this.lastAutoApprovalSignature = "";
62041
+ this.pendingAutoApprovalSignature = "";
62042
+ this.pendingAutoApprovalSince = 0;
62043
+ if (this.autoApproveSettleTimer) {
62044
+ clearTimeout(this.autoApproveSettleTimer);
62045
+ this.autoApproveSettleTimer = null;
62046
+ }
61972
62047
  return autoApproveActive;
61973
62048
  }
61974
62049
  const modal = adapterStatus.activeModal;
@@ -61987,22 +62062,57 @@ ${formatManifestValidationIssues2(validation.issues)}`,
61987
62062
  buttons.join("|"),
61988
62063
  buttonIndex
61989
62064
  ].join("::");
61990
- if (!this.autoApproveBusy || signature !== this.lastAutoApprovalSignature) {
61991
- this.autoApproveBusy = true;
61992
- this.lastAutoApprovalSignature = signature;
61993
- if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
61994
- this.autoApproveBusyTimer = setTimeout(() => {
61995
- this.autoApproveBusy = false;
61996
- this.autoApproveBusyTimer = null;
61997
- this.lastAutoApprovalSignature = "";
61998
- }, 5e3);
61999
- this.recordAutoApproval(modal?.message, buttonLabel, now);
62000
- setTimeout(() => {
62001
- this.adapter.resolveModal(buttonIndex);
62002
- }, 0);
62065
+ if (this.autoApproveBusy && signature === this.lastAutoApprovalSignature) {
62066
+ return autoApproveActive;
62003
62067
  }
62068
+ if (signature !== this.pendingAutoApprovalSignature) {
62069
+ this.pendingAutoApprovalSignature = signature;
62070
+ this.pendingAutoApprovalSince = now;
62071
+ }
62072
+ const settledForMs = now - this.pendingAutoApprovalSince;
62073
+ if (settledForMs < _CliProviderInstance.AUTO_APPROVE_SETTLE_MS) {
62074
+ if (this.autoApproveSettleTimer) clearTimeout(this.autoApproveSettleTimer);
62075
+ this.autoApproveSettleTimer = setTimeout(() => {
62076
+ this.autoApproveSettleTimer = null;
62077
+ this.recheckAutoApproveSettled();
62078
+ }, _CliProviderInstance.AUTO_APPROVE_SETTLE_MS - settledForMs + 20);
62079
+ return autoApproveActive;
62080
+ }
62081
+ if (this.autoApproveSettleTimer) {
62082
+ clearTimeout(this.autoApproveSettleTimer);
62083
+ this.autoApproveSettleTimer = null;
62084
+ }
62085
+ this.autoApproveBusy = true;
62086
+ this.lastAutoApprovalSignature = signature;
62087
+ this.pendingAutoApprovalSignature = "";
62088
+ this.pendingAutoApprovalSince = 0;
62089
+ if (this.autoApproveBusyTimer) clearTimeout(this.autoApproveBusyTimer);
62090
+ this.autoApproveBusyTimer = setTimeout(() => {
62091
+ this.autoApproveBusy = false;
62092
+ this.autoApproveBusyTimer = null;
62093
+ this.lastAutoApprovalSignature = "";
62094
+ }, 5e3);
62095
+ this.recordAutoApproval(modal?.message, buttonLabel, now);
62096
+ setTimeout(() => {
62097
+ this.adapter.resolveModal(buttonIndex);
62098
+ }, 0);
62004
62099
  return autoApproveActive;
62005
62100
  }
62101
+ /**
62102
+ * Re-drive the auto-approve check after the settle quiet window elapses.
62103
+ * The PTY may have gone silent once the approval prompt finished painting,
62104
+ * so no status-change frame is guaranteed to re-enter maybeAutoApproveStatus
62105
+ * — this timer-driven re-check picks up the now-settled modal and fires.
62106
+ * Deliberately lighter than detectStatusTransition(): it only re-evaluates
62107
+ * the approval decision; the next real PTY frame refreshes visible status.
62108
+ */
62109
+ recheckAutoApproveSettled() {
62110
+ try {
62111
+ const adapterStatus = this.adapter.getStatus({ allowParse: false });
62112
+ this.maybeAutoApproveStatus(adapterStatus, Date.now());
62113
+ } catch {
62114
+ }
62115
+ }
62006
62116
  detectStatusTransition() {
62007
62117
  const now = Date.now();
62008
62118
  const adapterStatus = this.adapter.getStatus({ allowParse: false });