@adhdev/daemon-standalone 1.0.49-rc.3 → 1.0.49-rc.5
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
|
@@ -37056,10 +37056,10 @@ var require_dist3 = __commonJS({
|
|
|
37056
37056
|
}
|
|
37057
37057
|
function getDaemonBuildInfo() {
|
|
37058
37058
|
if (cached2) return cached2;
|
|
37059
|
-
const commit = readInjected(true ? "
|
|
37060
|
-
const commitShort = readInjected(true ? "
|
|
37061
|
-
const version2 = readInjected(true ? "1.0.49-rc.
|
|
37062
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
37059
|
+
const commit = readInjected(true ? "0b3c203b7ae08f860c52a4dd7ee88edddd48d8cb" : void 0) ?? "unknown";
|
|
37060
|
+
const commitShort = readInjected(true ? "0b3c203b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
37061
|
+
const version2 = readInjected(true ? "1.0.49-rc.5" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
37062
|
+
const builtAt = readInjected(true ? "2026-08-14T13:19:52.123Z" : void 0);
|
|
37063
37063
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
37064
37064
|
return cached2;
|
|
37065
37065
|
}
|
|
@@ -42270,6 +42270,8 @@ ${error48.message || ""}`;
|
|
|
42270
42270
|
interpolateArgs: () => interpolateArgs,
|
|
42271
42271
|
interpolateString: () => interpolateString,
|
|
42272
42272
|
isMeshTaskDifficulty: () => isMeshTaskDifficulty,
|
|
42273
|
+
isPhantomDaemonEntry: () => isPhantomDaemonEntry,
|
|
42274
|
+
isRawDaemonDoId: () => isRawDaemonDoId,
|
|
42273
42275
|
joinRepoPath: () => joinRepoPath,
|
|
42274
42276
|
machineCoreFromDaemonId: () => machineCoreFromDaemonId,
|
|
42275
42277
|
meshNodeIdMatches: () => meshNodeIdMatches,
|
|
@@ -42565,6 +42567,18 @@ ${error48.message || ""}`;
|
|
|
42565
42567
|
if (!left || !right) return false;
|
|
42566
42568
|
return left === right;
|
|
42567
42569
|
}
|
|
42570
|
+
function isRawDaemonDoId(id) {
|
|
42571
|
+
const trimmed = readString2(id);
|
|
42572
|
+
return !!trimmed && /^[0-9a-f]{64}$/i.test(trimmed);
|
|
42573
|
+
}
|
|
42574
|
+
function isPhantomDaemonEntry(entry) {
|
|
42575
|
+
if (!entry) return false;
|
|
42576
|
+
if (!isRawDaemonDoId(entry.id)) return false;
|
|
42577
|
+
const hasMachineEvidence = Boolean(
|
|
42578
|
+
readString2(entry.machineNickname) || readString2(entry.nickname) || readString2(entry.hostname) || readString2(entry.platform) || readString2(entry.machine?.hostname) || readString2(entry.machine?.platform) || readString2(entry.machineId) || Array.isArray(entry.sessions) && entry.sessions.length > 0
|
|
42579
|
+
);
|
|
42580
|
+
return !hasMachineEvidence;
|
|
42581
|
+
}
|
|
42568
42582
|
function machineCoreFromDaemonId(id) {
|
|
42569
42583
|
const trimmed = readString2(id);
|
|
42570
42584
|
if (!trimmed) return void 0;
|
|
@@ -55444,6 +55458,8 @@ ${rendered}`, "utf-8");
|
|
|
55444
55458
|
});
|
|
55445
55459
|
function readProviderPriorityFromPolicy(policy) {
|
|
55446
55460
|
const record2 = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
55461
|
+
const derived = deriveProviderPriorityFromSlots(record2.slots);
|
|
55462
|
+
if (derived.length) return derived;
|
|
55447
55463
|
const raw = record2.providerPriority;
|
|
55448
55464
|
if (Array.isArray(raw)) {
|
|
55449
55465
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -55454,7 +55470,7 @@ ${rendered}`, "utf-8");
|
|
|
55454
55470
|
});
|
|
55455
55471
|
if (explicit.length) return explicit;
|
|
55456
55472
|
}
|
|
55457
|
-
return
|
|
55473
|
+
return [];
|
|
55458
55474
|
}
|
|
55459
55475
|
function normalizeProviderRoles(value) {
|
|
55460
55476
|
if (!Array.isArray(value)) return [];
|
|
@@ -55536,7 +55552,7 @@ ${rendered}`, "utf-8");
|
|
|
55536
55552
|
const workspace = readStringValue(node.workspace, node.repoRoot, node.repo_root);
|
|
55537
55553
|
const workspaceName = workspace ? workingDirBasename(workspace) : void 0;
|
|
55538
55554
|
const host = readStringValue(node.machineName, node.machine_name, node.hostname, node.host, node.daemonId, node.daemon_id, node.machineId, node.machine_id);
|
|
55539
|
-
const provider = providerPriority[0] || (Array.isArray(node.providers) ? readStringValue(...node.providers) : void 0);
|
|
55555
|
+
const provider = readProviderPriorityFromPolicy(node.policy)[0] || providerPriority[0] || (Array.isArray(node.providers) ? readStringValue(...node.providers) : void 0);
|
|
55540
55556
|
const parts = [workspaceName, host, provider].filter(Boolean);
|
|
55541
55557
|
if (parts.length > 0) return parts.join(" \xB7 ");
|
|
55542
55558
|
return nodeId || "unidentified mesh node";
|
|
@@ -57712,7 +57728,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57712
57728
|
init_mesh_work_queue();
|
|
57713
57729
|
}
|
|
57714
57730
|
});
|
|
57715
|
-
function
|
|
57731
|
+
function directQuotaEntryFor(node, providerType) {
|
|
57716
57732
|
const facts = node?.nodeFacts;
|
|
57717
57733
|
if (!facts || typeof facts !== "object") return null;
|
|
57718
57734
|
const reportedAt = Number(facts.reportedAt);
|
|
@@ -57721,6 +57737,14 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57721
57737
|
if (!quota || typeof quota !== "object") return null;
|
|
57722
57738
|
return { facts: { reportedAt }, quota };
|
|
57723
57739
|
}
|
|
57740
|
+
function quotaEntryFor(node, providerType, context) {
|
|
57741
|
+
const direct = directQuotaEntryFor(node, providerType);
|
|
57742
|
+
if (direct) return direct;
|
|
57743
|
+
const sourceNodeId = typeof node?.clonedFromNodeId === "string" ? node.clonedFromNodeId.trim() : "";
|
|
57744
|
+
if (!sourceNodeId || !Array.isArray(context?.nodes)) return null;
|
|
57745
|
+
const sourceNode = context.nodes.find((candidate) => candidate !== node && meshNodeIdMatches(candidate, sourceNodeId));
|
|
57746
|
+
return sourceNode ? directQuotaEntryFor(sourceNode, providerType) : null;
|
|
57747
|
+
}
|
|
57724
57748
|
function quotaSnapshotAgeMs(facts, quota, now = Date.now()) {
|
|
57725
57749
|
const updatedAt = Number(quota.updatedAt);
|
|
57726
57750
|
if (!Number.isFinite(updatedAt) || updatedAt <= 0) return Number.POSITIVE_INFINITY;
|
|
@@ -57743,8 +57767,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57743
57767
|
const reporterNowMs = Number(quota.updatedAt) + ageMs2;
|
|
57744
57768
|
return resetsAt - reporterNowMs < imminentMs;
|
|
57745
57769
|
}
|
|
57746
|
-
function evaluateProviderQuotaGate(node, providerType, policy, now = Date.now()) {
|
|
57747
|
-
const entry = quotaEntryFor(node, providerType);
|
|
57770
|
+
function evaluateProviderQuotaGate(node, providerType, policy, now = Date.now(), context) {
|
|
57771
|
+
const entry = quotaEntryFor(node, providerType, context);
|
|
57748
57772
|
if (!entry) return null;
|
|
57749
57773
|
const { facts, quota } = entry;
|
|
57750
57774
|
if (quota.status !== "ok") {
|
|
@@ -57756,9 +57780,12 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57756
57780
|
thresholdPercent: 0
|
|
57757
57781
|
};
|
|
57758
57782
|
}
|
|
57783
|
+
if (quota.metadata?.lastGoodWindows !== true || !isQuotaSnapshotFresh(facts, quota, policy, now)) {
|
|
57784
|
+
return null;
|
|
57785
|
+
}
|
|
57786
|
+
} else if (!isQuotaSnapshotFresh(facts, quota, policy, now)) {
|
|
57759
57787
|
return null;
|
|
57760
57788
|
}
|
|
57761
|
-
if (!isQuotaSnapshotFresh(facts, quota, policy, now)) return null;
|
|
57762
57789
|
const resolved = resolveQuotaRoutingPolicy(policy);
|
|
57763
57790
|
const session = remainingPercent(quota.session);
|
|
57764
57791
|
if (session !== void 0 && session < resolved.sessionMinRemainingPercent && !isSessionResetImminent(quota.session, facts, quota, resolved.sessionResetImminentMs, now)) {
|
|
@@ -57780,8 +57807,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57780
57807
|
}
|
|
57781
57808
|
return null;
|
|
57782
57809
|
}
|
|
57783
|
-
function expiryRiskForRanking(node, providerType, axis, policy, now = Date.now()) {
|
|
57784
|
-
const entry = quotaEntryFor(node, providerType);
|
|
57810
|
+
function expiryRiskForRanking(node, providerType, axis, policy, now = Date.now(), context) {
|
|
57811
|
+
const entry = quotaEntryFor(node, providerType, context);
|
|
57785
57812
|
if (!entry) return void 0;
|
|
57786
57813
|
const { facts, quota } = entry;
|
|
57787
57814
|
if (quota.status !== "ok") return void 0;
|
|
@@ -57800,19 +57827,19 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57800
57827
|
const elapsedFraction = Math.min(1, Math.max(0, 1 - (resetsAt - reporterNowMs) / windowMs));
|
|
57801
57828
|
return { remainingPercent: remaining, risk: remaining * elapsedFraction };
|
|
57802
57829
|
}
|
|
57803
|
-
function rankProvidersByQuotaGate(node, orderedProviderTypes, policy, now = Date.now()) {
|
|
57830
|
+
function rankProvidersByQuotaGate(node, orderedProviderTypes, policy, now = Date.now(), context) {
|
|
57804
57831
|
const clear = [];
|
|
57805
57832
|
const gated = [];
|
|
57806
57833
|
for (const providerType of orderedProviderTypes) {
|
|
57807
|
-
const block2 = evaluateProviderQuotaGate(node, providerType, policy, now);
|
|
57834
|
+
const block2 = evaluateProviderQuotaGate(node, providerType, policy, now, context);
|
|
57808
57835
|
if (block2) gated.push({ providerType, block: block2 });
|
|
57809
57836
|
else clear.push(providerType);
|
|
57810
57837
|
}
|
|
57811
|
-
const weeklyByProvider = new Map(clear.map((p) => [p, expiryRiskForRanking(node, p, "weekly", policy, now)]));
|
|
57838
|
+
const weeklyByProvider = new Map(clear.map((p) => [p, expiryRiskForRanking(node, p, "weekly", policy, now, context)]));
|
|
57812
57839
|
const headroomPercent = resolveQuotaRoutingPolicy(policy).sessionAxisWeeklyHeadroomPercent;
|
|
57813
57840
|
const weeklyMeasured = [...weeklyByProvider.values()].filter((w) => w !== void 0);
|
|
57814
57841
|
const sessionAxisActive = weeklyMeasured.length > 0 && weeklyMeasured.every((w) => w.remainingPercent > headroomPercent);
|
|
57815
|
-
const sessionByProvider = sessionAxisActive ? new Map(clear.map((p) => [p, expiryRiskForRanking(node, p, "session", policy, now)])) : void 0;
|
|
57842
|
+
const sessionByProvider = sessionAxisActive ? new Map(clear.map((p) => [p, expiryRiskForRanking(node, p, "session", policy, now, context)])) : void 0;
|
|
57816
57843
|
clear.sort((a, b) => {
|
|
57817
57844
|
const wa = weeklyByProvider.get(a);
|
|
57818
57845
|
const wb = weeklyByProvider.get(b);
|
|
@@ -57835,13 +57862,13 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57835
57862
|
});
|
|
57836
57863
|
return { clear, gated };
|
|
57837
57864
|
}
|
|
57838
|
-
function resolveRecoveryRelaunchProvider(node, failedProviderType, nodeProviderTypes = [], policy, now = Date.now()) {
|
|
57865
|
+
function resolveRecoveryRelaunchProvider(node, failedProviderType, nodeProviderTypes = [], policy, now = Date.now(), context) {
|
|
57839
57866
|
if (!failedProviderType) return { action: "block" };
|
|
57840
|
-
const block2 = evaluateProviderQuotaGate(node, failedProviderType, policy, now);
|
|
57867
|
+
const block2 = evaluateProviderQuotaGate(node, failedProviderType, policy, now, context);
|
|
57841
57868
|
if (!block2) return { action: "keep", providerType: failedProviderType };
|
|
57842
57869
|
const alternatives = nodeProviderTypes.filter((p) => p && p !== failedProviderType);
|
|
57843
57870
|
if (alternatives.length) {
|
|
57844
|
-
const ranked = rankProvidersByQuotaGate(node, alternatives, policy, now);
|
|
57871
|
+
const ranked = rankProvidersByQuotaGate(node, alternatives, policy, now, context);
|
|
57845
57872
|
if (ranked.clear.length) {
|
|
57846
57873
|
return { action: "fallback", providerType: ranked.clear[0], block: block2 };
|
|
57847
57874
|
}
|
|
@@ -57856,9 +57883,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57856
57883
|
}
|
|
57857
57884
|
return `QUOTA GATE: skipping recovery relaunch for node ${nodeId} \u2014 ${cause} and the node has no gate-clear alternative${taskId ? `; task ${taskId}` : ""} stays queued until a quota window resets`;
|
|
57858
57885
|
}
|
|
57859
|
-
function quotaRiskSnapshotForCandidates(node, orderedProviderTypes, policy, now = Date.now()) {
|
|
57886
|
+
function quotaRiskSnapshotForCandidates(node, orderedProviderTypes, policy, now = Date.now(), context) {
|
|
57860
57887
|
return orderedProviderTypes.map((providerType) => {
|
|
57861
|
-
const w = expiryRiskForRanking(node, providerType, "weekly", policy, now);
|
|
57888
|
+
const w = expiryRiskForRanking(node, providerType, "weekly", policy, now, context);
|
|
57862
57889
|
return {
|
|
57863
57890
|
providerType,
|
|
57864
57891
|
...w ? { remainingPercent: w.remainingPercent, risk: w.risk } : {}
|
|
@@ -57902,6 +57929,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
57902
57929
|
var init_mesh_quota_routing = __esm2({
|
|
57903
57930
|
"src/mesh/mesh-quota-routing.ts"() {
|
|
57904
57931
|
"use strict";
|
|
57932
|
+
init_dist();
|
|
57905
57933
|
init_repo_mesh_types();
|
|
57906
57934
|
PROVIDER_QUOTA_SESSION_LOW_SKIP_REASON = "provider_quota_session_low";
|
|
57907
57935
|
PROVIDER_QUOTA_WEEKLY_LOW_SKIP_REASON = "provider_quota_weekly_low";
|
|
@@ -61941,7 +61969,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
61941
61969
|
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`);
|
|
61942
61970
|
return false;
|
|
61943
61971
|
}
|
|
61944
|
-
const quotaClaimBlock = evaluateProviderQuotaGate(node, providerType, mesh?.policy?.quotaRouting ?? null);
|
|
61972
|
+
const quotaClaimBlock = evaluateProviderQuotaGate(node, providerType, mesh?.policy?.quotaRouting ?? null, Date.now(), mesh);
|
|
61945
61973
|
if (quotaClaimBlock) {
|
|
61946
61974
|
if (quotaClaimBlock.reason === PROVIDER_QUOTA_EXHAUSTED_SKIP_REASON) {
|
|
61947
61975
|
LOG2.info("MeshQueue", `QUOTA GATE: deferring queue claim for node ${nodeId} (${sessionId}): provider '${providerType}' reported its quota EXHAUSTED \u2014 task left pending until the quota resets`);
|
|
@@ -62418,7 +62446,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62418
62446
|
retractActionableSkipIfPreviouslyNotified(meshId, taskId);
|
|
62419
62447
|
}
|
|
62420
62448
|
}
|
|
62421
|
-
async function resolveUsableProvider(components, nodeId, node, meshId, requiredTags, task, quotaRouting) {
|
|
62449
|
+
async function resolveUsableProvider(components, nodeId, node, meshId, requiredTags, task, quotaRouting, quotaFactsContext) {
|
|
62422
62450
|
const providerLoader = components.providerLoader;
|
|
62423
62451
|
if (!providerLoader) return { reason: "provider_loader_unavailable" };
|
|
62424
62452
|
const slots = resolveNodeCapabilitySlots(node, meshId);
|
|
@@ -62466,8 +62494,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62466
62494
|
if (!candidates.length) {
|
|
62467
62495
|
return { reason: `provider_priority_unusable: ${failed.join("; ") || nodeId}` };
|
|
62468
62496
|
}
|
|
62469
|
-
const ranked = rankProvidersByQuotaGate(node, candidates.map((c) => c.providerType), quotaRouting);
|
|
62470
|
-
const riskSnapshot = quotaRiskSnapshotForCandidates(node, ranked.clear, quotaRouting);
|
|
62497
|
+
const ranked = rankProvidersByQuotaGate(node, candidates.map((c) => c.providerType), quotaRouting, Date.now(), quotaFactsContext);
|
|
62498
|
+
const riskSnapshot = quotaRiskSnapshotForCandidates(node, ranked.clear, quotaRouting, Date.now(), quotaFactsContext);
|
|
62471
62499
|
if (!ranked.clear.length) {
|
|
62472
62500
|
const detail = ranked.gated.map((g) => `${g.providerType}: ${g.block.reason}`).join("; ");
|
|
62473
62501
|
LOG2.info("MeshQueue", `QUOTA GATE: every usable provider on node ${nodeId} is quota-gated (${detail}); leaving the task queued until a quota window resets`);
|
|
@@ -62718,7 +62746,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62718
62746
|
}
|
|
62719
62747
|
autoLaunchInProgress.add(launchKey);
|
|
62720
62748
|
try {
|
|
62721
|
-
const resolved = await resolveUsableProvider(components, nodeId, node, meshId, task.requiredTags, { difficulty: task.difficulty, requiredTags: task.requiredTags }, mesh?.policy?.quotaRouting ?? null);
|
|
62749
|
+
const resolved = await resolveUsableProvider(components, nodeId, node, meshId, task.requiredTags, { difficulty: task.difficulty, requiredTags: task.requiredTags }, mesh?.policy?.quotaRouting ?? null, mesh);
|
|
62722
62750
|
if (!resolved.providerType) {
|
|
62723
62751
|
markSkip(nodeId, resolved.reason || "provider_unusable");
|
|
62724
62752
|
continue;
|
|
@@ -66393,7 +66421,9 @@ ${cleanBody}`;
|
|
|
66393
66421
|
node,
|
|
66394
66422
|
recoveryContext.failedProviderType,
|
|
66395
66423
|
resolveNodeCapabilitySlots(node, args.meshId).map((s2) => s2.provider),
|
|
66396
|
-
mesh?.policy?.quotaRouting ?? null
|
|
66424
|
+
mesh?.policy?.quotaRouting ?? null,
|
|
66425
|
+
Date.now(),
|
|
66426
|
+
mesh
|
|
66397
66427
|
) : { action: "block" };
|
|
66398
66428
|
const relaunchProviderType = relaunch.action === "block" ? null : relaunch.providerType;
|
|
66399
66429
|
if (node) {
|
|
@@ -110583,7 +110613,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110583
110613
|
...slots.length ? { slots } : {}
|
|
110584
110614
|
};
|
|
110585
110615
|
if (providerRoles.length) migrateProviderRolesToSlots2(policy);
|
|
110586
|
-
|
|
110616
|
+
syncProviderPriorityFromSlots(policy);
|
|
110587
110617
|
const role = normalizeMeshDaemonRole(args?.role);
|
|
110588
110618
|
const daemonId = typeof args?.daemonId === "string" && args.daemonId.trim() ? args.daemonId.trim() : void 0;
|
|
110589
110619
|
const machineId = typeof args?.machineId === "string" && args.machineId.trim() ? args.machineId.trim() : void 0;
|
|
@@ -110635,10 +110665,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110635
110665
|
else delete policy.providerRoles;
|
|
110636
110666
|
}
|
|
110637
110667
|
migrateProviderRolesToSlots2(policy);
|
|
110638
|
-
|
|
110639
|
-
|
|
110640
|
-
syncProviderPriorityFromSlots(policy, finalSlots);
|
|
110641
|
-
}
|
|
110668
|
+
const finalSlots = Object.prototype.hasOwnProperty.call(policy, "slots") ? policy.slots : getMesh2(meshId)?.nodes.find((n) => n.id === nodeId)?.policy?.slots;
|
|
110669
|
+
syncProviderPriorityFromSlots(policy, finalSlots);
|
|
110642
110670
|
const patch = { policy };
|
|
110643
110671
|
if (typeof args?.systemPrompt === "string") {
|
|
110644
110672
|
const trimmed = args.systemPrompt.trim();
|
|
@@ -110663,9 +110691,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
110663
110691
|
...inlineNode.policy && typeof inlineNode.policy === "object" && !Array.isArray(inlineNode.policy) ? inlineNode.policy : {},
|
|
110664
110692
|
...patch.policy
|
|
110665
110693
|
};
|
|
110666
|
-
|
|
110667
|
-
syncProviderPriorityFromSlots(inlineNode.policy);
|
|
110668
|
-
}
|
|
110694
|
+
syncProviderPriorityFromSlots(inlineNode.policy);
|
|
110669
110695
|
if (Object.prototype.hasOwnProperty.call(patch, "systemPrompt")) {
|
|
110670
110696
|
const sp = patch.systemPrompt;
|
|
110671
110697
|
if (typeof sp === "string" && sp.trim()) inlineNode.systemPrompt = sp;
|