@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.js CHANGED
@@ -417,10 +417,10 @@ function readInjected(value) {
417
417
  }
418
418
  function getDaemonBuildInfo() {
419
419
  if (cached) return cached;
420
- const commit = readInjected(true ? "f8a9c82867f25cbcb7bbfb407d1c3aa98585ff25" : void 0) ?? "unknown";
421
- const commitShort = readInjected(true ? "f8a9c828" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
422
- const version = readInjected(true ? "0.9.82-rc.501" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
423
- const builtAt = readInjected(true ? "2026-07-12T07:37:10.217Z" : void 0);
420
+ const commit = readInjected(true ? "85f5074b891b617a0568a36eb56691b8ce1633da" : void 0) ?? "unknown";
421
+ const commitShort = readInjected(true ? "85f5074b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
422
+ const version = readInjected(true ? "0.9.82-rc.503" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
423
+ const builtAt = readInjected(true ? "2026-07-12T10:01:27.241Z" : void 0);
424
424
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
425
425
  return cached;
426
426
  }
@@ -8949,6 +8949,7 @@ function stampPendingEventV2(event, hint) {
8949
8949
  });
8950
8950
  if (!stamp) return event;
8951
8951
  const dispatchedBySelfFallback = selfFallback && stamp.scope === "broadcast";
8952
+ const selfFallbackTarget = dispatchedBySelfFallback && !readNonEmptyString2(event.targetCoordinatorDaemonId) && !readNonEmptyString2(event.targetCoordinatorSessionId) ? readNonEmptyString2(stamp.dispatchedBy.daemonId) : void 0;
8952
8953
  return {
8953
8954
  ...event,
8954
8955
  protocolVersion: stamp.protocolVersion,
@@ -8956,7 +8957,8 @@ function stampPendingEventV2(event, hint) {
8956
8957
  scope: stamp.scope,
8957
8958
  dispatchedBy: stamp.dispatchedBy,
8958
8959
  ...stamp.intendedFor ? { intendedFor: stamp.intendedFor } : {},
8959
- ...dispatchedBySelfFallback ? { dispatchedBySelfFallback: true } : {}
8960
+ ...dispatchedBySelfFallback ? { dispatchedBySelfFallback: true } : {},
8961
+ ...selfFallbackTarget ? { targetCoordinatorDaemonId: selfFallbackTarget } : {}
8960
8962
  };
8961
8963
  }
8962
8964
  function readCoordinatorIdentityFromWire(raw) {
@@ -20884,8 +20886,11 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
20884
20886
  if (!nodeDaemonId) return;
20885
20887
  if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) return;
20886
20888
  if (daemonIdListIncludes(candidateDaemonIds, nodeDaemonId)) return;
20887
- const peerSnapshot = components.getMeshPeerConnectionStatus?.(nodeDaemonId);
20888
- if (peerSnapshot && String(peerSnapshot.state) !== "connected") return;
20889
+ const getPeerStatus = components.getMeshPeerConnectionStatus;
20890
+ if (getPeerStatus) {
20891
+ const peerSnapshot = getPeerStatus(nodeDaemonId);
20892
+ if (!peerSnapshot || String(peerSnapshot.state) !== "connected") return;
20893
+ }
20889
20894
  for (const pendingEventArgs of pulls) {
20890
20895
  let events;
20891
20896
  try {
@@ -20962,8 +20967,11 @@ async function collectLiveNodesWithSessions(components, mesh, selfIds, localDaem
20962
20967
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
20963
20968
  const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
20964
20969
  if (!isLocalNode) {
20965
- const peerSnapshot = components.getMeshPeerConnectionStatus?.(nodeDaemonId);
20966
- if (peerSnapshot && String(peerSnapshot.state) !== "connected") return node;
20970
+ const getPeerStatus = components.getMeshPeerConnectionStatus;
20971
+ if (getPeerStatus) {
20972
+ const peerSnapshot = getPeerStatus(nodeDaemonId);
20973
+ if (!peerSnapshot || String(peerSnapshot.state) !== "connected") return node;
20974
+ }
20967
20975
  }
20968
20976
  let statusResult;
20969
20977
  try {
@@ -45979,6 +45987,15 @@ var CliProviderInstance = class _CliProviderInstance {
45979
45987
  // R4b miss: collapse at boot+8s, dispatch at boot+12.4s > the 12s boot window).
45980
45988
  // Anchoring on the collapse moment makes the window cover dispatch-delay+turn.
45981
45989
  startupGraceCollapseAt = null;
45990
+ // ANTIGRAVITY-PREMATURE-COMPLETION gate: wall-clock when the CURRENT mesh task
45991
+ // was injected/attached (attachMeshAssignment). The injected task counts as having
45992
+ // genuinely entered generating only once a turn STARTS after this moment
45993
+ // (currentTurnStartedAt > meshTaskInjectedAt) — because currentTurnStartedAt
45994
+ // persists from the PRIOR turn and forceSendMessage pre-binds currentTurnTaskId at
45995
+ // inject time, so neither alone distinguishes "injected but not yet generating"
45996
+ // from "genuinely generating". This timestamp is that discriminator. 0 = no task
45997
+ // injected since boot (ad-hoc/non-mesh turns fall back to the plain turn-started check).
45998
+ meshTaskInjectedAt = 0;
45982
45999
  settings = {};
45983
46000
  monitor;
45984
46001
  generatingDebounceTimer = null;
@@ -46393,6 +46410,9 @@ var CliProviderInstance = class _CliProviderInstance {
46393
46410
  */
46394
46411
  attachMeshAssignment(assignment) {
46395
46412
  if (!assignment?.meshId) return;
46413
+ if (assignment.taskId && assignment.taskId.trim()) {
46414
+ this.meshTaskInjectedAt = Date.now();
46415
+ }
46396
46416
  this.settings = {
46397
46417
  ...this.settings,
46398
46418
  meshNodeFor: assignment.meshId,
@@ -46867,7 +46887,8 @@ var CliProviderInstance = class _CliProviderInstance {
46867
46887
  }
46868
46888
  const externalMessages = this.readExternalCompletionMessages();
46869
46889
  if (externalMessages) {
46870
- const present = turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
46890
+ const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
46891
+ const present = injectedTaskGenerating && turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
46871
46892
  const lastVisibleAssistant = this.lastVisibleAssistantSummary(externalMessages);
46872
46893
  if (lastVisibleAssistant) {
46873
46894
  this.lastCompletionSummary = { content: lastVisibleAssistant, receivedAt: Date.now() };
@@ -47175,6 +47196,38 @@ var CliProviderInstance = class _CliProviderInstance {
47175
47196
  const scalar = this.settings.meshActiveTaskId;
47176
47197
  return typeof scalar === "string" && scalar.trim() ? scalar : void 0;
47177
47198
  }
47199
+ /**
47200
+ * ANTIGRAVITY-PREMATURE-COMPLETION gate: has the CURRENTLY-injected task actually
47201
+ * entered generating (a real onTurnStarted for it)? Used to reject stale external-
47202
+ * native completion evidence that predates the injected task's turn.
47203
+ *
47204
+ * The injected task's id is the session scalar `meshActiveTaskId`, stamped by
47205
+ * attachMeshAssignment BEFORE the PTY turn starts. That stamp also records
47206
+ * `meshTaskInjectedAt`. The turn that has genuinely started is marked by
47207
+ * `adapter.currentTurnStartedAt` (set ONLY by onTurnStarted). Two naive signals both
47208
+ * FAIL for a reused-idle session:
47209
+ * - `currentTurnStartedAt > 0` alone: it persists from the PRIOR turn, so it is
47210
+ * already > 0 the instant a new task is injected (pre-onTurnStarted).
47211
+ * - `currentTurnTaskId === meshActiveTaskId` alone: forceSendMessage (the mesh
47212
+ * inject path) pre-binds currentTurnTaskId to the new taskId at inject time,
47213
+ * BEFORE the turn starts, so this matches prematurely too.
47214
+ * The robust discriminator is TEMPORAL: the producing turn must have STARTED AFTER
47215
+ * the injection — `currentTurnStartedAt > meshTaskInjectedAt`. Only then has the
47216
+ * injected task's own onTurnStarted fired.
47217
+ * - No injected task since boot (meshTaskInjectedAt === 0, e.g. an ad-hoc/dashboard
47218
+ * turn or a non-mesh session): fall back to the plain "a turn has started" check
47219
+ * so non-mesh completion is unaffected.
47220
+ * Fails CLOSED for the injected-but-not-started window; open once the injected turn is
47221
+ * genuinely underway (preserving the rc.480/481 completion-fires win).
47222
+ */
47223
+ injectedTaskHasStartedGenerating() {
47224
+ const turnStartedAt = typeof this.adapter?.currentTurnStartedAt === "number" ? this.adapter.currentTurnStartedAt : 0;
47225
+ const turnStarted = Number.isFinite(turnStartedAt) && turnStartedAt > 0;
47226
+ if (this.meshTaskInjectedAt <= 0) {
47227
+ return turnStarted;
47228
+ }
47229
+ return turnStarted && turnStartedAt > this.meshTaskInjectedAt;
47230
+ }
47178
47231
  // EVTTRACE correlation context for this session's completion lifecycle. taskId is
47179
47232
  // the primary grep anchor; instanceId is the session fallback.
47180
47233
  meshTraceCtx(event = "agent:generating_completed") {