@adhdev/daemon-core 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.
@@ -174,6 +174,9 @@ export declare class ProviderCliAdapter implements CliAdapter {
174
174
  private runParseApproval;
175
175
  private hasActionableApproval;
176
176
  private parsedStatusHasFinalAssistantMessage;
177
+ private parsedStatusHasFinalStandardAssistantMessage;
178
+ private shouldKeepCodexTurnOpenForFinish;
179
+ private rescheduleCodexFinishCheck;
177
180
  private projectEffectiveStatus;
178
181
  getStatus(options?: {
179
182
  allowParse?: boolean;
package/dist/index.js CHANGED
@@ -5615,6 +5615,11 @@ ${lastSnapshot}`;
5615
5615
  this.idleTimeout = setTimeout(() => {
5616
5616
  if (this.isWaitingForResponse && !this.hasActionableApproval()) {
5617
5617
  if (this.shouldDeferIdleTimeoutFinish()) return;
5618
+ const parsed = this.runParseSession();
5619
+ if (this.shouldKeepCodexTurnOpenForFinish(parsed)) {
5620
+ this.rescheduleCodexFinishCheck("codex_idle_timeout_not_final");
5621
+ return;
5622
+ }
5618
5623
  this.clearIdleFinishCandidate("idle_timeout_finish");
5619
5624
  this.finishResponse();
5620
5625
  }
@@ -5623,6 +5628,11 @@ ${lastSnapshot}`;
5623
5628
  finishResponse() {
5624
5629
  if (this.submitPendingUntil > Date.now()) return;
5625
5630
  if (this.responseSettleIgnoreUntil > Date.now()) return;
5631
+ const parsedBeforeFinish = this.runParseSession();
5632
+ if (this.shouldKeepCodexTurnOpenForFinish(parsedBeforeFinish)) {
5633
+ this.rescheduleCodexFinishCheck("codex_finish_not_final");
5634
+ return;
5635
+ }
5626
5636
  this.clearIdleFinishCandidate("finish_response_enter");
5627
5637
  this.recordTrace("finish_response", {
5628
5638
  ...buildCliTraceParseSnapshot({
@@ -5838,6 +5848,44 @@ ${lastSnapshot}`;
5838
5848
  });
5839
5849
  return !!lastAssistant;
5840
5850
  }
5851
+ parsedStatusHasFinalStandardAssistantMessage(parsed) {
5852
+ const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
5853
+ const lastAssistant = [...messages].reverse().find((message) => {
5854
+ if (!message || message.role !== "assistant") return false;
5855
+ return typeof message.content === "string" && message.content.trim().length > 0;
5856
+ });
5857
+ if (!lastAssistant) return false;
5858
+ const kind = typeof lastAssistant.kind === "string" && lastAssistant.kind.trim() ? lastAssistant.kind.trim() : "standard";
5859
+ return kind === "standard" && lastAssistant.meta?.streaming !== true;
5860
+ }
5861
+ shouldKeepCodexTurnOpenForFinish(parsed) {
5862
+ if (this.cliType !== "codex-cli") return false;
5863
+ if (!this.isWaitingForResponse || !this.currentTurnScope || this.hasActionableApproval()) return false;
5864
+ const parsedStatus = typeof parsed?.status === "string" ? parsed.status.trim() : "";
5865
+ if (parsedStatus !== "idle") return true;
5866
+ if (parsed?.activeModal || parsed?.modal) return true;
5867
+ return !this.parsedStatusHasFinalStandardAssistantMessage(parsed);
5868
+ }
5869
+ rescheduleCodexFinishCheck(reason) {
5870
+ this.clearIdleFinishCandidate(reason);
5871
+ this.setStatus("generating", reason);
5872
+ if (this.idleTimeout) clearTimeout(this.idleTimeout);
5873
+ this.idleTimeout = setTimeout(() => {
5874
+ if (!this.isWaitingForResponse || this.hasActionableApproval()) return;
5875
+ this.settledBuffer = this.recentOutputBuffer;
5876
+ this.evaluateSettled();
5877
+ }, this.getIdleFinishConfirmMs());
5878
+ this.recordTrace("codex_finish_deferred", {
5879
+ reason,
5880
+ ...buildCliTraceParseSnapshot({
5881
+ accumulatedBuffer: this.accumulatedBuffer,
5882
+ accumulatedRawBuffer: this.accumulatedRawBuffer,
5883
+ responseBuffer: this.responseBuffer,
5884
+ partialResponse: this.responseBuffer,
5885
+ scope: this.currentTurnScope
5886
+ })
5887
+ });
5888
+ }
5841
5889
  projectEffectiveStatus(startupModal = null) {
5842
5890
  if (this.parseErrorMessage) return "error";
5843
5891
  if (this.hasActionableApproval(startupModal)) return "waiting_approval";
@@ -5915,6 +5963,8 @@ ${lastSnapshot}`;
5915
5963
  }),
5916
5964
  activeModal,
5917
5965
  providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
5966
+ errorMessage: typeof parsed.errorMessage === "string" && parsed.errorMessage.trim() ? parsed.errorMessage.trim() : void 0,
5967
+ errorReason: typeof parsed.errorReason === "string" && parsed.errorReason.trim() ? parsed.errorReason.trim() : void 0,
5918
5968
  ...bufferState ? { bufferState } : {},
5919
5969
  ...parsed.transcriptAuthority === "provider" || parsed.transcriptAuthority === "daemon" ? { transcriptAuthority: parsed.transcriptAuthority } : this.providerOwnsTranscript() ? { transcriptAuthority: "provider" } : {},
5920
5970
  ...parsed.coverage === "full" || parsed.coverage === "tail" || parsed.coverage === "current-turn" ? { coverage: parsed.coverage } : this.providerOwnsTranscript() ? { coverage: this.shouldUseFullProviderTranscriptContext() ? "full" : "tail" } : {}
@@ -6718,6 +6768,9 @@ ${lastSnapshot}`;
6718
6768
  const parsedDebugState = this.getParsedDebugState();
6719
6769
  const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
6720
6770
  let effectiveStatus = this.projectEffectiveStatus(startupModal);
6771
+ if (parsedDebugState?.status === "error") {
6772
+ effectiveStatus = "error";
6773
+ }
6721
6774
  if (startupDetectedStatus === "waiting_approval") {
6722
6775
  effectiveStatus = "waiting_approval";
6723
6776
  }
@@ -6745,6 +6798,8 @@ ${lastSnapshot}`;
6745
6798
  providerSessionId: parsedDebugState.providerSessionId,
6746
6799
  transcriptAuthority: parsedDebugState.transcriptAuthority,
6747
6800
  coverage: parsedDebugState.coverage,
6801
+ errorMessage: parsedDebugState.errorMessage,
6802
+ errorReason: parsedDebugState.errorReason,
6748
6803
  activeModal: parsedDebugState.activeModal,
6749
6804
  messageCount: parsedMessages.length
6750
6805
  } : null,
@@ -19949,8 +20004,10 @@ var CliProviderInstance = class {
19949
20004
  if (typeof this.adapter.getScriptParsedStatus === "function") {
19950
20005
  try {
19951
20006
  parsedStatus = this.adapter.getScriptParsedStatus() || null;
19952
- this.errorMessage = void 0;
19953
- this.errorReason = void 0;
20007
+ const parsedErrorMessage = typeof parsedStatus?.errorMessage === "string" && parsedStatus.errorMessage.trim() ? parsedStatus.errorMessage.trim() : void 0;
20008
+ const parsedErrorReason = typeof parsedStatus?.errorReason === "string" && parsedStatus.errorReason.trim() ? parsedStatus.errorReason.trim() : void 0;
20009
+ this.errorMessage = parsedErrorMessage;
20010
+ this.errorReason = parsedErrorReason;
19954
20011
  } catch (error) {
19955
20012
  parseErrorMessage = error?.message || String(error);
19956
20013
  this.errorMessage = parseErrorMessage;
@@ -19961,7 +20018,7 @@ var CliProviderInstance = class {
19961
20018
  this.errorReason = void 0;
19962
20019
  }
19963
20020
  const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
19964
- const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
20021
+ const visibleStatus = parseErrorMessage || parsedStatus?.status === "error" ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
19965
20022
  const parsedProviderSessionId = normalizeProviderSessionId(
19966
20023
  this.provider,
19967
20024
  typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""