claude-use 11.75.0 → 11.77.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/README.md +1 -1
- package/dist/cli.cjs +2351 -2184
- package/dist/index.cjs +341 -196
- package/dist/index.mjs +341 -196
- package/dist/types/index.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1207,6 +1207,8 @@ var init_schema = __esm({
|
|
|
1207
1207
|
$schema: z3.string().optional(),
|
|
1208
1208
|
name: FileNameSchema,
|
|
1209
1209
|
defaultConfigProfile: StoredNameSchema.optional(),
|
|
1210
|
+
/** The provider this identity exists for: a launch on the identity routes through it unless `--provider`, `--no-provider` or a cascade layer's `launch.provider` says otherwise. Its sessions run on the provider's credential, so the identity needs no stored login. */
|
|
1211
|
+
provider: StoredNameSchema.optional(),
|
|
1210
1212
|
allowAmbientCredential: z3.boolean().default(false),
|
|
1211
1213
|
credential: CredentialSchema.optional(),
|
|
1212
1214
|
/** When this identity's five-hour window should be open: the front door opens one at each anchor if none is. Absent, nothing is opened on a schedule. */
|
|
@@ -4738,7 +4740,7 @@ var init_package = __esm({
|
|
|
4738
4740
|
"package.json"() {
|
|
4739
4741
|
package_default = {
|
|
4740
4742
|
name: "claude-use",
|
|
4741
|
-
version: "11.
|
|
4743
|
+
version: "11.77.0",
|
|
4742
4744
|
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.",
|
|
4743
4745
|
license: "MIT",
|
|
4744
4746
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -5945,19 +5947,23 @@ function renderReport(rows, style) {
|
|
|
5945
5947
|
const lines = [style(["bold"], REPORT_HEADING)];
|
|
5946
5948
|
for (const row of rows) {
|
|
5947
5949
|
const detail = row.detail === void 0 ? "" : ` ${style(["dim"], `(${row.detail})`)}`;
|
|
5948
|
-
|
|
5950
|
+
const label = row.label.padEnd(labelWidth);
|
|
5951
|
+
lines.push(
|
|
5952
|
+
row.notice === true ? `${indent}${style(NOTICE_FORMATS, label)}${COLUMN_GAP}${style(NOTICE_FORMATS, row.value)}${detail}` : `${indent}${style(["dim"], label)}${COLUMN_GAP}${row.value}${detail}`
|
|
5953
|
+
);
|
|
5949
5954
|
for (const note of row.notes ?? []) {
|
|
5950
5955
|
lines.push(`${indent}${" ".repeat(labelWidth)}${COLUMN_GAP}${style(["dim"], note)}`);
|
|
5951
5956
|
}
|
|
5952
5957
|
}
|
|
5953
5958
|
return lines;
|
|
5954
5959
|
}
|
|
5955
|
-
var REPORT_HEADING, COLUMN_GAP;
|
|
5960
|
+
var REPORT_HEADING, COLUMN_GAP, NOTICE_FORMATS;
|
|
5956
5961
|
var init_report = __esm({
|
|
5957
5962
|
"src/launcher/report.ts"() {
|
|
5958
5963
|
"use strict";
|
|
5959
5964
|
REPORT_HEADING = "agent-shim";
|
|
5960
5965
|
COLUMN_GAP = " ";
|
|
5966
|
+
NOTICE_FORMATS = ["yellow", "bold"];
|
|
5961
5967
|
}
|
|
5962
5968
|
});
|
|
5963
5969
|
|
|
@@ -7006,52 +7012,6 @@ var init_account = __esm({
|
|
|
7006
7012
|
}
|
|
7007
7013
|
});
|
|
7008
7014
|
|
|
7009
|
-
// src/usage/plan.ts
|
|
7010
|
-
import { z as z13 } from "zod";
|
|
7011
|
-
function planOf(account) {
|
|
7012
|
-
const userTier = account?.userRateLimitTier;
|
|
7013
|
-
if (userTier !== void 0 && ZERO_TIER.test(userTier)) {
|
|
7014
|
-
return { kind: "pay-per-use", tier: userTier };
|
|
7015
|
-
}
|
|
7016
|
-
const tier = account?.organizationRateLimitTier ?? userTier;
|
|
7017
|
-
const tierField = tier === void 0 ? {} : { tier };
|
|
7018
|
-
if (tier === void 0) {
|
|
7019
|
-
return { kind: "subscription", capacity: 1, recognised: false };
|
|
7020
|
-
}
|
|
7021
|
-
if (ZERO_TIER.test(tier)) {
|
|
7022
|
-
return { kind: "pay-per-use", ...tierField };
|
|
7023
|
-
}
|
|
7024
|
-
const multiplier = TIER_MULTIPLIER.exec(tier)?.[1];
|
|
7025
|
-
if (multiplier !== void 0) {
|
|
7026
|
-
return { kind: "subscription", capacity: Number(multiplier), recognised: true, ...tierField };
|
|
7027
|
-
}
|
|
7028
|
-
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
7029
|
-
}
|
|
7030
|
-
var PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
7031
|
-
var init_plan2 = __esm({
|
|
7032
|
-
"src/usage/plan.ts"() {
|
|
7033
|
-
"use strict";
|
|
7034
|
-
PlanClassSchema = z13.union([
|
|
7035
|
-
z13.strictObject({
|
|
7036
|
-
kind: z13.literal("subscription"),
|
|
7037
|
-
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
7038
|
-
capacity: z13.number().positive(),
|
|
7039
|
-
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
7040
|
-
recognised: z13.boolean(),
|
|
7041
|
-
/** The tier string the classification rests on, when the account had one. */
|
|
7042
|
-
tier: z13.string().optional()
|
|
7043
|
-
}),
|
|
7044
|
-
z13.strictObject({
|
|
7045
|
-
kind: z13.literal("pay-per-use"),
|
|
7046
|
-
tier: z13.string().optional()
|
|
7047
|
-
})
|
|
7048
|
-
]);
|
|
7049
|
-
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
7050
|
-
ZERO_TIER = /(?:^|_)zero$/;
|
|
7051
|
-
BASE_TIER = /(?:^|_)(?:pro|free)$/;
|
|
7052
|
-
}
|
|
7053
|
-
});
|
|
7054
|
-
|
|
7055
7015
|
// src/usage/rateLimit.ts
|
|
7056
7016
|
function epochSecondsToIso(value) {
|
|
7057
7017
|
if (value === void 0) {
|
|
@@ -7143,39 +7103,6 @@ var init_rateLimit = __esm({
|
|
|
7143
7103
|
}
|
|
7144
7104
|
});
|
|
7145
7105
|
|
|
7146
|
-
// src/usage/scan.ts
|
|
7147
|
-
import { z as z14 } from "zod";
|
|
7148
|
-
var AnthropicUsageSchema, ErrorObjectSchema;
|
|
7149
|
-
var init_scan = __esm({
|
|
7150
|
-
"src/usage/scan.ts"() {
|
|
7151
|
-
"use strict";
|
|
7152
|
-
AnthropicUsageSchema = z14.looseObject({
|
|
7153
|
-
input_tokens: z14.number().int().nonnegative().nullish(),
|
|
7154
|
-
output_tokens: z14.number().int().nonnegative().nullish(),
|
|
7155
|
-
cache_creation_input_tokens: z14.number().int().nonnegative().nullish(),
|
|
7156
|
-
cache_read_input_tokens: z14.number().int().nonnegative().nullish()
|
|
7157
|
-
});
|
|
7158
|
-
ErrorObjectSchema = z14.looseObject({
|
|
7159
|
-
type: z14.string().optional(),
|
|
7160
|
-
code: z14.union([z14.string(), z14.number()]).optional(),
|
|
7161
|
-
message: z14.string().optional()
|
|
7162
|
-
});
|
|
7163
|
-
}
|
|
7164
|
-
});
|
|
7165
|
-
|
|
7166
|
-
// src/usage/middleware.ts
|
|
7167
|
-
var ANTHROPIC_PROVIDER;
|
|
7168
|
-
var init_middleware = __esm({
|
|
7169
|
-
"src/usage/middleware.ts"() {
|
|
7170
|
-
"use strict";
|
|
7171
|
-
init_route();
|
|
7172
|
-
init_rateLimit();
|
|
7173
|
-
init_scan();
|
|
7174
|
-
init_schema2();
|
|
7175
|
-
ANTHROPIC_PROVIDER = "anthropic";
|
|
7176
|
-
}
|
|
7177
|
-
});
|
|
7178
|
-
|
|
7179
7106
|
// src/usage/preflight.ts
|
|
7180
7107
|
function formatAge(ms) {
|
|
7181
7108
|
const minutes = Math.floor(ms / (MS_PER_SECOND3 * SECONDS_PER_MINUTE));
|
|
@@ -7232,6 +7159,111 @@ var init_preflight = __esm({
|
|
|
7232
7159
|
}
|
|
7233
7160
|
});
|
|
7234
7161
|
|
|
7162
|
+
// src/usage/candidateText.ts
|
|
7163
|
+
function candidateHeading(candidate) {
|
|
7164
|
+
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
7165
|
+
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
7166
|
+
return `[${candidate.class}${score}]${dry}`;
|
|
7167
|
+
}
|
|
7168
|
+
function percent(fraction) {
|
|
7169
|
+
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
7170
|
+
}
|
|
7171
|
+
function describeWindow(label, window, effective, nowMs) {
|
|
7172
|
+
if (effective.reset) {
|
|
7173
|
+
return `${label} window has reset`;
|
|
7174
|
+
}
|
|
7175
|
+
const used = effective.utilization === void 0 ? "usage unknown" : `${percent(effective.utilization)} used`;
|
|
7176
|
+
const resets = effective.resetsAtMs === void 0 ? "" : `, resets in ${formatAge(effective.resetsAtMs - nowMs)}`;
|
|
7177
|
+
return `${label} ${used}${resets}${window.status === "allowed_warning" ? " (nearly used)" : ""}`;
|
|
7178
|
+
}
|
|
7179
|
+
var PERCENT;
|
|
7180
|
+
var init_candidateText = __esm({
|
|
7181
|
+
"src/usage/candidateText.ts"() {
|
|
7182
|
+
"use strict";
|
|
7183
|
+
init_preflight();
|
|
7184
|
+
PERCENT = 100;
|
|
7185
|
+
}
|
|
7186
|
+
});
|
|
7187
|
+
|
|
7188
|
+
// src/usage/plan.ts
|
|
7189
|
+
import { z as z13 } from "zod";
|
|
7190
|
+
function planOf(account) {
|
|
7191
|
+
const userTier = account?.userRateLimitTier;
|
|
7192
|
+
if (userTier !== void 0 && ZERO_TIER.test(userTier)) {
|
|
7193
|
+
return { kind: "pay-per-use", tier: userTier };
|
|
7194
|
+
}
|
|
7195
|
+
const tier = account?.organizationRateLimitTier ?? userTier;
|
|
7196
|
+
const tierField = tier === void 0 ? {} : { tier };
|
|
7197
|
+
if (tier === void 0) {
|
|
7198
|
+
return { kind: "subscription", capacity: 1, recognised: false };
|
|
7199
|
+
}
|
|
7200
|
+
if (ZERO_TIER.test(tier)) {
|
|
7201
|
+
return { kind: "pay-per-use", ...tierField };
|
|
7202
|
+
}
|
|
7203
|
+
const multiplier = TIER_MULTIPLIER.exec(tier)?.[1];
|
|
7204
|
+
if (multiplier !== void 0) {
|
|
7205
|
+
return { kind: "subscription", capacity: Number(multiplier), recognised: true, ...tierField };
|
|
7206
|
+
}
|
|
7207
|
+
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
7208
|
+
}
|
|
7209
|
+
var PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
7210
|
+
var init_plan2 = __esm({
|
|
7211
|
+
"src/usage/plan.ts"() {
|
|
7212
|
+
"use strict";
|
|
7213
|
+
PlanClassSchema = z13.union([
|
|
7214
|
+
z13.strictObject({
|
|
7215
|
+
kind: z13.literal("subscription"),
|
|
7216
|
+
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
7217
|
+
capacity: z13.number().positive(),
|
|
7218
|
+
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
7219
|
+
recognised: z13.boolean(),
|
|
7220
|
+
/** The tier string the classification rests on, when the account had one. */
|
|
7221
|
+
tier: z13.string().optional()
|
|
7222
|
+
}),
|
|
7223
|
+
z13.strictObject({
|
|
7224
|
+
kind: z13.literal("pay-per-use"),
|
|
7225
|
+
tier: z13.string().optional()
|
|
7226
|
+
})
|
|
7227
|
+
]);
|
|
7228
|
+
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
7229
|
+
ZERO_TIER = /(?:^|_)zero$/;
|
|
7230
|
+
BASE_TIER = /(?:^|_)(?:pro|free)$/;
|
|
7231
|
+
}
|
|
7232
|
+
});
|
|
7233
|
+
|
|
7234
|
+
// src/usage/scan.ts
|
|
7235
|
+
import { z as z14 } from "zod";
|
|
7236
|
+
var AnthropicUsageSchema, ErrorObjectSchema;
|
|
7237
|
+
var init_scan = __esm({
|
|
7238
|
+
"src/usage/scan.ts"() {
|
|
7239
|
+
"use strict";
|
|
7240
|
+
AnthropicUsageSchema = z14.looseObject({
|
|
7241
|
+
input_tokens: z14.number().int().nonnegative().nullish(),
|
|
7242
|
+
output_tokens: z14.number().int().nonnegative().nullish(),
|
|
7243
|
+
cache_creation_input_tokens: z14.number().int().nonnegative().nullish(),
|
|
7244
|
+
cache_read_input_tokens: z14.number().int().nonnegative().nullish()
|
|
7245
|
+
});
|
|
7246
|
+
ErrorObjectSchema = z14.looseObject({
|
|
7247
|
+
type: z14.string().optional(),
|
|
7248
|
+
code: z14.union([z14.string(), z14.number()]).optional(),
|
|
7249
|
+
message: z14.string().optional()
|
|
7250
|
+
});
|
|
7251
|
+
}
|
|
7252
|
+
});
|
|
7253
|
+
|
|
7254
|
+
// src/usage/middleware.ts
|
|
7255
|
+
var ANTHROPIC_PROVIDER;
|
|
7256
|
+
var init_middleware = __esm({
|
|
7257
|
+
"src/usage/middleware.ts"() {
|
|
7258
|
+
"use strict";
|
|
7259
|
+
init_route();
|
|
7260
|
+
init_rateLimit();
|
|
7261
|
+
init_scan();
|
|
7262
|
+
init_schema2();
|
|
7263
|
+
ANTHROPIC_PROVIDER = "anthropic";
|
|
7264
|
+
}
|
|
7265
|
+
});
|
|
7266
|
+
|
|
7235
7267
|
// src/usage/quotaFacts.ts
|
|
7236
7268
|
function windowFacts(window, nowMs) {
|
|
7237
7269
|
if (window?.utilization === void 0 || window.resetsAt === void 0) {
|
|
@@ -7331,17 +7363,6 @@ function windowRatio(records) {
|
|
|
7331
7363
|
}
|
|
7332
7364
|
return (last.seven - first.seven) / (last.five - first.five);
|
|
7333
7365
|
}
|
|
7334
|
-
function percent(fraction) {
|
|
7335
|
-
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
7336
|
-
}
|
|
7337
|
-
function describeWindow(label, window, effective, nowMs) {
|
|
7338
|
-
if (effective.reset) {
|
|
7339
|
-
return `${label} window has reset`;
|
|
7340
|
-
}
|
|
7341
|
-
const used = effective.utilization === void 0 ? "usage unknown" : `${percent(effective.utilization)} used`;
|
|
7342
|
-
const resets = effective.resetsAtMs === void 0 ? "" : `, resets in ${formatAge(effective.resetsAtMs - nowMs)}`;
|
|
7343
|
-
return `${label} ${used}${resets}${window.status === "allowed_warning" ? " (nearly used)" : ""}`;
|
|
7344
|
-
}
|
|
7345
7366
|
function capacityOf(plan) {
|
|
7346
7367
|
return plan.kind === "subscription" ? plan.capacity : 1;
|
|
7347
7368
|
}
|
|
@@ -7534,11 +7555,12 @@ function rankPool(input) {
|
|
|
7534
7555
|
...holdForReturn === void 0 ? {} : { holdForReturn }
|
|
7535
7556
|
};
|
|
7536
7557
|
}
|
|
7537
|
-
var MS_PER_SECOND4, MS_PER_HOUR2, HOURS_PER_DAY2, FIVE_HOURS, PROMPT_CACHE_TTL_HOURS,
|
|
7558
|
+
var MS_PER_SECOND4, MS_PER_HOUR2, HOURS_PER_DAY2, FIVE_HOURS, PROMPT_CACHE_TTL_HOURS, SEVEN_DAYS, FIVE_HOUR_WINDOW_MS, SEVEN_DAY_WINDOW_MS, PROMPT_CACHE_TTL_MS, CLASS_ORDER;
|
|
7538
7559
|
var init_pick = __esm({
|
|
7539
7560
|
"src/usage/pick.ts"() {
|
|
7540
7561
|
"use strict";
|
|
7541
7562
|
init_conditions();
|
|
7563
|
+
init_candidateText();
|
|
7542
7564
|
init_plan2();
|
|
7543
7565
|
init_middleware();
|
|
7544
7566
|
init_preflight();
|
|
@@ -7549,7 +7571,6 @@ var init_pick = __esm({
|
|
|
7549
7571
|
HOURS_PER_DAY2 = 24;
|
|
7550
7572
|
FIVE_HOURS = 5;
|
|
7551
7573
|
PROMPT_CACHE_TTL_HOURS = 1;
|
|
7552
|
-
PERCENT = 100;
|
|
7553
7574
|
SEVEN_DAYS = 7;
|
|
7554
7575
|
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR2;
|
|
7555
7576
|
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY2 * MS_PER_HOUR2;
|
|
@@ -9023,6 +9044,12 @@ function providerJsonPath(paths, name) {
|
|
|
9023
9044
|
function providerExists(paths, name) {
|
|
9024
9045
|
return fs7.existsSync(providerJsonPath(paths, name));
|
|
9025
9046
|
}
|
|
9047
|
+
function requireProviderExists(paths, name) {
|
|
9048
|
+
const canonical = canonicalProviderName(name, (candidate) => providerExists(paths, candidate), () => readProviderAliases(paths));
|
|
9049
|
+
if (!providerExists(paths, canonical)) {
|
|
9050
|
+
throw new ProviderNotFoundError(name);
|
|
9051
|
+
}
|
|
9052
|
+
}
|
|
9026
9053
|
function isRecord7(value) {
|
|
9027
9054
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9028
9055
|
}
|
|
@@ -9257,18 +9284,18 @@ function removeProvider(paths, name) {
|
|
|
9257
9284
|
}
|
|
9258
9285
|
fs7.rmSync(providerJsonPath(paths, name));
|
|
9259
9286
|
}
|
|
9260
|
-
function cascadeProviderName(cascade) {
|
|
9287
|
+
function cascadeProviderName(cascade, identityProvider) {
|
|
9261
9288
|
let name;
|
|
9262
9289
|
for (const layer of assembleCascade(cascade).layers) {
|
|
9263
9290
|
if (layer.launch?.provider !== void 0) {
|
|
9264
9291
|
name = layer.launch.provider;
|
|
9265
9292
|
}
|
|
9266
9293
|
}
|
|
9267
|
-
return name;
|
|
9294
|
+
return name ?? identityProvider;
|
|
9268
9295
|
}
|
|
9269
9296
|
function selectProvider(params) {
|
|
9270
9297
|
const cliName = params.cliProvider !== void 0 && params.cliProvider !== "" ? params.cliProvider : void 0;
|
|
9271
|
-
const named = cliName ?? (params.cascade === void 0 ?
|
|
9298
|
+
const named = cliName ?? (params.cascade === void 0 ? params.identityProvider : cascadeProviderName(params.cascade, params.identityProvider));
|
|
9272
9299
|
if (named === void 0) {
|
|
9273
9300
|
return void 0;
|
|
9274
9301
|
}
|
|
@@ -9429,6 +9456,9 @@ function decideSignIn(facts) {
|
|
|
9429
9456
|
if (facts.hasCredentialBlock) {
|
|
9430
9457
|
return { state: "token", detail: "supplies its own credential through a credential block, so a stored login is not what a launch uses" };
|
|
9431
9458
|
}
|
|
9459
|
+
if (facts.provider !== void 0) {
|
|
9460
|
+
return { state: "token", detail: "runs provider sessions with the provider's credential, so a stored login is not what a launch uses" };
|
|
9461
|
+
}
|
|
9432
9462
|
if (facts.keychainItem === true) {
|
|
9433
9463
|
return { state: "signed-in", detail: "a login is stored in the macOS Keychain" };
|
|
9434
9464
|
}
|
|
@@ -9441,9 +9471,10 @@ function credentialsFilePath(farmRoot) {
|
|
|
9441
9471
|
return path25.join(farmRoot, CREDENTIALS_FILE);
|
|
9442
9472
|
}
|
|
9443
9473
|
function identitySignIn(fs14, probe, identity) {
|
|
9444
|
-
const probing = !identity.hasCredentialBlock;
|
|
9474
|
+
const probing = !identity.hasCredentialBlock && identity.provider === void 0;
|
|
9445
9475
|
return decideSignIn({
|
|
9446
9476
|
hasCredentialBlock: identity.hasCredentialBlock,
|
|
9477
|
+
provider: identity.provider,
|
|
9447
9478
|
keychainItem: probing && probe.platform === "darwin" && probe.run !== void 0 ? keychainHasItem(probe.run, identity.farmRoot) : void 0,
|
|
9448
9479
|
credentialsFile: probing && fs14.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
|
|
9449
9480
|
platform: probe.platform
|
|
@@ -9598,6 +9629,62 @@ var init_guard = __esm({
|
|
|
9598
9629
|
}
|
|
9599
9630
|
});
|
|
9600
9631
|
|
|
9632
|
+
// src/usage/resets.ts
|
|
9633
|
+
function formatPeriod(window) {
|
|
9634
|
+
if (window.periodMs === void 0) {
|
|
9635
|
+
return window.period ?? "unknown period";
|
|
9636
|
+
}
|
|
9637
|
+
const hours = window.periodMs / MS_PER_HOUR3;
|
|
9638
|
+
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
9639
|
+
}
|
|
9640
|
+
function groupOf(row) {
|
|
9641
|
+
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
9642
|
+
}
|
|
9643
|
+
function compareRows(left, right) {
|
|
9644
|
+
return groupOf(left) - groupOf(right) || (left.resetsAt ?? "").localeCompare(right.resetsAt ?? "") || left.identity.localeCompare(right.identity) || left.provider.localeCompare(right.provider) || left.window.localeCompare(right.window);
|
|
9645
|
+
}
|
|
9646
|
+
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
9647
|
+
const effective = effectiveWindow(recorded, nowMs);
|
|
9648
|
+
return {
|
|
9649
|
+
identity: snapshot.identity,
|
|
9650
|
+
provider,
|
|
9651
|
+
window,
|
|
9652
|
+
observedAt: observedAt2,
|
|
9653
|
+
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
9654
|
+
reset: effective.reset,
|
|
9655
|
+
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
9656
|
+
...effective.status === void 0 ? {} : { status: effective.status }
|
|
9657
|
+
};
|
|
9658
|
+
}
|
|
9659
|
+
function collectResets(snapshots, nowMs) {
|
|
9660
|
+
const rows = snapshots.flatMap(
|
|
9661
|
+
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
9662
|
+
const unified = state.rateLimit?.unified;
|
|
9663
|
+
const observedAt2 = state.rateLimit?.observedAt;
|
|
9664
|
+
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
9665
|
+
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
9666
|
+
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
9667
|
+
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
9668
|
+
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
9669
|
+
];
|
|
9670
|
+
const quota = state.quota;
|
|
9671
|
+
const quotaRows2 = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
9672
|
+
return [...headerRows, ...quotaRows2];
|
|
9673
|
+
})
|
|
9674
|
+
);
|
|
9675
|
+
return { resets: rows.sort(compareRows) };
|
|
9676
|
+
}
|
|
9677
|
+
var MS_PER_HOUR3, HOURS_PER_DAY3;
|
|
9678
|
+
var init_resets = __esm({
|
|
9679
|
+
"src/usage/resets.ts"() {
|
|
9680
|
+
"use strict";
|
|
9681
|
+
init_preflight();
|
|
9682
|
+
init_rateLimit();
|
|
9683
|
+
MS_PER_HOUR3 = 36e5;
|
|
9684
|
+
HOURS_PER_DAY3 = 24;
|
|
9685
|
+
}
|
|
9686
|
+
});
|
|
9687
|
+
|
|
9601
9688
|
// src/cli/commandDeps.ts
|
|
9602
9689
|
var init_commandDeps = __esm({
|
|
9603
9690
|
"src/cli/commandDeps.ts"() {
|
|
@@ -11304,24 +11391,9 @@ var init_hold = __esm({
|
|
|
11304
11391
|
}
|
|
11305
11392
|
});
|
|
11306
11393
|
|
|
11307
|
-
// src/usage/candidateText.ts
|
|
11308
|
-
function candidateHeading(candidate) {
|
|
11309
|
-
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
11310
|
-
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
11311
|
-
return `[${candidate.class}${score}]${dry}`;
|
|
11312
|
-
}
|
|
11313
|
-
var init_candidateText = __esm({
|
|
11314
|
-
"src/usage/candidateText.ts"() {
|
|
11315
|
-
"use strict";
|
|
11316
|
-
}
|
|
11317
|
-
});
|
|
11318
|
-
|
|
11319
11394
|
// src/launcher/launchReport.ts
|
|
11320
11395
|
function poolDetail(pool) {
|
|
11321
11396
|
const [reason] = pool.reasons;
|
|
11322
|
-
if (pool.movedOff !== void 0) {
|
|
11323
|
-
return { detail: `moved off ${pool.movedOff.identity}: ${pool.movedOff.reason}`, ...reason === void 0 ? {} : { notes: [reason] } };
|
|
11324
|
-
}
|
|
11325
11397
|
return reason === void 0 ? {} : { detail: reason };
|
|
11326
11398
|
}
|
|
11327
11399
|
function rankingNotes(ranking, picked) {
|
|
@@ -11330,6 +11402,68 @@ function rankingNotes(ranking, picked) {
|
|
|
11330
11402
|
` ${candidate.reasons.join("; ")}`
|
|
11331
11403
|
]);
|
|
11332
11404
|
}
|
|
11405
|
+
function planText(account) {
|
|
11406
|
+
const plan = planOf(account);
|
|
11407
|
+
if (plan.kind === "pay-per-use") {
|
|
11408
|
+
return "pay-per-use";
|
|
11409
|
+
}
|
|
11410
|
+
return plan.recognised ? `${String(plan.capacity)}x` : void 0;
|
|
11411
|
+
}
|
|
11412
|
+
function loginAccountText(account) {
|
|
11413
|
+
const organisation = account.organizationName !== void 0 && account.organizationType !== void 0 && NAMED_ORGANISATION_TYPES.has(account.organizationType) ? account.organizationRole === void 0 ? account.organizationName : `${account.organizationName} (${account.organizationRole})` : void 0;
|
|
11414
|
+
const parts = [account.emailAddress, organisation, planText(account)].filter((part) => part !== void 0);
|
|
11415
|
+
return parts.length === 0 ? void 0 : parts.join(", ");
|
|
11416
|
+
}
|
|
11417
|
+
function accountRows(billing) {
|
|
11418
|
+
if (billing === void 0) {
|
|
11419
|
+
return [];
|
|
11420
|
+
}
|
|
11421
|
+
if (billing.provider !== void 0) {
|
|
11422
|
+
const quota = billing.snapshot?.providers[billing.provider]?.quota;
|
|
11423
|
+
const parts = [quota?.account?.email, quota?.level].filter((part) => part !== void 0);
|
|
11424
|
+
return parts.length === 0 ? [] : [{ label: "account", value: parts.join(", "), detail: `provider ${billing.provider}` }];
|
|
11425
|
+
}
|
|
11426
|
+
const account = billing.login ?? billing.snapshot?.account;
|
|
11427
|
+
const text = account === void 0 ? void 0 : loginAccountText(account);
|
|
11428
|
+
return text === void 0 ? [] : [{ label: "account", value: text }];
|
|
11429
|
+
}
|
|
11430
|
+
function isInformative(window, nowMs) {
|
|
11431
|
+
const effective = effectiveWindow(window, nowMs);
|
|
11432
|
+
return effective.reset || effective.utilization !== void 0 || effective.resetsAtMs !== void 0;
|
|
11433
|
+
}
|
|
11434
|
+
function quotaRows(billing) {
|
|
11435
|
+
if (billing === void 0) {
|
|
11436
|
+
return [];
|
|
11437
|
+
}
|
|
11438
|
+
const { nowMs } = billing;
|
|
11439
|
+
const state = billing.snapshot?.providers[billing.provider ?? ANTHROPIC_PROVIDER];
|
|
11440
|
+
const recorded = billing.provider === void 0 ? {
|
|
11441
|
+
observedAt: state?.rateLimit?.observedAt,
|
|
11442
|
+
windows: [
|
|
11443
|
+
{ label: "5h", window: state?.rateLimit?.unified?.fiveHour },
|
|
11444
|
+
{ label: "7d", window: state?.rateLimit?.unified?.sevenDay }
|
|
11445
|
+
]
|
|
11446
|
+
} : { observedAt: state?.quota?.observedAt, windows: (state?.quota?.windows ?? []).map((window) => ({ label: `${formatPeriod(window)} ${window.measures}`, window })) };
|
|
11447
|
+
const described = recorded.windows.flatMap(({ label, window }) => window !== void 0 && isInformative(window, nowMs) ? [describeWindow(label, window, effectiveWindow(window, nowMs), nowMs)] : []);
|
|
11448
|
+
return recorded.observedAt === void 0 || described.length === 0 ? [] : [{ label: "quota", value: described.join("; "), detail: `recorded ${formatAge(nowMs - Date.parse(recorded.observedAt))} ago` }];
|
|
11449
|
+
}
|
|
11450
|
+
function movedRows(facts) {
|
|
11451
|
+
const { identity } = facts;
|
|
11452
|
+
if (identity === void 0) {
|
|
11453
|
+
return [];
|
|
11454
|
+
}
|
|
11455
|
+
const moved = (from, detail) => [{ label: "moved", value: `${from} -> ${identity}`, detail, notice: true }];
|
|
11456
|
+
if (facts.limitRelaunchFrom !== void 0) {
|
|
11457
|
+
return moved(facts.limitRelaunchFrom, `${facts.limitRelaunchFrom} ran out of quota; the session resumed here`);
|
|
11458
|
+
}
|
|
11459
|
+
if (facts.pool?.movedOff !== void 0) {
|
|
11460
|
+
return moved(facts.pool.movedOff.identity, `the resumed conversation could not stay: ${facts.pool.movedOff.reason}`);
|
|
11461
|
+
}
|
|
11462
|
+
if (facts.lastRanAs !== void 0 && facts.lastRanAs.identity !== identity) {
|
|
11463
|
+
return moved(facts.lastRanAs.identity, `this directory last ran as ${facts.lastRanAs.identity} ${formatAge(facts.lastRanAs.agoMs)} ago`);
|
|
11464
|
+
}
|
|
11465
|
+
return [];
|
|
11466
|
+
}
|
|
11333
11467
|
function decisionRows(facts) {
|
|
11334
11468
|
return [
|
|
11335
11469
|
{ label: "identity", value: facts.identity ?? "(none)", detail: facts.identitySource },
|
|
@@ -11341,6 +11475,9 @@ function decisionRows(facts) {
|
|
|
11341
11475
|
...facts.ranking === void 0 ? {} : { notes: rankingNotes(facts.ranking, facts.identity) }
|
|
11342
11476
|
}
|
|
11343
11477
|
],
|
|
11478
|
+
...movedRows(facts),
|
|
11479
|
+
...accountRows(facts.billing),
|
|
11480
|
+
...quotaRows(facts.billing),
|
|
11344
11481
|
...facts.profile === void 0 ? [] : [{ label: "profile", value: facts.profile.name, detail: facts.profile.source }],
|
|
11345
11482
|
...facts.provider === void 0 ? [] : [{ label: "provider", value: facts.provider.name, detail: `credential ${facts.provider.credential}` }],
|
|
11346
11483
|
...facts.identityCredential === void 0 ? [] : [{ label: "credential", value: facts.identityCredential, detail: "the identity's own" }]
|
|
@@ -11370,10 +11507,16 @@ function farmRow(links, builtDirectories, adopted) {
|
|
|
11370
11507
|
function noteRow(text) {
|
|
11371
11508
|
return { label: "note", value: text };
|
|
11372
11509
|
}
|
|
11510
|
+
var NAMED_ORGANISATION_TYPES;
|
|
11373
11511
|
var init_launchReport = __esm({
|
|
11374
11512
|
"src/launcher/launchReport.ts"() {
|
|
11375
11513
|
"use strict";
|
|
11376
11514
|
init_candidateText();
|
|
11515
|
+
init_middleware();
|
|
11516
|
+
init_plan2();
|
|
11517
|
+
init_preflight();
|
|
11518
|
+
init_resets();
|
|
11519
|
+
NAMED_ORGANISATION_TYPES = /* @__PURE__ */ new Set(["claude_team", "claude_enterprise"]);
|
|
11377
11520
|
}
|
|
11378
11521
|
});
|
|
11379
11522
|
|
|
@@ -11448,7 +11591,8 @@ function resolvePoolLaunch(params) {
|
|
|
11448
11591
|
explanation: `pool ${poolName}: ${move}${pick.reasons.slice(0, REASONS_LOGGED).join("; ")}`,
|
|
11449
11592
|
reasons: pick.reasons,
|
|
11450
11593
|
candidates: graph.ranking.candidates,
|
|
11451
|
-
...movedOff === void 0 ? {} : { movedOff }
|
|
11594
|
+
...movedOff === void 0 ? {} : { movedOff },
|
|
11595
|
+
...stickyRead.sticky === void 0 ? {} : { lastRanAs: stickyRead.sticky }
|
|
11452
11596
|
};
|
|
11453
11597
|
}
|
|
11454
11598
|
if (earliestReturn === void 0) {
|
|
@@ -11626,7 +11770,8 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
11626
11770
|
return {
|
|
11627
11771
|
identityDecision: { ...decided, name: resolution.identity },
|
|
11628
11772
|
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
11629
|
-
poolRanking: resolution.candidates
|
|
11773
|
+
poolRanking: resolution.candidates,
|
|
11774
|
+
...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
|
|
11630
11775
|
};
|
|
11631
11776
|
}
|
|
11632
11777
|
function decideLaunch(params, readOnly) {
|
|
@@ -11653,7 +11798,7 @@ function decideLaunch(params, readOnly) {
|
|
|
11653
11798
|
return trimmed === "" ? void 0 : trimmed;
|
|
11654
11799
|
}
|
|
11655
11800
|
});
|
|
11656
|
-
const { identityDecision, poolPick, poolRanking } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
11801
|
+
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
11657
11802
|
const farmIdentity = configDirEscapeHatchApplies ? void 0 : identityDecision.name;
|
|
11658
11803
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
11659
11804
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
@@ -11706,7 +11851,8 @@ function decideLaunch(params, readOnly) {
|
|
|
11706
11851
|
paths,
|
|
11707
11852
|
port: fs14,
|
|
11708
11853
|
...parsedArgv.provider === void 0 || parsedArgv.provider === false ? {} : { cliProvider: parsedArgv.provider },
|
|
11709
|
-
...farmContext === void 0 ? {} : { cascade: farmContext.cascade }
|
|
11854
|
+
...farmContext === void 0 ? {} : { cascade: farmContext.cascade },
|
|
11855
|
+
...loadedIdentity?.config.provider === void 0 ? {} : { identityProvider: loadedIdentity.config.provider }
|
|
11710
11856
|
};
|
|
11711
11857
|
let selectedProvider;
|
|
11712
11858
|
let resolvedProvider;
|
|
@@ -11729,9 +11875,11 @@ function decideLaunch(params, readOnly) {
|
|
|
11729
11875
|
log.warn(warning);
|
|
11730
11876
|
}
|
|
11731
11877
|
}
|
|
11878
|
+
let billing;
|
|
11732
11879
|
if (farm !== void 0 && farmIdentity !== void 0) {
|
|
11880
|
+
let snapshot;
|
|
11733
11881
|
try {
|
|
11734
|
-
|
|
11882
|
+
snapshot = readUsageSnapshot(farm.fs, paths.usageSnapshotsDir, farmIdentity);
|
|
11735
11883
|
for (const warning of quotaWarnings(snapshot, selectedProvider?.name ?? ANTHROPIC_PROVIDER, farm.now())) {
|
|
11736
11884
|
log.warn(warning);
|
|
11737
11885
|
}
|
|
@@ -11741,6 +11889,16 @@ function decideLaunch(params, readOnly) {
|
|
|
11741
11889
|
}
|
|
11742
11890
|
log.warn(`agent-shim: ${error.message}`);
|
|
11743
11891
|
}
|
|
11892
|
+
let login;
|
|
11893
|
+
try {
|
|
11894
|
+
login = readAccountMetadata(farm.fs, paths.identitiesDir, farmIdentity);
|
|
11895
|
+
} catch (error) {
|
|
11896
|
+
if (!(error instanceof AccountMetadataError)) {
|
|
11897
|
+
throw error;
|
|
11898
|
+
}
|
|
11899
|
+
log.warn(`agent-shim: ${error.message}`);
|
|
11900
|
+
}
|
|
11901
|
+
billing = { login, snapshot, provider: selectedProvider?.name, nowMs: farm.now() };
|
|
11744
11902
|
}
|
|
11745
11903
|
const identityCredentialBlock = selectedProvider === void 0 && farmIdentity !== void 0 ? loadedIdentity?.config.credential : void 0;
|
|
11746
11904
|
const identityResolution = !readOnly && identityCredentialBlock !== void 0 && farmIdentity !== void 0 ? resolveIdentityCredential(farmIdentity, identityCredentialBlock, env, params.credentials) : void 0;
|
|
@@ -11839,6 +11997,8 @@ function decideLaunch(params, readOnly) {
|
|
|
11839
11997
|
identityDecision,
|
|
11840
11998
|
poolPick,
|
|
11841
11999
|
poolRanking,
|
|
12000
|
+
lastRanAs,
|
|
12001
|
+
billing,
|
|
11842
12002
|
notes,
|
|
11843
12003
|
configDirEscapeHatch: configDirEscapeHatchApplies,
|
|
11844
12004
|
farmIdentity,
|
|
@@ -11861,7 +12021,7 @@ function prepareLaunch(params) {
|
|
|
11861
12021
|
const { paths, proc, log } = params;
|
|
11862
12022
|
const { env } = proc;
|
|
11863
12023
|
const decided = decideLaunch(params, false);
|
|
11864
|
-
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, notes, flags: resolvedFlags, args: finalArgv, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
12024
|
+
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, lastRanAs, billing, notes, flags: resolvedFlags, args: finalArgv, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
11865
12025
|
const rows = [
|
|
11866
12026
|
...decisionRows({
|
|
11867
12027
|
identity: identityDecision.name,
|
|
@@ -11870,7 +12030,10 @@ function prepareLaunch(params) {
|
|
|
11870
12030
|
ranking: resolvedFlags.explain ? poolRanking : void 0,
|
|
11871
12031
|
profile: configProfileDecision.name === void 0 ? void 0 : { name: configProfileDecision.name, source: configProfileDecision.source },
|
|
11872
12032
|
provider: resolvedProvider === void 0 ? void 0 : { name: resolvedProvider.name, credential: `${resolvedProvider.credential.target} from ${describeSource(resolvedProvider.credential.source)}` },
|
|
11873
|
-
identityCredential: identityCredential === void 0 ? void 0 : `${identityCredential.target} from ${describeSource(identityCredential.source)}
|
|
12033
|
+
identityCredential: identityCredential === void 0 ? void 0 : `${identityCredential.target} from ${describeSource(identityCredential.source)}`,
|
|
12034
|
+
billing,
|
|
12035
|
+
lastRanAs,
|
|
12036
|
+
limitRelaunchFrom: params.supervised?.from
|
|
11874
12037
|
})
|
|
11875
12038
|
];
|
|
11876
12039
|
let warnings = [];
|
|
@@ -12055,6 +12218,7 @@ var init_launcher = __esm({
|
|
|
12055
12218
|
init_schema();
|
|
12056
12219
|
init_credential();
|
|
12057
12220
|
init_middleware();
|
|
12221
|
+
init_account();
|
|
12058
12222
|
init_preflight();
|
|
12059
12223
|
init_read();
|
|
12060
12224
|
init_claudeVersion();
|
|
@@ -12325,7 +12489,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
12325
12489
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
12326
12490
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
12327
12491
|
hold: realHoldPort,
|
|
12328
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path41.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
12492
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path41.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
12329
12493
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
12330
12494
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
12331
12495
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -16070,7 +16234,7 @@ function collectCheckReport(params) {
|
|
|
16070
16234
|
read,
|
|
16071
16235
|
...configProfileDecision.name === void 0 ? {} : { baseConfigProfile: configProfileDecision.name }
|
|
16072
16236
|
}).input;
|
|
16073
|
-
const providerName = cascadeProviderName(cascade);
|
|
16237
|
+
const providerName = cascadeProviderName(cascade, identityConfig?.provider);
|
|
16074
16238
|
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
16075
16239
|
const farmRoot = identityDecision.name === void 0 ? void 0 : path26.join(paths.identitiesDir, identityDecision.name);
|
|
16076
16240
|
const settingsFiles = {
|
|
@@ -16295,56 +16459,7 @@ var CheckReportJsonSchema = z21.strictObject({
|
|
|
16295
16459
|
// src/frontdoor/controlApi.ts
|
|
16296
16460
|
init_middleware();
|
|
16297
16461
|
init_preflight();
|
|
16298
|
-
|
|
16299
|
-
// src/usage/resets.ts
|
|
16300
|
-
init_preflight();
|
|
16301
|
-
init_rateLimit();
|
|
16302
|
-
var MS_PER_HOUR3 = 36e5;
|
|
16303
|
-
var HOURS_PER_DAY3 = 24;
|
|
16304
|
-
function formatPeriod(window) {
|
|
16305
|
-
if (window.periodMs === void 0) {
|
|
16306
|
-
return window.period ?? "unknown period";
|
|
16307
|
-
}
|
|
16308
|
-
const hours = window.periodMs / MS_PER_HOUR3;
|
|
16309
|
-
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
16310
|
-
}
|
|
16311
|
-
function groupOf(row) {
|
|
16312
|
-
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
16313
|
-
}
|
|
16314
|
-
function compareRows(left, right) {
|
|
16315
|
-
return groupOf(left) - groupOf(right) || (left.resetsAt ?? "").localeCompare(right.resetsAt ?? "") || left.identity.localeCompare(right.identity) || left.provider.localeCompare(right.provider) || left.window.localeCompare(right.window);
|
|
16316
|
-
}
|
|
16317
|
-
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
16318
|
-
const effective = effectiveWindow(recorded, nowMs);
|
|
16319
|
-
return {
|
|
16320
|
-
identity: snapshot.identity,
|
|
16321
|
-
provider,
|
|
16322
|
-
window,
|
|
16323
|
-
observedAt: observedAt2,
|
|
16324
|
-
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
16325
|
-
reset: effective.reset,
|
|
16326
|
-
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
16327
|
-
...effective.status === void 0 ? {} : { status: effective.status }
|
|
16328
|
-
};
|
|
16329
|
-
}
|
|
16330
|
-
function collectResets(snapshots, nowMs) {
|
|
16331
|
-
const rows = snapshots.flatMap(
|
|
16332
|
-
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
16333
|
-
const unified = state.rateLimit?.unified;
|
|
16334
|
-
const observedAt2 = state.rateLimit?.observedAt;
|
|
16335
|
-
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
16336
|
-
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
16337
|
-
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
16338
|
-
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
16339
|
-
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
16340
|
-
];
|
|
16341
|
-
const quota = state.quota;
|
|
16342
|
-
const quotaRows = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
16343
|
-
return [...headerRows, ...quotaRows];
|
|
16344
|
-
})
|
|
16345
|
-
);
|
|
16346
|
-
return { resets: rows.sort(compareRows) };
|
|
16347
|
-
}
|
|
16462
|
+
init_resets();
|
|
16348
16463
|
|
|
16349
16464
|
// src/usage/resetsSchema.ts
|
|
16350
16465
|
import { z as z22 } from "zod";
|
|
@@ -16499,6 +16614,12 @@ function setDefaultConfigProfile(paths, identityName, profileName) {
|
|
|
16499
16614
|
defaultConfigProfile: profileName
|
|
16500
16615
|
});
|
|
16501
16616
|
}
|
|
16617
|
+
function setIdentityProvider(paths, identityName, providerName) {
|
|
16618
|
+
if (!identityExists(paths, identityName)) {
|
|
16619
|
+
throw new IdentityNotFoundError(identityName);
|
|
16620
|
+
}
|
|
16621
|
+
return applyPatch(identityJsonPath(paths, identityName), IdentitySchema, { provider: providerName });
|
|
16622
|
+
}
|
|
16502
16623
|
function setAllowAmbientCredential(paths, identityName, allow) {
|
|
16503
16624
|
if (!identityExists(paths, identityName)) {
|
|
16504
16625
|
throw new IdentityNotFoundError(identityName);
|
|
@@ -17167,6 +17288,7 @@ function runDoctor(params) {
|
|
|
17167
17288
|
}
|
|
17168
17289
|
}
|
|
17169
17290
|
const validProfileNames = new Set(profileSources.keys());
|
|
17291
|
+
const validProviderNames = /* @__PURE__ */ new Set([...params.providers.map((entry) => entry.name), ...Object.keys(params.providerAliases ?? {})]);
|
|
17170
17292
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
17171
17293
|
for (const entry of params.identities) {
|
|
17172
17294
|
const validated3 = validate(IdentitySchema, entry, "identity", entry.name);
|
|
@@ -17176,35 +17298,47 @@ function runDoctor(params) {
|
|
|
17176
17298
|
}
|
|
17177
17299
|
validIdentityNames.add(entry.name);
|
|
17178
17300
|
const defaultProfile = validated3.data.defaultConfigProfile;
|
|
17301
|
+
let consistent = true;
|
|
17179
17302
|
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
17303
|
+
consistent = false;
|
|
17180
17304
|
push(
|
|
17181
17305
|
"identity",
|
|
17182
17306
|
"fail",
|
|
17183
17307
|
`Identity "${entry.name}" names configuration profile "${defaultProfile}" as its default, but no such profile exists.`,
|
|
17184
17308
|
entry.name
|
|
17185
17309
|
);
|
|
17186
|
-
} else {
|
|
17187
|
-
const credential = validated3.data.credential;
|
|
17188
|
-
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
17189
|
-
push(
|
|
17190
|
-
"identity",
|
|
17191
|
-
cache.unreadable ? "fail" : "pass",
|
|
17192
|
-
`${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
|
|
17193
|
-
entry.name
|
|
17194
|
-
);
|
|
17195
|
-
const signIn = decideSignIn({
|
|
17196
|
-
hasCredentialBlock: credential !== void 0,
|
|
17197
|
-
keychainItem: params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0,
|
|
17198
|
-
credentialsFile: entry.credentialsFilePresent,
|
|
17199
|
-
platform: params.platform
|
|
17200
|
-
});
|
|
17201
|
-
push(
|
|
17202
|
-
"sign-in",
|
|
17203
|
-
signIn.state === "signed-out" ? "warn" : "pass",
|
|
17204
|
-
signIn.state === "signed-out" ? `${entry.name} is signed out (${signIn.detail}). Run \`agent-shim run @${entry.name}\` and sign in.` : `${entry.name} ${signIn.state === "token" ? "uses a credential block" : "is signed in"} (${signIn.detail}).`,
|
|
17205
|
-
entry.name
|
|
17206
|
-
);
|
|
17207
17310
|
}
|
|
17311
|
+
const identityProvider = validated3.data.provider;
|
|
17312
|
+
if (identityProvider !== void 0 && !validProviderNames.has(identityProvider)) {
|
|
17313
|
+
consistent = false;
|
|
17314
|
+
push("identity", "fail", `Identity "${entry.name}" names provider "${identityProvider}" as its provider, but no such provider exists.`, entry.name);
|
|
17315
|
+
}
|
|
17316
|
+
if (!consistent) {
|
|
17317
|
+
continue;
|
|
17318
|
+
}
|
|
17319
|
+
const credential = validated3.data.credential;
|
|
17320
|
+
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
17321
|
+
const authenticatesWith = credential !== void 0 ? `credential ${describeCredential(credential)}` : identityProvider !== void 0 ? `the credential of provider "${identityProvider}"` : "its stored login";
|
|
17322
|
+
push(
|
|
17323
|
+
"identity",
|
|
17324
|
+
cache.unreadable ? "fail" : "pass",
|
|
17325
|
+
`${entry.name} is valid and authenticates with ${authenticatesWith}${cache.text}.`,
|
|
17326
|
+
entry.name
|
|
17327
|
+
);
|
|
17328
|
+
const standing = credential !== void 0 ? "uses a credential block" : identityProvider !== void 0 ? `exists for provider "${identityProvider}"` : "is signed in";
|
|
17329
|
+
const signIn = decideSignIn({
|
|
17330
|
+
hasCredentialBlock: credential !== void 0,
|
|
17331
|
+
provider: identityProvider,
|
|
17332
|
+
keychainItem: params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0,
|
|
17333
|
+
credentialsFile: entry.credentialsFilePresent,
|
|
17334
|
+
platform: params.platform
|
|
17335
|
+
});
|
|
17336
|
+
push(
|
|
17337
|
+
"sign-in",
|
|
17338
|
+
signIn.state === "signed-out" ? "warn" : "pass",
|
|
17339
|
+
signIn.state === "signed-out" ? `${entry.name} is signed out (${signIn.detail}). Run \`agent-shim run @${entry.name}\` and sign in.` : `${entry.name} ${standing} (${signIn.detail}).`,
|
|
17340
|
+
entry.name
|
|
17341
|
+
);
|
|
17208
17342
|
}
|
|
17209
17343
|
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
17210
17344
|
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
@@ -17867,6 +18001,7 @@ var storedMutationOutput = (kind, action, value) => z30.strictObject({ action: z
|
|
|
17867
18001
|
var IdentityValueSchema = z30.strictObject({
|
|
17868
18002
|
name: z30.string(),
|
|
17869
18003
|
defaultConfigProfile: z30.string().optional(),
|
|
18004
|
+
provider: z30.string().optional(),
|
|
17870
18005
|
allowAmbientCredential: z30.boolean(),
|
|
17871
18006
|
credential: CredentialSummarySchema2.optional(),
|
|
17872
18007
|
anchors: z30.array(AnchorSchema).optional()
|
|
@@ -17886,6 +18021,8 @@ var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created",
|
|
|
17886
18021
|
var ConfigIdentitySetInputSchema = z30.strictObject({
|
|
17887
18022
|
name: z30.string().min(1),
|
|
17888
18023
|
defaultConfigProfile: z30.union([z30.string().min(1), z30.literal(false)]).optional(),
|
|
18024
|
+
/** The provider the identity exists for; `false` clears it. */
|
|
18025
|
+
provider: z30.union([z30.string().min(1), z30.literal(false)]).optional(),
|
|
17889
18026
|
allowAmbientCredential: z30.boolean().optional(),
|
|
17890
18027
|
credential: z30.union([z30.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
17891
18028
|
/** `false` removes the anchors; a list replaces them. */
|
|
@@ -18030,6 +18167,7 @@ function identityValue(name, paths) {
|
|
|
18030
18167
|
return {
|
|
18031
18168
|
name: identity.name,
|
|
18032
18169
|
...identity.defaultConfigProfile === void 0 ? {} : { defaultConfigProfile: identity.defaultConfigProfile },
|
|
18170
|
+
...identity.provider === void 0 ? {} : { provider: identity.provider },
|
|
18033
18171
|
allowAmbientCredential: identity.allowAmbientCredential,
|
|
18034
18172
|
...identity.credential === void 0 ? {} : { credential: summariseCredential(identity.credential) },
|
|
18035
18173
|
...identity.anchors === void 0 ? {} : { anchors: identity.anchors }
|
|
@@ -18062,18 +18200,24 @@ function createConfigApiRouter(deps) {
|
|
|
18062
18200
|
return { action: "created", kind: "identity", name: input.name, value: identityValue(input.name, paths) };
|
|
18063
18201
|
})
|
|
18064
18202
|
),
|
|
18065
|
-
set: route("/rest/config/identity/set", "Update an identity's default profile, ambient-credential setting, credential or anchors").input(ConfigIdentitySetInputSchema).output(ConfigIdentitySetOutputSchema).handler(
|
|
18203
|
+
set: route("/rest/config/identity/set", "Update an identity's default profile, provider, ambient-credential setting, credential or anchors").input(ConfigIdentitySetInputSchema).output(ConfigIdentitySetOutputSchema).handler(
|
|
18066
18204
|
({ input }) => guarded(() => {
|
|
18067
|
-
requireChange(input.defaultConfigProfile !== void 0 || input.allowAmbientCredential !== void 0 || input.credential !== void 0 || input.anchors !== void 0, "defaultConfigProfile, allowAmbientCredential, credential or anchors");
|
|
18205
|
+
requireChange(input.defaultConfigProfile !== void 0 || input.provider !== void 0 || input.allowAmbientCredential !== void 0 || input.credential !== void 0 || input.anchors !== void 0, "defaultConfigProfile, provider, allowAmbientCredential, credential or anchors");
|
|
18068
18206
|
if (!identityExists(paths, input.name)) {
|
|
18069
18207
|
throw new IdentityNotFoundError(input.name);
|
|
18070
18208
|
}
|
|
18071
18209
|
if (typeof input.defaultConfigProfile === "string") {
|
|
18072
18210
|
requireProfileExists(paths, input.defaultConfigProfile);
|
|
18073
18211
|
}
|
|
18212
|
+
if (typeof input.provider === "string") {
|
|
18213
|
+
requireProviderExists(paths, input.provider);
|
|
18214
|
+
}
|
|
18074
18215
|
if (input.defaultConfigProfile !== void 0) {
|
|
18075
18216
|
setDefaultConfigProfile(paths, input.name, input.defaultConfigProfile === false ? void 0 : input.defaultConfigProfile);
|
|
18076
18217
|
}
|
|
18218
|
+
if (input.provider !== void 0) {
|
|
18219
|
+
setIdentityProvider(paths, input.name, input.provider === false ? void 0 : input.provider);
|
|
18220
|
+
}
|
|
18077
18221
|
if (input.allowAmbientCredential !== void 0) {
|
|
18078
18222
|
setAllowAmbientCredential(paths, input.name, input.allowAmbientCredential);
|
|
18079
18223
|
}
|
|
@@ -20787,6 +20931,7 @@ init_supervisor();
|
|
|
20787
20931
|
init_read();
|
|
20788
20932
|
init_schema2();
|
|
20789
20933
|
init_preflight();
|
|
20934
|
+
init_resets();
|
|
20790
20935
|
init_pick();
|
|
20791
20936
|
init_plan2();
|
|
20792
20937
|
init_poolPick();
|