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.cjs
CHANGED
|
@@ -1229,6 +1229,8 @@ var init_schema = __esm({
|
|
|
1229
1229
|
$schema: import_zod3.z.string().optional(),
|
|
1230
1230
|
name: FileNameSchema,
|
|
1231
1231
|
defaultConfigProfile: StoredNameSchema.optional(),
|
|
1232
|
+
/** 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. */
|
|
1233
|
+
provider: StoredNameSchema.optional(),
|
|
1232
1234
|
allowAmbientCredential: import_zod3.z.boolean().default(false),
|
|
1233
1235
|
credential: CredentialSchema.optional(),
|
|
1234
1236
|
/** 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. */
|
|
@@ -4762,7 +4764,7 @@ var init_package = __esm({
|
|
|
4762
4764
|
"package.json"() {
|
|
4763
4765
|
package_default = {
|
|
4764
4766
|
name: "claude-use",
|
|
4765
|
-
version: "11.
|
|
4767
|
+
version: "11.77.0",
|
|
4766
4768
|
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.",
|
|
4767
4769
|
license: "MIT",
|
|
4768
4770
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -5969,19 +5971,23 @@ function renderReport(rows, style) {
|
|
|
5969
5971
|
const lines = [style(["bold"], REPORT_HEADING)];
|
|
5970
5972
|
for (const row of rows) {
|
|
5971
5973
|
const detail = row.detail === void 0 ? "" : ` ${style(["dim"], `(${row.detail})`)}`;
|
|
5972
|
-
|
|
5974
|
+
const label = row.label.padEnd(labelWidth);
|
|
5975
|
+
lines.push(
|
|
5976
|
+
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}`
|
|
5977
|
+
);
|
|
5973
5978
|
for (const note of row.notes ?? []) {
|
|
5974
5979
|
lines.push(`${indent}${" ".repeat(labelWidth)}${COLUMN_GAP}${style(["dim"], note)}`);
|
|
5975
5980
|
}
|
|
5976
5981
|
}
|
|
5977
5982
|
return lines;
|
|
5978
5983
|
}
|
|
5979
|
-
var REPORT_HEADING, COLUMN_GAP;
|
|
5984
|
+
var REPORT_HEADING, COLUMN_GAP, NOTICE_FORMATS;
|
|
5980
5985
|
var init_report = __esm({
|
|
5981
5986
|
"src/launcher/report.ts"() {
|
|
5982
5987
|
"use strict";
|
|
5983
5988
|
REPORT_HEADING = "agent-shim";
|
|
5984
5989
|
COLUMN_GAP = " ";
|
|
5990
|
+
NOTICE_FORMATS = ["yellow", "bold"];
|
|
5985
5991
|
}
|
|
5986
5992
|
});
|
|
5987
5993
|
|
|
@@ -7031,52 +7037,6 @@ var init_account = __esm({
|
|
|
7031
7037
|
}
|
|
7032
7038
|
});
|
|
7033
7039
|
|
|
7034
|
-
// src/usage/plan.ts
|
|
7035
|
-
function planOf(account) {
|
|
7036
|
-
const userTier = account?.userRateLimitTier;
|
|
7037
|
-
if (userTier !== void 0 && ZERO_TIER.test(userTier)) {
|
|
7038
|
-
return { kind: "pay-per-use", tier: userTier };
|
|
7039
|
-
}
|
|
7040
|
-
const tier = account?.organizationRateLimitTier ?? userTier;
|
|
7041
|
-
const tierField = tier === void 0 ? {} : { tier };
|
|
7042
|
-
if (tier === void 0) {
|
|
7043
|
-
return { kind: "subscription", capacity: 1, recognised: false };
|
|
7044
|
-
}
|
|
7045
|
-
if (ZERO_TIER.test(tier)) {
|
|
7046
|
-
return { kind: "pay-per-use", ...tierField };
|
|
7047
|
-
}
|
|
7048
|
-
const multiplier = TIER_MULTIPLIER.exec(tier)?.[1];
|
|
7049
|
-
if (multiplier !== void 0) {
|
|
7050
|
-
return { kind: "subscription", capacity: Number(multiplier), recognised: true, ...tierField };
|
|
7051
|
-
}
|
|
7052
|
-
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
7053
|
-
}
|
|
7054
|
-
var import_zod13, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
7055
|
-
var init_plan2 = __esm({
|
|
7056
|
-
"src/usage/plan.ts"() {
|
|
7057
|
-
"use strict";
|
|
7058
|
-
import_zod13 = require("zod");
|
|
7059
|
-
PlanClassSchema = import_zod13.z.union([
|
|
7060
|
-
import_zod13.z.strictObject({
|
|
7061
|
-
kind: import_zod13.z.literal("subscription"),
|
|
7062
|
-
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
7063
|
-
capacity: import_zod13.z.number().positive(),
|
|
7064
|
-
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
7065
|
-
recognised: import_zod13.z.boolean(),
|
|
7066
|
-
/** The tier string the classification rests on, when the account had one. */
|
|
7067
|
-
tier: import_zod13.z.string().optional()
|
|
7068
|
-
}),
|
|
7069
|
-
import_zod13.z.strictObject({
|
|
7070
|
-
kind: import_zod13.z.literal("pay-per-use"),
|
|
7071
|
-
tier: import_zod13.z.string().optional()
|
|
7072
|
-
})
|
|
7073
|
-
]);
|
|
7074
|
-
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
7075
|
-
ZERO_TIER = /(?:^|_)zero$/;
|
|
7076
|
-
BASE_TIER = /(?:^|_)(?:pro|free)$/;
|
|
7077
|
-
}
|
|
7078
|
-
});
|
|
7079
|
-
|
|
7080
7040
|
// src/usage/rateLimit.ts
|
|
7081
7041
|
function epochSecondsToIso(value) {
|
|
7082
7042
|
if (value === void 0) {
|
|
@@ -7168,39 +7128,6 @@ var init_rateLimit = __esm({
|
|
|
7168
7128
|
}
|
|
7169
7129
|
});
|
|
7170
7130
|
|
|
7171
|
-
// src/usage/scan.ts
|
|
7172
|
-
var import_zod14, AnthropicUsageSchema, ErrorObjectSchema;
|
|
7173
|
-
var init_scan = __esm({
|
|
7174
|
-
"src/usage/scan.ts"() {
|
|
7175
|
-
"use strict";
|
|
7176
|
-
import_zod14 = require("zod");
|
|
7177
|
-
AnthropicUsageSchema = import_zod14.z.looseObject({
|
|
7178
|
-
input_tokens: import_zod14.z.number().int().nonnegative().nullish(),
|
|
7179
|
-
output_tokens: import_zod14.z.number().int().nonnegative().nullish(),
|
|
7180
|
-
cache_creation_input_tokens: import_zod14.z.number().int().nonnegative().nullish(),
|
|
7181
|
-
cache_read_input_tokens: import_zod14.z.number().int().nonnegative().nullish()
|
|
7182
|
-
});
|
|
7183
|
-
ErrorObjectSchema = import_zod14.z.looseObject({
|
|
7184
|
-
type: import_zod14.z.string().optional(),
|
|
7185
|
-
code: import_zod14.z.union([import_zod14.z.string(), import_zod14.z.number()]).optional(),
|
|
7186
|
-
message: import_zod14.z.string().optional()
|
|
7187
|
-
});
|
|
7188
|
-
}
|
|
7189
|
-
});
|
|
7190
|
-
|
|
7191
|
-
// src/usage/middleware.ts
|
|
7192
|
-
var ANTHROPIC_PROVIDER;
|
|
7193
|
-
var init_middleware = __esm({
|
|
7194
|
-
"src/usage/middleware.ts"() {
|
|
7195
|
-
"use strict";
|
|
7196
|
-
init_route();
|
|
7197
|
-
init_rateLimit();
|
|
7198
|
-
init_scan();
|
|
7199
|
-
init_schema2();
|
|
7200
|
-
ANTHROPIC_PROVIDER = "anthropic";
|
|
7201
|
-
}
|
|
7202
|
-
});
|
|
7203
|
-
|
|
7204
7131
|
// src/usage/preflight.ts
|
|
7205
7132
|
function formatAge(ms) {
|
|
7206
7133
|
const minutes = Math.floor(ms / (MS_PER_SECOND3 * SECONDS_PER_MINUTE));
|
|
@@ -7257,6 +7184,111 @@ var init_preflight = __esm({
|
|
|
7257
7184
|
}
|
|
7258
7185
|
});
|
|
7259
7186
|
|
|
7187
|
+
// src/usage/candidateText.ts
|
|
7188
|
+
function candidateHeading(candidate) {
|
|
7189
|
+
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
7190
|
+
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
7191
|
+
return `[${candidate.class}${score}]${dry}`;
|
|
7192
|
+
}
|
|
7193
|
+
function percent(fraction) {
|
|
7194
|
+
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
7195
|
+
}
|
|
7196
|
+
function describeWindow(label, window, effective, nowMs) {
|
|
7197
|
+
if (effective.reset) {
|
|
7198
|
+
return `${label} window has reset`;
|
|
7199
|
+
}
|
|
7200
|
+
const used = effective.utilization === void 0 ? "usage unknown" : `${percent(effective.utilization)} used`;
|
|
7201
|
+
const resets = effective.resetsAtMs === void 0 ? "" : `, resets in ${formatAge(effective.resetsAtMs - nowMs)}`;
|
|
7202
|
+
return `${label} ${used}${resets}${window.status === "allowed_warning" ? " (nearly used)" : ""}`;
|
|
7203
|
+
}
|
|
7204
|
+
var PERCENT;
|
|
7205
|
+
var init_candidateText = __esm({
|
|
7206
|
+
"src/usage/candidateText.ts"() {
|
|
7207
|
+
"use strict";
|
|
7208
|
+
init_preflight();
|
|
7209
|
+
PERCENT = 100;
|
|
7210
|
+
}
|
|
7211
|
+
});
|
|
7212
|
+
|
|
7213
|
+
// src/usage/plan.ts
|
|
7214
|
+
function planOf(account) {
|
|
7215
|
+
const userTier = account?.userRateLimitTier;
|
|
7216
|
+
if (userTier !== void 0 && ZERO_TIER.test(userTier)) {
|
|
7217
|
+
return { kind: "pay-per-use", tier: userTier };
|
|
7218
|
+
}
|
|
7219
|
+
const tier = account?.organizationRateLimitTier ?? userTier;
|
|
7220
|
+
const tierField = tier === void 0 ? {} : { tier };
|
|
7221
|
+
if (tier === void 0) {
|
|
7222
|
+
return { kind: "subscription", capacity: 1, recognised: false };
|
|
7223
|
+
}
|
|
7224
|
+
if (ZERO_TIER.test(tier)) {
|
|
7225
|
+
return { kind: "pay-per-use", ...tierField };
|
|
7226
|
+
}
|
|
7227
|
+
const multiplier = TIER_MULTIPLIER.exec(tier)?.[1];
|
|
7228
|
+
if (multiplier !== void 0) {
|
|
7229
|
+
return { kind: "subscription", capacity: Number(multiplier), recognised: true, ...tierField };
|
|
7230
|
+
}
|
|
7231
|
+
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
7232
|
+
}
|
|
7233
|
+
var import_zod13, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
7234
|
+
var init_plan2 = __esm({
|
|
7235
|
+
"src/usage/plan.ts"() {
|
|
7236
|
+
"use strict";
|
|
7237
|
+
import_zod13 = require("zod");
|
|
7238
|
+
PlanClassSchema = import_zod13.z.union([
|
|
7239
|
+
import_zod13.z.strictObject({
|
|
7240
|
+
kind: import_zod13.z.literal("subscription"),
|
|
7241
|
+
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
7242
|
+
capacity: import_zod13.z.number().positive(),
|
|
7243
|
+
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
7244
|
+
recognised: import_zod13.z.boolean(),
|
|
7245
|
+
/** The tier string the classification rests on, when the account had one. */
|
|
7246
|
+
tier: import_zod13.z.string().optional()
|
|
7247
|
+
}),
|
|
7248
|
+
import_zod13.z.strictObject({
|
|
7249
|
+
kind: import_zod13.z.literal("pay-per-use"),
|
|
7250
|
+
tier: import_zod13.z.string().optional()
|
|
7251
|
+
})
|
|
7252
|
+
]);
|
|
7253
|
+
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
7254
|
+
ZERO_TIER = /(?:^|_)zero$/;
|
|
7255
|
+
BASE_TIER = /(?:^|_)(?:pro|free)$/;
|
|
7256
|
+
}
|
|
7257
|
+
});
|
|
7258
|
+
|
|
7259
|
+
// src/usage/scan.ts
|
|
7260
|
+
var import_zod14, AnthropicUsageSchema, ErrorObjectSchema;
|
|
7261
|
+
var init_scan = __esm({
|
|
7262
|
+
"src/usage/scan.ts"() {
|
|
7263
|
+
"use strict";
|
|
7264
|
+
import_zod14 = require("zod");
|
|
7265
|
+
AnthropicUsageSchema = import_zod14.z.looseObject({
|
|
7266
|
+
input_tokens: import_zod14.z.number().int().nonnegative().nullish(),
|
|
7267
|
+
output_tokens: import_zod14.z.number().int().nonnegative().nullish(),
|
|
7268
|
+
cache_creation_input_tokens: import_zod14.z.number().int().nonnegative().nullish(),
|
|
7269
|
+
cache_read_input_tokens: import_zod14.z.number().int().nonnegative().nullish()
|
|
7270
|
+
});
|
|
7271
|
+
ErrorObjectSchema = import_zod14.z.looseObject({
|
|
7272
|
+
type: import_zod14.z.string().optional(),
|
|
7273
|
+
code: import_zod14.z.union([import_zod14.z.string(), import_zod14.z.number()]).optional(),
|
|
7274
|
+
message: import_zod14.z.string().optional()
|
|
7275
|
+
});
|
|
7276
|
+
}
|
|
7277
|
+
});
|
|
7278
|
+
|
|
7279
|
+
// src/usage/middleware.ts
|
|
7280
|
+
var ANTHROPIC_PROVIDER;
|
|
7281
|
+
var init_middleware = __esm({
|
|
7282
|
+
"src/usage/middleware.ts"() {
|
|
7283
|
+
"use strict";
|
|
7284
|
+
init_route();
|
|
7285
|
+
init_rateLimit();
|
|
7286
|
+
init_scan();
|
|
7287
|
+
init_schema2();
|
|
7288
|
+
ANTHROPIC_PROVIDER = "anthropic";
|
|
7289
|
+
}
|
|
7290
|
+
});
|
|
7291
|
+
|
|
7260
7292
|
// src/usage/quotaFacts.ts
|
|
7261
7293
|
function windowFacts(window, nowMs) {
|
|
7262
7294
|
if (window?.utilization === void 0 || window.resetsAt === void 0) {
|
|
@@ -7356,17 +7388,6 @@ function windowRatio(records) {
|
|
|
7356
7388
|
}
|
|
7357
7389
|
return (last.seven - first.seven) / (last.five - first.five);
|
|
7358
7390
|
}
|
|
7359
|
-
function percent(fraction) {
|
|
7360
|
-
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
7361
|
-
}
|
|
7362
|
-
function describeWindow(label, window, effective, nowMs) {
|
|
7363
|
-
if (effective.reset) {
|
|
7364
|
-
return `${label} window has reset`;
|
|
7365
|
-
}
|
|
7366
|
-
const used = effective.utilization === void 0 ? "usage unknown" : `${percent(effective.utilization)} used`;
|
|
7367
|
-
const resets = effective.resetsAtMs === void 0 ? "" : `, resets in ${formatAge(effective.resetsAtMs - nowMs)}`;
|
|
7368
|
-
return `${label} ${used}${resets}${window.status === "allowed_warning" ? " (nearly used)" : ""}`;
|
|
7369
|
-
}
|
|
7370
7391
|
function capacityOf(plan) {
|
|
7371
7392
|
return plan.kind === "subscription" ? plan.capacity : 1;
|
|
7372
7393
|
}
|
|
@@ -7559,11 +7580,12 @@ function rankPool(input) {
|
|
|
7559
7580
|
...holdForReturn === void 0 ? {} : { holdForReturn }
|
|
7560
7581
|
};
|
|
7561
7582
|
}
|
|
7562
|
-
var MS_PER_SECOND4, MS_PER_HOUR2, HOURS_PER_DAY2, FIVE_HOURS, PROMPT_CACHE_TTL_HOURS,
|
|
7583
|
+
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;
|
|
7563
7584
|
var init_pick = __esm({
|
|
7564
7585
|
"src/usage/pick.ts"() {
|
|
7565
7586
|
"use strict";
|
|
7566
7587
|
init_conditions();
|
|
7588
|
+
init_candidateText();
|
|
7567
7589
|
init_plan2();
|
|
7568
7590
|
init_middleware();
|
|
7569
7591
|
init_preflight();
|
|
@@ -7574,7 +7596,6 @@ var init_pick = __esm({
|
|
|
7574
7596
|
HOURS_PER_DAY2 = 24;
|
|
7575
7597
|
FIVE_HOURS = 5;
|
|
7576
7598
|
PROMPT_CACHE_TTL_HOURS = 1;
|
|
7577
|
-
PERCENT = 100;
|
|
7578
7599
|
SEVEN_DAYS = 7;
|
|
7579
7600
|
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR2;
|
|
7580
7601
|
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY2 * MS_PER_HOUR2;
|
|
@@ -9049,6 +9070,12 @@ function providerJsonPath(paths, name) {
|
|
|
9049
9070
|
function providerExists(paths, name) {
|
|
9050
9071
|
return import_node_fs6.default.existsSync(providerJsonPath(paths, name));
|
|
9051
9072
|
}
|
|
9073
|
+
function requireProviderExists(paths, name) {
|
|
9074
|
+
const canonical = canonicalProviderName(name, (candidate) => providerExists(paths, candidate), () => readProviderAliases(paths));
|
|
9075
|
+
if (!providerExists(paths, canonical)) {
|
|
9076
|
+
throw new ProviderNotFoundError(name);
|
|
9077
|
+
}
|
|
9078
|
+
}
|
|
9052
9079
|
function isRecord7(value) {
|
|
9053
9080
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9054
9081
|
}
|
|
@@ -9283,18 +9310,18 @@ function removeProvider(paths, name) {
|
|
|
9283
9310
|
}
|
|
9284
9311
|
import_node_fs6.default.rmSync(providerJsonPath(paths, name));
|
|
9285
9312
|
}
|
|
9286
|
-
function cascadeProviderName(cascade) {
|
|
9313
|
+
function cascadeProviderName(cascade, identityProvider) {
|
|
9287
9314
|
let name;
|
|
9288
9315
|
for (const layer of assembleCascade(cascade).layers) {
|
|
9289
9316
|
if (layer.launch?.provider !== void 0) {
|
|
9290
9317
|
name = layer.launch.provider;
|
|
9291
9318
|
}
|
|
9292
9319
|
}
|
|
9293
|
-
return name;
|
|
9320
|
+
return name ?? identityProvider;
|
|
9294
9321
|
}
|
|
9295
9322
|
function selectProvider(params) {
|
|
9296
9323
|
const cliName = params.cliProvider !== void 0 && params.cliProvider !== "" ? params.cliProvider : void 0;
|
|
9297
|
-
const named = cliName ?? (params.cascade === void 0 ?
|
|
9324
|
+
const named = cliName ?? (params.cascade === void 0 ? params.identityProvider : cascadeProviderName(params.cascade, params.identityProvider));
|
|
9298
9325
|
if (named === void 0) {
|
|
9299
9326
|
return void 0;
|
|
9300
9327
|
}
|
|
@@ -9454,6 +9481,9 @@ function decideSignIn(facts) {
|
|
|
9454
9481
|
if (facts.hasCredentialBlock) {
|
|
9455
9482
|
return { state: "token", detail: "supplies its own credential through a credential block, so a stored login is not what a launch uses" };
|
|
9456
9483
|
}
|
|
9484
|
+
if (facts.provider !== void 0) {
|
|
9485
|
+
return { state: "token", detail: "runs provider sessions with the provider's credential, so a stored login is not what a launch uses" };
|
|
9486
|
+
}
|
|
9457
9487
|
if (facts.keychainItem === true) {
|
|
9458
9488
|
return { state: "signed-in", detail: "a login is stored in the macOS Keychain" };
|
|
9459
9489
|
}
|
|
@@ -9466,9 +9496,10 @@ function credentialsFilePath(farmRoot) {
|
|
|
9466
9496
|
return import_node_path25.default.join(farmRoot, CREDENTIALS_FILE);
|
|
9467
9497
|
}
|
|
9468
9498
|
function identitySignIn(fs14, probe, identity) {
|
|
9469
|
-
const probing = !identity.hasCredentialBlock;
|
|
9499
|
+
const probing = !identity.hasCredentialBlock && identity.provider === void 0;
|
|
9470
9500
|
return decideSignIn({
|
|
9471
9501
|
hasCredentialBlock: identity.hasCredentialBlock,
|
|
9502
|
+
provider: identity.provider,
|
|
9472
9503
|
keychainItem: probing && probe.platform === "darwin" && probe.run !== void 0 ? keychainHasItem(probe.run, identity.farmRoot) : void 0,
|
|
9473
9504
|
credentialsFile: probing && fs14.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
|
|
9474
9505
|
platform: probe.platform
|
|
@@ -9625,6 +9656,62 @@ var init_guard = __esm({
|
|
|
9625
9656
|
}
|
|
9626
9657
|
});
|
|
9627
9658
|
|
|
9659
|
+
// src/usage/resets.ts
|
|
9660
|
+
function formatPeriod(window) {
|
|
9661
|
+
if (window.periodMs === void 0) {
|
|
9662
|
+
return window.period ?? "unknown period";
|
|
9663
|
+
}
|
|
9664
|
+
const hours = window.periodMs / MS_PER_HOUR3;
|
|
9665
|
+
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
9666
|
+
}
|
|
9667
|
+
function groupOf(row) {
|
|
9668
|
+
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
9669
|
+
}
|
|
9670
|
+
function compareRows(left, right) {
|
|
9671
|
+
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);
|
|
9672
|
+
}
|
|
9673
|
+
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
9674
|
+
const effective = effectiveWindow(recorded, nowMs);
|
|
9675
|
+
return {
|
|
9676
|
+
identity: snapshot.identity,
|
|
9677
|
+
provider,
|
|
9678
|
+
window,
|
|
9679
|
+
observedAt: observedAt2,
|
|
9680
|
+
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
9681
|
+
reset: effective.reset,
|
|
9682
|
+
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
9683
|
+
...effective.status === void 0 ? {} : { status: effective.status }
|
|
9684
|
+
};
|
|
9685
|
+
}
|
|
9686
|
+
function collectResets(snapshots, nowMs) {
|
|
9687
|
+
const rows = snapshots.flatMap(
|
|
9688
|
+
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
9689
|
+
const unified = state.rateLimit?.unified;
|
|
9690
|
+
const observedAt2 = state.rateLimit?.observedAt;
|
|
9691
|
+
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
9692
|
+
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
9693
|
+
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
9694
|
+
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
9695
|
+
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
9696
|
+
];
|
|
9697
|
+
const quota = state.quota;
|
|
9698
|
+
const quotaRows2 = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
9699
|
+
return [...headerRows, ...quotaRows2];
|
|
9700
|
+
})
|
|
9701
|
+
);
|
|
9702
|
+
return { resets: rows.sort(compareRows) };
|
|
9703
|
+
}
|
|
9704
|
+
var MS_PER_HOUR3, HOURS_PER_DAY3;
|
|
9705
|
+
var init_resets = __esm({
|
|
9706
|
+
"src/usage/resets.ts"() {
|
|
9707
|
+
"use strict";
|
|
9708
|
+
init_preflight();
|
|
9709
|
+
init_rateLimit();
|
|
9710
|
+
MS_PER_HOUR3 = 36e5;
|
|
9711
|
+
HOURS_PER_DAY3 = 24;
|
|
9712
|
+
}
|
|
9713
|
+
});
|
|
9714
|
+
|
|
9628
9715
|
// src/cli/commandDeps.ts
|
|
9629
9716
|
var init_commandDeps = __esm({
|
|
9630
9717
|
"src/cli/commandDeps.ts"() {
|
|
@@ -11332,24 +11419,9 @@ var init_hold = __esm({
|
|
|
11332
11419
|
}
|
|
11333
11420
|
});
|
|
11334
11421
|
|
|
11335
|
-
// src/usage/candidateText.ts
|
|
11336
|
-
function candidateHeading(candidate) {
|
|
11337
|
-
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
11338
|
-
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
11339
|
-
return `[${candidate.class}${score}]${dry}`;
|
|
11340
|
-
}
|
|
11341
|
-
var init_candidateText = __esm({
|
|
11342
|
-
"src/usage/candidateText.ts"() {
|
|
11343
|
-
"use strict";
|
|
11344
|
-
}
|
|
11345
|
-
});
|
|
11346
|
-
|
|
11347
11422
|
// src/launcher/launchReport.ts
|
|
11348
11423
|
function poolDetail(pool) {
|
|
11349
11424
|
const [reason] = pool.reasons;
|
|
11350
|
-
if (pool.movedOff !== void 0) {
|
|
11351
|
-
return { detail: `moved off ${pool.movedOff.identity}: ${pool.movedOff.reason}`, ...reason === void 0 ? {} : { notes: [reason] } };
|
|
11352
|
-
}
|
|
11353
11425
|
return reason === void 0 ? {} : { detail: reason };
|
|
11354
11426
|
}
|
|
11355
11427
|
function rankingNotes(ranking, picked) {
|
|
@@ -11358,6 +11430,68 @@ function rankingNotes(ranking, picked) {
|
|
|
11358
11430
|
` ${candidate.reasons.join("; ")}`
|
|
11359
11431
|
]);
|
|
11360
11432
|
}
|
|
11433
|
+
function planText(account) {
|
|
11434
|
+
const plan = planOf(account);
|
|
11435
|
+
if (plan.kind === "pay-per-use") {
|
|
11436
|
+
return "pay-per-use";
|
|
11437
|
+
}
|
|
11438
|
+
return plan.recognised ? `${String(plan.capacity)}x` : void 0;
|
|
11439
|
+
}
|
|
11440
|
+
function loginAccountText(account) {
|
|
11441
|
+
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;
|
|
11442
|
+
const parts = [account.emailAddress, organisation, planText(account)].filter((part) => part !== void 0);
|
|
11443
|
+
return parts.length === 0 ? void 0 : parts.join(", ");
|
|
11444
|
+
}
|
|
11445
|
+
function accountRows(billing) {
|
|
11446
|
+
if (billing === void 0) {
|
|
11447
|
+
return [];
|
|
11448
|
+
}
|
|
11449
|
+
if (billing.provider !== void 0) {
|
|
11450
|
+
const quota = billing.snapshot?.providers[billing.provider]?.quota;
|
|
11451
|
+
const parts = [quota?.account?.email, quota?.level].filter((part) => part !== void 0);
|
|
11452
|
+
return parts.length === 0 ? [] : [{ label: "account", value: parts.join(", "), detail: `provider ${billing.provider}` }];
|
|
11453
|
+
}
|
|
11454
|
+
const account = billing.login ?? billing.snapshot?.account;
|
|
11455
|
+
const text = account === void 0 ? void 0 : loginAccountText(account);
|
|
11456
|
+
return text === void 0 ? [] : [{ label: "account", value: text }];
|
|
11457
|
+
}
|
|
11458
|
+
function isInformative(window, nowMs) {
|
|
11459
|
+
const effective = effectiveWindow(window, nowMs);
|
|
11460
|
+
return effective.reset || effective.utilization !== void 0 || effective.resetsAtMs !== void 0;
|
|
11461
|
+
}
|
|
11462
|
+
function quotaRows(billing) {
|
|
11463
|
+
if (billing === void 0) {
|
|
11464
|
+
return [];
|
|
11465
|
+
}
|
|
11466
|
+
const { nowMs } = billing;
|
|
11467
|
+
const state = billing.snapshot?.providers[billing.provider ?? ANTHROPIC_PROVIDER];
|
|
11468
|
+
const recorded = billing.provider === void 0 ? {
|
|
11469
|
+
observedAt: state?.rateLimit?.observedAt,
|
|
11470
|
+
windows: [
|
|
11471
|
+
{ label: "5h", window: state?.rateLimit?.unified?.fiveHour },
|
|
11472
|
+
{ label: "7d", window: state?.rateLimit?.unified?.sevenDay }
|
|
11473
|
+
]
|
|
11474
|
+
} : { observedAt: state?.quota?.observedAt, windows: (state?.quota?.windows ?? []).map((window) => ({ label: `${formatPeriod(window)} ${window.measures}`, window })) };
|
|
11475
|
+
const described = recorded.windows.flatMap(({ label, window }) => window !== void 0 && isInformative(window, nowMs) ? [describeWindow(label, window, effectiveWindow(window, nowMs), nowMs)] : []);
|
|
11476
|
+
return recorded.observedAt === void 0 || described.length === 0 ? [] : [{ label: "quota", value: described.join("; "), detail: `recorded ${formatAge(nowMs - Date.parse(recorded.observedAt))} ago` }];
|
|
11477
|
+
}
|
|
11478
|
+
function movedRows(facts) {
|
|
11479
|
+
const { identity } = facts;
|
|
11480
|
+
if (identity === void 0) {
|
|
11481
|
+
return [];
|
|
11482
|
+
}
|
|
11483
|
+
const moved = (from, detail) => [{ label: "moved", value: `${from} -> ${identity}`, detail, notice: true }];
|
|
11484
|
+
if (facts.limitRelaunchFrom !== void 0) {
|
|
11485
|
+
return moved(facts.limitRelaunchFrom, `${facts.limitRelaunchFrom} ran out of quota; the session resumed here`);
|
|
11486
|
+
}
|
|
11487
|
+
if (facts.pool?.movedOff !== void 0) {
|
|
11488
|
+
return moved(facts.pool.movedOff.identity, `the resumed conversation could not stay: ${facts.pool.movedOff.reason}`);
|
|
11489
|
+
}
|
|
11490
|
+
if (facts.lastRanAs !== void 0 && facts.lastRanAs.identity !== identity) {
|
|
11491
|
+
return moved(facts.lastRanAs.identity, `this directory last ran as ${facts.lastRanAs.identity} ${formatAge(facts.lastRanAs.agoMs)} ago`);
|
|
11492
|
+
}
|
|
11493
|
+
return [];
|
|
11494
|
+
}
|
|
11361
11495
|
function decisionRows(facts) {
|
|
11362
11496
|
return [
|
|
11363
11497
|
{ label: "identity", value: facts.identity ?? "(none)", detail: facts.identitySource },
|
|
@@ -11369,6 +11503,9 @@ function decisionRows(facts) {
|
|
|
11369
11503
|
...facts.ranking === void 0 ? {} : { notes: rankingNotes(facts.ranking, facts.identity) }
|
|
11370
11504
|
}
|
|
11371
11505
|
],
|
|
11506
|
+
...movedRows(facts),
|
|
11507
|
+
...accountRows(facts.billing),
|
|
11508
|
+
...quotaRows(facts.billing),
|
|
11372
11509
|
...facts.profile === void 0 ? [] : [{ label: "profile", value: facts.profile.name, detail: facts.profile.source }],
|
|
11373
11510
|
...facts.provider === void 0 ? [] : [{ label: "provider", value: facts.provider.name, detail: `credential ${facts.provider.credential}` }],
|
|
11374
11511
|
...facts.identityCredential === void 0 ? [] : [{ label: "credential", value: facts.identityCredential, detail: "the identity's own" }]
|
|
@@ -11398,10 +11535,16 @@ function farmRow(links, builtDirectories, adopted) {
|
|
|
11398
11535
|
function noteRow(text) {
|
|
11399
11536
|
return { label: "note", value: text };
|
|
11400
11537
|
}
|
|
11538
|
+
var NAMED_ORGANISATION_TYPES;
|
|
11401
11539
|
var init_launchReport = __esm({
|
|
11402
11540
|
"src/launcher/launchReport.ts"() {
|
|
11403
11541
|
"use strict";
|
|
11404
11542
|
init_candidateText();
|
|
11543
|
+
init_middleware();
|
|
11544
|
+
init_plan2();
|
|
11545
|
+
init_preflight();
|
|
11546
|
+
init_resets();
|
|
11547
|
+
NAMED_ORGANISATION_TYPES = /* @__PURE__ */ new Set(["claude_team", "claude_enterprise"]);
|
|
11405
11548
|
}
|
|
11406
11549
|
});
|
|
11407
11550
|
|
|
@@ -11476,7 +11619,8 @@ function resolvePoolLaunch(params) {
|
|
|
11476
11619
|
explanation: `pool ${poolName}: ${move}${pick.reasons.slice(0, REASONS_LOGGED).join("; ")}`,
|
|
11477
11620
|
reasons: pick.reasons,
|
|
11478
11621
|
candidates: graph.ranking.candidates,
|
|
11479
|
-
...movedOff === void 0 ? {} : { movedOff }
|
|
11622
|
+
...movedOff === void 0 ? {} : { movedOff },
|
|
11623
|
+
...stickyRead.sticky === void 0 ? {} : { lastRanAs: stickyRead.sticky }
|
|
11480
11624
|
};
|
|
11481
11625
|
}
|
|
11482
11626
|
if (earliestReturn === void 0) {
|
|
@@ -11651,7 +11795,8 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
11651
11795
|
return {
|
|
11652
11796
|
identityDecision: { ...decided, name: resolution.identity },
|
|
11653
11797
|
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
11654
|
-
poolRanking: resolution.candidates
|
|
11798
|
+
poolRanking: resolution.candidates,
|
|
11799
|
+
...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
|
|
11655
11800
|
};
|
|
11656
11801
|
}
|
|
11657
11802
|
function decideLaunch(params, readOnly) {
|
|
@@ -11678,7 +11823,7 @@ function decideLaunch(params, readOnly) {
|
|
|
11678
11823
|
return trimmed === "" ? void 0 : trimmed;
|
|
11679
11824
|
}
|
|
11680
11825
|
});
|
|
11681
|
-
const { identityDecision, poolPick, poolRanking } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
11826
|
+
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
11682
11827
|
const farmIdentity = configDirEscapeHatchApplies ? void 0 : identityDecision.name;
|
|
11683
11828
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
11684
11829
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
@@ -11731,7 +11876,8 @@ function decideLaunch(params, readOnly) {
|
|
|
11731
11876
|
paths,
|
|
11732
11877
|
port: fs14,
|
|
11733
11878
|
...parsedArgv.provider === void 0 || parsedArgv.provider === false ? {} : { cliProvider: parsedArgv.provider },
|
|
11734
|
-
...farmContext === void 0 ? {} : { cascade: farmContext.cascade }
|
|
11879
|
+
...farmContext === void 0 ? {} : { cascade: farmContext.cascade },
|
|
11880
|
+
...loadedIdentity?.config.provider === void 0 ? {} : { identityProvider: loadedIdentity.config.provider }
|
|
11735
11881
|
};
|
|
11736
11882
|
let selectedProvider;
|
|
11737
11883
|
let resolvedProvider;
|
|
@@ -11754,9 +11900,11 @@ function decideLaunch(params, readOnly) {
|
|
|
11754
11900
|
log.warn(warning);
|
|
11755
11901
|
}
|
|
11756
11902
|
}
|
|
11903
|
+
let billing;
|
|
11757
11904
|
if (farm !== void 0 && farmIdentity !== void 0) {
|
|
11905
|
+
let snapshot;
|
|
11758
11906
|
try {
|
|
11759
|
-
|
|
11907
|
+
snapshot = readUsageSnapshot(farm.fs, paths.usageSnapshotsDir, farmIdentity);
|
|
11760
11908
|
for (const warning of quotaWarnings(snapshot, selectedProvider?.name ?? ANTHROPIC_PROVIDER, farm.now())) {
|
|
11761
11909
|
log.warn(warning);
|
|
11762
11910
|
}
|
|
@@ -11766,6 +11914,16 @@ function decideLaunch(params, readOnly) {
|
|
|
11766
11914
|
}
|
|
11767
11915
|
log.warn(`agent-shim: ${error.message}`);
|
|
11768
11916
|
}
|
|
11917
|
+
let login;
|
|
11918
|
+
try {
|
|
11919
|
+
login = readAccountMetadata(farm.fs, paths.identitiesDir, farmIdentity);
|
|
11920
|
+
} catch (error) {
|
|
11921
|
+
if (!(error instanceof AccountMetadataError)) {
|
|
11922
|
+
throw error;
|
|
11923
|
+
}
|
|
11924
|
+
log.warn(`agent-shim: ${error.message}`);
|
|
11925
|
+
}
|
|
11926
|
+
billing = { login, snapshot, provider: selectedProvider?.name, nowMs: farm.now() };
|
|
11769
11927
|
}
|
|
11770
11928
|
const identityCredentialBlock = selectedProvider === void 0 && farmIdentity !== void 0 ? loadedIdentity?.config.credential : void 0;
|
|
11771
11929
|
const identityResolution = !readOnly && identityCredentialBlock !== void 0 && farmIdentity !== void 0 ? resolveIdentityCredential(farmIdentity, identityCredentialBlock, env, params.credentials) : void 0;
|
|
@@ -11864,6 +12022,8 @@ function decideLaunch(params, readOnly) {
|
|
|
11864
12022
|
identityDecision,
|
|
11865
12023
|
poolPick,
|
|
11866
12024
|
poolRanking,
|
|
12025
|
+
lastRanAs,
|
|
12026
|
+
billing,
|
|
11867
12027
|
notes,
|
|
11868
12028
|
configDirEscapeHatch: configDirEscapeHatchApplies,
|
|
11869
12029
|
farmIdentity,
|
|
@@ -11886,7 +12046,7 @@ function prepareLaunch(params) {
|
|
|
11886
12046
|
const { paths, proc, log } = params;
|
|
11887
12047
|
const { env } = proc;
|
|
11888
12048
|
const decided = decideLaunch(params, false);
|
|
11889
|
-
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, notes, flags: resolvedFlags, args: finalArgv, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
12049
|
+
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, lastRanAs, billing, notes, flags: resolvedFlags, args: finalArgv, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
11890
12050
|
const rows = [
|
|
11891
12051
|
...decisionRows({
|
|
11892
12052
|
identity: identityDecision.name,
|
|
@@ -11895,7 +12055,10 @@ function prepareLaunch(params) {
|
|
|
11895
12055
|
ranking: resolvedFlags.explain ? poolRanking : void 0,
|
|
11896
12056
|
profile: configProfileDecision.name === void 0 ? void 0 : { name: configProfileDecision.name, source: configProfileDecision.source },
|
|
11897
12057
|
provider: resolvedProvider === void 0 ? void 0 : { name: resolvedProvider.name, credential: `${resolvedProvider.credential.target} from ${describeSource(resolvedProvider.credential.source)}` },
|
|
11898
|
-
identityCredential: identityCredential === void 0 ? void 0 : `${identityCredential.target} from ${describeSource(identityCredential.source)}
|
|
12058
|
+
identityCredential: identityCredential === void 0 ? void 0 : `${identityCredential.target} from ${describeSource(identityCredential.source)}`,
|
|
12059
|
+
billing,
|
|
12060
|
+
lastRanAs,
|
|
12061
|
+
limitRelaunchFrom: params.supervised?.from
|
|
11899
12062
|
})
|
|
11900
12063
|
];
|
|
11901
12064
|
let warnings = [];
|
|
@@ -12084,6 +12247,7 @@ var init_launcher = __esm({
|
|
|
12084
12247
|
init_schema();
|
|
12085
12248
|
init_credential();
|
|
12086
12249
|
init_middleware();
|
|
12250
|
+
init_account();
|
|
12087
12251
|
init_preflight();
|
|
12088
12252
|
init_read();
|
|
12089
12253
|
init_claudeVersion();
|
|
@@ -12352,7 +12516,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
12352
12516
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
12353
12517
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
12354
12518
|
hold: realHoldPort,
|
|
12355
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path41.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
12519
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path41.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
12356
12520
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
12357
12521
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
12358
12522
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -16485,7 +16649,7 @@ function collectCheckReport(params) {
|
|
|
16485
16649
|
read,
|
|
16486
16650
|
...configProfileDecision.name === void 0 ? {} : { baseConfigProfile: configProfileDecision.name }
|
|
16487
16651
|
}).input;
|
|
16488
|
-
const providerName = cascadeProviderName(cascade);
|
|
16652
|
+
const providerName = cascadeProviderName(cascade, identityConfig?.provider);
|
|
16489
16653
|
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
16490
16654
|
const farmRoot = identityDecision.name === void 0 ? void 0 : import_node_path26.default.join(paths.identitiesDir, identityDecision.name);
|
|
16491
16655
|
const settingsFiles = {
|
|
@@ -16710,56 +16874,7 @@ var CheckReportJsonSchema = import_zod21.z.strictObject({
|
|
|
16710
16874
|
// src/frontdoor/controlApi.ts
|
|
16711
16875
|
init_middleware();
|
|
16712
16876
|
init_preflight();
|
|
16713
|
-
|
|
16714
|
-
// src/usage/resets.ts
|
|
16715
|
-
init_preflight();
|
|
16716
|
-
init_rateLimit();
|
|
16717
|
-
var MS_PER_HOUR3 = 36e5;
|
|
16718
|
-
var HOURS_PER_DAY3 = 24;
|
|
16719
|
-
function formatPeriod(window) {
|
|
16720
|
-
if (window.periodMs === void 0) {
|
|
16721
|
-
return window.period ?? "unknown period";
|
|
16722
|
-
}
|
|
16723
|
-
const hours = window.periodMs / MS_PER_HOUR3;
|
|
16724
|
-
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
16725
|
-
}
|
|
16726
|
-
function groupOf(row) {
|
|
16727
|
-
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
16728
|
-
}
|
|
16729
|
-
function compareRows(left, right) {
|
|
16730
|
-
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);
|
|
16731
|
-
}
|
|
16732
|
-
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
16733
|
-
const effective = effectiveWindow(recorded, nowMs);
|
|
16734
|
-
return {
|
|
16735
|
-
identity: snapshot.identity,
|
|
16736
|
-
provider,
|
|
16737
|
-
window,
|
|
16738
|
-
observedAt: observedAt2,
|
|
16739
|
-
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
16740
|
-
reset: effective.reset,
|
|
16741
|
-
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
16742
|
-
...effective.status === void 0 ? {} : { status: effective.status }
|
|
16743
|
-
};
|
|
16744
|
-
}
|
|
16745
|
-
function collectResets(snapshots, nowMs) {
|
|
16746
|
-
const rows = snapshots.flatMap(
|
|
16747
|
-
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
16748
|
-
const unified = state.rateLimit?.unified;
|
|
16749
|
-
const observedAt2 = state.rateLimit?.observedAt;
|
|
16750
|
-
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
16751
|
-
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
16752
|
-
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
16753
|
-
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
16754
|
-
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
16755
|
-
];
|
|
16756
|
-
const quota = state.quota;
|
|
16757
|
-
const quotaRows = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
16758
|
-
return [...headerRows, ...quotaRows];
|
|
16759
|
-
})
|
|
16760
|
-
);
|
|
16761
|
-
return { resets: rows.sort(compareRows) };
|
|
16762
|
-
}
|
|
16877
|
+
init_resets();
|
|
16763
16878
|
|
|
16764
16879
|
// src/usage/resetsSchema.ts
|
|
16765
16880
|
var import_zod22 = require("zod");
|
|
@@ -16914,6 +17029,12 @@ function setDefaultConfigProfile(paths, identityName, profileName) {
|
|
|
16914
17029
|
defaultConfigProfile: profileName
|
|
16915
17030
|
});
|
|
16916
17031
|
}
|
|
17032
|
+
function setIdentityProvider(paths, identityName, providerName) {
|
|
17033
|
+
if (!identityExists(paths, identityName)) {
|
|
17034
|
+
throw new IdentityNotFoundError(identityName);
|
|
17035
|
+
}
|
|
17036
|
+
return applyPatch(identityJsonPath(paths, identityName), IdentitySchema, { provider: providerName });
|
|
17037
|
+
}
|
|
16917
17038
|
function setAllowAmbientCredential(paths, identityName, allow) {
|
|
16918
17039
|
if (!identityExists(paths, identityName)) {
|
|
16919
17040
|
throw new IdentityNotFoundError(identityName);
|
|
@@ -17582,6 +17703,7 @@ function runDoctor(params) {
|
|
|
17582
17703
|
}
|
|
17583
17704
|
}
|
|
17584
17705
|
const validProfileNames = new Set(profileSources.keys());
|
|
17706
|
+
const validProviderNames = /* @__PURE__ */ new Set([...params.providers.map((entry) => entry.name), ...Object.keys(params.providerAliases ?? {})]);
|
|
17585
17707
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
17586
17708
|
for (const entry of params.identities) {
|
|
17587
17709
|
const validated3 = validate(IdentitySchema, entry, "identity", entry.name);
|
|
@@ -17591,35 +17713,47 @@ function runDoctor(params) {
|
|
|
17591
17713
|
}
|
|
17592
17714
|
validIdentityNames.add(entry.name);
|
|
17593
17715
|
const defaultProfile = validated3.data.defaultConfigProfile;
|
|
17716
|
+
let consistent = true;
|
|
17594
17717
|
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
17718
|
+
consistent = false;
|
|
17595
17719
|
push(
|
|
17596
17720
|
"identity",
|
|
17597
17721
|
"fail",
|
|
17598
17722
|
`Identity "${entry.name}" names configuration profile "${defaultProfile}" as its default, but no such profile exists.`,
|
|
17599
17723
|
entry.name
|
|
17600
17724
|
);
|
|
17601
|
-
} else {
|
|
17602
|
-
const credential = validated3.data.credential;
|
|
17603
|
-
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
17604
|
-
push(
|
|
17605
|
-
"identity",
|
|
17606
|
-
cache.unreadable ? "fail" : "pass",
|
|
17607
|
-
`${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
|
|
17608
|
-
entry.name
|
|
17609
|
-
);
|
|
17610
|
-
const signIn = decideSignIn({
|
|
17611
|
-
hasCredentialBlock: credential !== void 0,
|
|
17612
|
-
keychainItem: params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0,
|
|
17613
|
-
credentialsFile: entry.credentialsFilePresent,
|
|
17614
|
-
platform: params.platform
|
|
17615
|
-
});
|
|
17616
|
-
push(
|
|
17617
|
-
"sign-in",
|
|
17618
|
-
signIn.state === "signed-out" ? "warn" : "pass",
|
|
17619
|
-
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}).`,
|
|
17620
|
-
entry.name
|
|
17621
|
-
);
|
|
17622
17725
|
}
|
|
17726
|
+
const identityProvider = validated3.data.provider;
|
|
17727
|
+
if (identityProvider !== void 0 && !validProviderNames.has(identityProvider)) {
|
|
17728
|
+
consistent = false;
|
|
17729
|
+
push("identity", "fail", `Identity "${entry.name}" names provider "${identityProvider}" as its provider, but no such provider exists.`, entry.name);
|
|
17730
|
+
}
|
|
17731
|
+
if (!consistent) {
|
|
17732
|
+
continue;
|
|
17733
|
+
}
|
|
17734
|
+
const credential = validated3.data.credential;
|
|
17735
|
+
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
17736
|
+
const authenticatesWith = credential !== void 0 ? `credential ${describeCredential(credential)}` : identityProvider !== void 0 ? `the credential of provider "${identityProvider}"` : "its stored login";
|
|
17737
|
+
push(
|
|
17738
|
+
"identity",
|
|
17739
|
+
cache.unreadable ? "fail" : "pass",
|
|
17740
|
+
`${entry.name} is valid and authenticates with ${authenticatesWith}${cache.text}.`,
|
|
17741
|
+
entry.name
|
|
17742
|
+
);
|
|
17743
|
+
const standing = credential !== void 0 ? "uses a credential block" : identityProvider !== void 0 ? `exists for provider "${identityProvider}"` : "is signed in";
|
|
17744
|
+
const signIn = decideSignIn({
|
|
17745
|
+
hasCredentialBlock: credential !== void 0,
|
|
17746
|
+
provider: identityProvider,
|
|
17747
|
+
keychainItem: params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0,
|
|
17748
|
+
credentialsFile: entry.credentialsFilePresent,
|
|
17749
|
+
platform: params.platform
|
|
17750
|
+
});
|
|
17751
|
+
push(
|
|
17752
|
+
"sign-in",
|
|
17753
|
+
signIn.state === "signed-out" ? "warn" : "pass",
|
|
17754
|
+
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}).`,
|
|
17755
|
+
entry.name
|
|
17756
|
+
);
|
|
17623
17757
|
}
|
|
17624
17758
|
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
17625
17759
|
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
@@ -18282,6 +18416,7 @@ var storedMutationOutput = (kind, action, value) => import_zod30.z.strictObject(
|
|
|
18282
18416
|
var IdentityValueSchema = import_zod30.z.strictObject({
|
|
18283
18417
|
name: import_zod30.z.string(),
|
|
18284
18418
|
defaultConfigProfile: import_zod30.z.string().optional(),
|
|
18419
|
+
provider: import_zod30.z.string().optional(),
|
|
18285
18420
|
allowAmbientCredential: import_zod30.z.boolean(),
|
|
18286
18421
|
credential: CredentialSummarySchema2.optional(),
|
|
18287
18422
|
anchors: import_zod30.z.array(AnchorSchema).optional()
|
|
@@ -18301,6 +18436,8 @@ var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created",
|
|
|
18301
18436
|
var ConfigIdentitySetInputSchema = import_zod30.z.strictObject({
|
|
18302
18437
|
name: import_zod30.z.string().min(1),
|
|
18303
18438
|
defaultConfigProfile: import_zod30.z.union([import_zod30.z.string().min(1), import_zod30.z.literal(false)]).optional(),
|
|
18439
|
+
/** The provider the identity exists for; `false` clears it. */
|
|
18440
|
+
provider: import_zod30.z.union([import_zod30.z.string().min(1), import_zod30.z.literal(false)]).optional(),
|
|
18304
18441
|
allowAmbientCredential: import_zod30.z.boolean().optional(),
|
|
18305
18442
|
credential: import_zod30.z.union([import_zod30.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
18306
18443
|
/** `false` removes the anchors; a list replaces them. */
|
|
@@ -18445,6 +18582,7 @@ function identityValue(name, paths) {
|
|
|
18445
18582
|
return {
|
|
18446
18583
|
name: identity.name,
|
|
18447
18584
|
...identity.defaultConfigProfile === void 0 ? {} : { defaultConfigProfile: identity.defaultConfigProfile },
|
|
18585
|
+
...identity.provider === void 0 ? {} : { provider: identity.provider },
|
|
18448
18586
|
allowAmbientCredential: identity.allowAmbientCredential,
|
|
18449
18587
|
...identity.credential === void 0 ? {} : { credential: summariseCredential(identity.credential) },
|
|
18450
18588
|
...identity.anchors === void 0 ? {} : { anchors: identity.anchors }
|
|
@@ -18477,18 +18615,24 @@ function createConfigApiRouter(deps) {
|
|
|
18477
18615
|
return { action: "created", kind: "identity", name: input.name, value: identityValue(input.name, paths) };
|
|
18478
18616
|
})
|
|
18479
18617
|
),
|
|
18480
|
-
set: route("/rest/config/identity/set", "Update an identity's default profile, ambient-credential setting, credential or anchors").input(ConfigIdentitySetInputSchema).output(ConfigIdentitySetOutputSchema).handler(
|
|
18618
|
+
set: route("/rest/config/identity/set", "Update an identity's default profile, provider, ambient-credential setting, credential or anchors").input(ConfigIdentitySetInputSchema).output(ConfigIdentitySetOutputSchema).handler(
|
|
18481
18619
|
({ input }) => guarded(() => {
|
|
18482
|
-
requireChange(input.defaultConfigProfile !== void 0 || input.allowAmbientCredential !== void 0 || input.credential !== void 0 || input.anchors !== void 0, "defaultConfigProfile, allowAmbientCredential, credential or anchors");
|
|
18620
|
+
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");
|
|
18483
18621
|
if (!identityExists(paths, input.name)) {
|
|
18484
18622
|
throw new IdentityNotFoundError(input.name);
|
|
18485
18623
|
}
|
|
18486
18624
|
if (typeof input.defaultConfigProfile === "string") {
|
|
18487
18625
|
requireProfileExists(paths, input.defaultConfigProfile);
|
|
18488
18626
|
}
|
|
18627
|
+
if (typeof input.provider === "string") {
|
|
18628
|
+
requireProviderExists(paths, input.provider);
|
|
18629
|
+
}
|
|
18489
18630
|
if (input.defaultConfigProfile !== void 0) {
|
|
18490
18631
|
setDefaultConfigProfile(paths, input.name, input.defaultConfigProfile === false ? void 0 : input.defaultConfigProfile);
|
|
18491
18632
|
}
|
|
18633
|
+
if (input.provider !== void 0) {
|
|
18634
|
+
setIdentityProvider(paths, input.name, input.provider === false ? void 0 : input.provider);
|
|
18635
|
+
}
|
|
18492
18636
|
if (input.allowAmbientCredential !== void 0) {
|
|
18493
18637
|
setAllowAmbientCredential(paths, input.name, input.allowAmbientCredential);
|
|
18494
18638
|
}
|
|
@@ -21202,6 +21346,7 @@ init_supervisor();
|
|
|
21202
21346
|
init_read();
|
|
21203
21347
|
init_schema2();
|
|
21204
21348
|
init_preflight();
|
|
21349
|
+
init_resets();
|
|
21205
21350
|
init_pick();
|
|
21206
21351
|
init_plan2();
|
|
21207
21352
|
init_poolPick();
|