@adhdev/daemon-core 0.9.82-rc.501 → 0.9.82-rc.503

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
@@ -412,10 +412,10 @@ function readInjected(value) {
412
412
  }
413
413
  function getDaemonBuildInfo() {
414
414
  if (cached) return cached;
415
- const commit = readInjected(true ? "f8a9c82867f25cbcb7bbfb407d1c3aa98585ff25" : void 0) ?? "unknown";
416
- const commitShort = readInjected(true ? "f8a9c828" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
417
- const version = readInjected(true ? "0.9.82-rc.501" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
418
- const builtAt = readInjected(true ? "2026-07-12T07:37:10.217Z" : void 0);
415
+ const commit = readInjected(true ? "85f5074b891b617a0568a36eb56691b8ce1633da" : void 0) ?? "unknown";
416
+ const commitShort = readInjected(true ? "85f5074b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
417
+ const version = readInjected(true ? "0.9.82-rc.503" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
418
+ const builtAt = readInjected(true ? "2026-07-12T10:01:27.241Z" : void 0);
419
419
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
420
420
  return cached;
421
421
  }
@@ -8945,6 +8945,7 @@ function stampPendingEventV2(event, hint) {
8945
8945
  });
8946
8946
  if (!stamp) return event;
8947
8947
  const dispatchedBySelfFallback = selfFallback && stamp.scope === "broadcast";
8948
+ const selfFallbackTarget = dispatchedBySelfFallback && !readNonEmptyString2(event.targetCoordinatorDaemonId) && !readNonEmptyString2(event.targetCoordinatorSessionId) ? readNonEmptyString2(stamp.dispatchedBy.daemonId) : void 0;
8948
8949
  return {
8949
8950
  ...event,
8950
8951
  protocolVersion: stamp.protocolVersion,
@@ -8952,7 +8953,8 @@ function stampPendingEventV2(event, hint) {
8952
8953
  scope: stamp.scope,
8953
8954
  dispatchedBy: stamp.dispatchedBy,
8954
8955
  ...stamp.intendedFor ? { intendedFor: stamp.intendedFor } : {},
8955
- ...dispatchedBySelfFallback ? { dispatchedBySelfFallback: true } : {}
8956
+ ...dispatchedBySelfFallback ? { dispatchedBySelfFallback: true } : {},
8957
+ ...selfFallbackTarget ? { targetCoordinatorDaemonId: selfFallbackTarget } : {}
8956
8958
  };
8957
8959
  }
8958
8960
  function readCoordinatorIdentityFromWire(raw) {
@@ -20886,8 +20888,11 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
20886
20888
  if (!nodeDaemonId) return;
20887
20889
  if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) return;
20888
20890
  if (daemonIdListIncludes(candidateDaemonIds, nodeDaemonId)) return;
20889
- const peerSnapshot = components.getMeshPeerConnectionStatus?.(nodeDaemonId);
20890
- if (peerSnapshot && String(peerSnapshot.state) !== "connected") return;
20891
+ const getPeerStatus = components.getMeshPeerConnectionStatus;
20892
+ if (getPeerStatus) {
20893
+ const peerSnapshot = getPeerStatus(nodeDaemonId);
20894
+ if (!peerSnapshot || String(peerSnapshot.state) !== "connected") return;
20895
+ }
20891
20896
  for (const pendingEventArgs of pulls) {
20892
20897
  let events;
20893
20898
  try {
@@ -20964,8 +20969,11 @@ async function collectLiveNodesWithSessions(components, mesh, selfIds, localDaem
20964
20969
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
20965
20970
  const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
20966
20971
  if (!isLocalNode) {
20967
- const peerSnapshot = components.getMeshPeerConnectionStatus?.(nodeDaemonId);
20968
- if (peerSnapshot && String(peerSnapshot.state) !== "connected") return node;
20972
+ const getPeerStatus = components.getMeshPeerConnectionStatus;
20973
+ if (getPeerStatus) {
20974
+ const peerSnapshot = getPeerStatus(nodeDaemonId);
20975
+ if (!peerSnapshot || String(peerSnapshot.state) !== "connected") return node;
20976
+ }
20969
20977
  }
20970
20978
  let statusResult;
20971
20979
  try {
@@ -45554,6 +45562,15 @@ var CliProviderInstance = class _CliProviderInstance {
45554
45562
  // R4b miss: collapse at boot+8s, dispatch at boot+12.4s > the 12s boot window).
45555
45563
  // Anchoring on the collapse moment makes the window cover dispatch-delay+turn.
45556
45564
  startupGraceCollapseAt = null;
45565
+ // ANTIGRAVITY-PREMATURE-COMPLETION gate: wall-clock when the CURRENT mesh task
45566
+ // was injected/attached (attachMeshAssignment). The injected task counts as having
45567
+ // genuinely entered generating only once a turn STARTS after this moment
45568
+ // (currentTurnStartedAt > meshTaskInjectedAt) — because currentTurnStartedAt
45569
+ // persists from the PRIOR turn and forceSendMessage pre-binds currentTurnTaskId at
45570
+ // inject time, so neither alone distinguishes "injected but not yet generating"
45571
+ // from "genuinely generating". This timestamp is that discriminator. 0 = no task
45572
+ // injected since boot (ad-hoc/non-mesh turns fall back to the plain turn-started check).
45573
+ meshTaskInjectedAt = 0;
45557
45574
  settings = {};
45558
45575
  monitor;
45559
45576
  generatingDebounceTimer = null;
@@ -45968,6 +45985,9 @@ var CliProviderInstance = class _CliProviderInstance {
45968
45985
  */
45969
45986
  attachMeshAssignment(assignment) {
45970
45987
  if (!assignment?.meshId) return;
45988
+ if (assignment.taskId && assignment.taskId.trim()) {
45989
+ this.meshTaskInjectedAt = Date.now();
45990
+ }
45971
45991
  this.settings = {
45972
45992
  ...this.settings,
45973
45993
  meshNodeFor: assignment.meshId,
@@ -46442,7 +46462,8 @@ var CliProviderInstance = class _CliProviderInstance {
46442
46462
  }
46443
46463
  const externalMessages = this.readExternalCompletionMessages();
46444
46464
  if (externalMessages) {
46445
- const present = turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
46465
+ const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
46466
+ const present = injectedTaskGenerating && turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
46446
46467
  const lastVisibleAssistant = this.lastVisibleAssistantSummary(externalMessages);
46447
46468
  if (lastVisibleAssistant) {
46448
46469
  this.lastCompletionSummary = { content: lastVisibleAssistant, receivedAt: Date.now() };
@@ -46750,6 +46771,38 @@ var CliProviderInstance = class _CliProviderInstance {
46750
46771
  const scalar = this.settings.meshActiveTaskId;
46751
46772
  return typeof scalar === "string" && scalar.trim() ? scalar : void 0;
46752
46773
  }
46774
+ /**
46775
+ * ANTIGRAVITY-PREMATURE-COMPLETION gate: has the CURRENTLY-injected task actually
46776
+ * entered generating (a real onTurnStarted for it)? Used to reject stale external-
46777
+ * native completion evidence that predates the injected task's turn.
46778
+ *
46779
+ * The injected task's id is the session scalar `meshActiveTaskId`, stamped by
46780
+ * attachMeshAssignment BEFORE the PTY turn starts. That stamp also records
46781
+ * `meshTaskInjectedAt`. The turn that has genuinely started is marked by
46782
+ * `adapter.currentTurnStartedAt` (set ONLY by onTurnStarted). Two naive signals both
46783
+ * FAIL for a reused-idle session:
46784
+ * - `currentTurnStartedAt > 0` alone: it persists from the PRIOR turn, so it is
46785
+ * already > 0 the instant a new task is injected (pre-onTurnStarted).
46786
+ * - `currentTurnTaskId === meshActiveTaskId` alone: forceSendMessage (the mesh
46787
+ * inject path) pre-binds currentTurnTaskId to the new taskId at inject time,
46788
+ * BEFORE the turn starts, so this matches prematurely too.
46789
+ * The robust discriminator is TEMPORAL: the producing turn must have STARTED AFTER
46790
+ * the injection — `currentTurnStartedAt > meshTaskInjectedAt`. Only then has the
46791
+ * injected task's own onTurnStarted fired.
46792
+ * - No injected task since boot (meshTaskInjectedAt === 0, e.g. an ad-hoc/dashboard
46793
+ * turn or a non-mesh session): fall back to the plain "a turn has started" check
46794
+ * so non-mesh completion is unaffected.
46795
+ * Fails CLOSED for the injected-but-not-started window; open once the injected turn is
46796
+ * genuinely underway (preserving the rc.480/481 completion-fires win).
46797
+ */
46798
+ injectedTaskHasStartedGenerating() {
46799
+ const turnStartedAt = typeof this.adapter?.currentTurnStartedAt === "number" ? this.adapter.currentTurnStartedAt : 0;
46800
+ const turnStarted = Number.isFinite(turnStartedAt) && turnStartedAt > 0;
46801
+ if (this.meshTaskInjectedAt <= 0) {
46802
+ return turnStarted;
46803
+ }
46804
+ return turnStarted && turnStartedAt > this.meshTaskInjectedAt;
46805
+ }
46753
46806
  // EVTTRACE correlation context for this session's completion lifecycle. taskId is
46754
46807
  // the primary grep anchor; instanceId is the session fallback.
46755
46808
  meshTraceCtx(event = "agent:generating_completed") {