@adhdev/daemon-standalone 0.9.82-rc.403 → 0.9.82-rc.405

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
@@ -30127,10 +30127,10 @@ var require_dist3 = __commonJS({
30127
30127
  }
30128
30128
  function getDaemonBuildInfo() {
30129
30129
  if (cached2) return cached2;
30130
- const commit = readInjected(true ? "9522954406c86758c979231d4f96b280d09efd7a" : void 0) ?? "unknown";
30131
- const commitShort = readInjected(true ? "95229544" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30132
- const version2 = readInjected(true ? "0.9.82-rc.403" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30133
- const builtAt = readInjected(true ? "2026-06-27T17:54:31.546Z" : void 0);
30130
+ const commit = readInjected(true ? "4e4b5f468d194f630073a66359898bce97fadf4b" : void 0) ?? "unknown";
30131
+ const commitShort = readInjected(true ? "4e4b5f46" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30132
+ const version2 = readInjected(true ? "0.9.82-rc.405" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30133
+ const builtAt = readInjected(true ? "2026-06-28T03:55:26.092Z" : void 0);
30134
30134
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30135
30135
  return cached2;
30136
30136
  }
@@ -69336,6 +69336,7 @@ ${body}
69336
69336
  var COMPLETED_FINALIZATION_MAX_WAIT_MS = 3e4;
69337
69337
  var NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4e3;
69338
69338
  var USER_INPUT_ACK_DEDUP_WINDOW_MS = 6e4;
69339
+ var STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS = 12e3;
69339
69340
  var TERMINAL_MESH_EVENTS = /* @__PURE__ */ new Set([
69340
69341
  "agent:generating_completed",
69341
69342
  "agent:stopped",
@@ -69601,6 +69602,23 @@ ${body}
69601
69602
  // first sets it; the other becomes a no-op.
69602
69603
  agentReadyEmitted = false;
69603
69604
  generatingStartedAt = 0;
69605
+ // GENERATING-BOUNDARY (R4b): the per-turn taskId for which a startup-grace
69606
+ // started+completed pair was already synthesized. Both fast-collapse callers
69607
+ // (starting→idle transition AND the idle-stayed no-status-change poll) route
69608
+ // through maybeSynthesizeStartupGraceCollapse; the idle-stayed caller re-polls
69609
+ // steadily while the session sits idle, so this guard makes the synthesis fire
69610
+ // AT MOST ONCE per collapsed turn.
69611
+ fastCollapseSynthesizedTaskId = null;
69612
+ // GENERATING-BOUNDARY (R4c): the wall-clock moment the FSM's starting→idle
69613
+ // startup-grace collapse was observed (set ONCE, on the first starting→idle
69614
+ // transition this boot). The idle-stayed collapse window is anchored on THIS,
69615
+ // not on instance/boot time (this.startedAt): the FSM spends the full 8s
69616
+ // startup-grace sitting in 'starting' before collapsing, and a turn can be
69617
+ // dispatched a few seconds AFTER the collapse — measuring the window from boot
69618
+ // would have it already closed by the time that turn lands+completes (the live
69619
+ // R4b miss: collapse at boot+8s, dispatch at boot+12.4s > the 12s boot window).
69620
+ // Anchoring on the collapse moment makes the window cover dispatch-delay+turn.
69621
+ startupGraceCollapseAt = null;
69604
69622
  settings = {};
69605
69623
  monitor;
69606
69624
  generatingDebounceTimer = null;
@@ -70727,6 +70745,73 @@ ${body}
70727
70745
  this.agentReadyEmitted = true;
70728
70746
  this.pushEvent({ event: "agent:ready", chatTitle, timestamp: now });
70729
70747
  }
70748
+ /**
70749
+ * GENERATING-BOUNDARY synthetic emit for a first turn that started AND finished
70750
+ * inside the startup-grace window without the FSM ever observing a 'generating'
70751
+ * frame (an unobservably-fast turn). Synthesizes the agent:generating_started +
70752
+ * agent:generating_completed pair so the mesh coordinator learns the worker went
70753
+ * idle. Returns true iff it synthesized.
70754
+ *
70755
+ * Two callers share this defense line:
70756
+ * - 'startup_grace_fast_collapse' — the starting→idle transition (the FSM whose
70757
+ * spec lacks/hadn't-synced the starting→busy edge collapses starting→idle
70758
+ * directly, with no intervening 'generating' frame).
70759
+ * - 'startup_grace_idle_turn_collapse' — the idle→idle no-status-change poll
70760
+ * (the launch settle already drained starting→idle BEFORE the first turn, so
70761
+ * the turn runs+completes while status stays 'idle' the whole time and
70762
+ * detectStatusTransition never re-enters its change block — the live rc.403
70763
+ * Probe1 miss).
70764
+ *
70765
+ * False-positive safety (must NOT fire on a benign boot): currentTurnTaskId is
70766
+ * set ONLY by onTurnStarted (a real turn STARTED this boot) and persists past
70767
+ * completion, so it excludes a true idle boot (null) and a queued-pending first
70768
+ * turn that only runs after grace (onTurnStarted not yet called → null).
70769
+ * !hasAdapterPendingResponse() excludes a turn still mid-flight. generating
70770
+ * never armed (generatingStartedAt===0 && !generatingDebouncePending) means the
70771
+ * whole idle→busy→idle never happened for this turn. The once-per-turn guard
70772
+ * (fastCollapseSynthesizedTaskId) keeps the re-polled idle-stayed caller from
70773
+ * re-emitting every poll.
70774
+ */
70775
+ maybeSynthesizeStartupGraceCollapse(chatTitle, now, reason) {
70776
+ const startedTurnTaskId = typeof this.adapter?.currentTurnTaskId === "string" && this.adapter.currentTurnTaskId.trim() ? this.adapter.currentTurnTaskId : void 0;
70777
+ const fastCollapsed = !!startedTurnTaskId && !this.hasAdapterPendingResponse() && !this.generatingStartedAt && !this.generatingDebouncePending;
70778
+ if (!fastCollapsed) return false;
70779
+ if (this.fastCollapseSynthesizedTaskId === startedTurnTaskId) return false;
70780
+ let fcFinalSummary;
70781
+ let fcEvidenceSource = "unavailable";
70782
+ try {
70783
+ const parsedMessages = this.adapter?.getScriptParsedStatus()?.messages;
70784
+ const evidence = this.completionFinalAssistantEvidence(parsedMessages);
70785
+ fcEvidenceSource = evidence.source;
70786
+ fcFinalSummary = extractFinalSummaryFromMessages(evidence.messages);
70787
+ } catch {
70788
+ }
70789
+ const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || fcEvidenceSource === "external-native") && !fcFinalSummary;
70790
+ const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
70791
+ if (missingEvidence && !hasMeshContext) {
70792
+ LOG2.info("CLI", `[${this.type}] ${reason} suppressed: missing final assistant evidence, no mesh context (source=${fcEvidenceSource})`);
70793
+ return false;
70794
+ }
70795
+ this.fastCollapseSynthesizedTaskId = startedTurnTaskId;
70796
+ LOG2.info("CLI", `[${this.type}] ${reason}: synthesizing started+completed (taskId=${startedTurnTaskId} source=${fcEvidenceSource} hadFinalSummary=${!!fcFinalSummary})`);
70797
+ this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
70798
+ if (this.isMeshWorkerSession()) {
70799
+ traceMeshEventStage("fired", this.meshTraceCtx(), `${reason} (source=${fcEvidenceSource})`);
70800
+ }
70801
+ this.pushEvent({
70802
+ event: "agent:generating_completed",
70803
+ chatTitle,
70804
+ duration: 0,
70805
+ timestamp: now,
70806
+ finalSummary: fcFinalSummary,
70807
+ completionDiagnostic: {
70808
+ reason,
70809
+ finalAssistantEvidenceSource: fcEvidenceSource,
70810
+ ...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
70811
+ }
70812
+ });
70813
+ return true;
70814
+ }
70730
70815
  detectStatusTransition() {
70731
70816
  const now = Date.now();
70732
70817
  const adapterStatus = this.adapter.getStatus({ allowParse: false });
@@ -70885,42 +70970,8 @@ ${body}
70885
70970
  }
70886
70971
  } else if (newStatus === "idle" && this.lastStatus === "starting") {
70887
70972
  this.emitAgentReadyOnce(chatTitle, now);
70888
- const startedTurnTaskId = typeof this.adapter?.currentTurnTaskId === "string" && this.adapter.currentTurnTaskId.trim() ? this.adapter.currentTurnTaskId : void 0;
70889
- const fastCollapsed = !!startedTurnTaskId && !this.hasAdapterPendingResponse() && !this.generatingStartedAt && !this.generatingDebouncePending;
70890
- if (fastCollapsed) {
70891
- let fcFinalSummary;
70892
- let fcEvidenceSource = "unavailable";
70893
- try {
70894
- const parsedMessages = this.adapter?.getScriptParsedStatus()?.messages;
70895
- const evidence = this.completionFinalAssistantEvidence(parsedMessages);
70896
- fcEvidenceSource = evidence.source;
70897
- fcFinalSummary = extractFinalSummaryFromMessages(evidence.messages);
70898
- } catch {
70899
- }
70900
- const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || fcEvidenceSource === "external-native") && !fcFinalSummary;
70901
- const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
70902
- if (missingEvidence && !hasMeshContext) {
70903
- LOG2.info("CLI", `[${this.type}] startup-grace fast-collapse suppressed: missing final assistant evidence, no mesh context (source=${fcEvidenceSource})`);
70904
- } else {
70905
- LOG2.info("CLI", `[${this.type}] startup-grace fast-collapse: synthesizing started+completed (taskId=${startedTurnTaskId} source=${fcEvidenceSource} hadFinalSummary=${!!fcFinalSummary})`);
70906
- this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
70907
- if (this.isMeshWorkerSession()) {
70908
- traceMeshEventStage("fired", this.meshTraceCtx(), `startup-grace fast-collapse (source=${fcEvidenceSource})`);
70909
- }
70910
- this.pushEvent({
70911
- event: "agent:generating_completed",
70912
- chatTitle,
70913
- duration: 0,
70914
- timestamp: now,
70915
- finalSummary: fcFinalSummary,
70916
- completionDiagnostic: {
70917
- reason: "startup_grace_fast_collapse",
70918
- finalAssistantEvidenceSource: fcEvidenceSource,
70919
- ...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
70920
- }
70921
- });
70922
- }
70923
- }
70973
+ if (this.startupGraceCollapseAt === null) this.startupGraceCollapseAt = now;
70974
+ this.maybeSynthesizeStartupGraceCollapse(chatTitle, now, "startup_grace_fast_collapse");
70924
70975
  } else if (newStatus === "error") {
70925
70976
  if (this.generatingDebounceTimer) {
70926
70977
  clearTimeout(this.generatingDebounceTimer);
@@ -70959,6 +71010,9 @@ ${body}
70959
71010
  }
70960
71011
  this.lastStatus = newStatus;
70961
71012
  }
71013
+ if (newStatus === "idle" && previousStatus === "idle" && this.startupGraceCollapseAt !== null && now - this.startupGraceCollapseAt < STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS) {
71014
+ this.maybeSynthesizeStartupGraceCollapse(chatTitle, now, "startup_grace_idle_turn_collapse");
71015
+ }
70962
71016
  if (newStatus === "idle" && adapterStatus.fsmReadySeen === true && !this.agentReadyEmitted) {
70963
71017
  this.emitAgentReadyOnce(chatTitle, now);
70964
71018
  }