@adhdev/daemon-standalone 1.0.49-rc.5 → 1.0.49-rc.7

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
@@ -37056,10 +37056,10 @@ var require_dist3 = __commonJS({
37056
37056
  }
37057
37057
  function getDaemonBuildInfo() {
37058
37058
  if (cached2) return cached2;
37059
- const commit = readInjected(true ? "0b3c203b7ae08f860c52a4dd7ee88edddd48d8cb" : void 0) ?? "unknown";
37060
- const commitShort = readInjected(true ? "0b3c203b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
37061
- const version2 = readInjected(true ? "1.0.49-rc.5" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
37062
- const builtAt = readInjected(true ? "2026-08-14T13:19:52.123Z" : void 0);
37059
+ const commit = readInjected(true ? "b4c4824f7d9b919bc149d6134c2e9720442d677c" : void 0) ?? "unknown";
37060
+ const commitShort = readInjected(true ? "b4c4824f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
37061
+ const version2 = readInjected(true ? "1.0.49-rc.7" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
37062
+ const builtAt = readInjected(true ? "2026-08-14T15:30:01.061Z" : void 0);
37063
37063
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
37064
37064
  return cached2;
37065
37065
  }
@@ -57767,10 +57767,23 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
57767
57767
  const reporterNowMs = Number(quota.updatedAt) + ageMs2;
57768
57768
  return resetsAt - reporterNowMs < imminentMs;
57769
57769
  }
57770
+ function isRetainedWindowTrustworthy(window, facts, quota, policy, now) {
57771
+ const resetsAt = Number(window?.resetsAt);
57772
+ if (!Number.isFinite(resetsAt) || resetsAt <= 0) {
57773
+ return isQuotaSnapshotFresh(facts, quota, policy, now);
57774
+ }
57775
+ const ageMs2 = quotaSnapshotAgeMs(facts, quota, now);
57776
+ if (!Number.isFinite(ageMs2)) return false;
57777
+ const reporterNowMs = Number(quota.updatedAt) + ageMs2;
57778
+ if (!Number.isFinite(reporterNowMs)) return false;
57779
+ return resetsAt > reporterNowMs;
57780
+ }
57770
57781
  function evaluateProviderQuotaGate(node, providerType, policy, now = Date.now(), context) {
57771
57782
  const entry = quotaEntryFor(node, providerType, context);
57772
57783
  if (!entry) return null;
57773
57784
  const { facts, quota } = entry;
57785
+ let sessionTrustworthy = true;
57786
+ let weeklyTrustworthy = true;
57774
57787
  if (quota.status !== "ok") {
57775
57788
  if (quota.status === "error" && quota.metadata?.failureKind === "quota-exhausted" && isQuotaSnapshotFresh(facts, quota, policy, now)) {
57776
57789
  return {
@@ -57780,15 +57793,15 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
57780
57793
  thresholdPercent: 0
57781
57794
  };
57782
57795
  }
57783
- if (quota.metadata?.lastGoodWindows !== true || !isQuotaSnapshotFresh(facts, quota, policy, now)) {
57784
- return null;
57785
- }
57796
+ if (quota.metadata?.lastGoodWindows !== true) return null;
57797
+ sessionTrustworthy = isRetainedWindowTrustworthy(quota.session, facts, quota, policy, now);
57798
+ weeklyTrustworthy = isRetainedWindowTrustworthy(quota.weekly, facts, quota, policy, now);
57786
57799
  } else if (!isQuotaSnapshotFresh(facts, quota, policy, now)) {
57787
57800
  return null;
57788
57801
  }
57789
57802
  const resolved = resolveQuotaRoutingPolicy(policy);
57790
57803
  const session = remainingPercent(quota.session);
57791
- if (session !== void 0 && session < resolved.sessionMinRemainingPercent && !isSessionResetImminent(quota.session, facts, quota, resolved.sessionResetImminentMs, now)) {
57804
+ if (sessionTrustworthy && session !== void 0 && session < resolved.sessionMinRemainingPercent && !isSessionResetImminent(quota.session, facts, quota, resolved.sessionResetImminentMs, now)) {
57792
57805
  return {
57793
57806
  reason: PROVIDER_QUOTA_SESSION_LOW_SKIP_REASON,
57794
57807
  window: "session",
@@ -57797,7 +57810,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
57797
57810
  };
57798
57811
  }
57799
57812
  const weekly = remainingPercent(quota.weekly);
57800
- if (weekly !== void 0 && weekly < resolved.weeklyMinRemainingPercent) {
57813
+ if (weeklyTrustworthy && weekly !== void 0 && weekly < resolved.weeklyMinRemainingPercent) {
57801
57814
  return {
57802
57815
  reason: PROVIDER_QUOTA_WEEKLY_LOW_SKIP_REASON,
57803
57816
  window: "weekly",
@@ -68835,6 +68848,17 @@ ${cleanBody}`;
68835
68848
  return void 0;
68836
68849
  }
68837
68850
  }
68851
+ function localGeneratingLabelIsContradicted(components, sessionId) {
68852
+ try {
68853
+ const probe = resolveLiveTurnPendingEvidence(components, sessionId);
68854
+ if (!probe) return false;
68855
+ if (probe()) return false;
68856
+ LOG2.info("MeshReconcile", `Session ${sessionId} reports FSM status 'generating' but its adapter has no live turn evidence \u2014 treating the label as stale so the early transcript-evidence rescue may evaluate it (the completion arm was likely orphaned by a continuity cancel)`);
68857
+ return true;
68858
+ } catch {
68859
+ return false;
68860
+ }
68861
+ }
68838
68862
  async function evaluateEarlyIdleTranscriptArm(components, mesh, store, row, localDaemonId, selfIds = []) {
68839
68863
  const sessionId = readNonEmptyString(row.assignedSessionId);
68840
68864
  if (!sessionId) return false;
@@ -68850,7 +68874,9 @@ ${cleanBody}`;
68850
68874
  }
68851
68875
  }
68852
68876
  const verdict = resolveSessionBusyVerdict(components, sessionId);
68853
- if (verdict === "GENERATING") return false;
68877
+ if (verdict === "GENERATING" && !localGeneratingLabelIsContradicted(components, sessionId)) {
68878
+ return false;
68879
+ }
68854
68880
  if (verdict === "UNKNOWN") {
68855
68881
  const nodeId = readNonEmptyString(row.assignedNodeId);
68856
68882
  const node = (mesh.nodes ?? []).find((n) => n.id === nodeId);
@@ -97067,6 +97093,8 @@ ${marker}`,
97067
97093
  var CANON_C_MISSING_ASSISTANT_MIN_ELAPSED_MS = 2e4;
97068
97094
  var MISSING_ASSISTANT_TRANSCRIPT_GROWTH_QUIET_MS = 6e4;
97069
97095
  var NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4e3;
97096
+ var CANCELLED_COMPLETION_RECHECK_MS = 1500;
97097
+ var CANCELLED_COMPLETION_RECHECK_MAX_ATTEMPTS = 4;
97070
97098
  var PTY_PARSED_FINAL_ASSISTANT_QUIET_DWELL_MS = 1200;
97071
97099
  var ANTIGRAVITY_HOLD_QUIET_DWELL_MS = 3e3;
97072
97100
  var ANTIGRAVITY_HOLD_HARD_CAP_MS = 5 * 6e4;
@@ -98616,6 +98644,64 @@ ${buttons.join("\n")}`;
98616
98644
  host.pushEvent({ event: me.type, agentKey: me.agentKey, message: me.message, elapsedSec: me.elapsedSec, timestamp: me.timestamp });
98617
98645
  }
98618
98646
  }
98647
+ init_logger();
98648
+ function armCancelledCompletionRecheck(host, pending, reason) {
98649
+ if (reason === "new_pty_output") return;
98650
+ const now = Date.now();
98651
+ const prior = host.cancelledCompletionRecheck;
98652
+ const carriedPending = prior?.pending ?? pending;
98653
+ const attempts = prior ? prior.attempts : 0;
98654
+ if (attempts >= CANCELLED_COMPLETION_RECHECK_MAX_ATTEMPTS) {
98655
+ clearCancelledCompletionRecheck(host);
98656
+ LOG2.debug("CLI", `[${host.type}] cancelled-completion recheck budget exhausted (${reason}) \u2014 deferring to the next FSM completion edge`);
98657
+ return;
98658
+ }
98659
+ host.cancelledCompletionRecheck = {
98660
+ pending: carriedPending,
98661
+ reason,
98662
+ attempts,
98663
+ firstCancelledAt: prior?.firstCancelledAt ?? now
98664
+ };
98665
+ if (host.cancelledCompletionRecheckTimer) clearTimeout(host.cancelledCompletionRecheckTimer);
98666
+ host.cancelledCompletionRecheckTimer = setTimeout(
98667
+ () => runCancelledCompletionRecheck(host),
98668
+ CANCELLED_COMPLETION_RECHECK_MS
98669
+ );
98670
+ }
98671
+ function clearCancelledCompletionRecheck(host) {
98672
+ if (host.cancelledCompletionRecheckTimer) {
98673
+ clearTimeout(host.cancelledCompletionRecheckTimer);
98674
+ host.cancelledCompletionRecheckTimer = null;
98675
+ }
98676
+ host.cancelledCompletionRecheck = null;
98677
+ }
98678
+ function runCancelledCompletionRecheck(host) {
98679
+ host.cancelledCompletionRecheckTimer = null;
98680
+ const watch3 = host.cancelledCompletionRecheck;
98681
+ if (!watch3) return;
98682
+ if (host.completedDebouncePending) {
98683
+ clearCancelledCompletionRecheck(host);
98684
+ return;
98685
+ }
98686
+ watch3.attempts += 1;
98687
+ LOG2.info("CLI", `[${host.type}] re-checking completion cancelled by ${watch3.reason} (attempt ${watch3.attempts}/${CANCELLED_COMPLETION_RECHECK_MAX_ATTEMPTS}, ${Date.now() - watch3.firstCancelledAt}ms since cancel)`);
98688
+ if (host.completionTraceOn()) host.recordCompletionGateTrace("cancel_recheck", {
98689
+ reason: watch3.reason,
98690
+ attempt: watch3.attempts,
98691
+ sinceCancelMs: Date.now() - watch3.firstCancelledAt,
98692
+ busyEpoch: host.busyEpoch
98693
+ });
98694
+ const lastOutputAt = host.adapter.getStatus({ allowParse: false })?.lastOutputAt;
98695
+ host.completedDebouncePending = {
98696
+ ...watch3.pending,
98697
+ busyEpochAtArm: host.busyEpoch,
98698
+ lastOutputAtArm: typeof lastOutputAt === "number" && Number.isFinite(lastOutputAt) ? lastOutputAt : watch3.pending.lastOutputAtArm
98699
+ };
98700
+ host.flushCompletedDebounceIfFinalized();
98701
+ if (host.cancelledCompletionRecheck === watch3 && host.completedDebouncePending) {
98702
+ clearCancelledCompletionRecheck(host);
98703
+ }
98704
+ }
98619
98705
  init_contracts2();
98620
98706
  var MAX_TRACKED_MESSAGES = 2e3;
98621
98707
  function hasUsableTimestamp(message) {
@@ -99775,11 +99861,20 @@ ${buttons.join("\n")}`;
99775
99861
  clearTimeout(this.autoApproveBusyTimer);
99776
99862
  this.autoApproveBusyTimer = null;
99777
99863
  }
99864
+ this.clearCancelledCompletionRecheck();
99778
99865
  this.appliedEffectKeys.clear();
99779
99866
  closeSqliteProbeCache(this.sqliteProbeCache);
99780
99867
  }
99781
99868
  completedDebounceTimer = null;
99782
99869
  completedDebouncePending = null;
99870
+ /**
99871
+ * (CANCEL-BLIP-ORPHAN) Re-verification watch for an arm the continuity cancel just
99872
+ * deleted — the cancelled arm's snapshot plus a bounded recheck budget, so a
99873
+ * sub-second PTY blip cannot permanently orphan the completion. Full rationale:
99874
+ * completion/cancel-recheck.ts.
99875
+ */
99876
+ cancelledCompletionRecheck = null;
99877
+ cancelledCompletionRecheckTimer = null;
99783
99878
  lastExternalCompletionProbe = null;
99784
99879
  // (NATIVE-TURN-SIGNAL) Terminal markers from the last native transcript read. Refreshed
99785
99880
  // on every completion probe; null when the provider surfaces none.
@@ -100226,6 +100321,17 @@ ${buttons.join("\n")}`;
100226
100321
  if (this.completedDebounceTimer) clearTimeout(this.completedDebounceTimer);
100227
100322
  this.completedDebounceTimer = setTimeout(() => this.flushCompletedDebounceIfFinalized(), delayMs);
100228
100323
  }
100324
+ /**
100325
+ * (CANCEL-BLIP-ORPHAN) Post-cancel completion re-verification. The judgment and its
100326
+ * full rationale live in completion/cancel-recheck.ts; these are the host-dispatched
100327
+ * seams, matching the status-transition / evidence / stall-rescue moves.
100328
+ */
100329
+ armCancelledCompletionRecheck(pending, reason) {
100330
+ armCancelledCompletionRecheck(this, pending, reason);
100331
+ }
100332
+ clearCancelledCompletionRecheck() {
100333
+ clearCancelledCompletionRecheck(this);
100334
+ }
100229
100335
  // EVTTRACE (observation-only): is this a mesh worker session whose completion
100230
100336
  // events must route to a coordinator? Used purely to gate trace logging so a
100231
100337
  // non-mesh CLI session's completions don't add EvtTrace noise. No decision logic.
@@ -100757,6 +100863,7 @@ ${buttons.join("\n")}`;
100757
100863
  if (this.completionTraceOn()) this.recordCompletionGateTrace("cancel", { blockReason: decision.reason, ...decision.trace });
100758
100864
  this.completedDebouncePending = null;
100759
100865
  this.completedDebounceTimer = null;
100866
+ this.armCancelledCompletionRecheck(pending, decision.reason);
100760
100867
  return;
100761
100868
  }
100762
100869
  this.applyCompletionArmPatch(pending, decision.armPatch);
@@ -100814,6 +100921,7 @@ ${buttons.join("\n")}`;
100814
100921
  });
100815
100922
  this.completedDebouncePending = null;
100816
100923
  this.completedDebounceTimer = null;
100924
+ this.clearCancelledCompletionRecheck();
100817
100925
  this.generatingStartedAt = 0;
100818
100926
  this.lastApprovalEventFingerprint = "";
100819
100927
  this.markCurrentTurnStartupGraceCollapseSatisfied();
@@ -100868,6 +100976,7 @@ ${buttons.join("\n")}`;
100868
100976
  });
100869
100977
  this.completedDebouncePending = null;
100870
100978
  this.completedDebounceTimer = null;
100979
+ this.clearCancelledCompletionRecheck();
100871
100980
  this.generatingStartedAt = 0;
100872
100981
  this.lastApprovalEventFingerprint = "";
100873
100982
  this.markCurrentTurnStartupGraceCollapseSatisfied();