@adhdev/daemon-standalone 1.0.45-rc.6 → 1.0.45-rc.7
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
|
@@ -36227,6 +36227,7 @@ var require_dist3 = __commonJS({
|
|
|
36227
36227
|
function normalizeMeshSchedulingStrategy(value) {
|
|
36228
36228
|
if (typeof value !== "string") return DEFAULT_MESH_SCHEDULING_STRATEGY;
|
|
36229
36229
|
const trimmed = value.trim();
|
|
36230
|
+
if (trimmed === "least_loaded" || trimmed === "round_robin") return "fitness";
|
|
36230
36231
|
return MESH_SCHEDULING_STRATEGIES.includes(trimmed) ? trimmed : DEFAULT_MESH_SCHEDULING_STRATEGY;
|
|
36231
36232
|
}
|
|
36232
36233
|
function resolveNodeSchedulingPriority(nodePolicy) {
|
|
@@ -36239,12 +36240,14 @@ var require_dist3 = __commonJS({
|
|
|
36239
36240
|
function resolveQuotaRoutingPolicy(value) {
|
|
36240
36241
|
const staleAfterMs = Number(value?.staleAfterMs);
|
|
36241
36242
|
const sessionMin = Number(value?.sessionMinRemainingPercent);
|
|
36243
|
+
const sessionResetImminentMs = Number(value?.sessionResetImminentMs);
|
|
36242
36244
|
const weeklyMin = Number(value?.weeklyMinRemainingPercent);
|
|
36243
36245
|
const spreadMax = Number(value?.spreadBonusMax);
|
|
36244
36246
|
const clampPercentField = (n, fallback) => Number.isFinite(n) ? Math.min(100, Math.max(0, n)) : fallback;
|
|
36245
36247
|
return {
|
|
36246
36248
|
staleAfterMs: Number.isFinite(staleAfterMs) && staleAfterMs >= 0 ? Math.floor(staleAfterMs) : DEFAULT_QUOTA_ROUTING_POLICY.staleAfterMs,
|
|
36247
36249
|
sessionMinRemainingPercent: clampPercentField(sessionMin, DEFAULT_QUOTA_ROUTING_POLICY.sessionMinRemainingPercent),
|
|
36250
|
+
sessionResetImminentMs: Number.isFinite(sessionResetImminentMs) && sessionResetImminentMs >= 0 ? Math.floor(sessionResetImminentMs) : DEFAULT_QUOTA_ROUTING_POLICY.sessionResetImminentMs,
|
|
36248
36251
|
weeklyMinRemainingPercent: clampPercentField(weeklyMin, DEFAULT_QUOTA_ROUTING_POLICY.weeklyMinRemainingPercent),
|
|
36249
36252
|
spreadBonusMax: Number.isFinite(spreadMax) && spreadMax >= 0 ? spreadMax : DEFAULT_QUOTA_ROUTING_POLICY.spreadBonusMax
|
|
36250
36253
|
};
|
|
@@ -36260,6 +36263,9 @@ var require_dist3 = __commonJS({
|
|
|
36260
36263
|
if (record2.sessionMinRemainingPercent !== void 0 && resolved.sessionMinRemainingPercent !== DEFAULT_QUOTA_ROUTING_POLICY.sessionMinRemainingPercent) {
|
|
36261
36264
|
out.sessionMinRemainingPercent = resolved.sessionMinRemainingPercent;
|
|
36262
36265
|
}
|
|
36266
|
+
if (record2.sessionResetImminentMs !== void 0 && resolved.sessionResetImminentMs !== DEFAULT_QUOTA_ROUTING_POLICY.sessionResetImminentMs) {
|
|
36267
|
+
out.sessionResetImminentMs = resolved.sessionResetImminentMs;
|
|
36268
|
+
}
|
|
36263
36269
|
if (record2.weeklyMinRemainingPercent !== void 0 && resolved.weeklyMinRemainingPercent !== DEFAULT_QUOTA_ROUTING_POLICY.weeklyMinRemainingPercent) {
|
|
36264
36270
|
out.weeklyMinRemainingPercent = resolved.weeklyMinRemainingPercent;
|
|
36265
36271
|
}
|
|
@@ -36499,6 +36505,7 @@ var require_dist3 = __commonJS({
|
|
|
36499
36505
|
DEFAULT_QUOTA_ROUTING_POLICY = {
|
|
36500
36506
|
staleAfterMs: 30 * 60 * 1e3,
|
|
36501
36507
|
sessionMinRemainingPercent: 10,
|
|
36508
|
+
sessionResetImminentMs: 5 * 60 * 1e3,
|
|
36502
36509
|
weeklyMinRemainingPercent: 15,
|
|
36503
36510
|
spreadBonusMax: 30
|
|
36504
36511
|
};
|
|
@@ -37020,10 +37027,10 @@ var require_dist3 = __commonJS({
|
|
|
37020
37027
|
}
|
|
37021
37028
|
function getDaemonBuildInfo() {
|
|
37022
37029
|
if (cached2) return cached2;
|
|
37023
|
-
const commit = readInjected(true ? "
|
|
37024
|
-
const commitShort = readInjected(true ? "
|
|
37025
|
-
const version2 = readInjected(true ? "1.0.45-rc.
|
|
37026
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
37030
|
+
const commit = readInjected(true ? "c935da6be0da24d1e046a4ecb5139e8490dba7b4" : void 0) ?? "unknown";
|
|
37031
|
+
const commitShort = readInjected(true ? "c935da6b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
37032
|
+
const version2 = readInjected(true ? "1.0.45-rc.7" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
37033
|
+
const builtAt = readInjected(true ? "2026-08-12T10:49:30.678Z" : void 0);
|
|
37027
37034
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
37028
37035
|
return cached2;
|
|
37029
37036
|
}
|
|
@@ -42162,6 +42169,7 @@ ${error48.message || ""}`;
|
|
|
42162
42169
|
buildSlotProposal: () => buildSlotProposal,
|
|
42163
42170
|
canonicalDaemonId: () => canonicalDaemonId,
|
|
42164
42171
|
daemonIdsEquivalent: () => daemonIdsEquivalent,
|
|
42172
|
+
deriveProviderPriorityFromSlots: () => deriveProviderPriorityFromSlots,
|
|
42165
42173
|
deriveSlotsFromLegacy: () => deriveSlotsFromLegacy,
|
|
42166
42174
|
expandDaemonIdForms: () => expandDaemonIdForms,
|
|
42167
42175
|
formatQuotaAccount: () => formatQuotaAccount,
|
|
@@ -42626,6 +42634,16 @@ ${error48.message || ""}`;
|
|
|
42626
42634
|
};
|
|
42627
42635
|
});
|
|
42628
42636
|
}
|
|
42637
|
+
function deriveProviderPriorityFromSlots(slots) {
|
|
42638
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42639
|
+
const out = [];
|
|
42640
|
+
for (const slot of normalizeNodeCapabilitySlots(slots)) {
|
|
42641
|
+
if (seen.has(slot.provider)) continue;
|
|
42642
|
+
seen.add(slot.provider);
|
|
42643
|
+
out.push(slot.provider);
|
|
42644
|
+
}
|
|
42645
|
+
return out;
|
|
42646
|
+
}
|
|
42629
42647
|
function slotKey(slot) {
|
|
42630
42648
|
return [
|
|
42631
42649
|
slot.provider,
|
|
@@ -48572,11 +48590,12 @@ Next step: ${nextStep}`;
|
|
|
48572
48590
|
ON mesh_missions(mesh_id, status, updated_at);
|
|
48573
48591
|
|
|
48574
48592
|
-- Load-balancing scheduler: per-mesh round-robin rotation cursor. When
|
|
48575
|
-
-- the schedulingStrategy
|
|
48576
|
-
-- the
|
|
48577
|
-
--
|
|
48578
|
-
-- node. Persisted (not a module
|
|
48579
|
-
-- and stays a single source of
|
|
48593
|
+
-- the schedulingStrategy spreads work ('fitness' with no task in scope),
|
|
48594
|
+
-- eligible nodes tied at the same (priority, load) are rotated by this
|
|
48595
|
+
-- cursor so the tie-break winner cycles across scheduling passes instead
|
|
48596
|
+
-- of always favouring the same array-order node. Persisted (not a module
|
|
48597
|
+
-- Map) so rotation survives daemon restarts and stays a single source of
|
|
48598
|
+
-- truth across scheduling entry points.
|
|
48580
48599
|
CREATE TABLE IF NOT EXISTS mesh_scheduler_cursor (
|
|
48581
48600
|
mesh_id TEXT PRIMARY KEY,
|
|
48582
48601
|
cursor INTEGER NOT NULL DEFAULT 0
|
|
@@ -55243,13 +55262,16 @@ ${rendered}`, "utf-8");
|
|
|
55243
55262
|
function readProviderPriorityFromPolicy(policy) {
|
|
55244
55263
|
const record2 = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
55245
55264
|
const raw = record2.providerPriority;
|
|
55246
|
-
if (
|
|
55247
|
-
|
|
55248
|
-
|
|
55249
|
-
|
|
55250
|
-
|
|
55251
|
-
|
|
55252
|
-
|
|
55265
|
+
if (Array.isArray(raw)) {
|
|
55266
|
+
const seen = /* @__PURE__ */ new Set();
|
|
55267
|
+
const explicit = raw.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean).filter((type2) => {
|
|
55268
|
+
if (seen.has(type2)) return false;
|
|
55269
|
+
seen.add(type2);
|
|
55270
|
+
return true;
|
|
55271
|
+
});
|
|
55272
|
+
if (explicit.length) return explicit;
|
|
55273
|
+
}
|
|
55274
|
+
return deriveProviderPriorityFromSlots(record2.slots);
|
|
55253
55275
|
}
|
|
55254
55276
|
function normalizeProviderRoles(value) {
|
|
55255
55277
|
if (!Array.isArray(value)) return [];
|
|
@@ -60480,6 +60502,14 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
60480
60502
|
if (!Number.isFinite(used)) return void 0;
|
|
60481
60503
|
return Math.min(100, Math.max(0, 100 - used));
|
|
60482
60504
|
}
|
|
60505
|
+
function isSessionResetImminent(session, facts, quota, imminentMs, now) {
|
|
60506
|
+
const resetsAt = Number(session?.resetsAt);
|
|
60507
|
+
if (!Number.isFinite(resetsAt) || resetsAt <= 0) return false;
|
|
60508
|
+
const ageMs2 = quotaSnapshotAgeMs(facts, quota, now);
|
|
60509
|
+
if (!Number.isFinite(ageMs2)) return false;
|
|
60510
|
+
const reporterNowMs = Number(quota.updatedAt) + ageMs2;
|
|
60511
|
+
return resetsAt - reporterNowMs < imminentMs;
|
|
60512
|
+
}
|
|
60483
60513
|
function evaluateProviderQuotaGate(node, providerType, policy, now = Date.now()) {
|
|
60484
60514
|
const entry = quotaEntryFor(node, providerType);
|
|
60485
60515
|
if (!entry) return null;
|
|
@@ -60488,7 +60518,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
60488
60518
|
if (!isQuotaSnapshotFresh(facts, quota, policy, now)) return null;
|
|
60489
60519
|
const resolved = resolveQuotaRoutingPolicy(policy);
|
|
60490
60520
|
const session = remainingPercent(quota.session);
|
|
60491
|
-
if (session !== void 0 && session < resolved.sessionMinRemainingPercent) {
|
|
60521
|
+
if (session !== void 0 && session < resolved.sessionMinRemainingPercent && !isSessionResetImminent(quota.session, facts, quota, resolved.sessionResetImminentMs, now)) {
|
|
60492
60522
|
return {
|
|
60493
60523
|
reason: PROVIDER_QUOTA_SESSION_LOW_SKIP_REASON,
|
|
60494
60524
|
window: "session",
|
|
@@ -61228,7 +61258,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61228
61258
|
}
|
|
61229
61259
|
const priorityOf = (n) => resolveNodeSchedulingPriority(n.node?.policy);
|
|
61230
61260
|
let rotation = 0;
|
|
61231
|
-
if (strategy === "
|
|
61261
|
+
if (strategy === "fitness") {
|
|
61232
61262
|
const cursor = opts?.bumpCursor ? MeshRuntimeStore.getInstance().bumpSchedulerCursor(meshId) : MeshRuntimeStore.getInstance().getSchedulerCursor(meshId);
|
|
61233
61263
|
rotation = (cursor % nodes.length + nodes.length) % nodes.length;
|
|
61234
61264
|
}
|
|
@@ -61236,7 +61266,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61236
61266
|
return [...nodes].sort((a, b) => {
|
|
61237
61267
|
const prioDelta = priorityOf(b) - priorityOf(a);
|
|
61238
61268
|
if (prioDelta !== 0) return prioDelta;
|
|
61239
|
-
if (strategy === "
|
|
61269
|
+
if (strategy === "fitness") {
|
|
61240
61270
|
const loadDelta = nodeActiveLoad(meshId, a.nodeId) - nodeActiveLoad(meshId, b.nodeId);
|
|
61241
61271
|
if (loadDelta !== 0) return loadDelta;
|
|
61242
61272
|
}
|
|
@@ -61610,6 +61640,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61610
61640
|
LOG2.info("MeshQueue", `Deferring queue claim for node ${nodeId} (${sessionId}): an auto fast-forward is mutating its workspace \u2014 task left pending, claim re-fires next tick`);
|
|
61611
61641
|
return false;
|
|
61612
61642
|
}
|
|
61643
|
+
const quotaClaimBlock = evaluateProviderQuotaGate(node, providerType, mesh?.policy?.quotaRouting ?? null);
|
|
61644
|
+
if (quotaClaimBlock) {
|
|
61645
|
+
LOG2.info("MeshQueue", `QUOTA GATE: deferring queue claim for node ${nodeId} (${sessionId}): provider '${providerType}' has ${quotaClaimBlock.remainingPercent.toFixed(1)}% ${quotaClaimBlock.window} quota remaining (< ${quotaClaimBlock.thresholdPercent}% threshold) \u2014 task left pending until the window resets`);
|
|
61646
|
+
return false;
|
|
61647
|
+
}
|
|
61613
61648
|
const inlineBootstrapNode = (() => {
|
|
61614
61649
|
try {
|
|
61615
61650
|
const inlineMesh = components.router?.getCachedInlineMesh?.(meshId);
|
|
@@ -62604,7 +62639,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62604
62639
|
const aPrio = resolveNodeSchedulingPriority(a.node?.policy);
|
|
62605
62640
|
const bPrio = resolveNodeSchedulingPriority(b.node?.policy);
|
|
62606
62641
|
if (aPrio !== bPrio) return bPrio - aPrio;
|
|
62607
|
-
if (strategy === "
|
|
62642
|
+
if (strategy === "fitness") {
|
|
62608
62643
|
const loadDelta = nodeActiveLoad(meshId, a.nodeId) - nodeActiveLoad(meshId, b.nodeId);
|
|
62609
62644
|
if (loadDelta !== 0) return loadDelta;
|
|
62610
62645
|
}
|
|
@@ -109324,6 +109359,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109324
109359
|
if (await isAncestor2(worktreeOssSha, sourceSha)) return "advance";
|
|
109325
109360
|
return "skip_diverged";
|
|
109326
109361
|
}
|
|
109362
|
+
function syncProviderPriorityFromSlots(policy, slots = policy.slots) {
|
|
109363
|
+
const derived = deriveProviderPriorityFromSlots(slots);
|
|
109364
|
+
if (derived.length) policy.providerPriority = derived;
|
|
109365
|
+
}
|
|
109327
109366
|
async function syncClonedWorktreeSubmodules(worktreePath, sourceWorkspace, rg) {
|
|
109328
109367
|
const submodulePaths = getRegisteredSubmodulePaths(worktreePath);
|
|
109329
109368
|
if (submodulePaths.size === 0) return;
|
|
@@ -109887,12 +109926,15 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109887
109926
|
const providerPriority = Array.isArray(args?.providerPriority) ? args.providerPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean) : [];
|
|
109888
109927
|
const readOnly = args?.readOnly === true;
|
|
109889
109928
|
const providerRoles = normalizeProviderRoles(args?.providerRoles);
|
|
109929
|
+
const slots = normalizeNodeCapabilitySlots(args?.slots);
|
|
109890
109930
|
const policy = {
|
|
109891
109931
|
...readOnly ? { readOnly: true } : {},
|
|
109892
109932
|
...providerPriority.length ? { providerPriority } : {},
|
|
109893
|
-
...providerRoles.length ? { providerRoles } : {}
|
|
109933
|
+
...providerRoles.length ? { providerRoles } : {},
|
|
109934
|
+
...slots.length ? { slots } : {}
|
|
109894
109935
|
};
|
|
109895
109936
|
if (providerRoles.length) migrateProviderRolesToSlots2(policy);
|
|
109937
|
+
if (!providerPriority.length) syncProviderPriorityFromSlots(policy);
|
|
109896
109938
|
const role = normalizeMeshDaemonRole(args?.role);
|
|
109897
109939
|
const daemonId = typeof args?.daemonId === "string" && args.daemonId.trim() ? args.daemonId.trim() : void 0;
|
|
109898
109940
|
const machineId = typeof args?.machineId === "string" && args.machineId.trim() ? args.machineId.trim() : void 0;
|
|
@@ -109927,7 +109969,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109927
109969
|
const ownerFailure = await ctx.requireMeshHostMutationOwner(meshId, args?.inlineMesh, "node update");
|
|
109928
109970
|
if (ownerFailure) return ownerFailure;
|
|
109929
109971
|
try {
|
|
109930
|
-
const { updateNode: updateNode2, normalizeCapabilityTags: normalizeCapabilityTags2, migrateProviderRolesToSlots: migrateProviderRolesToSlots2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
109972
|
+
const { updateNode: updateNode2, normalizeCapabilityTags: normalizeCapabilityTags2, migrateProviderRolesToSlots: migrateProviderRolesToSlots2, getMesh: getMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
109931
109973
|
const policy = args?.policy && typeof args.policy === "object" && !Array.isArray(args.policy) ? { ...args.policy } : {};
|
|
109932
109974
|
if (Array.isArray(args?.providerPriority)) {
|
|
109933
109975
|
const providerPriority = args.providerPriority.map((type2) => typeof type2 === "string" ? type2.trim() : "").filter(Boolean);
|
|
@@ -109944,6 +109986,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109944
109986
|
else delete policy.providerRoles;
|
|
109945
109987
|
}
|
|
109946
109988
|
migrateProviderRolesToSlots2(policy);
|
|
109989
|
+
if (!Array.isArray(args?.providerPriority) && !Object.prototype.hasOwnProperty.call(policy, "providerPriority")) {
|
|
109990
|
+
const finalSlots = Object.prototype.hasOwnProperty.call(policy, "slots") ? policy.slots : getMesh2(meshId)?.nodes.find((n) => n.id === nodeId)?.policy?.slots;
|
|
109991
|
+
syncProviderPriorityFromSlots(policy, finalSlots);
|
|
109992
|
+
}
|
|
109947
109993
|
const patch = { policy };
|
|
109948
109994
|
if (typeof args?.systemPrompt === "string") {
|
|
109949
109995
|
const trimmed = args.systemPrompt.trim();
|
|
@@ -109968,6 +110014,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
109968
110014
|
...inlineNode.policy && typeof inlineNode.policy === "object" && !Array.isArray(inlineNode.policy) ? inlineNode.policy : {},
|
|
109969
110015
|
...patch.policy
|
|
109970
110016
|
};
|
|
110017
|
+
if (!Array.isArray(args?.providerPriority) && !Object.prototype.hasOwnProperty.call(patch.policy, "providerPriority")) {
|
|
110018
|
+
syncProviderPriorityFromSlots(inlineNode.policy);
|
|
110019
|
+
}
|
|
109971
110020
|
if (Object.prototype.hasOwnProperty.call(patch, "systemPrompt")) {
|
|
109972
110021
|
const sp = patch.systemPrompt;
|
|
109973
110022
|
if (typeof sp === "string" && sp.trim()) inlineNode.systemPrompt = sp;
|