@adhdev/daemon-standalone 0.9.82-rc.110 → 0.9.82-rc.111

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
@@ -26809,6 +26809,8 @@ Next step: ${nextStep}`;
26809
26809
  pendingOutboundQueue = [];
26810
26810
  pendingOutboundFlushTimer = null;
26811
26811
  pendingOutboundFlushInFlight = false;
26812
+ providerErrorRetryTimer = null;
26813
+ providerErrorRetryKey = "";
26812
26814
  // Resize redraw suppression
26813
26815
  resizeSuppressUntil = 0;
26814
26816
  // Debug: status transition history
@@ -27415,6 +27417,11 @@ ${lastSnapshot}`;
27415
27417
  clearTimeout(this.ptyOutputFlushTimer);
27416
27418
  this.ptyOutputFlushTimer = null;
27417
27419
  }
27420
+ if (this.providerErrorRetryTimer) {
27421
+ clearTimeout(this.providerErrorRetryTimer);
27422
+ this.providerErrorRetryTimer = null;
27423
+ }
27424
+ this.providerErrorRetryKey = "";
27418
27425
  }
27419
27426
  clearStaleIdleResponseGuard(reason) {
27420
27427
  const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
@@ -27564,6 +27571,7 @@ ${lastSnapshot}`;
27564
27571
  return;
27565
27572
  }
27566
27573
  if (status === "error") {
27574
+ if (this.maybeScheduleProviderErrorRetry(ctx, session)) return;
27567
27575
  this.applyError(ctx, session);
27568
27576
  return;
27569
27577
  }
@@ -27750,6 +27758,63 @@ ${lastSnapshot}`;
27750
27758
  });
27751
27759
  this.onStatusChange?.();
27752
27760
  }
27761
+ maybeScheduleProviderErrorRetry(ctx, session) {
27762
+ const retryPrompt = typeof session.retryPrompt === "string" ? String(session.retryPrompt).trim() : "";
27763
+ const retryDelayMs = typeof session.retryDelayMs === "number" ? Number(session.retryDelayMs) : NaN;
27764
+ if (!retryPrompt || !Number.isFinite(retryDelayMs) || retryDelayMs < 0) return false;
27765
+ if (!this.ptyProcess) return false;
27766
+ const retryAttempt = typeof session.retryAttempt === "number" ? Number(session.retryAttempt) : 0;
27767
+ const retryMaxAttempts = typeof session.retryMaxAttempts === "number" ? Number(session.retryMaxAttempts) : 0;
27768
+ const errorReason = typeof session.errorReason === "string" && session.errorReason.trim() ? session.errorReason.trim() : "provider_error";
27769
+ const retryKey = `${errorReason}:${retryAttempt}:${retryPrompt}`;
27770
+ if (this.providerErrorRetryTimer && this.providerErrorRetryKey === retryKey) return true;
27771
+ if (this.providerErrorRetryTimer) clearTimeout(this.providerErrorRetryTimer);
27772
+ this.providerErrorRetryKey = retryKey;
27773
+ this.clearIdleFinishCandidate("provider_error_retry");
27774
+ if (this.idleTimeout) {
27775
+ clearTimeout(this.idleTimeout);
27776
+ this.idleTimeout = null;
27777
+ }
27778
+ if (this.approvalExitTimeout) {
27779
+ clearTimeout(this.approvalExitTimeout);
27780
+ this.approvalExitTimeout = null;
27781
+ }
27782
+ this.providerErrorMessage = typeof session.errorMessage === "string" && session.errorMessage.trim() ? session.errorMessage.trim() : "Provider reported an error";
27783
+ this.providerErrorReason = errorReason;
27784
+ this.activeModal = null;
27785
+ this.responseSettleIgnoreUntil = Date.now() + retryDelayMs + this.timeouts.outputSettle + 400;
27786
+ this.setStatus("generating", "provider_error_retry_scheduled");
27787
+ this.recordTrace("provider_error_retry_scheduled", {
27788
+ retryPrompt,
27789
+ retryDelayMs,
27790
+ retryAttempt,
27791
+ retryMaxAttempts,
27792
+ errorReason,
27793
+ parsedStatus: ctx.parsedStatus || ctx.status
27794
+ });
27795
+ this.onStatusChange?.();
27796
+ this.providerErrorRetryTimer = setTimeout(() => {
27797
+ this.providerErrorRetryTimer = null;
27798
+ this.providerErrorRetryKey = "";
27799
+ if (!this.ptyProcess) return;
27800
+ this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
27801
+ this.submitRetryUsed = false;
27802
+ this.recordTrace("provider_error_retry_write", {
27803
+ retryPrompt,
27804
+ retryAttempt,
27805
+ retryMaxAttempts,
27806
+ errorReason
27807
+ });
27808
+ this.ptyProcess.write(`${retryPrompt}\r`);
27809
+ if (this.settleTimer) clearTimeout(this.settleTimer);
27810
+ this.settleTimer = setTimeout(() => {
27811
+ this.settleTimer = null;
27812
+ this.settledBuffer = this.recentOutputBuffer;
27813
+ this.evaluateSettled();
27814
+ }, this.timeouts.outputSettle + 150);
27815
+ }, retryDelayMs);
27816
+ return true;
27817
+ }
27753
27818
  applyIdle(ctx, now) {
27754
27819
  const { modal, lastParsedAssistant, prevStatus } = ctx;
27755
27820
  if (prevStatus === "waiting_approval") {