@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.mjs CHANGED
@@ -270,10 +270,10 @@ function readInjected(value) {
270
270
  }
271
271
  function getDaemonBuildInfo() {
272
272
  if (cached) return cached;
273
- const commit = readInjected(true ? "5f22e3d153ae396b06c67b4eb88a98c7461a28d8" : void 0) ?? "unknown";
274
- const commitShort = readInjected(true ? "5f22e3d1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
275
- const version = readInjected(true ? "0.9.82-rc.297" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
276
- const builtAt = readInjected(true ? "2026-06-16T16:23:46.913Z" : void 0);
273
+ const commit = readInjected(true ? "86c45b0edabd4e1088f6333c996142f0dfaa930b" : void 0) ?? "unknown";
274
+ const commitShort = readInjected(true ? "86c45b0e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
275
+ const version = readInjected(true ? "0.9.82-rc.299" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
276
+ const builtAt = readInjected(true ? "2026-06-16T19:56:20.514Z" : void 0);
277
277
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
278
278
  return cached;
279
279
  }
@@ -3653,11 +3653,30 @@ var init_mesh_runtime_store = __esm({
3653
3653
  `).get(meshId, sessionId, nodeId);
3654
3654
  return row !== void 0;
3655
3655
  }
3656
+ /** A session may only execute one task at a time, regardless of task mode. */
3657
+ hasActiveSessionAssignment(meshId, sessionId) {
3658
+ const row = this.db.prepare(`
3659
+ SELECT 1 FROM mesh_queue
3660
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_session_id = ?
3661
+ LIMIT 1
3662
+ `).get(meshId, sessionId);
3663
+ return row !== void 0;
3664
+ }
3665
+ /** A node may only execute one write task at a time (worktree isolation). */
3666
+ hasActiveNodeAssignment(meshId, nodeId) {
3667
+ const row = this.db.prepare(`
3668
+ SELECT 1 FROM mesh_queue
3669
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_node_id = ?
3670
+ LIMIT 1
3671
+ `).get(meshId, nodeId);
3672
+ return row !== void 0;
3673
+ }
3656
3674
  // O(1) claim: transaction ensures only one session claims a pending task
3657
3675
  claimNextQueueTask(meshId, nodeId, sessionId, capabilityTags = []) {
3658
3676
  return this.transaction(() => {
3659
3677
  this.ensureLegacyQueueMigrated(meshId);
3660
- if (this.hasActiveAssignment(meshId, sessionId, nodeId)) return null;
3678
+ if (this.hasActiveSessionAssignment(meshId, sessionId)) return null;
3679
+ const nodeBusy = this.hasActiveNodeAssignment(meshId, nodeId);
3661
3680
  const rows = [
3662
3681
  ...this.db.prepare(`
3663
3682
  SELECT payload FROM mesh_queue
@@ -3690,7 +3709,11 @@ var init_mesh_runtime_store = __esm({
3690
3709
  const deps = Array.isArray(candidate.dependsOn) ? candidate.dependsOn : [];
3691
3710
  return deps.every((depId) => depStatus.get(depId) === "completed");
3692
3711
  };
3693
- const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate));
3712
+ const nodeConflictAllows = (candidate) => {
3713
+ if (candidate.taskMode === "live_debug_readonly") return true;
3714
+ return !nodeBusy;
3715
+ };
3716
+ const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate) && nodeConflictAllows(candidate));
3694
3717
  if (!entry) return null;
3695
3718
  const now = (/* @__PURE__ */ new Date()).toISOString();
3696
3719
  entry.status = "assigned";
@@ -7164,7 +7187,7 @@ function findRecentTerminalLedgerEvidence(args) {
7164
7187
  if (args.sessionId && entry.sessionId === args.sessionId) {
7165
7188
  return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
7166
7189
  }
7167
- if (!args.sessionId && args.nodeId && entry.nodeId === args.nodeId) {
7190
+ if (!args.sessionId && args.nodeId && meshNodeIdMatches(entry, args.nodeId)) {
7168
7191
  return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
7169
7192
  }
7170
7193
  }
@@ -7377,6 +7400,7 @@ var init_mesh_events_stale = __esm({
7377
7400
  init_mesh_delivery_policy();
7378
7401
  init_mesh_events_pending();
7379
7402
  init_mesh_events_utils();
7403
+ init_dist();
7380
7404
  }
7381
7405
  });
7382
7406
 
@@ -7560,9 +7584,10 @@ function resolveWorkerDelegateRouting(components, instanceId, deps) {
7560
7584
  const mesh = meshIdFromRuntime ? deps.getMeshById(meshIdFromRuntime) : deps.getMeshByWorkspace(workspace);
7561
7585
  const meshId = meshIdFromRuntime || readNonEmptyString2(mesh?.id);
7562
7586
  if (!meshId) return reject("mesh_unresolved");
7563
- const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
7564
- const nodeId = readNonEmptyString2(targetNode?.id) || runtimeNodeId;
7565
- const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
7587
+ const stampedNode = runtimeNodeId ? mesh?.nodes?.find((n) => meshNodeIdMatches(n, runtimeNodeId)) : void 0;
7588
+ const targetNode = stampedNode || mesh?.nodes?.find((n) => n.workspace === workspace);
7589
+ const nodeId = runtimeNodeId || readNonEmptyString2(targetNode?.id);
7590
+ const nodeLabel = nodeId ? `Node '${nodeId}'` : `Agent at ${workspace}`;
7566
7591
  return {
7567
7592
  isDelegate: true,
7568
7593
  meshId,
@@ -7643,6 +7668,7 @@ var init_mesh_routing = __esm({
7643
7668
  init_mesh_ledger();
7644
7669
  init_logger();
7645
7670
  init_mesh_events_utils();
7671
+ init_dist();
7646
7672
  UNROUTABLE_DIAGNOSTIC_STREAM = "__unroutable__";
7647
7673
  UNROUTABLE_DIAGNOSTIC_DEDUP_MS = 60 * 1e3;
7648
7674
  recentUnroutableDiagnostics = /* @__PURE__ */ new Map();
@@ -7802,7 +7828,7 @@ function hasRecentIntentionalCleanupStop(meshId, sessionId, nodeId) {
7802
7828
  if (!Number.isNaN(timestamp) && timestamp < cutoff) break;
7803
7829
  if (!isIntentionalCleanupStopEntry(entry)) continue;
7804
7830
  if (sessionId && entry.sessionId === sessionId) return true;
7805
- if (!sessionId && nodeId && entry.nodeId === nodeId) return true;
7831
+ if (!sessionId && nodeId && meshNodeIdMatches(entry, nodeId)) return true;
7806
7832
  }
7807
7833
  return false;
7808
7834
  }
@@ -8058,8 +8084,11 @@ function localAutoLaunchSkipReason(node) {
8058
8084
  }
8059
8085
  return null;
8060
8086
  }
8061
- function activeAssignedCount(meshId) {
8062
- return getQueue(meshId, { status: ["assigned"] }).length;
8087
+ function activeWriteAssignedCount(meshId) {
8088
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.taskMode !== "live_debug_readonly").length;
8089
+ }
8090
+ function activeReadonlyAssignedCount(meshId) {
8091
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.taskMode === "live_debug_readonly").length;
8063
8092
  }
8064
8093
  function nodeHasActiveAssignment(meshId, nodeId) {
8065
8094
  return getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedNodeId === nodeId);
@@ -8166,10 +8195,17 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
8166
8195
  const pending = queue.filter((task) => task.status === "pending");
8167
8196
  if (!pending.length) return false;
8168
8197
  const maxParallelTasks = Math.max(1, Math.floor(Number(mesh?.policy?.maxParallelTasks) || 2));
8198
+ const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
8169
8199
  for (const task of pending) {
8170
- if (activeAssignedCount(meshId) >= maxParallelTasks) {
8200
+ const isReadonly = task.taskMode === "live_debug_readonly";
8201
+ if (isReadonly) {
8202
+ if (activeReadonlyAssignedCount(meshId) >= maxReadonlyParallelTasks) {
8203
+ markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_readonly_parallel_tasks_reached" });
8204
+ continue;
8205
+ }
8206
+ } else if (activeWriteAssignedCount(meshId) >= maxParallelTasks) {
8171
8207
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_parallel_tasks_reached" });
8172
- return false;
8208
+ continue;
8173
8209
  }
8174
8210
  if (task.targetSessionId) {
8175
8211
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "target_session_constraint" });
@@ -8218,7 +8254,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
8218
8254
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: localSkipReason, nodeId });
8219
8255
  continue;
8220
8256
  }
8221
- if (nodeHasActiveAssignment(meshId, nodeId)) {
8257
+ if (task.taskMode !== "live_debug_readonly" && nodeHasActiveAssignment(meshId, nodeId)) {
8222
8258
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "node_has_active_assignment", nodeId });
8223
8259
  continue;
8224
8260
  }