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

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
@@ -26759,6 +26759,9 @@ Next step: ${nextStep}`;
26759
26759
  isWaitingForResponse = false;
26760
26760
  activeModal = null;
26761
26761
  parseErrorMessage = null;
26762
+ providerSessionId = null;
26763
+ providerErrorMessage = null;
26764
+ providerErrorReason = null;
26762
26765
  responseTimeout = null;
26763
26766
  idleTimeout = null;
26764
26767
  ready = false;
@@ -27560,6 +27563,10 @@ ${lastSnapshot}`;
27560
27563
  this.applyHoldGenerating(ctx, recentInteractiveActivity);
27561
27564
  return;
27562
27565
  }
27566
+ if (status === "error") {
27567
+ this.applyError(ctx, session);
27568
+ return;
27569
+ }
27563
27570
  if (status === "waiting_approval") {
27564
27571
  this.applyWaitingApproval(ctx);
27565
27572
  return;
@@ -27704,6 +27711,45 @@ ${lastSnapshot}`;
27704
27711
  }, this.timeouts.generatingIdle);
27705
27712
  this.onStatusChange?.();
27706
27713
  }
27714
+ applyError(ctx, session) {
27715
+ this.clearIdleFinishCandidate("provider_error");
27716
+ if (this.responseTimeout) {
27717
+ clearTimeout(this.responseTimeout);
27718
+ this.responseTimeout = null;
27719
+ }
27720
+ if (this.idleTimeout) {
27721
+ clearTimeout(this.idleTimeout);
27722
+ this.idleTimeout = null;
27723
+ }
27724
+ if (this.approvalExitTimeout) {
27725
+ clearTimeout(this.approvalExitTimeout);
27726
+ this.approvalExitTimeout = null;
27727
+ }
27728
+ this.isWaitingForResponse = false;
27729
+ this.responseSettleIgnoreUntil = 0;
27730
+ this.submitRetryUsed = false;
27731
+ this.submitRetryPromptSnippet = "";
27732
+ this.finishRetryCount = 0;
27733
+ this.currentTurnScope = null;
27734
+ this.activeModal = null;
27735
+ this.providerErrorMessage = typeof session.errorMessage === "string" && session.errorMessage.trim() ? session.errorMessage.trim() : "Provider reported an error";
27736
+ this.providerErrorReason = typeof session.errorReason === "string" && session.errorReason.trim() ? session.errorReason.trim() : "provider_error";
27737
+ this.setStatus("error", this.providerErrorReason);
27738
+ this.recordTrace("provider_error", {
27739
+ errorMessage: this.providerErrorMessage,
27740
+ errorReason: this.providerErrorReason,
27741
+ parsedStatus: ctx.parsedStatus || ctx.status,
27742
+ messageCount: ctx.parsedMessages.length,
27743
+ ...buildCliTraceParseSnapshot({
27744
+ accumulatedBuffer: this.accumulatedBuffer,
27745
+ accumulatedRawBuffer: this.accumulatedRawBuffer,
27746
+ responseBuffer: this.responseBuffer,
27747
+ partialResponse: this.responseBuffer,
27748
+ scope: this.currentTurnScope
27749
+ })
27750
+ });
27751
+ this.onStatusChange?.();
27752
+ }
27707
27753
  applyIdle(ctx, now) {
27708
27754
  const { modal, lastParsedAssistant, prevStatus } = ctx;
27709
27755
  if (prevStatus === "waiting_approval") {
@@ -27950,6 +27996,7 @@ ${lastSnapshot}`;
27950
27996
  { ...input, tail, tailScreen: buildCliScreenSnapshot(tail) }
27951
27997
  );
27952
27998
  this.parseErrorMessage = null;
27999
+ if (session && typeof session === "object") this.applyParsedSessionMetadata(session);
27953
28000
  return session && typeof session === "object" ? session : null;
27954
28001
  } catch (e) {
27955
28002
  const message = e?.message || String(e);
@@ -28006,6 +28053,15 @@ ${lastSnapshot}`;
28006
28053
  });
28007
28054
  return !!lastAssistant;
28008
28055
  }
28056
+ applyParsedSessionMetadata(parsed) {
28057
+ const providerSessionId = typeof parsed?.providerSessionId === "string" && parsed.providerSessionId.trim() ? parsed.providerSessionId.trim() : "";
28058
+ if (providerSessionId) {
28059
+ this.providerSessionId = providerSessionId;
28060
+ this.updateRuntimeMeta({ providerSessionId });
28061
+ }
28062
+ this.providerErrorMessage = typeof parsed?.errorMessage === "string" && parsed.errorMessage.trim() ? parsed.errorMessage.trim() : null;
28063
+ this.providerErrorReason = typeof parsed?.errorReason === "string" && parsed.errorReason.trim() ? parsed.errorReason.trim() : null;
28064
+ }
28009
28065
  parsedStatusHasFinalStandardAssistantMessage(parsed) {
28010
28066
  const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
28011
28067
  const lastAssistant = [...messages].reverse().find((message) => {
@@ -28088,8 +28144,9 @@ ${lastSnapshot}`;
28088
28144
  queuedAt: message.queuedAt,
28089
28145
  source: message.source
28090
28146
  })),
28091
- errorMessage: this.parseErrorMessage || void 0,
28092
- errorReason: this.parseErrorMessage ? "parse_error" : void 0,
28147
+ errorMessage: this.parseErrorMessage || this.providerErrorMessage || void 0,
28148
+ errorReason: this.parseErrorMessage ? "parse_error" : this.providerErrorReason || void 0,
28149
+ providerSessionId: this.providerSessionId || void 0,
28093
28150
  ...bufferState ? { bufferState } : {}
28094
28151
  };
28095
28152
  }
@@ -28120,7 +28177,7 @@ ${lastSnapshot}`;
28120
28177
  lastOutputAt: this.lastOutputAt
28121
28178
  }),
28122
28179
  activeModal,
28123
- providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
28180
+ providerSessionId: this.providerSessionId || (typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0),
28124
28181
  errorMessage: typeof parsed.errorMessage === "string" && parsed.errorMessage.trim() ? parsed.errorMessage.trim() : void 0,
28125
28182
  errorReason: typeof parsed.errorReason === "string" && parsed.errorReason.trim() ? parsed.errorReason.trim() : void 0,
28126
28183
  ...bufferState ? { bufferState } : {},
@@ -42061,6 +42118,13 @@ ${effect.notification.body || ""}`.trim();
42061
42118
  this.errorMessage = void 0;
42062
42119
  this.errorReason = void 0;
42063
42120
  }
42121
+ const adapterProviderSessionId = normalizeProviderSessionId(
42122
+ this.provider,
42123
+ typeof adapterStatus?.providerSessionId === "string" ? adapterStatus.providerSessionId : ""
42124
+ );
42125
+ if (adapterProviderSessionId) {
42126
+ this.promoteProviderSessionId(adapterProviderSessionId);
42127
+ }
42064
42128
  const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
42065
42129
  const visibleStatus = parseErrorMessage || parsedStatus?.status === "error" ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
42066
42130
  const parsedProviderSessionId = normalizeProviderSessionId(
@@ -42445,6 +42509,13 @@ ${effect.notification.body || ""}`.trim();
42445
42509
  detectStatusTransition() {
42446
42510
  const now = Date.now();
42447
42511
  const adapterStatus = this.adapter.getStatus({ allowParse: false });
42512
+ const adapterProviderSessionId = normalizeProviderSessionId(
42513
+ this.provider,
42514
+ typeof adapterStatus?.providerSessionId === "string" ? adapterStatus.providerSessionId : ""
42515
+ );
42516
+ if (adapterProviderSessionId) {
42517
+ this.promoteProviderSessionId(adapterProviderSessionId);
42518
+ }
42448
42519
  const parsedStatus = null;
42449
42520
  const rawStatus = adapterStatus.status;
42450
42521
  const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, now);
@@ -42526,6 +42597,29 @@ ${effect.notification.body || ""}`.trim();
42526
42597
  }
42527
42598
  } else if (newStatus === "idle" && this.lastStatus === "starting") {
42528
42599
  this.pushEvent({ event: "agent:ready", chatTitle, timestamp: now });
42600
+ } else if (newStatus === "error") {
42601
+ if (this.generatingDebounceTimer) {
42602
+ clearTimeout(this.generatingDebounceTimer);
42603
+ this.generatingDebounceTimer = null;
42604
+ }
42605
+ this.generatingDebouncePending = null;
42606
+ if (this.completedDebounceTimer) {
42607
+ clearTimeout(this.completedDebounceTimer);
42608
+ this.completedDebounceTimer = null;
42609
+ }
42610
+ this.completedDebouncePending = null;
42611
+ this.errorMessage = adapterStatus.errorMessage || this.errorMessage;
42612
+ this.errorReason = adapterStatus.errorReason || this.errorReason;
42613
+ this.pushEvent({
42614
+ event: "agent:stopped",
42615
+ chatTitle,
42616
+ timestamp: now,
42617
+ finalSummary: adapterStatus.errorMessage || adapterStatus.errorReason || "Provider reported an error",
42618
+ completionDiagnostic: {
42619
+ reason: adapterStatus.errorReason || "provider_error",
42620
+ errorMessage: adapterStatus.errorMessage || void 0
42621
+ }
42622
+ });
42529
42623
  } else if (newStatus === "stopped") {
42530
42624
  if (this.generatingDebounceTimer) {
42531
42625
  clearTimeout(this.generatingDebounceTimer);