claude-use 9.10.1 → 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/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.10.1",
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 score = remaining * plan.capacity / (untilResetMs / MS_PER_HOUR2);
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: basis.name, reasons: [...windowReasons.map((reason, index) => index === windowReasons.length - 1 ? `${reason}${observedAgo}` : reason), ...planReasons] },
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 z16 } from "zod";
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 = z16.strictObject({
6056
- targetPath: z16.string().min(1),
6057
- method: z16.enum(["hardlink", "copy"]),
6058
- installedAtMs: z16.number()
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 z24 } from "zod";
7694
- var MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY3, 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;
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
- HOURS_PER_DAY3 = 24;
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 * HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7]
7734
+ [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7]
7710
7735
  ]);
7711
- ZaiLimitSchema = z24.object({
7712
- type: z24.string(),
7713
- unit: z24.number().int(),
7714
- number: z24.number().int().positive(),
7715
- percentage: z24.number().nonnegative(),
7716
- nextResetTime: z24.number().positive().optional(),
7717
- usage: z24.number().nonnegative().optional(),
7718
- currentValue: z24.number().nonnegative().optional(),
7719
- remaining: z24.number().nonnegative().optional()
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 = z24.object({
7722
- success: z24.boolean(),
7723
- msg: z24.string().optional(),
7724
- data: z24.object({ level: z24.string().optional(), limits: z24.array(ZaiLimitSchema) })
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 = HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7;
7730
- OpenRouterKeySchema = z24.object({
7731
- data: z24.object({
7732
- limit: z24.number().nonnegative().nullable(),
7733
- limit_remaining: z24.number().nullable(),
7734
- limit_reset: z24.string().nullable(),
7735
- is_free_tier: z24.boolean().optional(),
7736
- free_model_daily_requests: z24.object({ used: z24.number().nonnegative(), limit: z24.number().nonnegative(), remaining: z24.number() }).optional()
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 = z24.object({ data: z24.object({ total_credits: z24.number().nonnegative(), total_usage: z24.number().nonnegative() }) });
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 z20 } from "zod";
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 z19 } from "zod";
12387
+ import { z as z20 } from "zod";
12293
12388
 
12294
12389
  // src/codex/auth.ts
12295
- import { z as z17 } from "zod";
12296
- var AuthFileSchema = z17.looseObject({
12297
- tokens: z17.looseObject({
12298
- access_token: z17.string().optional(),
12299
- refresh_token: z17.string().optional(),
12300
- id_token: z17.string().optional(),
12301
- account_id: z17.string().optional()
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: z17.string().optional()
12398
+ last_refresh: z18.string().optional()
12304
12399
  });
12305
- var TokenGrantSchema = z17.looseObject({
12306
- access_token: z17.string().min(1).optional(),
12307
- refresh_token: z17.string().min(1).optional(),
12308
- id_token: z17.string().min(1).optional(),
12309
- account_id: z17.string().min(1).optional()
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 z18 } from "zod";
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 = z18.looseObject({
12324
- access_token: z18.string().min(1),
12325
- refresh_token: z18.string().min(1).optional(),
12326
- id_token: z18.string().min(1).optional(),
12327
- expires_in: z18.number().positive(),
12328
- scope: z18.string().optional()
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 = z18.looseObject({ alg: z18.string(), kid: z18.string().optional() });
12331
- var IdTokenClaimsSchema = z18.looseObject({
12332
- iss: z18.string(),
12333
- sub: z18.string().min(1),
12334
- aud: z18.union([z18.string(), z18.array(z18.string())]),
12335
- exp: z18.number(),
12336
- nonce: z18.string().optional(),
12337
- email: z18.string().optional()
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 = z18.object({ keys: z18.array(z18.looseObject({ kid: z18.string().optional(), kty: z18.string() })) });
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 = z19.strictObject({
12343
- clientId: z19.string().min(1),
12344
- sub: z19.string().min(1),
12345
- email: z19.string().optional(),
12346
- idToken: z19.string().min(1),
12347
- accessToken: z19.string().min(1),
12348
- refreshToken: z19.string().min(1),
12349
- scopes: z19.array(z19.string()).readonly(),
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: z19.number()
12446
+ expiresAt: z20.number()
12352
12447
  });
12353
- var SiwcFileSchema = z19.strictObject({ registeredClientId: z19.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
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 = z20.strictObject({ snapshots: z20.readonly(z20.array(UsageSnapshotSchema)) });
12977
- var UsageWindowsInputSchema = z20.strictObject({
12978
- identity: z20.string().min(1),
12979
- provider: z20.string().min(1).optional()
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 = z20.strictObject({
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: z20.boolean(),
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: z20.number().optional(),
13080
+ utilization: z21.number().optional(),
12986
13081
  /** The reset instant, for a window that has not reset yet and reported one. */
12987
- resetsAtMs: z20.number().optional(),
13082
+ resetsAtMs: z21.number().optional(),
12988
13083
  /** The window's own status, for a window that has not reset yet. */
12989
- status: z20.string().optional()
13084
+ status: z21.string().optional()
12990
13085
  });
12991
- var UsageWindowsOutputSchema = z20.strictObject({
12992
- identity: z20.string(),
12993
- provider: z20.string(),
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: z20.iso.datetime().optional(),
13090
+ observedAt: z21.iso.datetime().optional(),
12996
13091
  fiveHour: EffectiveWindowSchema.optional(),
12997
13092
  sevenDay: EffectiveWindowSchema.optional()
12998
13093
  });
12999
- var UsageLiveOutputSchema = z20.strictObject({
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: z20.readonly(z20.array(RcLiveRateLimitSchema))
13098
+ sessions: z21.readonly(z21.array(RcLiveRateLimitSchema))
13004
13099
  });
13005
- var FrontDoorSessionStatusSchema = z20.strictObject({
13006
- pid: z20.int().positive(),
13007
- startedAt: z20.number(),
13008
- alive: z20.boolean()
13100
+ var FrontDoorSessionStatusSchema = z21.strictObject({
13101
+ pid: z21.int().positive(),
13102
+ startedAt: z21.number(),
13103
+ alive: z21.boolean()
13009
13104
  });
13010
- var HeadroomSocketTargetSchema = z20.union([z20.strictObject({ socketPath: z20.string() }), z20.strictObject({ refused: z20.string() })]);
13011
- var FrontDoorStatusOutputSchema = z20.strictObject({
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: z20.boolean(),
13014
- sessions: z20.readonly(z20.array(FrontDoorSessionStatusSchema)),
13108
+ supervisorAlive: z21.boolean(),
13109
+ sessions: z21.readonly(z21.array(FrontDoorSessionStatusSchema)),
13015
13110
  headroomSocket: HeadroomSocketTargetSchema.optional(),
13016
- logPath: z20.string(),
13017
- logExists: z20.boolean()
13111
+ logPath: z21.string(),
13112
+ logExists: z21.boolean()
13018
13113
  });
13019
- var FrontDoorSessionsOutputSchema = z20.strictObject({ sessions: z20.readonly(z20.array(FrontDoorSessionStatusSchema)) });
13020
- var CheckRunInputSchema = z20.strictObject({
13021
- path: z20.string().min(1),
13022
- identity: z20.string().min(1).optional()
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 = z20.strictObject({
13025
- pool: z20.string().min(1),
13026
- path: z20.string().min(1)
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 = z20.strictObject({
13029
- section: z20.enum(DOCTOR_SECTIONS),
13030
- subject: z20.string().optional(),
13031
- severity: z20.enum(DOCTOR_SEVERITIES),
13032
- message: z20.string()
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 = z20.strictObject({
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: z20.boolean(),
13037
- findings: z20.readonly(z20.array(DoctorFindingSchema))
13131
+ ok: z21.boolean(),
13132
+ findings: z21.readonly(z21.array(DoctorFindingSchema))
13038
13133
  });
13039
- var FrontDoorRestartOutputSchema = z20.strictObject({
13040
- action: z20.literal("restarting"),
13041
- previousPid: z20.int().positive()
13134
+ var FrontDoorRestartOutputSchema = z21.strictObject({
13135
+ action: z21.literal("restarting"),
13136
+ previousPid: z21.int().positive()
13042
13137
  });
13043
- var UpdateCheckOutputSchema = z20.strictObject({
13044
- current: z20.string(),
13045
- latest: z20.string(),
13046
- action: z20.enum(["current", "available", "updated"])
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 = z20.discriminatedUnion("state", [
13049
- z20.strictObject({ state: z20.literal("none") }),
13050
- z20.strictObject({ state: z20.literal("signed-in"), email: z20.string().optional(), planScope: z20.boolean(), accessTokenExpiresAt: z20.number() }),
13051
- z20.strictObject({ state: z20.literal("unreadable"), message: z20.string() })
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 = z20.strictObject({
13148
+ var CodexStatusOutputSchema = z21.strictObject({
13054
13149
  signIn: CodexSignInSchema,
13055
- codexProviders: z20.readonly(z20.array(z20.string()))
13150
+ codexProviders: z21.readonly(z21.array(z21.string()))
13056
13151
  });
13057
- var CodexLogoutOutputSchema = z20.strictObject({
13058
- hadGrant: z20.boolean(),
13059
- revoked: z20.boolean()
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 z21 } from "zod";
13217
- var RemovalConfirmationSchema = z21.boolean();
13218
- var CredentialWriteSchema = (targets) => z21.strictObject({
13219
- sources: z21.array(RemoteCredentialSourceSchema).min(1).optional(),
13220
- target: z21.enum(targets).optional(),
13221
- cache: z21.union([z21.literal(false), CredentialCacheSchema]).optional()
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 = z21.strictObject({
13224
- target: z21.enum(CREDENTIAL_TARGETS),
13225
- sources: z21.readonly(z21.array(
13226
- z21.discriminatedUnion("kind", [
13227
- z21.strictObject({ kind: z21.literal("env"), variable: z21.string() }),
13228
- z21.strictObject({ kind: z21.literal("file"), path: z21.string() }),
13229
- z21.strictObject({ kind: z21.literal("command"), program: z21.string() }),
13230
- z21.strictObject({ kind: z21.literal("op"), reference: z21.string() }),
13231
- z21.strictObject({ kind: z21.literal("keychain"), service: z21.string(), account: z21.string().optional() }),
13232
- z21.strictObject({ kind: z21.literal("literal") })
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) => z21.strictObject({ action: z21.literal(action), kind: z21.literal(kind), name: z21.string() });
13238
- var storedMutationOutput = (kind, action, value) => z21.strictObject({ action: z21.literal(action), kind: z21.literal(kind), name: z21.string(), value });
13239
- var IdentityValueSchema = z21.strictObject({
13240
- name: z21.string(),
13241
- defaultConfigProfile: z21.string().optional(),
13242
- allowAmbientCredential: z21.boolean(),
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 = z21.strictObject({
13247
- name: z21.string(),
13248
- kind: z21.enum(PROVIDER_KINDS),
13249
- displayName: z21.string(),
13250
- baseUrl: z21.string().optional(),
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: z21.record(z21.string(), z21.string()).optional()
13348
+ env: z22.record(z22.string(), z22.string()).optional()
13254
13349
  });
13255
- var ConfigNameInputSchema = z21.strictObject({ name: z21.string().min(1) });
13350
+ var ConfigNameInputSchema = z22.strictObject({ name: z22.string().min(1) });
13256
13351
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
13257
- var ConfigIdentitySetInputSchema = z21.strictObject({
13258
- name: z21.string().min(1),
13259
- defaultConfigProfile: z21.union([z21.string().min(1), z21.literal(false)]).optional(),
13260
- allowAmbientCredential: z21.boolean().optional(),
13261
- credential: z21.union([z21.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
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 = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
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 = z21.strictObject({
13268
- name: z21.string().min(1),
13269
- extends: z21.array(z21.string().min(1)).optional(),
13270
- description: z21.string().optional()
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 = z21.strictObject({
13274
- name: z21.string().min(1),
13275
- category: z21.record(z21.string(), z21.boolean()).optional(),
13276
- entry: z21.record(z21.string(), z21.boolean()).optional(),
13277
- extends: z21.union([z21.array(z21.string().min(1)), z21.literal(false)]).optional(),
13278
- description: z21.union([z21.string(), z21.literal(false)]).optional(),
13279
- launch: z21.strictObject({
13280
- skipPermissions: z21.boolean().optional(),
13281
- remoteControl: z21.boolean().optional(),
13282
- headroom: z21.boolean().optional(),
13283
- trackUsage: z21.boolean().optional(),
13284
- provider: z21.union([z21.string().min(1), z21.literal(false)]).optional(),
13285
- claudeVersion: z21.union([z21.string().min(1), z21.literal(false)]).optional()
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 = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
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 = z21.array(z21.string().min(1)).min(1);
13293
- var ConfigPoolAddInputSchema = z21.strictObject({
13294
- name: z21.string().min(1),
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: z21.enum(POOL_PREFERENCES).optional()
13391
+ preference: z22.enum(POOL_PREFERENCES).optional()
13297
13392
  });
13298
13393
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
13299
- var ConfigPoolSetInputSchema = z21.strictObject({
13300
- name: z21.string().min(1),
13394
+ var ConfigPoolSetInputSchema = z22.strictObject({
13395
+ name: z22.string().min(1),
13301
13396
  identities: PoolMembersInputSchema.optional(),
13302
- preference: z21.union([z21.enum(POOL_PREFERENCES), z21.literal(false)]).optional()
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 = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
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 = z21.strictObject({
13309
- name: z21.string().min(1),
13310
- kind: z21.enum(PROVIDER_KINDS).optional(),
13311
- displayName: z21.string().min(1),
13312
- baseUrl: z21.string().min(1).optional(),
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 = z21.strictObject({
13318
- name: z21.string().min(1),
13319
- displayName: z21.string().min(1).optional(),
13320
- baseUrl: z21.string().min(1).optional(),
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 = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13420
+ var ConfigProviderRemoveInputSchema = z22.strictObject({ name: z22.string().min(1), confirm: RemovalConfirmationSchema });
13326
13421
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
13327
- var ConfigRuleAddInputSchema = z21.strictObject({
13328
- path: z21.string().min(1),
13329
- configProfile: z21.string().min(1).optional(),
13330
- identity: z21.string().min(1).optional()
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 = z21.strictObject({
13334
- path: z21.string().min(1),
13335
- configProfile: z21.union([z21.string().min(1), z21.literal(false)]).optional(),
13336
- identity: z21.union([z21.string().min(1), z21.literal(false)]).optional()
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 = z21.strictObject({ path: z21.string().min(1), confirm: RemovalConfirmationSchema });
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 z22 } from "zod";
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 = z22.strictObject({
13652
- source: z22.string().min(1),
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: z22.number().int().positive(),
13655
- payload: z22.unknown()
13749
+ sequence: z23.number().int().positive(),
13750
+ payload: z23.unknown()
13656
13751
  });
13657
- var DoorEventSourceQuerySchema = z22.strictObject({
13658
- sources: z22.array(z22.string().min(1)).min(1).optional()
13752
+ var DoorEventSourceQuerySchema = z23.strictObject({
13753
+ sources: z23.array(z23.string().min(1)).min(1).optional()
13659
13754
  });
13660
- var LaunchLifecycleEventSchema = z22.strictObject({
13661
- kind: z22.enum(["registered", "pruned", "ended"]),
13662
- pid: z22.number().int().positive(),
13663
- startedAt: z22.number(),
13664
- observedAt: z22.number()
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 = z22.discriminatedUnion("kind", [
13667
- z22.strictObject({ kind: z22.literal("generation"), pid: z22.number().int().positive(), providerPort: z22.number().int().positive(), connectPort: z22.number().int().positive(), directPort: z22.number().int().positive(), observedAt: z22.number() }),
13668
- z22.strictObject({ kind: z22.literal("listenerFailed"), pid: z22.number().int().positive(), listener: z22.enum(["provider", "connect", "direct"]), message: z22.string(), observedAt: z22.number() }),
13669
- z22.strictObject({ kind: z22.literal("binaryTurnover"), pid: z22.number().int().positive(), observedAt: z22.number() }),
13670
- z22.strictObject({ kind: z22.literal("idleShutdown"), pid: z22.number().int().positive(), observedAt: z22.number() })
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 = z22.strictObject({
13673
- identity: z22.string().min(1),
13674
- provider: z22.string().min(1),
13675
- window: z22.enum(["fiveHour", "sevenDay"]),
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: z22.number().min(0).max(1),
13678
- resetsAt: z22.iso.datetime(),
13679
- observedAt: z22.number()
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 z23 } from "zod";
13858
+ import { z as z24 } from "zod";
13764
13859
  init_claudeVersion();
13765
13860
  init_identity();
13766
- var LaunchResolveInputSchema = z23.strictObject({
13767
- path: z23.string().min(1),
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: z23.readonly(z23.array(z23.string())).optional(),
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: z23.record(z23.string(), z23.string()).optional()
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 = z23.strictObject({
13774
- name: z23.string(),
13775
- reasons: z23.readonly(z23.array(z23.string())),
13776
- movedOff: z23.strictObject({ identity: z23.string(), reason: z23.string() }).optional()
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 = z23.strictObject({
13779
- identity: z23.string().optional(),
13780
- identitySource: z23.enum(IDENTITY_DECISION_SOURCES),
13873
+ var LaunchDecisionSchema = z24.strictObject({
13874
+ identity: z24.string().optional(),
13875
+ identitySource: z24.enum(IDENTITY_DECISION_SOURCES),
13781
13876
  pool: LaunchPoolDecisionSchema.optional(),
13782
- configDirEscapeHatch: z23.boolean(),
13783
- configDir: z23.string().optional(),
13784
- configProfile: z23.string().optional(),
13785
- configProfileSource: z23.enum(CONFIG_PROFILE_DECISION_SOURCES),
13786
- provider: z23.string().optional()
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 = z23.strictObject({
13789
- skipPermissions: z23.boolean(),
13790
- remoteControl: z23.boolean(),
13791
- headroom: z23.boolean(),
13792
- trackUsage: z23.boolean()
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 = z23.strictObject({
13889
+ var LaunchResolveOutputSchema = z24.strictObject({
13795
13890
  decision: LaunchDecisionSchema,
13796
13891
  flags: LaunchFlagsSchema,
13797
- claudeVersion: z23.strictObject({ version: z23.string(), source: z23.enum(CLAUDE_VERSION_SOURCES) }).optional(),
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: z23.string(),
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: z23.readonly(z23.array(z23.string())),
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: z23.strictObject({ subject: z23.enum(["provider", "identity"]), name: z23.string(), summary: CredentialSummarySchema }).optional(),
13804
- routing: z23.strictObject({ frontDoor: z23.boolean(), headroom: z23.boolean() }),
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: z23.readonly(z23.array(z23.string())),
13807
- warnings: z23.readonly(z23.array(z23.string()))
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 MS_PER_HOUR3 = 36e5;
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 * MS_PER_HOUR3;
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, rowOf) {
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(rowOf), ...last === void 0 ? {} : { next_cursor: idOf(last) } };
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,