@adhdev/daemon-core 0.9.82-rc.297 → 0.9.82-rc.299

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
@@ -275,10 +275,10 @@ function readInjected(value) {
275
275
  }
276
276
  function getDaemonBuildInfo() {
277
277
  if (cached) return cached;
278
- const commit = readInjected(true ? "5f22e3d153ae396b06c67b4eb88a98c7461a28d8" : void 0) ?? "unknown";
279
- const commitShort = readInjected(true ? "5f22e3d1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
280
- const version = readInjected(true ? "0.9.82-rc.297" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
281
- const builtAt = readInjected(true ? "2026-06-16T16:23:46.913Z" : void 0);
278
+ const commit = readInjected(true ? "86c45b0edabd4e1088f6333c996142f0dfaa930b" : void 0) ?? "unknown";
279
+ const commitShort = readInjected(true ? "86c45b0e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
280
+ const version = readInjected(true ? "0.9.82-rc.299" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
281
+ const builtAt = readInjected(true ? "2026-06-16T19:56:20.514Z" : void 0);
282
282
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
283
283
  return cached;
284
284
  }
@@ -3659,11 +3659,30 @@ var init_mesh_runtime_store = __esm({
3659
3659
  `).get(meshId, sessionId, nodeId);
3660
3660
  return row !== void 0;
3661
3661
  }
3662
+ /** A session may only execute one task at a time, regardless of task mode. */
3663
+ hasActiveSessionAssignment(meshId, sessionId) {
3664
+ const row = this.db.prepare(`
3665
+ SELECT 1 FROM mesh_queue
3666
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_session_id = ?
3667
+ LIMIT 1
3668
+ `).get(meshId, sessionId);
3669
+ return row !== void 0;
3670
+ }
3671
+ /** A node may only execute one write task at a time (worktree isolation). */
3672
+ hasActiveNodeAssignment(meshId, nodeId) {
3673
+ const row = this.db.prepare(`
3674
+ SELECT 1 FROM mesh_queue
3675
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_node_id = ?
3676
+ LIMIT 1
3677
+ `).get(meshId, nodeId);
3678
+ return row !== void 0;
3679
+ }
3662
3680
  // O(1) claim: transaction ensures only one session claims a pending task
3663
3681
  claimNextQueueTask(meshId, nodeId, sessionId, capabilityTags = []) {
3664
3682
  return this.transaction(() => {
3665
3683
  this.ensureLegacyQueueMigrated(meshId);
3666
- if (this.hasActiveAssignment(meshId, sessionId, nodeId)) return null;
3684
+ if (this.hasActiveSessionAssignment(meshId, sessionId)) return null;
3685
+ const nodeBusy = this.hasActiveNodeAssignment(meshId, nodeId);
3667
3686
  const rows = [
3668
3687
  ...this.db.prepare(`
3669
3688
  SELECT payload FROM mesh_queue
@@ -3696,7 +3715,11 @@ var init_mesh_runtime_store = __esm({
3696
3715
  const deps = Array.isArray(candidate.dependsOn) ? candidate.dependsOn : [];
3697
3716
  return deps.every((depId) => depStatus.get(depId) === "completed");
3698
3717
  };
3699
- const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate));
3718
+ const nodeConflictAllows = (candidate) => {
3719
+ if (candidate.taskMode === "live_debug_readonly") return true;
3720
+ return !nodeBusy;
3721
+ };
3722
+ const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate) && nodeConflictAllows(candidate));
3700
3723
  if (!entry) return null;
3701
3724
  const now = (/* @__PURE__ */ new Date()).toISOString();
3702
3725
  entry.status = "assigned";
@@ -7170,7 +7193,7 @@ function findRecentTerminalLedgerEvidence(args) {
7170
7193
  if (args.sessionId && entry.sessionId === args.sessionId) {
7171
7194
  return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
7172
7195
  }
7173
- if (!args.sessionId && args.nodeId && entry.nodeId === args.nodeId) {
7196
+ if (!args.sessionId && args.nodeId && meshNodeIdMatches(entry, args.nodeId)) {
7174
7197
  return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
7175
7198
  }
7176
7199
  }
@@ -7383,6 +7406,7 @@ var init_mesh_events_stale = __esm({
7383
7406
  init_mesh_delivery_policy();
7384
7407
  init_mesh_events_pending();
7385
7408
  init_mesh_events_utils();
7409
+ init_dist();
7386
7410
  }
7387
7411
  });
7388
7412
 
@@ -7567,9 +7591,10 @@ function resolveWorkerDelegateRouting(components, instanceId, deps) {
7567
7591
  const mesh = meshIdFromRuntime ? deps.getMeshById(meshIdFromRuntime) : deps.getMeshByWorkspace(workspace);
7568
7592
  const meshId = meshIdFromRuntime || readNonEmptyString2(mesh?.id);
7569
7593
  if (!meshId) return reject("mesh_unresolved");
7570
- const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
7571
- const nodeId = readNonEmptyString2(targetNode?.id) || runtimeNodeId;
7572
- const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
7594
+ const stampedNode = runtimeNodeId ? mesh?.nodes?.find((n) => meshNodeIdMatches(n, runtimeNodeId)) : void 0;
7595
+ const targetNode = stampedNode || mesh?.nodes?.find((n) => n.workspace === workspace);
7596
+ const nodeId = runtimeNodeId || readNonEmptyString2(targetNode?.id);
7597
+ const nodeLabel = nodeId ? `Node '${nodeId}'` : `Agent at ${workspace}`;
7573
7598
  return {
7574
7599
  isDelegate: true,
7575
7600
  meshId,
@@ -7650,6 +7675,7 @@ var init_mesh_routing = __esm({
7650
7675
  init_mesh_ledger();
7651
7676
  init_logger();
7652
7677
  init_mesh_events_utils();
7678
+ init_dist();
7653
7679
  UNROUTABLE_DIAGNOSTIC_STREAM = "__unroutable__";
7654
7680
  UNROUTABLE_DIAGNOSTIC_DEDUP_MS = 60 * 1e3;
7655
7681
  recentUnroutableDiagnostics = /* @__PURE__ */ new Map();
@@ -7808,7 +7834,7 @@ function hasRecentIntentionalCleanupStop(meshId, sessionId, nodeId) {
7808
7834
  if (!Number.isNaN(timestamp) && timestamp < cutoff) break;
7809
7835
  if (!isIntentionalCleanupStopEntry(entry)) continue;
7810
7836
  if (sessionId && entry.sessionId === sessionId) return true;
7811
- if (!sessionId && nodeId && entry.nodeId === nodeId) return true;
7837
+ if (!sessionId && nodeId && meshNodeIdMatches(entry, nodeId)) return true;
7812
7838
  }
7813
7839
  return false;
7814
7840
  }
@@ -8064,8 +8090,11 @@ function localAutoLaunchSkipReason(node) {
8064
8090
  }
8065
8091
  return null;
8066
8092
  }
8067
- function activeAssignedCount(meshId) {
8068
- return getQueue(meshId, { status: ["assigned"] }).length;
8093
+ function activeWriteAssignedCount(meshId) {
8094
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.taskMode !== "live_debug_readonly").length;
8095
+ }
8096
+ function activeReadonlyAssignedCount(meshId) {
8097
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.taskMode === "live_debug_readonly").length;
8069
8098
  }
8070
8099
  function nodeHasActiveAssignment(meshId, nodeId) {
8071
8100
  return getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedNodeId === nodeId);
@@ -8172,10 +8201,17 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
8172
8201
  const pending = queue.filter((task) => task.status === "pending");
8173
8202
  if (!pending.length) return false;
8174
8203
  const maxParallelTasks = Math.max(1, Math.floor(Number(mesh?.policy?.maxParallelTasks) || 2));
8204
+ const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
8175
8205
  for (const task of pending) {
8176
- if (activeAssignedCount(meshId) >= maxParallelTasks) {
8206
+ const isReadonly = task.taskMode === "live_debug_readonly";
8207
+ if (isReadonly) {
8208
+ if (activeReadonlyAssignedCount(meshId) >= maxReadonlyParallelTasks) {
8209
+ markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_readonly_parallel_tasks_reached" });
8210
+ continue;
8211
+ }
8212
+ } else if (activeWriteAssignedCount(meshId) >= maxParallelTasks) {
8177
8213
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_parallel_tasks_reached" });
8178
- return false;
8214
+ continue;
8179
8215
  }
8180
8216
  if (task.targetSessionId) {
8181
8217
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "target_session_constraint" });
@@ -8224,7 +8260,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
8224
8260
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: localSkipReason, nodeId });
8225
8261
  continue;
8226
8262
  }
8227
- if (nodeHasActiveAssignment(meshId, nodeId)) {
8263
+ if (task.taskMode !== "live_debug_readonly" && nodeHasActiveAssignment(meshId, nodeId)) {
8228
8264
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "node_has_active_assignment", nodeId });
8229
8265
  continue;
8230
8266
  }