@adhdev/daemon-core 0.9.82-rc.320 → 0.9.82-rc.322

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
@@ -35,35 +35,6 @@ function resolveNodeSchedulingPriority(nodePolicy) {
35
35
  const raw = Number(nodePolicy?.schedulingPriority);
36
36
  return Number.isFinite(raw) ? raw : 0;
37
37
  }
38
- function resolveTaskAffinityRole(taskMode, policy) {
39
- if (!taskMode) return null;
40
- if (policy?.enabled === false) return null;
41
- const override = policy?.byTaskMode && Object.prototype.hasOwnProperty.call(policy.byTaskMode, taskMode) ? policy.byTaskMode[taskMode] : void 0;
42
- if (typeof override === "string") {
43
- const trimmed = override.trim().toLowerCase();
44
- return trimmed ? trimmed : null;
45
- }
46
- const fallback = DEFAULT_TASKMODE_ROLE_MAP[taskMode];
47
- return fallback ?? null;
48
- }
49
- function resolveMeshRoleOptions(policy) {
50
- const out = [...STANDARD_MESH_ROLES];
51
- const seen = new Set(out);
52
- const add = (raw) => {
53
- if (typeof raw !== "string") return;
54
- const role = raw.trim().toLowerCase();
55
- if (!role || seen.has(role)) return;
56
- seen.add(role);
57
- out.push(role);
58
- };
59
- if (policy?.byTaskMode) {
60
- for (const value of Object.values(policy.byTaskMode)) add(value);
61
- }
62
- if (Array.isArray(policy?.customRoles)) {
63
- for (const value of policy.customRoles) add(value);
64
- }
65
- return out;
66
- }
67
38
  function resolveAutoConvergeCodeChange(policy) {
68
39
  return policy?.autoConvergeCodeChange === true;
69
40
  }
@@ -76,7 +47,7 @@ function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
76
47
  }
77
48
  return true;
78
49
  }
79
- function resolveProviderRole(nodePolicy, providerType) {
50
+ function resolveProviderMaxParallel(nodePolicy, providerType) {
80
51
  const wanted = typeof providerType === "string" ? providerType.trim().toLowerCase() : "";
81
52
  if (!wanted) return void 0;
82
53
  const roles = nodePolicy?.providerRoles;
@@ -84,17 +55,14 @@ function resolveProviderRole(nodePolicy, providerType) {
84
55
  for (const entry of roles) {
85
56
  if (!entry || typeof entry !== "object") continue;
86
57
  const type = typeof entry.providerType === "string" ? entry.providerType.trim().toLowerCase() : "";
87
- if (type && type === wanted) return entry;
58
+ if (!type || type !== wanted) continue;
59
+ const raw = Number(entry.maxParallel);
60
+ if (!Number.isFinite(raw) || raw < 0) return void 0;
61
+ return Math.floor(raw);
88
62
  }
89
63
  return void 0;
90
64
  }
91
- function resolveProviderMaxParallel(nodePolicy, providerType) {
92
- const role = resolveProviderRole(nodePolicy, providerType);
93
- const raw = Number(role?.maxParallel);
94
- if (!Number.isFinite(raw) || raw < 0) return void 0;
95
- return Math.floor(raw);
96
- }
97
- var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, STANDARD_MESH_ROLES, DEFAULT_TASKMODE_ROLE_MAP, DEFAULT_MESH_POLICY;
65
+ var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY;
98
66
  var init_repo_mesh_types = __esm({
99
67
  "src/repo-mesh-types.ts"() {
100
68
  "use strict";
@@ -107,14 +75,6 @@ var init_repo_mesh_types = __esm({
107
75
  DEFAULT_MESH_SCHEDULING_STRATEGY = "first_eligible";
108
76
  MESH_CONVERGE_REFINE_TAG = "converge=refine";
109
77
  MESH_CONVERGE_FAST_FORWARD_TAG = "converge=fast_forward";
110
- STANDARD_MESH_ROLES = ["investigator", "coder", "validator", "converger"];
111
- DEFAULT_TASKMODE_ROLE_MAP = {
112
- live_debug_readonly: "investigator",
113
- code_change: "coder",
114
- launch_app: "coder",
115
- validation: "validator",
116
- convergence: "converger"
117
- };
118
78
  DEFAULT_MESH_POLICY = {
119
79
  requirePreTaskCheckpoint: false,
120
80
  requirePostTaskCheckpoint: true,
@@ -348,10 +308,10 @@ function readInjected(value) {
348
308
  }
349
309
  function getDaemonBuildInfo() {
350
310
  if (cached) return cached;
351
- const commit = readInjected(true ? "bbaf30f95c09531cec77fb48a8cf6d38b3b6d7f9" : void 0) ?? "unknown";
352
- const commitShort = readInjected(true ? "bbaf30f9" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
353
- const version = readInjected(true ? "0.9.82-rc.320" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
354
- const builtAt = readInjected(true ? "2026-06-19T01:16:38.511Z" : void 0);
311
+ const commit = readInjected(true ? "c19690a16292dbcb1ed5ff5458b94596fce46e38" : void 0) ?? "unknown";
312
+ const commitShort = readInjected(true ? "c19690a1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
313
+ const version = readInjected(true ? "0.9.82-rc.322" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
314
+ const builtAt = readInjected(true ? "2026-06-19T05:42:02.504Z" : void 0);
355
315
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
356
316
  return cached;
357
317
  }
@@ -1587,11 +1547,42 @@ function loadMeshConfig() {
1587
1547
  try {
1588
1548
  const raw = JSON.parse(readFileSync2(path42, "utf-8"));
1589
1549
  if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
1590
- return raw;
1550
+ const config = raw;
1551
+ const migrated = migrateLoadedMeshConfig(config);
1552
+ if (migrated) {
1553
+ try {
1554
+ saveMeshConfig(config);
1555
+ } catch {
1556
+ }
1557
+ }
1558
+ return config;
1591
1559
  } catch {
1592
1560
  return { meshes: [] };
1593
1561
  }
1594
1562
  }
1563
+ function migrateLoadedMeshConfig(config) {
1564
+ let changed = false;
1565
+ for (const mesh of config.meshes) {
1566
+ if (!mesh || !Array.isArray(mesh.nodes)) continue;
1567
+ for (const node of mesh.nodes) {
1568
+ if (stripDeadRoleFromProviderRoles(node?.policy)) changed = true;
1569
+ }
1570
+ }
1571
+ return changed;
1572
+ }
1573
+ function stripDeadRoleFromProviderRoles(policy) {
1574
+ if (!policy || typeof policy !== "object") return false;
1575
+ const roles = policy.providerRoles;
1576
+ if (!Array.isArray(roles)) return false;
1577
+ let changed = false;
1578
+ for (const entry of roles) {
1579
+ if (entry && typeof entry === "object" && !Array.isArray(entry) && Object.prototype.hasOwnProperty.call(entry, "role")) {
1580
+ delete entry.role;
1581
+ changed = true;
1582
+ }
1583
+ }
1584
+ return changed;
1585
+ }
1595
1586
  function normalizeCapabilityTags(value) {
1596
1587
  if (!Array.isArray(value)) return void 0;
1597
1588
  const seen = /* @__PURE__ */ new Set();
@@ -1655,61 +1646,8 @@ function mergeMeshPolicy(base, patch) {
1655
1646
  } else {
1656
1647
  delete policy.autoConvergeCodeChange;
1657
1648
  }
1658
- const normalizedAffinity = normalizeTaskAffinityPolicy(policy.taskAffinity);
1659
- if (normalizedAffinity) {
1660
- policy.taskAffinity = normalizedAffinity;
1661
- } else {
1662
- delete policy.taskAffinity;
1663
- }
1664
1649
  return policy;
1665
1650
  }
1666
- function normalizeTaskAffinityPolicy(value) {
1667
- if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
1668
- const record = value;
1669
- const out = {};
1670
- let hasContent = false;
1671
- if (typeof record.enabled === "boolean") {
1672
- out.enabled = record.enabled;
1673
- if (record.enabled === false) hasContent = true;
1674
- else delete out.enabled;
1675
- }
1676
- if (record.byTaskMode && typeof record.byTaskMode === "object" && !Array.isArray(record.byTaskMode)) {
1677
- const byTaskMode = {};
1678
- for (const [mode, raw] of Object.entries(record.byTaskMode)) {
1679
- const modeKey = mode.trim();
1680
- if (!modeKey) continue;
1681
- if (typeof raw !== "string") continue;
1682
- const role = raw.trim().toLowerCase();
1683
- byTaskMode[modeKey] = role;
1684
- if (role && !STANDARD_MESH_ROLES.includes(role)) {
1685
- try {
1686
- console.warn(`[mesh] task_affinity.byTaskMode.${modeKey}: custom role "${role}" is not a standard mesh role (${STANDARD_MESH_ROLES.join("/")}); routing still applies`);
1687
- } catch {
1688
- }
1689
- }
1690
- }
1691
- if (Object.keys(byTaskMode).length > 0) {
1692
- out.byTaskMode = byTaskMode;
1693
- hasContent = true;
1694
- }
1695
- }
1696
- if (Array.isArray(record.customRoles)) {
1697
- const seen = /* @__PURE__ */ new Set();
1698
- const customRoles = [];
1699
- for (const raw of record.customRoles) {
1700
- if (typeof raw !== "string") continue;
1701
- const role = raw.trim().toLowerCase();
1702
- if (!role || seen.has(role)) continue;
1703
- seen.add(role);
1704
- customRoles.push(role);
1705
- }
1706
- if (customRoles.length > 0) {
1707
- out.customRoles = customRoles;
1708
- hasContent = true;
1709
- }
1710
- }
1711
- return hasContent ? out : void 0;
1712
- }
1713
1651
  function normalizeAutoFastForwardPolicy(value) {
1714
1652
  const record = value && typeof value === "object" && !Array.isArray(value) ? value : {};
1715
1653
  const maxBehind = Number(record.maxBehind);
@@ -2166,11 +2104,10 @@ function buildNodeConfigSection(mesh) {
2166
2104
  const providerRoles = Array.isArray(n.policy?.providerRoles) ? n.policy.providerRoles.map((r) => {
2167
2105
  const type = typeof r?.providerType === "string" ? r.providerType.trim() : "";
2168
2106
  if (!type) return "";
2169
- const role = typeof r?.role === "string" && r.role.trim() ? `=${r.role.trim()}` : "";
2170
2107
  const cap = Number.isFinite(Number(r?.maxParallel)) ? ` (max ${Math.floor(Number(r.maxParallel))})` : "";
2171
- return `${type}${role}${cap}`;
2108
+ return `${type}${cap}`;
2172
2109
  }).filter(Boolean) : [];
2173
- const providerRolesSuffix = providerRoles.length ? ` | roles: ${providerRoles.join(", ")}` : "";
2110
+ const providerRolesSuffix = providerRoles.length ? ` | caps: ${providerRoles.join(", ")}` : "";
2174
2111
  lines.push(`- ${explicitLabel} nodeId: \`${n.id}\` | workspace: \`${n.workspace}\`${n.daemonId ? ` | daemon: \`${n.daemonId}\`` : ""}${providerPriority}${providerRolesSuffix}${suffix}`);
2175
2112
  const nodePrompt = typeof n.systemPrompt === "string" ? n.systemPrompt.trim() : "";
2176
2113
  if (nodePrompt) {
@@ -3000,7 +2937,6 @@ __export(mesh_work_queue_exports, {
3000
2937
  recordTaskAutoLaunch: () => recordTaskAutoLaunch,
3001
2938
  requeueTask: () => requeueTask,
3002
2939
  resolveConvergeRequiredTags: () => resolveConvergeRequiredTags,
3003
- resolveTaskAffinityRequiredTags: () => resolveTaskAffinityRequiredTags,
3004
2940
  updateDirectDispatchStatus: () => updateDirectDispatchStatus,
3005
2941
  updateSessionTaskStatus: () => updateSessionTaskStatus,
3006
2942
  updateTaskStatus: () => updateTaskStatus,
@@ -3075,21 +3011,6 @@ function firstProviderPriority(policy) {
3075
3011
  if (!Array.isArray(raw)) return void 0;
3076
3012
  return raw.find((type) => typeof type === "string" && type.trim())?.trim();
3077
3013
  }
3078
- function roleCapabilityTags(policy, providerType) {
3079
- const roles = policy && typeof policy === "object" && !Array.isArray(policy) ? policy.providerRoles : void 0;
3080
- if (!Array.isArray(roles)) return [];
3081
- const wantedProvider = typeof providerType === "string" && providerType.trim() ? providerType.trim().toLowerCase() : "";
3082
- const out = [];
3083
- for (const entry of roles) {
3084
- if (!entry || typeof entry !== "object") continue;
3085
- const type = typeof entry.providerType === "string" ? entry.providerType.trim().toLowerCase() : "";
3086
- const role = typeof entry.role === "string" ? entry.role.trim().toLowerCase() : "";
3087
- if (!role) continue;
3088
- if (wantedProvider && type && type !== wantedProvider) continue;
3089
- out.push(`role=${role}`);
3090
- }
3091
- return out;
3092
- }
3093
3014
  function buildMeshNodeCapabilityTags(node, providerType) {
3094
3015
  const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
3095
3016
  const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
@@ -3112,14 +3033,7 @@ function buildMeshNodeCapabilityTags(node, providerType) {
3112
3033
  // receives the task instead). Reuses the ordinary required-tags filter —
3113
3034
  // the load-balancing scheduler auto-injects converge=refine for code_change
3114
3035
  // so such work is hard-filtered onto refine-capable nodes.
3115
- ...node?.isLocalWorktree === true ? ["converge=refine"] : ["converge=fast_forward"],
3116
- // Role-based routing: advertise role=<x> for each (node, provider) role
3117
- // declared in policy.providerRoles. Narrowed to the selected provider when
3118
- // one is given so the chosen provider must match a task's required role;
3119
- // when no provider is selected, all declared roles are advertised for the
3120
- // node-level eligibility scan. Reuses the ordinary required-tags filter —
3121
- // no separate role field/gate.
3122
- ...roleCapabilityTags(node?.policy, providerType)
3036
+ ...node?.isLocalWorktree === true ? ["converge=refine"] : ["converge=fast_forward"]
3123
3037
  ]);
3124
3038
  }
3125
3039
  function nodeSatisfiesRequiredTags(requiredTags, capabilityTags) {
@@ -3140,31 +3054,6 @@ function resolveConvergeRequiredTags(meshId, taskMode, explicitRequiredTags, opt
3140
3054
  if (!optedIn) return explicitRequiredTags;
3141
3055
  return normalizeMeshCapabilityTags([...explicitRequiredTags, MESH_CONVERGE_REFINE_TAG]);
3142
3056
  }
3143
- function meshHasNodeAdvertisingRole(nodes, role) {
3144
- if (!Array.isArray(nodes) || nodes.length === 0) return false;
3145
- const wanted = `role=${role}`;
3146
- return nodes.some((node) => buildMeshNodeCapabilityTags(node).includes(wanted));
3147
- }
3148
- function resolveTaskAffinityRequiredTags(meshId, taskMode, explicitRequiredTags, opts) {
3149
- if (typeof opts?.targetNodeId === "string" && opts.targetNodeId.trim()) return explicitRequiredTags;
3150
- if (opts?.callerSpecifiedRequiredTags === true) return explicitRequiredTags;
3151
- let mesh;
3152
- try {
3153
- mesh = getMesh(meshId);
3154
- } catch {
3155
- return explicitRequiredTags;
3156
- }
3157
- const role = resolveTaskAffinityRole(taskMode, mesh?.policy?.taskAffinity);
3158
- if (!role) return explicitRequiredTags;
3159
- if (!meshHasNodeAdvertisingRole(mesh?.nodes, role)) {
3160
- try {
3161
- console.warn(`[mesh] task_affinity: no node advertises role=${role} for taskMode=${taskMode} in mesh ${meshId}; skipping injection (least_loaded fallback)`);
3162
- } catch {
3163
- }
3164
- return explicitRequiredTags;
3165
- }
3166
- return normalizeMeshCapabilityTags([...explicitRequiredTags, `role=${role}`]);
3167
- }
3168
3057
  function withQueueLock(_meshId, fn) {
3169
3058
  return MeshRuntimeStore.getInstance().transaction(fn);
3170
3059
  }
@@ -3216,19 +3105,12 @@ function enqueueTask(meshId, message, opts) {
3216
3105
  }
3217
3106
  assertNoDependencyCycle(meshId, id, dependsOn);
3218
3107
  const callerTags = normalizeMeshCapabilityTags(opts?.requiredTags);
3219
- const callerSpecifiedRequiredTags = callerTags.length > 0;
3220
- let resolvedRequiredTags = resolveConvergeRequiredTags(
3108
+ const resolvedRequiredTags = resolveConvergeRequiredTags(
3221
3109
  meshId,
3222
3110
  modeValidation.taskMode,
3223
3111
  callerTags,
3224
3112
  { targetNodeId: opts?.targetNodeId }
3225
3113
  );
3226
- resolvedRequiredTags = resolveTaskAffinityRequiredTags(
3227
- meshId,
3228
- modeValidation.taskMode,
3229
- resolvedRequiredTags,
3230
- { targetNodeId: opts?.targetNodeId, callerSpecifiedRequiredTags }
3231
- );
3232
3114
  const entry = {
3233
3115
  id,
3234
3116
  meshId,
@@ -42476,8 +42358,6 @@ function normalizeProviderRoles(value) {
42476
42358
  const providerType = typeof rec.providerType === "string" ? rec.providerType.trim() : "";
42477
42359
  if (!providerType) continue;
42478
42360
  const entry = { providerType };
42479
- const role = typeof rec.role === "string" ? rec.role.trim() : "";
42480
- if (role) entry.role = role;
42481
42361
  const maxParallel = Number(rec.maxParallel);
42482
42362
  if (Number.isFinite(maxParallel) && maxParallel >= 0) entry.maxParallel = Math.floor(maxParallel);
42483
42363
  byType.set(providerType.toLowerCase(), entry);
@@ -42547,7 +42427,7 @@ function buildMeshNodeDisplayLabel(node, nodeId, providerPriority) {
42547
42427
  const explicit = readStringValue(node.machineLabel, node.machine_label, node.machineNickname, node.machine_nickname, node.alias);
42548
42428
  if (explicit) return explicit;
42549
42429
  const workspace = readStringValue(node.workspace, node.repoRoot, node.repo_root);
42550
- const workspaceName = workspace ? pathBasename(workspace) : void 0;
42430
+ const workspaceName = workspace ? workingDirBasename(workspace) : void 0;
42551
42431
  const host = readStringValue(node.machineName, node.machine_name, node.hostname, node.host, node.daemonId, node.daemon_id, node.machineId, node.machine_id);
42552
42432
  const provider = providerPriority[0] || (Array.isArray(node.providers) ? readStringValue(...node.providers) : void 0);
42553
42433
  const parts = [workspaceName, host, provider].filter(Boolean);
@@ -43044,6 +42924,13 @@ function readCachedInlineMeshActiveSessions(node) {
43044
42924
  const sessionId = readStringValue(fallbackSession.id, fallbackSession.sessionId, fallbackSession.session_id, node?.activeSessionId, node?.active_session_id, node?.sessionId, node?.session_id);
43045
42925
  return sessionId ? [sessionId] : [];
43046
42926
  }
42927
+ function resolveMeshNodeAttribution(node) {
42928
+ const record = readObjectRecord(node);
42929
+ return {
42930
+ daemonId: readMeshNodeDaemonId(record),
42931
+ machineName: readMeshNodeDisplayMachineName(record)
42932
+ };
42933
+ }
43047
42934
  function readCachedInlineMeshActiveSessionDetails(node) {
43048
42935
  const cachedStatus = readObjectRecord(node?.cachedStatus);
43049
42936
  const activeSession = readObjectRecord(cachedStatus.activeSession);
@@ -58268,7 +58155,6 @@ export {
58268
58155
  DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS,
58269
58156
  DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS,
58270
58157
  DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS,
58271
- DEFAULT_TASKMODE_ROLE_MAP,
58272
58158
  DEV_SERVER_PORT,
58273
58159
  DaemonAgentStreamManager,
58274
58160
  DaemonCdpInitializer,
@@ -58308,7 +58194,6 @@ export {
58308
58194
  RawTerminalAttachment,
58309
58195
  STALE_TERMINAL_REFINE_WINDOW_MS,
58310
58196
  STANDALONE_CDP_SCAN_INTERVAL_MS,
58311
- STANDARD_MESH_ROLES,
58312
58197
  SessionHostPtyTransportFactory,
58313
58198
  TerminalAdapter,
58314
58199
  TurnSnapshotTracker,
@@ -58541,13 +58426,11 @@ export {
58541
58426
  resolveDeliveryDecision,
58542
58427
  resolveGitRepository,
58543
58428
  resolveMeshHostStatus,
58429
+ resolveMeshNodeAttribution,
58544
58430
  resolveMeshRefineValidationPlan,
58545
- resolveMeshRoleOptions,
58546
58431
  resolveNodeSchedulingPriority,
58547
58432
  resolveSessionHostAppName,
58548
58433
  resolveSessionHostAppNameResolution,
58549
- resolveTaskAffinityRequiredTags,
58550
- resolveTaskAffinityRole,
58551
58434
  resolveWorktreePath,
58552
58435
  runAsyncBatch,
58553
58436
  runGit,