@adhdev/daemon-standalone 1.0.56-rc.16 → 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 ? "c852fab0cc75bb87987f691208882a171351755d" : void 0) ?? "unknown";
36624
- const commitShort = readInjected(true ? "c852fab0" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36625
- const version2 = readInjected(true ? "1.0.56-rc.16" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36626
- const builtAt = readInjected(true ? "2026-08-20T09:06:05.030Z" : void 0);
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
  }
@@ -39668,6 +39668,76 @@ child.on('exit', () => process.exit(0));
39668
39668
  SOURCE = "statusline";
39669
39669
  }
39670
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
+ }
39671
39741
  function codexCommand(env2) {
39672
39742
  const override = env2.ADHDEV_CODEX_BIN?.trim();
39673
39743
  return override ? override : "codex";
@@ -39851,7 +39921,7 @@ child.on('exit', () => process.exit(0));
39851
39921
  finish(
39852
39922
  quotaFailure("codex-cli", "error", `Codex rate-limit request failed: ${detail}`, {
39853
39923
  source: "app-server",
39854
- failureKind: "unknown"
39924
+ failureKind: "cli-unavailable"
39855
39925
  })
39856
39926
  );
39857
39927
  }
@@ -39860,16 +39930,13 @@ child.on('exit', () => process.exit(0));
39860
39930
  if (message.id === RATE_LIMITS_ID) {
39861
39931
  if (message.error) {
39862
39932
  const text = message.error.message ?? "unknown error";
39863
- const unauthenticated = AUTH_REQUIRED_PATTERN.test(text);
39933
+ const failureKind = classifyCodexAppServerError(text);
39864
39934
  finish(
39865
39935
  quotaFailure(
39866
39936
  "codex-cli",
39867
- unauthenticated ? "unavailable" : "error",
39868
- unauthenticated ? "Not signed in to Codex \u2014 run codex on this machine to sign in, then retry" : `Codex rate-limit request failed: ${text}`,
39869
- {
39870
- source: "app-server",
39871
- failureKind: unauthenticated ? "missing-credentials" : "unknown"
39872
- }
39937
+ failureKind === "missing-credentials" ? "unavailable" : "error",
39938
+ describeCodexRateLimitFailure(failureKind, text),
39939
+ { source: "app-server", failureKind }
39873
39940
  )
39874
39941
  );
39875
39942
  return;
@@ -39963,7 +40030,10 @@ child.on('exit', () => process.exit(0));
39963
40030
  var ACCOUNT_ID;
39964
40031
  var CLIENT_NAME;
39965
40032
  var CLIENT_VERSION;
39966
- var AUTH_REQUIRED_PATTERN;
40033
+ var MISSING_CREDENTIALS_PATTERN;
40034
+ var NETWORK_PATTERN;
40035
+ var RATE_LIMIT_TEXT_PATTERN;
40036
+ var UNAUTHORIZED_ERROR_CODES;
39967
40037
  var init_codex = __esm2({
39968
40038
  "src/quota/fetchers/codex.ts"() {
39969
40039
  "use strict";
@@ -39976,7 +40046,10 @@ child.on('exit', () => process.exit(0));
39976
40046
  ACCOUNT_ID = 3;
39977
40047
  CLIENT_NAME = "adhdev";
39978
40048
  CLIENT_VERSION = "1.0.0";
39979
- AUTH_REQUIRED_PATTERN = /auth|sign[- ]?in|log[- ]?in|credential|token/i;
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"]);
39980
40053
  }
39981
40054
  });
39982
40055
  function grokHome(env2) {
@@ -51223,9 +51296,11 @@ The instruction it carried was never delivered to anyone. If it still matters, r
51223
51296
  }
51224
51297
  function decideSlotForModel(input) {
51225
51298
  const { requestedModel, slots } = input;
51226
- const declaring = slots.filter((s2) => isModelAllowedBySlot(requestedModel, s2.slot));
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));
51227
51302
  if (!declaring.length) {
51228
- const declaredModels = slots.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);
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);
51229
51304
  return { outcome: "notify", reason: SLOT_MODEL_ABSENT_SKIP_REASON, declaredModels };
51230
51305
  }
51231
51306
  const free = declaring.find((s2) => s2.available);
@@ -51239,6 +51314,19 @@ The instruction it carried was never delivered to anyone. If it still matters, r
51239
51314
  busySlots: declaring.map((s2) => s2.slot)
51240
51315
  };
51241
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
+ }
51242
51330
  var CLAUDE_FAMILIES;
51243
51331
  var MODIFIER_WORDS;
51244
51332
  var SLOT_MODEL_BUSY_SKIP_REASON;
@@ -62853,25 +62941,32 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
62853
62941
  }
62854
62942
  return null;
62855
62943
  }
62944
+ function isStructurallyUnmeasurable(quota) {
62945
+ const kind = quota.metadata?.failureKind;
62946
+ return typeof kind === "string" && STRUCTURALLY_UNMEASURABLE_FAILURE_KINDS.has(kind);
62947
+ }
62856
62948
  function expiryRiskForRanking(node, providerType, axis, policy, now = Date.now(), context) {
62857
62949
  const entry = quotaEntryFor(node, providerType, context, now);
62858
62950
  if (!entry) return void 0;
62859
62951
  const { facts, quota } = entry;
62860
- if (quota.status !== "ok") return void 0;
62861
- if (!isQuotaSnapshotFresh(facts, quota, policy, now)) return void 0;
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;
62862
62954
  const window = axis === "session" ? quota.session : quota.weekly;
62863
62955
  const remaining = remainingPercent(window);
62864
62956
  if (remaining === void 0) return void 0;
62865
62957
  const resetsAt = Number(window?.resetsAt);
62866
- if (!Number.isFinite(resetsAt) || resetsAt <= 0) return { remainingPercent: remaining, risk: 0 };
62958
+ if (!Number.isFinite(resetsAt) || resetsAt <= 0) return { remainingPercent: remaining, risk: 0, confidence };
62867
62959
  const ageMs2 = quotaSnapshotAgeMs(facts, quota, now);
62868
- if (!Number.isFinite(ageMs2)) return { remainingPercent: remaining, risk: 0 };
62960
+ if (!Number.isFinite(ageMs2)) return { remainingPercent: remaining, risk: 0, confidence };
62869
62961
  const reporterNowMs = Number(quota.updatedAt) + ageMs2;
62870
62962
  const windowMinutes3 = Number(window?.windowMinutes);
62871
62963
  const fallbackMinutes = axis === "session" ? DEFAULT_SESSION_WINDOW_MINUTES : DEFAULT_WEEKLY_WINDOW_MINUTES;
62872
62964
  const windowMs = (Number.isFinite(windowMinutes3) && windowMinutes3 > 0 ? windowMinutes3 : fallbackMinutes) * 60 * 1e3;
62873
62965
  const elapsedFraction = Math.min(1, Math.max(0, 1 - (resetsAt - reporterNowMs) / windowMs));
62874
- 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;
62875
62970
  }
62876
62971
  function rankProvidersByQuotaGate(node, orderedProviderTypes, policy, now = Date.now(), context) {
62877
62972
  const clear = [];
@@ -62896,14 +62991,19 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
62896
62991
  const sa = sessionByProvider.get(a);
62897
62992
  const sb = sessionByProvider.get(b);
62898
62993
  if (sa !== void 0 && sb !== void 0) {
62899
- if (sb.risk !== sa.risk) return sb.risk - sa.risk;
62994
+ const ra2 = rankedRisk(sa);
62995
+ const rb2 = rankedRisk(sb);
62996
+ if (rb2 !== ra2) return rb2 - ra2;
62900
62997
  if (sb.remainingPercent !== sa.remainingPercent) {
62901
62998
  return sb.remainingPercent - sa.remainingPercent;
62902
62999
  }
62903
63000
  } else if (sa !== void 0) return -1;
62904
63001
  else if (sb !== void 0) return 1;
62905
63002
  }
62906
- if (wb.risk !== wa.risk) return wb.risk - wa.risk;
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;
62907
63007
  return wb.remainingPercent - wa.remainingPercent;
62908
63008
  });
62909
63009
  return { clear, gated };
@@ -62934,10 +63034,21 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
62934
63034
  const w = expiryRiskForRanking(node, providerType, "weekly", policy, now, context);
62935
63035
  return {
62936
63036
  providerType,
62937
- ...w ? { remainingPercent: w.remainingPercent, risk: w.risk } : {}
63037
+ ...w ? {
63038
+ remainingPercent: w.remainingPercent,
63039
+ risk: w.risk,
63040
+ ...w.confidence !== CONFIDENCE_CURRENT ? { confidence: w.confidence, rankedRisk: rankedRisk(w) } : {}
63041
+ } : {}
62938
63042
  };
62939
63043
  });
62940
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
+ }
62941
63052
  function recordLastQuotaRanking(nodeId, record2) {
62942
63053
  if (!nodeId) return;
62943
63054
  lastQuotaRankingByNode.set(nodeId, record2);
@@ -62977,6 +63088,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
62977
63088
  var absentFailOpenLoggedAt;
62978
63089
  var DEFAULT_WEEKLY_WINDOW_MINUTES;
62979
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;
62980
63096
  var lastQuotaRankingByNode;
62981
63097
  var init_mesh_quota_routing = __esm2({
62982
63098
  "src/mesh/mesh-quota-routing.ts"() {
@@ -62993,6 +63109,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
62993
63109
  absentFailOpenLoggedAt = /* @__PURE__ */ new Map();
62994
63110
  DEFAULT_WEEKLY_WINDOW_MINUTES = 7 * 24 * 60;
62995
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;
62996
63117
  lastQuotaRankingByNode = /* @__PURE__ */ new Map();
62997
63118
  }
62998
63119
  });
@@ -67006,6 +67127,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
67006
67127
  const winnerRisk = riskByProvider.get(winner.providerType)?.risk;
67007
67128
  return {
67008
67129
  riskSnapshot,
67130
+ ...losers.length ? { allLosers: losers } : {},
67009
67131
  ...riskSnapshot.length ? { quotaRiskSnapshot: riskSnapshot.slice(0, ROUTING_ARRAY_MAX) } : {},
67010
67132
  ...riskSnapshot.length > ROUTING_ARRAY_MAX ? { quotaRisksOmitted: riskSnapshot.length - ROUTING_ARRAY_MAX } : {},
67011
67133
  ...losers.length ? { intraNodeLosers: losers.slice(0, INTRA_NODE_LOSERS_MAX) } : {},
@@ -67024,6 +67146,23 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
67024
67146
  }
67025
67147
  };
67026
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
+ }
67027
67166
  function serializedBytes(value) {
67028
67167
  return Buffer.byteLength(JSON.stringify(value), "utf8");
67029
67168
  }
@@ -67069,8 +67208,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
67069
67208
  const winningSlot = args.resolved.slot;
67070
67209
  const executedSlot = args.executedSlot ?? winningSlot;
67071
67210
  const winningProvider = args.resolved.providerType;
67211
+ const executedProvider = executedSlot.provider;
67072
67212
  const sameDeclaredProvider = winningSlot.provider === executedSlot.provider;
67073
- const executedProvider = sameDeclaredProvider ? winningProvider : executedSlot.provider;
67074
67213
  const winningModel = winningSlot.model?.trim() || void 0;
67075
67214
  const executedModel = executedSlot.model?.trim() || void 0;
67076
67215
  const demoted = !sameDeclaredProvider || winningModel !== executedModel;
@@ -68238,7 +68377,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
68238
68377
  }
68239
68378
  const ranked = rankProvidersByQuotaGate(node, candidates.map((c) => c.providerType), quotaRouting, Date.now(), quotaFactsContext);
68240
68379
  const winner = ranked.clear.length ? candidates.find((candidate) => candidate.providerType === ranked.clear[0]) ?? candidates[0] : void 0;
68241
- const { riskSnapshot, ...routingDiagnostics } = buildProviderSelectionDiagnostics({
68380
+ const { riskSnapshot, allLosers, ...routingDiagnostics } = buildProviderSelectionDiagnostics({
68242
68381
  node,
68243
68382
  nodeId,
68244
68383
  meshId,
@@ -68253,13 +68392,15 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
68253
68392
  ranked,
68254
68393
  winner
68255
68394
  });
68395
+ const rationale = selectionRationaleFrom(routingDiagnostics.selectionTrajectory, allLosers);
68256
68396
  if (!ranked.clear.length) {
68257
68397
  const detail = ranked.gated.map((g) => `${g.providerType}: ${g.block.reason}`).join("; ");
68258
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`);
68259
68399
  recordLastQuotaRanking(nodeId, {
68260
68400
  decidedAt: Date.now(),
68261
68401
  clear: riskSnapshot,
68262
- 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 } : {}
68263
68404
  });
68264
68405
  return { reason: `${ALL_PROVIDERS_QUOTA_GATED_SKIP_REASON}: ${detail}` };
68265
68406
  }
@@ -68269,7 +68410,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
68269
68410
  decidedAt: Date.now(),
68270
68411
  winner: selectedWinner.providerType,
68271
68412
  clear: riskSnapshot,
68272
- 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 } : {}
68273
68416
  });
68274
68417
  return {
68275
68418
  providerType: selectedWinner.providerType,
@@ -68518,26 +68661,30 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
68518
68661
  const effectiveThinkingLevel = resolveLaunchAxis(task.thinkingLevel, task.thinkingLevelSource, resolved.thinkingLevel, slotCoversDifficulty);
68519
68662
  const slotDecision = decideSlotForModel({
68520
68663
  requestedModel,
68664
+ providerType: resolved.providerType,
68521
68665
  slots: resolveNodeCapabilitySlots(node, meshId).map((slot) => ({
68522
68666
  slot,
68523
68667
  available: slotHasCapacity(meshId, nodeId, node, slot, mesh?.nodes, isReadonly)
68524
68668
  }))
68525
68669
  });
68526
68670
  if (slotDecision.outcome === "wait") {
68527
- 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`);
68528
68672
  markSkip(nodeId, slotDecision.reason, { providerType: resolved.providerType });
68529
68673
  continue;
68530
68674
  }
68531
68675
  if (slotDecision.outcome === "notify") {
68532
- 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`);
68533
68677
  markSkip(nodeId, slotDecision.reason, { providerType: resolved.providerType });
68534
68678
  continue;
68535
68679
  }
68536
- const rawEffectiveModel = slotDecision.model;
68537
- const winningModel = resolved.slot?.model?.trim() || void 0;
68538
- const finalizedModel = slotDecision.slot.model?.trim() || void 0;
68539
- const slotWasDemoted = resolved.slot?.provider !== slotDecision.slot.provider || winningModel !== finalizedModel;
68540
- const demotionReason = slotWasDemoted ? slotHasCapacity(meshId, nodeId, node, resolved.slot, mesh?.nodes, isReadonly) ? "slot_reselected_during_launch" : "winning_slot_capacity_exhausted" : void 0;
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;
68541
68688
  const effectiveModel = isModelCompatibleWithProvider(rawEffectiveModel, resolved.providerType) ? rawEffectiveModel : void 0;
68542
68689
  if (rawEffectiveModel && effectiveModel === void 0) {
68543
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`);
@@ -132782,15 +132929,20 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
132782
132929
  init_dist();
132783
132930
  var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
132784
132931
  var CLAUDE_WRAP_NOT_REPLACE_LINE = "Install wraps (not replaces) your statusline, so nothing is lost.";
132785
- function formatWindow(label, window, isLastGood = false) {
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) {
132786
132938
  if (!window) {
132787
132939
  return ` ${label.padEnd(8)} ${import_chalk2.default.gray("not reported")}`;
132788
132940
  }
132789
132941
  const percent = `${window.usedPercent.toFixed(1)}%`;
132790
132942
  const bar = renderBar(window.usedPercent);
132791
132943
  const reset = window.resetsAt === null ? "" : import_chalk2.default.gray(` resets ${formatRelative(window.resetsAt)}`);
132792
- const stale = isLastGood ? import_chalk2.default.gray(" (refreshing)") : "";
132793
- return ` ${label.padEnd(8)} ${bar} ${percent.padStart(6)} used${reset}${stale}`;
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}`;
132794
132946
  }
132795
132947
  function renderBar(usedPercent) {
132796
132948
  const width = 20;
@@ -132829,9 +132981,9 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
132829
132981
  const account = formatQuotaAccount(quota);
132830
132982
  console.log(account ? `${import_chalk2.default.bold(name)} ${import_chalk2.default.gray(account)}` : import_chalk2.default.bold(name));
132831
132983
  if (quota.status === "ok" || quota.session || quota.weekly) {
132832
- const isLastGood = quota.metadata?.lastGoodWindows === true;
132833
- console.log(formatWindow("5 hour", quota.session, isLastGood));
132834
- console.log(formatWindow("7 day", quota.weekly, isLastGood));
132984
+ const cue = windowCue(quota);
132985
+ console.log(formatWindow("5 hour", quota.session, cue));
132986
+ console.log(formatWindow("7 day", quota.weekly, cue));
132835
132987
  }
132836
132988
  if (quota.error) {
132837
132989
  const tone = quota.status === "unavailable" ? import_chalk2.default.gray : import_chalk2.default.yellow;