claude-use 11.81.0 → 11.82.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 +142 -24
- package/dist/index.cjs +134 -11
- package/dist/index.mjs +134 -11
- package/dist/types/index.d.ts +4 -2
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -28388,7 +28388,7 @@ var init_schema = __esm({
|
|
|
28388
28388
|
resumeOnLimit: external_exports.boolean().optional(),
|
|
28389
28389
|
/** Whether a supervised session's context is compacted before its identity's quota is spent, so the resume on the next member writes a small context instead of a large one. Needs `resumeOnLimit`. Absent means false. */
|
|
28390
28390
|
compactBeforeLimit: external_exports.boolean().optional(),
|
|
28391
|
-
/** The share of a quota window, in whole percent, at which sessions are compacted. Absent means the launcher decides from what compacting every session on the member would cost against what its
|
|
28391
|
+
/** The share of a quota window, in whole percent, at which sessions are compacted. Absent means the launcher decides from what compacting every session on the member would cost against what its tightest quota window has left. Needs `compactBeforeLimit`. */
|
|
28392
28392
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
28393
28393
|
}).refine((pool) => pool.compactBeforeLimit !== true || pool.resumeOnLimit === true, { message: "compactBeforeLimit needs resumeOnLimit, since a session that is not moved has no cold cache to avoid", path: ["compactBeforeLimit"] }).refine((pool) => pool.compactAtUtilisation === void 0 || pool.compactBeforeLimit === true, { message: "compactAtUtilisation needs compactBeforeLimit", path: ["compactAtUtilisation"] });
|
|
28394
28394
|
WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
@@ -38285,7 +38285,7 @@ var init_package = __esm({
|
|
|
38285
38285
|
"package.json"() {
|
|
38286
38286
|
package_default = {
|
|
38287
38287
|
name: "claude-use",
|
|
38288
|
-
version: "11.
|
|
38288
|
+
version: "11.82.0",
|
|
38289
38289
|
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.",
|
|
38290
38290
|
license: "MIT",
|
|
38291
38291
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -38952,10 +38952,10 @@ function billedTokensOf(record2) {
|
|
|
38952
38952
|
const usage = record2.usage;
|
|
38953
38953
|
return (usage?.inputTokens ?? 0) + (usage?.cacheCreationInputTokens ?? 0) + (usage?.outputTokens ?? 0);
|
|
38954
38954
|
}
|
|
38955
|
-
function utilisationPerBilledToken(records) {
|
|
38955
|
+
function utilisationPerBilledToken(records, which) {
|
|
38956
38956
|
const points = [];
|
|
38957
38957
|
for (const record2 of records) {
|
|
38958
|
-
const window = record2.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record2.rateLimitHeaders)?.
|
|
38958
|
+
const window = record2.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record2.rateLimitHeaders)?.[which];
|
|
38959
38959
|
if (window?.utilization !== void 0 && window.resetsAt !== void 0) {
|
|
38960
38960
|
points.push({ resetsAt: window.resetsAt, utilization: window.utilization, billed: billedTokensOf(record2) });
|
|
38961
38961
|
}
|
|
@@ -39140,14 +39140,17 @@ function rankPool(input2) {
|
|
|
39140
39140
|
}
|
|
39141
39141
|
const { sticky: sticky2 } = input2;
|
|
39142
39142
|
const warmHere = sticky2?.identity === candidate.identity && nowMs - Date.parse(sticky2.at) <= PROMPT_CACHE_TTL_MS;
|
|
39143
|
-
|
|
39144
|
-
|
|
39143
|
+
const resumeTokens = input2.resumeContextTokens;
|
|
39144
|
+
if (input2.resuming && resumeTokens !== void 0 && !warmHere) {
|
|
39145
39145
|
const committed = input2.committedContextTokens?.[candidate.identity] ?? 0;
|
|
39146
|
-
const
|
|
39147
|
-
|
|
39148
|
-
|
|
39149
|
-
const
|
|
39150
|
-
|
|
39146
|
+
const alongside = committed === 0 ? "" : ` (with ${String(committed)} tokens of other conversations already moving here)`;
|
|
39147
|
+
for (const [name, label2, window] of [["fiveHour", "5h", fiveHour], ["sevenDay", "7d", sevenDay]]) {
|
|
39148
|
+
const perToken = window === void 0 ? void 0 : utilisationPerBilledToken(assessment.member.records, name);
|
|
39149
|
+
const cost = perToken === void 0 ? void 0 : (resumeTokens + committed) * perToken;
|
|
39150
|
+
if (window !== void 0 && cost !== void 0 && cost > window.remaining) {
|
|
39151
|
+
dryAfterMs.push(0);
|
|
39152
|
+
drySpots.push(`resuming a ${String(resumeTokens)}-token conversation here${alongside} would cost about ${percent(cost)} of the ${label2} window, which has ${percent(window.remaining)} left`);
|
|
39153
|
+
}
|
|
39151
39154
|
}
|
|
39152
39155
|
}
|
|
39153
39156
|
if (drySpots.length === 0) {
|
|
@@ -120764,7 +120767,11 @@ function reasonNotToOpen(identity, snapshot, nowMs) {
|
|
|
120764
120767
|
if (five?.resetsAtMs !== void 0) {
|
|
120765
120768
|
return `a five-hour window is already open, resetting in ${formatAge(five.resetsAtMs - nowMs)}`;
|
|
120766
120769
|
}
|
|
120767
|
-
|
|
120770
|
+
const refusal2 = refusalReason(identity, snapshot, nowMs);
|
|
120771
|
+
if (refusal2 !== void 0 || five !== void 0) {
|
|
120772
|
+
return refusal2;
|
|
120773
|
+
}
|
|
120774
|
+
return "it reports a seven-day window and no five-hour one, so there is no five-hour window to anchor";
|
|
120768
120775
|
}
|
|
120769
120776
|
async function runWindowKeeper(ports) {
|
|
120770
120777
|
const nowMs = ports.nowMs();
|
|
@@ -123310,6 +123317,7 @@ var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
|
123310
123317
|
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
123311
123318
|
init_signIn();
|
|
123312
123319
|
init_identityAccounts();
|
|
123320
|
+
init_read();
|
|
123313
123321
|
init_load();
|
|
123314
123322
|
init_unrecognisedKeys();
|
|
123315
123323
|
init_schema();
|
|
@@ -123604,6 +123612,82 @@ function describeSharedLoginMembers(poolName, shared) {
|
|
|
123604
123612
|
return `Pool "${poolName}" lists ${joinNames(shared.members)}, which hold the same login${holder === void 0 ? "" : ` (${holder})`}, so they share one quota window. A launch ranks them as one candidate and never fails over from one to another; keep one of them in the pool.`;
|
|
123605
123613
|
}
|
|
123606
123614
|
|
|
123615
|
+
// src/poolWindowReads.ts
|
|
123616
|
+
init_schema();
|
|
123617
|
+
init_identity();
|
|
123618
|
+
init_conditions();
|
|
123619
|
+
init_middleware();
|
|
123620
|
+
init_rateLimit();
|
|
123621
|
+
var WINDOW_NAMES = ["fiveHour", "sevenDay", "extraUsage"];
|
|
123622
|
+
var WINDOW_PROSE = { fiveHour: "five-hour", sevenDay: "seven-day", extraUsage: "extra-usage" };
|
|
123623
|
+
var WINDOW_FACTS = ["remaining", "utilization", "hoursUntilReset"];
|
|
123624
|
+
var DERIVED_FACTS = [{ key: "quota.burnPerHour", window: "fiveHour" }];
|
|
123625
|
+
function receivedWindows(snapshot) {
|
|
123626
|
+
const unified = snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified;
|
|
123627
|
+
if (unified === void 0) {
|
|
123628
|
+
return void 0;
|
|
123629
|
+
}
|
|
123630
|
+
return /* @__PURE__ */ new Set([...unified.fiveHour === void 0 ? [] : ["fiveHour"], ...unified.sevenDay === void 0 ? [] : ["sevenDay"], ...soleOverageWindow(unified) === void 0 ? [] : ["extraUsage"]]);
|
|
123631
|
+
}
|
|
123632
|
+
function conditionReads(when) {
|
|
123633
|
+
const direct = WINDOW_NAMES.flatMap((window) => WINDOW_FACTS.some((fact) => referencesFact(when, `quota.${window}.${fact}`)) ? [{ window, reference: `quota.${window}` }] : []);
|
|
123634
|
+
const derived2 = DERIVED_FACTS.flatMap(({ key, window }) => referencesFact(when, key) ? [{ window, reference: key }] : []);
|
|
123635
|
+
return [...direct, ...derived2];
|
|
123636
|
+
}
|
|
123637
|
+
function identitiesOf(selector, pools, visited = /* @__PURE__ */ new Set()) {
|
|
123638
|
+
const nested = poolNameOf(selector);
|
|
123639
|
+
if (nested === void 0) {
|
|
123640
|
+
return [selector];
|
|
123641
|
+
}
|
|
123642
|
+
const pool = pools[nested];
|
|
123643
|
+
if (pool === void 0 || visited.has(nested)) {
|
|
123644
|
+
return [];
|
|
123645
|
+
}
|
|
123646
|
+
visited.add(nested);
|
|
123647
|
+
return [...new Set(pool.identities.flatMap((member) => identitiesOf(poolMemberIdentity(member), pools, visited)))];
|
|
123648
|
+
}
|
|
123649
|
+
function poolWindowReadFindings(pools, windowsOf2) {
|
|
123650
|
+
const findings = [];
|
|
123651
|
+
for (const [poolName, pool] of Object.entries(pools)) {
|
|
123652
|
+
for (const member of pool.identities) {
|
|
123653
|
+
if (typeof member === "string") {
|
|
123654
|
+
continue;
|
|
123655
|
+
}
|
|
123656
|
+
const reads = conditionReads(member.when);
|
|
123657
|
+
for (const identity of identitiesOf(member.identity, pools)) {
|
|
123658
|
+
const received = windowsOf2(identity);
|
|
123659
|
+
for (const { window, reference } of reads) {
|
|
123660
|
+
if (received !== void 0 && !received.has(window)) {
|
|
123661
|
+
findings.push({ subject: poolName, message: `Pool "${poolName}" guards ${member.identity} with a condition that reads ${reference}, but ${identity} reports no ${WINDOW_PROSE[window]} window, so the condition is undecided for it and it always ranks last within its class.` });
|
|
123662
|
+
}
|
|
123663
|
+
}
|
|
123664
|
+
}
|
|
123665
|
+
}
|
|
123666
|
+
if (pool.compactBeforeLimit === true) {
|
|
123667
|
+
for (const identity of identitiesOf(`pool:${poolName}`, pools)) {
|
|
123668
|
+
const received = windowsOf2(identity);
|
|
123669
|
+
if (received !== void 0 && !received.has("fiveHour") && !received.has("sevenDay")) {
|
|
123670
|
+
findings.push({ subject: poolName, message: `Pool "${poolName}" compacts before the limit, but ${identity} reports no five-hour or seven-day window, so its sessions are never compacted before the limit.` });
|
|
123671
|
+
}
|
|
123672
|
+
}
|
|
123673
|
+
}
|
|
123674
|
+
}
|
|
123675
|
+
return findings;
|
|
123676
|
+
}
|
|
123677
|
+
function jobWindowReadFindings(jobs, pools, windowsOf2) {
|
|
123678
|
+
return Object.entries(jobs).flatMap(([jobName, job]) => {
|
|
123679
|
+
const { trigger, target } = job;
|
|
123680
|
+
if (!("beforeReset" in trigger)) {
|
|
123681
|
+
return [];
|
|
123682
|
+
}
|
|
123683
|
+
const identities = "pool" in target ? identitiesOf(`pool:${target.pool}`, pools) : identitiesOf(target.identity, pools);
|
|
123684
|
+
return identities.flatMap((identity) => {
|
|
123685
|
+
const received = windowsOf2(identity);
|
|
123686
|
+
return received === void 0 || received.has(trigger.beforeReset) ? [] : [{ subject: jobName, message: `Job "${jobName}" runs before the ${WINDOW_PROSE[trigger.beforeReset]} window resets, but ${identity} reports no ${WINDOW_PROSE[trigger.beforeReset]} window, so the job is skipped whenever it runs as ${identity}.` }];
|
|
123687
|
+
});
|
|
123688
|
+
});
|
|
123689
|
+
}
|
|
123690
|
+
|
|
123607
123691
|
// src/doctorReport.ts
|
|
123608
123692
|
init_extends();
|
|
123609
123693
|
var DOCTOR_SEVERITIES = ["pass", "warn", "fail"];
|
|
@@ -123972,6 +124056,17 @@ function runDoctor(params) {
|
|
|
123972
124056
|
reportedCycles.add(key);
|
|
123973
124057
|
push("pool", "fail", `Pool cycle: ${chain.join(" -> ")}. A pool cannot nest itself, directly or through another pool.`, chain[0]);
|
|
123974
124058
|
}
|
|
124059
|
+
const { usageSnapshots } = params;
|
|
124060
|
+
if (usageSnapshots !== void 0) {
|
|
124061
|
+
const windowsOf2 = (identityName) => receivedWindows(usageSnapshots[identityName]);
|
|
124062
|
+
for (const finding of poolWindowReadFindings(pools, windowsOf2)) {
|
|
124063
|
+
push("pool", "warn", finding.message, finding.subject);
|
|
124064
|
+
}
|
|
124065
|
+
const jobs = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.jobs ?? {} : {};
|
|
124066
|
+
for (const finding of jobWindowReadFindings(jobs, pools, windowsOf2)) {
|
|
124067
|
+
push("global-config", "warn", finding.message, finding.subject);
|
|
124068
|
+
}
|
|
124069
|
+
}
|
|
123975
124070
|
const selectionExists = (selector) => {
|
|
123976
124071
|
const poolName = poolNameOf(selector);
|
|
123977
124072
|
return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
|
|
@@ -124230,6 +124325,19 @@ function collectDoctorReport(params) {
|
|
|
124230
124325
|
const identityPath = import_node_path47.default.join(farmRoot, "identity.json");
|
|
124231
124326
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs20.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, name)?.account };
|
|
124232
124327
|
});
|
|
124328
|
+
const usageSnapshots = {};
|
|
124329
|
+
for (const name of identityNames) {
|
|
124330
|
+
try {
|
|
124331
|
+
const snapshot = readUsageSnapshot(realFsPort, paths.usageSnapshotsDir, name);
|
|
124332
|
+
if (snapshot !== void 0) {
|
|
124333
|
+
usageSnapshots[name] = snapshot;
|
|
124334
|
+
}
|
|
124335
|
+
} catch (error63) {
|
|
124336
|
+
if (!(error63 instanceof UsageSnapshotError)) {
|
|
124337
|
+
throw error63;
|
|
124338
|
+
}
|
|
124339
|
+
}
|
|
124340
|
+
}
|
|
124233
124341
|
const profileNames = import_node_fs20.default.existsSync(paths.configProfilesDir) ? import_node_fs20.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
124234
124342
|
const configProfiles = profileNames.map((name) => {
|
|
124235
124343
|
const profilePath = import_node_path47.default.join(paths.configProfilesDir, `${name}.json`);
|
|
@@ -124273,6 +124381,7 @@ function collectDoctorReport(params) {
|
|
|
124273
124381
|
chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
|
|
124274
124382
|
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
124275
124383
|
identities,
|
|
124384
|
+
usageSnapshots,
|
|
124276
124385
|
configProfiles,
|
|
124277
124386
|
providers,
|
|
124278
124387
|
providerAliases: readProviderAliases(paths),
|
|
@@ -156524,7 +156633,7 @@ function membersOf(options) {
|
|
|
156524
156633
|
}
|
|
156525
156634
|
var RESUME_ON_LIMIT_DESCRIPTION = "Keep an interactive session of this pool going when its identity runs out of quota: the launcher stops it and resumes the same conversation under the next ranked member, on the same terminal.";
|
|
156526
156635
|
var COMPACT_BEFORE_LIMIT_DESCRIPTION = "Compact each supervised session's context while its member can still afford it, so the resume on the next member writes a small context instead of a large one. Needs --resume-on-limit.";
|
|
156527
|
-
var COMPACT_AT_UTILISATION_DESCRIPTION = "Compact when either quota window of the member passes this share, in whole percent. Without it, a session is compacted when compacting every session on its member would cost more than the
|
|
156636
|
+
var COMPACT_AT_UTILISATION_DESCRIPTION = "Compact when either quota window of the member passes this share, in whole percent. Without it, a session is compacted when compacting every session on its member would cost more than the member's tightest quota window has left. Needs --compact-before-limit.";
|
|
156528
156637
|
var PREFERENCE_DESCRIPTION = "How a launch picks a member: score (the default) picks the member whose remaining quota expires soonest; listed tries the members in the order the pool lists them, skipping any that is refused right now.";
|
|
156529
156638
|
function registerPoolCommand(program2, deps) {
|
|
156530
156639
|
const { paths } = deps;
|
|
@@ -156598,7 +156707,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
156598
156707
|
console.log("Resume on limit: yes");
|
|
156599
156708
|
}
|
|
156600
156709
|
if (entry.compactBeforeLimit === true) {
|
|
156601
|
-
console.log(`Compact before limit: ${entry.compactAtUtilisation === void 0 ? "when compacting would cost more than the
|
|
156710
|
+
console.log(`Compact before limit: ${entry.compactAtUtilisation === void 0 ? "when compacting would cost more than the member's tightest quota window has left" : `at ${String(entry.compactAtUtilisation)}% of a window`}`);
|
|
156602
156711
|
}
|
|
156603
156712
|
}),
|
|
156604
156713
|
["agent-shim pool show subs"]
|
|
@@ -158245,25 +158354,34 @@ var asPercent = (fraction) => `${String(Math.round(fraction * PERCENT6))}%`;
|
|
|
158245
158354
|
function compactableTokens(state) {
|
|
158246
158355
|
return state?.mark === "idle" && state.compacted !== true && state.contextTokens !== void 0 && state.contextTokens > 0 ? state.contextTokens : void 0;
|
|
158247
158356
|
}
|
|
158248
|
-
function
|
|
158357
|
+
function presentWindows(input2) {
|
|
158249
158358
|
const unified = input2.snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified;
|
|
158250
|
-
|
|
158359
|
+
return [["fiveHour", "5h"], ["sevenDay", "7d"]].flatMap(([name, label2]) => {
|
|
158360
|
+
const recorded = unified?.[name];
|
|
158361
|
+
return recorded === void 0 ? [] : [{ name, label: label2, window: effectiveWindow(recorded, input2.nowMs) }];
|
|
158362
|
+
});
|
|
158363
|
+
}
|
|
158364
|
+
function triggerReason(input2) {
|
|
158365
|
+
const windows = presentWindows(input2);
|
|
158251
158366
|
if (input2.atUtilisation !== void 0) {
|
|
158252
|
-
const
|
|
158253
|
-
|
|
158254
|
-
|
|
158255
|
-
return `the ${name} window is at ${asPercent(window.utilization)}, past ${String(input2.atUtilisation)}%`;
|
|
158367
|
+
for (const { label: label2, window } of windows) {
|
|
158368
|
+
if (window.utilization !== void 0 && window.utilization * PERCENT6 >= input2.atUtilisation) {
|
|
158369
|
+
return `the ${label2} window is at ${asPercent(window.utilization)}, past ${String(input2.atUtilisation)}%`;
|
|
158256
158370
|
}
|
|
158257
158371
|
}
|
|
158258
158372
|
return void 0;
|
|
158259
158373
|
}
|
|
158260
|
-
const
|
|
158261
|
-
|
|
158374
|
+
const measured = windows.flatMap(({ name, label: label2, window }) => window.utilization === void 0 ? [] : [{ name, label: label2, remaining: Math.max(0, 1 - window.utilization) }]);
|
|
158375
|
+
const tightest = measured.reduce((least, entry) => least === void 0 || entry.remaining < least.remaining ? entry : least, void 0);
|
|
158376
|
+
if (tightest === void 0) {
|
|
158377
|
+
return void 0;
|
|
158378
|
+
}
|
|
158379
|
+
const perToken = utilisationPerBilledToken(input2.records(), tightest.name);
|
|
158380
|
+
if (perToken === void 0) {
|
|
158262
158381
|
return void 0;
|
|
158263
158382
|
}
|
|
158264
|
-
const remaining = Math.max(0, 1 - five.utilization);
|
|
158265
158383
|
const cost = input2.sessions.reduce((sum2, session) => sum2 + (session.state?.contextTokens ?? 0), 0) * perToken;
|
|
158266
|
-
return remaining < cost ? `the
|
|
158384
|
+
return tightest.remaining < cost ? `the ${tightest.label} window has ${asPercent(tightest.remaining)} left, and compacting every session on this member would use about ${asPercent(cost)}` : void 0;
|
|
158267
158385
|
}
|
|
158268
158386
|
function decideCompaction(input2) {
|
|
158269
158387
|
const own2 = input2.sessions.find((session) => session.sessionId === input2.sessionId);
|
package/dist/index.cjs
CHANGED
|
@@ -1128,7 +1128,7 @@ var init_schema = __esm({
|
|
|
1128
1128
|
resumeOnLimit: import_zod3.z.boolean().optional(),
|
|
1129
1129
|
/** Whether a supervised session's context is compacted before its identity's quota is spent, so the resume on the next member writes a small context instead of a large one. Needs `resumeOnLimit`. Absent means false. */
|
|
1130
1130
|
compactBeforeLimit: import_zod3.z.boolean().optional(),
|
|
1131
|
-
/** The share of a quota window, in whole percent, at which sessions are compacted. Absent means the launcher decides from what compacting every session on the member would cost against what its
|
|
1131
|
+
/** The share of a quota window, in whole percent, at which sessions are compacted. Absent means the launcher decides from what compacting every session on the member would cost against what its tightest quota window has left. Needs `compactBeforeLimit`. */
|
|
1132
1132
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
1133
1133
|
}).refine((pool) => pool.compactBeforeLimit !== true || pool.resumeOnLimit === true, { message: "compactBeforeLimit needs resumeOnLimit, since a session that is not moved has no cold cache to avoid", path: ["compactBeforeLimit"] }).refine((pool) => pool.compactAtUtilisation === void 0 || pool.compactBeforeLimit === true, { message: "compactAtUtilisation needs compactBeforeLimit", path: ["compactAtUtilisation"] });
|
|
1134
1134
|
WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
@@ -1729,6 +1729,24 @@ function evaluateWhen(when, context) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
return { status: "definite", passed: failed.length === 0, checked, failed };
|
|
1731
1731
|
}
|
|
1732
|
+
function referencesFact(when, key) {
|
|
1733
|
+
if (when === void 0 || !("kind" in when)) {
|
|
1734
|
+
return false;
|
|
1735
|
+
}
|
|
1736
|
+
const walk2 = (node) => {
|
|
1737
|
+
if (Array.isArray(node)) {
|
|
1738
|
+
return node.some(walk2);
|
|
1739
|
+
}
|
|
1740
|
+
if (typeof node !== "object" || node === null) {
|
|
1741
|
+
return false;
|
|
1742
|
+
}
|
|
1743
|
+
if ("kind" in node && node.kind === "reference" && "key" in node && node.key === key) {
|
|
1744
|
+
return true;
|
|
1745
|
+
}
|
|
1746
|
+
return Object.values(node).some(walk2);
|
|
1747
|
+
};
|
|
1748
|
+
return walk2(when);
|
|
1749
|
+
}
|
|
1732
1750
|
function isVacuousWhen(when) {
|
|
1733
1751
|
return when !== void 0 && !("kind" in when) && Object.keys(when).length === 0;
|
|
1734
1752
|
}
|
|
@@ -4769,7 +4787,7 @@ var init_package = __esm({
|
|
|
4769
4787
|
"package.json"() {
|
|
4770
4788
|
package_default = {
|
|
4771
4789
|
name: "claude-use",
|
|
4772
|
-
version: "11.
|
|
4790
|
+
version: "11.82.0",
|
|
4773
4791
|
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.",
|
|
4774
4792
|
license: "MIT",
|
|
4775
4793
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -7428,10 +7446,10 @@ function billedTokensOf(record) {
|
|
|
7428
7446
|
const usage = record.usage;
|
|
7429
7447
|
return (usage?.inputTokens ?? 0) + (usage?.cacheCreationInputTokens ?? 0) + (usage?.outputTokens ?? 0);
|
|
7430
7448
|
}
|
|
7431
|
-
function utilisationPerBilledToken(records) {
|
|
7449
|
+
function utilisationPerBilledToken(records, which) {
|
|
7432
7450
|
const points = [];
|
|
7433
7451
|
for (const record of records) {
|
|
7434
|
-
const window = record.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record.rateLimitHeaders)?.
|
|
7452
|
+
const window = record.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record.rateLimitHeaders)?.[which];
|
|
7435
7453
|
if (window?.utilization !== void 0 && window.resetsAt !== void 0) {
|
|
7436
7454
|
points.push({ resetsAt: window.resetsAt, utilization: window.utilization, billed: billedTokensOf(record) });
|
|
7437
7455
|
}
|
|
@@ -7616,14 +7634,17 @@ function rankPool(input) {
|
|
|
7616
7634
|
}
|
|
7617
7635
|
const { sticky: sticky2 } = input;
|
|
7618
7636
|
const warmHere = sticky2?.identity === candidate.identity && nowMs - Date.parse(sticky2.at) <= PROMPT_CACHE_TTL_MS;
|
|
7619
|
-
|
|
7620
|
-
|
|
7637
|
+
const resumeTokens = input.resumeContextTokens;
|
|
7638
|
+
if (input.resuming && resumeTokens !== void 0 && !warmHere) {
|
|
7621
7639
|
const committed = input.committedContextTokens?.[candidate.identity] ?? 0;
|
|
7622
|
-
const
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
const
|
|
7626
|
-
|
|
7640
|
+
const alongside = committed === 0 ? "" : ` (with ${String(committed)} tokens of other conversations already moving here)`;
|
|
7641
|
+
for (const [name, label, window] of [["fiveHour", "5h", fiveHour], ["sevenDay", "7d", sevenDay]]) {
|
|
7642
|
+
const perToken = window === void 0 ? void 0 : utilisationPerBilledToken(assessment.member.records, name);
|
|
7643
|
+
const cost = perToken === void 0 ? void 0 : (resumeTokens + committed) * perToken;
|
|
7644
|
+
if (window !== void 0 && cost !== void 0 && cost > window.remaining) {
|
|
7645
|
+
dryAfterMs.push(0);
|
|
7646
|
+
drySpots.push(`resuming a ${String(resumeTokens)}-token conversation here${alongside} would cost about ${percent(cost)} of the ${label} window, which has ${percent(window.remaining)} left`);
|
|
7647
|
+
}
|
|
7627
7648
|
}
|
|
7628
7649
|
}
|
|
7629
7650
|
if (drySpots.length === 0) {
|
|
@@ -17205,6 +17226,7 @@ var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
|
17205
17226
|
var import_node_path29 = __toESM(require("node:path"), 1);
|
|
17206
17227
|
init_signIn();
|
|
17207
17228
|
init_identityAccounts();
|
|
17229
|
+
init_read();
|
|
17208
17230
|
|
|
17209
17231
|
// src/codex/siwcStore.ts
|
|
17210
17232
|
var import_zod26 = require("zod");
|
|
@@ -17578,6 +17600,82 @@ function describeSharedLoginMembers(poolName, shared) {
|
|
|
17578
17600
|
return `Pool "${poolName}" lists ${joinNames(shared.members)}, which hold the same login${holder === void 0 ? "" : ` (${holder})`}, so they share one quota window. A launch ranks them as one candidate and never fails over from one to another; keep one of them in the pool.`;
|
|
17579
17601
|
}
|
|
17580
17602
|
|
|
17603
|
+
// src/poolWindowReads.ts
|
|
17604
|
+
init_schema();
|
|
17605
|
+
init_identity();
|
|
17606
|
+
init_conditions();
|
|
17607
|
+
init_middleware();
|
|
17608
|
+
init_rateLimit();
|
|
17609
|
+
var WINDOW_NAMES = ["fiveHour", "sevenDay", "extraUsage"];
|
|
17610
|
+
var WINDOW_PROSE = { fiveHour: "five-hour", sevenDay: "seven-day", extraUsage: "extra-usage" };
|
|
17611
|
+
var WINDOW_FACTS = ["remaining", "utilization", "hoursUntilReset"];
|
|
17612
|
+
var DERIVED_FACTS = [{ key: "quota.burnPerHour", window: "fiveHour" }];
|
|
17613
|
+
function receivedWindows(snapshot) {
|
|
17614
|
+
const unified = snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified;
|
|
17615
|
+
if (unified === void 0) {
|
|
17616
|
+
return void 0;
|
|
17617
|
+
}
|
|
17618
|
+
return /* @__PURE__ */ new Set([...unified.fiveHour === void 0 ? [] : ["fiveHour"], ...unified.sevenDay === void 0 ? [] : ["sevenDay"], ...soleOverageWindow(unified) === void 0 ? [] : ["extraUsage"]]);
|
|
17619
|
+
}
|
|
17620
|
+
function conditionReads(when) {
|
|
17621
|
+
const direct = WINDOW_NAMES.flatMap((window) => WINDOW_FACTS.some((fact) => referencesFact(when, `quota.${window}.${fact}`)) ? [{ window, reference: `quota.${window}` }] : []);
|
|
17622
|
+
const derived = DERIVED_FACTS.flatMap(({ key, window }) => referencesFact(when, key) ? [{ window, reference: key }] : []);
|
|
17623
|
+
return [...direct, ...derived];
|
|
17624
|
+
}
|
|
17625
|
+
function identitiesOf(selector, pools, visited = /* @__PURE__ */ new Set()) {
|
|
17626
|
+
const nested = poolNameOf(selector);
|
|
17627
|
+
if (nested === void 0) {
|
|
17628
|
+
return [selector];
|
|
17629
|
+
}
|
|
17630
|
+
const pool = pools[nested];
|
|
17631
|
+
if (pool === void 0 || visited.has(nested)) {
|
|
17632
|
+
return [];
|
|
17633
|
+
}
|
|
17634
|
+
visited.add(nested);
|
|
17635
|
+
return [...new Set(pool.identities.flatMap((member) => identitiesOf(poolMemberIdentity(member), pools, visited)))];
|
|
17636
|
+
}
|
|
17637
|
+
function poolWindowReadFindings(pools, windowsOf) {
|
|
17638
|
+
const findings = [];
|
|
17639
|
+
for (const [poolName, pool] of Object.entries(pools)) {
|
|
17640
|
+
for (const member of pool.identities) {
|
|
17641
|
+
if (typeof member === "string") {
|
|
17642
|
+
continue;
|
|
17643
|
+
}
|
|
17644
|
+
const reads = conditionReads(member.when);
|
|
17645
|
+
for (const identity of identitiesOf(member.identity, pools)) {
|
|
17646
|
+
const received = windowsOf(identity);
|
|
17647
|
+
for (const { window, reference } of reads) {
|
|
17648
|
+
if (received !== void 0 && !received.has(window)) {
|
|
17649
|
+
findings.push({ subject: poolName, message: `Pool "${poolName}" guards ${member.identity} with a condition that reads ${reference}, but ${identity} reports no ${WINDOW_PROSE[window]} window, so the condition is undecided for it and it always ranks last within its class.` });
|
|
17650
|
+
}
|
|
17651
|
+
}
|
|
17652
|
+
}
|
|
17653
|
+
}
|
|
17654
|
+
if (pool.compactBeforeLimit === true) {
|
|
17655
|
+
for (const identity of identitiesOf(`pool:${poolName}`, pools)) {
|
|
17656
|
+
const received = windowsOf(identity);
|
|
17657
|
+
if (received !== void 0 && !received.has("fiveHour") && !received.has("sevenDay")) {
|
|
17658
|
+
findings.push({ subject: poolName, message: `Pool "${poolName}" compacts before the limit, but ${identity} reports no five-hour or seven-day window, so its sessions are never compacted before the limit.` });
|
|
17659
|
+
}
|
|
17660
|
+
}
|
|
17661
|
+
}
|
|
17662
|
+
}
|
|
17663
|
+
return findings;
|
|
17664
|
+
}
|
|
17665
|
+
function jobWindowReadFindings(jobs, pools, windowsOf) {
|
|
17666
|
+
return Object.entries(jobs).flatMap(([jobName, job]) => {
|
|
17667
|
+
const { trigger, target } = job;
|
|
17668
|
+
if (!("beforeReset" in trigger)) {
|
|
17669
|
+
return [];
|
|
17670
|
+
}
|
|
17671
|
+
const identities = "pool" in target ? identitiesOf(`pool:${target.pool}`, pools) : identitiesOf(target.identity, pools);
|
|
17672
|
+
return identities.flatMap((identity) => {
|
|
17673
|
+
const received = windowsOf(identity);
|
|
17674
|
+
return received === void 0 || received.has(trigger.beforeReset) ? [] : [{ subject: jobName, message: `Job "${jobName}" runs before the ${WINDOW_PROSE[trigger.beforeReset]} window resets, but ${identity} reports no ${WINDOW_PROSE[trigger.beforeReset]} window, so the job is skipped whenever it runs as ${identity}.` }];
|
|
17675
|
+
});
|
|
17676
|
+
});
|
|
17677
|
+
}
|
|
17678
|
+
|
|
17581
17679
|
// src/doctorReport.ts
|
|
17582
17680
|
init_extends();
|
|
17583
17681
|
var DOCTOR_SEVERITIES = ["pass", "warn", "fail"];
|
|
@@ -17946,6 +18044,17 @@ function runDoctor(params) {
|
|
|
17946
18044
|
reportedCycles.add(key);
|
|
17947
18045
|
push("pool", "fail", `Pool cycle: ${chain.join(" -> ")}. A pool cannot nest itself, directly or through another pool.`, chain[0]);
|
|
17948
18046
|
}
|
|
18047
|
+
const { usageSnapshots } = params;
|
|
18048
|
+
if (usageSnapshots !== void 0) {
|
|
18049
|
+
const windowsOf = (identityName) => receivedWindows(usageSnapshots[identityName]);
|
|
18050
|
+
for (const finding of poolWindowReadFindings(pools, windowsOf)) {
|
|
18051
|
+
push("pool", "warn", finding.message, finding.subject);
|
|
18052
|
+
}
|
|
18053
|
+
const jobs = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.jobs ?? {} : {};
|
|
18054
|
+
for (const finding of jobWindowReadFindings(jobs, pools, windowsOf)) {
|
|
18055
|
+
push("global-config", "warn", finding.message, finding.subject);
|
|
18056
|
+
}
|
|
18057
|
+
}
|
|
17949
18058
|
const selectionExists = (selector) => {
|
|
17950
18059
|
const poolName = poolNameOf(selector);
|
|
17951
18060
|
return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
|
|
@@ -18204,6 +18313,19 @@ function collectDoctorReport(params) {
|
|
|
18204
18313
|
const identityPath = import_node_path29.default.join(farmRoot, "identity.json");
|
|
18205
18314
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs10.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, name)?.account };
|
|
18206
18315
|
});
|
|
18316
|
+
const usageSnapshots = {};
|
|
18317
|
+
for (const name of identityNames) {
|
|
18318
|
+
try {
|
|
18319
|
+
const snapshot = readUsageSnapshot(realFsPort, paths.usageSnapshotsDir, name);
|
|
18320
|
+
if (snapshot !== void 0) {
|
|
18321
|
+
usageSnapshots[name] = snapshot;
|
|
18322
|
+
}
|
|
18323
|
+
} catch (error) {
|
|
18324
|
+
if (!(error instanceof UsageSnapshotError)) {
|
|
18325
|
+
throw error;
|
|
18326
|
+
}
|
|
18327
|
+
}
|
|
18328
|
+
}
|
|
18207
18329
|
const profileNames = import_node_fs10.default.existsSync(paths.configProfilesDir) ? import_node_fs10.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
18208
18330
|
const configProfiles = profileNames.map((name) => {
|
|
18209
18331
|
const profilePath = import_node_path29.default.join(paths.configProfilesDir, `${name}.json`);
|
|
@@ -18247,6 +18369,7 @@ function collectDoctorReport(params) {
|
|
|
18247
18369
|
chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
|
|
18248
18370
|
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
18249
18371
|
identities,
|
|
18372
|
+
usageSnapshots,
|
|
18250
18373
|
configProfiles,
|
|
18251
18374
|
providers,
|
|
18252
18375
|
providerAliases: readProviderAliases(paths),
|
package/dist/index.mjs
CHANGED
|
@@ -1106,7 +1106,7 @@ var init_schema = __esm({
|
|
|
1106
1106
|
resumeOnLimit: z3.boolean().optional(),
|
|
1107
1107
|
/** Whether a supervised session's context is compacted before its identity's quota is spent, so the resume on the next member writes a small context instead of a large one. Needs `resumeOnLimit`. Absent means false. */
|
|
1108
1108
|
compactBeforeLimit: z3.boolean().optional(),
|
|
1109
|
-
/** The share of a quota window, in whole percent, at which sessions are compacted. Absent means the launcher decides from what compacting every session on the member would cost against what its
|
|
1109
|
+
/** The share of a quota window, in whole percent, at which sessions are compacted. Absent means the launcher decides from what compacting every session on the member would cost against what its tightest quota window has left. Needs `compactBeforeLimit`. */
|
|
1110
1110
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
1111
1111
|
}).refine((pool) => pool.compactBeforeLimit !== true || pool.resumeOnLimit === true, { message: "compactBeforeLimit needs resumeOnLimit, since a session that is not moved has no cold cache to avoid", path: ["compactBeforeLimit"] }).refine((pool) => pool.compactAtUtilisation === void 0 || pool.compactBeforeLimit === true, { message: "compactAtUtilisation needs compactBeforeLimit", path: ["compactAtUtilisation"] });
|
|
1112
1112
|
WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
@@ -1709,6 +1709,24 @@ function evaluateWhen(when, context) {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
return { status: "definite", passed: failed.length === 0, checked, failed };
|
|
1711
1711
|
}
|
|
1712
|
+
function referencesFact(when, key) {
|
|
1713
|
+
if (when === void 0 || !("kind" in when)) {
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1716
|
+
const walk2 = (node) => {
|
|
1717
|
+
if (Array.isArray(node)) {
|
|
1718
|
+
return node.some(walk2);
|
|
1719
|
+
}
|
|
1720
|
+
if (typeof node !== "object" || node === null) {
|
|
1721
|
+
return false;
|
|
1722
|
+
}
|
|
1723
|
+
if ("kind" in node && node.kind === "reference" && "key" in node && node.key === key) {
|
|
1724
|
+
return true;
|
|
1725
|
+
}
|
|
1726
|
+
return Object.values(node).some(walk2);
|
|
1727
|
+
};
|
|
1728
|
+
return walk2(when);
|
|
1729
|
+
}
|
|
1712
1730
|
function isVacuousWhen(when) {
|
|
1713
1731
|
return when !== void 0 && !("kind" in when) && Object.keys(when).length === 0;
|
|
1714
1732
|
}
|
|
@@ -4745,7 +4763,7 @@ var init_package = __esm({
|
|
|
4745
4763
|
"package.json"() {
|
|
4746
4764
|
package_default = {
|
|
4747
4765
|
name: "claude-use",
|
|
4748
|
-
version: "11.
|
|
4766
|
+
version: "11.82.0",
|
|
4749
4767
|
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.",
|
|
4750
4768
|
license: "MIT",
|
|
4751
4769
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -7403,10 +7421,10 @@ function billedTokensOf(record) {
|
|
|
7403
7421
|
const usage = record.usage;
|
|
7404
7422
|
return (usage?.inputTokens ?? 0) + (usage?.cacheCreationInputTokens ?? 0) + (usage?.outputTokens ?? 0);
|
|
7405
7423
|
}
|
|
7406
|
-
function utilisationPerBilledToken(records) {
|
|
7424
|
+
function utilisationPerBilledToken(records, which) {
|
|
7407
7425
|
const points = [];
|
|
7408
7426
|
for (const record of records) {
|
|
7409
|
-
const window = record.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record.rateLimitHeaders)?.
|
|
7427
|
+
const window = record.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record.rateLimitHeaders)?.[which];
|
|
7410
7428
|
if (window?.utilization !== void 0 && window.resetsAt !== void 0) {
|
|
7411
7429
|
points.push({ resetsAt: window.resetsAt, utilization: window.utilization, billed: billedTokensOf(record) });
|
|
7412
7430
|
}
|
|
@@ -7591,14 +7609,17 @@ function rankPool(input) {
|
|
|
7591
7609
|
}
|
|
7592
7610
|
const { sticky: sticky2 } = input;
|
|
7593
7611
|
const warmHere = sticky2?.identity === candidate.identity && nowMs - Date.parse(sticky2.at) <= PROMPT_CACHE_TTL_MS;
|
|
7594
|
-
|
|
7595
|
-
|
|
7612
|
+
const resumeTokens = input.resumeContextTokens;
|
|
7613
|
+
if (input.resuming && resumeTokens !== void 0 && !warmHere) {
|
|
7596
7614
|
const committed = input.committedContextTokens?.[candidate.identity] ?? 0;
|
|
7597
|
-
const
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
const
|
|
7601
|
-
|
|
7615
|
+
const alongside = committed === 0 ? "" : ` (with ${String(committed)} tokens of other conversations already moving here)`;
|
|
7616
|
+
for (const [name, label, window] of [["fiveHour", "5h", fiveHour], ["sevenDay", "7d", sevenDay]]) {
|
|
7617
|
+
const perToken = window === void 0 ? void 0 : utilisationPerBilledToken(assessment.member.records, name);
|
|
7618
|
+
const cost = perToken === void 0 ? void 0 : (resumeTokens + committed) * perToken;
|
|
7619
|
+
if (window !== void 0 && cost !== void 0 && cost > window.remaining) {
|
|
7620
|
+
dryAfterMs.push(0);
|
|
7621
|
+
drySpots.push(`resuming a ${String(resumeTokens)}-token conversation here${alongside} would cost about ${percent(cost)} of the ${label} window, which has ${percent(window.remaining)} left`);
|
|
7622
|
+
}
|
|
7602
7623
|
}
|
|
7603
7624
|
}
|
|
7604
7625
|
if (drySpots.length === 0) {
|
|
@@ -16790,6 +16811,7 @@ import fs11 from "node:fs";
|
|
|
16790
16811
|
import path29 from "node:path";
|
|
16791
16812
|
init_signIn();
|
|
16792
16813
|
init_identityAccounts();
|
|
16814
|
+
init_read();
|
|
16793
16815
|
|
|
16794
16816
|
// src/codex/siwcStore.ts
|
|
16795
16817
|
import { z as z26 } from "zod";
|
|
@@ -17163,6 +17185,82 @@ function describeSharedLoginMembers(poolName, shared) {
|
|
|
17163
17185
|
return `Pool "${poolName}" lists ${joinNames(shared.members)}, which hold the same login${holder === void 0 ? "" : ` (${holder})`}, so they share one quota window. A launch ranks them as one candidate and never fails over from one to another; keep one of them in the pool.`;
|
|
17164
17186
|
}
|
|
17165
17187
|
|
|
17188
|
+
// src/poolWindowReads.ts
|
|
17189
|
+
init_schema();
|
|
17190
|
+
init_identity();
|
|
17191
|
+
init_conditions();
|
|
17192
|
+
init_middleware();
|
|
17193
|
+
init_rateLimit();
|
|
17194
|
+
var WINDOW_NAMES = ["fiveHour", "sevenDay", "extraUsage"];
|
|
17195
|
+
var WINDOW_PROSE = { fiveHour: "five-hour", sevenDay: "seven-day", extraUsage: "extra-usage" };
|
|
17196
|
+
var WINDOW_FACTS = ["remaining", "utilization", "hoursUntilReset"];
|
|
17197
|
+
var DERIVED_FACTS = [{ key: "quota.burnPerHour", window: "fiveHour" }];
|
|
17198
|
+
function receivedWindows(snapshot) {
|
|
17199
|
+
const unified = snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified;
|
|
17200
|
+
if (unified === void 0) {
|
|
17201
|
+
return void 0;
|
|
17202
|
+
}
|
|
17203
|
+
return /* @__PURE__ */ new Set([...unified.fiveHour === void 0 ? [] : ["fiveHour"], ...unified.sevenDay === void 0 ? [] : ["sevenDay"], ...soleOverageWindow(unified) === void 0 ? [] : ["extraUsage"]]);
|
|
17204
|
+
}
|
|
17205
|
+
function conditionReads(when) {
|
|
17206
|
+
const direct = WINDOW_NAMES.flatMap((window) => WINDOW_FACTS.some((fact) => referencesFact(when, `quota.${window}.${fact}`)) ? [{ window, reference: `quota.${window}` }] : []);
|
|
17207
|
+
const derived = DERIVED_FACTS.flatMap(({ key, window }) => referencesFact(when, key) ? [{ window, reference: key }] : []);
|
|
17208
|
+
return [...direct, ...derived];
|
|
17209
|
+
}
|
|
17210
|
+
function identitiesOf(selector, pools, visited = /* @__PURE__ */ new Set()) {
|
|
17211
|
+
const nested = poolNameOf(selector);
|
|
17212
|
+
if (nested === void 0) {
|
|
17213
|
+
return [selector];
|
|
17214
|
+
}
|
|
17215
|
+
const pool = pools[nested];
|
|
17216
|
+
if (pool === void 0 || visited.has(nested)) {
|
|
17217
|
+
return [];
|
|
17218
|
+
}
|
|
17219
|
+
visited.add(nested);
|
|
17220
|
+
return [...new Set(pool.identities.flatMap((member) => identitiesOf(poolMemberIdentity(member), pools, visited)))];
|
|
17221
|
+
}
|
|
17222
|
+
function poolWindowReadFindings(pools, windowsOf) {
|
|
17223
|
+
const findings = [];
|
|
17224
|
+
for (const [poolName, pool] of Object.entries(pools)) {
|
|
17225
|
+
for (const member of pool.identities) {
|
|
17226
|
+
if (typeof member === "string") {
|
|
17227
|
+
continue;
|
|
17228
|
+
}
|
|
17229
|
+
const reads = conditionReads(member.when);
|
|
17230
|
+
for (const identity of identitiesOf(member.identity, pools)) {
|
|
17231
|
+
const received = windowsOf(identity);
|
|
17232
|
+
for (const { window, reference } of reads) {
|
|
17233
|
+
if (received !== void 0 && !received.has(window)) {
|
|
17234
|
+
findings.push({ subject: poolName, message: `Pool "${poolName}" guards ${member.identity} with a condition that reads ${reference}, but ${identity} reports no ${WINDOW_PROSE[window]} window, so the condition is undecided for it and it always ranks last within its class.` });
|
|
17235
|
+
}
|
|
17236
|
+
}
|
|
17237
|
+
}
|
|
17238
|
+
}
|
|
17239
|
+
if (pool.compactBeforeLimit === true) {
|
|
17240
|
+
for (const identity of identitiesOf(`pool:${poolName}`, pools)) {
|
|
17241
|
+
const received = windowsOf(identity);
|
|
17242
|
+
if (received !== void 0 && !received.has("fiveHour") && !received.has("sevenDay")) {
|
|
17243
|
+
findings.push({ subject: poolName, message: `Pool "${poolName}" compacts before the limit, but ${identity} reports no five-hour or seven-day window, so its sessions are never compacted before the limit.` });
|
|
17244
|
+
}
|
|
17245
|
+
}
|
|
17246
|
+
}
|
|
17247
|
+
}
|
|
17248
|
+
return findings;
|
|
17249
|
+
}
|
|
17250
|
+
function jobWindowReadFindings(jobs, pools, windowsOf) {
|
|
17251
|
+
return Object.entries(jobs).flatMap(([jobName, job]) => {
|
|
17252
|
+
const { trigger, target } = job;
|
|
17253
|
+
if (!("beforeReset" in trigger)) {
|
|
17254
|
+
return [];
|
|
17255
|
+
}
|
|
17256
|
+
const identities = "pool" in target ? identitiesOf(`pool:${target.pool}`, pools) : identitiesOf(target.identity, pools);
|
|
17257
|
+
return identities.flatMap((identity) => {
|
|
17258
|
+
const received = windowsOf(identity);
|
|
17259
|
+
return received === void 0 || received.has(trigger.beforeReset) ? [] : [{ subject: jobName, message: `Job "${jobName}" runs before the ${WINDOW_PROSE[trigger.beforeReset]} window resets, but ${identity} reports no ${WINDOW_PROSE[trigger.beforeReset]} window, so the job is skipped whenever it runs as ${identity}.` }];
|
|
17260
|
+
});
|
|
17261
|
+
});
|
|
17262
|
+
}
|
|
17263
|
+
|
|
17166
17264
|
// src/doctorReport.ts
|
|
17167
17265
|
init_extends();
|
|
17168
17266
|
var DOCTOR_SEVERITIES = ["pass", "warn", "fail"];
|
|
@@ -17531,6 +17629,17 @@ function runDoctor(params) {
|
|
|
17531
17629
|
reportedCycles.add(key);
|
|
17532
17630
|
push("pool", "fail", `Pool cycle: ${chain.join(" -> ")}. A pool cannot nest itself, directly or through another pool.`, chain[0]);
|
|
17533
17631
|
}
|
|
17632
|
+
const { usageSnapshots } = params;
|
|
17633
|
+
if (usageSnapshots !== void 0) {
|
|
17634
|
+
const windowsOf = (identityName) => receivedWindows(usageSnapshots[identityName]);
|
|
17635
|
+
for (const finding of poolWindowReadFindings(pools, windowsOf)) {
|
|
17636
|
+
push("pool", "warn", finding.message, finding.subject);
|
|
17637
|
+
}
|
|
17638
|
+
const jobs = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.jobs ?? {} : {};
|
|
17639
|
+
for (const finding of jobWindowReadFindings(jobs, pools, windowsOf)) {
|
|
17640
|
+
push("global-config", "warn", finding.message, finding.subject);
|
|
17641
|
+
}
|
|
17642
|
+
}
|
|
17534
17643
|
const selectionExists = (selector) => {
|
|
17535
17644
|
const poolName = poolNameOf(selector);
|
|
17536
17645
|
return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
|
|
@@ -17789,6 +17898,19 @@ function collectDoctorReport(params) {
|
|
|
17789
17898
|
const identityPath = path29.join(farmRoot, "identity.json");
|
|
17790
17899
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: fs11.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, name)?.account };
|
|
17791
17900
|
});
|
|
17901
|
+
const usageSnapshots = {};
|
|
17902
|
+
for (const name of identityNames) {
|
|
17903
|
+
try {
|
|
17904
|
+
const snapshot = readUsageSnapshot(realFsPort, paths.usageSnapshotsDir, name);
|
|
17905
|
+
if (snapshot !== void 0) {
|
|
17906
|
+
usageSnapshots[name] = snapshot;
|
|
17907
|
+
}
|
|
17908
|
+
} catch (error) {
|
|
17909
|
+
if (!(error instanceof UsageSnapshotError)) {
|
|
17910
|
+
throw error;
|
|
17911
|
+
}
|
|
17912
|
+
}
|
|
17913
|
+
}
|
|
17792
17914
|
const profileNames = fs11.existsSync(paths.configProfilesDir) ? fs11.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
17793
17915
|
const configProfiles = profileNames.map((name) => {
|
|
17794
17916
|
const profilePath = path29.join(paths.configProfilesDir, `${name}.json`);
|
|
@@ -17832,6 +17954,7 @@ function collectDoctorReport(params) {
|
|
|
17832
17954
|
chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
|
|
17833
17955
|
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
17834
17956
|
identities,
|
|
17957
|
+
usageSnapshots,
|
|
17835
17958
|
configProfiles,
|
|
17836
17959
|
providers,
|
|
17837
17960
|
providerAliases: readProviderAliases(paths),
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2117,7 +2117,7 @@ type PoolPreference = z.infer<typeof PoolPreferenceSchema>;
|
|
|
2117
2117
|
*
|
|
2118
2118
|
* A member entry may name another pool (`pool:<name>`), which is ranked with its own preference and contributes its pick at the entry's position; see `PoolMemberSchema`. The graph must stay acyclic, which `pool add`/`pool set` enforce and `doctor` re-checks.
|
|
2119
2119
|
*
|
|
2120
|
-
* `compactBeforeLimit` makes the supervised sessions compact their context while their member can still afford it, at `compactAtUtilisation` percent of a window or, when that is absent, when compacting every session on the member would cost more than
|
|
2120
|
+
* `compactBeforeLimit` makes the supervised sessions compact their context while their member can still afford it, at `compactAtUtilisation` percent of a window or, when that is absent, when compacting every session on the member would cost more than the window it has the smallest share left of (the seven-day one for an account with no five-hour window) has left.
|
|
2121
2121
|
*
|
|
2122
2122
|
* `resumeOnLimit` makes an interactive launch from the pool supervised: when its identity runs out of quota, the launcher stops the session and resumes the same conversation under the next ranked member, on the same terminal. Absent means false.
|
|
2123
2123
|
*
|
|
@@ -9311,6 +9311,8 @@ interface RunDoctorParams {
|
|
|
9311
9311
|
readonly raw: string | undefined;
|
|
9312
9312
|
};
|
|
9313
9313
|
readonly identities: readonly DoctorIdentityInput[];
|
|
9314
|
+
/** Each identity's last recorded usage snapshot, by identity name. Omit to skip checking that pools and jobs read only windows their identities receive; an identity missing from it has no readable snapshot, so what it receives is unknown and nothing is reported for it. */
|
|
9315
|
+
readonly usageSnapshots?: Readonly<Record<string, UsageSnapshot>>;
|
|
9314
9316
|
readonly configProfiles: readonly DoctorConfigProfileInput[];
|
|
9315
9317
|
readonly providers: readonly DoctorProviderInput[];
|
|
9316
9318
|
/** The recorded former names of renamed providers. Omit to leave them out of the findings. */
|
|
@@ -26524,7 +26526,7 @@ interface ConditionContext {
|
|
|
26524
26526
|
readonly branchDetached?: boolean;
|
|
26525
26527
|
readonly env: Readonly<Record<string, string | undefined>>;
|
|
26526
26528
|
/**
|
|
26527
|
-
* The pool-selection facts a member entry's policy condition reads. Present only when the condition guards a pool member, so the same reference namespace serves the cascade and the pool: `quota.fiveHour.remaining`, `quota.fiveHour.utilization`, `quota.fiveHour.hoursUntilReset`, the same three under `quota.sevenDay`, and under `quota.extraUsage` for an account metered by extra usage alone (an Enterprise one with no plan windows), `quota.burnPerHour` (the five-hour window's observed utilisation pace, in fractions per hour), `session.resuming` (this launch resumes or continues a conversation) and `session.lastPickHoursAgo` (how long ago this directory last picked this member). Conversation context is deliberately not provided: nothing the door holds knows it, so a condition referencing it is indeterminate, naming the missing fact, rather than guessed.
|
|
26529
|
+
* The pool-selection facts a member entry's policy condition reads. Present only when the condition guards a pool member, so the same reference namespace serves the cascade and the pool: `quota.fiveHour.remaining`, `quota.fiveHour.utilization`, `quota.fiveHour.hoursUntilReset`, the same three under `quota.sevenDay`, and under `quota.extraUsage` for an account metered by extra usage alone (an Enterprise one with no plan windows), `quota.burnPerHour` (the five-hour window's observed utilisation pace, in fractions per hour, so absent for an account without that window), `session.resuming` (this launch resumes or continues a conversation) and `session.lastPickHoursAgo` (how long ago this directory last picked this member). Conversation context is deliberately not provided: nothing the door holds knows it, so a condition referencing it is indeterminate, naming the missing fact, rather than guessed. A window the account does not have is absent in the same way, never a guessed zero: a verified Ultra account reports no five-hour window, so a condition reading `quota.fiveHour.*` or `quota.burnPerHour` is indeterminate for it on every evaluation, which `doctor` reports.
|
|
26528
26530
|
*/
|
|
26529
26531
|
readonly pool?: {
|
|
26530
26532
|
readonly fiveHour?: PoolWindowFacts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-use",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.82.0",
|
|
4
4
|
"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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|