@adhdev/daemon-standalone 0.9.82-rc.381 → 0.9.82-rc.382

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
@@ -30108,10 +30108,10 @@ var require_dist3 = __commonJS({
30108
30108
  }
30109
30109
  function getDaemonBuildInfo() {
30110
30110
  if (cached2) return cached2;
30111
- const commit = readInjected(true ? "18afac213951f79c502feb6b25b7399fe4d709b3" : void 0) ?? "unknown";
30112
- const commitShort = readInjected(true ? "18afac21" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30113
- const version2 = readInjected(true ? "0.9.82-rc.381" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30114
- const builtAt = readInjected(true ? "2026-06-25T11:45:12.459Z" : void 0);
30111
+ const commit = readInjected(true ? "70741c4fe19c6f71bcef702e7e149d963d6fd916" : void 0) ?? "unknown";
30112
+ const commitShort = readInjected(true ? "70741c4f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30113
+ const version2 = readInjected(true ? "0.9.82-rc.382" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30114
+ const builtAt = readInjected(true ? "2026-06-25T13:33:15.097Z" : void 0);
30115
30115
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30116
30116
  return cached2;
30117
30117
  }
@@ -38363,6 +38363,107 @@ ${rendered}`, "utf-8");
38363
38363
  ]);
38364
38364
  }
38365
38365
  });
38366
+ var mesh_scheduling_runtime_exports = {};
38367
+ __export2(mesh_scheduling_runtime_exports, {
38368
+ buildMeshSchedulingRuntime: () => buildMeshSchedulingRuntime
38369
+ });
38370
+ function isReadonly(task) {
38371
+ return task.taskMode === "live_debug_readonly";
38372
+ }
38373
+ function isAssigned(task) {
38374
+ return task.status === "assigned";
38375
+ }
38376
+ function buildMeshSchedulingRuntime(mesh, queue) {
38377
+ const strategy = normalizeMeshSchedulingStrategy(mesh?.policy?.schedulingStrategy);
38378
+ const maxParallelTasks = resolveMaxParallelTasks(mesh?.policy?.maxParallelTasks);
38379
+ const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
38380
+ const assignedTasks = (Array.isArray(queue) ? queue : []).filter(isAssigned);
38381
+ const activeWriteAssigned = assignedTasks.filter((t) => !isReadonly(t)).length;
38382
+ const activeReadonlyAssigned = assignedTasks.filter(isReadonly).length;
38383
+ const globalWriteCapReached = activeWriteAssigned >= maxParallelTasks;
38384
+ const globalReadonlyCapReached = activeReadonlyAssigned >= maxReadonlyParallelTasks;
38385
+ const writeAssignedByNode = /* @__PURE__ */ new Map();
38386
+ const assignedByNode = /* @__PURE__ */ new Map();
38387
+ const providerCountByNode = /* @__PURE__ */ new Map();
38388
+ for (const task of assignedTasks) {
38389
+ const nodeId = typeof task.assignedNodeId === "string" ? task.assignedNodeId.trim() : "";
38390
+ if (!nodeId) continue;
38391
+ assignedByNode.set(nodeId, (assignedByNode.get(nodeId) ?? 0) + 1);
38392
+ if (!isReadonly(task)) {
38393
+ writeAssignedByNode.set(nodeId, (writeAssignedByNode.get(nodeId) ?? 0) + 1);
38394
+ }
38395
+ const provider = typeof task.assignedProviderType === "string" ? task.assignedProviderType : "";
38396
+ if (provider) {
38397
+ let byProvider = providerCountByNode.get(nodeId);
38398
+ if (!byProvider) {
38399
+ byProvider = /* @__PURE__ */ new Map();
38400
+ providerCountByNode.set(nodeId, byProvider);
38401
+ }
38402
+ byProvider.set(provider, (byProvider.get(provider) ?? 0) + 1);
38403
+ }
38404
+ }
38405
+ const nodes = [];
38406
+ for (const rawNode of Array.isArray(mesh?.nodes) ? mesh.nodes : []) {
38407
+ const nodeId = normalizeMeshNodeId(rawNode);
38408
+ if (!nodeId) continue;
38409
+ const policy = rawNode?.policy || void 0;
38410
+ const load4 = assignedByNode.get(nodeId) ?? 0;
38411
+ const schedulingPriority = resolveNodeSchedulingPriority(policy);
38412
+ const capReasons = [];
38413
+ if (globalWriteCapReached) capReasons.push("global_max_parallel_tasks_reached");
38414
+ if ((writeAssignedByNode.get(nodeId) ?? 0) > 0) capReasons.push("node_has_active_assignment");
38415
+ let providerRoles;
38416
+ const declaredRoles = Array.isArray(policy?.providerRoles) ? policy.providerRoles : [];
38417
+ if (declaredRoles.length) {
38418
+ const byProvider = providerCountByNode.get(nodeId);
38419
+ providerRoles = [];
38420
+ for (const role of declaredRoles) {
38421
+ if (!role || typeof role !== "object") continue;
38422
+ const providerType = typeof role.providerType === "string" ? role.providerType.trim() : "";
38423
+ if (!providerType) continue;
38424
+ const maxParallel = resolveProviderMaxParallel(policy, providerType);
38425
+ const activeAssigned = byProvider?.get(providerType) ?? 0;
38426
+ const capReached = maxParallel !== void 0 && activeAssigned >= maxParallel;
38427
+ providerRoles.push({
38428
+ providerType,
38429
+ ...maxParallel !== void 0 ? { maxParallel } : {},
38430
+ activeAssigned,
38431
+ capReached
38432
+ });
38433
+ if (capReached) capReasons.push(`max_provider_parallel_reached:${providerType}`);
38434
+ }
38435
+ if (!providerRoles.length) providerRoles = void 0;
38436
+ }
38437
+ const maxConcurrentSessions = Number(policy?.maxConcurrentSessions);
38438
+ const hasSessionCap = Number.isFinite(maxConcurrentSessions) && maxConcurrentSessions >= 0;
38439
+ nodes.push({
38440
+ nodeId,
38441
+ load: load4,
38442
+ schedulingPriority,
38443
+ ...hasSessionCap ? { maxConcurrentSessions: Math.floor(maxConcurrentSessions) } : {},
38444
+ ...providerRoles ? { providerRoles } : {},
38445
+ capReached: capReasons.length > 0,
38446
+ capReasons
38447
+ });
38448
+ }
38449
+ return {
38450
+ strategy,
38451
+ maxParallelTasks,
38452
+ maxReadonlyParallelTasks,
38453
+ activeWriteAssigned,
38454
+ activeReadonlyAssigned,
38455
+ globalWriteCapReached,
38456
+ globalReadonlyCapReached,
38457
+ nodes
38458
+ };
38459
+ }
38460
+ var init_mesh_scheduling_runtime = __esm2({
38461
+ "src/mesh/mesh-scheduling-runtime.ts"() {
38462
+ "use strict";
38463
+ init_repo_mesh_types();
38464
+ init_dist();
38465
+ }
38466
+ });
38366
38467
  function readNonEmptyString2(value) {
38367
38468
  return typeof value === "string" && value.trim() ? value.trim() : "";
38368
38469
  }
@@ -43619,6 +43720,20 @@ ${cleanBody}`;
43619
43720
  }
43620
43721
  return "";
43621
43722
  }
43723
+ function recoverMeshIdByCoordinatorAndNode(coordinatorDaemonId, nodeId) {
43724
+ if (!coordinatorDaemonId) return "";
43725
+ const hosted = listMeshes().filter((mesh) => {
43726
+ const host = resolveMeshHostStatus(mesh);
43727
+ return host.role === "host" && (!host.hostDaemonId || daemonIdsEquivalent(host.hostDaemonId, coordinatorDaemonId));
43728
+ });
43729
+ if (hosted.length === 0) return "";
43730
+ if (nodeId) {
43731
+ const byNode = hosted.find((mesh) => Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId)));
43732
+ if (byNode) return readNonEmptyString2(byNode.id);
43733
+ return "";
43734
+ }
43735
+ return hosted.length === 1 ? readNonEmptyString2(hosted[0].id) : "";
43736
+ }
43622
43737
  function resolveForwardEventMeshId(components, payload) {
43623
43738
  const direct = readNonEmptyString2(payload.meshId);
43624
43739
  if (direct) return direct;
@@ -44365,7 +44480,10 @@ ${cleanBody}`;
44365
44480
  }
44366
44481
  const nodeId = readNonEmptyString2(payload.nodeId);
44367
44482
  const workspace = readNonEmptyString2(payload.workspace);
44368
- const meshId = readNonEmptyString2(payload.meshId) || (workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "") || recoverMeshIdByNodeId(nodeId);
44483
+ const meshId = readNonEmptyString2(payload.meshId) || (workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "") || recoverMeshIdByNodeId(nodeId) || recoverMeshIdByCoordinatorAndNode(
44484
+ readNonEmptyString2(payload.meshCoordinatorDaemonId) || readNonEmptyString2(payload.coordinatorDaemonId),
44485
+ nodeId
44486
+ );
44369
44487
  if (!meshId) {
44370
44488
  traceMeshEventDrop("meshId_required", {
44371
44489
  taskId: payload.taskId,
@@ -44420,7 +44538,12 @@ ${cleanBody}`;
44420
44538
  ...event,
44421
44539
  event: eventName,
44422
44540
  nodeId: readNonEmptyString2(routing.nodeId) || readNonEmptyString2(event.meshNodeId) || void 0,
44423
- workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0
44541
+ workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0,
44542
+ // Fix B: carry the resolved coordinator anchor so the coordinator's receive-side
44543
+ // recovery (recoverMeshIdByCoordinatorAndNode) can match this forward to one of the
44544
+ // meshes it hosts when workspace + nodeId both miss. routing.coordinatorDaemonId is
44545
+ // the same anchor this forward is addressed to (coordinatorDaemonId below).
44546
+ meshCoordinatorDaemonId: coordinatorDaemonId
44424
44547
  };
44425
44548
  const resolvedMeshId = resolveForwardEventMeshId(components, payload);
44426
44549
  if (resolvedMeshId) payload.meshId = resolvedMeshId;
@@ -44555,6 +44678,7 @@ ${cleanBody}`;
44555
44678
  init_mesh_runtime_store();
44556
44679
  init_mesh_events_pending();
44557
44680
  init_mesh_routing();
44681
+ init_mesh_host_ownership();
44558
44682
  init_mesh_unresolved_forward_outbox();
44559
44683
  init_mesh_event_trace();
44560
44684
  init_snapshot();
@@ -53138,98 +53262,7 @@ ${lastSnapshot}`;
53138
53262
  init_mesh_work_queue();
53139
53263
  init_mesh_active_work();
53140
53264
  init_mesh_refine_status();
53141
- init_repo_mesh_types();
53142
- init_dist();
53143
- function isReadonly(task) {
53144
- return task.taskMode === "live_debug_readonly";
53145
- }
53146
- function isAssigned(task) {
53147
- return task.status === "assigned";
53148
- }
53149
- function buildMeshSchedulingRuntime(mesh, queue) {
53150
- const strategy = normalizeMeshSchedulingStrategy(mesh?.policy?.schedulingStrategy);
53151
- const maxParallelTasks = resolveMaxParallelTasks(mesh?.policy?.maxParallelTasks);
53152
- const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
53153
- const assignedTasks = (Array.isArray(queue) ? queue : []).filter(isAssigned);
53154
- const activeWriteAssigned = assignedTasks.filter((t) => !isReadonly(t)).length;
53155
- const activeReadonlyAssigned = assignedTasks.filter(isReadonly).length;
53156
- const globalWriteCapReached = activeWriteAssigned >= maxParallelTasks;
53157
- const globalReadonlyCapReached = activeReadonlyAssigned >= maxReadonlyParallelTasks;
53158
- const writeAssignedByNode = /* @__PURE__ */ new Map();
53159
- const assignedByNode = /* @__PURE__ */ new Map();
53160
- const providerCountByNode = /* @__PURE__ */ new Map();
53161
- for (const task of assignedTasks) {
53162
- const nodeId = typeof task.assignedNodeId === "string" ? task.assignedNodeId.trim() : "";
53163
- if (!nodeId) continue;
53164
- assignedByNode.set(nodeId, (assignedByNode.get(nodeId) ?? 0) + 1);
53165
- if (!isReadonly(task)) {
53166
- writeAssignedByNode.set(nodeId, (writeAssignedByNode.get(nodeId) ?? 0) + 1);
53167
- }
53168
- const provider = typeof task.assignedProviderType === "string" ? task.assignedProviderType : "";
53169
- if (provider) {
53170
- let byProvider = providerCountByNode.get(nodeId);
53171
- if (!byProvider) {
53172
- byProvider = /* @__PURE__ */ new Map();
53173
- providerCountByNode.set(nodeId, byProvider);
53174
- }
53175
- byProvider.set(provider, (byProvider.get(provider) ?? 0) + 1);
53176
- }
53177
- }
53178
- const nodes = [];
53179
- for (const rawNode of Array.isArray(mesh?.nodes) ? mesh.nodes : []) {
53180
- const nodeId = normalizeMeshNodeId(rawNode);
53181
- if (!nodeId) continue;
53182
- const policy = rawNode?.policy || void 0;
53183
- const load4 = assignedByNode.get(nodeId) ?? 0;
53184
- const schedulingPriority = resolveNodeSchedulingPriority(policy);
53185
- const capReasons = [];
53186
- if (globalWriteCapReached) capReasons.push("global_max_parallel_tasks_reached");
53187
- if ((writeAssignedByNode.get(nodeId) ?? 0) > 0) capReasons.push("node_has_active_assignment");
53188
- let providerRoles;
53189
- const declaredRoles = Array.isArray(policy?.providerRoles) ? policy.providerRoles : [];
53190
- if (declaredRoles.length) {
53191
- const byProvider = providerCountByNode.get(nodeId);
53192
- providerRoles = [];
53193
- for (const role of declaredRoles) {
53194
- if (!role || typeof role !== "object") continue;
53195
- const providerType = typeof role.providerType === "string" ? role.providerType.trim() : "";
53196
- if (!providerType) continue;
53197
- const maxParallel = resolveProviderMaxParallel(policy, providerType);
53198
- const activeAssigned = byProvider?.get(providerType) ?? 0;
53199
- const capReached = maxParallel !== void 0 && activeAssigned >= maxParallel;
53200
- providerRoles.push({
53201
- providerType,
53202
- ...maxParallel !== void 0 ? { maxParallel } : {},
53203
- activeAssigned,
53204
- capReached
53205
- });
53206
- if (capReached) capReasons.push(`max_provider_parallel_reached:${providerType}`);
53207
- }
53208
- if (!providerRoles.length) providerRoles = void 0;
53209
- }
53210
- const maxConcurrentSessions = Number(policy?.maxConcurrentSessions);
53211
- const hasSessionCap = Number.isFinite(maxConcurrentSessions) && maxConcurrentSessions >= 0;
53212
- nodes.push({
53213
- nodeId,
53214
- load: load4,
53215
- schedulingPriority,
53216
- ...hasSessionCap ? { maxConcurrentSessions: Math.floor(maxConcurrentSessions) } : {},
53217
- ...providerRoles ? { providerRoles } : {},
53218
- capReached: capReasons.length > 0,
53219
- capReasons
53220
- });
53221
- }
53222
- return {
53223
- strategy,
53224
- maxParallelTasks,
53225
- maxReadonlyParallelTasks,
53226
- activeWriteAssigned,
53227
- activeReadonlyAssigned,
53228
- globalWriteCapReached,
53229
- globalReadonlyCapReached,
53230
- nodes
53231
- };
53232
- }
53265
+ init_mesh_scheduling_runtime();
53233
53266
  init_mesh_host_ownership();
53234
53267
  init_mesh_events();
53235
53268
  init_mesh_events_utils();
@@ -68844,9 +68877,35 @@ ${body}
68844
68877
  * terminal state. Leaving meshNodeFor pinned would route this session's
68845
68878
  * subsequent unrelated turns (e.g. ad-hoc dashboard chats) to the
68846
68879
  * coordinator as if they were task completions.
68880
+ *
68881
+ * MESHID-DROP-ON-DETACH (Fix C): a coordinator-LAUNCHED worker session
68882
+ * (launchedByCoordinator) holds its mesh membership (meshNodeFor / meshNodeId /
68883
+ * meshCoordinatorDaemonId) at the SESSION level — set once at launch
68884
+ * (mesh_launch_session / queue auto-launch), independent of any single task.
68885
+ * The original detach wiped meshNodeFor + meshNodeId together with the
68886
+ * task-level meshActiveTaskId, so the FIRST task completion stripped the
68887
+ * membership and EVERY subsequent completion forwarded with meshId absent —
68888
+ * resolveWorkerDelegateRouting fell to mesh_unresolved and the coordinator
68889
+ * rejected the forward "meshId required". For a launched member we therefore
68890
+ * clear ONLY the task-level marker (meshActiveTaskId) and preserve the
68891
+ * session-level membership so its next task's completion still resolves.
68892
+ * A task-less ad-hoc turn on a preserved-membership session is NOT misrouted:
68893
+ * its completion carries no taskId and the session holds no active assignment,
68894
+ * so the forwarder's WARMUPGAP guard skips the dispatch-row flip (it only
68895
+ * injects a benign task-less notification). A NON-launched session (a plain CLI
68896
+ * session adopted by mesh_send_task --direct, launchedByCoordinator falsy)
68897
+ * keeps the original full clear so an ad-hoc session is never left pinned.
68847
68898
  */
68848
68899
  detachMeshAssignment() {
68849
68900
  if (!this.settings.meshNodeFor && !this.settings.meshActiveTaskId && !this.settings.meshNodeId) return;
68901
+ if (this.settings.launchedByCoordinator === true) {
68902
+ if (!this.settings.meshActiveTaskId) return;
68903
+ const { meshActiveTaskId: meshActiveTaskId2, ...rest2 } = this.settings;
68904
+ void meshActiveTaskId2;
68905
+ this.settings = rest2;
68906
+ this.adapter.updateRuntimeSettings?.(this.settings);
68907
+ return;
68908
+ }
68850
68909
  const { meshNodeFor, meshNodeId, meshActiveTaskId, ...rest } = this.settings;
68851
68910
  void meshNodeFor;
68852
68911
  void meshActiveTaskId;
@@ -78651,6 +78710,9 @@ ${ptyResult.output.slice(-2e3)}`);
78651
78710
  const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
78652
78711
  const queue = getQueue2(meshId);
78653
78712
  const queueSummary = getMeshQueueStats2(meshId);
78713
+ const { buildMeshSchedulingRuntime: buildMeshSchedulingRuntime2 } = await Promise.resolve().then(() => (init_mesh_scheduling_runtime(), mesh_scheduling_runtime_exports));
78714
+ const schedulingRuntime = buildMeshSchedulingRuntime2(mesh, queue);
78715
+ const schedulingByNode = new Map(schedulingRuntime.nodes.map((n) => [n.nodeId, n]));
78654
78716
  const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
78655
78717
  const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
78656
78718
  const asyncRefineLedgerEntries = readLedgerEntries2(meshId, { tail: 100 });
@@ -78765,6 +78827,11 @@ ${ptyResult.output.slice(-2e3)}`);
78765
78827
  activeSessionDetails: [],
78766
78828
  launchReady: false
78767
78829
  };
78830
+ const nodeScheduling = schedulingByNode.get(nodeId);
78831
+ if (nodeScheduling) {
78832
+ const { nodeId: _omitNodeId, ...nodeSchedulingRest } = nodeScheduling;
78833
+ status.scheduling = nodeSchedulingRest;
78834
+ }
78768
78835
  if (isSelfNode) {
78769
78836
  status.connection = {
78770
78837
  perspective: "selected_coordinator",
@@ -78965,6 +79032,19 @@ ${ptyResult.output.slice(-2e3)}`);
78965
79032
  branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
78966
79033
  ...previewFreshness ? { previewFreshness, deployFreshness: previewFreshness } : {},
78967
79034
  nodes: nodeStatuses,
79035
+ // Mesh-level scheduling rollup (strategy + global cap consumption). Mirrors
79036
+ // the MCP `mesh_status` tool's `scheduling` block field-for-field so both
79037
+ // surfaces read the same runtime; per-node detail lives on each
79038
+ // nodes[].scheduling above.
79039
+ scheduling: {
79040
+ strategy: schedulingRuntime.strategy,
79041
+ maxParallelTasks: schedulingRuntime.maxParallelTasks,
79042
+ maxReadonlyParallelTasks: schedulingRuntime.maxReadonlyParallelTasks,
79043
+ activeWriteAssigned: schedulingRuntime.activeWriteAssigned,
79044
+ activeReadonlyAssigned: schedulingRuntime.activeReadonlyAssigned,
79045
+ globalWriteCapReached: schedulingRuntime.globalWriteCapReached,
79046
+ globalReadonlyCapReached: schedulingRuntime.globalReadonlyCapReached
79047
+ },
78968
79048
  queue: { tasks: queue, summary: queueSummary },
78969
79049
  ledger: { entries: ledgerEntries, summary: ledgerSummary },
78970
79050
  ...missions.length > 0 ? { missions } : {},