@adhdev/daemon-core 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.mjs CHANGED
@@ -4646,6 +4646,8 @@ var init_provider_cli_adapter = __esm({
4646
4646
  pendingOutboundQueue = [];
4647
4647
  pendingOutboundFlushTimer = null;
4648
4648
  pendingOutboundFlushInFlight = false;
4649
+ providerErrorRetryTimer = null;
4650
+ providerErrorRetryKey = "";
4649
4651
  // Resize redraw suppression
4650
4652
  resizeSuppressUntil = 0;
4651
4653
  // Debug: status transition history
@@ -5252,6 +5254,11 @@ ${lastSnapshot}`;
5252
5254
  clearTimeout(this.ptyOutputFlushTimer);
5253
5255
  this.ptyOutputFlushTimer = null;
5254
5256
  }
5257
+ if (this.providerErrorRetryTimer) {
5258
+ clearTimeout(this.providerErrorRetryTimer);
5259
+ this.providerErrorRetryTimer = null;
5260
+ }
5261
+ this.providerErrorRetryKey = "";
5255
5262
  }
5256
5263
  clearStaleIdleResponseGuard(reason) {
5257
5264
  const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
@@ -5401,6 +5408,7 @@ ${lastSnapshot}`;
5401
5408
  return;
5402
5409
  }
5403
5410
  if (status === "error") {
5411
+ if (this.maybeScheduleProviderErrorRetry(ctx, session)) return;
5404
5412
  this.applyError(ctx, session);
5405
5413
  return;
5406
5414
  }
@@ -5587,6 +5595,63 @@ ${lastSnapshot}`;
5587
5595
  });
5588
5596
  this.onStatusChange?.();
5589
5597
  }
5598
+ maybeScheduleProviderErrorRetry(ctx, session) {
5599
+ const retryPrompt = typeof session.retryPrompt === "string" ? String(session.retryPrompt).trim() : "";
5600
+ const retryDelayMs = typeof session.retryDelayMs === "number" ? Number(session.retryDelayMs) : NaN;
5601
+ if (!retryPrompt || !Number.isFinite(retryDelayMs) || retryDelayMs < 0) return false;
5602
+ if (!this.ptyProcess) return false;
5603
+ const retryAttempt = typeof session.retryAttempt === "number" ? Number(session.retryAttempt) : 0;
5604
+ const retryMaxAttempts = typeof session.retryMaxAttempts === "number" ? Number(session.retryMaxAttempts) : 0;
5605
+ const errorReason = typeof session.errorReason === "string" && session.errorReason.trim() ? session.errorReason.trim() : "provider_error";
5606
+ const retryKey = `${errorReason}:${retryAttempt}:${retryPrompt}`;
5607
+ if (this.providerErrorRetryTimer && this.providerErrorRetryKey === retryKey) return true;
5608
+ if (this.providerErrorRetryTimer) clearTimeout(this.providerErrorRetryTimer);
5609
+ this.providerErrorRetryKey = retryKey;
5610
+ this.clearIdleFinishCandidate("provider_error_retry");
5611
+ if (this.idleTimeout) {
5612
+ clearTimeout(this.idleTimeout);
5613
+ this.idleTimeout = null;
5614
+ }
5615
+ if (this.approvalExitTimeout) {
5616
+ clearTimeout(this.approvalExitTimeout);
5617
+ this.approvalExitTimeout = null;
5618
+ }
5619
+ this.providerErrorMessage = typeof session.errorMessage === "string" && session.errorMessage.trim() ? session.errorMessage.trim() : "Provider reported an error";
5620
+ this.providerErrorReason = errorReason;
5621
+ this.activeModal = null;
5622
+ this.responseSettleIgnoreUntil = Date.now() + retryDelayMs + this.timeouts.outputSettle + 400;
5623
+ this.setStatus("generating", "provider_error_retry_scheduled");
5624
+ this.recordTrace("provider_error_retry_scheduled", {
5625
+ retryPrompt,
5626
+ retryDelayMs,
5627
+ retryAttempt,
5628
+ retryMaxAttempts,
5629
+ errorReason,
5630
+ parsedStatus: ctx.parsedStatus || ctx.status
5631
+ });
5632
+ this.onStatusChange?.();
5633
+ this.providerErrorRetryTimer = setTimeout(() => {
5634
+ this.providerErrorRetryTimer = null;
5635
+ this.providerErrorRetryKey = "";
5636
+ if (!this.ptyProcess) return;
5637
+ this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
5638
+ this.submitRetryUsed = false;
5639
+ this.recordTrace("provider_error_retry_write", {
5640
+ retryPrompt,
5641
+ retryAttempt,
5642
+ retryMaxAttempts,
5643
+ errorReason
5644
+ });
5645
+ this.ptyProcess.write(`${retryPrompt}\r`);
5646
+ if (this.settleTimer) clearTimeout(this.settleTimer);
5647
+ this.settleTimer = setTimeout(() => {
5648
+ this.settleTimer = null;
5649
+ this.settledBuffer = this.recentOutputBuffer;
5650
+ this.evaluateSettled();
5651
+ }, this.timeouts.outputSettle + 150);
5652
+ }, retryDelayMs);
5653
+ return true;
5654
+ }
5590
5655
  applyIdle(ctx, now) {
5591
5656
  const { modal, lastParsedAssistant, prevStatus } = ctx;
5592
5657
  if (prevStatus === "waiting_approval") {