@adhdev/daemon-standalone 1.0.56-rc.15 → 1.0.56-rc.17
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
|
@@ -36620,10 +36620,10 @@ var require_dist3 = __commonJS({
|
|
|
36620
36620
|
}
|
|
36621
36621
|
function getDaemonBuildInfo() {
|
|
36622
36622
|
if (cached2) return cached2;
|
|
36623
|
-
const commit = readInjected(true ? "
|
|
36624
|
-
const commitShort = readInjected(true ? "
|
|
36625
|
-
const version2 = readInjected(true ? "1.0.56-rc.
|
|
36626
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36623
|
+
const commit = readInjected(true ? "575d84363f3756976fe6c7ff5847da752f4b3ddf" : void 0) ?? "unknown";
|
|
36624
|
+
const commitShort = readInjected(true ? "575d8436" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36625
|
+
const version2 = readInjected(true ? "1.0.56-rc.17" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36626
|
+
const builtAt = readInjected(true ? "2026-08-20T11:09:14.700Z" : void 0);
|
|
36627
36627
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36628
36628
|
return cached2;
|
|
36629
36629
|
}
|
|
@@ -38622,6 +38622,11 @@ var require_dist3 = __commonJS({
|
|
|
38622
38622
|
init_config();
|
|
38623
38623
|
}
|
|
38624
38624
|
});
|
|
38625
|
+
function antigravityUserAgent() {
|
|
38626
|
+
const os31 = process.platform === "win32" ? "windows" : process.platform;
|
|
38627
|
+
const arch2 = process.arch === "x64" ? "amd64" : process.arch;
|
|
38628
|
+
return `antigravity/${ANTIGRAVITY_USER_AGENT_VERSION} ${os31}/${arch2}`;
|
|
38629
|
+
}
|
|
38625
38630
|
function baseUrl(env2) {
|
|
38626
38631
|
const override = env2.ANTIGRAVITY_CLOUDCODE_BASE_URL?.trim();
|
|
38627
38632
|
return (override ? override : DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
@@ -38975,7 +38980,8 @@ var require_dist3 = __commonJS({
|
|
|
38975
38980
|
headers: {
|
|
38976
38981
|
Authorization: `Bearer ${credentials.accessToken}`,
|
|
38977
38982
|
"Content-Type": "application/json",
|
|
38978
|
-
Accept: "application/json"
|
|
38983
|
+
Accept: "application/json",
|
|
38984
|
+
"User-Agent": antigravityUserAgent()
|
|
38979
38985
|
},
|
|
38980
38986
|
// ★MUST stay `{}` — verified live that sending `project` or
|
|
38981
38987
|
// `metadata` makes the server answer 429/400.
|
|
@@ -39015,6 +39021,7 @@ var require_dist3 = __commonJS({
|
|
|
39015
39021
|
}
|
|
39016
39022
|
}
|
|
39017
39023
|
var DEFAULT_BASE_URL;
|
|
39024
|
+
var ANTIGRAVITY_USER_AGENT_VERSION;
|
|
39018
39025
|
var REQUEST_TIMEOUT_MS;
|
|
39019
39026
|
var EXPIRY_SKEW_MS;
|
|
39020
39027
|
var CRED_STORE_TIMEOUT_MS;
|
|
@@ -39028,7 +39035,8 @@ var require_dist3 = __commonJS({
|
|
|
39028
39035
|
"use strict";
|
|
39029
39036
|
init_types();
|
|
39030
39037
|
init_deps();
|
|
39031
|
-
DEFAULT_BASE_URL = "https://cloudcode-pa.googleapis.com/v1internal";
|
|
39038
|
+
DEFAULT_BASE_URL = "https://daily-cloudcode-pa.googleapis.com/v1internal";
|
|
39039
|
+
ANTIGRAVITY_USER_AGENT_VERSION = "1.1.16";
|
|
39032
39040
|
REQUEST_TIMEOUT_MS = 1e4;
|
|
39033
39041
|
EXPIRY_SKEW_MS = 5e3;
|
|
39034
39042
|
CRED_STORE_TIMEOUT_MS = 5e3;
|
|
@@ -39660,6 +39668,76 @@ child.on('exit', () => process.exit(0));
|
|
|
39660
39668
|
SOURCE = "statusline";
|
|
39661
39669
|
}
|
|
39662
39670
|
});
|
|
39671
|
+
function toHttpStatus(value) {
|
|
39672
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
39673
|
+
return value;
|
|
39674
|
+
}
|
|
39675
|
+
if (typeof value === "string" && /^\d{3}$/.test(value.trim())) {
|
|
39676
|
+
return Number(value.trim());
|
|
39677
|
+
}
|
|
39678
|
+
return null;
|
|
39679
|
+
}
|
|
39680
|
+
function kindFromHttpStatus(status) {
|
|
39681
|
+
if (status === 401 || status === 403) return "unauthorized";
|
|
39682
|
+
if (status === 429) return "rate-limited";
|
|
39683
|
+
if (status >= 500 && status <= 599) return "server";
|
|
39684
|
+
return null;
|
|
39685
|
+
}
|
|
39686
|
+
function extractEmbeddedHttpStatus(text) {
|
|
39687
|
+
const bodyEq = text.match(/\bbody\s*=\s*(\{[\s\S]*\})\s*;?/);
|
|
39688
|
+
if (bodyEq?.[1]) {
|
|
39689
|
+
try {
|
|
39690
|
+
const parsed = JSON.parse(bodyEq[1]);
|
|
39691
|
+
const nested = toHttpStatus(parsed.status) ?? toHttpStatus(parsed.error?.status);
|
|
39692
|
+
const fromNested = nested !== null ? kindFromHttpStatus(nested) : null;
|
|
39693
|
+
if (fromNested && nested !== null) return nested;
|
|
39694
|
+
} catch {
|
|
39695
|
+
}
|
|
39696
|
+
}
|
|
39697
|
+
const jsonStatus = text.match(/"status"\s*:\s*(\d{3})/);
|
|
39698
|
+
if (jsonStatus) {
|
|
39699
|
+
const n = Number(jsonStatus[1]);
|
|
39700
|
+
if (kindFromHttpStatus(n)) return n;
|
|
39701
|
+
}
|
|
39702
|
+
const labelled = text.match(/\b(?:HTTP\s+|failed:\s*)(401|403|429|5\d{2})\b/i);
|
|
39703
|
+
if (labelled) return Number(labelled[1]);
|
|
39704
|
+
const phrase = text.match(/\b(401|403)\s+Unauthorized\b/i) ?? text.match(/\b(429)\s+Too Many Requests\b/i);
|
|
39705
|
+
if (phrase) return Number(phrase[1]);
|
|
39706
|
+
return null;
|
|
39707
|
+
}
|
|
39708
|
+
function extractEmbeddedErrorCode(text) {
|
|
39709
|
+
const match = text.match(/"code"\s*:\s*"([^"]+)"/);
|
|
39710
|
+
return match?.[1] ?? null;
|
|
39711
|
+
}
|
|
39712
|
+
function classifyCodexAppServerError(message) {
|
|
39713
|
+
const text = message.trim();
|
|
39714
|
+
const http4 = extractEmbeddedHttpStatus(text);
|
|
39715
|
+
if (http4 !== null) {
|
|
39716
|
+
const kind = kindFromHttpStatus(http4);
|
|
39717
|
+
if (kind) return kind;
|
|
39718
|
+
}
|
|
39719
|
+
const code = extractEmbeddedErrorCode(text);
|
|
39720
|
+
if (code && UNAUTHORIZED_ERROR_CODES.has(code)) return "unauthorized";
|
|
39721
|
+
if (/\bunauthorized\b/i.test(text)) return "unauthorized";
|
|
39722
|
+
if (NETWORK_PATTERN.test(text)) return "network";
|
|
39723
|
+
if (RATE_LIMIT_TEXT_PATTERN.test(text)) return "rate-limited";
|
|
39724
|
+
if (MISSING_CREDENTIALS_PATTERN.test(text)) return "missing-credentials";
|
|
39725
|
+
return "server";
|
|
39726
|
+
}
|
|
39727
|
+
function describeCodexRateLimitFailure(kind, text) {
|
|
39728
|
+
switch (kind) {
|
|
39729
|
+
case "missing-credentials":
|
|
39730
|
+
return `Not signed in to Codex (${text}) \u2014 run codex on this machine to sign in, then retry`;
|
|
39731
|
+
case "unauthorized":
|
|
39732
|
+
return `Codex rate-limit lookup was rejected: ${text}`;
|
|
39733
|
+
case "rate-limited":
|
|
39734
|
+
return `Codex rate-limit lookup was rate limited: ${text}`;
|
|
39735
|
+
case "network":
|
|
39736
|
+
return `Codex rate-limit lookup failed: ${text}`;
|
|
39737
|
+
default:
|
|
39738
|
+
return `Codex rate-limit request failed: ${text}`;
|
|
39739
|
+
}
|
|
39740
|
+
}
|
|
39663
39741
|
function codexCommand(env2) {
|
|
39664
39742
|
const override = env2.ADHDEV_CODEX_BIN?.trim();
|
|
39665
39743
|
return override ? override : "codex";
|
|
@@ -39843,7 +39921,7 @@ child.on('exit', () => process.exit(0));
|
|
|
39843
39921
|
finish(
|
|
39844
39922
|
quotaFailure("codex-cli", "error", `Codex rate-limit request failed: ${detail}`, {
|
|
39845
39923
|
source: "app-server",
|
|
39846
|
-
failureKind: "
|
|
39924
|
+
failureKind: "cli-unavailable"
|
|
39847
39925
|
})
|
|
39848
39926
|
);
|
|
39849
39927
|
}
|
|
@@ -39852,16 +39930,13 @@ child.on('exit', () => process.exit(0));
|
|
|
39852
39930
|
if (message.id === RATE_LIMITS_ID) {
|
|
39853
39931
|
if (message.error) {
|
|
39854
39932
|
const text = message.error.message ?? "unknown error";
|
|
39855
|
-
const
|
|
39933
|
+
const failureKind = classifyCodexAppServerError(text);
|
|
39856
39934
|
finish(
|
|
39857
39935
|
quotaFailure(
|
|
39858
39936
|
"codex-cli",
|
|
39859
|
-
|
|
39860
|
-
|
|
39861
|
-
{
|
|
39862
|
-
source: "app-server",
|
|
39863
|
-
failureKind: unauthenticated ? "missing-credentials" : "unknown"
|
|
39864
|
-
}
|
|
39937
|
+
failureKind === "missing-credentials" ? "unavailable" : "error",
|
|
39938
|
+
describeCodexRateLimitFailure(failureKind, text),
|
|
39939
|
+
{ source: "app-server", failureKind }
|
|
39865
39940
|
)
|
|
39866
39941
|
);
|
|
39867
39942
|
return;
|
|
@@ -39955,7 +40030,10 @@ child.on('exit', () => process.exit(0));
|
|
|
39955
40030
|
var ACCOUNT_ID;
|
|
39956
40031
|
var CLIENT_NAME;
|
|
39957
40032
|
var CLIENT_VERSION;
|
|
39958
|
-
var
|
|
40033
|
+
var MISSING_CREDENTIALS_PATTERN;
|
|
40034
|
+
var NETWORK_PATTERN;
|
|
40035
|
+
var RATE_LIMIT_TEXT_PATTERN;
|
|
40036
|
+
var UNAUTHORIZED_ERROR_CODES;
|
|
39959
40037
|
var init_codex = __esm2({
|
|
39960
40038
|
"src/quota/fetchers/codex.ts"() {
|
|
39961
40039
|
"use strict";
|
|
@@ -39968,7 +40046,10 @@ child.on('exit', () => process.exit(0));
|
|
|
39968
40046
|
ACCOUNT_ID = 3;
|
|
39969
40047
|
CLIENT_NAME = "adhdev";
|
|
39970
40048
|
CLIENT_VERSION = "1.0.0";
|
|
39971
|
-
|
|
40049
|
+
MISSING_CREDENTIALS_PATTERN = /not\s+signed[\s-]?in|\bsign[\s-]?in\b|\blog[\s-]?in\b|\bno account\b|authentication required/i;
|
|
40050
|
+
NETWORK_PATTERN = /\bnetwork error\b|\bENOTFOUND\b|\bECONNREFUSED\b|\bECONNRESET\b|\bETIMEDOUT\b|\bEAI_AGAIN\b|socket hang up|\bfetch failed\b|failed to fetch/i;
|
|
40051
|
+
RATE_LIMIT_TEXT_PATTERN = /\brate limit(?:ed|s)? exceeded\b|\btoo many requests\b/i;
|
|
40052
|
+
UNAUTHORIZED_ERROR_CODES = /* @__PURE__ */ new Set(["token_revoked", "invalid_token", "access_denied"]);
|
|
39972
40053
|
}
|
|
39973
40054
|
});
|
|
39974
40055
|
function grokHome(env2) {
|
|
@@ -51215,9 +51296,11 @@ The instruction it carried was never delivered to anyone. If it still matters, r
|
|
|
51215
51296
|
}
|
|
51216
51297
|
function decideSlotForModel(input) {
|
|
51217
51298
|
const { requestedModel, slots } = input;
|
|
51218
|
-
const
|
|
51299
|
+
const wanted = typeof input.providerType === "string" ? input.providerType.trim() : "";
|
|
51300
|
+
const candidates = wanted ? slots.filter((s2) => (s2.slot.provider?.trim() ?? "") === wanted) : slots;
|
|
51301
|
+
const declaring = candidates.filter((s2) => isModelAllowedBySlot(requestedModel, s2.slot));
|
|
51219
51302
|
if (!declaring.length) {
|
|
51220
|
-
const declaredModels =
|
|
51303
|
+
const declaredModels = candidates.map((s2) => typeof s2.slot.model === "string" && s2.slot.model.trim() ? s2.slot.model.trim() : "(provider default)").filter((v, i, a) => a.indexOf(v) === i);
|
|
51221
51304
|
return { outcome: "notify", reason: SLOT_MODEL_ABSENT_SKIP_REASON, declaredModels };
|
|
51222
51305
|
}
|
|
51223
51306
|
const free = declaring.find((s2) => s2.available);
|
|
@@ -51231,6 +51314,19 @@ The instruction it carried was never delivered to anyone. If it still matters, r
|
|
|
51231
51314
|
busySlots: declaring.map((s2) => s2.slot)
|
|
51232
51315
|
};
|
|
51233
51316
|
}
|
|
51317
|
+
function finalizeSlotSelection(args) {
|
|
51318
|
+
const winningModel = args.winningSlot?.model?.trim() || void 0;
|
|
51319
|
+
const finalizedModel = args.decidedSlot.model?.trim() || void 0;
|
|
51320
|
+
const demoted = args.winningSlot?.provider !== args.decidedSlot.provider || winningModel !== finalizedModel;
|
|
51321
|
+
return {
|
|
51322
|
+
slot: args.decidedSlot,
|
|
51323
|
+
model: args.decidedModel,
|
|
51324
|
+
demoted,
|
|
51325
|
+
...demoted ? {
|
|
51326
|
+
demotionReason: args.winningSlotHasCapacity ? "slot_reselected_during_launch" : "winning_slot_capacity_exhausted"
|
|
51327
|
+
} : {}
|
|
51328
|
+
};
|
|
51329
|
+
}
|
|
51234
51330
|
var CLAUDE_FAMILIES;
|
|
51235
51331
|
var MODIFIER_WORDS;
|
|
51236
51332
|
var SLOT_MODEL_BUSY_SKIP_REASON;
|
|
@@ -62845,25 +62941,32 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62845
62941
|
}
|
|
62846
62942
|
return null;
|
|
62847
62943
|
}
|
|
62944
|
+
function isStructurallyUnmeasurable(quota) {
|
|
62945
|
+
const kind = quota.metadata?.failureKind;
|
|
62946
|
+
return typeof kind === "string" && STRUCTURALLY_UNMEASURABLE_FAILURE_KINDS.has(kind);
|
|
62947
|
+
}
|
|
62848
62948
|
function expiryRiskForRanking(node, providerType, axis, policy, now = Date.now(), context) {
|
|
62849
62949
|
const entry = quotaEntryFor(node, providerType, context, now);
|
|
62850
62950
|
if (!entry) return void 0;
|
|
62851
62951
|
const { facts, quota } = entry;
|
|
62852
|
-
|
|
62853
|
-
|
|
62952
|
+
const fresh = isQuotaSnapshotFresh(facts, quota, policy, now);
|
|
62953
|
+
const confidence = quota.status === "ok" && fresh ? CONFIDENCE_CURRENT : isStructurallyUnmeasurable(quota) ? CONFIDENCE_RETAINED_STRUCTURAL : CONFIDENCE_RETAINED_AGED;
|
|
62854
62954
|
const window = axis === "session" ? quota.session : quota.weekly;
|
|
62855
62955
|
const remaining = remainingPercent(window);
|
|
62856
62956
|
if (remaining === void 0) return void 0;
|
|
62857
62957
|
const resetsAt = Number(window?.resetsAt);
|
|
62858
|
-
if (!Number.isFinite(resetsAt) || resetsAt <= 0) return { remainingPercent: remaining, risk: 0 };
|
|
62958
|
+
if (!Number.isFinite(resetsAt) || resetsAt <= 0) return { remainingPercent: remaining, risk: 0, confidence };
|
|
62859
62959
|
const ageMs2 = quotaSnapshotAgeMs(facts, quota, now);
|
|
62860
|
-
if (!Number.isFinite(ageMs2)) return { remainingPercent: remaining, risk: 0 };
|
|
62960
|
+
if (!Number.isFinite(ageMs2)) return { remainingPercent: remaining, risk: 0, confidence };
|
|
62861
62961
|
const reporterNowMs = Number(quota.updatedAt) + ageMs2;
|
|
62862
62962
|
const windowMinutes3 = Number(window?.windowMinutes);
|
|
62863
62963
|
const fallbackMinutes = axis === "session" ? DEFAULT_SESSION_WINDOW_MINUTES : DEFAULT_WEEKLY_WINDOW_MINUTES;
|
|
62864
62964
|
const windowMs = (Number.isFinite(windowMinutes3) && windowMinutes3 > 0 ? windowMinutes3 : fallbackMinutes) * 60 * 1e3;
|
|
62865
62965
|
const elapsedFraction = Math.min(1, Math.max(0, 1 - (resetsAt - reporterNowMs) / windowMs));
|
|
62866
|
-
return { remainingPercent: remaining, risk: remaining * elapsedFraction };
|
|
62966
|
+
return { remainingPercent: remaining, risk: remaining * elapsedFraction, confidence };
|
|
62967
|
+
}
|
|
62968
|
+
function rankedRisk(reading) {
|
|
62969
|
+
return reading.risk * reading.confidence;
|
|
62867
62970
|
}
|
|
62868
62971
|
function rankProvidersByQuotaGate(node, orderedProviderTypes, policy, now = Date.now(), context) {
|
|
62869
62972
|
const clear = [];
|
|
@@ -62888,14 +62991,19 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62888
62991
|
const sa = sessionByProvider.get(a);
|
|
62889
62992
|
const sb = sessionByProvider.get(b);
|
|
62890
62993
|
if (sa !== void 0 && sb !== void 0) {
|
|
62891
|
-
|
|
62994
|
+
const ra2 = rankedRisk(sa);
|
|
62995
|
+
const rb2 = rankedRisk(sb);
|
|
62996
|
+
if (rb2 !== ra2) return rb2 - ra2;
|
|
62892
62997
|
if (sb.remainingPercent !== sa.remainingPercent) {
|
|
62893
62998
|
return sb.remainingPercent - sa.remainingPercent;
|
|
62894
62999
|
}
|
|
62895
63000
|
} else if (sa !== void 0) return -1;
|
|
62896
63001
|
else if (sb !== void 0) return 1;
|
|
62897
63002
|
}
|
|
62898
|
-
|
|
63003
|
+
const ra = rankedRisk(wa);
|
|
63004
|
+
const rb = rankedRisk(wb);
|
|
63005
|
+
if (rb !== ra) return rb - ra;
|
|
63006
|
+
if (wb.confidence !== wa.confidence) return wb.confidence - wa.confidence;
|
|
62899
63007
|
return wb.remainingPercent - wa.remainingPercent;
|
|
62900
63008
|
});
|
|
62901
63009
|
return { clear, gated };
|
|
@@ -62926,10 +63034,21 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62926
63034
|
const w = expiryRiskForRanking(node, providerType, "weekly", policy, now, context);
|
|
62927
63035
|
return {
|
|
62928
63036
|
providerType,
|
|
62929
|
-
...w ? {
|
|
63037
|
+
...w ? {
|
|
63038
|
+
remainingPercent: w.remainingPercent,
|
|
63039
|
+
risk: w.risk,
|
|
63040
|
+
...w.confidence !== CONFIDENCE_CURRENT ? { confidence: w.confidence, rankedRisk: rankedRisk(w) } : {}
|
|
63041
|
+
} : {}
|
|
62930
63042
|
};
|
|
62931
63043
|
});
|
|
62932
63044
|
}
|
|
63045
|
+
function buildQuotaRankingRationale(winner, losers) {
|
|
63046
|
+
return {
|
|
63047
|
+
winner,
|
|
63048
|
+
losers: losers.slice(0, RATIONALE_LOSERS_MAX),
|
|
63049
|
+
...losers.length > RATIONALE_LOSERS_MAX ? { losersOmitted: losers.length - RATIONALE_LOSERS_MAX } : {}
|
|
63050
|
+
};
|
|
63051
|
+
}
|
|
62933
63052
|
function recordLastQuotaRanking(nodeId, record2) {
|
|
62934
63053
|
if (!nodeId) return;
|
|
62935
63054
|
lastQuotaRankingByNode.set(nodeId, record2);
|
|
@@ -62969,6 +63088,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62969
63088
|
var absentFailOpenLoggedAt;
|
|
62970
63089
|
var DEFAULT_WEEKLY_WINDOW_MINUTES;
|
|
62971
63090
|
var DEFAULT_SESSION_WINDOW_MINUTES;
|
|
63091
|
+
var CONFIDENCE_CURRENT;
|
|
63092
|
+
var CONFIDENCE_RETAINED_STRUCTURAL;
|
|
63093
|
+
var CONFIDENCE_RETAINED_AGED;
|
|
63094
|
+
var STRUCTURALLY_UNMEASURABLE_FAILURE_KINDS;
|
|
63095
|
+
var RATIONALE_LOSERS_MAX;
|
|
62972
63096
|
var lastQuotaRankingByNode;
|
|
62973
63097
|
var init_mesh_quota_routing = __esm2({
|
|
62974
63098
|
"src/mesh/mesh-quota-routing.ts"() {
|
|
@@ -62985,6 +63109,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62985
63109
|
absentFailOpenLoggedAt = /* @__PURE__ */ new Map();
|
|
62986
63110
|
DEFAULT_WEEKLY_WINDOW_MINUTES = 7 * 24 * 60;
|
|
62987
63111
|
DEFAULT_SESSION_WINDOW_MINUTES = 5 * 60;
|
|
63112
|
+
CONFIDENCE_CURRENT = 1;
|
|
63113
|
+
CONFIDENCE_RETAINED_STRUCTURAL = 0.7;
|
|
63114
|
+
CONFIDENCE_RETAINED_AGED = 0.4;
|
|
63115
|
+
STRUCTURALLY_UNMEASURABLE_FAILURE_KINDS = /* @__PURE__ */ new Set(["no-data"]);
|
|
63116
|
+
RATIONALE_LOSERS_MAX = 4;
|
|
62988
63117
|
lastQuotaRankingByNode = /* @__PURE__ */ new Map();
|
|
62989
63118
|
}
|
|
62990
63119
|
});
|
|
@@ -66998,6 +67127,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
66998
67127
|
const winnerRisk = riskByProvider.get(winner.providerType)?.risk;
|
|
66999
67128
|
return {
|
|
67000
67129
|
riskSnapshot,
|
|
67130
|
+
...losers.length ? { allLosers: losers } : {},
|
|
67001
67131
|
...riskSnapshot.length ? { quotaRiskSnapshot: riskSnapshot.slice(0, ROUTING_ARRAY_MAX) } : {},
|
|
67002
67132
|
...riskSnapshot.length > ROUTING_ARRAY_MAX ? { quotaRisksOmitted: riskSnapshot.length - ROUTING_ARRAY_MAX } : {},
|
|
67003
67133
|
...losers.length ? { intraNodeLosers: losers.slice(0, INTRA_NODE_LOSERS_MAX) } : {},
|
|
@@ -67016,6 +67146,23 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
67016
67146
|
}
|
|
67017
67147
|
};
|
|
67018
67148
|
}
|
|
67149
|
+
function selectionRationaleFrom(trajectory, allLosers) {
|
|
67150
|
+
const winner = trajectory?.providerWinner;
|
|
67151
|
+
if (!winner) return void 0;
|
|
67152
|
+
return buildQuotaRankingRationale(
|
|
67153
|
+
{
|
|
67154
|
+
providerType: winner.providerType,
|
|
67155
|
+
...winner.model ? { model: winner.model } : {},
|
|
67156
|
+
fitnessScore: winner.fitnessScore
|
|
67157
|
+
},
|
|
67158
|
+
(allLosers ?? []).map((loser) => ({
|
|
67159
|
+
providerType: loser.providerType,
|
|
67160
|
+
...loser.model ? { model: loser.model } : {},
|
|
67161
|
+
...loser.fitnessScore !== void 0 ? { fitnessScore: loser.fitnessScore } : {},
|
|
67162
|
+
reason: loser.reason
|
|
67163
|
+
}))
|
|
67164
|
+
);
|
|
67165
|
+
}
|
|
67019
67166
|
function serializedBytes(value) {
|
|
67020
67167
|
return Buffer.byteLength(JSON.stringify(value), "utf8");
|
|
67021
67168
|
}
|
|
@@ -67061,8 +67208,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
67061
67208
|
const winningSlot = args.resolved.slot;
|
|
67062
67209
|
const executedSlot = args.executedSlot ?? winningSlot;
|
|
67063
67210
|
const winningProvider = args.resolved.providerType;
|
|
67211
|
+
const executedProvider = executedSlot.provider;
|
|
67064
67212
|
const sameDeclaredProvider = winningSlot.provider === executedSlot.provider;
|
|
67065
|
-
const executedProvider = sameDeclaredProvider ? winningProvider : executedSlot.provider;
|
|
67066
67213
|
const winningModel = winningSlot.model?.trim() || void 0;
|
|
67067
67214
|
const executedModel = executedSlot.model?.trim() || void 0;
|
|
67068
67215
|
const demoted = !sameDeclaredProvider || winningModel !== executedModel;
|
|
@@ -68230,7 +68377,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
68230
68377
|
}
|
|
68231
68378
|
const ranked = rankProvidersByQuotaGate(node, candidates.map((c) => c.providerType), quotaRouting, Date.now(), quotaFactsContext);
|
|
68232
68379
|
const winner = ranked.clear.length ? candidates.find((candidate) => candidate.providerType === ranked.clear[0]) ?? candidates[0] : void 0;
|
|
68233
|
-
const { riskSnapshot, ...routingDiagnostics } = buildProviderSelectionDiagnostics({
|
|
68380
|
+
const { riskSnapshot, allLosers, ...routingDiagnostics } = buildProviderSelectionDiagnostics({
|
|
68234
68381
|
node,
|
|
68235
68382
|
nodeId,
|
|
68236
68383
|
meshId,
|
|
@@ -68245,13 +68392,15 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
68245
68392
|
ranked,
|
|
68246
68393
|
winner
|
|
68247
68394
|
});
|
|
68395
|
+
const rationale = selectionRationaleFrom(routingDiagnostics.selectionTrajectory, allLosers);
|
|
68248
68396
|
if (!ranked.clear.length) {
|
|
68249
68397
|
const detail = ranked.gated.map((g) => `${g.providerType}: ${g.block.reason}`).join("; ");
|
|
68250
68398
|
LOG2.info("MeshQueue", `QUOTA GATE: every usable provider on node ${nodeId} is quota-gated (${detail}); leaving the task queued until a quota window resets`);
|
|
68251
68399
|
recordLastQuotaRanking(nodeId, {
|
|
68252
68400
|
decidedAt: Date.now(),
|
|
68253
68401
|
clear: riskSnapshot,
|
|
68254
|
-
gated: ranked.gated.map((g) => ({ providerType: g.providerType, reason: g.block.reason }))
|
|
68402
|
+
gated: ranked.gated.map((g) => ({ providerType: g.providerType, reason: g.block.reason })),
|
|
68403
|
+
...taskId ? { taskId } : {}
|
|
68255
68404
|
});
|
|
68256
68405
|
return { reason: `${ALL_PROVIDERS_QUOTA_GATED_SKIP_REASON}: ${detail}` };
|
|
68257
68406
|
}
|
|
@@ -68261,7 +68410,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
68261
68410
|
decidedAt: Date.now(),
|
|
68262
68411
|
winner: selectedWinner.providerType,
|
|
68263
68412
|
clear: riskSnapshot,
|
|
68264
|
-
gated: ranked.gated.map((g) => ({ providerType: g.providerType, reason: g.block.reason }))
|
|
68413
|
+
gated: ranked.gated.map((g) => ({ providerType: g.providerType, reason: g.block.reason })),
|
|
68414
|
+
...taskId ? { taskId } : {},
|
|
68415
|
+
...rationale ? { rationale } : {}
|
|
68265
68416
|
});
|
|
68266
68417
|
return {
|
|
68267
68418
|
providerType: selectedWinner.providerType,
|
|
@@ -68510,26 +68661,30 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
68510
68661
|
const effectiveThinkingLevel = resolveLaunchAxis(task.thinkingLevel, task.thinkingLevelSource, resolved.thinkingLevel, slotCoversDifficulty);
|
|
68511
68662
|
const slotDecision = decideSlotForModel({
|
|
68512
68663
|
requestedModel,
|
|
68664
|
+
providerType: resolved.providerType,
|
|
68513
68665
|
slots: resolveNodeCapabilitySlots(node, meshId).map((slot) => ({
|
|
68514
68666
|
slot,
|
|
68515
68667
|
available: slotHasCapacity(meshId, nodeId, node, slot, mesh?.nodes, isReadonly)
|
|
68516
68668
|
}))
|
|
68517
68669
|
});
|
|
68518
68670
|
if (slotDecision.outcome === "wait") {
|
|
68519
|
-
LOG2.info("MeshQueue", `SLOT MODEL GUARD: model '${requestedModel}' is declared on node ${nodeId} but every matching slot is at its maxParallel cap (task ${task.id}); leaving the task queued until a slot goes idle`);
|
|
68671
|
+
LOG2.info("MeshQueue", `SLOT MODEL GUARD: model '${requestedModel}' is declared on node ${nodeId} for provider '${resolved.providerType}' but every matching slot is at its maxParallel cap (task ${task.id}); leaving the task queued until a slot goes idle`);
|
|
68520
68672
|
markSkip(nodeId, slotDecision.reason, { providerType: resolved.providerType });
|
|
68521
68673
|
continue;
|
|
68522
68674
|
}
|
|
68523
68675
|
if (slotDecision.outcome === "notify") {
|
|
68524
|
-
LOG2.warn("MeshQueue", `SLOT MODEL GUARD: no slot on node ${nodeId} declares model '${requestedModel}' (declared: ${slotDecision.declaredModels.join(", ") || "none"}) for task ${task.id}; not launching \u2014 surfacing to the coordinator to re-drive`);
|
|
68676
|
+
LOG2.warn("MeshQueue", `SLOT MODEL GUARD: no '${resolved.providerType}' slot on node ${nodeId} declares model '${requestedModel}' (declared: ${slotDecision.declaredModels.join(", ") || "none"}) for task ${task.id}; not launching \u2014 surfacing to the coordinator to re-drive`);
|
|
68525
68677
|
markSkip(nodeId, slotDecision.reason, { providerType: resolved.providerType });
|
|
68526
68678
|
continue;
|
|
68527
68679
|
}
|
|
68528
|
-
const
|
|
68529
|
-
|
|
68530
|
-
|
|
68531
|
-
|
|
68532
|
-
|
|
68680
|
+
const finalization = finalizeSlotSelection({
|
|
68681
|
+
winningSlot: resolved.slot,
|
|
68682
|
+
decidedSlot: slotDecision.slot,
|
|
68683
|
+
decidedModel: slotDecision.model,
|
|
68684
|
+
winningSlotHasCapacity: slotHasCapacity(meshId, nodeId, node, resolved.slot, mesh?.nodes, isReadonly)
|
|
68685
|
+
});
|
|
68686
|
+
const rawEffectiveModel = finalization.model;
|
|
68687
|
+
const demotionReason = finalization.demotionReason;
|
|
68533
68688
|
const effectiveModel = isModelCompatibleWithProvider(rawEffectiveModel, resolved.providerType) ? rawEffectiveModel : void 0;
|
|
68534
68689
|
if (rawEffectiveModel && effectiveModel === void 0) {
|
|
68535
68690
|
LOG2.info("MeshQueue", `CODEX-400 GUARD: dropped incompatible launch model '${rawEffectiveModel}' for non-Anthropic provider '${resolved.providerType}' on node ${nodeId} (task ${task.id}); provider will use its own default model`);
|
|
@@ -132774,15 +132929,20 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
132774
132929
|
init_dist();
|
|
132775
132930
|
var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
|
|
132776
132931
|
var CLAUDE_WRAP_NOT_REPLACE_LINE = "Install wraps (not replaces) your statusline, so nothing is lost.";
|
|
132777
|
-
function
|
|
132932
|
+
function windowCue(quota) {
|
|
132933
|
+
if (quota.metadata?.lastGoodWindows === true) return "refreshing";
|
|
132934
|
+
if (quota.metadata?.failureKind === "no-data" && (quota.session || quota.weekly)) return "stale";
|
|
132935
|
+
return void 0;
|
|
132936
|
+
}
|
|
132937
|
+
function formatWindow(label, window, cue = void 0) {
|
|
132778
132938
|
if (!window) {
|
|
132779
132939
|
return ` ${label.padEnd(8)} ${import_chalk2.default.gray("not reported")}`;
|
|
132780
132940
|
}
|
|
132781
132941
|
const percent = `${window.usedPercent.toFixed(1)}%`;
|
|
132782
132942
|
const bar = renderBar(window.usedPercent);
|
|
132783
132943
|
const reset = window.resetsAt === null ? "" : import_chalk2.default.gray(` resets ${formatRelative(window.resetsAt)}`);
|
|
132784
|
-
const
|
|
132785
|
-
return ` ${label.padEnd(8)} ${bar} ${percent.padStart(6)} used${reset}${
|
|
132944
|
+
const marker = cue === "refreshing" ? import_chalk2.default.gray(" (refreshing)") : cue === "stale" ? import_chalk2.default.gray(" (stale)") : "";
|
|
132945
|
+
return ` ${label.padEnd(8)} ${bar} ${percent.padStart(6)} used${reset}${marker}`;
|
|
132786
132946
|
}
|
|
132787
132947
|
function renderBar(usedPercent) {
|
|
132788
132948
|
const width = 20;
|
|
@@ -132821,9 +132981,9 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
132821
132981
|
const account = formatQuotaAccount(quota);
|
|
132822
132982
|
console.log(account ? `${import_chalk2.default.bold(name)} ${import_chalk2.default.gray(account)}` : import_chalk2.default.bold(name));
|
|
132823
132983
|
if (quota.status === "ok" || quota.session || quota.weekly) {
|
|
132824
|
-
const
|
|
132825
|
-
console.log(formatWindow("5 hour", quota.session,
|
|
132826
|
-
console.log(formatWindow("7 day", quota.weekly,
|
|
132984
|
+
const cue = windowCue(quota);
|
|
132985
|
+
console.log(formatWindow("5 hour", quota.session, cue));
|
|
132986
|
+
console.log(formatWindow("7 day", quota.weekly, cue));
|
|
132827
132987
|
}
|
|
132828
132988
|
if (quota.error) {
|
|
132829
132989
|
const tone = quota.status === "unavailable" ? import_chalk2.default.gray : import_chalk2.default.yellow;
|