claude-use 9.10.0 → 9.11.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 -0
- package/dist/cli.cjs +139 -26
- package/dist/index.cjs +373 -271
- package/dist/index.mjs +369 -270
- package/dist/types/index.d.ts +62 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2639,7 +2639,7 @@ var init_package = __esm({
|
|
|
2639
2639
|
"package.json"() {
|
|
2640
2640
|
package_default = {
|
|
2641
2641
|
name: "claude-use",
|
|
2642
|
-
version: "9.
|
|
2642
|
+
version: "9.11.0",
|
|
2643
2643
|
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.",
|
|
2644
2644
|
license: "MIT",
|
|
2645
2645
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -4559,6 +4559,25 @@ function windowBurn(records, which) {
|
|
|
4559
4559
|
}
|
|
4560
4560
|
return (last.utilization - first.utilization) / (last.atMs - first.atMs);
|
|
4561
4561
|
}
|
|
4562
|
+
function windowRatio(records) {
|
|
4563
|
+
const points = [];
|
|
4564
|
+
for (const record of records) {
|
|
4565
|
+
const unified = record.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record.rateLimitHeaders);
|
|
4566
|
+
const five = unified?.fiveHour;
|
|
4567
|
+
const seven = unified?.sevenDay;
|
|
4568
|
+
if (five?.utilization !== void 0 && five.resetsAt !== void 0 && seven?.utilization !== void 0 && seven.resetsAt !== void 0) {
|
|
4569
|
+
points.push({ fiveResetsAt: five.resetsAt, sevenResetsAt: seven.resetsAt, five: five.utilization, seven: seven.utilization });
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
const latest = points.at(-1);
|
|
4573
|
+
const current = points.filter((point) => point.fiveResetsAt === latest?.fiveResetsAt && point.sevenResetsAt === latest.sevenResetsAt);
|
|
4574
|
+
const first = current.at(0);
|
|
4575
|
+
const last = current.at(-1);
|
|
4576
|
+
if (first === void 0 || last === void 0 || last.five <= first.five || last.seven <= first.seven) {
|
|
4577
|
+
return void 0;
|
|
4578
|
+
}
|
|
4579
|
+
return (last.seven - first.seven) / (last.five - first.five);
|
|
4580
|
+
}
|
|
4562
4581
|
function percent(fraction) {
|
|
4563
4582
|
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
4564
4583
|
}
|
|
@@ -4640,15 +4659,21 @@ function assessIdentity(member, nowMs) {
|
|
|
4640
4659
|
}
|
|
4641
4660
|
const remaining = Math.max(0, 1 - basis.window.utilization);
|
|
4642
4661
|
const untilResetMs = basis.window.resetsAtMs === void 0 ? basis.windowMs : Math.max(basis.window.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4643
|
-
const
|
|
4662
|
+
const weeklyScore = remaining * plan.capacity / (untilResetMs / MS_PER_HOUR2);
|
|
4644
4663
|
const fiveRemaining = five?.utilization === void 0 ? void 0 : Math.max(0, 1 - five.utilization);
|
|
4645
4664
|
const fiveUntil = five?.resetsAtMs === void 0 ? FIVE_HOUR_WINDOW_MS : Math.max(five.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4665
|
+
const ratio = windowRatio(member.records);
|
|
4666
|
+
const fiveHourScore = basis.name === "sevenDay" && fiveRemaining !== void 0 && ratio !== void 0 ? Math.min(fiveRemaining * ratio, remaining) * plan.capacity / (fiveUntil / MS_PER_HOUR2) : void 0;
|
|
4667
|
+
const fiveHourLeads = fiveHourScore !== void 0 && fiveHourScore > weeklyScore;
|
|
4668
|
+
const score = fiveHourLeads ? fiveHourScore : weeklyScore;
|
|
4669
|
+
const scoreWindow = fiveHourLeads ? "fiveHour" : basis.name;
|
|
4670
|
+
const fiveHourTermReasons = basis.name !== "sevenDay" || fiveRemaining === void 0 ? [] : ratio === void 0 ? ["5h reset not scored: no measured 5h to 7d ratio yet"] : fiveHourLeads ? [`5h term leads: ${percent(fiveRemaining)} of 5h unused is about ${percent(Math.min(fiveRemaining * ratio, remaining))} of the week at the measured ratio, resets in ${formatAge(fiveUntil)}`] : [];
|
|
4646
4671
|
const burn = windowBurn(member.records, "fiveHour");
|
|
4647
4672
|
const sevenRemaining = seven?.utilization === void 0 ? void 0 : Math.max(0, 1 - seven.utilization);
|
|
4648
4673
|
const sevenUntil = seven?.resetsAtMs === void 0 ? SEVEN_DAY_WINDOW_MS : Math.max(seven.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4649
4674
|
const sevenDayBurn = windowBurn(member.records, "sevenDay");
|
|
4650
4675
|
return {
|
|
4651
|
-
candidate: { ...base, class: "scored", score, scoreWindow
|
|
4676
|
+
candidate: { ...base, class: "scored", score, scoreWindow, reasons: [...fiveHourTermReasons, ...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
4652
4677
|
...fiveRemaining === void 0 ? {} : { fiveHour: { remaining: fiveRemaining, untilResetMs: fiveUntil } },
|
|
4653
4678
|
...burn === void 0 ? {} : { burn },
|
|
4654
4679
|
...sevenRemaining === void 0 ? {} : { sevenDay: { remaining: sevenRemaining, untilResetMs: sevenUntil } },
|
|
@@ -6002,7 +6027,7 @@ var init_commandDeps = __esm({
|
|
|
6002
6027
|
// src/claudeShim.ts
|
|
6003
6028
|
import fs8 from "node:fs";
|
|
6004
6029
|
import path26 from "node:path";
|
|
6005
|
-
import { z as
|
|
6030
|
+
import { z as z17 } from "zod";
|
|
6006
6031
|
function commandFilename(ownExecutablePath, commandName) {
|
|
6007
6032
|
return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
|
|
6008
6033
|
}
|
|
@@ -6052,10 +6077,10 @@ var init_claudeShim = __esm({
|
|
|
6052
6077
|
init_store();
|
|
6053
6078
|
init_realPorts();
|
|
6054
6079
|
init_cliError();
|
|
6055
|
-
ClaudeShimStateSchema =
|
|
6056
|
-
targetPath:
|
|
6057
|
-
method:
|
|
6058
|
-
installedAtMs:
|
|
6080
|
+
ClaudeShimStateSchema = z17.strictObject({
|
|
6081
|
+
targetPath: z17.string().min(1),
|
|
6082
|
+
method: z17.enum(["hardlink", "copy"]),
|
|
6083
|
+
installedAtMs: z17.number()
|
|
6059
6084
|
});
|
|
6060
6085
|
nodeLinkFs = { link: fs8.linkSync, copyFile: fs8.copyFileSync, chmod: fs8.chmodSync };
|
|
6061
6086
|
}
|
|
@@ -7690,15 +7715,15 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
7690
7715
|
});
|
|
7691
7716
|
|
|
7692
7717
|
// src/usage/providerQuota.ts
|
|
7693
|
-
import { z as
|
|
7694
|
-
var MS_PER_SECOND7, SECONDS_PER_HOUR,
|
|
7718
|
+
import { z as z25 } from "zod";
|
|
7719
|
+
var MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY4, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema;
|
|
7695
7720
|
var init_providerQuota = __esm({
|
|
7696
7721
|
"src/usage/providerQuota.ts"() {
|
|
7697
7722
|
"use strict";
|
|
7698
7723
|
init_schema2();
|
|
7699
7724
|
MS_PER_SECOND7 = 1e3;
|
|
7700
7725
|
SECONDS_PER_HOUR = 3600;
|
|
7701
|
-
|
|
7726
|
+
HOURS_PER_DAY4 = 24;
|
|
7702
7727
|
DAYS_PER_MONTH = 30;
|
|
7703
7728
|
ZAI_HOST = "api.z.ai";
|
|
7704
7729
|
ZAI_QUOTA_URL = `https://${ZAI_HOST}/api/monitor/usage/quota/limit`;
|
|
@@ -7706,37 +7731,37 @@ var init_providerQuota = __esm({
|
|
|
7706
7731
|
ZAI_UNIT_MONTHS = 5;
|
|
7707
7732
|
ZAI_UNIT_MS = /* @__PURE__ */ new Map([
|
|
7708
7733
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
|
|
7709
|
-
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH *
|
|
7734
|
+
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7]
|
|
7710
7735
|
]);
|
|
7711
|
-
ZaiLimitSchema =
|
|
7712
|
-
type:
|
|
7713
|
-
unit:
|
|
7714
|
-
number:
|
|
7715
|
-
percentage:
|
|
7716
|
-
nextResetTime:
|
|
7717
|
-
usage:
|
|
7718
|
-
currentValue:
|
|
7719
|
-
remaining:
|
|
7736
|
+
ZaiLimitSchema = z25.object({
|
|
7737
|
+
type: z25.string(),
|
|
7738
|
+
unit: z25.number().int(),
|
|
7739
|
+
number: z25.number().int().positive(),
|
|
7740
|
+
percentage: z25.number().nonnegative(),
|
|
7741
|
+
nextResetTime: z25.number().positive().optional(),
|
|
7742
|
+
usage: z25.number().nonnegative().optional(),
|
|
7743
|
+
currentValue: z25.number().nonnegative().optional(),
|
|
7744
|
+
remaining: z25.number().nonnegative().optional()
|
|
7720
7745
|
});
|
|
7721
|
-
ZaiResponseSchema =
|
|
7722
|
-
success:
|
|
7723
|
-
msg:
|
|
7724
|
-
data:
|
|
7746
|
+
ZaiResponseSchema = z25.object({
|
|
7747
|
+
success: z25.boolean(),
|
|
7748
|
+
msg: z25.string().optional(),
|
|
7749
|
+
data: z25.object({ level: z25.string().optional(), limits: z25.array(ZaiLimitSchema) })
|
|
7725
7750
|
});
|
|
7726
7751
|
OPENROUTER_HOST = "openrouter.ai";
|
|
7727
7752
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
7728
7753
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
7729
|
-
MS_PER_DAY3 =
|
|
7730
|
-
OpenRouterKeySchema =
|
|
7731
|
-
data:
|
|
7732
|
-
limit:
|
|
7733
|
-
limit_remaining:
|
|
7734
|
-
limit_reset:
|
|
7735
|
-
is_free_tier:
|
|
7736
|
-
free_model_daily_requests:
|
|
7754
|
+
MS_PER_DAY3 = HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7;
|
|
7755
|
+
OpenRouterKeySchema = z25.object({
|
|
7756
|
+
data: z25.object({
|
|
7757
|
+
limit: z25.number().nonnegative().nullable(),
|
|
7758
|
+
limit_remaining: z25.number().nullable(),
|
|
7759
|
+
limit_reset: z25.string().nullable(),
|
|
7760
|
+
is_free_tier: z25.boolean().optional(),
|
|
7761
|
+
free_model_daily_requests: z25.object({ used: z25.number().nonnegative(), limit: z25.number().nonnegative(), remaining: z25.number() }).optional()
|
|
7737
7762
|
})
|
|
7738
7763
|
});
|
|
7739
|
-
OpenRouterCreditsSchema =
|
|
7764
|
+
OpenRouterCreditsSchema = z25.object({ data: z25.object({ total_credits: z25.number().nonnegative(), total_usage: z25.number().nonnegative() }) });
|
|
7740
7765
|
}
|
|
7741
7766
|
});
|
|
7742
7767
|
|
|
@@ -11974,7 +11999,7 @@ var PoolPickCandidateViewSchema = z14.strictObject({
|
|
|
11974
11999
|
class: z14.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
11975
12000
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
11976
12001
|
score: z14.number().optional(),
|
|
11977
|
-
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation; present with `score`. */
|
|
12002
|
+
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation or its measured-ratio five-hour term outranks the weekly one; present with `score`. */
|
|
11978
12003
|
scoreWindow: z14.enum(["sevenDay", "fiveHour"]).optional(),
|
|
11979
12004
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
11980
12005
|
feasible: z14.boolean(),
|
|
@@ -12092,9 +12117,79 @@ var CheckReportJsonSchema = z15.strictObject({
|
|
|
12092
12117
|
init_middleware();
|
|
12093
12118
|
init_preflight();
|
|
12094
12119
|
|
|
12120
|
+
// src/usage/resets.ts
|
|
12121
|
+
init_preflight();
|
|
12122
|
+
init_rateLimit();
|
|
12123
|
+
var MS_PER_HOUR3 = 36e5;
|
|
12124
|
+
var HOURS_PER_DAY3 = 24;
|
|
12125
|
+
function formatPeriod(window) {
|
|
12126
|
+
if (window.periodMs === void 0) {
|
|
12127
|
+
return window.period ?? "unknown period";
|
|
12128
|
+
}
|
|
12129
|
+
const hours = window.periodMs / MS_PER_HOUR3;
|
|
12130
|
+
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
12131
|
+
}
|
|
12132
|
+
function groupOf(row) {
|
|
12133
|
+
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
12134
|
+
}
|
|
12135
|
+
function compareRows(left, right) {
|
|
12136
|
+
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);
|
|
12137
|
+
}
|
|
12138
|
+
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
12139
|
+
const effective = effectiveWindow(recorded, nowMs);
|
|
12140
|
+
return {
|
|
12141
|
+
identity: snapshot.identity,
|
|
12142
|
+
provider,
|
|
12143
|
+
window,
|
|
12144
|
+
observedAt: observedAt2,
|
|
12145
|
+
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
12146
|
+
reset: effective.reset,
|
|
12147
|
+
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
12148
|
+
...effective.status === void 0 ? {} : { status: effective.status }
|
|
12149
|
+
};
|
|
12150
|
+
}
|
|
12151
|
+
function collectResets(snapshots, nowMs) {
|
|
12152
|
+
const rows = snapshots.flatMap(
|
|
12153
|
+
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
12154
|
+
const unified = state.rateLimit?.unified;
|
|
12155
|
+
const observedAt2 = state.rateLimit?.observedAt;
|
|
12156
|
+
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
12157
|
+
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
12158
|
+
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
12159
|
+
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
12160
|
+
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
12161
|
+
];
|
|
12162
|
+
const quota = state.quota;
|
|
12163
|
+
const quotaRows = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
12164
|
+
return [...headerRows, ...quotaRows];
|
|
12165
|
+
})
|
|
12166
|
+
);
|
|
12167
|
+
return { resets: rows.sort(compareRows) };
|
|
12168
|
+
}
|
|
12169
|
+
|
|
12170
|
+
// src/usage/resetsSchema.ts
|
|
12171
|
+
import { z as z16 } from "zod";
|
|
12172
|
+
var ResetRowSchema = z16.strictObject({
|
|
12173
|
+
identity: z16.string(),
|
|
12174
|
+
provider: z16.string(),
|
|
12175
|
+
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
12176
|
+
window: z16.string(),
|
|
12177
|
+
/** When the state the window comes from was observed, as an ISO instant. */
|
|
12178
|
+
observedAt: z16.iso.datetime(),
|
|
12179
|
+
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
12180
|
+
resetsAt: z16.iso.datetime().optional(),
|
|
12181
|
+
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
12182
|
+
reset: z16.boolean(),
|
|
12183
|
+
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
12184
|
+
utilization: z16.number().optional(),
|
|
12185
|
+
/** The window's own status, for a window that has not reset yet. */
|
|
12186
|
+
status: z16.string().optional()
|
|
12187
|
+
});
|
|
12188
|
+
var ResetScheduleSchema = z16.strictObject({ resets: z16.readonly(z16.array(ResetRowSchema)) });
|
|
12189
|
+
|
|
12095
12190
|
// src/frontdoor/controlSchemas.ts
|
|
12096
12191
|
import path30 from "node:path";
|
|
12097
|
-
import { z as
|
|
12192
|
+
import { z as z21 } from "zod";
|
|
12098
12193
|
|
|
12099
12194
|
// src/doctorReport.ts
|
|
12100
12195
|
init_claudeShim();
|
|
@@ -12289,24 +12384,24 @@ function credentialsFilePath(farmRoot) {
|
|
|
12289
12384
|
}
|
|
12290
12385
|
|
|
12291
12386
|
// src/codex/siwcStore.ts
|
|
12292
|
-
import { z as
|
|
12387
|
+
import { z as z20 } from "zod";
|
|
12293
12388
|
|
|
12294
12389
|
// src/codex/auth.ts
|
|
12295
|
-
import { z as
|
|
12296
|
-
var AuthFileSchema =
|
|
12297
|
-
tokens:
|
|
12298
|
-
access_token:
|
|
12299
|
-
refresh_token:
|
|
12300
|
-
id_token:
|
|
12301
|
-
account_id:
|
|
12390
|
+
import { z as z18 } from "zod";
|
|
12391
|
+
var AuthFileSchema = z18.looseObject({
|
|
12392
|
+
tokens: z18.looseObject({
|
|
12393
|
+
access_token: z18.string().optional(),
|
|
12394
|
+
refresh_token: z18.string().optional(),
|
|
12395
|
+
id_token: z18.string().optional(),
|
|
12396
|
+
account_id: z18.string().optional()
|
|
12302
12397
|
}).nullish(),
|
|
12303
|
-
last_refresh:
|
|
12398
|
+
last_refresh: z18.string().optional()
|
|
12304
12399
|
});
|
|
12305
|
-
var TokenGrantSchema =
|
|
12306
|
-
access_token:
|
|
12307
|
-
refresh_token:
|
|
12308
|
-
id_token:
|
|
12309
|
-
account_id:
|
|
12400
|
+
var TokenGrantSchema = z18.looseObject({
|
|
12401
|
+
access_token: z18.string().min(1).optional(),
|
|
12402
|
+
refresh_token: z18.string().min(1).optional(),
|
|
12403
|
+
id_token: z18.string().min(1).optional(),
|
|
12404
|
+
account_id: z18.string().min(1).optional()
|
|
12310
12405
|
});
|
|
12311
12406
|
var CodexAuthError = class extends Error {
|
|
12312
12407
|
constructor(message) {
|
|
@@ -12316,41 +12411,41 @@ var CodexAuthError = class extends Error {
|
|
|
12316
12411
|
};
|
|
12317
12412
|
|
|
12318
12413
|
// src/codex/siwc.ts
|
|
12319
|
-
import { z as
|
|
12414
|
+
import { z as z19 } from "zod";
|
|
12320
12415
|
var SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
12321
12416
|
var SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
12322
12417
|
var SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
12323
|
-
var TokenResponseSchema =
|
|
12324
|
-
access_token:
|
|
12325
|
-
refresh_token:
|
|
12326
|
-
id_token:
|
|
12327
|
-
expires_in:
|
|
12328
|
-
scope:
|
|
12418
|
+
var TokenResponseSchema = z19.looseObject({
|
|
12419
|
+
access_token: z19.string().min(1),
|
|
12420
|
+
refresh_token: z19.string().min(1).optional(),
|
|
12421
|
+
id_token: z19.string().min(1).optional(),
|
|
12422
|
+
expires_in: z19.number().positive(),
|
|
12423
|
+
scope: z19.string().optional()
|
|
12329
12424
|
});
|
|
12330
|
-
var JwtHeaderSchema =
|
|
12331
|
-
var IdTokenClaimsSchema =
|
|
12332
|
-
iss:
|
|
12333
|
-
sub:
|
|
12334
|
-
aud:
|
|
12335
|
-
exp:
|
|
12336
|
-
nonce:
|
|
12337
|
-
email:
|
|
12425
|
+
var JwtHeaderSchema = z19.looseObject({ alg: z19.string(), kid: z19.string().optional() });
|
|
12426
|
+
var IdTokenClaimsSchema = z19.looseObject({
|
|
12427
|
+
iss: z19.string(),
|
|
12428
|
+
sub: z19.string().min(1),
|
|
12429
|
+
aud: z19.union([z19.string(), z19.array(z19.string())]),
|
|
12430
|
+
exp: z19.number(),
|
|
12431
|
+
nonce: z19.string().optional(),
|
|
12432
|
+
email: z19.string().optional()
|
|
12338
12433
|
});
|
|
12339
|
-
var JwksSchema =
|
|
12434
|
+
var JwksSchema = z19.object({ keys: z19.array(z19.looseObject({ kid: z19.string().optional(), kty: z19.string() })) });
|
|
12340
12435
|
|
|
12341
12436
|
// src/codex/siwcStore.ts
|
|
12342
|
-
var SiwcGrantSchema =
|
|
12343
|
-
clientId:
|
|
12344
|
-
sub:
|
|
12345
|
-
email:
|
|
12346
|
-
idToken:
|
|
12347
|
-
accessToken:
|
|
12348
|
-
refreshToken:
|
|
12349
|
-
scopes:
|
|
12437
|
+
var SiwcGrantSchema = z20.strictObject({
|
|
12438
|
+
clientId: z20.string().min(1),
|
|
12439
|
+
sub: z20.string().min(1),
|
|
12440
|
+
email: z20.string().optional(),
|
|
12441
|
+
idToken: z20.string().min(1),
|
|
12442
|
+
accessToken: z20.string().min(1),
|
|
12443
|
+
refreshToken: z20.string().min(1),
|
|
12444
|
+
scopes: z20.array(z20.string()).readonly(),
|
|
12350
12445
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
12351
|
-
expiresAt:
|
|
12446
|
+
expiresAt: z20.number()
|
|
12352
12447
|
});
|
|
12353
|
-
var SiwcFileSchema =
|
|
12448
|
+
var SiwcFileSchema = z20.strictObject({ registeredClientId: z20.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
12354
12449
|
function parseSiwcFile(raw, filePath) {
|
|
12355
12450
|
let json;
|
|
12356
12451
|
try {
|
|
@@ -12973,90 +13068,90 @@ function collectDoctorReport(params) {
|
|
|
12973
13068
|
// src/frontdoor/controlSchemas.ts
|
|
12974
13069
|
init_schema2();
|
|
12975
13070
|
init_state();
|
|
12976
|
-
var UsageListOutputSchema =
|
|
12977
|
-
var UsageWindowsInputSchema =
|
|
12978
|
-
identity:
|
|
12979
|
-
provider:
|
|
13071
|
+
var UsageListOutputSchema = z21.strictObject({ snapshots: z21.readonly(z21.array(UsageSnapshotSchema)) });
|
|
13072
|
+
var UsageWindowsInputSchema = z21.strictObject({
|
|
13073
|
+
identity: z21.string().min(1),
|
|
13074
|
+
provider: z21.string().min(1).optional()
|
|
12980
13075
|
});
|
|
12981
|
-
var EffectiveWindowSchema =
|
|
13076
|
+
var EffectiveWindowSchema = z21.strictObject({
|
|
12982
13077
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
12983
|
-
reset:
|
|
13078
|
+
reset: z21.boolean(),
|
|
12984
13079
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
12985
|
-
utilization:
|
|
13080
|
+
utilization: z21.number().optional(),
|
|
12986
13081
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
12987
|
-
resetsAtMs:
|
|
13082
|
+
resetsAtMs: z21.number().optional(),
|
|
12988
13083
|
/** The window's own status, for a window that has not reset yet. */
|
|
12989
|
-
status:
|
|
13084
|
+
status: z21.string().optional()
|
|
12990
13085
|
});
|
|
12991
|
-
var UsageWindowsOutputSchema =
|
|
12992
|
-
identity:
|
|
12993
|
-
provider:
|
|
13086
|
+
var UsageWindowsOutputSchema = z21.strictObject({
|
|
13087
|
+
identity: z21.string(),
|
|
13088
|
+
provider: z21.string(),
|
|
12994
13089
|
/** When the rate-limit state the windows come from was observed. */
|
|
12995
|
-
observedAt:
|
|
13090
|
+
observedAt: z21.iso.datetime().optional(),
|
|
12996
13091
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
12997
13092
|
sevenDay: EffectiveWindowSchema.optional()
|
|
12998
13093
|
});
|
|
12999
|
-
var UsageLiveOutputSchema =
|
|
13094
|
+
var UsageLiveOutputSchema = z21.strictObject({
|
|
13000
13095
|
/** The freshest observation the door holds, never narrowed by the read's session filter because it is the door's single latest statement of the account's quota; absent while no rate_limit_event has been filed at all. */
|
|
13001
13096
|
latest: RcLiveRateLimitSchema.optional(),
|
|
13002
13097
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
13003
|
-
sessions:
|
|
13098
|
+
sessions: z21.readonly(z21.array(RcLiveRateLimitSchema))
|
|
13004
13099
|
});
|
|
13005
|
-
var FrontDoorSessionStatusSchema =
|
|
13006
|
-
pid:
|
|
13007
|
-
startedAt:
|
|
13008
|
-
alive:
|
|
13100
|
+
var FrontDoorSessionStatusSchema = z21.strictObject({
|
|
13101
|
+
pid: z21.int().positive(),
|
|
13102
|
+
startedAt: z21.number(),
|
|
13103
|
+
alive: z21.boolean()
|
|
13009
13104
|
});
|
|
13010
|
-
var HeadroomSocketTargetSchema =
|
|
13011
|
-
var FrontDoorStatusOutputSchema =
|
|
13105
|
+
var HeadroomSocketTargetSchema = z21.union([z21.strictObject({ socketPath: z21.string() }), z21.strictObject({ refused: z21.string() })]);
|
|
13106
|
+
var FrontDoorStatusOutputSchema = z21.strictObject({
|
|
13012
13107
|
state: FrontDoorStateSchema,
|
|
13013
|
-
supervisorAlive:
|
|
13014
|
-
sessions:
|
|
13108
|
+
supervisorAlive: z21.boolean(),
|
|
13109
|
+
sessions: z21.readonly(z21.array(FrontDoorSessionStatusSchema)),
|
|
13015
13110
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
13016
|
-
logPath:
|
|
13017
|
-
logExists:
|
|
13111
|
+
logPath: z21.string(),
|
|
13112
|
+
logExists: z21.boolean()
|
|
13018
13113
|
});
|
|
13019
|
-
var FrontDoorSessionsOutputSchema =
|
|
13020
|
-
var CheckRunInputSchema =
|
|
13021
|
-
path:
|
|
13022
|
-
identity:
|
|
13114
|
+
var FrontDoorSessionsOutputSchema = z21.strictObject({ sessions: z21.readonly(z21.array(FrontDoorSessionStatusSchema)) });
|
|
13115
|
+
var CheckRunInputSchema = z21.strictObject({
|
|
13116
|
+
path: z21.string().min(1),
|
|
13117
|
+
identity: z21.string().min(1).optional()
|
|
13023
13118
|
}).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13024
|
-
var PoolPickInputSchema =
|
|
13025
|
-
pool:
|
|
13026
|
-
path:
|
|
13119
|
+
var PoolPickInputSchema = z21.strictObject({
|
|
13120
|
+
pool: z21.string().min(1),
|
|
13121
|
+
path: z21.string().min(1)
|
|
13027
13122
|
}).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13028
|
-
var DoctorFindingSchema =
|
|
13029
|
-
section:
|
|
13030
|
-
subject:
|
|
13031
|
-
severity:
|
|
13032
|
-
message:
|
|
13123
|
+
var DoctorFindingSchema = z21.strictObject({
|
|
13124
|
+
section: z21.enum(DOCTOR_SECTIONS),
|
|
13125
|
+
subject: z21.string().optional(),
|
|
13126
|
+
severity: z21.enum(DOCTOR_SEVERITIES),
|
|
13127
|
+
message: z21.string()
|
|
13033
13128
|
});
|
|
13034
|
-
var DoctorRunOutputSchema =
|
|
13129
|
+
var DoctorRunOutputSchema = z21.strictObject({
|
|
13035
13130
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
13036
|
-
ok:
|
|
13037
|
-
findings:
|
|
13131
|
+
ok: z21.boolean(),
|
|
13132
|
+
findings: z21.readonly(z21.array(DoctorFindingSchema))
|
|
13038
13133
|
});
|
|
13039
|
-
var FrontDoorRestartOutputSchema =
|
|
13040
|
-
action:
|
|
13041
|
-
previousPid:
|
|
13134
|
+
var FrontDoorRestartOutputSchema = z21.strictObject({
|
|
13135
|
+
action: z21.literal("restarting"),
|
|
13136
|
+
previousPid: z21.int().positive()
|
|
13042
13137
|
});
|
|
13043
|
-
var UpdateCheckOutputSchema =
|
|
13044
|
-
current:
|
|
13045
|
-
latest:
|
|
13046
|
-
action:
|
|
13138
|
+
var UpdateCheckOutputSchema = z21.strictObject({
|
|
13139
|
+
current: z21.string(),
|
|
13140
|
+
latest: z21.string(),
|
|
13141
|
+
action: z21.enum(["current", "available", "updated"])
|
|
13047
13142
|
});
|
|
13048
|
-
var CodexSignInSchema =
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13143
|
+
var CodexSignInSchema = z21.discriminatedUnion("state", [
|
|
13144
|
+
z21.strictObject({ state: z21.literal("none") }),
|
|
13145
|
+
z21.strictObject({ state: z21.literal("signed-in"), email: z21.string().optional(), planScope: z21.boolean(), accessTokenExpiresAt: z21.number() }),
|
|
13146
|
+
z21.strictObject({ state: z21.literal("unreadable"), message: z21.string() })
|
|
13052
13147
|
]);
|
|
13053
|
-
var CodexStatusOutputSchema =
|
|
13148
|
+
var CodexStatusOutputSchema = z21.strictObject({
|
|
13054
13149
|
signIn: CodexSignInSchema,
|
|
13055
|
-
codexProviders:
|
|
13150
|
+
codexProviders: z21.readonly(z21.array(z21.string()))
|
|
13056
13151
|
});
|
|
13057
|
-
var CodexLogoutOutputSchema =
|
|
13058
|
-
hadGrant:
|
|
13059
|
-
revoked:
|
|
13152
|
+
var CodexLogoutOutputSchema = z21.strictObject({
|
|
13153
|
+
hadGrant: z21.boolean(),
|
|
13154
|
+
revoked: z21.boolean()
|
|
13060
13155
|
});
|
|
13061
13156
|
|
|
13062
13157
|
// src/frontdoor/codexApi.ts
|
|
@@ -13213,130 +13308,130 @@ init_providersStore();
|
|
|
13213
13308
|
|
|
13214
13309
|
// src/frontdoor/configSchemas.ts
|
|
13215
13310
|
init_schema();
|
|
13216
|
-
import { z as
|
|
13217
|
-
var RemovalConfirmationSchema =
|
|
13218
|
-
var CredentialWriteSchema = (targets) =>
|
|
13219
|
-
sources:
|
|
13220
|
-
target:
|
|
13221
|
-
cache:
|
|
13311
|
+
import { z as z22 } from "zod";
|
|
13312
|
+
var RemovalConfirmationSchema = z22.boolean();
|
|
13313
|
+
var CredentialWriteSchema = (targets) => z22.strictObject({
|
|
13314
|
+
sources: z22.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
13315
|
+
target: z22.enum(targets).optional(),
|
|
13316
|
+
cache: z22.union([z22.literal(false), CredentialCacheSchema]).optional()
|
|
13222
13317
|
});
|
|
13223
|
-
var CredentialSummarySchema2 =
|
|
13224
|
-
target:
|
|
13225
|
-
sources:
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13318
|
+
var CredentialSummarySchema2 = z22.strictObject({
|
|
13319
|
+
target: z22.enum(CREDENTIAL_TARGETS),
|
|
13320
|
+
sources: z22.readonly(z22.array(
|
|
13321
|
+
z22.discriminatedUnion("kind", [
|
|
13322
|
+
z22.strictObject({ kind: z22.literal("env"), variable: z22.string() }),
|
|
13323
|
+
z22.strictObject({ kind: z22.literal("file"), path: z22.string() }),
|
|
13324
|
+
z22.strictObject({ kind: z22.literal("command"), program: z22.string() }),
|
|
13325
|
+
z22.strictObject({ kind: z22.literal("op"), reference: z22.string() }),
|
|
13326
|
+
z22.strictObject({ kind: z22.literal("keychain"), service: z22.string(), account: z22.string().optional() }),
|
|
13327
|
+
z22.strictObject({ kind: z22.literal("literal") })
|
|
13233
13328
|
])
|
|
13234
13329
|
)),
|
|
13235
13330
|
cache: CredentialCacheSchema.optional()
|
|
13236
13331
|
});
|
|
13237
|
-
var mutationOutput = (kind, action) =>
|
|
13238
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
13239
|
-
var IdentityValueSchema =
|
|
13240
|
-
name:
|
|
13241
|
-
defaultConfigProfile:
|
|
13242
|
-
allowAmbientCredential:
|
|
13332
|
+
var mutationOutput = (kind, action) => z22.strictObject({ action: z22.literal(action), kind: z22.literal(kind), name: z22.string() });
|
|
13333
|
+
var storedMutationOutput = (kind, action, value) => z22.strictObject({ action: z22.literal(action), kind: z22.literal(kind), name: z22.string(), value });
|
|
13334
|
+
var IdentityValueSchema = z22.strictObject({
|
|
13335
|
+
name: z22.string(),
|
|
13336
|
+
defaultConfigProfile: z22.string().optional(),
|
|
13337
|
+
allowAmbientCredential: z22.boolean(),
|
|
13243
13338
|
credential: CredentialSummarySchema2.optional()
|
|
13244
13339
|
});
|
|
13245
13340
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
13246
|
-
var ProviderValueSchema =
|
|
13247
|
-
name:
|
|
13248
|
-
kind:
|
|
13249
|
-
displayName:
|
|
13250
|
-
baseUrl:
|
|
13341
|
+
var ProviderValueSchema = z22.strictObject({
|
|
13342
|
+
name: z22.string(),
|
|
13343
|
+
kind: z22.enum(PROVIDER_KINDS),
|
|
13344
|
+
displayName: z22.string(),
|
|
13345
|
+
baseUrl: z22.string().optional(),
|
|
13251
13346
|
codex: CodexProviderConfigSchema.optional(),
|
|
13252
13347
|
credential: CredentialSummarySchema2,
|
|
13253
|
-
env:
|
|
13348
|
+
env: z22.record(z22.string(), z22.string()).optional()
|
|
13254
13349
|
});
|
|
13255
|
-
var ConfigNameInputSchema =
|
|
13350
|
+
var ConfigNameInputSchema = z22.strictObject({ name: z22.string().min(1) });
|
|
13256
13351
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
13257
|
-
var ConfigIdentitySetInputSchema =
|
|
13258
|
-
name:
|
|
13259
|
-
defaultConfigProfile:
|
|
13260
|
-
allowAmbientCredential:
|
|
13261
|
-
credential:
|
|
13352
|
+
var ConfigIdentitySetInputSchema = z22.strictObject({
|
|
13353
|
+
name: z22.string().min(1),
|
|
13354
|
+
defaultConfigProfile: z22.union([z22.string().min(1), z22.literal(false)]).optional(),
|
|
13355
|
+
allowAmbientCredential: z22.boolean().optional(),
|
|
13356
|
+
credential: z22.union([z22.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
|
|
13262
13357
|
});
|
|
13263
13358
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
13264
|
-
var ConfigIdentityRemoveInputSchema =
|
|
13359
|
+
var ConfigIdentityRemoveInputSchema = z22.strictObject({ name: z22.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13265
13360
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
13266
13361
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
13267
|
-
var ConfigProfileAddInputSchema =
|
|
13268
|
-
name:
|
|
13269
|
-
extends:
|
|
13270
|
-
description:
|
|
13362
|
+
var ConfigProfileAddInputSchema = z22.strictObject({
|
|
13363
|
+
name: z22.string().min(1),
|
|
13364
|
+
extends: z22.array(z22.string().min(1)).optional(),
|
|
13365
|
+
description: z22.string().optional()
|
|
13271
13366
|
});
|
|
13272
13367
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
13273
|
-
var ConfigProfileSetInputSchema =
|
|
13274
|
-
name:
|
|
13275
|
-
category:
|
|
13276
|
-
entry:
|
|
13277
|
-
extends:
|
|
13278
|
-
description:
|
|
13279
|
-
launch:
|
|
13280
|
-
skipPermissions:
|
|
13281
|
-
remoteControl:
|
|
13282
|
-
headroom:
|
|
13283
|
-
trackUsage:
|
|
13284
|
-
provider:
|
|
13285
|
-
claudeVersion:
|
|
13368
|
+
var ConfigProfileSetInputSchema = z22.strictObject({
|
|
13369
|
+
name: z22.string().min(1),
|
|
13370
|
+
category: z22.record(z22.string(), z22.boolean()).optional(),
|
|
13371
|
+
entry: z22.record(z22.string(), z22.boolean()).optional(),
|
|
13372
|
+
extends: z22.union([z22.array(z22.string().min(1)), z22.literal(false)]).optional(),
|
|
13373
|
+
description: z22.union([z22.string(), z22.literal(false)]).optional(),
|
|
13374
|
+
launch: z22.strictObject({
|
|
13375
|
+
skipPermissions: z22.boolean().optional(),
|
|
13376
|
+
remoteControl: z22.boolean().optional(),
|
|
13377
|
+
headroom: z22.boolean().optional(),
|
|
13378
|
+
trackUsage: z22.boolean().optional(),
|
|
13379
|
+
provider: z22.union([z22.string().min(1), z22.literal(false)]).optional(),
|
|
13380
|
+
claudeVersion: z22.union([z22.string().min(1), z22.literal(false)]).optional()
|
|
13286
13381
|
}).optional()
|
|
13287
13382
|
});
|
|
13288
13383
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
13289
|
-
var ConfigProfileRemoveInputSchema =
|
|
13384
|
+
var ConfigProfileRemoveInputSchema = z22.strictObject({ name: z22.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13290
13385
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
13291
13386
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
13292
|
-
var PoolMembersInputSchema =
|
|
13293
|
-
var ConfigPoolAddInputSchema =
|
|
13294
|
-
name:
|
|
13387
|
+
var PoolMembersInputSchema = z22.array(z22.string().min(1)).min(1);
|
|
13388
|
+
var ConfigPoolAddInputSchema = z22.strictObject({
|
|
13389
|
+
name: z22.string().min(1),
|
|
13295
13390
|
identities: PoolMembersInputSchema,
|
|
13296
|
-
preference:
|
|
13391
|
+
preference: z22.enum(POOL_PREFERENCES).optional()
|
|
13297
13392
|
});
|
|
13298
13393
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
13299
|
-
var ConfigPoolSetInputSchema =
|
|
13300
|
-
name:
|
|
13394
|
+
var ConfigPoolSetInputSchema = z22.strictObject({
|
|
13395
|
+
name: z22.string().min(1),
|
|
13301
13396
|
identities: PoolMembersInputSchema.optional(),
|
|
13302
|
-
preference:
|
|
13397
|
+
preference: z22.union([z22.enum(POOL_PREFERENCES), z22.literal(false)]).optional()
|
|
13303
13398
|
});
|
|
13304
13399
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
13305
|
-
var ConfigPoolRemoveInputSchema =
|
|
13400
|
+
var ConfigPoolRemoveInputSchema = z22.strictObject({ name: z22.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13306
13401
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
13307
13402
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
13308
|
-
var ConfigProviderAddInputSchema =
|
|
13309
|
-
name:
|
|
13310
|
-
kind:
|
|
13311
|
-
displayName:
|
|
13312
|
-
baseUrl:
|
|
13403
|
+
var ConfigProviderAddInputSchema = z22.strictObject({
|
|
13404
|
+
name: z22.string().min(1),
|
|
13405
|
+
kind: z22.enum(PROVIDER_KINDS).optional(),
|
|
13406
|
+
displayName: z22.string().min(1),
|
|
13407
|
+
baseUrl: z22.string().min(1).optional(),
|
|
13313
13408
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
13314
13409
|
codex: CodexProviderConfigSchema.optional()
|
|
13315
13410
|
});
|
|
13316
13411
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
13317
|
-
var ConfigProviderSetInputSchema =
|
|
13318
|
-
name:
|
|
13319
|
-
displayName:
|
|
13320
|
-
baseUrl:
|
|
13412
|
+
var ConfigProviderSetInputSchema = z22.strictObject({
|
|
13413
|
+
name: z22.string().min(1),
|
|
13414
|
+
displayName: z22.string().min(1).optional(),
|
|
13415
|
+
baseUrl: z22.string().min(1).optional(),
|
|
13321
13416
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
13322
13417
|
codex: CodexProviderConfigSchema.optional()
|
|
13323
13418
|
});
|
|
13324
13419
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
13325
|
-
var ConfigProviderRemoveInputSchema =
|
|
13420
|
+
var ConfigProviderRemoveInputSchema = z22.strictObject({ name: z22.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13326
13421
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
13327
|
-
var ConfigRuleAddInputSchema =
|
|
13328
|
-
path:
|
|
13329
|
-
configProfile:
|
|
13330
|
-
identity:
|
|
13422
|
+
var ConfigRuleAddInputSchema = z22.strictObject({
|
|
13423
|
+
path: z22.string().min(1),
|
|
13424
|
+
configProfile: z22.string().min(1).optional(),
|
|
13425
|
+
identity: z22.string().min(1).optional()
|
|
13331
13426
|
});
|
|
13332
13427
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
13333
|
-
var ConfigRuleSetInputSchema =
|
|
13334
|
-
path:
|
|
13335
|
-
configProfile:
|
|
13336
|
-
identity:
|
|
13428
|
+
var ConfigRuleSetInputSchema = z22.strictObject({
|
|
13429
|
+
path: z22.string().min(1),
|
|
13430
|
+
configProfile: z22.union([z22.string().min(1), z22.literal(false)]).optional(),
|
|
13431
|
+
identity: z22.union([z22.string().min(1), z22.literal(false)]).optional()
|
|
13337
13432
|
});
|
|
13338
13433
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
13339
|
-
var ConfigRuleRemoveInputSchema =
|
|
13434
|
+
var ConfigRuleRemoveInputSchema = z22.strictObject({ path: z22.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13340
13435
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
13341
13436
|
|
|
13342
13437
|
// src/frontdoor/configApi.ts
|
|
@@ -13642,41 +13737,41 @@ import { openapi as openapi4 } from "@orpc/openapi";
|
|
|
13642
13737
|
import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from "@orpc/server";
|
|
13643
13738
|
|
|
13644
13739
|
// src/frontdoor/eventSchemas.ts
|
|
13645
|
-
import { z as
|
|
13740
|
+
import { z as z23 } from "zod";
|
|
13646
13741
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
13647
13742
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
13648
13743
|
var USAGE_EVENT_SOURCE = "usage";
|
|
13649
13744
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
13650
13745
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
13651
|
-
var DoorEventSchema =
|
|
13652
|
-
source:
|
|
13746
|
+
var DoorEventSchema = z23.strictObject({
|
|
13747
|
+
source: z23.string().min(1),
|
|
13653
13748
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
13654
|
-
sequence:
|
|
13655
|
-
payload:
|
|
13749
|
+
sequence: z23.number().int().positive(),
|
|
13750
|
+
payload: z23.unknown()
|
|
13656
13751
|
});
|
|
13657
|
-
var DoorEventSourceQuerySchema =
|
|
13658
|
-
sources:
|
|
13752
|
+
var DoorEventSourceQuerySchema = z23.strictObject({
|
|
13753
|
+
sources: z23.array(z23.string().min(1)).min(1).optional()
|
|
13659
13754
|
});
|
|
13660
|
-
var LaunchLifecycleEventSchema =
|
|
13661
|
-
kind:
|
|
13662
|
-
pid:
|
|
13663
|
-
startedAt:
|
|
13664
|
-
observedAt:
|
|
13755
|
+
var LaunchLifecycleEventSchema = z23.strictObject({
|
|
13756
|
+
kind: z23.enum(["registered", "pruned", "ended"]),
|
|
13757
|
+
pid: z23.number().int().positive(),
|
|
13758
|
+
startedAt: z23.number(),
|
|
13759
|
+
observedAt: z23.number()
|
|
13665
13760
|
});
|
|
13666
|
-
var DoorHealthEventSchema =
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13761
|
+
var DoorHealthEventSchema = z23.discriminatedUnion("kind", [
|
|
13762
|
+
z23.strictObject({ kind: z23.literal("generation"), pid: z23.number().int().positive(), providerPort: z23.number().int().positive(), connectPort: z23.number().int().positive(), directPort: z23.number().int().positive(), observedAt: z23.number() }),
|
|
13763
|
+
z23.strictObject({ kind: z23.literal("listenerFailed"), pid: z23.number().int().positive(), listener: z23.enum(["provider", "connect", "direct"]), message: z23.string(), observedAt: z23.number() }),
|
|
13764
|
+
z23.strictObject({ kind: z23.literal("binaryTurnover"), pid: z23.number().int().positive(), observedAt: z23.number() }),
|
|
13765
|
+
z23.strictObject({ kind: z23.literal("idleShutdown"), pid: z23.number().int().positive(), observedAt: z23.number() })
|
|
13671
13766
|
]);
|
|
13672
|
-
var QuotaExpiringEventSchema =
|
|
13673
|
-
identity:
|
|
13674
|
-
provider:
|
|
13675
|
-
window:
|
|
13767
|
+
var QuotaExpiringEventSchema = z23.strictObject({
|
|
13768
|
+
identity: z23.string().min(1),
|
|
13769
|
+
provider: z23.string().min(1),
|
|
13770
|
+
window: z23.enum(["fiveHour", "sevenDay"]),
|
|
13676
13771
|
/** The fraction of the window already used when it was seen expiring, always below one because a fully used window has nothing left to spend. */
|
|
13677
|
-
utilization:
|
|
13678
|
-
resetsAt:
|
|
13679
|
-
observedAt:
|
|
13772
|
+
utilization: z23.number().min(0).max(1),
|
|
13773
|
+
resetsAt: z23.iso.datetime(),
|
|
13774
|
+
observedAt: z23.number()
|
|
13680
13775
|
});
|
|
13681
13776
|
|
|
13682
13777
|
// src/frontdoor/eventsApi.ts
|
|
@@ -13760,51 +13855,51 @@ import { openapi as openapi6 } from "@orpc/openapi";
|
|
|
13760
13855
|
|
|
13761
13856
|
// src/frontdoor/launchSchemas.ts
|
|
13762
13857
|
import path31 from "node:path";
|
|
13763
|
-
import { z as
|
|
13858
|
+
import { z as z24 } from "zod";
|
|
13764
13859
|
init_claudeVersion();
|
|
13765
13860
|
init_identity();
|
|
13766
|
-
var LaunchResolveInputSchema =
|
|
13767
|
-
path:
|
|
13861
|
+
var LaunchResolveInputSchema = z24.strictObject({
|
|
13862
|
+
path: z24.string().min(1),
|
|
13768
13863
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
13769
|
-
argv:
|
|
13864
|
+
argv: z24.readonly(z24.array(z24.string())).optional(),
|
|
13770
13865
|
/** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
|
|
13771
|
-
env:
|
|
13866
|
+
env: z24.record(z24.string(), z24.string()).optional()
|
|
13772
13867
|
}).refine((input) => path31.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13773
|
-
var LaunchPoolDecisionSchema =
|
|
13774
|
-
name:
|
|
13775
|
-
reasons:
|
|
13776
|
-
movedOff:
|
|
13868
|
+
var LaunchPoolDecisionSchema = z24.strictObject({
|
|
13869
|
+
name: z24.string(),
|
|
13870
|
+
reasons: z24.readonly(z24.array(z24.string())),
|
|
13871
|
+
movedOff: z24.strictObject({ identity: z24.string(), reason: z24.string() }).optional()
|
|
13777
13872
|
});
|
|
13778
|
-
var LaunchDecisionSchema =
|
|
13779
|
-
identity:
|
|
13780
|
-
identitySource:
|
|
13873
|
+
var LaunchDecisionSchema = z24.strictObject({
|
|
13874
|
+
identity: z24.string().optional(),
|
|
13875
|
+
identitySource: z24.enum(IDENTITY_DECISION_SOURCES),
|
|
13781
13876
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
13782
|
-
configDirEscapeHatch:
|
|
13783
|
-
configDir:
|
|
13784
|
-
configProfile:
|
|
13785
|
-
configProfileSource:
|
|
13786
|
-
provider:
|
|
13877
|
+
configDirEscapeHatch: z24.boolean(),
|
|
13878
|
+
configDir: z24.string().optional(),
|
|
13879
|
+
configProfile: z24.string().optional(),
|
|
13880
|
+
configProfileSource: z24.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
13881
|
+
provider: z24.string().optional()
|
|
13787
13882
|
});
|
|
13788
|
-
var LaunchFlagsSchema =
|
|
13789
|
-
skipPermissions:
|
|
13790
|
-
remoteControl:
|
|
13791
|
-
headroom:
|
|
13792
|
-
trackUsage:
|
|
13883
|
+
var LaunchFlagsSchema = z24.strictObject({
|
|
13884
|
+
skipPermissions: z24.boolean(),
|
|
13885
|
+
remoteControl: z24.boolean(),
|
|
13886
|
+
headroom: z24.boolean(),
|
|
13887
|
+
trackUsage: z24.boolean()
|
|
13793
13888
|
});
|
|
13794
|
-
var LaunchResolveOutputSchema =
|
|
13889
|
+
var LaunchResolveOutputSchema = z24.strictObject({
|
|
13795
13890
|
decision: LaunchDecisionSchema,
|
|
13796
13891
|
flags: LaunchFlagsSchema,
|
|
13797
|
-
claudeVersion:
|
|
13892
|
+
claudeVersion: z24.strictObject({ version: z24.string(), source: z24.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
13798
13893
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
13799
|
-
bin:
|
|
13894
|
+
bin: z24.string(),
|
|
13800
13895
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
13801
|
-
args:
|
|
13896
|
+
args: z24.readonly(z24.array(z24.string())),
|
|
13802
13897
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
13803
|
-
credential:
|
|
13804
|
-
routing:
|
|
13898
|
+
credential: z24.strictObject({ subject: z24.enum(["provider", "identity"]), name: z24.string(), summary: CredentialSummarySchema }).optional(),
|
|
13899
|
+
routing: z24.strictObject({ frontDoor: z24.boolean(), headroom: z24.boolean() }),
|
|
13805
13900
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
13806
|
-
environment:
|
|
13807
|
-
warnings:
|
|
13901
|
+
environment: z24.readonly(z24.array(z24.string())),
|
|
13902
|
+
warnings: z24.readonly(z24.array(z24.string()))
|
|
13808
13903
|
});
|
|
13809
13904
|
|
|
13810
13905
|
// src/frontdoor/launchApi.ts
|
|
@@ -13848,6 +13943,7 @@ function createControlApiRouter(deps) {
|
|
|
13848
13943
|
return {
|
|
13849
13944
|
usage: {
|
|
13850
13945
|
list: authed.meta(openapi7({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] })).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
13946
|
+
resets: authed.meta(openapi7({ method: "GET", path: "/rest/usage/resets", summary: "List every recorded quota window with when it resets", tags: [USAGE_API_TAG] })).output(ResetScheduleSchema).handler(() => collectResets(deps.usageSnapshots(), deps.now())),
|
|
13851
13947
|
effectiveWindow: authed.meta(openapi7({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] })).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input }) => {
|
|
13852
13948
|
const snapshot = deps.usageSnapshotOf(input.identity);
|
|
13853
13949
|
if (snapshot === void 0) {
|
|
@@ -14169,11 +14265,11 @@ function createDoorHealthPublisher(hub, now, pid) {
|
|
|
14169
14265
|
|
|
14170
14266
|
// src/frontdoor/quotaExpiringEvents.ts
|
|
14171
14267
|
init_schema2();
|
|
14172
|
-
var
|
|
14268
|
+
var MS_PER_HOUR4 = 36e5;
|
|
14173
14269
|
var MS_PER_DAY2 = 864e5;
|
|
14174
14270
|
var FIVE_HOUR_WINDOW_HOURS = 5;
|
|
14175
14271
|
var SEVEN_DAY_WINDOW_DAYS = 7;
|
|
14176
|
-
var FIVE_HOUR_WINDOW_MS2 = FIVE_HOUR_WINDOW_HOURS *
|
|
14272
|
+
var FIVE_HOUR_WINDOW_MS2 = FIVE_HOUR_WINDOW_HOURS * MS_PER_HOUR4;
|
|
14177
14273
|
var SEVEN_DAY_WINDOW_MS2 = SEVEN_DAY_WINDOW_DAYS * MS_PER_DAY2;
|
|
14178
14274
|
var FINAL_SPAN_DENOMINATOR = 30;
|
|
14179
14275
|
var QUOTA_EXPIRING_WINDOW_FRACTION = 1 / FINAL_SPAN_DENOMINATOR;
|
|
@@ -14614,7 +14710,7 @@ function numberOf(record, field) {
|
|
|
14614
14710
|
}
|
|
14615
14711
|
return void 0;
|
|
14616
14712
|
}
|
|
14617
|
-
function pageOfRcChannel(url, rows, idOf,
|
|
14713
|
+
function pageOfRcChannel(url, rows, idOf, rowOf2) {
|
|
14618
14714
|
const query = new URL(url, "http://127.0.0.1").searchParams;
|
|
14619
14715
|
const anchor = query.get("after_event_id") ?? query.get("cursor");
|
|
14620
14716
|
const rawLimit = query.get("limit");
|
|
@@ -14628,7 +14724,7 @@ function pageOfRcChannel(url, rows, idOf, rowOf) {
|
|
|
14628
14724
|
}
|
|
14629
14725
|
const page = limit === void 0 ? rows.slice(from) : rows.slice(from, from + limit);
|
|
14630
14726
|
const last = page[page.length - 1];
|
|
14631
|
-
return { data: page.map(
|
|
14727
|
+
return { data: page.map(rowOf2), ...last === void 0 ? {} : { next_cursor: idOf(last) } };
|
|
14632
14728
|
}
|
|
14633
14729
|
async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
14634
14730
|
const { request: request4, response, host } = ctx;
|
|
@@ -16214,6 +16310,8 @@ export {
|
|
|
16214
16310
|
RcRateLimitWindowSchema,
|
|
16215
16311
|
RcStreamEnvelopeSchema,
|
|
16216
16312
|
RcStreamEventSchema,
|
|
16313
|
+
ResetRowSchema,
|
|
16314
|
+
ResetScheduleSchema,
|
|
16217
16315
|
USAGE_EVENT_SOURCE,
|
|
16218
16316
|
UpdateCheckOutputSchema,
|
|
16219
16317
|
UsageError,
|
|
@@ -16258,6 +16356,7 @@ export {
|
|
|
16258
16356
|
collectDoctorReport,
|
|
16259
16357
|
collectFrontDoorStatus,
|
|
16260
16358
|
collectPoolPick,
|
|
16359
|
+
collectResets,
|
|
16261
16360
|
createCodexApiRouter,
|
|
16262
16361
|
createConfigApiRouter,
|
|
16263
16362
|
createControlApiRouter,
|