claude-use 12.0.1 → 12.1.0
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/cli.cjs +384 -128
- package/dist/index.cjs +407 -168
- package/dist/index.mjs +396 -158
- package/dist/types/index.d.ts +1055 -1003
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5245,6 +5245,23 @@ function identityIdResolver(identitiesDir, fs17) {
|
|
|
5245
5245
|
return identityIdIn(records, name);
|
|
5246
5246
|
};
|
|
5247
5247
|
}
|
|
5248
|
+
function identityReader(identitiesDir, fs17) {
|
|
5249
|
+
const read = /* @__PURE__ */ new Map();
|
|
5250
|
+
const readOnce = (file) => {
|
|
5251
|
+
if (!read.has(file)) {
|
|
5252
|
+
read.set(file, fs17.readConfigFile(file));
|
|
5253
|
+
}
|
|
5254
|
+
return read.get(file);
|
|
5255
|
+
};
|
|
5256
|
+
const idOf = identityIdResolver(identitiesDir, { readdir: fs17.readdir, readConfigFile: readOnce });
|
|
5257
|
+
return {
|
|
5258
|
+
idOf,
|
|
5259
|
+
load: (name) => {
|
|
5260
|
+
const id = idOf(name);
|
|
5261
|
+
return id === void 0 ? void 0 : loadConfigFile(path15.join(identitiesDir, id, IDENTITY_FILE), IdentitySchema, readOnce)?.config;
|
|
5262
|
+
}
|
|
5263
|
+
};
|
|
5264
|
+
}
|
|
5248
5265
|
function loadIdentity(identitiesDir, name, fs17) {
|
|
5249
5266
|
if (!isFileName(name)) {
|
|
5250
5267
|
throw new UnsafeNameError(name, "identity", FILE_NAME_RULE);
|
|
@@ -9216,7 +9233,8 @@ var init_identityAccounts = __esm({
|
|
|
9216
9233
|
function candidateHeading(candidate) {
|
|
9217
9234
|
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
9218
9235
|
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
9219
|
-
|
|
9236
|
+
const onProvider = candidate.provider === void 0 ? "" : ` on provider ${candidate.provider}`;
|
|
9237
|
+
return `[${candidate.class}${score}]${dry}${onProvider}`;
|
|
9220
9238
|
}
|
|
9221
9239
|
function percent(fraction) {
|
|
9222
9240
|
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
@@ -9259,6 +9277,9 @@ function planOf(account) {
|
|
|
9259
9277
|
}
|
|
9260
9278
|
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
9261
9279
|
}
|
|
9280
|
+
function planOfProviderQuota(quota) {
|
|
9281
|
+
return planOf(quota?.level === void 0 ? void 0 : { organizationRateLimitTier: quota.level });
|
|
9282
|
+
}
|
|
9262
9283
|
var PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
9263
9284
|
var init_plan2 = __esm({
|
|
9264
9285
|
"src/usage/plan.ts"() {
|
|
@@ -9317,12 +9338,58 @@ var init_middleware = __esm({
|
|
|
9317
9338
|
}
|
|
9318
9339
|
});
|
|
9319
9340
|
|
|
9341
|
+
// src/usage/windowLengths.ts
|
|
9342
|
+
var MS_PER_HOUR2, HOURS_PER_DAY3, FIVE_HOURS, SEVEN_DAYS, FIVE_HOUR_WINDOW_MS, SEVEN_DAY_WINDOW_MS;
|
|
9343
|
+
var init_windowLengths = __esm({
|
|
9344
|
+
"src/usage/windowLengths.ts"() {
|
|
9345
|
+
"use strict";
|
|
9346
|
+
MS_PER_HOUR2 = 36e5;
|
|
9347
|
+
HOURS_PER_DAY3 = 24;
|
|
9348
|
+
FIVE_HOURS = 5;
|
|
9349
|
+
SEVEN_DAYS = 7;
|
|
9350
|
+
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR2;
|
|
9351
|
+
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY3 * MS_PER_HOUR2;
|
|
9352
|
+
}
|
|
9353
|
+
});
|
|
9354
|
+
|
|
9355
|
+
// src/usage/providerWindows.ts
|
|
9356
|
+
function bindingWindow(quota, periodMs) {
|
|
9357
|
+
const same = quota.windows.filter((window) => window.periodMs === periodMs);
|
|
9358
|
+
const tightest = same.reduce((binding, window) => binding === void 0 || window.utilization > binding.utilization ? window : binding, void 0);
|
|
9359
|
+
if (tightest === void 0) {
|
|
9360
|
+
return void 0;
|
|
9361
|
+
}
|
|
9362
|
+
return { utilization: tightest.utilization, ...tightest.resetsAt === void 0 ? {} : { resetsAt: tightest.resetsAt }, status: tightest.utilization >= 1 ? "rejected" : "allowed" };
|
|
9363
|
+
}
|
|
9364
|
+
function unifiedFromQuota(quota) {
|
|
9365
|
+
const fiveHour = bindingWindow(quota, FIVE_HOUR_WINDOW_MS);
|
|
9366
|
+
const sevenDay = bindingWindow(quota, SEVEN_DAY_WINDOW_MS);
|
|
9367
|
+
return fiveHour === void 0 && sevenDay === void 0 ? void 0 : { ...fiveHour === void 0 ? {} : { fiveHour }, ...sevenDay === void 0 ? {} : { sevenDay } };
|
|
9368
|
+
}
|
|
9369
|
+
function rankingWindowsOf(provider, state) {
|
|
9370
|
+
const recorded = state?.rateLimit;
|
|
9371
|
+
if (provider === void 0) {
|
|
9372
|
+
return recorded?.unified === void 0 ? void 0 : { unified: recorded.unified, observedAt: recorded.observedAt };
|
|
9373
|
+
}
|
|
9374
|
+
if (recorded?.unified !== void 0 && (recorded.unified.fiveHour !== void 0 || recorded.unified.sevenDay !== void 0)) {
|
|
9375
|
+
return { unified: recorded.unified, observedAt: recorded.observedAt };
|
|
9376
|
+
}
|
|
9377
|
+
const pulled = state?.quota === void 0 ? void 0 : unifiedFromQuota(state.quota);
|
|
9378
|
+
return state?.quota === void 0 || pulled === void 0 ? void 0 : { unified: pulled, observedAt: state.quota.observedAt };
|
|
9379
|
+
}
|
|
9380
|
+
var init_providerWindows = __esm({
|
|
9381
|
+
"src/usage/providerWindows.ts"() {
|
|
9382
|
+
"use strict";
|
|
9383
|
+
init_windowLengths();
|
|
9384
|
+
}
|
|
9385
|
+
});
|
|
9386
|
+
|
|
9320
9387
|
// src/usage/quotaFacts.ts
|
|
9321
9388
|
function windowFacts(window, nowMs) {
|
|
9322
9389
|
if (window?.utilization === void 0 || window.resetsAt === void 0) {
|
|
9323
9390
|
return void 0;
|
|
9324
9391
|
}
|
|
9325
|
-
return { remaining: Math.max(0, 1 - window.utilization), utilization: window.utilization, hoursUntilReset: Math.max(0, (Date.parse(window.resetsAt) - nowMs) /
|
|
9392
|
+
return { remaining: Math.max(0, 1 - window.utilization), utilization: window.utilization, hoursUntilReset: Math.max(0, (Date.parse(window.resetsAt) - nowMs) / MS_PER_HOUR3) };
|
|
9326
9393
|
}
|
|
9327
9394
|
function quotaFactsOf(unified, nowMs) {
|
|
9328
9395
|
const fiveHour = windowFacts(unified?.fiveHour, nowMs);
|
|
@@ -9330,19 +9397,16 @@ function quotaFactsOf(unified, nowMs) {
|
|
|
9330
9397
|
const extraUsage = windowFacts(unified === void 0 ? void 0 : soleOverageWindow(unified), nowMs);
|
|
9331
9398
|
return { ...fiveHour === void 0 ? {} : { fiveHour }, ...sevenDay === void 0 ? {} : { sevenDay }, ...extraUsage === void 0 ? {} : { extraUsage } };
|
|
9332
9399
|
}
|
|
9333
|
-
var
|
|
9400
|
+
var MS_PER_HOUR3;
|
|
9334
9401
|
var init_quotaFacts = __esm({
|
|
9335
9402
|
"src/usage/quotaFacts.ts"() {
|
|
9336
9403
|
"use strict";
|
|
9337
9404
|
init_rateLimit();
|
|
9338
|
-
|
|
9405
|
+
MS_PER_HOUR3 = 36e5;
|
|
9339
9406
|
}
|
|
9340
9407
|
});
|
|
9341
9408
|
|
|
9342
9409
|
// src/usage/pick.ts
|
|
9343
|
-
function unifiedOf(state) {
|
|
9344
|
-
return state?.rateLimit?.unified;
|
|
9345
|
-
}
|
|
9346
9410
|
function limitBlockedUntil(state, nowMs) {
|
|
9347
9411
|
const limit = state?.lastLimit;
|
|
9348
9412
|
if (state === void 0 || limit === void 0) {
|
|
@@ -9432,6 +9496,10 @@ function assessRefusedNested(member, nested, nowMs) {
|
|
|
9432
9496
|
};
|
|
9433
9497
|
}
|
|
9434
9498
|
function assess(member, nowMs) {
|
|
9499
|
+
const assessment = assessMember(member, nowMs);
|
|
9500
|
+
return member.provider === void 0 ? assessment : { ...assessment, candidate: { ...assessment.candidate, provider: member.provider } };
|
|
9501
|
+
}
|
|
9502
|
+
function assessMember(member, nowMs) {
|
|
9435
9503
|
if (member.sameLoginAs !== void 0) {
|
|
9436
9504
|
return { candidate: { identity: member.identity, class: "ineligible", plan: planOf(member.account), reasons: [`same login as ${member.sameLoginAs}`] } };
|
|
9437
9505
|
}
|
|
@@ -9445,22 +9513,43 @@ function assess(member, nowMs) {
|
|
|
9445
9513
|
const assessment = assessIdentity(member, nowMs);
|
|
9446
9514
|
return { ...assessment, candidate: { ...assessment.candidate, reasons: [`picked by pool "${nested.pool}"`, ...nested.reasons] } };
|
|
9447
9515
|
}
|
|
9516
|
+
function sliceOf(member) {
|
|
9517
|
+
return member.snapshot?.providers[member.provider ?? ANTHROPIC_PROVIDER];
|
|
9518
|
+
}
|
|
9519
|
+
function assessProviderWithoutWindows(member, provider, state, base, planReasons, nowMs) {
|
|
9520
|
+
const blockedUntil = limitBlockedUntil(state, nowMs);
|
|
9521
|
+
if (blockedUntil !== void 0) {
|
|
9522
|
+
return { candidate: { ...base, class: "ineligible", blockedUntilMs: blockedUntil, reasons: [`refused until ${new Date(blockedUntil).toISOString()} (in ${formatAge(blockedUntil - nowMs)})`, ...planReasons] } };
|
|
9523
|
+
}
|
|
9524
|
+
if (base.plan.kind === "pay-per-use") {
|
|
9525
|
+
return { candidate: { ...base, class: "pay-per-use", usageUnrecorded: true, reasons: [...planReasons, `provider ${provider} reports no plan windows, so its spend is not tracked`] } };
|
|
9526
|
+
}
|
|
9527
|
+
const why = state === void 0 ? `no usage recorded for provider ${provider} yet, so its quota is unknown` : `provider ${provider} reports no plan windows, so its quota is unknown`;
|
|
9528
|
+
return { candidate: { ...base, class: "unknown", reasons: [why, ...planReasons] } };
|
|
9529
|
+
}
|
|
9448
9530
|
function assessIdentity(member, nowMs) {
|
|
9449
|
-
const
|
|
9531
|
+
const state = sliceOf(member);
|
|
9532
|
+
const plan = member.provider === void 0 ? planOf(member.account) : planOfProviderQuota(state?.quota);
|
|
9450
9533
|
const planReasons = plan.kind === "pay-per-use" ? ["billed by use (no plan allowance)"] : plan.recognised ? [`${String(plan.capacity)}x plan`] : [`plan tier ${plan.tier === void 0 ? "not known" : `"${plan.tier}" not recognised`}, counted as 1x`];
|
|
9451
9534
|
const base = { identity: member.identity, plan };
|
|
9452
9535
|
if (member.readError !== void 0) {
|
|
9453
9536
|
return { candidate: { ...base, class: "unknown", reasons: [`usage state unreadable: ${member.readError}`, ...planReasons] } };
|
|
9454
9537
|
}
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9538
|
+
if (member.providerError !== void 0) {
|
|
9539
|
+
return { candidate: { ...base, class: "unknown", reasons: [`provider configuration unreadable: ${member.providerError}`, ...planReasons] } };
|
|
9540
|
+
}
|
|
9541
|
+
const windows = rankingWindowsOf(member.provider, state);
|
|
9542
|
+
if (member.snapshot === void 0 || state === void 0 || windows === void 0) {
|
|
9543
|
+
if (member.provider !== void 0) {
|
|
9544
|
+
return assessProviderWithoutWindows(member, member.provider, state, base, planReasons, nowMs);
|
|
9545
|
+
}
|
|
9458
9546
|
if (plan.kind === "pay-per-use") {
|
|
9459
9547
|
return { candidate: { ...base, class: "pay-per-use", usageUnrecorded: true, reasons: [...planReasons, "no usage recorded yet, so its spend is not tracked (turn on trackUsage for it)"] } };
|
|
9460
9548
|
}
|
|
9461
9549
|
return { candidate: { ...base, class: "unknown", reasons: ["no usage recorded yet, so its quota is unknown (turn on trackUsage for it)", ...planReasons] } };
|
|
9462
9550
|
}
|
|
9463
|
-
const
|
|
9551
|
+
const { unified } = windows;
|
|
9552
|
+
const observedAgo = ` (last seen ${formatAge(nowMs - Date.parse(windows.observedAt))} ago)`;
|
|
9464
9553
|
const fiveHourWindow = unified.fiveHour;
|
|
9465
9554
|
const sevenDayWindow = unified.sevenDay;
|
|
9466
9555
|
const five = fiveHourWindow === void 0 ? void 0 : effectiveWindow(fiveHourWindow, nowMs);
|
|
@@ -9472,6 +9561,15 @@ function assessIdentity(member, nowMs) {
|
|
|
9472
9561
|
const overageWindow = soleOverageWindow(unified);
|
|
9473
9562
|
const overage = overageWindow === void 0 ? void 0 : effectiveWindow(overageWindow, nowMs);
|
|
9474
9563
|
const overageReasons = overageWindow === void 0 || overage === void 0 ? [] : [describeWindow("extra usage", overageWindow, overage, nowMs)];
|
|
9564
|
+
if (member.provider !== void 0) {
|
|
9565
|
+
const spent = [
|
|
9566
|
+
{ name: "5h", window: five },
|
|
9567
|
+
{ name: "7d", window: seven }
|
|
9568
|
+
].filter(({ window }) => window?.status === "rejected" && window.resetsAtMs === void 0).map(({ name }) => name);
|
|
9569
|
+
if (spent.length > 0) {
|
|
9570
|
+
return { candidate: { ...base, class: "ineligible", reasons: [`provider ${member.provider} ${spent.join(" and ")} window used in full with no reset time reported, so it is refused until it reports one`, ...windowReasons, ...planReasons] } };
|
|
9571
|
+
}
|
|
9572
|
+
}
|
|
9475
9573
|
const blockedUntil = Math.max(
|
|
9476
9574
|
windowBlockedUntil([five, seven, overage].flatMap((window) => window === void 0 ? [] : [window])) ?? 0,
|
|
9477
9575
|
limitBlockedUntil(state, nowMs) ?? 0
|
|
@@ -9492,11 +9590,11 @@ function assessIdentity(member, nowMs) {
|
|
|
9492
9590
|
}
|
|
9493
9591
|
const remaining = Math.max(0, 1 - basis.window.utilization);
|
|
9494
9592
|
const untilResetMs = basis.window.resetsAtMs === void 0 ? basis.windowMs : Math.max(basis.window.resetsAtMs - nowMs, MS_PER_SECOND5);
|
|
9495
|
-
const weeklyScore = remaining * plan.capacity / (untilResetMs /
|
|
9593
|
+
const weeklyScore = remaining * plan.capacity / (untilResetMs / MS_PER_HOUR4);
|
|
9496
9594
|
const fiveRemaining = five?.utilization === void 0 ? void 0 : Math.max(0, 1 - five.utilization);
|
|
9497
9595
|
const fiveUntil = five?.resetsAtMs === void 0 ? FIVE_HOUR_WINDOW_MS : Math.max(five.resetsAtMs - nowMs, MS_PER_SECOND5);
|
|
9498
9596
|
const ratio = windowRatio(member.records);
|
|
9499
|
-
const fiveHourScore = basis.name === "sevenDay" && fiveRemaining !== void 0 && ratio !== void 0 ? Math.min(fiveRemaining * ratio, remaining) * plan.capacity / (fiveUntil /
|
|
9597
|
+
const fiveHourScore = basis.name === "sevenDay" && fiveRemaining !== void 0 && ratio !== void 0 ? Math.min(fiveRemaining * ratio, remaining) * plan.capacity / (fiveUntil / MS_PER_HOUR4) : void 0;
|
|
9500
9598
|
const fiveHourLeads = fiveHourScore !== void 0 && fiveHourScore > weeklyScore;
|
|
9501
9599
|
const score = fiveHourLeads ? fiveHourScore : weeklyScore;
|
|
9502
9600
|
const scoreWindow = fiveHourLeads ? "fiveHour" : basis.name;
|
|
@@ -9514,15 +9612,15 @@ function assessIdentity(member, nowMs) {
|
|
|
9514
9612
|
};
|
|
9515
9613
|
}
|
|
9516
9614
|
function poolFactsOf(member, nowMs, resuming, sticky) {
|
|
9517
|
-
const { fiveHour, sevenDay, extraUsage } = quotaFactsOf(member.
|
|
9615
|
+
const { fiveHour, sevenDay, extraUsage } = quotaFactsOf(rankingWindowsOf(member.provider, sliceOf(member))?.unified, nowMs);
|
|
9518
9616
|
const burn = windowBurn(member.records, "fiveHour");
|
|
9519
9617
|
return {
|
|
9520
9618
|
...fiveHour === void 0 ? {} : { fiveHour },
|
|
9521
9619
|
...sevenDay === void 0 ? {} : { sevenDay },
|
|
9522
9620
|
...extraUsage === void 0 ? {} : { extraUsage },
|
|
9523
|
-
...burn === void 0 ? {} : { burnPerHour: burn *
|
|
9621
|
+
...burn === void 0 ? {} : { burnPerHour: burn * MS_PER_HOUR4 },
|
|
9524
9622
|
resuming,
|
|
9525
|
-
...sticky?.identity === member.identity ? { lastPickHoursAgo: Math.max(0, (nowMs - Date.parse(sticky.at)) /
|
|
9623
|
+
...sticky?.identity === member.identity ? { lastPickHoursAgo: Math.max(0, (nowMs - Date.parse(sticky.at)) / MS_PER_HOUR4) } : {}
|
|
9526
9624
|
};
|
|
9527
9625
|
}
|
|
9528
9626
|
function rankPool(input) {
|
|
@@ -9617,7 +9715,7 @@ function rankPool(input) {
|
|
|
9617
9715
|
...holdForReturn === void 0 ? {} : { holdForReturn }
|
|
9618
9716
|
};
|
|
9619
9717
|
}
|
|
9620
|
-
var MS_PER_SECOND5,
|
|
9718
|
+
var MS_PER_SECOND5, MS_PER_HOUR4, PROMPT_CACHE_TTL_HOURS, PROMPT_CACHE_TTL_MS, CLASS_ORDER;
|
|
9621
9719
|
var init_pick = __esm({
|
|
9622
9720
|
"src/usage/pick.ts"() {
|
|
9623
9721
|
"use strict";
|
|
@@ -9626,17 +9724,14 @@ var init_pick = __esm({
|
|
|
9626
9724
|
init_plan2();
|
|
9627
9725
|
init_middleware();
|
|
9628
9726
|
init_preflight();
|
|
9727
|
+
init_providerWindows();
|
|
9629
9728
|
init_quotaFacts();
|
|
9729
|
+
init_windowLengths();
|
|
9630
9730
|
init_rateLimit();
|
|
9631
9731
|
MS_PER_SECOND5 = 1e3;
|
|
9632
|
-
|
|
9633
|
-
HOURS_PER_DAY3 = 24;
|
|
9634
|
-
FIVE_HOURS = 5;
|
|
9732
|
+
MS_PER_HOUR4 = 36e5;
|
|
9635
9733
|
PROMPT_CACHE_TTL_HOURS = 1;
|
|
9636
|
-
|
|
9637
|
-
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR3;
|
|
9638
|
-
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY3 * MS_PER_HOUR3;
|
|
9639
|
-
PROMPT_CACHE_TTL_MS = PROMPT_CACHE_TTL_HOURS * MS_PER_HOUR3;
|
|
9734
|
+
PROMPT_CACHE_TTL_MS = PROMPT_CACHE_TTL_HOURS * MS_PER_HOUR4;
|
|
9640
9735
|
CLASS_ORDER = { scored: 0, unknown: 1, "pay-per-use": 2, ineligible: 3 };
|
|
9641
9736
|
}
|
|
9642
9737
|
});
|
|
@@ -9773,7 +9868,7 @@ import { z as z19 } from "zod";
|
|
|
9773
9868
|
function errorMessage(error) {
|
|
9774
9869
|
return error instanceof Error ? error.message : String(error);
|
|
9775
9870
|
}
|
|
9776
|
-
function loadPoolMembers(fs17, paths, identities, nowMs, idOf) {
|
|
9871
|
+
function loadPoolMembers(fs17, paths, identities, nowMs, idOf, providerOf) {
|
|
9777
9872
|
const windowStartMs = nowMs - FIVE_HOUR_WINDOW_MS;
|
|
9778
9873
|
const log = readUsageLog(fs17, paths.usageLogDir, { sinceMs: windowStartMs });
|
|
9779
9874
|
return identities.map((identity) => {
|
|
@@ -9781,14 +9876,20 @@ function loadPoolMembers(fs17, paths, identities, nowMs, idOf) {
|
|
|
9781
9876
|
if (id === void 0) {
|
|
9782
9877
|
return { identity, records: [] };
|
|
9783
9878
|
}
|
|
9784
|
-
const
|
|
9879
|
+
const resolved = providerOf?.(identity);
|
|
9880
|
+
const provider = typeof resolved === "object" ? resolved.named : resolved;
|
|
9881
|
+
const providerField = {
|
|
9882
|
+
...provider === void 0 ? {} : { provider },
|
|
9883
|
+
...typeof resolved === "object" ? { providerError: resolved.reason } : {}
|
|
9884
|
+
};
|
|
9885
|
+
const records = log.records.filter((record) => record.identity === id && record.provider === (provider ?? ANTHROPIC_PROVIDER) && Date.parse(record.at) >= windowStartMs);
|
|
9785
9886
|
try {
|
|
9786
9887
|
const snapshot = readUsageSnapshot(fs17, paths.usageSnapshotsDir, id);
|
|
9787
9888
|
const account = readAccountMetadata(fs17, paths.identitiesDir, id) ?? snapshot?.account;
|
|
9788
|
-
return { identity, records, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
|
|
9889
|
+
return { identity, records, ...providerField, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
|
|
9789
9890
|
} catch (error) {
|
|
9790
9891
|
if (error instanceof UsageSnapshotError || error instanceof AccountMetadataError) {
|
|
9791
|
-
return { identity, records, readError: errorMessage(error) };
|
|
9892
|
+
return { identity, records, ...providerField, readError: errorMessage(error) };
|
|
9792
9893
|
}
|
|
9793
9894
|
throw error;
|
|
9794
9895
|
}
|
|
@@ -9798,7 +9899,7 @@ function snapshotAgeKey(member) {
|
|
|
9798
9899
|
return member.snapshot === void 0 ? Number.NEGATIVE_INFINITY : Date.parse(member.snapshot.updatedAt);
|
|
9799
9900
|
}
|
|
9800
9901
|
function collapseSharedLogins(members) {
|
|
9801
|
-
const groups = groupSharedLogins(members, (member) => member.nested === void 0 && member.account !== void 0 ? loginKeyOf(member.account) : void 0);
|
|
9902
|
+
const groups = groupSharedLogins(members, (member) => member.nested === void 0 && member.provider === void 0 && member.account !== void 0 ? loginKeyOf(member.account) : void 0);
|
|
9802
9903
|
const representativeOf = /* @__PURE__ */ new Map();
|
|
9803
9904
|
for (const group of groups) {
|
|
9804
9905
|
const representative = group.reduce((freshest, member) => snapshotAgeKey(member) > snapshotAgeKey(freshest) ? member : freshest);
|
|
@@ -9828,7 +9929,7 @@ function rankNamedPool(input, poolName, stack, sticky) {
|
|
|
9828
9929
|
const childStack = [...stack, poolName];
|
|
9829
9930
|
const direct = pool.identities.filter((entry) => poolNameOf(poolMemberIdentity(entry)) === void 0);
|
|
9830
9931
|
const missing = direct.filter((entry) => input.identityIdOf(poolMemberIdentity(entry)) === void 0).map((entry) => ({ pool: poolName, identity: poolMemberIdentity(entry) }));
|
|
9831
|
-
const loaded = new Map(loadPoolMembers(input.fs, input.paths, direct.filter((entry) => input.identityIdOf(poolMemberIdentity(entry)) !== void 0).map(poolMemberIdentity), input.nowMs, input.identityIdOf).map((member) => [member.identity, member]));
|
|
9932
|
+
const loaded = new Map(loadPoolMembers(input.fs, input.paths, direct.filter((entry) => input.identityIdOf(poolMemberIdentity(entry)) !== void 0).map(poolMemberIdentity), input.nowMs, input.identityIdOf, input.providerOf).map((member) => [member.identity, member]));
|
|
9832
9933
|
const members = [];
|
|
9833
9934
|
for (const entry of pool.identities) {
|
|
9834
9935
|
const nestedName = poolNameOf(poolMemberIdentity(entry));
|
|
@@ -9869,7 +9970,7 @@ function nestedMember(input, nestedName, childStack, sticky) {
|
|
|
9869
9970
|
const nested = rankNamedPool(input, nestedName, childStack, sticky);
|
|
9870
9971
|
const pick = nested.ranking.pick;
|
|
9871
9972
|
if (pick !== void 0) {
|
|
9872
|
-
const [member] = loadPoolMembers(input.fs, input.paths, [pick.identity], input.nowMs, input.identityIdOf);
|
|
9973
|
+
const [member] = loadPoolMembers(input.fs, input.paths, [pick.identity], input.nowMs, input.identityIdOf, input.providerOf);
|
|
9873
9974
|
return { member: { ...member ?? { identity: pick.identity, records: [] }, nested: { kind: "pick", pool: nestedName, reasons: pick.reasons } }, missing: nested.missing };
|
|
9874
9975
|
}
|
|
9875
9976
|
const earliestReturn = nested.ranking.earliestReturn;
|
|
@@ -9964,6 +10065,7 @@ var init_poolPick = __esm({
|
|
|
9964
10065
|
init_read();
|
|
9965
10066
|
init_middleware();
|
|
9966
10067
|
init_store2();
|
|
10068
|
+
init_windowLengths();
|
|
9967
10069
|
PoolGraphError = class extends CliError {
|
|
9968
10070
|
constructor(message) {
|
|
9969
10071
|
super(message);
|
|
@@ -10736,7 +10838,7 @@ var init_package = __esm({
|
|
|
10736
10838
|
"package.json"() {
|
|
10737
10839
|
package_default = {
|
|
10738
10840
|
name: "claude-use",
|
|
10739
|
-
version: "12.0
|
|
10841
|
+
version: "12.1.0",
|
|
10740
10842
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
10741
10843
|
license: "MIT",
|
|
10742
10844
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -10995,92 +11097,6 @@ var init_cascade = __esm({
|
|
|
10995
11097
|
}
|
|
10996
11098
|
});
|
|
10997
11099
|
|
|
10998
|
-
// src/paths.ts
|
|
10999
|
-
import fs9 from "node:fs";
|
|
11000
|
-
import os5 from "node:os";
|
|
11001
|
-
import path36 from "node:path";
|
|
11002
|
-
function resolveAgentShimHome(env = process.env, home = os5.homedir(), isDirectory = isExistingDirectory) {
|
|
11003
|
-
const fromEnv = env.AGENT_SHIM_HOME;
|
|
11004
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
11005
|
-
return fromEnv;
|
|
11006
|
-
}
|
|
11007
|
-
const current = path36.join(home, HOME_DIRNAME);
|
|
11008
|
-
const legacy = path36.join(home, LEGACY_HOME_DIRNAME);
|
|
11009
|
-
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
11010
|
-
}
|
|
11011
|
-
function isExistingDirectory(candidate) {
|
|
11012
|
-
return fs9.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
11013
|
-
}
|
|
11014
|
-
function resolveClaudeHome() {
|
|
11015
|
-
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
11016
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
11017
|
-
return fromEnv;
|
|
11018
|
-
}
|
|
11019
|
-
return path36.join(os5.homedir(), ".claude");
|
|
11020
|
-
}
|
|
11021
|
-
function buildLayoutPaths(root) {
|
|
11022
|
-
return {
|
|
11023
|
-
root,
|
|
11024
|
-
identitiesDir: path36.join(root, "identities"),
|
|
11025
|
-
configProfilesDir: path36.join(root, "config-profiles"),
|
|
11026
|
-
providersDir: path36.join(root, "providers"),
|
|
11027
|
-
providerAliasesFile: path36.join(root, "provider-aliases.json"),
|
|
11028
|
-
directoryRulesFile: path36.join(root, "directory-rules.json"),
|
|
11029
|
-
activeIdentityFile: path36.join(root, "active-identity"),
|
|
11030
|
-
globalConfigFile: path36.join(root, "config.json"),
|
|
11031
|
-
categoriesLocalFile: path36.join(root, "categories.local.json"),
|
|
11032
|
-
claudeShimFile: path36.join(root, "claude-shim.json"),
|
|
11033
|
-
headroomDir: path36.join(root, "headroom"),
|
|
11034
|
-
headroomStateFile: path36.join(root, "headroom", "state.json"),
|
|
11035
|
-
headroomRoutingFile: path36.join(root, "headroom", "routing.json"),
|
|
11036
|
-
headroomLegacyStateFile: path36.join(root, "headroom", "state.v2.json"),
|
|
11037
|
-
headroomAllowlistFile: path36.join(root, "headroom", "run", "allowlist.txt"),
|
|
11038
|
-
headroomSocketDir: path36.join(root, "headroom", "run"),
|
|
11039
|
-
headroomLockFile: path36.join(root, "headroom", "start.lock"),
|
|
11040
|
-
headroomSessionsDir: path36.join(root, "headroom", "sessions"),
|
|
11041
|
-
logsDir: path36.join(root, "logs"),
|
|
11042
|
-
headroomLogPath: path36.join(root, "logs", "headroom.log"),
|
|
11043
|
-
frontdoorDir: path36.join(root, "frontdoor"),
|
|
11044
|
-
frontdoorCaDir: path36.join(root, "frontdoor", "ca"),
|
|
11045
|
-
frontdoorCaCertFile: path36.join(root, "frontdoor", "ca", "ca.pem"),
|
|
11046
|
-
frontdoorCaKeyFile: path36.join(root, "frontdoor", "ca", "ca.key"),
|
|
11047
|
-
frontdoorCaBundlesDir: path36.join(root, "frontdoor", "ca", "bundles"),
|
|
11048
|
-
chatgptSignInFile: path36.join(root, "codex", "chatgpt-sign-in.json"),
|
|
11049
|
-
frontdoorStateFile: path36.join(root, "frontdoor", "state.json"),
|
|
11050
|
-
frontdoorLockFile: path36.join(root, "frontdoor", "start.lock"),
|
|
11051
|
-
frontdoorControlTokenFile: path36.join(root, "frontdoor", "control-token"),
|
|
11052
|
-
frontdoorSessionsDir: path36.join(root, "frontdoor", "sessions"),
|
|
11053
|
-
frontdoorDirectRecordsDir: path36.join(root, "frontdoor", "direct"),
|
|
11054
|
-
frontdoorDrainingDir: path36.join(root, "frontdoor", "draining"),
|
|
11055
|
-
frontdoorRcCredentialsDir: path36.join(root, "frontdoor", "rc-credentials"),
|
|
11056
|
-
frontdoorLogPath: path36.join(root, "logs", "frontdoor.log"),
|
|
11057
|
-
usageDir: path36.join(root, "usage"),
|
|
11058
|
-
usageLogDir: path36.join(root, "usage", "log"),
|
|
11059
|
-
usageSnapshotsDir: path36.join(root, "usage", "snapshots"),
|
|
11060
|
-
statuslineDir: path36.join(root, "statusline"),
|
|
11061
|
-
catalogueDir: path36.join(root, "catalogues"),
|
|
11062
|
-
usagePicksFile: path36.join(root, "usage", "picks.json"),
|
|
11063
|
-
usageAnchorsFile: path36.join(root, "usage", "anchors.json"),
|
|
11064
|
-
usageJobsFile: path36.join(root, "usage", "jobs.json"),
|
|
11065
|
-
jobLogsDir: path36.join(root, "logs", "jobs"),
|
|
11066
|
-
identityRenamesDir: path36.join(root, "identity-renames"),
|
|
11067
|
-
identityNameRenamesDir: path36.join(root, "identity-name-renames"),
|
|
11068
|
-
launchesDir: path36.join(root, "launches"),
|
|
11069
|
-
superviseDir: path36.join(root, "supervise"),
|
|
11070
|
-
modelMovesDir: path36.join(root, "model-moves"),
|
|
11071
|
-
mcpPermissionsFile: path36.join(root, "mcp", "permissions.json")
|
|
11072
|
-
};
|
|
11073
|
-
}
|
|
11074
|
-
function resolveLayoutPaths() {
|
|
11075
|
-
return buildLayoutPaths(resolveAgentShimHome());
|
|
11076
|
-
}
|
|
11077
|
-
var init_paths = __esm({
|
|
11078
|
-
"src/paths.ts"() {
|
|
11079
|
-
"use strict";
|
|
11080
|
-
init_legacy();
|
|
11081
|
-
}
|
|
11082
|
-
});
|
|
11083
|
-
|
|
11084
11100
|
// src/providerAliases.ts
|
|
11085
11101
|
import { z as z26 } from "zod";
|
|
11086
11102
|
function parseAliases(file, raw) {
|
|
@@ -11333,12 +11349,12 @@ var init_families = __esm({
|
|
|
11333
11349
|
});
|
|
11334
11350
|
|
|
11335
11351
|
// src/providersStore.ts
|
|
11336
|
-
import
|
|
11352
|
+
import fs9 from "node:fs";
|
|
11337
11353
|
function providerJsonPath(paths, name) {
|
|
11338
11354
|
return providerFilePath(paths.providersDir, name);
|
|
11339
11355
|
}
|
|
11340
11356
|
function providerExists(paths, name) {
|
|
11341
|
-
return
|
|
11357
|
+
return fs9.existsSync(providerJsonPath(paths, name));
|
|
11342
11358
|
}
|
|
11343
11359
|
function requireProviderExists(paths, name) {
|
|
11344
11360
|
const canonical = canonicalProviderName(name, (candidate) => providerExists(paths, candidate), () => readProviderAliases(paths));
|
|
@@ -11395,12 +11411,12 @@ function parseProviderFile(filePath, raw) {
|
|
|
11395
11411
|
}
|
|
11396
11412
|
function readProvider(paths, name) {
|
|
11397
11413
|
const filePath = providerJsonPath(paths, name);
|
|
11398
|
-
if (!
|
|
11414
|
+
if (!fs9.existsSync(filePath)) {
|
|
11399
11415
|
return void 0;
|
|
11400
11416
|
}
|
|
11401
11417
|
let raw;
|
|
11402
11418
|
try {
|
|
11403
|
-
raw = JSON.parse(
|
|
11419
|
+
raw = JSON.parse(fs9.readFileSync(filePath, "utf8"));
|
|
11404
11420
|
} catch (error) {
|
|
11405
11421
|
throw error instanceof SyntaxError ? new ConfigFileNotJsonError(filePath) : error;
|
|
11406
11422
|
}
|
|
@@ -11416,7 +11432,7 @@ function reportInvalidProvider(name, message) {
|
|
|
11416
11432
|
}
|
|
11417
11433
|
function listProviders(paths, onInvalid = reportInvalidProvider) {
|
|
11418
11434
|
const names = listProviderNames(
|
|
11419
|
-
(dir) =>
|
|
11435
|
+
(dir) => fs9.readdirSync(dir),
|
|
11420
11436
|
paths.providersDir
|
|
11421
11437
|
);
|
|
11422
11438
|
const result = [];
|
|
@@ -11583,7 +11599,7 @@ function removeProvider(paths, name) {
|
|
|
11583
11599
|
if (!providerExists(paths, name)) {
|
|
11584
11600
|
throw new ProviderNotFoundError(name);
|
|
11585
11601
|
}
|
|
11586
|
-
|
|
11602
|
+
fs9.rmSync(providerJsonPath(paths, name));
|
|
11587
11603
|
createRealCredentialCache(paths.root).remove("file", `provider ${name}`);
|
|
11588
11604
|
}
|
|
11589
11605
|
function cascadeProviderName(cascade, identityProvider) {
|
|
@@ -11595,13 +11611,19 @@ function cascadeProviderName(cascade, identityProvider) {
|
|
|
11595
11611
|
}
|
|
11596
11612
|
return name ?? identityProvider;
|
|
11597
11613
|
}
|
|
11598
|
-
function
|
|
11614
|
+
function selectedProviderName(params) {
|
|
11599
11615
|
const cliName = params.cliProvider !== void 0 && params.cliProvider !== "" ? params.cliProvider : void 0;
|
|
11600
11616
|
const named = cliName ?? (params.cascade === void 0 ? params.identityProvider : cascadeProviderName(params.cascade, params.identityProvider));
|
|
11601
11617
|
if (named === void 0) {
|
|
11602
11618
|
return void 0;
|
|
11603
11619
|
}
|
|
11604
|
-
|
|
11620
|
+
return canonicalProviderName(named, (candidate) => loadProvider(params.paths.providersDir, candidate, params.port) !== void 0, () => loadProviderAliases(params.paths.providerAliasesFile, params.port));
|
|
11621
|
+
}
|
|
11622
|
+
function selectProvider(params) {
|
|
11623
|
+
const name = selectedProviderName(params);
|
|
11624
|
+
if (name === void 0) {
|
|
11625
|
+
return void 0;
|
|
11626
|
+
}
|
|
11605
11627
|
const definition = loadProvider(params.paths.providersDir, name, params.port);
|
|
11606
11628
|
if (definition === void 0) {
|
|
11607
11629
|
const known = listProviderNames(params.port.readdir, params.paths.providersDir);
|
|
@@ -11746,6 +11768,167 @@ var init_providersStore = __esm({
|
|
|
11746
11768
|
}
|
|
11747
11769
|
});
|
|
11748
11770
|
|
|
11771
|
+
// src/launcher/memberProvider.ts
|
|
11772
|
+
function unreadableFileReason(error) {
|
|
11773
|
+
if (error instanceof ConfigValidationError) {
|
|
11774
|
+
return `${error.filepath} is invalid`;
|
|
11775
|
+
}
|
|
11776
|
+
if (error instanceof ConfigFileNotJsonError) {
|
|
11777
|
+
return error.message.replace(/\.$/, "");
|
|
11778
|
+
}
|
|
11779
|
+
if (error instanceof LegacyProviderFileError) {
|
|
11780
|
+
return `${error.filePath} uses ${error.conversion.fields.join(", ")}, which a credential block replaced`;
|
|
11781
|
+
}
|
|
11782
|
+
return void 0;
|
|
11783
|
+
}
|
|
11784
|
+
function memberProviderResolver(params) {
|
|
11785
|
+
if (params.cliProvider === false) {
|
|
11786
|
+
return () => void 0;
|
|
11787
|
+
}
|
|
11788
|
+
const cliProvider = params.cliProvider;
|
|
11789
|
+
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
11790
|
+
const cascades = /* @__PURE__ */ new Map();
|
|
11791
|
+
const cascadeOver = (baseConfigProfile) => {
|
|
11792
|
+
const cached = cascades.get(baseConfigProfile);
|
|
11793
|
+
if (cached !== void 0) {
|
|
11794
|
+
return cached;
|
|
11795
|
+
}
|
|
11796
|
+
const loaded = params.loadCascade(baseConfigProfile);
|
|
11797
|
+
cascades.set(baseConfigProfile, loaded);
|
|
11798
|
+
return loaded;
|
|
11799
|
+
};
|
|
11800
|
+
return (name) => {
|
|
11801
|
+
let declared;
|
|
11802
|
+
try {
|
|
11803
|
+
declared = identities.load(name);
|
|
11804
|
+
} catch (error) {
|
|
11805
|
+
if (!(error instanceof ConfigValidationError)) {
|
|
11806
|
+
throw error;
|
|
11807
|
+
}
|
|
11808
|
+
}
|
|
11809
|
+
const profile = decideConfigProfile({
|
|
11810
|
+
env: params.env,
|
|
11811
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
11812
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
11813
|
+
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
11814
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
11815
|
+
});
|
|
11816
|
+
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
11817
|
+
let named = flagged ?? declared?.provider;
|
|
11818
|
+
try {
|
|
11819
|
+
const cascade = cascadeOver(profile.name);
|
|
11820
|
+
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
11821
|
+
return selectedProviderName({
|
|
11822
|
+
paths: params.paths,
|
|
11823
|
+
port: params.fs,
|
|
11824
|
+
...cliProvider === void 0 ? {} : { cliProvider },
|
|
11825
|
+
cascade,
|
|
11826
|
+
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
11827
|
+
});
|
|
11828
|
+
} catch (error) {
|
|
11829
|
+
const reason = unreadableFileReason(error);
|
|
11830
|
+
if (reason === void 0) {
|
|
11831
|
+
throw error;
|
|
11832
|
+
}
|
|
11833
|
+
return { ...named === void 0 ? {} : { named }, reason };
|
|
11834
|
+
}
|
|
11835
|
+
};
|
|
11836
|
+
}
|
|
11837
|
+
var init_memberProvider = __esm({
|
|
11838
|
+
"src/launcher/memberProvider.ts"() {
|
|
11839
|
+
"use strict";
|
|
11840
|
+
init_load();
|
|
11841
|
+
init_providersStore();
|
|
11842
|
+
init_identity();
|
|
11843
|
+
}
|
|
11844
|
+
});
|
|
11845
|
+
|
|
11846
|
+
// src/paths.ts
|
|
11847
|
+
import fs10 from "node:fs";
|
|
11848
|
+
import os6 from "node:os";
|
|
11849
|
+
import path36 from "node:path";
|
|
11850
|
+
function resolveAgentShimHome(env = process.env, home = os6.homedir(), isDirectory = isExistingDirectory) {
|
|
11851
|
+
const fromEnv = env.AGENT_SHIM_HOME;
|
|
11852
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
11853
|
+
return fromEnv;
|
|
11854
|
+
}
|
|
11855
|
+
const current = path36.join(home, HOME_DIRNAME);
|
|
11856
|
+
const legacy = path36.join(home, LEGACY_HOME_DIRNAME);
|
|
11857
|
+
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
11858
|
+
}
|
|
11859
|
+
function isExistingDirectory(candidate) {
|
|
11860
|
+
return fs10.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
11861
|
+
}
|
|
11862
|
+
function resolveClaudeHome() {
|
|
11863
|
+
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
11864
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
11865
|
+
return fromEnv;
|
|
11866
|
+
}
|
|
11867
|
+
return path36.join(os6.homedir(), ".claude");
|
|
11868
|
+
}
|
|
11869
|
+
function buildLayoutPaths(root) {
|
|
11870
|
+
return {
|
|
11871
|
+
root,
|
|
11872
|
+
identitiesDir: path36.join(root, "identities"),
|
|
11873
|
+
configProfilesDir: path36.join(root, "config-profiles"),
|
|
11874
|
+
providersDir: path36.join(root, "providers"),
|
|
11875
|
+
providerAliasesFile: path36.join(root, "provider-aliases.json"),
|
|
11876
|
+
directoryRulesFile: path36.join(root, "directory-rules.json"),
|
|
11877
|
+
activeIdentityFile: path36.join(root, "active-identity"),
|
|
11878
|
+
globalConfigFile: path36.join(root, "config.json"),
|
|
11879
|
+
categoriesLocalFile: path36.join(root, "categories.local.json"),
|
|
11880
|
+
claudeShimFile: path36.join(root, "claude-shim.json"),
|
|
11881
|
+
headroomDir: path36.join(root, "headroom"),
|
|
11882
|
+
headroomStateFile: path36.join(root, "headroom", "state.json"),
|
|
11883
|
+
headroomRoutingFile: path36.join(root, "headroom", "routing.json"),
|
|
11884
|
+
headroomLegacyStateFile: path36.join(root, "headroom", "state.v2.json"),
|
|
11885
|
+
headroomAllowlistFile: path36.join(root, "headroom", "run", "allowlist.txt"),
|
|
11886
|
+
headroomSocketDir: path36.join(root, "headroom", "run"),
|
|
11887
|
+
headroomLockFile: path36.join(root, "headroom", "start.lock"),
|
|
11888
|
+
headroomSessionsDir: path36.join(root, "headroom", "sessions"),
|
|
11889
|
+
logsDir: path36.join(root, "logs"),
|
|
11890
|
+
headroomLogPath: path36.join(root, "logs", "headroom.log"),
|
|
11891
|
+
frontdoorDir: path36.join(root, "frontdoor"),
|
|
11892
|
+
frontdoorCaDir: path36.join(root, "frontdoor", "ca"),
|
|
11893
|
+
frontdoorCaCertFile: path36.join(root, "frontdoor", "ca", "ca.pem"),
|
|
11894
|
+
frontdoorCaKeyFile: path36.join(root, "frontdoor", "ca", "ca.key"),
|
|
11895
|
+
frontdoorCaBundlesDir: path36.join(root, "frontdoor", "ca", "bundles"),
|
|
11896
|
+
chatgptSignInFile: path36.join(root, "codex", "chatgpt-sign-in.json"),
|
|
11897
|
+
frontdoorStateFile: path36.join(root, "frontdoor", "state.json"),
|
|
11898
|
+
frontdoorLockFile: path36.join(root, "frontdoor", "start.lock"),
|
|
11899
|
+
frontdoorControlTokenFile: path36.join(root, "frontdoor", "control-token"),
|
|
11900
|
+
frontdoorSessionsDir: path36.join(root, "frontdoor", "sessions"),
|
|
11901
|
+
frontdoorDirectRecordsDir: path36.join(root, "frontdoor", "direct"),
|
|
11902
|
+
frontdoorDrainingDir: path36.join(root, "frontdoor", "draining"),
|
|
11903
|
+
frontdoorRcCredentialsDir: path36.join(root, "frontdoor", "rc-credentials"),
|
|
11904
|
+
frontdoorLogPath: path36.join(root, "logs", "frontdoor.log"),
|
|
11905
|
+
usageDir: path36.join(root, "usage"),
|
|
11906
|
+
usageLogDir: path36.join(root, "usage", "log"),
|
|
11907
|
+
usageSnapshotsDir: path36.join(root, "usage", "snapshots"),
|
|
11908
|
+
statuslineDir: path36.join(root, "statusline"),
|
|
11909
|
+
catalogueDir: path36.join(root, "catalogues"),
|
|
11910
|
+
usagePicksFile: path36.join(root, "usage", "picks.json"),
|
|
11911
|
+
usageAnchorsFile: path36.join(root, "usage", "anchors.json"),
|
|
11912
|
+
usageJobsFile: path36.join(root, "usage", "jobs.json"),
|
|
11913
|
+
jobLogsDir: path36.join(root, "logs", "jobs"),
|
|
11914
|
+
identityRenamesDir: path36.join(root, "identity-renames"),
|
|
11915
|
+
identityNameRenamesDir: path36.join(root, "identity-name-renames"),
|
|
11916
|
+
launchesDir: path36.join(root, "launches"),
|
|
11917
|
+
superviseDir: path36.join(root, "supervise"),
|
|
11918
|
+
modelMovesDir: path36.join(root, "model-moves"),
|
|
11919
|
+
mcpPermissionsFile: path36.join(root, "mcp", "permissions.json")
|
|
11920
|
+
};
|
|
11921
|
+
}
|
|
11922
|
+
function resolveLayoutPaths() {
|
|
11923
|
+
return buildLayoutPaths(resolveAgentShimHome());
|
|
11924
|
+
}
|
|
11925
|
+
var init_paths = __esm({
|
|
11926
|
+
"src/paths.ts"() {
|
|
11927
|
+
"use strict";
|
|
11928
|
+
init_legacy();
|
|
11929
|
+
}
|
|
11930
|
+
});
|
|
11931
|
+
|
|
11749
11932
|
// src/launcher/claudeVersion.ts
|
|
11750
11933
|
function validated2(value, origin) {
|
|
11751
11934
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
@@ -11788,7 +11971,7 @@ function formatPeriod(window) {
|
|
|
11788
11971
|
if (window.periodMs === void 0) {
|
|
11789
11972
|
return window.period ?? "unknown period";
|
|
11790
11973
|
}
|
|
11791
|
-
const hours = window.periodMs /
|
|
11974
|
+
const hours = window.periodMs / MS_PER_HOUR5;
|
|
11792
11975
|
return hours >= HOURS_PER_DAY4 && Number.isInteger(hours / HOURS_PER_DAY4) ? `${String(hours / HOURS_PER_DAY4)}d` : `${String(hours)}h`;
|
|
11793
11976
|
}
|
|
11794
11977
|
function groupOf(row) {
|
|
@@ -11828,13 +12011,13 @@ function collectResets(snapshots, nowMs) {
|
|
|
11828
12011
|
);
|
|
11829
12012
|
return { resets: rows.sort(compareRows) };
|
|
11830
12013
|
}
|
|
11831
|
-
var
|
|
12014
|
+
var MS_PER_HOUR5, HOURS_PER_DAY4;
|
|
11832
12015
|
var init_resets = __esm({
|
|
11833
12016
|
"src/usage/resets.ts"() {
|
|
11834
12017
|
"use strict";
|
|
11835
12018
|
init_preflight();
|
|
11836
12019
|
init_rateLimit();
|
|
11837
|
-
|
|
12020
|
+
MS_PER_HOUR5 = 36e5;
|
|
11838
12021
|
HOURS_PER_DAY4 = 24;
|
|
11839
12022
|
}
|
|
11840
12023
|
});
|
|
@@ -12436,7 +12619,7 @@ var init_modelPicker = __esm({
|
|
|
12436
12619
|
});
|
|
12437
12620
|
|
|
12438
12621
|
// src/models/targets.ts
|
|
12439
|
-
import
|
|
12622
|
+
import os8 from "node:os";
|
|
12440
12623
|
function providerModels(paths) {
|
|
12441
12624
|
const door = readFrontDoorState(realFarmFs, paths.frontdoorStateFile);
|
|
12442
12625
|
const recordedPid = door?.port === void 0 ? void 0 : door.supervisorPid;
|
|
@@ -12449,7 +12632,7 @@ function providerModels(paths) {
|
|
|
12449
12632
|
if (entry.provider.kind === "codex") {
|
|
12450
12633
|
if (catalogue !== void 0 && catalogue.supervisorPid !== supervisorPid) return [];
|
|
12451
12634
|
const env = doorHome === void 0 ? process.env : { ...process.env, CODEX_HOME: doorHome };
|
|
12452
|
-
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env,
|
|
12635
|
+
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, os8.homedir(), realFsPort.readFileUtf8);
|
|
12453
12636
|
if (fingerprint === void 0 || catalogue?.credentialFingerprint !== fingerprint) return [];
|
|
12454
12637
|
}
|
|
12455
12638
|
return providerModelRows(entry.provider, catalogue?.models).map((row) => ({ provider: entry.name, model: row.model }));
|
|
@@ -13756,7 +13939,10 @@ var init_hold = __esm({
|
|
|
13756
13939
|
// src/launcher/launchReport.ts
|
|
13757
13940
|
function poolDetail(pool) {
|
|
13758
13941
|
const [reason] = pool.reasons;
|
|
13759
|
-
|
|
13942
|
+
if (reason === void 0) {
|
|
13943
|
+
return {};
|
|
13944
|
+
}
|
|
13945
|
+
return { detail: pool.provider === void 0 ? reason : `${reason} (ranked on provider ${pool.provider})` };
|
|
13760
13946
|
}
|
|
13761
13947
|
function rankingNotes(ranking, picked) {
|
|
13762
13948
|
return ranking.flatMap((candidate, index) => [
|
|
@@ -13918,6 +14104,7 @@ function resolvePoolLaunch(params) {
|
|
|
13918
14104
|
resuming,
|
|
13919
14105
|
...params.resumeContextTokens === void 0 ? {} : { resumeContextTokens: params.resumeContextTokens },
|
|
13920
14106
|
...params.committedContextTokens === void 0 ? {} : { committedContextTokens: params.committedContextTokens },
|
|
14107
|
+
...params.providerOf === void 0 ? {} : { providerOf: params.providerOf },
|
|
13921
14108
|
identityIdOf: identityIdResolver(params.paths.identitiesDir, params.fs),
|
|
13922
14109
|
...stickyRead.sticky === void 0 ? {} : { sticky: stickyRead.sticky }
|
|
13923
14110
|
});
|
|
@@ -13959,6 +14146,7 @@ function resolvePoolLaunch(params) {
|
|
|
13959
14146
|
explanation: `pool ${poolName}: ${move}${pick.reasons.slice(0, REASONS_LOGGED).join("; ")}`,
|
|
13960
14147
|
reasons: pick.reasons,
|
|
13961
14148
|
candidates: graph.ranking.candidates,
|
|
14149
|
+
...pick.provider === void 0 ? {} : { provider: pick.provider },
|
|
13962
14150
|
...movedOff === void 0 ? {} : { movedOff },
|
|
13963
14151
|
...stickyRead.sticky === void 0 ? {} : { lastRanAs: stickyRead.sticky }
|
|
13964
14152
|
};
|
|
@@ -13991,13 +14179,13 @@ var init_pool = __esm({
|
|
|
13991
14179
|
});
|
|
13992
14180
|
|
|
13993
14181
|
// src/launcher/spawn.ts
|
|
13994
|
-
import
|
|
14182
|
+
import os9 from "node:os";
|
|
13995
14183
|
function childExitCode(result) {
|
|
13996
14184
|
if (result.status !== null) {
|
|
13997
14185
|
return result.status;
|
|
13998
14186
|
}
|
|
13999
14187
|
if (result.signal !== null) {
|
|
14000
|
-
return SIGNAL_EXIT_CODE_OFFSET +
|
|
14188
|
+
return SIGNAL_EXIT_CODE_OFFSET + os9.constants.signals[result.signal];
|
|
14001
14189
|
}
|
|
14002
14190
|
return 1;
|
|
14003
14191
|
}
|
|
@@ -14090,7 +14278,7 @@ var init_launchHook = __esm({
|
|
|
14090
14278
|
|
|
14091
14279
|
// src/launcher.ts
|
|
14092
14280
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14093
|
-
import
|
|
14281
|
+
import os10 from "node:os";
|
|
14094
14282
|
import { isDeepStrictEqual } from "node:util";
|
|
14095
14283
|
import path51 from "node:path";
|
|
14096
14284
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
@@ -14100,7 +14288,7 @@ function resolveIdentityCredential(identity, credential, env, port) {
|
|
|
14100
14288
|
const resolution = resolveCredential({ credential, env, port, subject: `identity ${identity.name}`, cacheKey: identityCacheKey(identity.id) });
|
|
14101
14289
|
return resolution.ok ? resolution : { ok: false, status: CREDENTIAL_UNAVAILABLE_EXIT, message: `agent-shim: ${resolution.message}` };
|
|
14102
14290
|
}
|
|
14103
|
-
function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
14291
|
+
function pickFromPool(decided, params, parsedArgv, readOnly, providerSelections) {
|
|
14104
14292
|
const { paths, fs: fs17, proc, log } = params;
|
|
14105
14293
|
if (decided.pool === void 0) {
|
|
14106
14294
|
return { identityDecision: decided };
|
|
@@ -14115,6 +14303,17 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
14115
14303
|
return proc.exit(1);
|
|
14116
14304
|
}
|
|
14117
14305
|
const resumeContextTokens = resumedContextTokens(farmRuntime.fs, { claudeHome: farmRuntime.claudeHome, cwd: farmRuntime.cwd, passthrough: parsedArgv.rest });
|
|
14306
|
+
const cliFlagConfigProfile = params.cliFlagConfigProfile ?? parsedArgv.configProfile;
|
|
14307
|
+
const providerOf = memberProviderResolver({
|
|
14308
|
+
paths,
|
|
14309
|
+
fs: fs17,
|
|
14310
|
+
env: providerSelections.env,
|
|
14311
|
+
cliProvider: parsedArgv.provider,
|
|
14312
|
+
...cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile },
|
|
14313
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
14314
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile },
|
|
14315
|
+
loadCascade: (baseConfigProfile) => farmRuntime.loadCascade(baseConfigProfile, providerSelections.cliOverride)
|
|
14316
|
+
});
|
|
14118
14317
|
const resolution = resolvePoolLaunch({
|
|
14119
14318
|
poolName: decided.pool,
|
|
14120
14319
|
selectedVia: decided.source,
|
|
@@ -14126,6 +14325,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
14126
14325
|
now: farmRuntime.now,
|
|
14127
14326
|
sleep: farmRuntime.lock.sleep,
|
|
14128
14327
|
passthrough: parsedArgv.rest,
|
|
14328
|
+
providerOf,
|
|
14129
14329
|
...resumeContextTokens === void 0 ? {} : { resumeContextTokens },
|
|
14130
14330
|
// A read-only decision never sleeps for a refused pool and never records its pick, so asking what a launch would pick leaves the next real launch's keep-warm preference as it was.
|
|
14131
14331
|
wait: !readOnly && parsedArgv.wait === true,
|
|
@@ -14138,7 +14338,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
14138
14338
|
}
|
|
14139
14339
|
return {
|
|
14140
14340
|
identityDecision: { ...decided, name: resolution.identity },
|
|
14141
|
-
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
14341
|
+
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.provider === void 0 ? {} : { provider: resolution.provider }, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
14142
14342
|
poolRanking: resolution.candidates,
|
|
14143
14343
|
...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
|
|
14144
14344
|
};
|
|
@@ -14174,7 +14374,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
14174
14374
|
shareFlags: parsedArgv.shareFlags,
|
|
14175
14375
|
hideFlags: parsedArgv.hideFlags
|
|
14176
14376
|
});
|
|
14177
|
-
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
14377
|
+
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly, { env, cliOverride });
|
|
14178
14378
|
const lockFarm = !readOnly && !configDirEscapeHatchApplies && identityDecision.name !== void 0 ? params.farm : void 0;
|
|
14179
14379
|
const lockPorts = params.namesLock ?? (lockFarm === void 0 ? realIdentityNamesLockPorts : { fs: lockFarm.fs, nowMs: lockFarm.now, ...lockFarm.lock });
|
|
14180
14380
|
const namesLock = readOnly || configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : acquireIdentityNamesLock(paths, lockPorts);
|
|
@@ -14375,12 +14575,12 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
14375
14575
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
14376
14576
|
const binding = parseCatalogueBinding(params.fs.readFileUtf8(catalogueBindingPath(paths, name, catalogueOwner, generation)));
|
|
14377
14577
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
14378
|
-
const home = configuredHome === void 0 || configuredHome === "" ? path51.join(
|
|
14578
|
+
const home = configuredHome === void 0 || configuredHome === "" ? path51.join(os10.homedir(), ".codex") : configuredHome;
|
|
14379
14579
|
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : path51.resolve(home, "auth.json");
|
|
14380
14580
|
const revision = params.fs.fileRevision?.(source);
|
|
14381
14581
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
14382
14582
|
}
|
|
14383
|
-
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv,
|
|
14583
|
+
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, os10.homedir(), params.fs.readFileUtf8) : void 0;
|
|
14384
14584
|
if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
|
|
14385
14585
|
return [[name, definition, cache?.models ?? []]];
|
|
14386
14586
|
} catch {
|
|
@@ -14674,6 +14874,7 @@ var init_launcher = __esm({
|
|
|
14674
14874
|
init_state();
|
|
14675
14875
|
init_providerCatalogue();
|
|
14676
14876
|
init_providersStore();
|
|
14877
|
+
init_memberProvider();
|
|
14677
14878
|
init_pool();
|
|
14678
14879
|
init_resumeContext();
|
|
14679
14880
|
init_lock();
|
|
@@ -14797,7 +14998,7 @@ var init_trust = __esm({
|
|
|
14797
14998
|
|
|
14798
14999
|
// src/frontdoor/realFrontDoorPort.ts
|
|
14799
15000
|
import fs16 from "node:fs";
|
|
14800
|
-
import
|
|
15001
|
+
import os11 from "node:os";
|
|
14801
15002
|
function realEnsurePorts(paths, spawnDaemon) {
|
|
14802
15003
|
return {
|
|
14803
15004
|
fs: realFarmFs,
|
|
@@ -14844,7 +15045,7 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
14844
15045
|
const cache2 = parseCatalogueCache(realFarmFs.readFileUtf8(catalogueCachePath(paths, name, supervisorPid, owner.generation)));
|
|
14845
15046
|
let fingerprint;
|
|
14846
15047
|
try {
|
|
14847
|
-
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome },
|
|
15048
|
+
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, os11.homedir(), realFarmFs.readFileUtf8);
|
|
14848
15049
|
} catch (error) {
|
|
14849
15050
|
warnings.add(`Cannot read catalogue credentials for ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
14850
15051
|
return false;
|
|
@@ -14923,11 +15124,11 @@ var init_realFrontDoorPort = __esm({
|
|
|
14923
15124
|
});
|
|
14924
15125
|
|
|
14925
15126
|
// src/launchWiring.ts
|
|
14926
|
-
import
|
|
15127
|
+
import os12 from "node:os";
|
|
14927
15128
|
import path54 from "node:path";
|
|
14928
15129
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
14929
15130
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
14930
|
-
const home =
|
|
15131
|
+
const home = os12.homedir();
|
|
14931
15132
|
const read = cosmiconfigReader();
|
|
14932
15133
|
const classification = loadClassification(paths);
|
|
14933
15134
|
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
@@ -15200,7 +15401,7 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
15200
15401
|
init_schema();
|
|
15201
15402
|
init_identity();
|
|
15202
15403
|
init_middleware();
|
|
15203
|
-
|
|
15404
|
+
init_windowLengths();
|
|
15204
15405
|
init_plan2();
|
|
15205
15406
|
PERCENT2 = 100;
|
|
15206
15407
|
ANTHROPIC_USAGE_FRESHNESS_MS = FIVE_HOUR_WINDOW_MS / PERCENT2;
|
|
@@ -19126,7 +19327,7 @@ import { openapi as openapi9 } from "@orpc/openapi";
|
|
|
19126
19327
|
|
|
19127
19328
|
// src/checkReport.ts
|
|
19128
19329
|
init_cliError();
|
|
19129
|
-
import
|
|
19330
|
+
import os7 from "node:os";
|
|
19130
19331
|
|
|
19131
19332
|
// src/codex/categories.ts
|
|
19132
19333
|
var CODEX_CATEGORIES = {
|
|
@@ -19158,7 +19359,7 @@ init_load();
|
|
|
19158
19359
|
init_load();
|
|
19159
19360
|
init_cascade();
|
|
19160
19361
|
init_identity();
|
|
19161
|
-
import
|
|
19362
|
+
import os5 from "node:os";
|
|
19162
19363
|
|
|
19163
19364
|
// src/poolPickReport.ts
|
|
19164
19365
|
init_identity();
|
|
@@ -19172,6 +19373,7 @@ function candidateView(candidate) {
|
|
|
19172
19373
|
feasible: candidate.feasible,
|
|
19173
19374
|
...candidate.blockedUntilMs === void 0 ? {} : { blockedUntil: new Date(candidate.blockedUntilMs).toISOString() },
|
|
19174
19375
|
plan: candidate.plan,
|
|
19376
|
+
...candidate.provider === void 0 ? {} : { provider: candidate.provider },
|
|
19175
19377
|
reasons: [...candidate.reasons]
|
|
19176
19378
|
};
|
|
19177
19379
|
}
|
|
@@ -19185,6 +19387,7 @@ function collectPoolPick(params) {
|
|
|
19185
19387
|
nowMs: params.nowMs,
|
|
19186
19388
|
resuming: false,
|
|
19187
19389
|
identityIdOf: identityIdResolver(params.paths.identitiesDir, params.fs),
|
|
19390
|
+
...params.providerOf === void 0 ? {} : { providerOf: params.providerOf },
|
|
19188
19391
|
...sticky.sticky === void 0 ? {} : { sticky: sticky.sticky }
|
|
19189
19392
|
});
|
|
19190
19393
|
return {
|
|
@@ -19199,6 +19402,29 @@ function collectPoolPick(params) {
|
|
|
19199
19402
|
};
|
|
19200
19403
|
}
|
|
19201
19404
|
|
|
19405
|
+
// src/poolProviderWiring.ts
|
|
19406
|
+
init_load();
|
|
19407
|
+
init_cascade();
|
|
19408
|
+
init_memberProvider();
|
|
19409
|
+
init_realPorts();
|
|
19410
|
+
import os4 from "node:os";
|
|
19411
|
+
function realMemberProviderResolver(params) {
|
|
19412
|
+
const home = os4.homedir();
|
|
19413
|
+
const read = cosmiconfigReader();
|
|
19414
|
+
const loaded = params.loaded ?? loadCascadeInput({ paths: params.paths, home, cwd: params.cwd, read });
|
|
19415
|
+
const selections = readDirectorySelections(loaded);
|
|
19416
|
+
return memberProviderResolver({
|
|
19417
|
+
paths: params.paths,
|
|
19418
|
+
fs: realFsPort,
|
|
19419
|
+
env: params.env,
|
|
19420
|
+
cliProvider: params.cliProvider,
|
|
19421
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
19422
|
+
...selections.configProfile === void 0 ? {} : { directoryRuleConfigProfile: selections.configProfile },
|
|
19423
|
+
...loaded.globalConfig?.defaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: loaded.globalConfig.defaultConfigProfile },
|
|
19424
|
+
loadCascade: (baseConfigProfile) => loadCascadeInput({ paths: params.paths, home, cwd: params.cwd, read, ...baseConfigProfile === void 0 ? {} : { baseConfigProfile } }).input
|
|
19425
|
+
});
|
|
19426
|
+
}
|
|
19427
|
+
|
|
19202
19428
|
// src/launchSelection.ts
|
|
19203
19429
|
init_poolStore();
|
|
19204
19430
|
init_realPorts();
|
|
@@ -19224,7 +19450,8 @@ function selectLaunch(params, loaded) {
|
|
|
19224
19450
|
if (pools[decidedIdentity.pool] === void 0) {
|
|
19225
19451
|
throw new PoolNotFoundError(decidedIdentity.pool);
|
|
19226
19452
|
}
|
|
19227
|
-
|
|
19453
|
+
const providerOf = realMemberProviderResolver({ paths, cwd, env: params.env, ...params.configProfile === void 0 ? {} : { cliFlagConfigProfile: params.configProfile }, loaded });
|
|
19454
|
+
poolPick = collectPoolPick({ paths, fs: realFsPort, usageFs: realFarmFs, poolName: decidedIdentity.pool, pools, directory: cwd, nowMs: Date.now(), providerOf });
|
|
19228
19455
|
}
|
|
19229
19456
|
const identity = poolPick?.pick === void 0 ? decidedIdentity : { ...decidedIdentity, name: poolPick.pick };
|
|
19230
19457
|
const loadedIdentity = identity.name === void 0 ? void 0 : loadIdentity(paths.identitiesDir, identity.name, realFsPort);
|
|
@@ -19241,7 +19468,7 @@ function selectLaunch(params, loaded) {
|
|
|
19241
19468
|
};
|
|
19242
19469
|
}
|
|
19243
19470
|
function resolveLaunchSelection(params) {
|
|
19244
|
-
const loaded = loadCascadeInput({ paths: params.paths, home:
|
|
19471
|
+
const loaded = loadCascadeInput({ paths: params.paths, home: os5.homedir(), cwd: params.cwd, read: cosmiconfigReader() });
|
|
19245
19472
|
return selectLaunch(params, loaded).selection;
|
|
19246
19473
|
}
|
|
19247
19474
|
|
|
@@ -19581,7 +19808,7 @@ function loadCheckProvider(paths, name) {
|
|
|
19581
19808
|
}
|
|
19582
19809
|
function collectCheckReport(params) {
|
|
19583
19810
|
const { paths, cwd } = params;
|
|
19584
|
-
const home =
|
|
19811
|
+
const home = os7.homedir();
|
|
19585
19812
|
const read = cosmiconfigReader();
|
|
19586
19813
|
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
19587
19814
|
const git = resolveGitBranch(realRunPort, cwd);
|
|
@@ -19717,6 +19944,8 @@ var PoolPickCandidateViewSchema = z28.strictObject({
|
|
|
19717
19944
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
19718
19945
|
blockedUntil: z28.iso.datetime().optional(),
|
|
19719
19946
|
plan: PlanClassSchema,
|
|
19947
|
+
/** The provider the member was ranked on, when its launch spends one in place of its Claude account: its windows, refusals and plan are the provider's own. Absent when ranked on the Claude account. */
|
|
19948
|
+
provider: z28.string().optional(),
|
|
19720
19949
|
/** The facts behind the class and score, in the order they matter. */
|
|
19721
19950
|
reasons: z28.array(z28.string())
|
|
19722
19951
|
});
|
|
@@ -21884,6 +22113,8 @@ var LaunchResolveInputSchema = z41.strictObject({
|
|
|
21884
22113
|
var LaunchPoolDecisionSchema = z41.strictObject({
|
|
21885
22114
|
name: z41.string(),
|
|
21886
22115
|
reasons: z41.readonly(z41.array(z41.string())),
|
|
22116
|
+
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
22117
|
+
provider: z41.string().optional(),
|
|
21887
22118
|
movedOff: z41.strictObject({ identity: z41.string(), reason: z41.string() }).optional()
|
|
21888
22119
|
});
|
|
21889
22120
|
var LaunchDecisionSchema = z41.strictObject({
|
|
@@ -22634,7 +22865,7 @@ function createDoorHealthPublisher(hub, now, pid) {
|
|
|
22634
22865
|
}
|
|
22635
22866
|
|
|
22636
22867
|
// src/frontdoor/quotaExpiringEvents.ts
|
|
22637
|
-
|
|
22868
|
+
init_windowLengths();
|
|
22638
22869
|
var FINAL_SPAN_DENOMINATOR = 30;
|
|
22639
22870
|
var QUOTA_EXPIRING_WINDOW_FRACTION = 1 / FINAL_SPAN_DENOMINATOR;
|
|
22640
22871
|
function createQuotaExpiringPublisher(hub, deps) {
|
|
@@ -24940,7 +25171,7 @@ init_launchWiring();
|
|
|
24940
25171
|
init_argv();
|
|
24941
25172
|
init_cascade();
|
|
24942
25173
|
init_identity();
|
|
24943
|
-
import
|
|
25174
|
+
import os13 from "node:os";
|
|
24944
25175
|
|
|
24945
25176
|
// src/launcher/poolRefresh.ts
|
|
24946
25177
|
init_anthropicUsageRefresh();
|
|
@@ -24949,7 +25180,8 @@ async function refreshStalePoolMembers(params) {
|
|
|
24949
25180
|
if (identities.size === 0) {
|
|
24950
25181
|
return;
|
|
24951
25182
|
}
|
|
24952
|
-
|
|
25183
|
+
const members = params.loadMembers([...identities]).filter((member) => member.provider === void 0 && member.providerError === void 0);
|
|
25184
|
+
await params.refresher.refreshStale(members);
|
|
24953
25185
|
}
|
|
24954
25186
|
|
|
24955
25187
|
// src/poolUsageRefresh.ts
|
|
@@ -24969,7 +25201,7 @@ async function refreshPools(params) {
|
|
|
24969
25201
|
await refreshStalePoolMembers({
|
|
24970
25202
|
poolNames: params.poolNames,
|
|
24971
25203
|
pools: readPools(paths),
|
|
24972
|
-
loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now(), (name) => identityIdOf(paths, name)),
|
|
25204
|
+
loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now(), (name) => identityIdOf(paths, name), params.providerOf),
|
|
24973
25205
|
refresher
|
|
24974
25206
|
});
|
|
24975
25207
|
}
|
|
@@ -24991,12 +25223,13 @@ async function refreshPoolUsage(params) {
|
|
|
24991
25223
|
poolNames: params.poolNames,
|
|
24992
25224
|
spawnDaemon: daemonSpawnerFor(params.agentShim),
|
|
24993
25225
|
log: params.log ?? (() => void 0),
|
|
24994
|
-
...params.refresher === void 0 ? {} : { refresher: params.refresher }
|
|
25226
|
+
...params.refresher === void 0 ? {} : { refresher: params.refresher },
|
|
25227
|
+
...params.providerOf === void 0 ? {} : { providerOf: params.providerOf }
|
|
24995
25228
|
});
|
|
24996
25229
|
}
|
|
24997
25230
|
function poolSelectedByLaunch(options) {
|
|
24998
25231
|
const paths = options.paths ?? resolveLayoutPaths();
|
|
24999
|
-
const loaded = loadCascadeInput({ paths, home:
|
|
25232
|
+
const loaded = loadCascadeInput({ paths, home: os13.homedir(), cwd: options.cwd, read: cosmiconfigReader() });
|
|
25000
25233
|
return decideIdentity({
|
|
25001
25234
|
env: options.env,
|
|
25002
25235
|
argv0Identity: parseLauncherArgv(options.argv).identity,
|
|
@@ -25006,8 +25239,12 @@ function poolSelectedByLaunch(options) {
|
|
|
25006
25239
|
}
|
|
25007
25240
|
async function refreshLaunchPoolUsage(options) {
|
|
25008
25241
|
const pool = poolSelectedByLaunch(options);
|
|
25242
|
+
const paths = options.paths ?? resolveLayoutPaths();
|
|
25243
|
+
const parsed = parseLauncherArgv(options.argv);
|
|
25009
25244
|
await refreshPoolUsage({
|
|
25010
|
-
|
|
25245
|
+
paths,
|
|
25246
|
+
// The provider each member's launch will spend, resolved as the launch resolves it, so a launch through a provider probes no Claude account.
|
|
25247
|
+
...pool === void 0 ? {} : { providerOf: realMemberProviderResolver({ paths, cwd: options.cwd, env: options.env, ...parsed.provider === void 0 ? {} : { cliProvider: parsed.provider }, ...parsed.configProfile === void 0 ? {} : { cliFlagConfigProfile: parsed.configProfile } }) },
|
|
25011
25248
|
cwd: options.cwd,
|
|
25012
25249
|
poolNames: pool === void 0 ? [] : [pool],
|
|
25013
25250
|
...options.agentShim === void 0 ? {} : { agentShim: options.agentShim },
|
|
@@ -25379,6 +25616,7 @@ export {
|
|
|
25379
25616
|
realCodexAppServerPort,
|
|
25380
25617
|
realConnectCertStore,
|
|
25381
25618
|
realConnectEffects,
|
|
25619
|
+
realMemberProviderResolver,
|
|
25382
25620
|
realRcControlTransport,
|
|
25383
25621
|
realRcEventDial,
|
|
25384
25622
|
realRcStreamDial,
|