@adhdev/daemon-standalone 0.9.82-rc.100 → 0.9.82-rc.101

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
@@ -27773,6 +27773,11 @@ ${lastSnapshot}`;
27773
27773
  this.idleTimeout = setTimeout(() => {
27774
27774
  if (this.isWaitingForResponse && !this.hasActionableApproval()) {
27775
27775
  if (this.shouldDeferIdleTimeoutFinish()) return;
27776
+ const parsed = this.runParseSession();
27777
+ if (this.shouldKeepCodexTurnOpenForFinish(parsed)) {
27778
+ this.rescheduleCodexFinishCheck("codex_idle_timeout_not_final");
27779
+ return;
27780
+ }
27776
27781
  this.clearIdleFinishCandidate("idle_timeout_finish");
27777
27782
  this.finishResponse();
27778
27783
  }
@@ -27781,6 +27786,11 @@ ${lastSnapshot}`;
27781
27786
  finishResponse() {
27782
27787
  if (this.submitPendingUntil > Date.now()) return;
27783
27788
  if (this.responseSettleIgnoreUntil > Date.now()) return;
27789
+ const parsedBeforeFinish = this.runParseSession();
27790
+ if (this.shouldKeepCodexTurnOpenForFinish(parsedBeforeFinish)) {
27791
+ this.rescheduleCodexFinishCheck("codex_finish_not_final");
27792
+ return;
27793
+ }
27784
27794
  this.clearIdleFinishCandidate("finish_response_enter");
27785
27795
  this.recordTrace("finish_response", {
27786
27796
  ...buildCliTraceParseSnapshot({
@@ -27996,6 +28006,44 @@ ${lastSnapshot}`;
27996
28006
  });
27997
28007
  return !!lastAssistant;
27998
28008
  }
28009
+ parsedStatusHasFinalStandardAssistantMessage(parsed) {
28010
+ const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
28011
+ const lastAssistant = [...messages].reverse().find((message) => {
28012
+ if (!message || message.role !== "assistant") return false;
28013
+ return typeof message.content === "string" && message.content.trim().length > 0;
28014
+ });
28015
+ if (!lastAssistant) return false;
28016
+ const kind = typeof lastAssistant.kind === "string" && lastAssistant.kind.trim() ? lastAssistant.kind.trim() : "standard";
28017
+ return kind === "standard" && lastAssistant.meta?.streaming !== true;
28018
+ }
28019
+ shouldKeepCodexTurnOpenForFinish(parsed) {
28020
+ if (this.cliType !== "codex-cli") return false;
28021
+ if (!this.isWaitingForResponse || !this.currentTurnScope || this.hasActionableApproval()) return false;
28022
+ const parsedStatus = typeof parsed?.status === "string" ? parsed.status.trim() : "";
28023
+ if (parsedStatus !== "idle") return true;
28024
+ if (parsed?.activeModal || parsed?.modal) return true;
28025
+ return !this.parsedStatusHasFinalStandardAssistantMessage(parsed);
28026
+ }
28027
+ rescheduleCodexFinishCheck(reason) {
28028
+ this.clearIdleFinishCandidate(reason);
28029
+ this.setStatus("generating", reason);
28030
+ if (this.idleTimeout) clearTimeout(this.idleTimeout);
28031
+ this.idleTimeout = setTimeout(() => {
28032
+ if (!this.isWaitingForResponse || this.hasActionableApproval()) return;
28033
+ this.settledBuffer = this.recentOutputBuffer;
28034
+ this.evaluateSettled();
28035
+ }, this.getIdleFinishConfirmMs());
28036
+ this.recordTrace("codex_finish_deferred", {
28037
+ reason,
28038
+ ...buildCliTraceParseSnapshot({
28039
+ accumulatedBuffer: this.accumulatedBuffer,
28040
+ accumulatedRawBuffer: this.accumulatedRawBuffer,
28041
+ responseBuffer: this.responseBuffer,
28042
+ partialResponse: this.responseBuffer,
28043
+ scope: this.currentTurnScope
28044
+ })
28045
+ });
28046
+ }
27999
28047
  projectEffectiveStatus(startupModal = null) {
28000
28048
  if (this.parseErrorMessage) return "error";
28001
28049
  if (this.hasActionableApproval(startupModal)) return "waiting_approval";
@@ -28073,6 +28121,8 @@ ${lastSnapshot}`;
28073
28121
  }),
28074
28122
  activeModal,
28075
28123
  providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
28124
+ errorMessage: typeof parsed.errorMessage === "string" && parsed.errorMessage.trim() ? parsed.errorMessage.trim() : void 0,
28125
+ errorReason: typeof parsed.errorReason === "string" && parsed.errorReason.trim() ? parsed.errorReason.trim() : void 0,
28076
28126
  ...bufferState ? { bufferState } : {},
28077
28127
  ...parsed.transcriptAuthority === "provider" || parsed.transcriptAuthority === "daemon" ? { transcriptAuthority: parsed.transcriptAuthority } : this.providerOwnsTranscript() ? { transcriptAuthority: "provider" } : {},
28078
28128
  ...parsed.coverage === "full" || parsed.coverage === "tail" || parsed.coverage === "current-turn" ? { coverage: parsed.coverage } : this.providerOwnsTranscript() ? { coverage: this.shouldUseFullProviderTranscriptContext() ? "full" : "tail" } : {}
@@ -28876,6 +28926,9 @@ ${lastSnapshot}`;
28876
28926
  const parsedDebugState = this.getParsedDebugState();
28877
28927
  const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
28878
28928
  let effectiveStatus = this.projectEffectiveStatus(startupModal);
28929
+ if (parsedDebugState?.status === "error") {
28930
+ effectiveStatus = "error";
28931
+ }
28879
28932
  if (startupDetectedStatus === "waiting_approval") {
28880
28933
  effectiveStatus = "waiting_approval";
28881
28934
  }
@@ -28903,6 +28956,8 @@ ${lastSnapshot}`;
28903
28956
  providerSessionId: parsedDebugState.providerSessionId,
28904
28957
  transcriptAuthority: parsedDebugState.transcriptAuthority,
28905
28958
  coverage: parsedDebugState.coverage,
28959
+ errorMessage: parsedDebugState.errorMessage,
28960
+ errorReason: parsedDebugState.errorReason,
28906
28961
  activeModal: parsedDebugState.activeModal,
28907
28962
  messageCount: parsedMessages.length
28908
28963
  } : null,
@@ -41957,8 +42012,10 @@ ${effect.notification.body || ""}`.trim();
41957
42012
  if (typeof this.adapter.getScriptParsedStatus === "function") {
41958
42013
  try {
41959
42014
  parsedStatus = this.adapter.getScriptParsedStatus() || null;
41960
- this.errorMessage = void 0;
41961
- this.errorReason = void 0;
42015
+ const parsedErrorMessage = typeof parsedStatus?.errorMessage === "string" && parsedStatus.errorMessage.trim() ? parsedStatus.errorMessage.trim() : void 0;
42016
+ const parsedErrorReason = typeof parsedStatus?.errorReason === "string" && parsedStatus.errorReason.trim() ? parsedStatus.errorReason.trim() : void 0;
42017
+ this.errorMessage = parsedErrorMessage;
42018
+ this.errorReason = parsedErrorReason;
41962
42019
  } catch (error48) {
41963
42020
  parseErrorMessage = error48?.message || String(error48);
41964
42021
  this.errorMessage = parseErrorMessage;
@@ -41969,7 +42026,7 @@ ${effect.notification.body || ""}`.trim();
41969
42026
  this.errorReason = void 0;
41970
42027
  }
41971
42028
  const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
41972
- const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
42029
+ const visibleStatus = parseErrorMessage || parsedStatus?.status === "error" ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
41973
42030
  const parsedProviderSessionId = normalizeProviderSessionId(
41974
42031
  this.provider,
41975
42032
  typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""