claude-use 9.10.1 → 9.12.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 +2 -0
- package/dist/cli.cjs +128 -23
- package/dist/index.cjs +373 -271
- package/dist/index.mjs +369 -270
- package/dist/types/index.d.ts +90 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2663,7 +2663,7 @@ var init_package = __esm({
|
|
|
2663
2663
|
"package.json"() {
|
|
2664
2664
|
package_default = {
|
|
2665
2665
|
name: "claude-use",
|
|
2666
|
-
version: "9.
|
|
2666
|
+
version: "9.12.0",
|
|
2667
2667
|
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.",
|
|
2668
2668
|
license: "MIT",
|
|
2669
2669
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -4585,6 +4585,25 @@ function windowBurn(records, which) {
|
|
|
4585
4585
|
}
|
|
4586
4586
|
return (last.utilization - first.utilization) / (last.atMs - first.atMs);
|
|
4587
4587
|
}
|
|
4588
|
+
function windowRatio(records) {
|
|
4589
|
+
const points = [];
|
|
4590
|
+
for (const record of records) {
|
|
4591
|
+
const unified = record.rateLimitHeaders === void 0 ? void 0 : parseUnifiedRateLimit(record.rateLimitHeaders);
|
|
4592
|
+
const five = unified?.fiveHour;
|
|
4593
|
+
const seven = unified?.sevenDay;
|
|
4594
|
+
if (five?.utilization !== void 0 && five.resetsAt !== void 0 && seven?.utilization !== void 0 && seven.resetsAt !== void 0) {
|
|
4595
|
+
points.push({ fiveResetsAt: five.resetsAt, sevenResetsAt: seven.resetsAt, five: five.utilization, seven: seven.utilization });
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
const latest = points.at(-1);
|
|
4599
|
+
const current = points.filter((point) => point.fiveResetsAt === latest?.fiveResetsAt && point.sevenResetsAt === latest.sevenResetsAt);
|
|
4600
|
+
const first = current.at(0);
|
|
4601
|
+
const last = current.at(-1);
|
|
4602
|
+
if (first === void 0 || last === void 0 || last.five <= first.five || last.seven <= first.seven) {
|
|
4603
|
+
return void 0;
|
|
4604
|
+
}
|
|
4605
|
+
return (last.seven - first.seven) / (last.five - first.five);
|
|
4606
|
+
}
|
|
4588
4607
|
function percent(fraction) {
|
|
4589
4608
|
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
4590
4609
|
}
|
|
@@ -4666,15 +4685,21 @@ function assessIdentity(member, nowMs) {
|
|
|
4666
4685
|
}
|
|
4667
4686
|
const remaining = Math.max(0, 1 - basis.window.utilization);
|
|
4668
4687
|
const untilResetMs = basis.window.resetsAtMs === void 0 ? basis.windowMs : Math.max(basis.window.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4669
|
-
const
|
|
4688
|
+
const weeklyScore = remaining * plan.capacity / (untilResetMs / MS_PER_HOUR2);
|
|
4670
4689
|
const fiveRemaining = five?.utilization === void 0 ? void 0 : Math.max(0, 1 - five.utilization);
|
|
4671
4690
|
const fiveUntil = five?.resetsAtMs === void 0 ? FIVE_HOUR_WINDOW_MS : Math.max(five.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4691
|
+
const ratio = windowRatio(member.records);
|
|
4692
|
+
const fiveHourScore = basis.name === "sevenDay" && fiveRemaining !== void 0 && ratio !== void 0 ? Math.min(fiveRemaining * ratio, remaining) * plan.capacity / (fiveUntil / MS_PER_HOUR2) : void 0;
|
|
4693
|
+
const fiveHourLeads = fiveHourScore !== void 0 && fiveHourScore > weeklyScore;
|
|
4694
|
+
const score = fiveHourLeads ? fiveHourScore : weeklyScore;
|
|
4695
|
+
const scoreWindow = fiveHourLeads ? "fiveHour" : basis.name;
|
|
4696
|
+
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)}`] : [];
|
|
4672
4697
|
const burn = windowBurn(member.records, "fiveHour");
|
|
4673
4698
|
const sevenRemaining = seven?.utilization === void 0 ? void 0 : Math.max(0, 1 - seven.utilization);
|
|
4674
4699
|
const sevenUntil = seven?.resetsAtMs === void 0 ? SEVEN_DAY_WINDOW_MS : Math.max(seven.resetsAtMs - nowMs, MS_PER_SECOND4);
|
|
4675
4700
|
const sevenDayBurn = windowBurn(member.records, "sevenDay");
|
|
4676
4701
|
return {
|
|
4677
|
-
candidate: { ...base, class: "scored", score, scoreWindow
|
|
4702
|
+
candidate: { ...base, class: "scored", score, scoreWindow, reasons: [...fiveHourTermReasons, ...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
|
|
4678
4703
|
...fiveRemaining === void 0 ? {} : { fiveHour: { remaining: fiveRemaining, untilResetMs: fiveUntil } },
|
|
4679
4704
|
...burn === void 0 ? {} : { burn },
|
|
4680
4705
|
...sevenRemaining === void 0 ? {} : { sevenDay: { remaining: sevenRemaining, untilResetMs: sevenUntil } },
|
|
@@ -6068,21 +6093,21 @@ function findPathShadow(params) {
|
|
|
6068
6093
|
}
|
|
6069
6094
|
return params.pathDirs.some((dir) => import_node_path26.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
6070
6095
|
}
|
|
6071
|
-
var import_node_fs7, import_node_path26,
|
|
6096
|
+
var import_node_fs7, import_node_path26, import_zod17, ClaudeShimStateSchema, nodeLinkFs;
|
|
6072
6097
|
var init_claudeShim = __esm({
|
|
6073
6098
|
"src/claudeShim.ts"() {
|
|
6074
6099
|
"use strict";
|
|
6075
6100
|
import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
6076
6101
|
import_node_path26 = __toESM(require("node:path"), 1);
|
|
6077
|
-
|
|
6102
|
+
import_zod17 = require("zod");
|
|
6078
6103
|
init_commandDeps();
|
|
6079
6104
|
init_store();
|
|
6080
6105
|
init_realPorts();
|
|
6081
6106
|
init_cliError();
|
|
6082
|
-
ClaudeShimStateSchema =
|
|
6083
|
-
targetPath:
|
|
6084
|
-
method:
|
|
6085
|
-
installedAtMs:
|
|
6107
|
+
ClaudeShimStateSchema = import_zod17.z.strictObject({
|
|
6108
|
+
targetPath: import_zod17.z.string().min(1),
|
|
6109
|
+
method: import_zod17.z.enum(["hardlink", "copy"]),
|
|
6110
|
+
installedAtMs: import_zod17.z.number()
|
|
6086
6111
|
});
|
|
6087
6112
|
nodeLinkFs = { link: import_node_fs7.default.linkSync, copyFile: import_node_fs7.default.copyFileSync, chmod: import_node_fs7.default.chmodSync };
|
|
6088
6113
|
}
|
|
@@ -7718,15 +7743,15 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
7718
7743
|
});
|
|
7719
7744
|
|
|
7720
7745
|
// src/usage/providerQuota.ts
|
|
7721
|
-
var
|
|
7746
|
+
var import_zod25, 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;
|
|
7722
7747
|
var init_providerQuota = __esm({
|
|
7723
7748
|
"src/usage/providerQuota.ts"() {
|
|
7724
7749
|
"use strict";
|
|
7725
|
-
|
|
7750
|
+
import_zod25 = require("zod");
|
|
7726
7751
|
init_schema2();
|
|
7727
7752
|
MS_PER_SECOND7 = 1e3;
|
|
7728
7753
|
SECONDS_PER_HOUR = 3600;
|
|
7729
|
-
|
|
7754
|
+
HOURS_PER_DAY4 = 24;
|
|
7730
7755
|
DAYS_PER_MONTH = 30;
|
|
7731
7756
|
ZAI_HOST = "api.z.ai";
|
|
7732
7757
|
ZAI_QUOTA_URL = `https://${ZAI_HOST}/api/monitor/usage/quota/limit`;
|
|
@@ -7734,37 +7759,37 @@ var init_providerQuota = __esm({
|
|
|
7734
7759
|
ZAI_UNIT_MONTHS = 5;
|
|
7735
7760
|
ZAI_UNIT_MS = /* @__PURE__ */ new Map([
|
|
7736
7761
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
|
|
7737
|
-
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH *
|
|
7762
|
+
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7]
|
|
7738
7763
|
]);
|
|
7739
|
-
ZaiLimitSchema =
|
|
7740
|
-
type:
|
|
7741
|
-
unit:
|
|
7742
|
-
number:
|
|
7743
|
-
percentage:
|
|
7744
|
-
nextResetTime:
|
|
7745
|
-
usage:
|
|
7746
|
-
currentValue:
|
|
7747
|
-
remaining:
|
|
7764
|
+
ZaiLimitSchema = import_zod25.z.object({
|
|
7765
|
+
type: import_zod25.z.string(),
|
|
7766
|
+
unit: import_zod25.z.number().int(),
|
|
7767
|
+
number: import_zod25.z.number().int().positive(),
|
|
7768
|
+
percentage: import_zod25.z.number().nonnegative(),
|
|
7769
|
+
nextResetTime: import_zod25.z.number().positive().optional(),
|
|
7770
|
+
usage: import_zod25.z.number().nonnegative().optional(),
|
|
7771
|
+
currentValue: import_zod25.z.number().nonnegative().optional(),
|
|
7772
|
+
remaining: import_zod25.z.number().nonnegative().optional()
|
|
7748
7773
|
});
|
|
7749
|
-
ZaiResponseSchema =
|
|
7750
|
-
success:
|
|
7751
|
-
msg:
|
|
7752
|
-
data:
|
|
7774
|
+
ZaiResponseSchema = import_zod25.z.object({
|
|
7775
|
+
success: import_zod25.z.boolean(),
|
|
7776
|
+
msg: import_zod25.z.string().optional(),
|
|
7777
|
+
data: import_zod25.z.object({ level: import_zod25.z.string().optional(), limits: import_zod25.z.array(ZaiLimitSchema) })
|
|
7753
7778
|
});
|
|
7754
7779
|
OPENROUTER_HOST = "openrouter.ai";
|
|
7755
7780
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
7756
7781
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
7757
|
-
MS_PER_DAY3 =
|
|
7758
|
-
OpenRouterKeySchema =
|
|
7759
|
-
data:
|
|
7760
|
-
limit:
|
|
7761
|
-
limit_remaining:
|
|
7762
|
-
limit_reset:
|
|
7763
|
-
is_free_tier:
|
|
7764
|
-
free_model_daily_requests:
|
|
7782
|
+
MS_PER_DAY3 = HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7;
|
|
7783
|
+
OpenRouterKeySchema = import_zod25.z.object({
|
|
7784
|
+
data: import_zod25.z.object({
|
|
7785
|
+
limit: import_zod25.z.number().nonnegative().nullable(),
|
|
7786
|
+
limit_remaining: import_zod25.z.number().nullable(),
|
|
7787
|
+
limit_reset: import_zod25.z.string().nullable(),
|
|
7788
|
+
is_free_tier: import_zod25.z.boolean().optional(),
|
|
7789
|
+
free_model_daily_requests: import_zod25.z.object({ used: import_zod25.z.number().nonnegative(), limit: import_zod25.z.number().nonnegative(), remaining: import_zod25.z.number() }).optional()
|
|
7765
7790
|
})
|
|
7766
7791
|
});
|
|
7767
|
-
OpenRouterCreditsSchema =
|
|
7792
|
+
OpenRouterCreditsSchema = import_zod25.z.object({ data: import_zod25.z.object({ total_credits: import_zod25.z.number().nonnegative(), total_usage: import_zod25.z.number().nonnegative() }) });
|
|
7768
7793
|
}
|
|
7769
7794
|
});
|
|
7770
7795
|
|
|
@@ -8029,6 +8054,8 @@ __export(index_exports, {
|
|
|
8029
8054
|
RcRateLimitWindowSchema: () => RcRateLimitWindowSchema,
|
|
8030
8055
|
RcStreamEnvelopeSchema: () => RcStreamEnvelopeSchema,
|
|
8031
8056
|
RcStreamEventSchema: () => RcStreamEventSchema,
|
|
8057
|
+
ResetRowSchema: () => ResetRowSchema,
|
|
8058
|
+
ResetScheduleSchema: () => ResetScheduleSchema,
|
|
8032
8059
|
USAGE_EVENT_SOURCE: () => USAGE_EVENT_SOURCE,
|
|
8033
8060
|
UpdateCheckOutputSchema: () => UpdateCheckOutputSchema,
|
|
8034
8061
|
UsageError: () => UsageError,
|
|
@@ -8073,6 +8100,7 @@ __export(index_exports, {
|
|
|
8073
8100
|
collectDoctorReport: () => collectDoctorReport,
|
|
8074
8101
|
collectFrontDoorStatus: () => collectFrontDoorStatus,
|
|
8075
8102
|
collectPoolPick: () => collectPoolPick,
|
|
8103
|
+
collectResets: () => collectResets,
|
|
8076
8104
|
createCodexApiRouter: () => createCodexApiRouter,
|
|
8077
8105
|
createConfigApiRouter: () => createConfigApiRouter,
|
|
8078
8106
|
createControlApiRouter: () => createControlApiRouter,
|
|
@@ -12356,7 +12384,7 @@ var PoolPickCandidateViewSchema = import_zod14.z.strictObject({
|
|
|
12356
12384
|
class: import_zod14.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
12357
12385
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
12358
12386
|
score: import_zod14.z.number().optional(),
|
|
12359
|
-
/** 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`. */
|
|
12387
|
+
/** 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`. */
|
|
12360
12388
|
scoreWindow: import_zod14.z.enum(["sevenDay", "fiveHour"]).optional(),
|
|
12361
12389
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
12362
12390
|
feasible: import_zod14.z.boolean(),
|
|
@@ -12474,9 +12502,79 @@ var CheckReportJsonSchema = import_zod15.z.strictObject({
|
|
|
12474
12502
|
init_middleware();
|
|
12475
12503
|
init_preflight();
|
|
12476
12504
|
|
|
12505
|
+
// src/usage/resets.ts
|
|
12506
|
+
init_preflight();
|
|
12507
|
+
init_rateLimit();
|
|
12508
|
+
var MS_PER_HOUR3 = 36e5;
|
|
12509
|
+
var HOURS_PER_DAY3 = 24;
|
|
12510
|
+
function formatPeriod(window) {
|
|
12511
|
+
if (window.periodMs === void 0) {
|
|
12512
|
+
return window.period ?? "unknown period";
|
|
12513
|
+
}
|
|
12514
|
+
const hours = window.periodMs / MS_PER_HOUR3;
|
|
12515
|
+
return hours >= HOURS_PER_DAY3 && Number.isInteger(hours / HOURS_PER_DAY3) ? `${String(hours / HOURS_PER_DAY3)}d` : `${String(hours)}h`;
|
|
12516
|
+
}
|
|
12517
|
+
function groupOf(row) {
|
|
12518
|
+
return row.resetsAt === void 0 ? 2 : row.reset ? 1 : 0;
|
|
12519
|
+
}
|
|
12520
|
+
function compareRows(left, right) {
|
|
12521
|
+
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);
|
|
12522
|
+
}
|
|
12523
|
+
function rowOf(snapshot, provider, window, observedAt2, recorded, nowMs) {
|
|
12524
|
+
const effective = effectiveWindow(recorded, nowMs);
|
|
12525
|
+
return {
|
|
12526
|
+
identity: snapshot.identity,
|
|
12527
|
+
provider,
|
|
12528
|
+
window,
|
|
12529
|
+
observedAt: observedAt2,
|
|
12530
|
+
...recorded.resetsAt === void 0 ? {} : { resetsAt: recorded.resetsAt },
|
|
12531
|
+
reset: effective.reset,
|
|
12532
|
+
...effective.utilization === void 0 ? {} : { utilization: effective.utilization },
|
|
12533
|
+
...effective.status === void 0 ? {} : { status: effective.status }
|
|
12534
|
+
};
|
|
12535
|
+
}
|
|
12536
|
+
function collectResets(snapshots, nowMs) {
|
|
12537
|
+
const rows = snapshots.flatMap(
|
|
12538
|
+
(snapshot) => Object.entries(snapshot.providers).flatMap(([provider, state]) => {
|
|
12539
|
+
const unified = state.rateLimit?.unified;
|
|
12540
|
+
const observedAt2 = state.rateLimit?.observedAt;
|
|
12541
|
+
const overage = unified === void 0 ? void 0 : soleOverageWindow(unified);
|
|
12542
|
+
const headerRows = observedAt2 === void 0 || unified === void 0 ? [] : [
|
|
12543
|
+
...unified.fiveHour === void 0 ? [] : [rowOf(snapshot, provider, "5h", observedAt2, unified.fiveHour, nowMs)],
|
|
12544
|
+
...unified.sevenDay === void 0 ? [] : [rowOf(snapshot, provider, "7d", observedAt2, unified.sevenDay, nowMs)],
|
|
12545
|
+
...overage === void 0 ? [] : [rowOf(snapshot, provider, "extra usage", observedAt2, overage, nowMs)]
|
|
12546
|
+
];
|
|
12547
|
+
const quota = state.quota;
|
|
12548
|
+
const quotaRows = quota === void 0 ? [] : quota.windows.map((window) => rowOf(snapshot, provider, `${window.measures} ${formatPeriod(window)}`, quota.observedAt, window, nowMs));
|
|
12549
|
+
return [...headerRows, ...quotaRows];
|
|
12550
|
+
})
|
|
12551
|
+
);
|
|
12552
|
+
return { resets: rows.sort(compareRows) };
|
|
12553
|
+
}
|
|
12554
|
+
|
|
12555
|
+
// src/usage/resetsSchema.ts
|
|
12556
|
+
var import_zod16 = require("zod");
|
|
12557
|
+
var ResetRowSchema = import_zod16.z.strictObject({
|
|
12558
|
+
identity: import_zod16.z.string(),
|
|
12559
|
+
provider: import_zod16.z.string(),
|
|
12560
|
+
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
12561
|
+
window: import_zod16.z.string(),
|
|
12562
|
+
/** When the state the window comes from was observed, as an ISO instant. */
|
|
12563
|
+
observedAt: import_zod16.z.iso.datetime(),
|
|
12564
|
+
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
12565
|
+
resetsAt: import_zod16.z.iso.datetime().optional(),
|
|
12566
|
+
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
12567
|
+
reset: import_zod16.z.boolean(),
|
|
12568
|
+
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
12569
|
+
utilization: import_zod16.z.number().optional(),
|
|
12570
|
+
/** The window's own status, for a window that has not reset yet. */
|
|
12571
|
+
status: import_zod16.z.string().optional()
|
|
12572
|
+
});
|
|
12573
|
+
var ResetScheduleSchema = import_zod16.z.strictObject({ resets: import_zod16.z.readonly(import_zod16.z.array(ResetRowSchema)) });
|
|
12574
|
+
|
|
12477
12575
|
// src/frontdoor/controlSchemas.ts
|
|
12478
12576
|
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
12479
|
-
var
|
|
12577
|
+
var import_zod21 = require("zod");
|
|
12480
12578
|
|
|
12481
12579
|
// src/doctorReport.ts
|
|
12482
12580
|
init_claudeShim();
|
|
@@ -12671,24 +12769,24 @@ function credentialsFilePath(farmRoot) {
|
|
|
12671
12769
|
}
|
|
12672
12770
|
|
|
12673
12771
|
// src/codex/siwcStore.ts
|
|
12674
|
-
var
|
|
12772
|
+
var import_zod20 = require("zod");
|
|
12675
12773
|
|
|
12676
12774
|
// src/codex/auth.ts
|
|
12677
|
-
var
|
|
12678
|
-
var AuthFileSchema =
|
|
12679
|
-
tokens:
|
|
12680
|
-
access_token:
|
|
12681
|
-
refresh_token:
|
|
12682
|
-
id_token:
|
|
12683
|
-
account_id:
|
|
12775
|
+
var import_zod18 = require("zod");
|
|
12776
|
+
var AuthFileSchema = import_zod18.z.looseObject({
|
|
12777
|
+
tokens: import_zod18.z.looseObject({
|
|
12778
|
+
access_token: import_zod18.z.string().optional(),
|
|
12779
|
+
refresh_token: import_zod18.z.string().optional(),
|
|
12780
|
+
id_token: import_zod18.z.string().optional(),
|
|
12781
|
+
account_id: import_zod18.z.string().optional()
|
|
12684
12782
|
}).nullish(),
|
|
12685
|
-
last_refresh:
|
|
12783
|
+
last_refresh: import_zod18.z.string().optional()
|
|
12686
12784
|
});
|
|
12687
|
-
var TokenGrantSchema =
|
|
12688
|
-
access_token:
|
|
12689
|
-
refresh_token:
|
|
12690
|
-
id_token:
|
|
12691
|
-
account_id:
|
|
12785
|
+
var TokenGrantSchema = import_zod18.z.looseObject({
|
|
12786
|
+
access_token: import_zod18.z.string().min(1).optional(),
|
|
12787
|
+
refresh_token: import_zod18.z.string().min(1).optional(),
|
|
12788
|
+
id_token: import_zod18.z.string().min(1).optional(),
|
|
12789
|
+
account_id: import_zod18.z.string().min(1).optional()
|
|
12692
12790
|
});
|
|
12693
12791
|
var CodexAuthError = class extends Error {
|
|
12694
12792
|
constructor(message) {
|
|
@@ -12698,41 +12796,41 @@ var CodexAuthError = class extends Error {
|
|
|
12698
12796
|
};
|
|
12699
12797
|
|
|
12700
12798
|
// src/codex/siwc.ts
|
|
12701
|
-
var
|
|
12799
|
+
var import_zod19 = require("zod");
|
|
12702
12800
|
var SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
12703
12801
|
var SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
12704
12802
|
var SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
12705
|
-
var TokenResponseSchema =
|
|
12706
|
-
access_token:
|
|
12707
|
-
refresh_token:
|
|
12708
|
-
id_token:
|
|
12709
|
-
expires_in:
|
|
12710
|
-
scope:
|
|
12803
|
+
var TokenResponseSchema = import_zod19.z.looseObject({
|
|
12804
|
+
access_token: import_zod19.z.string().min(1),
|
|
12805
|
+
refresh_token: import_zod19.z.string().min(1).optional(),
|
|
12806
|
+
id_token: import_zod19.z.string().min(1).optional(),
|
|
12807
|
+
expires_in: import_zod19.z.number().positive(),
|
|
12808
|
+
scope: import_zod19.z.string().optional()
|
|
12711
12809
|
});
|
|
12712
|
-
var JwtHeaderSchema =
|
|
12713
|
-
var IdTokenClaimsSchema =
|
|
12714
|
-
iss:
|
|
12715
|
-
sub:
|
|
12716
|
-
aud:
|
|
12717
|
-
exp:
|
|
12718
|
-
nonce:
|
|
12719
|
-
email:
|
|
12810
|
+
var JwtHeaderSchema = import_zod19.z.looseObject({ alg: import_zod19.z.string(), kid: import_zod19.z.string().optional() });
|
|
12811
|
+
var IdTokenClaimsSchema = import_zod19.z.looseObject({
|
|
12812
|
+
iss: import_zod19.z.string(),
|
|
12813
|
+
sub: import_zod19.z.string().min(1),
|
|
12814
|
+
aud: import_zod19.z.union([import_zod19.z.string(), import_zod19.z.array(import_zod19.z.string())]),
|
|
12815
|
+
exp: import_zod19.z.number(),
|
|
12816
|
+
nonce: import_zod19.z.string().optional(),
|
|
12817
|
+
email: import_zod19.z.string().optional()
|
|
12720
12818
|
});
|
|
12721
|
-
var JwksSchema =
|
|
12819
|
+
var JwksSchema = import_zod19.z.object({ keys: import_zod19.z.array(import_zod19.z.looseObject({ kid: import_zod19.z.string().optional(), kty: import_zod19.z.string() })) });
|
|
12722
12820
|
|
|
12723
12821
|
// src/codex/siwcStore.ts
|
|
12724
|
-
var SiwcGrantSchema =
|
|
12725
|
-
clientId:
|
|
12726
|
-
sub:
|
|
12727
|
-
email:
|
|
12728
|
-
idToken:
|
|
12729
|
-
accessToken:
|
|
12730
|
-
refreshToken:
|
|
12731
|
-
scopes:
|
|
12822
|
+
var SiwcGrantSchema = import_zod20.z.strictObject({
|
|
12823
|
+
clientId: import_zod20.z.string().min(1),
|
|
12824
|
+
sub: import_zod20.z.string().min(1),
|
|
12825
|
+
email: import_zod20.z.string().optional(),
|
|
12826
|
+
idToken: import_zod20.z.string().min(1),
|
|
12827
|
+
accessToken: import_zod20.z.string().min(1),
|
|
12828
|
+
refreshToken: import_zod20.z.string().min(1),
|
|
12829
|
+
scopes: import_zod20.z.array(import_zod20.z.string()).readonly(),
|
|
12732
12830
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
12733
|
-
expiresAt:
|
|
12831
|
+
expiresAt: import_zod20.z.number()
|
|
12734
12832
|
});
|
|
12735
|
-
var SiwcFileSchema =
|
|
12833
|
+
var SiwcFileSchema = import_zod20.z.strictObject({ registeredClientId: import_zod20.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
12736
12834
|
function parseSiwcFile(raw, filePath) {
|
|
12737
12835
|
let json;
|
|
12738
12836
|
try {
|
|
@@ -13355,90 +13453,90 @@ function collectDoctorReport(params) {
|
|
|
13355
13453
|
// src/frontdoor/controlSchemas.ts
|
|
13356
13454
|
init_schema2();
|
|
13357
13455
|
init_state();
|
|
13358
|
-
var UsageListOutputSchema =
|
|
13359
|
-
var UsageWindowsInputSchema =
|
|
13360
|
-
identity:
|
|
13361
|
-
provider:
|
|
13456
|
+
var UsageListOutputSchema = import_zod21.z.strictObject({ snapshots: import_zod21.z.readonly(import_zod21.z.array(UsageSnapshotSchema)) });
|
|
13457
|
+
var UsageWindowsInputSchema = import_zod21.z.strictObject({
|
|
13458
|
+
identity: import_zod21.z.string().min(1),
|
|
13459
|
+
provider: import_zod21.z.string().min(1).optional()
|
|
13362
13460
|
});
|
|
13363
|
-
var EffectiveWindowSchema =
|
|
13461
|
+
var EffectiveWindowSchema = import_zod21.z.strictObject({
|
|
13364
13462
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
13365
|
-
reset:
|
|
13463
|
+
reset: import_zod21.z.boolean(),
|
|
13366
13464
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
13367
|
-
utilization:
|
|
13465
|
+
utilization: import_zod21.z.number().optional(),
|
|
13368
13466
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
13369
|
-
resetsAtMs:
|
|
13467
|
+
resetsAtMs: import_zod21.z.number().optional(),
|
|
13370
13468
|
/** The window's own status, for a window that has not reset yet. */
|
|
13371
|
-
status:
|
|
13469
|
+
status: import_zod21.z.string().optional()
|
|
13372
13470
|
});
|
|
13373
|
-
var UsageWindowsOutputSchema =
|
|
13374
|
-
identity:
|
|
13375
|
-
provider:
|
|
13471
|
+
var UsageWindowsOutputSchema = import_zod21.z.strictObject({
|
|
13472
|
+
identity: import_zod21.z.string(),
|
|
13473
|
+
provider: import_zod21.z.string(),
|
|
13376
13474
|
/** When the rate-limit state the windows come from was observed. */
|
|
13377
|
-
observedAt:
|
|
13475
|
+
observedAt: import_zod21.z.iso.datetime().optional(),
|
|
13378
13476
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
13379
13477
|
sevenDay: EffectiveWindowSchema.optional()
|
|
13380
13478
|
});
|
|
13381
|
-
var UsageLiveOutputSchema =
|
|
13479
|
+
var UsageLiveOutputSchema = import_zod21.z.strictObject({
|
|
13382
13480
|
/** 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. */
|
|
13383
13481
|
latest: RcLiveRateLimitSchema.optional(),
|
|
13384
13482
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
13385
|
-
sessions:
|
|
13483
|
+
sessions: import_zod21.z.readonly(import_zod21.z.array(RcLiveRateLimitSchema))
|
|
13386
13484
|
});
|
|
13387
|
-
var FrontDoorSessionStatusSchema =
|
|
13388
|
-
pid:
|
|
13389
|
-
startedAt:
|
|
13390
|
-
alive:
|
|
13485
|
+
var FrontDoorSessionStatusSchema = import_zod21.z.strictObject({
|
|
13486
|
+
pid: import_zod21.z.int().positive(),
|
|
13487
|
+
startedAt: import_zod21.z.number(),
|
|
13488
|
+
alive: import_zod21.z.boolean()
|
|
13391
13489
|
});
|
|
13392
|
-
var HeadroomSocketTargetSchema =
|
|
13393
|
-
var FrontDoorStatusOutputSchema =
|
|
13490
|
+
var HeadroomSocketTargetSchema = import_zod21.z.union([import_zod21.z.strictObject({ socketPath: import_zod21.z.string() }), import_zod21.z.strictObject({ refused: import_zod21.z.string() })]);
|
|
13491
|
+
var FrontDoorStatusOutputSchema = import_zod21.z.strictObject({
|
|
13394
13492
|
state: FrontDoorStateSchema,
|
|
13395
|
-
supervisorAlive:
|
|
13396
|
-
sessions:
|
|
13493
|
+
supervisorAlive: import_zod21.z.boolean(),
|
|
13494
|
+
sessions: import_zod21.z.readonly(import_zod21.z.array(FrontDoorSessionStatusSchema)),
|
|
13397
13495
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
13398
|
-
logPath:
|
|
13399
|
-
logExists:
|
|
13496
|
+
logPath: import_zod21.z.string(),
|
|
13497
|
+
logExists: import_zod21.z.boolean()
|
|
13400
13498
|
});
|
|
13401
|
-
var FrontDoorSessionsOutputSchema =
|
|
13402
|
-
var CheckRunInputSchema =
|
|
13403
|
-
path:
|
|
13404
|
-
identity:
|
|
13499
|
+
var FrontDoorSessionsOutputSchema = import_zod21.z.strictObject({ sessions: import_zod21.z.readonly(import_zod21.z.array(FrontDoorSessionStatusSchema)) });
|
|
13500
|
+
var CheckRunInputSchema = import_zod21.z.strictObject({
|
|
13501
|
+
path: import_zod21.z.string().min(1),
|
|
13502
|
+
identity: import_zod21.z.string().min(1).optional()
|
|
13405
13503
|
}).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13406
|
-
var PoolPickInputSchema =
|
|
13407
|
-
pool:
|
|
13408
|
-
path:
|
|
13504
|
+
var PoolPickInputSchema = import_zod21.z.strictObject({
|
|
13505
|
+
pool: import_zod21.z.string().min(1),
|
|
13506
|
+
path: import_zod21.z.string().min(1)
|
|
13409
13507
|
}).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
13410
|
-
var DoctorFindingSchema =
|
|
13411
|
-
section:
|
|
13412
|
-
subject:
|
|
13413
|
-
severity:
|
|
13414
|
-
message:
|
|
13508
|
+
var DoctorFindingSchema = import_zod21.z.strictObject({
|
|
13509
|
+
section: import_zod21.z.enum(DOCTOR_SECTIONS),
|
|
13510
|
+
subject: import_zod21.z.string().optional(),
|
|
13511
|
+
severity: import_zod21.z.enum(DOCTOR_SEVERITIES),
|
|
13512
|
+
message: import_zod21.z.string()
|
|
13415
13513
|
});
|
|
13416
|
-
var DoctorRunOutputSchema =
|
|
13514
|
+
var DoctorRunOutputSchema = import_zod21.z.strictObject({
|
|
13417
13515
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
13418
|
-
ok:
|
|
13419
|
-
findings:
|
|
13516
|
+
ok: import_zod21.z.boolean(),
|
|
13517
|
+
findings: import_zod21.z.readonly(import_zod21.z.array(DoctorFindingSchema))
|
|
13420
13518
|
});
|
|
13421
|
-
var FrontDoorRestartOutputSchema =
|
|
13422
|
-
action:
|
|
13423
|
-
previousPid:
|
|
13519
|
+
var FrontDoorRestartOutputSchema = import_zod21.z.strictObject({
|
|
13520
|
+
action: import_zod21.z.literal("restarting"),
|
|
13521
|
+
previousPid: import_zod21.z.int().positive()
|
|
13424
13522
|
});
|
|
13425
|
-
var UpdateCheckOutputSchema =
|
|
13426
|
-
current:
|
|
13427
|
-
latest:
|
|
13428
|
-
action:
|
|
13523
|
+
var UpdateCheckOutputSchema = import_zod21.z.strictObject({
|
|
13524
|
+
current: import_zod21.z.string(),
|
|
13525
|
+
latest: import_zod21.z.string(),
|
|
13526
|
+
action: import_zod21.z.enum(["current", "available", "updated"])
|
|
13429
13527
|
});
|
|
13430
|
-
var CodexSignInSchema =
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13528
|
+
var CodexSignInSchema = import_zod21.z.discriminatedUnion("state", [
|
|
13529
|
+
import_zod21.z.strictObject({ state: import_zod21.z.literal("none") }),
|
|
13530
|
+
import_zod21.z.strictObject({ state: import_zod21.z.literal("signed-in"), email: import_zod21.z.string().optional(), planScope: import_zod21.z.boolean(), accessTokenExpiresAt: import_zod21.z.number() }),
|
|
13531
|
+
import_zod21.z.strictObject({ state: import_zod21.z.literal("unreadable"), message: import_zod21.z.string() })
|
|
13434
13532
|
]);
|
|
13435
|
-
var CodexStatusOutputSchema =
|
|
13533
|
+
var CodexStatusOutputSchema = import_zod21.z.strictObject({
|
|
13436
13534
|
signIn: CodexSignInSchema,
|
|
13437
|
-
codexProviders:
|
|
13535
|
+
codexProviders: import_zod21.z.readonly(import_zod21.z.array(import_zod21.z.string()))
|
|
13438
13536
|
});
|
|
13439
|
-
var CodexLogoutOutputSchema =
|
|
13440
|
-
hadGrant:
|
|
13441
|
-
revoked:
|
|
13537
|
+
var CodexLogoutOutputSchema = import_zod21.z.strictObject({
|
|
13538
|
+
hadGrant: import_zod21.z.boolean(),
|
|
13539
|
+
revoked: import_zod21.z.boolean()
|
|
13442
13540
|
});
|
|
13443
13541
|
|
|
13444
13542
|
// src/frontdoor/codexApi.ts
|
|
@@ -13594,131 +13692,131 @@ init_identity();
|
|
|
13594
13692
|
init_providersStore();
|
|
13595
13693
|
|
|
13596
13694
|
// src/frontdoor/configSchemas.ts
|
|
13597
|
-
var
|
|
13695
|
+
var import_zod22 = require("zod");
|
|
13598
13696
|
init_schema();
|
|
13599
|
-
var RemovalConfirmationSchema =
|
|
13600
|
-
var CredentialWriteSchema = (targets) =>
|
|
13601
|
-
sources:
|
|
13602
|
-
target:
|
|
13603
|
-
cache:
|
|
13697
|
+
var RemovalConfirmationSchema = import_zod22.z.boolean();
|
|
13698
|
+
var CredentialWriteSchema = (targets) => import_zod22.z.strictObject({
|
|
13699
|
+
sources: import_zod22.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
13700
|
+
target: import_zod22.z.enum(targets).optional(),
|
|
13701
|
+
cache: import_zod22.z.union([import_zod22.z.literal(false), CredentialCacheSchema]).optional()
|
|
13604
13702
|
});
|
|
13605
|
-
var CredentialSummarySchema2 =
|
|
13606
|
-
target:
|
|
13607
|
-
sources:
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13703
|
+
var CredentialSummarySchema2 = import_zod22.z.strictObject({
|
|
13704
|
+
target: import_zod22.z.enum(CREDENTIAL_TARGETS),
|
|
13705
|
+
sources: import_zod22.z.readonly(import_zod22.z.array(
|
|
13706
|
+
import_zod22.z.discriminatedUnion("kind", [
|
|
13707
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("env"), variable: import_zod22.z.string() }),
|
|
13708
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("file"), path: import_zod22.z.string() }),
|
|
13709
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("command"), program: import_zod22.z.string() }),
|
|
13710
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("op"), reference: import_zod22.z.string() }),
|
|
13711
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("keychain"), service: import_zod22.z.string(), account: import_zod22.z.string().optional() }),
|
|
13712
|
+
import_zod22.z.strictObject({ kind: import_zod22.z.literal("literal") })
|
|
13615
13713
|
])
|
|
13616
13714
|
)),
|
|
13617
13715
|
cache: CredentialCacheSchema.optional()
|
|
13618
13716
|
});
|
|
13619
|
-
var mutationOutput = (kind, action) =>
|
|
13620
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
13621
|
-
var IdentityValueSchema =
|
|
13622
|
-
name:
|
|
13623
|
-
defaultConfigProfile:
|
|
13624
|
-
allowAmbientCredential:
|
|
13717
|
+
var mutationOutput = (kind, action) => import_zod22.z.strictObject({ action: import_zod22.z.literal(action), kind: import_zod22.z.literal(kind), name: import_zod22.z.string() });
|
|
13718
|
+
var storedMutationOutput = (kind, action, value) => import_zod22.z.strictObject({ action: import_zod22.z.literal(action), kind: import_zod22.z.literal(kind), name: import_zod22.z.string(), value });
|
|
13719
|
+
var IdentityValueSchema = import_zod22.z.strictObject({
|
|
13720
|
+
name: import_zod22.z.string(),
|
|
13721
|
+
defaultConfigProfile: import_zod22.z.string().optional(),
|
|
13722
|
+
allowAmbientCredential: import_zod22.z.boolean(),
|
|
13625
13723
|
credential: CredentialSummarySchema2.optional()
|
|
13626
13724
|
});
|
|
13627
13725
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
13628
|
-
var ProviderValueSchema =
|
|
13629
|
-
name:
|
|
13630
|
-
kind:
|
|
13631
|
-
displayName:
|
|
13632
|
-
baseUrl:
|
|
13726
|
+
var ProviderValueSchema = import_zod22.z.strictObject({
|
|
13727
|
+
name: import_zod22.z.string(),
|
|
13728
|
+
kind: import_zod22.z.enum(PROVIDER_KINDS),
|
|
13729
|
+
displayName: import_zod22.z.string(),
|
|
13730
|
+
baseUrl: import_zod22.z.string().optional(),
|
|
13633
13731
|
codex: CodexProviderConfigSchema.optional(),
|
|
13634
13732
|
credential: CredentialSummarySchema2,
|
|
13635
|
-
env:
|
|
13733
|
+
env: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).optional()
|
|
13636
13734
|
});
|
|
13637
|
-
var ConfigNameInputSchema =
|
|
13735
|
+
var ConfigNameInputSchema = import_zod22.z.strictObject({ name: import_zod22.z.string().min(1) });
|
|
13638
13736
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
13639
|
-
var ConfigIdentitySetInputSchema =
|
|
13640
|
-
name:
|
|
13641
|
-
defaultConfigProfile:
|
|
13642
|
-
allowAmbientCredential:
|
|
13643
|
-
credential:
|
|
13737
|
+
var ConfigIdentitySetInputSchema = import_zod22.z.strictObject({
|
|
13738
|
+
name: import_zod22.z.string().min(1),
|
|
13739
|
+
defaultConfigProfile: import_zod22.z.union([import_zod22.z.string().min(1), import_zod22.z.literal(false)]).optional(),
|
|
13740
|
+
allowAmbientCredential: import_zod22.z.boolean().optional(),
|
|
13741
|
+
credential: import_zod22.z.union([import_zod22.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
|
|
13644
13742
|
});
|
|
13645
13743
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
13646
|
-
var ConfigIdentityRemoveInputSchema =
|
|
13744
|
+
var ConfigIdentityRemoveInputSchema = import_zod22.z.strictObject({ name: import_zod22.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13647
13745
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
13648
13746
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
13649
|
-
var ConfigProfileAddInputSchema =
|
|
13650
|
-
name:
|
|
13651
|
-
extends:
|
|
13652
|
-
description:
|
|
13747
|
+
var ConfigProfileAddInputSchema = import_zod22.z.strictObject({
|
|
13748
|
+
name: import_zod22.z.string().min(1),
|
|
13749
|
+
extends: import_zod22.z.array(import_zod22.z.string().min(1)).optional(),
|
|
13750
|
+
description: import_zod22.z.string().optional()
|
|
13653
13751
|
});
|
|
13654
13752
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
13655
|
-
var ConfigProfileSetInputSchema =
|
|
13656
|
-
name:
|
|
13657
|
-
category:
|
|
13658
|
-
entry:
|
|
13659
|
-
extends:
|
|
13660
|
-
description:
|
|
13661
|
-
launch:
|
|
13662
|
-
skipPermissions:
|
|
13663
|
-
remoteControl:
|
|
13664
|
-
headroom:
|
|
13665
|
-
trackUsage:
|
|
13666
|
-
provider:
|
|
13667
|
-
claudeVersion:
|
|
13753
|
+
var ConfigProfileSetInputSchema = import_zod22.z.strictObject({
|
|
13754
|
+
name: import_zod22.z.string().min(1),
|
|
13755
|
+
category: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.boolean()).optional(),
|
|
13756
|
+
entry: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.boolean()).optional(),
|
|
13757
|
+
extends: import_zod22.z.union([import_zod22.z.array(import_zod22.z.string().min(1)), import_zod22.z.literal(false)]).optional(),
|
|
13758
|
+
description: import_zod22.z.union([import_zod22.z.string(), import_zod22.z.literal(false)]).optional(),
|
|
13759
|
+
launch: import_zod22.z.strictObject({
|
|
13760
|
+
skipPermissions: import_zod22.z.boolean().optional(),
|
|
13761
|
+
remoteControl: import_zod22.z.boolean().optional(),
|
|
13762
|
+
headroom: import_zod22.z.boolean().optional(),
|
|
13763
|
+
trackUsage: import_zod22.z.boolean().optional(),
|
|
13764
|
+
provider: import_zod22.z.union([import_zod22.z.string().min(1), import_zod22.z.literal(false)]).optional(),
|
|
13765
|
+
claudeVersion: import_zod22.z.union([import_zod22.z.string().min(1), import_zod22.z.literal(false)]).optional()
|
|
13668
13766
|
}).optional()
|
|
13669
13767
|
});
|
|
13670
13768
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
13671
|
-
var ConfigProfileRemoveInputSchema =
|
|
13769
|
+
var ConfigProfileRemoveInputSchema = import_zod22.z.strictObject({ name: import_zod22.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13672
13770
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
13673
13771
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
13674
|
-
var PoolMembersInputSchema =
|
|
13675
|
-
var ConfigPoolAddInputSchema =
|
|
13676
|
-
name:
|
|
13772
|
+
var PoolMembersInputSchema = import_zod22.z.array(import_zod22.z.string().min(1)).min(1);
|
|
13773
|
+
var ConfigPoolAddInputSchema = import_zod22.z.strictObject({
|
|
13774
|
+
name: import_zod22.z.string().min(1),
|
|
13677
13775
|
identities: PoolMembersInputSchema,
|
|
13678
|
-
preference:
|
|
13776
|
+
preference: import_zod22.z.enum(POOL_PREFERENCES).optional()
|
|
13679
13777
|
});
|
|
13680
13778
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
13681
|
-
var ConfigPoolSetInputSchema =
|
|
13682
|
-
name:
|
|
13779
|
+
var ConfigPoolSetInputSchema = import_zod22.z.strictObject({
|
|
13780
|
+
name: import_zod22.z.string().min(1),
|
|
13683
13781
|
identities: PoolMembersInputSchema.optional(),
|
|
13684
|
-
preference:
|
|
13782
|
+
preference: import_zod22.z.union([import_zod22.z.enum(POOL_PREFERENCES), import_zod22.z.literal(false)]).optional()
|
|
13685
13783
|
});
|
|
13686
13784
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
13687
|
-
var ConfigPoolRemoveInputSchema =
|
|
13785
|
+
var ConfigPoolRemoveInputSchema = import_zod22.z.strictObject({ name: import_zod22.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13688
13786
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
13689
13787
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
13690
|
-
var ConfigProviderAddInputSchema =
|
|
13691
|
-
name:
|
|
13692
|
-
kind:
|
|
13693
|
-
displayName:
|
|
13694
|
-
baseUrl:
|
|
13788
|
+
var ConfigProviderAddInputSchema = import_zod22.z.strictObject({
|
|
13789
|
+
name: import_zod22.z.string().min(1),
|
|
13790
|
+
kind: import_zod22.z.enum(PROVIDER_KINDS).optional(),
|
|
13791
|
+
displayName: import_zod22.z.string().min(1),
|
|
13792
|
+
baseUrl: import_zod22.z.string().min(1).optional(),
|
|
13695
13793
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
13696
13794
|
codex: CodexProviderConfigSchema.optional()
|
|
13697
13795
|
});
|
|
13698
13796
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
13699
|
-
var ConfigProviderSetInputSchema =
|
|
13700
|
-
name:
|
|
13701
|
-
displayName:
|
|
13702
|
-
baseUrl:
|
|
13797
|
+
var ConfigProviderSetInputSchema = import_zod22.z.strictObject({
|
|
13798
|
+
name: import_zod22.z.string().min(1),
|
|
13799
|
+
displayName: import_zod22.z.string().min(1).optional(),
|
|
13800
|
+
baseUrl: import_zod22.z.string().min(1).optional(),
|
|
13703
13801
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
13704
13802
|
codex: CodexProviderConfigSchema.optional()
|
|
13705
13803
|
});
|
|
13706
13804
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
13707
|
-
var ConfigProviderRemoveInputSchema =
|
|
13805
|
+
var ConfigProviderRemoveInputSchema = import_zod22.z.strictObject({ name: import_zod22.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13708
13806
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
13709
|
-
var ConfigRuleAddInputSchema =
|
|
13710
|
-
path:
|
|
13711
|
-
configProfile:
|
|
13712
|
-
identity:
|
|
13807
|
+
var ConfigRuleAddInputSchema = import_zod22.z.strictObject({
|
|
13808
|
+
path: import_zod22.z.string().min(1),
|
|
13809
|
+
configProfile: import_zod22.z.string().min(1).optional(),
|
|
13810
|
+
identity: import_zod22.z.string().min(1).optional()
|
|
13713
13811
|
});
|
|
13714
13812
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
13715
|
-
var ConfigRuleSetInputSchema =
|
|
13716
|
-
path:
|
|
13717
|
-
configProfile:
|
|
13718
|
-
identity:
|
|
13813
|
+
var ConfigRuleSetInputSchema = import_zod22.z.strictObject({
|
|
13814
|
+
path: import_zod22.z.string().min(1),
|
|
13815
|
+
configProfile: import_zod22.z.union([import_zod22.z.string().min(1), import_zod22.z.literal(false)]).optional(),
|
|
13816
|
+
identity: import_zod22.z.union([import_zod22.z.string().min(1), import_zod22.z.literal(false)]).optional()
|
|
13719
13817
|
});
|
|
13720
13818
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
13721
|
-
var ConfigRuleRemoveInputSchema =
|
|
13819
|
+
var ConfigRuleRemoveInputSchema = import_zod22.z.strictObject({ path: import_zod22.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
13722
13820
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
13723
13821
|
|
|
13724
13822
|
// src/frontdoor/configApi.ts
|
|
@@ -14024,41 +14122,41 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
14024
14122
|
var import_server3 = require("@orpc/server");
|
|
14025
14123
|
|
|
14026
14124
|
// src/frontdoor/eventSchemas.ts
|
|
14027
|
-
var
|
|
14125
|
+
var import_zod23 = require("zod");
|
|
14028
14126
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
14029
14127
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
14030
14128
|
var USAGE_EVENT_SOURCE = "usage";
|
|
14031
14129
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
14032
14130
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
14033
|
-
var DoorEventSchema =
|
|
14034
|
-
source:
|
|
14131
|
+
var DoorEventSchema = import_zod23.z.strictObject({
|
|
14132
|
+
source: import_zod23.z.string().min(1),
|
|
14035
14133
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
14036
|
-
sequence:
|
|
14037
|
-
payload:
|
|
14134
|
+
sequence: import_zod23.z.number().int().positive(),
|
|
14135
|
+
payload: import_zod23.z.unknown()
|
|
14038
14136
|
});
|
|
14039
|
-
var DoorEventSourceQuerySchema =
|
|
14040
|
-
sources:
|
|
14137
|
+
var DoorEventSourceQuerySchema = import_zod23.z.strictObject({
|
|
14138
|
+
sources: import_zod23.z.array(import_zod23.z.string().min(1)).min(1).optional()
|
|
14041
14139
|
});
|
|
14042
|
-
var LaunchLifecycleEventSchema =
|
|
14043
|
-
kind:
|
|
14044
|
-
pid:
|
|
14045
|
-
startedAt:
|
|
14046
|
-
observedAt:
|
|
14140
|
+
var LaunchLifecycleEventSchema = import_zod23.z.strictObject({
|
|
14141
|
+
kind: import_zod23.z.enum(["registered", "pruned", "ended"]),
|
|
14142
|
+
pid: import_zod23.z.number().int().positive(),
|
|
14143
|
+
startedAt: import_zod23.z.number(),
|
|
14144
|
+
observedAt: import_zod23.z.number()
|
|
14047
14145
|
});
|
|
14048
|
-
var DoorHealthEventSchema =
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14146
|
+
var DoorHealthEventSchema = import_zod23.z.discriminatedUnion("kind", [
|
|
14147
|
+
import_zod23.z.strictObject({ kind: import_zod23.z.literal("generation"), pid: import_zod23.z.number().int().positive(), providerPort: import_zod23.z.number().int().positive(), connectPort: import_zod23.z.number().int().positive(), directPort: import_zod23.z.number().int().positive(), observedAt: import_zod23.z.number() }),
|
|
14148
|
+
import_zod23.z.strictObject({ kind: import_zod23.z.literal("listenerFailed"), pid: import_zod23.z.number().int().positive(), listener: import_zod23.z.enum(["provider", "connect", "direct"]), message: import_zod23.z.string(), observedAt: import_zod23.z.number() }),
|
|
14149
|
+
import_zod23.z.strictObject({ kind: import_zod23.z.literal("binaryTurnover"), pid: import_zod23.z.number().int().positive(), observedAt: import_zod23.z.number() }),
|
|
14150
|
+
import_zod23.z.strictObject({ kind: import_zod23.z.literal("idleShutdown"), pid: import_zod23.z.number().int().positive(), observedAt: import_zod23.z.number() })
|
|
14053
14151
|
]);
|
|
14054
|
-
var QuotaExpiringEventSchema =
|
|
14055
|
-
identity:
|
|
14056
|
-
provider:
|
|
14057
|
-
window:
|
|
14152
|
+
var QuotaExpiringEventSchema = import_zod23.z.strictObject({
|
|
14153
|
+
identity: import_zod23.z.string().min(1),
|
|
14154
|
+
provider: import_zod23.z.string().min(1),
|
|
14155
|
+
window: import_zod23.z.enum(["fiveHour", "sevenDay"]),
|
|
14058
14156
|
/** 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. */
|
|
14059
|
-
utilization:
|
|
14060
|
-
resetsAt:
|
|
14061
|
-
observedAt:
|
|
14157
|
+
utilization: import_zod23.z.number().min(0).max(1),
|
|
14158
|
+
resetsAt: import_zod23.z.iso.datetime(),
|
|
14159
|
+
observedAt: import_zod23.z.number()
|
|
14062
14160
|
});
|
|
14063
14161
|
|
|
14064
14162
|
// src/frontdoor/eventsApi.ts
|
|
@@ -14142,51 +14240,51 @@ init_cliError();
|
|
|
14142
14240
|
|
|
14143
14241
|
// src/frontdoor/launchSchemas.ts
|
|
14144
14242
|
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
14145
|
-
var
|
|
14243
|
+
var import_zod24 = require("zod");
|
|
14146
14244
|
init_claudeVersion();
|
|
14147
14245
|
init_identity();
|
|
14148
|
-
var LaunchResolveInputSchema =
|
|
14149
|
-
path:
|
|
14246
|
+
var LaunchResolveInputSchema = import_zod24.z.strictObject({
|
|
14247
|
+
path: import_zod24.z.string().min(1),
|
|
14150
14248
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
14151
|
-
argv:
|
|
14249
|
+
argv: import_zod24.z.readonly(import_zod24.z.array(import_zod24.z.string())).optional(),
|
|
14152
14250
|
/** 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. */
|
|
14153
|
-
env:
|
|
14251
|
+
env: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.string()).optional()
|
|
14154
14252
|
}).refine((input) => import_node_path31.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
14155
|
-
var LaunchPoolDecisionSchema =
|
|
14156
|
-
name:
|
|
14157
|
-
reasons:
|
|
14158
|
-
movedOff:
|
|
14253
|
+
var LaunchPoolDecisionSchema = import_zod24.z.strictObject({
|
|
14254
|
+
name: import_zod24.z.string(),
|
|
14255
|
+
reasons: import_zod24.z.readonly(import_zod24.z.array(import_zod24.z.string())),
|
|
14256
|
+
movedOff: import_zod24.z.strictObject({ identity: import_zod24.z.string(), reason: import_zod24.z.string() }).optional()
|
|
14159
14257
|
});
|
|
14160
|
-
var LaunchDecisionSchema =
|
|
14161
|
-
identity:
|
|
14162
|
-
identitySource:
|
|
14258
|
+
var LaunchDecisionSchema = import_zod24.z.strictObject({
|
|
14259
|
+
identity: import_zod24.z.string().optional(),
|
|
14260
|
+
identitySource: import_zod24.z.enum(IDENTITY_DECISION_SOURCES),
|
|
14163
14261
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
14164
|
-
configDirEscapeHatch:
|
|
14165
|
-
configDir:
|
|
14166
|
-
configProfile:
|
|
14167
|
-
configProfileSource:
|
|
14168
|
-
provider:
|
|
14262
|
+
configDirEscapeHatch: import_zod24.z.boolean(),
|
|
14263
|
+
configDir: import_zod24.z.string().optional(),
|
|
14264
|
+
configProfile: import_zod24.z.string().optional(),
|
|
14265
|
+
configProfileSource: import_zod24.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
14266
|
+
provider: import_zod24.z.string().optional()
|
|
14169
14267
|
});
|
|
14170
|
-
var LaunchFlagsSchema =
|
|
14171
|
-
skipPermissions:
|
|
14172
|
-
remoteControl:
|
|
14173
|
-
headroom:
|
|
14174
|
-
trackUsage:
|
|
14268
|
+
var LaunchFlagsSchema = import_zod24.z.strictObject({
|
|
14269
|
+
skipPermissions: import_zod24.z.boolean(),
|
|
14270
|
+
remoteControl: import_zod24.z.boolean(),
|
|
14271
|
+
headroom: import_zod24.z.boolean(),
|
|
14272
|
+
trackUsage: import_zod24.z.boolean()
|
|
14175
14273
|
});
|
|
14176
|
-
var LaunchResolveOutputSchema =
|
|
14274
|
+
var LaunchResolveOutputSchema = import_zod24.z.strictObject({
|
|
14177
14275
|
decision: LaunchDecisionSchema,
|
|
14178
14276
|
flags: LaunchFlagsSchema,
|
|
14179
|
-
claudeVersion:
|
|
14277
|
+
claudeVersion: import_zod24.z.strictObject({ version: import_zod24.z.string(), source: import_zod24.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
14180
14278
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
14181
|
-
bin:
|
|
14279
|
+
bin: import_zod24.z.string(),
|
|
14182
14280
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
14183
|
-
args:
|
|
14281
|
+
args: import_zod24.z.readonly(import_zod24.z.array(import_zod24.z.string())),
|
|
14184
14282
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
14185
|
-
credential:
|
|
14186
|
-
routing:
|
|
14283
|
+
credential: import_zod24.z.strictObject({ subject: import_zod24.z.enum(["provider", "identity"]), name: import_zod24.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
14284
|
+
routing: import_zod24.z.strictObject({ frontDoor: import_zod24.z.boolean(), headroom: import_zod24.z.boolean() }),
|
|
14187
14285
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
14188
|
-
environment:
|
|
14189
|
-
warnings:
|
|
14286
|
+
environment: import_zod24.z.readonly(import_zod24.z.array(import_zod24.z.string())),
|
|
14287
|
+
warnings: import_zod24.z.readonly(import_zod24.z.array(import_zod24.z.string()))
|
|
14190
14288
|
});
|
|
14191
14289
|
|
|
14192
14290
|
// src/frontdoor/launchApi.ts
|
|
@@ -14230,6 +14328,7 @@ function createControlApiRouter(deps) {
|
|
|
14230
14328
|
return {
|
|
14231
14329
|
usage: {
|
|
14232
14330
|
list: authed.meta((0, import_openapi7.openapi)({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] })).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
14331
|
+
resets: authed.meta((0, import_openapi7.openapi)({ 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())),
|
|
14233
14332
|
effectiveWindow: authed.meta((0, import_openapi7.openapi)({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] })).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input }) => {
|
|
14234
14333
|
const snapshot = deps.usageSnapshotOf(input.identity);
|
|
14235
14334
|
if (snapshot === void 0) {
|
|
@@ -14551,11 +14650,11 @@ function createDoorHealthPublisher(hub, now, pid) {
|
|
|
14551
14650
|
|
|
14552
14651
|
// src/frontdoor/quotaExpiringEvents.ts
|
|
14553
14652
|
init_schema2();
|
|
14554
|
-
var
|
|
14653
|
+
var MS_PER_HOUR4 = 36e5;
|
|
14555
14654
|
var MS_PER_DAY2 = 864e5;
|
|
14556
14655
|
var FIVE_HOUR_WINDOW_HOURS = 5;
|
|
14557
14656
|
var SEVEN_DAY_WINDOW_DAYS = 7;
|
|
14558
|
-
var FIVE_HOUR_WINDOW_MS2 = FIVE_HOUR_WINDOW_HOURS *
|
|
14657
|
+
var FIVE_HOUR_WINDOW_MS2 = FIVE_HOUR_WINDOW_HOURS * MS_PER_HOUR4;
|
|
14559
14658
|
var SEVEN_DAY_WINDOW_MS2 = SEVEN_DAY_WINDOW_DAYS * MS_PER_DAY2;
|
|
14560
14659
|
var FINAL_SPAN_DENOMINATOR = 30;
|
|
14561
14660
|
var QUOTA_EXPIRING_WINDOW_FRACTION = 1 / FINAL_SPAN_DENOMINATOR;
|
|
@@ -14996,7 +15095,7 @@ function numberOf(record, field) {
|
|
|
14996
15095
|
}
|
|
14997
15096
|
return void 0;
|
|
14998
15097
|
}
|
|
14999
|
-
function pageOfRcChannel(url, rows, idOf,
|
|
15098
|
+
function pageOfRcChannel(url, rows, idOf, rowOf2) {
|
|
15000
15099
|
const query = new URL(url, "http://127.0.0.1").searchParams;
|
|
15001
15100
|
const anchor = query.get("after_event_id") ?? query.get("cursor");
|
|
15002
15101
|
const rawLimit = query.get("limit");
|
|
@@ -15010,7 +15109,7 @@ function pageOfRcChannel(url, rows, idOf, rowOf) {
|
|
|
15010
15109
|
}
|
|
15011
15110
|
const page = limit === void 0 ? rows.slice(from) : rows.slice(from, from + limit);
|
|
15012
15111
|
const last = page[page.length - 1];
|
|
15013
|
-
return { data: page.map(
|
|
15112
|
+
return { data: page.map(rowOf2), ...last === void 0 ? {} : { next_cursor: idOf(last) } };
|
|
15014
15113
|
}
|
|
15015
15114
|
async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
15016
15115
|
const { request: request4, response, host } = ctx;
|
|
@@ -16597,6 +16696,8 @@ init_ownCli();
|
|
|
16597
16696
|
RcRateLimitWindowSchema,
|
|
16598
16697
|
RcStreamEnvelopeSchema,
|
|
16599
16698
|
RcStreamEventSchema,
|
|
16699
|
+
ResetRowSchema,
|
|
16700
|
+
ResetScheduleSchema,
|
|
16600
16701
|
USAGE_EVENT_SOURCE,
|
|
16601
16702
|
UpdateCheckOutputSchema,
|
|
16602
16703
|
UsageError,
|
|
@@ -16641,6 +16742,7 @@ init_ownCli();
|
|
|
16641
16742
|
collectDoctorReport,
|
|
16642
16743
|
collectFrontDoorStatus,
|
|
16643
16744
|
collectPoolPick,
|
|
16745
|
+
collectResets,
|
|
16644
16746
|
createCodexApiRouter,
|
|
16645
16747
|
createConfigApiRouter,
|
|
16646
16748
|
createControlApiRouter,
|