@adhdev/daemon-core 0.9.82-rc.402 → 0.9.82-rc.404

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.mjs CHANGED
@@ -394,10 +394,10 @@ function readInjected(value) {
394
394
  }
395
395
  function getDaemonBuildInfo() {
396
396
  if (cached) return cached;
397
- const commit = readInjected(true ? "93b00efeec1fccd6550c1faf5fa838106caef4bb" : void 0) ?? "unknown";
398
- const commitShort = readInjected(true ? "93b00efe" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
399
- const version = readInjected(true ? "0.9.82-rc.402" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
400
- const builtAt = readInjected(true ? "2026-06-27T16:41:05.513Z" : void 0);
397
+ const commit = readInjected(true ? "056bddcd4112e4c90d82fdaab60557ccc7acf2a3" : void 0) ?? "unknown";
398
+ const commitShort = readInjected(true ? "056bddcd" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
399
+ const version = readInjected(true ? "0.9.82-rc.404" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
400
+ const builtAt = readInjected(true ? "2026-06-27T19:00:01.532Z" : void 0);
401
401
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
402
402
  return cached;
403
403
  }
@@ -39310,6 +39310,7 @@ var COMPLETED_FINALIZATION_RETRY_MS = 1e3;
39310
39310
  var COMPLETED_FINALIZATION_MAX_WAIT_MS = 3e4;
39311
39311
  var NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4e3;
39312
39312
  var USER_INPUT_ACK_DEDUP_WINDOW_MS = 6e4;
39313
+ var STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS = 12e3;
39313
39314
  var TERMINAL_MESH_EVENTS = /* @__PURE__ */ new Set([
39314
39315
  "agent:generating_completed",
39315
39316
  "agent:stopped",
@@ -39575,6 +39576,13 @@ var CliProviderInstance = class _CliProviderInstance {
39575
39576
  // first sets it; the other becomes a no-op.
39576
39577
  agentReadyEmitted = false;
39577
39578
  generatingStartedAt = 0;
39579
+ // GENERATING-BOUNDARY (R4b): the per-turn taskId for which a startup-grace
39580
+ // started+completed pair was already synthesized. Both fast-collapse callers
39581
+ // (starting→idle transition AND the idle-stayed no-status-change poll) route
39582
+ // through maybeSynthesizeStartupGraceCollapse; the idle-stayed caller re-polls
39583
+ // steadily while the session sits idle, so this guard makes the synthesis fire
39584
+ // AT MOST ONCE per collapsed turn.
39585
+ fastCollapseSynthesizedTaskId = null;
39578
39586
  settings = {};
39579
39587
  monitor;
39580
39588
  generatingDebounceTimer = null;
@@ -40701,6 +40709,73 @@ var CliProviderInstance = class _CliProviderInstance {
40701
40709
  this.agentReadyEmitted = true;
40702
40710
  this.pushEvent({ event: "agent:ready", chatTitle, timestamp: now });
40703
40711
  }
40712
+ /**
40713
+ * GENERATING-BOUNDARY synthetic emit for a first turn that started AND finished
40714
+ * inside the startup-grace window without the FSM ever observing a 'generating'
40715
+ * frame (an unobservably-fast turn). Synthesizes the agent:generating_started +
40716
+ * agent:generating_completed pair so the mesh coordinator learns the worker went
40717
+ * idle. Returns true iff it synthesized.
40718
+ *
40719
+ * Two callers share this defense line:
40720
+ * - 'startup_grace_fast_collapse' — the starting→idle transition (the FSM whose
40721
+ * spec lacks/hadn't-synced the starting→busy edge collapses starting→idle
40722
+ * directly, with no intervening 'generating' frame).
40723
+ * - 'startup_grace_idle_turn_collapse' — the idle→idle no-status-change poll
40724
+ * (the launch settle already drained starting→idle BEFORE the first turn, so
40725
+ * the turn runs+completes while status stays 'idle' the whole time and
40726
+ * detectStatusTransition never re-enters its change block — the live rc.403
40727
+ * Probe1 miss).
40728
+ *
40729
+ * False-positive safety (must NOT fire on a benign boot): currentTurnTaskId is
40730
+ * set ONLY by onTurnStarted (a real turn STARTED this boot) and persists past
40731
+ * completion, so it excludes a true idle boot (null) and a queued-pending first
40732
+ * turn that only runs after grace (onTurnStarted not yet called → null).
40733
+ * !hasAdapterPendingResponse() excludes a turn still mid-flight. generating
40734
+ * never armed (generatingStartedAt===0 && !generatingDebouncePending) means the
40735
+ * whole idle→busy→idle never happened for this turn. The once-per-turn guard
40736
+ * (fastCollapseSynthesizedTaskId) keeps the re-polled idle-stayed caller from
40737
+ * re-emitting every poll.
40738
+ */
40739
+ maybeSynthesizeStartupGraceCollapse(chatTitle, now, reason) {
40740
+ const startedTurnTaskId = typeof this.adapter?.currentTurnTaskId === "string" && this.adapter.currentTurnTaskId.trim() ? this.adapter.currentTurnTaskId : void 0;
40741
+ const fastCollapsed = !!startedTurnTaskId && !this.hasAdapterPendingResponse() && !this.generatingStartedAt && !this.generatingDebouncePending;
40742
+ if (!fastCollapsed) return false;
40743
+ if (this.fastCollapseSynthesizedTaskId === startedTurnTaskId) return false;
40744
+ let fcFinalSummary;
40745
+ let fcEvidenceSource = "unavailable";
40746
+ try {
40747
+ const parsedMessages = this.adapter?.getScriptParsedStatus()?.messages;
40748
+ const evidence = this.completionFinalAssistantEvidence(parsedMessages);
40749
+ fcEvidenceSource = evidence.source;
40750
+ fcFinalSummary = extractFinalSummaryFromMessages(evidence.messages);
40751
+ } catch {
40752
+ }
40753
+ const missingEvidence = (this.provider.requiresFinalAssistantBeforeIdle === true || fcEvidenceSource === "external-native") && !fcFinalSummary;
40754
+ const hasMeshContext = !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.launchedByCoordinator);
40755
+ if (missingEvidence && !hasMeshContext) {
40756
+ LOG.info("CLI", `[${this.type}] ${reason} suppressed: missing final assistant evidence, no mesh context (source=${fcEvidenceSource})`);
40757
+ return false;
40758
+ }
40759
+ this.fastCollapseSynthesizedTaskId = startedTurnTaskId;
40760
+ LOG.info("CLI", `[${this.type}] ${reason}: synthesizing started+completed (taskId=${startedTurnTaskId} source=${fcEvidenceSource} hadFinalSummary=${!!fcFinalSummary})`);
40761
+ this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
40762
+ if (this.isMeshWorkerSession()) {
40763
+ traceMeshEventStage("fired", this.meshTraceCtx(), `${reason} (source=${fcEvidenceSource})`);
40764
+ }
40765
+ this.pushEvent({
40766
+ event: "agent:generating_completed",
40767
+ chatTitle,
40768
+ duration: 0,
40769
+ timestamp: now,
40770
+ finalSummary: fcFinalSummary,
40771
+ completionDiagnostic: {
40772
+ reason,
40773
+ finalAssistantEvidenceSource: fcEvidenceSource,
40774
+ ...missingEvidence ? { blockReason: "missing_final_assistant" } : {}
40775
+ }
40776
+ });
40777
+ return true;
40778
+ }
40704
40779
  detectStatusTransition() {
40705
40780
  const now = Date.now();
40706
40781
  const adapterStatus = this.adapter.getStatus({ allowParse: false });
@@ -40859,6 +40934,7 @@ var CliProviderInstance = class _CliProviderInstance {
40859
40934
  }
40860
40935
  } else if (newStatus === "idle" && this.lastStatus === "starting") {
40861
40936
  this.emitAgentReadyOnce(chatTitle, now);
40937
+ this.maybeSynthesizeStartupGraceCollapse(chatTitle, now, "startup_grace_fast_collapse");
40862
40938
  } else if (newStatus === "error") {
40863
40939
  if (this.generatingDebounceTimer) {
40864
40940
  clearTimeout(this.generatingDebounceTimer);
@@ -40897,6 +40973,9 @@ var CliProviderInstance = class _CliProviderInstance {
40897
40973
  }
40898
40974
  this.lastStatus = newStatus;
40899
40975
  }
40976
+ if (newStatus === "idle" && previousStatus === "idle" && now - this.startedAt < STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS) {
40977
+ this.maybeSynthesizeStartupGraceCollapse(chatTitle, now, "startup_grace_idle_turn_collapse");
40978
+ }
40900
40979
  if (newStatus === "idle" && adapterStatus.fsmReadySeen === true && !this.agentReadyEmitted) {
40901
40980
  this.emitAgentReadyOnce(chatTitle, now);
40902
40981
  }