@adhdev/daemon-core 0.9.82-rc.394 → 0.9.82-rc.396

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
@@ -383,10 +383,10 @@ function readInjected(value) {
383
383
  }
384
384
  function getDaemonBuildInfo() {
385
385
  if (cached) return cached;
386
- const commit = readInjected(true ? "5de1627a0f2a92574b4ea1508d43ab920c3cb238" : void 0) ?? "unknown";
387
- const commitShort = readInjected(true ? "5de1627a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
388
- const version = readInjected(true ? "0.9.82-rc.394" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
389
- const builtAt = readInjected(true ? "2026-06-27T06:01:30.863Z" : void 0);
386
+ const commit = readInjected(true ? "109c5230408ea2b33e9083395b42b1c3e894aed2" : void 0) ?? "unknown";
387
+ const commitShort = readInjected(true ? "109c5230" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
388
+ const version = readInjected(true ? "0.9.82-rc.396" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
389
+ const builtAt = readInjected(true ? "2026-06-27T07:15:39.648Z" : void 0);
390
390
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
391
391
  return cached;
392
392
  }
@@ -9866,27 +9866,32 @@ function reconcileDirectDispatchCompletionFromTranscript(args) {
9866
9866
  updateDirectDispatchStatus(args.meshId, args.sessionId, kind === "task_completed" ? "completed" : "failed", args.taskId);
9867
9867
  markSessionDeliveriesTerminal(args.meshId, args.sessionId, kind === "task_completed" ? "completed" : "failed");
9868
9868
  setImmediate(() => cleanupTerminalDirectDispatches());
9869
+ const eventName = kind === "task_completed" ? "agent:generating_completed" : "agent:stopped";
9870
+ const nodeLabel = nodeId ? `Node '${nodeId}'` : "Remote agent";
9871
+ const metadataEvent = {
9872
+ targetSessionId: args.sessionId,
9873
+ providerType: providerType || void 0,
9874
+ providerSessionId: readNonEmptyString2(args.providerSessionId),
9875
+ finalSummary,
9876
+ taskId: args.taskId,
9877
+ workerResult,
9878
+ completionDiagnostic: {
9879
+ reason: "direct_task_transcript_reconciliation",
9880
+ terminalLedgerKind: kind,
9881
+ terminalLedgerId: entry.id
9882
+ }
9883
+ };
9884
+ const targetCoordinatorSessionId = readNonEmptyString2(args.targetCoordinatorSessionId) || readNonEmptyString2(dispatch?.payload?.coordinatorSessionId);
9869
9885
  queuePendingMeshCoordinatorEvent({
9870
- event: kind === "task_completed" ? "agent:generating_completed" : "agent:stopped",
9886
+ event: eventName,
9871
9887
  meshId: args.meshId,
9872
- nodeLabel: nodeId ? `Node '${nodeId}'` : "Remote agent",
9888
+ nodeLabel,
9873
9889
  nodeId: nodeId || void 0,
9874
- metadataEvent: {
9875
- targetSessionId: args.sessionId,
9876
- providerType: providerType || void 0,
9877
- providerSessionId: readNonEmptyString2(args.providerSessionId),
9878
- finalSummary,
9879
- taskId: args.taskId,
9880
- workerResult,
9881
- completionDiagnostic: {
9882
- reason: "direct_task_transcript_reconciliation",
9883
- terminalLedgerKind: kind,
9884
- terminalLedgerId: entry.id
9885
- }
9886
- },
9887
- coordinatorMessage: void 0,
9890
+ metadataEvent,
9891
+ coordinatorMessage: buildMeshSystemMessage({ event: eventName, nodeLabel, metadataEvent }),
9888
9892
  queuedAt: Date.now(),
9889
- ...readNonEmptyString2(args.targetCoordinatorDaemonId) ? { targetCoordinatorDaemonId: readNonEmptyString2(args.targetCoordinatorDaemonId) } : {}
9893
+ ...readNonEmptyString2(args.targetCoordinatorDaemonId) ? { targetCoordinatorDaemonId: readNonEmptyString2(args.targetCoordinatorDaemonId) } : {},
9894
+ ...targetCoordinatorSessionId ? { targetCoordinatorSessionId } : {}
9890
9895
  });
9891
9896
  return { reconciled: true, kind, workerResult, ledgerEntryId: entry.id };
9892
9897
  }
@@ -10779,6 +10784,11 @@ function deliverTaskToSession(dispatchThunk, ctx, warmup) {
10779
10784
  function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
10780
10785
  const mesh = getMeshWithCache(components, meshId);
10781
10786
  const node = mesh?.nodes.find((n) => readMeshNodeId(n) === nodeId);
10787
+ const gateNode = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
10788
+ if (gateNode?.worktreeBootstrap?.status === "running") {
10789
+ LOG.info("MeshQueue", `Gating queue claim for worktree node ${nodeId} (${sessionId}): worktree bootstrap still running \u2014 task left pending; claim re-fires once bootstrap reaches a terminal state (guards against dispatching into a half-built worktree \u2192 empty session)`);
10790
+ return false;
10791
+ }
10782
10792
  const localClaimAdapter = components.cliManager?.adapters?.get(sessionId);
10783
10793
  let claimInstanceWorkspace = "";
10784
10794
  let claimStampedNodeId = "";
@@ -15217,7 +15227,19 @@ function shouldHoldPendingDrainForBusyLocalCoordinator(components, meshId, reque
15217
15227
  return localIds.some((id) => daemonIdsEquivalent(id, requested));
15218
15228
  }
15219
15229
  function injectPendingIntoCoordinator(coordinator, pending) {
15220
- if (!coordinator || !pending.coordinatorMessage) return;
15230
+ if (!coordinator) return;
15231
+ let coordinatorMessage = pending.coordinatorMessage;
15232
+ if (!coordinatorMessage) {
15233
+ if (!shouldForceInjectMeshEvent(pending.event)) return;
15234
+ const metadataEvent = pending.metadataEvent && typeof pending.metadataEvent === "object" ? pending.metadataEvent : {};
15235
+ coordinatorMessage = buildMeshSystemMessage({
15236
+ event: pending.event,
15237
+ nodeLabel: pending.nodeLabel,
15238
+ metadataEvent
15239
+ });
15240
+ if (!coordinatorMessage) return;
15241
+ LOG.warn("MeshReconcile", `Lazily synthesized missing coordinatorMessage for ${pending.event} (mesh ${pending.meshId}) at inject time \u2014 a queued terminal event arrived message-less`);
15242
+ }
15221
15243
  const force = shouldForceInjectMeshEvent(pending.event);
15222
15244
  traceMeshEventStage("surfaced", {
15223
15245
  taskId: pending.metadataEvent?.taskId,
@@ -15227,7 +15249,7 @@ function injectPendingIntoCoordinator(coordinator, pending) {
15227
15249
  event: pending.event
15228
15250
  }, force ? "force-inject" : "inject");
15229
15251
  coordinator.onEvent("send_message", {
15230
- input: { text: pending.coordinatorMessage, textFallback: pending.coordinatorMessage },
15252
+ input: { text: coordinatorMessage, textFallback: coordinatorMessage },
15231
15253
  ...force ? { force: true } : {}
15232
15254
  });
15233
15255
  }