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

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 ? "697af741759b27253991842eccf35716fbd33205" : void 0) ?? "unknown";
416
+ const commitShort = readInjected(true ? "697af741" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
417
+ const version = readInjected(true ? "0.9.82-rc.502" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
418
+ const builtAt = readInjected(true ? "2026-07-12T08:56:31.769Z" : 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) {
@@ -45554,6 +45556,15 @@ var CliProviderInstance = class _CliProviderInstance {
45554
45556
  // R4b miss: collapse at boot+8s, dispatch at boot+12.4s > the 12s boot window).
45555
45557
  // Anchoring on the collapse moment makes the window cover dispatch-delay+turn.
45556
45558
  startupGraceCollapseAt = null;
45559
+ // ANTIGRAVITY-PREMATURE-COMPLETION gate: wall-clock when the CURRENT mesh task
45560
+ // was injected/attached (attachMeshAssignment). The injected task counts as having
45561
+ // genuinely entered generating only once a turn STARTS after this moment
45562
+ // (currentTurnStartedAt > meshTaskInjectedAt) — because currentTurnStartedAt
45563
+ // persists from the PRIOR turn and forceSendMessage pre-binds currentTurnTaskId at
45564
+ // inject time, so neither alone distinguishes "injected but not yet generating"
45565
+ // from "genuinely generating". This timestamp is that discriminator. 0 = no task
45566
+ // injected since boot (ad-hoc/non-mesh turns fall back to the plain turn-started check).
45567
+ meshTaskInjectedAt = 0;
45557
45568
  settings = {};
45558
45569
  monitor;
45559
45570
  generatingDebounceTimer = null;
@@ -45968,6 +45979,9 @@ var CliProviderInstance = class _CliProviderInstance {
45968
45979
  */
45969
45980
  attachMeshAssignment(assignment) {
45970
45981
  if (!assignment?.meshId) return;
45982
+ if (assignment.taskId && assignment.taskId.trim()) {
45983
+ this.meshTaskInjectedAt = Date.now();
45984
+ }
45971
45985
  this.settings = {
45972
45986
  ...this.settings,
45973
45987
  meshNodeFor: assignment.meshId,
@@ -46442,7 +46456,8 @@ var CliProviderInstance = class _CliProviderInstance {
46442
46456
  }
46443
46457
  const externalMessages = this.readExternalCompletionMessages();
46444
46458
  if (externalMessages) {
46445
- const present = turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
46459
+ const injectedTaskGenerating = this.injectedTaskHasStartedGenerating();
46460
+ const present = injectedTaskGenerating && turnClosed && this.completionHasFinalAssistantMessage(externalMessages, turnStartedAt);
46446
46461
  const lastVisibleAssistant = this.lastVisibleAssistantSummary(externalMessages);
46447
46462
  if (lastVisibleAssistant) {
46448
46463
  this.lastCompletionSummary = { content: lastVisibleAssistant, receivedAt: Date.now() };
@@ -46750,6 +46765,38 @@ var CliProviderInstance = class _CliProviderInstance {
46750
46765
  const scalar = this.settings.meshActiveTaskId;
46751
46766
  return typeof scalar === "string" && scalar.trim() ? scalar : void 0;
46752
46767
  }
46768
+ /**
46769
+ * ANTIGRAVITY-PREMATURE-COMPLETION gate: has the CURRENTLY-injected task actually
46770
+ * entered generating (a real onTurnStarted for it)? Used to reject stale external-
46771
+ * native completion evidence that predates the injected task's turn.
46772
+ *
46773
+ * The injected task's id is the session scalar `meshActiveTaskId`, stamped by
46774
+ * attachMeshAssignment BEFORE the PTY turn starts. That stamp also records
46775
+ * `meshTaskInjectedAt`. The turn that has genuinely started is marked by
46776
+ * `adapter.currentTurnStartedAt` (set ONLY by onTurnStarted). Two naive signals both
46777
+ * FAIL for a reused-idle session:
46778
+ * - `currentTurnStartedAt > 0` alone: it persists from the PRIOR turn, so it is
46779
+ * already > 0 the instant a new task is injected (pre-onTurnStarted).
46780
+ * - `currentTurnTaskId === meshActiveTaskId` alone: forceSendMessage (the mesh
46781
+ * inject path) pre-binds currentTurnTaskId to the new taskId at inject time,
46782
+ * BEFORE the turn starts, so this matches prematurely too.
46783
+ * The robust discriminator is TEMPORAL: the producing turn must have STARTED AFTER
46784
+ * the injection — `currentTurnStartedAt > meshTaskInjectedAt`. Only then has the
46785
+ * injected task's own onTurnStarted fired.
46786
+ * - No injected task since boot (meshTaskInjectedAt === 0, e.g. an ad-hoc/dashboard
46787
+ * turn or a non-mesh session): fall back to the plain "a turn has started" check
46788
+ * so non-mesh completion is unaffected.
46789
+ * Fails CLOSED for the injected-but-not-started window; open once the injected turn is
46790
+ * genuinely underway (preserving the rc.480/481 completion-fires win).
46791
+ */
46792
+ injectedTaskHasStartedGenerating() {
46793
+ const turnStartedAt = typeof this.adapter?.currentTurnStartedAt === "number" ? this.adapter.currentTurnStartedAt : 0;
46794
+ const turnStarted = Number.isFinite(turnStartedAt) && turnStartedAt > 0;
46795
+ if (this.meshTaskInjectedAt <= 0) {
46796
+ return turnStarted;
46797
+ }
46798
+ return turnStarted && turnStartedAt > this.meshTaskInjectedAt;
46799
+ }
46753
46800
  // EVTTRACE correlation context for this session's completion lifecycle. taskId is
46754
46801
  // the primary grep anchor; instanceId is the session fallback.
46755
46802
  meshTraceCtx(event = "agent:generating_completed") {