@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.
@@ -80,6 +80,8 @@ export declare class ProviderCliAdapter implements CliAdapter {
80
80
  private pendingOutboundQueue;
81
81
  private pendingOutboundFlushTimer;
82
82
  private pendingOutboundFlushInFlight;
83
+ private providerErrorRetryTimer;
84
+ private providerErrorRetryKey;
83
85
  private resizeSuppressUntil;
84
86
  private statusHistory;
85
87
  private cliScripts;
@@ -168,6 +170,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
168
170
  private applyWaitingApproval;
169
171
  private applyGenerating;
170
172
  private applyError;
173
+ private maybeScheduleProviderErrorRetry;
171
174
  private applyIdle;
172
175
  private finishResponse;
173
176
  private maybeCommitVisibleIdleTranscript;
package/dist/index.js CHANGED
@@ -4651,6 +4651,8 @@ var init_provider_cli_adapter = __esm({
4651
4651
  pendingOutboundQueue = [];
4652
4652
  pendingOutboundFlushTimer = null;
4653
4653
  pendingOutboundFlushInFlight = false;
4654
+ providerErrorRetryTimer = null;
4655
+ providerErrorRetryKey = "";
4654
4656
  // Resize redraw suppression
4655
4657
  resizeSuppressUntil = 0;
4656
4658
  // Debug: status transition history
@@ -5257,6 +5259,11 @@ ${lastSnapshot}`;
5257
5259
  clearTimeout(this.ptyOutputFlushTimer);
5258
5260
  this.ptyOutputFlushTimer = null;
5259
5261
  }
5262
+ if (this.providerErrorRetryTimer) {
5263
+ clearTimeout(this.providerErrorRetryTimer);
5264
+ this.providerErrorRetryTimer = null;
5265
+ }
5266
+ this.providerErrorRetryKey = "";
5260
5267
  }
5261
5268
  clearStaleIdleResponseGuard(reason) {
5262
5269
  const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
@@ -5406,6 +5413,7 @@ ${lastSnapshot}`;
5406
5413
  return;
5407
5414
  }
5408
5415
  if (status === "error") {
5416
+ if (this.maybeScheduleProviderErrorRetry(ctx, session)) return;
5409
5417
  this.applyError(ctx, session);
5410
5418
  return;
5411
5419
  }
@@ -5592,6 +5600,63 @@ ${lastSnapshot}`;
5592
5600
  });
5593
5601
  this.onStatusChange?.();
5594
5602
  }
5603
+ maybeScheduleProviderErrorRetry(ctx, session) {
5604
+ const retryPrompt = typeof session.retryPrompt === "string" ? String(session.retryPrompt).trim() : "";
5605
+ const retryDelayMs = typeof session.retryDelayMs === "number" ? Number(session.retryDelayMs) : NaN;
5606
+ if (!retryPrompt || !Number.isFinite(retryDelayMs) || retryDelayMs < 0) return false;
5607
+ if (!this.ptyProcess) return false;
5608
+ const retryAttempt = typeof session.retryAttempt === "number" ? Number(session.retryAttempt) : 0;
5609
+ const retryMaxAttempts = typeof session.retryMaxAttempts === "number" ? Number(session.retryMaxAttempts) : 0;
5610
+ const errorReason = typeof session.errorReason === "string" && session.errorReason.trim() ? session.errorReason.trim() : "provider_error";
5611
+ const retryKey = `${errorReason}:${retryAttempt}:${retryPrompt}`;
5612
+ if (this.providerErrorRetryTimer && this.providerErrorRetryKey === retryKey) return true;
5613
+ if (this.providerErrorRetryTimer) clearTimeout(this.providerErrorRetryTimer);
5614
+ this.providerErrorRetryKey = retryKey;
5615
+ this.clearIdleFinishCandidate("provider_error_retry");
5616
+ if (this.idleTimeout) {
5617
+ clearTimeout(this.idleTimeout);
5618
+ this.idleTimeout = null;
5619
+ }
5620
+ if (this.approvalExitTimeout) {
5621
+ clearTimeout(this.approvalExitTimeout);
5622
+ this.approvalExitTimeout = null;
5623
+ }
5624
+ this.providerErrorMessage = typeof session.errorMessage === "string" && session.errorMessage.trim() ? session.errorMessage.trim() : "Provider reported an error";
5625
+ this.providerErrorReason = errorReason;
5626
+ this.activeModal = null;
5627
+ this.responseSettleIgnoreUntil = Date.now() + retryDelayMs + this.timeouts.outputSettle + 400;
5628
+ this.setStatus("generating", "provider_error_retry_scheduled");
5629
+ this.recordTrace("provider_error_retry_scheduled", {
5630
+ retryPrompt,
5631
+ retryDelayMs,
5632
+ retryAttempt,
5633
+ retryMaxAttempts,
5634
+ errorReason,
5635
+ parsedStatus: ctx.parsedStatus || ctx.status
5636
+ });
5637
+ this.onStatusChange?.();
5638
+ this.providerErrorRetryTimer = setTimeout(() => {
5639
+ this.providerErrorRetryTimer = null;
5640
+ this.providerErrorRetryKey = "";
5641
+ if (!this.ptyProcess) return;
5642
+ this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
5643
+ this.submitRetryUsed = false;
5644
+ this.recordTrace("provider_error_retry_write", {
5645
+ retryPrompt,
5646
+ retryAttempt,
5647
+ retryMaxAttempts,
5648
+ errorReason
5649
+ });
5650
+ this.ptyProcess.write(`${retryPrompt}\r`);
5651
+ if (this.settleTimer) clearTimeout(this.settleTimer);
5652
+ this.settleTimer = setTimeout(() => {
5653
+ this.settleTimer = null;
5654
+ this.settledBuffer = this.recentOutputBuffer;
5655
+ this.evaluateSettled();
5656
+ }, this.timeouts.outputSettle + 150);
5657
+ }, retryDelayMs);
5658
+ return true;
5659
+ }
5595
5660
  applyIdle(ctx, now) {
5596
5661
  const { modal, lastParsedAssistant, prevStatus } = ctx;
5597
5662
  if (prevStatus === "waiting_approval") {