@adhdev/daemon-standalone 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
@@ -29983,10 +29983,10 @@ var require_dist3 = __commonJS({
29983
29983
  }
29984
29984
  function getDaemonBuildInfo() {
29985
29985
  if (cached2) return cached2;
29986
- const commit = readInjected(true ? "5f22e3d153ae396b06c67b4eb88a98c7461a28d8" : void 0) ?? "unknown";
29987
- const commitShort = readInjected(true ? "5f22e3d1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29988
- const version2 = readInjected(true ? "0.9.82-rc.297" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29989
- const builtAt = readInjected(true ? "2026-06-16T16:24:13.401Z" : void 0);
29986
+ const commit = readInjected(true ? "86c45b0edabd4e1088f6333c996142f0dfaa930b" : void 0) ?? "unknown";
29987
+ const commitShort = readInjected(true ? "86c45b0e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29988
+ const version2 = readInjected(true ? "0.9.82-rc.299" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29989
+ const builtAt = readInjected(true ? "2026-06-16T19:56:45.959Z" : void 0);
29990
29990
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
29991
29991
  return cached2;
29992
29992
  }
@@ -33402,11 +33402,30 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
33402
33402
  `).get(meshId, sessionId, nodeId);
33403
33403
  return row !== void 0;
33404
33404
  }
33405
+ /** A session may only execute one task at a time, regardless of task mode. */
33406
+ hasActiveSessionAssignment(meshId, sessionId) {
33407
+ const row = this.db.prepare(`
33408
+ SELECT 1 FROM mesh_queue
33409
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_session_id = ?
33410
+ LIMIT 1
33411
+ `).get(meshId, sessionId);
33412
+ return row !== void 0;
33413
+ }
33414
+ /** A node may only execute one write task at a time (worktree isolation). */
33415
+ hasActiveNodeAssignment(meshId, nodeId) {
33416
+ const row = this.db.prepare(`
33417
+ SELECT 1 FROM mesh_queue
33418
+ WHERE mesh_id = ? AND status = 'assigned' AND assigned_node_id = ?
33419
+ LIMIT 1
33420
+ `).get(meshId, nodeId);
33421
+ return row !== void 0;
33422
+ }
33405
33423
  // O(1) claim: transaction ensures only one session claims a pending task
33406
33424
  claimNextQueueTask(meshId, nodeId, sessionId, capabilityTags = []) {
33407
33425
  return this.transaction(() => {
33408
33426
  this.ensureLegacyQueueMigrated(meshId);
33409
- if (this.hasActiveAssignment(meshId, sessionId, nodeId)) return null;
33427
+ if (this.hasActiveSessionAssignment(meshId, sessionId)) return null;
33428
+ const nodeBusy = this.hasActiveNodeAssignment(meshId, nodeId);
33410
33429
  const rows = [
33411
33430
  ...this.db.prepare(`
33412
33431
  SELECT payload FROM mesh_queue
@@ -33439,7 +33458,11 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
33439
33458
  const deps = Array.isArray(candidate.dependsOn) ? candidate.dependsOn : [];
33440
33459
  return deps.every((depId) => depStatus.get(depId) === "completed");
33441
33460
  };
33442
- const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate));
33461
+ const nodeConflictAllows = (candidate) => {
33462
+ if (candidate.taskMode === "live_debug_readonly") return true;
33463
+ return !nodeBusy;
33464
+ };
33465
+ const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate) && nodeConflictAllows(candidate));
33443
33466
  if (!entry) return null;
33444
33467
  const now = (/* @__PURE__ */ new Date()).toISOString();
33445
33468
  entry.status = "assigned";
@@ -36930,7 +36953,7 @@ Next step: ${nextStep}`;
36930
36953
  if (args.sessionId && entry.sessionId === args.sessionId) {
36931
36954
  return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
36932
36955
  }
36933
- if (!args.sessionId && args.nodeId && entry.nodeId === args.nodeId) {
36956
+ if (!args.sessionId && args.nodeId && meshNodeIdMatches(entry, args.nodeId)) {
36934
36957
  return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
36935
36958
  }
36936
36959
  }
@@ -37143,6 +37166,7 @@ Next step: ${nextStep}`;
37143
37166
  init_mesh_delivery_policy();
37144
37167
  init_mesh_events_pending();
37145
37168
  init_mesh_events_utils();
37169
+ init_dist();
37146
37170
  }
37147
37171
  });
37148
37172
  function parseVersion(raw) {
@@ -37326,9 +37350,10 @@ Next step: ${nextStep}`;
37326
37350
  const mesh = meshIdFromRuntime ? deps.getMeshById(meshIdFromRuntime) : deps.getMeshByWorkspace(workspace);
37327
37351
  const meshId = meshIdFromRuntime || readNonEmptyString2(mesh?.id);
37328
37352
  if (!meshId) return reject("mesh_unresolved");
37329
- const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
37330
- const nodeId = readNonEmptyString2(targetNode?.id) || runtimeNodeId;
37331
- const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
37353
+ const stampedNode = runtimeNodeId ? mesh?.nodes?.find((n) => meshNodeIdMatches(n, runtimeNodeId)) : void 0;
37354
+ const targetNode = stampedNode || mesh?.nodes?.find((n) => n.workspace === workspace);
37355
+ const nodeId = runtimeNodeId || readNonEmptyString2(targetNode?.id);
37356
+ const nodeLabel = nodeId ? `Node '${nodeId}'` : `Agent at ${workspace}`;
37332
37357
  return {
37333
37358
  isDelegate: true,
37334
37359
  meshId,
@@ -37411,6 +37436,7 @@ Next step: ${nextStep}`;
37411
37436
  init_mesh_ledger();
37412
37437
  init_logger();
37413
37438
  init_mesh_events_utils();
37439
+ init_dist();
37414
37440
  UNROUTABLE_DIAGNOSTIC_STREAM = "__unroutable__";
37415
37441
  UNROUTABLE_DIAGNOSTIC_DEDUP_MS = 60 * 1e3;
37416
37442
  recentUnroutableDiagnostics = /* @__PURE__ */ new Map();
@@ -37567,7 +37593,7 @@ Next step: ${nextStep}`;
37567
37593
  if (!Number.isNaN(timestamp) && timestamp < cutoff) break;
37568
37594
  if (!isIntentionalCleanupStopEntry(entry)) continue;
37569
37595
  if (sessionId && entry.sessionId === sessionId) return true;
37570
- if (!sessionId && nodeId && entry.nodeId === nodeId) return true;
37596
+ if (!sessionId && nodeId && meshNodeIdMatches(entry, nodeId)) return true;
37571
37597
  }
37572
37598
  return false;
37573
37599
  }
@@ -37823,8 +37849,11 @@ Next step: ${nextStep}`;
37823
37849
  }
37824
37850
  return null;
37825
37851
  }
37826
- function activeAssignedCount(meshId) {
37827
- return getQueue(meshId, { status: ["assigned"] }).length;
37852
+ function activeWriteAssignedCount(meshId) {
37853
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.taskMode !== "live_debug_readonly").length;
37854
+ }
37855
+ function activeReadonlyAssignedCount(meshId) {
37856
+ return getQueue(meshId, { status: ["assigned"] }).filter((task) => task.taskMode === "live_debug_readonly").length;
37828
37857
  }
37829
37858
  function nodeHasActiveAssignment(meshId, nodeId) {
37830
37859
  return getQueue(meshId, { status: ["assigned"] }).some((task) => task.assignedNodeId === nodeId);
@@ -37931,10 +37960,17 @@ Next step: ${nextStep}`;
37931
37960
  const pending = queue.filter((task) => task.status === "pending");
37932
37961
  if (!pending.length) return false;
37933
37962
  const maxParallelTasks = Math.max(1, Math.floor(Number(mesh?.policy?.maxParallelTasks) || 2));
37963
+ const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
37934
37964
  for (const task of pending) {
37935
- if (activeAssignedCount(meshId) >= maxParallelTasks) {
37965
+ const isReadonly = task.taskMode === "live_debug_readonly";
37966
+ if (isReadonly) {
37967
+ if (activeReadonlyAssignedCount(meshId) >= maxReadonlyParallelTasks) {
37968
+ markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_readonly_parallel_tasks_reached" });
37969
+ continue;
37970
+ }
37971
+ } else if (activeWriteAssignedCount(meshId) >= maxParallelTasks) {
37936
37972
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_parallel_tasks_reached" });
37937
- return false;
37973
+ continue;
37938
37974
  }
37939
37975
  if (task.targetSessionId) {
37940
37976
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "target_session_constraint" });
@@ -37983,7 +38019,7 @@ Next step: ${nextStep}`;
37983
38019
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: localSkipReason, nodeId });
37984
38020
  continue;
37985
38021
  }
37986
- if (nodeHasActiveAssignment(meshId, nodeId)) {
38022
+ if (task.taskMode !== "live_debug_readonly" && nodeHasActiveAssignment(meshId, nodeId)) {
37987
38023
  markAutoLaunch(meshId, task.id, { status: "skipped", reason: "node_has_active_assignment", nodeId });
37988
38024
  continue;
37989
38025
  }