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

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 ? "d41c5687bc8d6f8a7c7f7ffeb3faac5801f146f1" : void 0) ?? "unknown";
312
+ const commitShort = readInjected(true ? "d41c5687" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
313
+ const version = readInjected(true ? "0.9.82-rc.321" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
314
+ const builtAt = readInjected(true ? "2026-06-19T03:20:44.153Z" : void 0);
355
315
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
356
316
  return cached;
357
317
  }
@@ -1655,61 +1615,8 @@ function mergeMeshPolicy(base, patch) {
1655
1615
  } else {
1656
1616
  delete policy.autoConvergeCodeChange;
1657
1617
  }
1658
- const normalizedAffinity = normalizeTaskAffinityPolicy(policy.taskAffinity);
1659
- if (normalizedAffinity) {
1660
- policy.taskAffinity = normalizedAffinity;
1661
- } else {
1662
- delete policy.taskAffinity;
1663
- }
1664
1618
  return policy;
1665
1619
  }
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
1620
  function normalizeAutoFastForwardPolicy(value) {
1714
1621
  const record = value && typeof value === "object" && !Array.isArray(value) ? value : {};
1715
1622
  const maxBehind = Number(record.maxBehind);
@@ -2166,11 +2073,10 @@ function buildNodeConfigSection(mesh) {
2166
2073
  const providerRoles = Array.isArray(n.policy?.providerRoles) ? n.policy.providerRoles.map((r) => {
2167
2074
  const type = typeof r?.providerType === "string" ? r.providerType.trim() : "";
2168
2075
  if (!type) return "";
2169
- const role = typeof r?.role === "string" && r.role.trim() ? `=${r.role.trim()}` : "";
2170
2076
  const cap = Number.isFinite(Number(r?.maxParallel)) ? ` (max ${Math.floor(Number(r.maxParallel))})` : "";
2171
- return `${type}${role}${cap}`;
2077
+ return `${type}${cap}`;
2172
2078
  }).filter(Boolean) : [];
2173
- const providerRolesSuffix = providerRoles.length ? ` | roles: ${providerRoles.join(", ")}` : "";
2079
+ const providerRolesSuffix = providerRoles.length ? ` | caps: ${providerRoles.join(", ")}` : "";
2174
2080
  lines.push(`- ${explicitLabel} nodeId: \`${n.id}\` | workspace: \`${n.workspace}\`${n.daemonId ? ` | daemon: \`${n.daemonId}\`` : ""}${providerPriority}${providerRolesSuffix}${suffix}`);
2175
2081
  const nodePrompt = typeof n.systemPrompt === "string" ? n.systemPrompt.trim() : "";
2176
2082
  if (nodePrompt) {
@@ -3000,7 +2906,6 @@ __export(mesh_work_queue_exports, {
3000
2906
  recordTaskAutoLaunch: () => recordTaskAutoLaunch,
3001
2907
  requeueTask: () => requeueTask,
3002
2908
  resolveConvergeRequiredTags: () => resolveConvergeRequiredTags,
3003
- resolveTaskAffinityRequiredTags: () => resolveTaskAffinityRequiredTags,
3004
2909
  updateDirectDispatchStatus: () => updateDirectDispatchStatus,
3005
2910
  updateSessionTaskStatus: () => updateSessionTaskStatus,
3006
2911
  updateTaskStatus: () => updateTaskStatus,
@@ -3075,21 +2980,6 @@ function firstProviderPriority(policy) {
3075
2980
  if (!Array.isArray(raw)) return void 0;
3076
2981
  return raw.find((type) => typeof type === "string" && type.trim())?.trim();
3077
2982
  }
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
2983
  function buildMeshNodeCapabilityTags(node, providerType) {
3094
2984
  const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
3095
2985
  const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
@@ -3112,14 +3002,7 @@ function buildMeshNodeCapabilityTags(node, providerType) {
3112
3002
  // receives the task instead). Reuses the ordinary required-tags filter —
3113
3003
  // the load-balancing scheduler auto-injects converge=refine for code_change
3114
3004
  // 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)
3005
+ ...node?.isLocalWorktree === true ? ["converge=refine"] : ["converge=fast_forward"]
3123
3006
  ]);
3124
3007
  }
3125
3008
  function nodeSatisfiesRequiredTags(requiredTags, capabilityTags) {
@@ -3140,31 +3023,6 @@ function resolveConvergeRequiredTags(meshId, taskMode, explicitRequiredTags, opt
3140
3023
  if (!optedIn) return explicitRequiredTags;
3141
3024
  return normalizeMeshCapabilityTags([...explicitRequiredTags, MESH_CONVERGE_REFINE_TAG]);
3142
3025
  }
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
3026
  function withQueueLock(_meshId, fn) {
3169
3027
  return MeshRuntimeStore.getInstance().transaction(fn);
3170
3028
  }
@@ -3216,19 +3074,12 @@ function enqueueTask(meshId, message, opts) {
3216
3074
  }
3217
3075
  assertNoDependencyCycle(meshId, id, dependsOn);
3218
3076
  const callerTags = normalizeMeshCapabilityTags(opts?.requiredTags);
3219
- const callerSpecifiedRequiredTags = callerTags.length > 0;
3220
- let resolvedRequiredTags = resolveConvergeRequiredTags(
3077
+ const resolvedRequiredTags = resolveConvergeRequiredTags(
3221
3078
  meshId,
3222
3079
  modeValidation.taskMode,
3223
3080
  callerTags,
3224
3081
  { targetNodeId: opts?.targetNodeId }
3225
3082
  );
3226
- resolvedRequiredTags = resolveTaskAffinityRequiredTags(
3227
- meshId,
3228
- modeValidation.taskMode,
3229
- resolvedRequiredTags,
3230
- { targetNodeId: opts?.targetNodeId, callerSpecifiedRequiredTags }
3231
- );
3232
3083
  const entry = {
3233
3084
  id,
3234
3085
  meshId,
@@ -42476,8 +42327,6 @@ function normalizeProviderRoles(value) {
42476
42327
  const providerType = typeof rec.providerType === "string" ? rec.providerType.trim() : "";
42477
42328
  if (!providerType) continue;
42478
42329
  const entry = { providerType };
42479
- const role = typeof rec.role === "string" ? rec.role.trim() : "";
42480
- if (role) entry.role = role;
42481
42330
  const maxParallel = Number(rec.maxParallel);
42482
42331
  if (Number.isFinite(maxParallel) && maxParallel >= 0) entry.maxParallel = Math.floor(maxParallel);
42483
42332
  byType.set(providerType.toLowerCase(), entry);
@@ -58268,7 +58117,6 @@ export {
58268
58117
  DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS,
58269
58118
  DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS,
58270
58119
  DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS,
58271
- DEFAULT_TASKMODE_ROLE_MAP,
58272
58120
  DEV_SERVER_PORT,
58273
58121
  DaemonAgentStreamManager,
58274
58122
  DaemonCdpInitializer,
@@ -58308,7 +58156,6 @@ export {
58308
58156
  RawTerminalAttachment,
58309
58157
  STALE_TERMINAL_REFINE_WINDOW_MS,
58310
58158
  STANDALONE_CDP_SCAN_INTERVAL_MS,
58311
- STANDARD_MESH_ROLES,
58312
58159
  SessionHostPtyTransportFactory,
58313
58160
  TerminalAdapter,
58314
58161
  TurnSnapshotTracker,
@@ -58542,12 +58389,9 @@ export {
58542
58389
  resolveGitRepository,
58543
58390
  resolveMeshHostStatus,
58544
58391
  resolveMeshRefineValidationPlan,
58545
- resolveMeshRoleOptions,
58546
58392
  resolveNodeSchedulingPriority,
58547
58393
  resolveSessionHostAppName,
58548
58394
  resolveSessionHostAppNameResolution,
58549
- resolveTaskAffinityRequiredTags,
58550
- resolveTaskAffinityRole,
58551
58395
  resolveWorktreePath,
58552
58396
  runAsyncBatch,
58553
58397
  runGit,