claude-use 9.8.0 → 9.10.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
@@ -607,9 +607,9 @@ function applyPatch(filePath, schema, patch, options = {}) {
607
607
  if (!result.success) {
608
608
  throw new ConfigValidationError(filePath, result.error.issues);
609
609
  }
610
- const validated2 = result.data;
611
- writeJsonAtomic(filePath, validated2, storeFs);
612
- return validated2;
610
+ const validated3 = result.data;
611
+ writeJsonAtomic(filePath, validated3, storeFs);
612
+ return validated3;
613
613
  }
614
614
  var nodeStoreFs;
615
615
  var init_store = __esm({
@@ -2639,7 +2639,7 @@ var init_package = __esm({
2639
2639
  "package.json"() {
2640
2640
  package_default = {
2641
2641
  name: "claude-use",
2642
- version: "9.8.0",
2642
+ version: "9.10.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>",
@@ -2745,7 +2745,7 @@ var init_package = __esm({
2745
2745
  // src/headroom/state.ts
2746
2746
  import { createHash as createHash3 } from "node:crypto";
2747
2747
  import path11 from "node:path";
2748
- import { z as z5 } from "zod";
2748
+ import { z as z6 } from "zod";
2749
2749
  function parseJson(raw, schema) {
2750
2750
  if (raw === void 0 || raw.trim() === "") {
2751
2751
  return void 0;
@@ -2876,28 +2876,28 @@ var init_state2 = __esm({
2876
2876
  "use strict";
2877
2877
  init_schema();
2878
2878
  HEADROOM_ANTHROPIC_UPSTREAM = "https://api.anthropic.com";
2879
- HeadroomStateSchema = z5.strictObject({
2879
+ HeadroomStateSchema = z6.strictObject({
2880
2880
  /** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
2881
- supervisorPid: z5.number().int().positive().optional(),
2881
+ supervisorPid: z6.number().int().positive().optional(),
2882
2882
  /** The headroom proxy process itself. Absent while the supervisor is between restarts. */
2883
- headroomPid: z5.number().int().positive().optional(),
2883
+ headroomPid: z6.number().int().positive().optional(),
2884
2884
  /**
2885
2885
  * The unix socket the proxy serves on, inside the owner-only socket directory. Absent until the proxy has passed its readiness check, so "socketPath is set" is itself the ready signal a launcher polls for. The front door reads it on every hop, so a restart (which keeps the generation's path) is followed without anything being relaunched.
2886
2886
  */
2887
- socketPath: z5.string().min(1).optional(),
2887
+ socketPath: z6.string().min(1).optional(),
2888
2888
  /** The `headroom --version` output of the running install. */
2889
- version: z5.string().optional(),
2889
+ version: z6.string().optional(),
2890
2890
  /** Hash of the allowlist the running proxy was started with, so a provider-file change is detected as drift. */
2891
- allowlistHash: z5.string().optional(),
2891
+ allowlistHash: z6.string().optional(),
2892
2892
  /** Hash of the token-saving settings the running proxy was started with, so a settings change is detected as drift. */
2893
- settingsHash: z5.string().optional(),
2893
+ settingsHash: z6.string().optional(),
2894
2894
  /** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
2895
- installedSource: z5.string().optional(),
2895
+ installedSource: z6.string().optional(),
2896
2896
  /** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
2897
- lastError: z5.string().optional()
2897
+ lastError: z6.string().optional()
2898
2898
  });
2899
- HeadroomSessionSchema = z5.strictObject({ pid: z5.number().int().positive(), startedAt: z5.number(), supervisorPid: z5.number().int().positive() });
2900
- HeadroomLockSchema = z5.strictObject({ pid: z5.number().int().positive(), at: z5.number() });
2899
+ HeadroomSessionSchema = z6.strictObject({ pid: z6.number().int().positive(), startedAt: z6.number(), supervisorPid: z6.number().int().positive() });
2900
+ HeadroomLockSchema = z6.strictObject({ pid: z6.number().int().positive(), at: z6.number() });
2901
2901
  }
2902
2902
  });
2903
2903
 
@@ -3091,7 +3091,7 @@ var init_socket = __esm({
3091
3091
  });
3092
3092
 
3093
3093
  // src/headroom/source.ts
3094
- import { z as z6 } from "zod";
3094
+ import { z as z7 } from "zod";
3095
3095
  function isMovingGitSource(spec) {
3096
3096
  const match = GIT_SPEC_RE.exec(spec);
3097
3097
  if (match === null) {
@@ -3110,7 +3110,7 @@ var init_source = __esm({
3110
3110
  "use strict";
3111
3111
  GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
3112
3112
  COMMIT_SHA_RE = /^[0-9a-f]{40}$/i;
3113
- DirectUrlSchema = z6.object({ vcs_info: z6.object({ commit_id: z6.string() }) });
3113
+ DirectUrlSchema = z7.object({ vcs_info: z7.object({ commit_id: z7.string() }) });
3114
3114
  }
3115
3115
  });
3116
3116
 
@@ -3378,7 +3378,7 @@ var init_supervisor = __esm({
3378
3378
  });
3379
3379
 
3380
3380
  // src/realPorts.ts
3381
- import { spawn, spawnSync } from "node:child_process";
3381
+ import { spawn as spawn2, spawnSync } from "node:child_process";
3382
3382
  import { createHash as createHash5 } from "node:crypto";
3383
3383
  import fs3 from "node:fs";
3384
3384
  import os3 from "node:os";
@@ -3456,7 +3456,7 @@ function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
3456
3456
  fs3.mkdirSync(path13.dirname(logPath), { recursive: true });
3457
3457
  const logFd = fs3.openSync(logPath, "a");
3458
3458
  try {
3459
- const child = spawn(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
3459
+ const child = spawn2(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
3460
3460
  child.unref();
3461
3461
  if (child.pid === void 0) {
3462
3462
  throw new Error(`spawning ${subcommand} returned no pid`);
@@ -4014,149 +4014,149 @@ var init_identity = __esm({
4014
4014
  });
4015
4015
 
4016
4016
  // src/usage/schema.ts
4017
- import { z as z7 } from "zod";
4017
+ import { z as z8 } from "zod";
4018
4018
  var USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
4019
4019
  var init_schema2 = __esm({
4020
4020
  "src/usage/schema.ts"() {
4021
4021
  "use strict";
4022
4022
  USAGE_SCHEMA_VERSION = 1;
4023
- VersionSchema = z7.literal(USAGE_SCHEMA_VERSION);
4024
- InstantSchema = z7.iso.datetime();
4025
- TokenCountSchema = z7.number().int().nonnegative();
4026
- TokenUsageSchema = z7.strictObject({
4023
+ VersionSchema = z8.literal(USAGE_SCHEMA_VERSION);
4024
+ InstantSchema = z8.iso.datetime();
4025
+ TokenCountSchema = z8.number().int().nonnegative();
4026
+ TokenUsageSchema = z8.strictObject({
4027
4027
  inputTokens: TokenCountSchema.optional(),
4028
4028
  outputTokens: TokenCountSchema.optional(),
4029
4029
  cacheCreationInputTokens: TokenCountSchema.optional(),
4030
4030
  cacheReadInputTokens: TokenCountSchema.optional()
4031
4031
  });
4032
4032
  LIMIT_KINDS = ["rate-limited", "quota-exhausted"];
4033
- LimitClassificationSchema = z7.strictObject({
4034
- kind: z7.enum(LIMIT_KINDS),
4033
+ LimitClassificationSchema = z8.strictObject({
4034
+ kind: z8.enum(LIMIT_KINDS),
4035
4035
  /** Seconds to wait before retrying, from the response's `retry-after`. */
4036
- retryAfterSeconds: z7.number().nonnegative().optional(),
4036
+ retryAfterSeconds: z8.number().nonnegative().optional(),
4037
4037
  /** When the limiting window resets, from the upstream's own reset header. */
4038
4038
  resetAt: InstantSchema.optional(),
4039
4039
  /** The window the upstream named as the binding one (`anthropic-ratelimit-unified-representative-claim`), such as `five_hour` or `seven_day`. */
4040
- window: z7.string().optional(),
4040
+ window: z8.string().optional(),
4041
4041
  /** The signals the classification rests on, each `<name>=<value>` from a response header or the error body's `type` or `code`. Never the error message. */
4042
- evidence: z7.array(z7.string())
4042
+ evidence: z8.array(z8.string())
4043
4043
  });
4044
- UsageRecordSchema = z7.strictObject({
4044
+ UsageRecordSchema = z8.strictObject({
4045
4045
  schemaVersion: VersionSchema,
4046
4046
  /** When the front door received the request. */
4047
4047
  at: InstantSchema,
4048
4048
  /** The launching identity, when the launch resolved one. */
4049
- identity: z7.string().optional(),
4049
+ identity: z8.string().optional(),
4050
4050
  /** `anthropic` for an OAuth session's request to Claude Code's own API, otherwise the provider's name. */
4051
- provider: z7.string(),
4051
+ provider: z8.string(),
4052
4052
  /** The launch's session id, generated per launch. */
4053
- sessionId: z7.string().optional(),
4053
+ sessionId: z8.string().optional(),
4054
4054
  /** The project the launch ran in (its git repository root), when the launch sent one: headroom launches do. */
4055
- project: z7.string().optional(),
4055
+ project: z8.string().optional(),
4056
4056
  /** The front-door route that served the request. */
4057
- route: z7.string(),
4058
- method: z7.string(),
4057
+ route: z8.string(),
4058
+ method: z8.string(),
4059
4059
  /** The API path as the upstream sees it (`/v1/messages`), without the provider prefix or a query string. */
4060
- endpoint: z7.string(),
4060
+ endpoint: z8.string(),
4061
4061
  /** The model the response named. */
4062
- model: z7.string().optional(),
4063
- status: z7.number().int(),
4062
+ model: z8.string().optional(),
4063
+ status: z8.number().int(),
4064
4064
  /** Milliseconds from the request's arrival to its response head. */
4065
- latencyMs: z7.number().int().nonnegative(),
4065
+ latencyMs: z8.number().int().nonnegative(),
4066
4066
  /** Milliseconds from the request's arrival to the end of its response body. */
4067
- durationMs: z7.number().int().nonnegative(),
4067
+ durationMs: z8.number().int().nonnegative(),
4068
4068
  /** Whether the client received the whole body. */
4069
- outcome: z7.enum(["completed", "aborted"]),
4069
+ outcome: z8.enum(["completed", "aborted"]),
4070
4070
  usage: TokenUsageSchema.optional(),
4071
4071
  /** The response's quota and rate-limit headers, by name (see `isRateLimitHeader`). */
4072
- rateLimitHeaders: z7.record(z7.string(), z7.string()).optional(),
4072
+ rateLimitHeaders: z8.record(z8.string(), z8.string()).optional(),
4073
4073
  limit: LimitClassificationSchema.optional(),
4074
4074
  /** The upstream's request id (`request-id`), for matching a record to the provider's own logs. */
4075
- requestId: z7.string().optional()
4075
+ requestId: z8.string().optional()
4076
4076
  });
4077
- QuotaWindowSchema = z7.strictObject({
4077
+ QuotaWindowSchema = z8.strictObject({
4078
4078
  /** The fraction of the window used, as the upstream reports it (0 to 1). */
4079
- utilization: z7.number().nonnegative().optional(),
4079
+ utilization: z8.number().nonnegative().optional(),
4080
4080
  resetsAt: InstantSchema.optional(),
4081
4081
  /** The window's own status (`allowed`, `allowed_warning`, `rejected`). */
4082
- status: z7.string().optional(),
4082
+ status: z8.string().optional(),
4083
4083
  /** The fraction of the window's grace allowance used, while the upstream reports the window in grace (the five-hour window only). Requests are served beyond the window's own full mark while it grows, but refusals have been seen at a small value, so nothing ranks on it. */
4084
- graceUtilization: z7.number().nonnegative().optional()
4084
+ graceUtilization: z8.number().nonnegative().optional()
4085
4085
  });
4086
- ExtraUsageSpendSchema = z7.strictObject({
4086
+ ExtraUsageSpendSchema = z8.strictObject({
4087
4087
  /** Spent so far in the allowance's period, in the currency's minor units (pence, cents). */
4088
- usedMinor: z7.number().nonnegative(),
4088
+ usedMinor: z8.number().nonnegative(),
4089
4089
  /** The allowance's cap in the same units, when it has one. */
4090
- limitMinor: z7.number().nonnegative().optional(),
4090
+ limitMinor: z8.number().nonnegative().optional(),
4091
4091
  /** The ISO 4217 currency code. */
4092
- currency: z7.string()
4092
+ currency: z8.string()
4093
4093
  });
4094
- UnifiedRateLimitSchema = z7.strictObject({
4094
+ UnifiedRateLimitSchema = z8.strictObject({
4095
4095
  /** The overall status: `allowed`, `allowed_warning` or `rejected`. */
4096
- status: z7.string().optional(),
4096
+ status: z8.string().optional(),
4097
4097
  fiveHour: QuotaWindowSchema.optional(),
4098
4098
  sevenDay: QuotaWindowSchema.optional(),
4099
4099
  /** The weekly window of the models whose usage may continue as extra usage (`7d_oi`), reported by some plans beside the all-models weekly window. */
4100
4100
  sevenDayOverageIncluded: QuotaWindowSchema.optional(),
4101
4101
  /** The window that currently binds. */
4102
- representativeClaim: z7.string().optional(),
4102
+ representativeClaim: z8.string().optional(),
4103
4103
  /** When the binding window resets. */
4104
4104
  resetAt: InstantSchema.optional(),
4105
4105
  /** Whether usage beyond the plan (extra usage) is available: `allowed` or `rejected`. */
4106
- overageStatus: z7.string().optional(),
4106
+ overageStatus: z8.string().optional(),
4107
4107
  /** The fraction of the extra-usage allowance used, as the upstream reports it (0 to 1). An account with no plan windows, such as an Enterprise one, is metered by this alone. */
4108
- overageUtilization: z7.number().nonnegative().optional(),
4108
+ overageUtilization: z8.number().nonnegative().optional(),
4109
4109
  /** When the extra-usage allowance resets. */
4110
4110
  overageResetsAt: InstantSchema.optional(),
4111
4111
  /** Why extra usage is unavailable, as the upstream names it (`out_of_credits`, for one). */
4112
- overageDisabledReason: z7.string().optional(),
4112
+ overageDisabledReason: z8.string().optional(),
4113
4113
  /** Whether the response was served on extra usage, as the upstream states it. */
4114
- overageInUse: z7.boolean().optional(),
4114
+ overageInUse: z8.boolean().optional(),
4115
4115
  /** The allowance in money, from the usage endpoint (the response headers state only the fraction). */
4116
4116
  extraUsageSpend: ExtraUsageSpendSchema.optional(),
4117
4117
  /** True when the upstream offers a fallback while a window is rejected: some requests, by model, are still served, though the rest are refused. */
4118
- fallbackAvailable: z7.boolean().optional()
4118
+ fallbackAvailable: z8.boolean().optional()
4119
4119
  });
4120
- RateLimitStateSchema = z7.strictObject({
4120
+ RateLimitStateSchema = z8.strictObject({
4121
4121
  observedAt: InstantSchema,
4122
4122
  /** Every quota and rate-limit header on that response, by name. */
4123
- headers: z7.record(z7.string(), z7.string()),
4123
+ headers: z8.record(z8.string(), z8.string()),
4124
4124
  unified: UnifiedRateLimitSchema.optional(),
4125
4125
  /** When the usage endpoint last answered that it has no plan windows for the account, which a later response replaces. Its answer leaves the recorded `unified` state alone (a response's headers may be the only source of it), so this alone says the question was asked. */
4126
4126
  planWindowsUnavailableAt: InstantSchema.optional()
4127
4127
  });
4128
4128
  LimitEventSchema = LimitClassificationSchema.extend({
4129
4129
  observedAt: InstantSchema,
4130
- status: z7.number().int()
4130
+ status: z8.number().int()
4131
4131
  });
4132
- ProviderQuotaWindowSchema = z7.strictObject({
4132
+ ProviderQuotaWindowSchema = z8.strictObject({
4133
4133
  /** What the window measures, in the provider's terms (`tokens`, `tool-calls`). */
4134
- measures: z7.string(),
4134
+ measures: z8.string(),
4135
4135
  /** The window's length in milliseconds, when the provider's unit is one this project knows; absent for an unrecognised unit, with `period` carrying the raw code. */
4136
- periodMs: z7.number().int().positive().optional(),
4136
+ periodMs: z8.number().int().positive().optional(),
4137
4137
  /** The provider's own description of the period when `periodMs` could not be derived, such as `unit 4 x 1`. */
4138
- period: z7.string().optional(),
4138
+ period: z8.string().optional(),
4139
4139
  /** The fraction of the window used (0 to 1). */
4140
- utilization: z7.number().nonnegative(),
4140
+ utilization: z8.number().nonnegative(),
4141
4141
  resetsAt: InstantSchema.optional(),
4142
4142
  /** Absolute counts, when the provider reports them for this window. */
4143
- limit: z7.number().nonnegative().optional(),
4144
- used: z7.number().nonnegative().optional(),
4145
- remaining: z7.number().nonnegative().optional()
4143
+ limit: z8.number().nonnegative().optional(),
4144
+ used: z8.number().nonnegative().optional(),
4145
+ remaining: z8.number().nonnegative().optional()
4146
4146
  });
4147
- ProviderQuotaSchema = z7.strictObject({
4147
+ ProviderQuotaSchema = z8.strictObject({
4148
4148
  observedAt: InstantSchema,
4149
4149
  /** Which usage endpoint produced it (`z.ai`). */
4150
- source: z7.string(),
4150
+ source: z8.string(),
4151
4151
  /** The subscription level the endpoint reports, when it does. */
4152
- level: z7.string().optional(),
4153
- windows: z7.array(ProviderQuotaWindowSchema)
4152
+ level: z8.string().optional(),
4153
+ windows: z8.array(ProviderQuotaWindowSchema)
4154
4154
  });
4155
- ProviderUsageStateSchema = z7.strictObject({
4155
+ ProviderUsageStateSchema = z8.strictObject({
4156
4156
  /** When the provider last served a request for the identity through the front door. Absent while the state holds only a rate-limit state fetched from the provider's usage endpoint, for an identity that has made no request. */
4157
4157
  lastRequestAt: InstantSchema.optional(),
4158
- lastStatus: z7.number().int().optional(),
4159
- lastModel: z7.string().optional(),
4158
+ lastStatus: z8.number().int().optional(),
4159
+ lastModel: z8.string().optional(),
4160
4160
  /** The latest rate-limit state, from the last response that carried any rate-limit header. */
4161
4161
  rateLimit: RateLimitStateSchema.optional(),
4162
4162
  /** The latest classified refusal. It stays after later successes, so a reader compares its `resetAt` (or `observedAt` plus `retryAfterSeconds`) with the current time. */
@@ -4164,31 +4164,31 @@ var init_schema2 = __esm({
4164
4164
  /** The latest quota the provider's usage endpoint reported, for providers whose quota is not visible in response headers. */
4165
4165
  quota: ProviderQuotaSchema.optional()
4166
4166
  });
4167
- AccountMetadataSchema = z7.strictObject({
4168
- accountUuid: z7.string().optional(),
4169
- emailAddress: z7.string().optional(),
4170
- displayName: z7.string().optional(),
4171
- organizationUuid: z7.string().optional(),
4172
- organizationName: z7.string().optional(),
4173
- organizationType: z7.string().optional(),
4174
- organizationRole: z7.string().optional(),
4175
- workspaceRole: z7.string().optional(),
4176
- billingType: z7.string().optional(),
4177
- seatTier: z7.string().optional(),
4178
- organizationRateLimitTier: z7.string().optional(),
4179
- userRateLimitTier: z7.string().optional(),
4180
- hasExtraUsageEnabled: z7.boolean().optional(),
4181
- subscriptionCreatedAt: z7.string().optional(),
4182
- accountCreatedAt: z7.string().optional()
4167
+ AccountMetadataSchema = z8.strictObject({
4168
+ accountUuid: z8.string().optional(),
4169
+ emailAddress: z8.string().optional(),
4170
+ displayName: z8.string().optional(),
4171
+ organizationUuid: z8.string().optional(),
4172
+ organizationName: z8.string().optional(),
4173
+ organizationType: z8.string().optional(),
4174
+ organizationRole: z8.string().optional(),
4175
+ workspaceRole: z8.string().optional(),
4176
+ billingType: z8.string().optional(),
4177
+ seatTier: z8.string().optional(),
4178
+ organizationRateLimitTier: z8.string().optional(),
4179
+ userRateLimitTier: z8.string().optional(),
4180
+ hasExtraUsageEnabled: z8.boolean().optional(),
4181
+ subscriptionCreatedAt: z8.string().optional(),
4182
+ accountCreatedAt: z8.string().optional()
4183
4183
  });
4184
- UsageSnapshotSchema = z7.strictObject({
4184
+ UsageSnapshotSchema = z8.strictObject({
4185
4185
  schemaVersion: VersionSchema,
4186
- identity: z7.string(),
4186
+ identity: z8.string(),
4187
4187
  updatedAt: InstantSchema,
4188
4188
  /** The identity's account metadata as of `updatedAt`. */
4189
4189
  account: AccountMetadataSchema.optional(),
4190
4190
  /** Latest state per provider, keyed by provider name (`anthropic` for OAuth sessions). */
4191
- providers: z7.record(z7.string(), ProviderUsageStateSchema)
4191
+ providers: z8.record(z8.string(), ProviderUsageStateSchema)
4192
4192
  });
4193
4193
  }
4194
4194
  });
@@ -4276,7 +4276,7 @@ var init_account = __esm({
4276
4276
  });
4277
4277
 
4278
4278
  // src/usage/plan.ts
4279
- import { z as z8 } from "zod";
4279
+ import { z as z9 } from "zod";
4280
4280
  function planOf(account) {
4281
4281
  const userTier = account?.userRateLimitTier;
4282
4282
  if (userTier !== void 0 && ZERO_TIER.test(userTier)) {
@@ -4300,19 +4300,19 @@ var PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
4300
4300
  var init_plan2 = __esm({
4301
4301
  "src/usage/plan.ts"() {
4302
4302
  "use strict";
4303
- PlanClassSchema = z8.union([
4304
- z8.strictObject({
4305
- kind: z8.literal("subscription"),
4303
+ PlanClassSchema = z9.union([
4304
+ z9.strictObject({
4305
+ kind: z9.literal("subscription"),
4306
4306
  /** The plan's size as a multiple of the smallest subscription tier (Max 5x is 5, Max 20x is 20). */
4307
- capacity: z8.number().positive(),
4307
+ capacity: z9.number().positive(),
4308
4308
  /** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
4309
- recognised: z8.boolean(),
4309
+ recognised: z9.boolean(),
4310
4310
  /** The tier string the classification rests on, when the account had one. */
4311
- tier: z8.string().optional()
4311
+ tier: z9.string().optional()
4312
4312
  }),
4313
- z8.strictObject({
4314
- kind: z8.literal("pay-per-use"),
4315
- tier: z8.string().optional()
4313
+ z9.strictObject({
4314
+ kind: z9.literal("pay-per-use"),
4315
+ tier: z9.string().optional()
4316
4316
  })
4317
4317
  ]);
4318
4318
  TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
@@ -4413,21 +4413,21 @@ var init_rateLimit = __esm({
4413
4413
  });
4414
4414
 
4415
4415
  // src/usage/scan.ts
4416
- import { z as z9 } from "zod";
4416
+ import { z as z10 } from "zod";
4417
4417
  var AnthropicUsageSchema, ErrorObjectSchema;
4418
4418
  var init_scan = __esm({
4419
4419
  "src/usage/scan.ts"() {
4420
4420
  "use strict";
4421
- AnthropicUsageSchema = z9.looseObject({
4422
- input_tokens: z9.number().int().nonnegative().nullish(),
4423
- output_tokens: z9.number().int().nonnegative().nullish(),
4424
- cache_creation_input_tokens: z9.number().int().nonnegative().nullish(),
4425
- cache_read_input_tokens: z9.number().int().nonnegative().nullish()
4421
+ AnthropicUsageSchema = z10.looseObject({
4422
+ input_tokens: z10.number().int().nonnegative().nullish(),
4423
+ output_tokens: z10.number().int().nonnegative().nullish(),
4424
+ cache_creation_input_tokens: z10.number().int().nonnegative().nullish(),
4425
+ cache_read_input_tokens: z10.number().int().nonnegative().nullish()
4426
4426
  });
4427
- ErrorObjectSchema = z9.looseObject({
4428
- type: z9.string().optional(),
4429
- code: z9.union([z9.string(), z9.number()]).optional(),
4430
- message: z9.string().optional()
4427
+ ErrorObjectSchema = z10.looseObject({
4428
+ type: z10.string().optional(),
4429
+ code: z10.union([z10.string(), z10.number()]).optional(),
4430
+ message: z10.string().optional()
4431
4431
  });
4432
4432
  }
4433
4433
  });
@@ -5001,7 +5001,7 @@ var init_store2 = __esm({
5001
5001
 
5002
5002
  // src/usage/poolPick.ts
5003
5003
  import path20 from "node:path";
5004
- import { z as z10 } from "zod";
5004
+ import { z as z11 } from "zod";
5005
5005
  function errorMessage(error) {
5006
5006
  return error instanceof Error ? error.message : String(error);
5007
5007
  }
@@ -5151,10 +5151,10 @@ var init_poolPick = __esm({
5151
5151
  }
5152
5152
  };
5153
5153
  SCHEMA_VERSION = 1;
5154
- PickEntrySchema = z10.strictObject({ identity: z10.string().min(1), at: z10.iso.datetime() });
5155
- PicksFileSchema = z10.strictObject({
5156
- schemaVersion: z10.literal(SCHEMA_VERSION),
5157
- picks: z10.record(z10.string().min(1), PickEntrySchema)
5154
+ PickEntrySchema = z11.strictObject({ identity: z11.string().min(1), at: z11.iso.datetime() });
5155
+ PicksFileSchema = z11.strictObject({
5156
+ schemaVersion: z11.literal(SCHEMA_VERSION),
5157
+ picks: z11.record(z11.string().min(1), PickEntrySchema)
5158
5158
  });
5159
5159
  }
5160
5160
  });
@@ -5216,7 +5216,8 @@ function buildLayoutPaths(root) {
5216
5216
  usageDir: path22.join(root, "usage"),
5217
5217
  usageLogDir: path22.join(root, "usage", "log"),
5218
5218
  usageSnapshotsDir: path22.join(root, "usage", "snapshots"),
5219
- usagePicksFile: path22.join(root, "usage", "picks.json")
5219
+ usagePicksFile: path22.join(root, "usage", "picks.json"),
5220
+ mcpPermissionsFile: path22.join(root, "mcp", "permissions.json")
5220
5221
  };
5221
5222
  }
5222
5223
  function resolveLayoutPaths() {
@@ -5230,7 +5231,7 @@ var init_paths = __esm({
5230
5231
  });
5231
5232
 
5232
5233
  // src/credentialCache.ts
5233
- import { z as z11 } from "zod";
5234
+ import { z as z12 } from "zod";
5234
5235
  function effectiveStore(cache, platform) {
5235
5236
  return cache.store ?? (platform === "darwin" ? "keychain" : "file");
5236
5237
  }
@@ -5297,9 +5298,9 @@ var init_credentialCache = __esm({
5297
5298
  init_schema();
5298
5299
  init_preflight();
5299
5300
  MS_PER_UNIT = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
5300
- CachedCredentialSchema = z11.strictObject({
5301
- token: z11.string().min(1),
5302
- fetchedAt: z11.number().int().nonnegative(),
5301
+ CachedCredentialSchema = z12.strictObject({
5302
+ token: z12.string().min(1),
5303
+ fetchedAt: z12.number().int().nonnegative(),
5303
5304
  source: CredentialSourceSchema
5304
5305
  });
5305
5306
  }
@@ -5901,7 +5902,7 @@ var init_envBool = __esm({
5901
5902
  });
5902
5903
 
5903
5904
  // src/launcher/claudeVersion.ts
5904
- function validated(value, origin) {
5905
+ function validated2(value, origin) {
5905
5906
  if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
5906
5907
  throw new InvalidClaudeVersionError(value, origin);
5907
5908
  }
@@ -5909,11 +5910,11 @@ function validated(value, origin) {
5909
5910
  }
5910
5911
  function resolveClaudeVersion(params) {
5911
5912
  if (params.flag !== void 0) {
5912
- return { version: validated(params.flag, "--claude-version"), source: "flag" };
5913
+ return { version: validated2(params.flag, "--claude-version"), source: "flag" };
5913
5914
  }
5914
5915
  const fromEnv = params.env.AGENT_SHIM_CLAUDE_VERSION;
5915
5916
  if (fromEnv !== void 0 && fromEnv !== "") {
5916
- return { version: validated(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
5917
+ return { version: validated2(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
5917
5918
  }
5918
5919
  return params.cascade === void 0 ? void 0 : { version: params.cascade, source: "cascade" };
5919
5920
  }
@@ -6001,7 +6002,7 @@ var init_commandDeps = __esm({
6001
6002
  // src/claudeShim.ts
6002
6003
  import fs8 from "node:fs";
6003
6004
  import path26 from "node:path";
6004
- import { z as z15 } from "zod";
6005
+ import { z as z16 } from "zod";
6005
6006
  function commandFilename(ownExecutablePath, commandName) {
6006
6007
  return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
6007
6008
  }
@@ -6051,10 +6052,10 @@ var init_claudeShim = __esm({
6051
6052
  init_store();
6052
6053
  init_realPorts();
6053
6054
  init_cliError();
6054
- ClaudeShimStateSchema = z15.strictObject({
6055
- targetPath: z15.string().min(1),
6056
- method: z15.enum(["hardlink", "copy"]),
6057
- installedAtMs: z15.number()
6055
+ ClaudeShimStateSchema = z16.strictObject({
6056
+ targetPath: z16.string().min(1),
6057
+ method: z16.enum(["hardlink", "copy"]),
6058
+ installedAtMs: z16.number()
6058
6059
  });
6059
6060
  nodeLinkFs = { link: fs8.linkSync, copyFile: fs8.copyFileSync, chmod: fs8.chmodSync };
6060
6061
  }
@@ -7182,10 +7183,10 @@ function resolveLaunch(params) {
7182
7183
  environment
7183
7184
  };
7184
7185
  }
7185
- function runLaunchPlan(plan, spawn2) {
7186
+ function runLaunchPlan(plan, spawn3) {
7186
7187
  try {
7187
7188
  plan.markChildStarted();
7188
- const result = spawn2.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
7189
+ const result = spawn3.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
7189
7190
  if (result.error !== void 0) {
7190
7191
  throw result.error;
7191
7192
  }
@@ -7689,7 +7690,7 @@ var init_anthropicUsageRefresh = __esm({
7689
7690
  });
7690
7691
 
7691
7692
  // src/usage/providerQuota.ts
7692
- import { z as z23 } from "zod";
7693
+ import { z as z24 } from "zod";
7693
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;
7694
7695
  var init_providerQuota = __esm({
7695
7696
  "src/usage/providerQuota.ts"() {
@@ -7707,35 +7708,35 @@ var init_providerQuota = __esm({
7707
7708
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
7708
7709
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7]
7709
7710
  ]);
7710
- ZaiLimitSchema = z23.object({
7711
- type: z23.string(),
7712
- unit: z23.number().int(),
7713
- number: z23.number().int().positive(),
7714
- percentage: z23.number().nonnegative(),
7715
- nextResetTime: z23.number().positive().optional(),
7716
- usage: z23.number().nonnegative().optional(),
7717
- currentValue: z23.number().nonnegative().optional(),
7718
- remaining: z23.number().nonnegative().optional()
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()
7719
7720
  });
7720
- ZaiResponseSchema = z23.object({
7721
- success: z23.boolean(),
7722
- msg: z23.string().optional(),
7723
- data: z23.object({ level: z23.string().optional(), limits: z23.array(ZaiLimitSchema) })
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) })
7724
7725
  });
7725
7726
  OPENROUTER_HOST = "openrouter.ai";
7726
7727
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
7727
7728
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
7728
7729
  MS_PER_DAY3 = HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7;
7729
- OpenRouterKeySchema = z23.object({
7730
- data: z23.object({
7731
- limit: z23.number().nonnegative().nullable(),
7732
- limit_remaining: z23.number().nullable(),
7733
- limit_reset: z23.string().nullable(),
7734
- is_free_tier: z23.boolean().optional(),
7735
- free_model_daily_requests: z23.object({ used: z23.number().nonnegative(), limit: z23.number().nonnegative(), remaining: z23.number() }).optional()
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()
7736
7737
  })
7737
7738
  });
7738
- OpenRouterCreditsSchema = z23.object({ data: z23.object({ total_credits: z23.number().nonnegative(), total_usage: z23.number().nonnegative() }) });
7739
+ OpenRouterCreditsSchema = z24.object({ data: z24.object({ total_credits: z24.number().nonnegative(), total_usage: z24.number().nonnegative() }) });
7739
7740
  }
7740
7741
  });
7741
7742
 
@@ -10896,6 +10897,242 @@ function frontDoorRcApiClient(port, ca, token) {
10896
10897
  return createORPCClient(frontDoorApiLink(port, ca, token));
10897
10898
  }
10898
10899
 
10900
+ // src/codex/appServer.ts
10901
+ init_cliError();
10902
+ init_package();
10903
+
10904
+ // src/codex/appServerSchemas.ts
10905
+ import { z as z5 } from "zod";
10906
+ var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
10907
+ var RateLimitWindowSchema = z5.object({
10908
+ usedPercent: z5.number(),
10909
+ resetsAt: z5.number().nullish(),
10910
+ windowDurationMins: z5.number().nullish()
10911
+ });
10912
+ var RateLimitSnapshotSchema = z5.object({
10913
+ limitId: z5.string().nullish(),
10914
+ limitName: z5.string().nullish(),
10915
+ planType: z5.string().nullish(),
10916
+ primary: RateLimitWindowSchema.nullish(),
10917
+ secondary: RateLimitWindowSchema.nullish(),
10918
+ rateLimitReachedType: z5.string().nullish(),
10919
+ spendControlReached: z5.boolean().nullish()
10920
+ });
10921
+ var RateLimitResetCreditSchema = z5.object({
10922
+ id: z5.string(),
10923
+ grantedAt: z5.number(),
10924
+ expiresAt: z5.number().nullish(),
10925
+ resetType: z5.string(),
10926
+ status: z5.string(),
10927
+ title: z5.string().nullish(),
10928
+ description: z5.string().nullish()
10929
+ });
10930
+ var CodexAccountSchema = z5.discriminatedUnion("type", [
10931
+ z5.object({ type: z5.literal("apiKey") }),
10932
+ z5.object({ type: z5.literal("chatgpt"), email: z5.string().nullable(), planType: z5.string() }),
10933
+ z5.object({ type: z5.literal("amazonBedrock"), usesCodexManagedCredentials: z5.boolean().default(false) })
10934
+ ]);
10935
+ var CodexAccountReadSchema = z5.object({
10936
+ account: CodexAccountSchema.nullable(),
10937
+ requiresOpenaiAuth: z5.boolean()
10938
+ });
10939
+ var CodexRateLimitsReadSchema = z5.object({
10940
+ rateLimits: RateLimitSnapshotSchema,
10941
+ rateLimitsByLimitId: z5.record(z5.string(), RateLimitSnapshotSchema).nullish(),
10942
+ rateLimitResetCredits: z5.object({ availableCount: z5.number(), credits: z5.array(RateLimitResetCreditSchema).nullish() }).nullish(),
10943
+ accountId: z5.string().nullish(),
10944
+ ordinaryUsageAllowed: z5.boolean().nullish()
10945
+ });
10946
+ var CodexInitializeResultSchema = z5.object({ userAgent: z5.string() });
10947
+
10948
+ // src/codex/appServer.ts
10949
+ var CodexAppServerUnavailableError = class extends CliError {
10950
+ constructor(detail) {
10951
+ super(`The Codex app-server is not available: ${detail}.`);
10952
+ this.name = "CodexAppServerUnavailableError";
10953
+ }
10954
+ };
10955
+ var CodexAppServerRequestError = class extends CliError {
10956
+ constructor(method, rpcCode, detail) {
10957
+ super(`Codex app-server ${method} failed (${String(rpcCode)}): ${detail}`);
10958
+ this.method = method;
10959
+ this.rpcCode = rpcCode;
10960
+ this.name = "CodexAppServerRequestError";
10961
+ }
10962
+ method;
10963
+ rpcCode;
10964
+ };
10965
+ var CodexAppServerProtocolError = class extends CliError {
10966
+ constructor(method, installedVersion, detail) {
10967
+ super(
10968
+ `Codex app-server ${method} answered in a shape this reader does not know (installed Codex ${installedVersion ?? "of unknown version"}, shapes generated against ${CODEX_APP_SERVER_GENERATED_AGAINST}): ${detail}`
10969
+ );
10970
+ this.method = method;
10971
+ this.installedVersion = installedVersion;
10972
+ this.name = "CodexAppServerProtocolError";
10973
+ }
10974
+ method;
10975
+ installedVersion;
10976
+ };
10977
+ var CODEX_APP_SERVER_TIMEOUT_MS = 3e4;
10978
+ var CLIENT_NAME = "agent-shim";
10979
+ function installedVersionOf(userAgent) {
10980
+ return /^[^/\s]+\/(\S+)/.exec(userAgent)?.[1];
10981
+ }
10982
+ function responseTo(message, id) {
10983
+ if (typeof message !== "object" || message === null || !("id" in message) || message.id !== id) {
10984
+ return void 0;
10985
+ }
10986
+ if ("error" in message && typeof message.error === "object" && message.error !== null) {
10987
+ const { error } = message;
10988
+ const code = "code" in error && typeof error.code === "number" ? error.code : 0;
10989
+ const detail = "message" in error && typeof error.message === "string" ? error.message : "no message";
10990
+ return { error: { code, message: detail } };
10991
+ }
10992
+ return "result" in message ? { result: message.result } : void 0;
10993
+ }
10994
+ async function withAppServer(port, options, ask) {
10995
+ const connection = await port.open({ bin: options.bin ?? "codex", codexHome: options.codexHome });
10996
+ let nextId = 0;
10997
+ const timeoutMs = options.timeoutMs ?? CODEX_APP_SERVER_TIMEOUT_MS;
10998
+ const stopper = AbortSignal.any([...options.signal === void 0 ? [] : [options.signal], AbortSignal.timeout(timeoutMs)]);
10999
+ const stopReason = () => {
11000
+ if (options.signal?.aborted !== true) {
11001
+ return new CodexAppServerUnavailableError(`it did not answer within ${String(timeoutMs)} ms`);
11002
+ }
11003
+ const reason = options.signal.reason;
11004
+ return reason instanceof Error ? reason : new Error(`the Codex app-server read was aborted: ${String(reason)}`);
11005
+ };
11006
+ const aborted = new Promise((_resolve, reject) => {
11007
+ if (stopper.aborted) {
11008
+ reject(stopReason());
11009
+ return;
11010
+ }
11011
+ stopper.addEventListener(
11012
+ "abort",
11013
+ () => {
11014
+ reject(stopReason());
11015
+ },
11016
+ { once: true }
11017
+ );
11018
+ });
11019
+ aborted.catch(() => void 0);
11020
+ const request4 = async (method, params) => {
11021
+ nextId += 1;
11022
+ const id = nextId;
11023
+ connection.send({ jsonrpc: "2.0", id, method, params });
11024
+ for (; ; ) {
11025
+ const message = await Promise.race([connection.receive(), aborted]);
11026
+ if (message === void 0) {
11027
+ throw new CodexAppServerUnavailableError(`it ended before answering ${method}`);
11028
+ }
11029
+ const response = responseTo(message, id);
11030
+ if (response === void 0) {
11031
+ continue;
11032
+ }
11033
+ if ("error" in response) {
11034
+ throw new CodexAppServerRequestError(method, response.error.code, response.error.message);
11035
+ }
11036
+ return response.result;
11037
+ }
11038
+ };
11039
+ try {
11040
+ const initialised = CodexInitializeResultSchema.safeParse(await request4("initialize", { clientInfo: { name: CLIENT_NAME, title: null, version: package_default.version } }));
11041
+ if (!initialised.success) {
11042
+ throw new CodexAppServerProtocolError("initialize", void 0, initialised.error.message);
11043
+ }
11044
+ connection.send({ jsonrpc: "2.0", method: "initialized" });
11045
+ return await ask(request4, installedVersionOf(initialised.data.userAgent));
11046
+ } finally {
11047
+ await connection.close();
11048
+ }
11049
+ }
11050
+ function validated(method, installedVersion, schema, value) {
11051
+ const parsed = schema.safeParse(value);
11052
+ if (!parsed.success) {
11053
+ throw new CodexAppServerProtocolError(method, installedVersion, parsed.error.message);
11054
+ }
11055
+ return parsed.data;
11056
+ }
11057
+ async function readCodexAccount(port, options) {
11058
+ return await withAppServer(port, options, async (request4, version) => validated("account/read", version, CodexAccountReadSchema, await request4("account/read", { refreshToken: false })));
11059
+ }
11060
+ async function readCodexRateLimits(port, options) {
11061
+ return await withAppServer(port, options, async (request4, version) => validated("account/rateLimits/read", version, CodexRateLimitsReadSchema, await request4("account/rateLimits/read", void 0)));
11062
+ }
11063
+
11064
+ // src/codex/realAppServer.ts
11065
+ import { spawn } from "node:child_process";
11066
+ import readline from "node:readline";
11067
+ var SHUTDOWN_GRACE_MS = 5e3;
11068
+ var realCodexAppServerPort = {
11069
+ open: async ({ bin, codexHome }) => {
11070
+ const child = spawn(bin, ["app-server"], { stdio: ["pipe", "pipe", "ignore"], env: { ...process.env, CODEX_HOME: codexHome } });
11071
+ await new Promise((resolve, reject) => {
11072
+ child.once("spawn", resolve);
11073
+ child.once("error", (error) => {
11074
+ reject(new CodexAppServerUnavailableError(`${bin} could not be started (${error.message})`));
11075
+ });
11076
+ });
11077
+ const exited = new Promise((resolve) => {
11078
+ child.once("exit", () => {
11079
+ resolve();
11080
+ });
11081
+ });
11082
+ const pending = [];
11083
+ const waiting = [];
11084
+ let ended = false;
11085
+ const deliver = (message) => {
11086
+ const waiter = waiting.shift();
11087
+ if (waiter === void 0) {
11088
+ pending.push(message);
11089
+ } else {
11090
+ waiter(message);
11091
+ }
11092
+ };
11093
+ const lines = readline.createInterface({ input: child.stdout });
11094
+ lines.on("line", (line) => {
11095
+ try {
11096
+ deliver(JSON.parse(line));
11097
+ } catch {
11098
+ }
11099
+ });
11100
+ lines.on("close", () => {
11101
+ ended = true;
11102
+ for (const waiter of waiting.splice(0)) {
11103
+ waiter(void 0);
11104
+ }
11105
+ });
11106
+ const connection = {
11107
+ send: (message) => {
11108
+ child.stdin.write(`${JSON.stringify(message)}
11109
+ `);
11110
+ },
11111
+ receive: async () => {
11112
+ if (pending.length > 0) {
11113
+ return pending.shift();
11114
+ }
11115
+ if (ended) {
11116
+ return void 0;
11117
+ }
11118
+ return await new Promise((resolve) => {
11119
+ waiting.push(resolve);
11120
+ });
11121
+ },
11122
+ close: async () => {
11123
+ child.stdin.end();
11124
+ const timer = setTimeout(() => {
11125
+ child.kill("SIGKILL");
11126
+ }, SHUTDOWN_GRACE_MS);
11127
+ await exited;
11128
+ clearTimeout(timer);
11129
+ lines.close();
11130
+ }
11131
+ };
11132
+ return connection;
11133
+ }
11134
+ };
11135
+
10899
11136
  // src/frontdoor/doorClient.ts
10900
11137
  init_cliError();
10901
11138
  init_realPorts();
@@ -11294,7 +11531,7 @@ init_providersStore();
11294
11531
  init_projects();
11295
11532
  init_pipeline();
11296
11533
  import path25 from "node:path";
11297
- import { z as z12 } from "zod";
11534
+ import { z as z13 } from "zod";
11298
11535
  var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
11299
11536
  function projectFragmentOf(rawKey) {
11300
11537
  return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
@@ -11371,9 +11608,9 @@ function lookupKeychainService(run, farmRoot) {
11371
11608
  note: serviceName === void 0 ? `A Keychain entry was found for account "${farmRoot}" but its service name could not be parsed from security's output.` : `Keychain service name for this identity: "${serviceName}".`
11372
11609
  };
11373
11610
  }
11374
- var SettingsSecretsShapeSchema = z12.looseObject({
11375
- env: z12.record(z12.string(), z12.unknown()).optional(),
11376
- hooks: z12.record(z12.string(), z12.array(z12.unknown())).optional()
11611
+ var SettingsSecretsShapeSchema = z13.looseObject({
11612
+ env: z13.record(z13.string(), z13.unknown()).optional(),
11613
+ hooks: z13.record(z13.string(), z13.array(z13.unknown())).optional()
11377
11614
  });
11378
11615
  function hookCommandCountOf(group) {
11379
11616
  if (typeof group !== "object" || group === null) {
@@ -11669,7 +11906,7 @@ init_schema();
11669
11906
  init_claudeVersion();
11670
11907
  init_identity();
11671
11908
  init_projects();
11672
- import { z as z14 } from "zod";
11909
+ import { z as z15 } from "zod";
11673
11910
 
11674
11911
  // src/resolve/types.ts
11675
11912
  var LAYER_KINDS = [
@@ -11730,123 +11967,123 @@ var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
11730
11967
 
11731
11968
  // src/usage/pickReportSchema.ts
11732
11969
  init_plan2();
11733
- import { z as z13 } from "zod";
11734
- var PoolPickCandidateViewSchema = z13.strictObject({
11735
- identity: z13.string(),
11970
+ import { z as z14 } from "zod";
11971
+ var PoolPickCandidateViewSchema = z14.strictObject({
11972
+ identity: z14.string(),
11736
11973
  /** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
11737
- class: z13.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
11974
+ class: z14.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
11738
11975
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
11739
- score: z13.number().optional(),
11976
+ score: z14.number().optional(),
11740
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`. */
11741
- scoreWindow: z13.enum(["sevenDay", "fiveHour"]).optional(),
11978
+ scoreWindow: z14.enum(["sevenDay", "fiveHour"]).optional(),
11742
11979
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
11743
- feasible: z13.boolean(),
11980
+ feasible: z14.boolean(),
11744
11981
  /** When an `ineligible` member can be used again, as an ISO instant. */
11745
- blockedUntil: z13.iso.datetime().optional(),
11982
+ blockedUntil: z14.iso.datetime().optional(),
11746
11983
  plan: PlanClassSchema,
11747
11984
  /** The facts behind the class and score, in the order they matter. */
11748
- reasons: z13.array(z13.string())
11985
+ reasons: z14.array(z14.string())
11749
11986
  });
11750
- var PoolPickReportSchema = z13.strictObject({
11751
- pool: z13.string(),
11752
- directory: z13.string(),
11987
+ var PoolPickReportSchema = z14.strictObject({
11988
+ pool: z14.string(),
11989
+ directory: z14.string(),
11753
11990
  /** The member a launch would run as, absent when every member is refused. */
11754
- pick: z13.string().optional(),
11755
- candidates: z13.array(PoolPickCandidateViewSchema),
11991
+ pick: z14.string().optional(),
11992
+ candidates: z14.array(PoolPickCandidateViewSchema),
11756
11993
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
11757
- missing: z13.array(z13.string()),
11994
+ missing: z14.array(z14.string()),
11758
11995
  /** When nothing can be picked, the soonest any member returns. */
11759
- earliestReturn: z13.strictObject({ identity: z13.string(), at: z13.iso.datetime() }).optional(),
11996
+ earliestReturn: z14.strictObject({ identity: z14.string(), at: z14.iso.datetime() }).optional(),
11760
11997
  /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
11761
- movedOff: z13.strictObject({ identity: z13.string(), reason: z13.string() }).optional(),
11998
+ movedOff: z14.strictObject({ identity: z14.string(), reason: z14.string() }).optional(),
11762
11999
  /** Why the last-pick record could not be read, when that is the case. */
11763
- stickyProblem: z13.string().optional()
12000
+ stickyProblem: z14.string().optional()
11764
12001
  });
11765
12002
 
11766
12003
  // src/checkReportSchema.ts
11767
12004
  var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
11768
- var CheckLayerViewSchema = z14.strictObject({
11769
- id: z14.int(),
11770
- kind: z14.enum(LAYER_KINDS),
11771
- source: z14.string()
11772
- });
11773
- var CheckEntryViewSchema = z14.strictObject({
11774
- path: z14.string(),
11775
- shared: z14.boolean(),
11776
- via: z14.enum(DECISION_VIAS),
12005
+ var CheckLayerViewSchema = z15.strictObject({
12006
+ id: z15.int(),
12007
+ kind: z15.enum(LAYER_KINDS),
12008
+ source: z15.string()
12009
+ });
12010
+ var CheckEntryViewSchema = z15.strictObject({
12011
+ path: z15.string(),
12012
+ shared: z15.boolean(),
12013
+ via: z15.enum(DECISION_VIAS),
11777
12014
  /** The entry's real category, or null when nothing classifies it. */
11778
- category: z14.enum(CATEGORY_NAMES).nullable(),
11779
- rule: z14.strictObject({ key: z14.string(), layer: z14.int() }).optional(),
12015
+ category: z15.enum(CATEGORY_NAMES).nullable(),
12016
+ rule: z15.strictObject({ key: z15.string(), layer: z15.int() }).optional(),
11780
12017
  /** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
11781
- eliminated: z14.readonly(z14.array(z14.strictObject({ key: z14.string(), failed: z14.readonly(z14.array(z14.string())) }))).optional()
11782
- });
11783
- var CheckDiagnosticSchema = z14.strictObject({
11784
- code: z14.enum(DIAGNOSTIC_CODES),
11785
- severity: z14.enum(DIAGNOSTIC_SEVERITIES),
11786
- message: z14.string(),
11787
- subject: z14.string().optional(),
11788
- layer: z14.int().optional()
11789
- });
11790
- var CheckAmbientCredentialSchema = z14.union([z14.strictObject({ ok: z14.literal(true) }), z14.strictObject({ ok: z14.literal(false), variable: z14.string(), message: z14.string() })]);
11791
- var CheckKeychainSchema = z14.strictObject({
11792
- checked: z14.literal(true),
11793
- found: z14.boolean(),
11794
- serviceName: z14.string().optional(),
11795
- note: z14.string()
11796
- });
11797
- var CheckSettingsExposureSchema = z14.strictObject({
11798
- file: z14.string(),
11799
- envKeyNames: z14.readonly(z14.array(z14.string())),
11800
- hookEventNames: z14.readonly(z14.array(z14.string())),
11801
- hookCommandCount: z14.int().nonnegative()
11802
- });
11803
- var CredentialSourceSummarySchema = z14.union([
11804
- z14.strictObject({ kind: z14.literal("env"), variable: z14.string() }),
11805
- z14.strictObject({ kind: z14.literal("file"), path: z14.string() }),
11806
- z14.strictObject({ kind: z14.literal("command"), program: z14.string() }),
11807
- z14.strictObject({ kind: z14.literal("op"), reference: z14.string() }),
11808
- z14.strictObject({ kind: z14.literal("keychain"), service: z14.string(), account: z14.string().optional() }),
11809
- z14.strictObject({ kind: z14.literal("literal") })
12018
+ eliminated: z15.readonly(z15.array(z15.strictObject({ key: z15.string(), failed: z15.readonly(z15.array(z15.string())) }))).optional()
12019
+ });
12020
+ var CheckDiagnosticSchema = z15.strictObject({
12021
+ code: z15.enum(DIAGNOSTIC_CODES),
12022
+ severity: z15.enum(DIAGNOSTIC_SEVERITIES),
12023
+ message: z15.string(),
12024
+ subject: z15.string().optional(),
12025
+ layer: z15.int().optional()
12026
+ });
12027
+ var CheckAmbientCredentialSchema = z15.union([z15.strictObject({ ok: z15.literal(true) }), z15.strictObject({ ok: z15.literal(false), variable: z15.string(), message: z15.string() })]);
12028
+ var CheckKeychainSchema = z15.strictObject({
12029
+ checked: z15.literal(true),
12030
+ found: z15.boolean(),
12031
+ serviceName: z15.string().optional(),
12032
+ note: z15.string()
12033
+ });
12034
+ var CheckSettingsExposureSchema = z15.strictObject({
12035
+ file: z15.string(),
12036
+ envKeyNames: z15.readonly(z15.array(z15.string())),
12037
+ hookEventNames: z15.readonly(z15.array(z15.string())),
12038
+ hookCommandCount: z15.int().nonnegative()
12039
+ });
12040
+ var CredentialSourceSummarySchema = z15.union([
12041
+ z15.strictObject({ kind: z15.literal("env"), variable: z15.string() }),
12042
+ z15.strictObject({ kind: z15.literal("file"), path: z15.string() }),
12043
+ z15.strictObject({ kind: z15.literal("command"), program: z15.string() }),
12044
+ z15.strictObject({ kind: z15.literal("op"), reference: z15.string() }),
12045
+ z15.strictObject({ kind: z15.literal("keychain"), service: z15.string(), account: z15.string().optional() }),
12046
+ z15.strictObject({ kind: z15.literal("literal") })
11810
12047
  ]);
11811
- var CredentialSummarySchema = z14.strictObject({
11812
- target: z14.enum(CREDENTIAL_TARGETS),
11813
- sources: z14.readonly(z14.array(CredentialSourceSummarySchema)),
12048
+ var CredentialSummarySchema = z15.strictObject({
12049
+ target: z15.enum(CREDENTIAL_TARGETS),
12050
+ sources: z15.readonly(z15.array(CredentialSourceSummarySchema)),
11814
12051
  cache: CredentialCacheSchema.optional()
11815
12052
  });
11816
- var CachedCredentialStateSchema = z14.union([
11817
- z14.strictObject({ store: z14.enum(CREDENTIAL_CACHE_STORES), status: z14.literal("empty") }),
11818
- z14.strictObject({ store: z14.enum(CREDENTIAL_CACHE_STORES), status: z14.literal("unreadable"), reason: z14.string() }),
11819
- z14.strictObject({ store: z14.enum(CREDENTIAL_CACHE_STORES), status: z14.enum(["fresh", "expired"]), ageMs: z14.number(), expiresInMs: z14.number().optional() })
12053
+ var CachedCredentialStateSchema = z15.union([
12054
+ z15.strictObject({ store: z15.enum(CREDENTIAL_CACHE_STORES), status: z15.literal("empty") }),
12055
+ z15.strictObject({ store: z15.enum(CREDENTIAL_CACHE_STORES), status: z15.literal("unreadable"), reason: z15.string() }),
12056
+ z15.strictObject({ store: z15.enum(CREDENTIAL_CACHE_STORES), status: z15.enum(["fresh", "expired"]), ageMs: z15.number(), expiresInMs: z15.number().optional() })
11820
12057
  ]);
11821
- var CheckCredentialProviderSchema = z14.union([
11822
- z14.strictObject({ name: z14.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
11823
- z14.strictObject({ name: z14.string(), problem: z14.string() })
12058
+ var CheckCredentialProviderSchema = z15.union([
12059
+ z15.strictObject({ name: z15.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
12060
+ z15.strictObject({ name: z15.string(), problem: z15.string() })
11824
12061
  ]);
11825
- var CheckCredentialSchema = z14.strictObject({
11826
- applies: z14.enum(CHECK_CREDENTIAL_APPLIES),
12062
+ var CheckCredentialSchema = z15.strictObject({
12063
+ applies: z15.enum(CHECK_CREDENTIAL_APPLIES),
11827
12064
  provider: CheckCredentialProviderSchema.optional(),
11828
12065
  identity: CredentialSummarySchema.optional(),
11829
12066
  identityCached: CachedCredentialStateSchema.optional()
11830
12067
  });
11831
- var CheckClaudeVersionSchema = z14.strictObject({
11832
- pinned: z14.strictObject({ version: z14.string(), source: z14.enum(CLAUDE_VERSION_SOURCES), installed: z14.boolean() }).optional(),
11833
- highestInstalled: z14.string().optional(),
11834
- installed: z14.readonly(z14.array(z14.string()))
12068
+ var CheckClaudeVersionSchema = z15.strictObject({
12069
+ pinned: z15.strictObject({ version: z15.string(), source: z15.enum(CLAUDE_VERSION_SOURCES), installed: z15.boolean() }).optional(),
12070
+ highestInstalled: z15.string().optional(),
12071
+ installed: z15.readonly(z15.array(z15.string()))
11835
12072
  });
11836
- var CheckReportJsonSchema = z14.strictObject({
11837
- identity: z14.strictObject({ name: z14.string().nullable(), source: z14.enum(IDENTITY_DECISION_SOURCES) }),
12073
+ var CheckReportJsonSchema = z15.strictObject({
12074
+ identity: z15.strictObject({ name: z15.string().nullable(), source: z15.enum(IDENTITY_DECISION_SOURCES) }),
11838
12075
  /** The pool ranking, when the launch named a pool instead of an identity. */
11839
12076
  pool: PoolPickReportSchema.optional(),
11840
- configProfile: z14.strictObject({ name: z14.string().nullable(), source: z14.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
11841
- layers: z14.readonly(z14.array(CheckLayerViewSchema)),
11842
- entries: z14.readonly(z14.array(CheckEntryViewSchema)),
11843
- projectEncodingAmbiguities: z14.readonly(
11844
- z14.array(z14.strictObject({ fragment: z14.string(), encoded: z14.string(), reason: z14.enum(ENCODING_AMBIGUITY_REASONS), detail: z14.string() }))
12077
+ configProfile: z15.strictObject({ name: z15.string().nullable(), source: z15.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
12078
+ layers: z15.readonly(z15.array(CheckLayerViewSchema)),
12079
+ entries: z15.readonly(z15.array(CheckEntryViewSchema)),
12080
+ projectEncodingAmbiguities: z15.readonly(
12081
+ z15.array(z15.strictObject({ fragment: z15.string(), encoded: z15.string(), reason: z15.enum(ENCODING_AMBIGUITY_REASONS), detail: z15.string() }))
11845
12082
  ),
11846
- diagnostics: z14.readonly(z14.array(CheckDiagnosticSchema)),
12083
+ diagnostics: z15.readonly(z15.array(CheckDiagnosticSchema)),
11847
12084
  ambientCredential: CheckAmbientCredentialSchema,
11848
12085
  keychain: CheckKeychainSchema.optional(),
11849
- settingsExposure: z14.readonly(z14.array(CheckSettingsExposureSchema)),
12086
+ settingsExposure: z15.readonly(z15.array(CheckSettingsExposureSchema)),
11850
12087
  credential: CheckCredentialSchema,
11851
12088
  claudeVersion: CheckClaudeVersionSchema.optional()
11852
12089
  });
@@ -11857,7 +12094,7 @@ init_preflight();
11857
12094
 
11858
12095
  // src/frontdoor/controlSchemas.ts
11859
12096
  import path30 from "node:path";
11860
- import { z as z19 } from "zod";
12097
+ import { z as z20 } from "zod";
11861
12098
 
11862
12099
  // src/doctorReport.ts
11863
12100
  init_claudeShim();
@@ -12052,24 +12289,24 @@ function credentialsFilePath(farmRoot) {
12052
12289
  }
12053
12290
 
12054
12291
  // src/codex/siwcStore.ts
12055
- import { z as z18 } from "zod";
12292
+ import { z as z19 } from "zod";
12056
12293
 
12057
12294
  // src/codex/auth.ts
12058
- import { z as z16 } from "zod";
12059
- var AuthFileSchema = z16.looseObject({
12060
- tokens: z16.looseObject({
12061
- access_token: z16.string().optional(),
12062
- refresh_token: z16.string().optional(),
12063
- id_token: z16.string().optional(),
12064
- account_id: z16.string().optional()
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()
12065
12302
  }).nullish(),
12066
- last_refresh: z16.string().optional()
12303
+ last_refresh: z17.string().optional()
12067
12304
  });
12068
- var TokenGrantSchema = z16.looseObject({
12069
- access_token: z16.string().min(1).optional(),
12070
- refresh_token: z16.string().min(1).optional(),
12071
- id_token: z16.string().min(1).optional(),
12072
- account_id: z16.string().min(1).optional()
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()
12073
12310
  });
12074
12311
  var CodexAuthError = class extends Error {
12075
12312
  constructor(message) {
@@ -12079,41 +12316,41 @@ var CodexAuthError = class extends Error {
12079
12316
  };
12080
12317
 
12081
12318
  // src/codex/siwc.ts
12082
- import { z as z17 } from "zod";
12319
+ import { z as z18 } from "zod";
12083
12320
  var SIWC_RESOURCE = "https://api.openai.com/v1";
12084
12321
  var SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
12085
12322
  var SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
12086
- var TokenResponseSchema = z17.looseObject({
12087
- access_token: z17.string().min(1),
12088
- refresh_token: z17.string().min(1).optional(),
12089
- id_token: z17.string().min(1).optional(),
12090
- expires_in: z17.number().positive(),
12091
- scope: z17.string().optional()
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()
12092
12329
  });
12093
- var JwtHeaderSchema = z17.looseObject({ alg: z17.string(), kid: z17.string().optional() });
12094
- var IdTokenClaimsSchema = z17.looseObject({
12095
- iss: z17.string(),
12096
- sub: z17.string().min(1),
12097
- aud: z17.union([z17.string(), z17.array(z17.string())]),
12098
- exp: z17.number(),
12099
- nonce: z17.string().optional(),
12100
- email: z17.string().optional()
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()
12101
12338
  });
12102
- var JwksSchema = z17.object({ keys: z17.array(z17.looseObject({ kid: z17.string().optional(), kty: z17.string() })) });
12339
+ var JwksSchema = z18.object({ keys: z18.array(z18.looseObject({ kid: z18.string().optional(), kty: z18.string() })) });
12103
12340
 
12104
12341
  // src/codex/siwcStore.ts
12105
- var SiwcGrantSchema = z18.strictObject({
12106
- clientId: z18.string().min(1),
12107
- sub: z18.string().min(1),
12108
- email: z18.string().optional(),
12109
- idToken: z18.string().min(1),
12110
- accessToken: z18.string().min(1),
12111
- refreshToken: z18.string().min(1),
12112
- scopes: z18.array(z18.string()).readonly(),
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(),
12113
12350
  /** When the access token stops working, in milliseconds since the epoch. */
12114
- expiresAt: z18.number()
12351
+ expiresAt: z19.number()
12115
12352
  });
12116
- var SiwcFileSchema = z18.strictObject({ registeredClientId: z18.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12353
+ var SiwcFileSchema = z19.strictObject({ registeredClientId: z19.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12117
12354
  function parseSiwcFile(raw, filePath) {
12118
12355
  let json;
12119
12356
  try {
@@ -12273,17 +12510,17 @@ function pushProvider(push, entry, cacheEnv, signIn) {
12273
12510
  push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
12274
12511
  return;
12275
12512
  }
12276
- const validated2 = ProviderSchema.safeParse(parsed);
12277
- if (!validated2.success) {
12278
- push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
12513
+ const validated3 = ProviderSchema.safeParse(parsed);
12514
+ if (!validated3.success) {
12515
+ push("provider", "fail", new ConfigValidationError(entry.path, validated3.error.issues).message, entry.name);
12279
12516
  return;
12280
12517
  }
12281
- const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
12282
- push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
12283
- if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
12518
+ const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated3.data.credential);
12519
+ push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated3.data)}, credential ${describeCredential(validated3.data.credential)})${cache.text}.`, entry.name);
12520
+ if (validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
12284
12521
  push("provider", "warn", `${entry.name} does not set ENABLE_TOOL_SEARCH: a session on this provider keeps Claude Code's own API as its base URL, so it defers MCP tool loading and sends tool_reference payloads the upstream backend must understand. Set ENABLE_TOOL_SEARCH=false in the provider's env block to load tools upfront instead, when the backend does not support them.`, entry.name);
12285
12522
  }
12286
- if (signIn !== void 0 && isCodexProvider(validated2.data) && validated2.data.codex?.login === "chatgpt-sign-in") {
12523
+ if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
12287
12524
  const problem = signInProblem(signIn);
12288
12525
  if (problem !== void 0) {
12289
12526
  push("provider", "warn", `${entry.name} uses the Sign in with ChatGPT login, but ${problem}`, entry.name);
@@ -12351,13 +12588,13 @@ function runDoctor(params) {
12351
12588
  pushLegacyName(push, params);
12352
12589
  const profileSources = /* @__PURE__ */ new Map();
12353
12590
  for (const entry of params.configProfiles) {
12354
- const validated2 = validateJson(ConfigProfileSchema, entry);
12355
- if (!validated2.ok) {
12356
- push("config-profile", "fail", validated2.message, entry.name);
12591
+ const validated3 = validateJson(ConfigProfileSchema, entry);
12592
+ if (!validated3.ok) {
12593
+ push("config-profile", "fail", validated3.message, entry.name);
12357
12594
  continue;
12358
12595
  }
12359
- profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
12360
- checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
12596
+ profileSources.set(entry.name, { name: entry.name, profile: validated3.data });
12597
+ checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated3.data.launch?.claudeVersion);
12361
12598
  }
12362
12599
  const loadProfile = (name) => profileSources.get(name);
12363
12600
  for (const name of profileSources.keys()) {
@@ -12373,13 +12610,13 @@ function runDoctor(params) {
12373
12610
  const validProfileNames = new Set(profileSources.keys());
12374
12611
  const validIdentityNames = /* @__PURE__ */ new Set();
12375
12612
  for (const entry of params.identities) {
12376
- const validated2 = validateJson(IdentitySchema, entry);
12377
- if (!validated2.ok) {
12378
- push("identity", "fail", validated2.message, entry.name);
12613
+ const validated3 = validateJson(IdentitySchema, entry);
12614
+ if (!validated3.ok) {
12615
+ push("identity", "fail", validated3.message, entry.name);
12379
12616
  continue;
12380
12617
  }
12381
12618
  validIdentityNames.add(entry.name);
12382
- const defaultProfile = validated2.data.defaultConfigProfile;
12619
+ const defaultProfile = validated3.data.defaultConfigProfile;
12383
12620
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
12384
12621
  push(
12385
12622
  "identity",
@@ -12388,7 +12625,7 @@ function runDoctor(params) {
12388
12625
  entry.name
12389
12626
  );
12390
12627
  } else {
12391
- const credential = validated2.data.credential;
12628
+ const credential = validated3.data.credential;
12392
12629
  const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
12393
12630
  push(
12394
12631
  "identity",
@@ -12459,12 +12696,12 @@ function runDoctor(params) {
12459
12696
  if (params.directoryRules.raw === void 0) {
12460
12697
  push("directory-rules", "pass", "No directory-rules.json configured.");
12461
12698
  } else {
12462
- const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
12463
- if (!validated2.ok) {
12464
- push("directory-rules", "fail", validated2.message);
12699
+ const validated3 = validateJson(DirectoryRulesSchema, params.directoryRules);
12700
+ if (!validated3.ok) {
12701
+ push("directory-rules", "fail", validated3.message);
12465
12702
  } else {
12466
12703
  push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
12467
- for (const rule of validated2.data.rules) {
12704
+ for (const rule of validated3.data.rules) {
12468
12705
  const badRefs = [];
12469
12706
  if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
12470
12707
  badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
@@ -12484,11 +12721,11 @@ function runDoctor(params) {
12484
12721
  if (params.globalConfig.raw === void 0) {
12485
12722
  push("global-config", "pass", "No config.json configured.");
12486
12723
  } else {
12487
- const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
12488
- if (!validated2.ok) {
12489
- push("global-config", "fail", validated2.message);
12724
+ const validated3 = validateJson(GlobalConfigSchema, params.globalConfig);
12725
+ if (!validated3.ok) {
12726
+ push("global-config", "fail", validated3.message);
12490
12727
  } else {
12491
- const defaultProfile = validated2.data.defaultConfigProfile;
12728
+ const defaultProfile = validated3.data.defaultConfigProfile;
12492
12729
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
12493
12730
  push(
12494
12731
  "global-config",
@@ -12497,18 +12734,18 @@ function runDoctor(params) {
12497
12734
  );
12498
12735
  } else {
12499
12736
  push("global-config", "pass", `${params.globalConfig.path} is valid.`);
12500
- checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
12737
+ checkPin("global-config", void 0, "config.json", validated3.data.launch?.claudeVersion);
12501
12738
  }
12502
12739
  }
12503
12740
  }
12504
12741
  if (params.categoriesLocal.raw === void 0) {
12505
12742
  push("categories-local", "pass", "No categories.local.json configured.");
12506
12743
  } else {
12507
- const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
12744
+ const validated3 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
12508
12745
  push(
12509
12746
  "categories-local",
12510
- validated2.ok ? "pass" : "fail",
12511
- validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
12747
+ validated3.ok ? "pass" : "fail",
12748
+ validated3.ok ? `${params.categoriesLocal.path} is valid.` : validated3.message
12512
12749
  );
12513
12750
  }
12514
12751
  if (params.headroom.state.raw === void 0) {
@@ -12516,11 +12753,11 @@ function runDoctor(params) {
12516
12753
  } else if (tcpPortEraRecord(params.headroom.state.raw)) {
12517
12754
  push("headroom", "pass", `${params.headroom.state.path} holds a previous release's TCP-port state record; the next launch through headroom claims over it.`);
12518
12755
  } else {
12519
- const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
12520
- if (!validated2.ok) {
12521
- push("headroom", "fail", validated2.message);
12756
+ const validated3 = validateJson(HeadroomStateSchema, params.headroom.state);
12757
+ if (!validated3.ok) {
12758
+ push("headroom", "fail", validated3.message);
12522
12759
  } else {
12523
- const state = validated2.data;
12760
+ const state = validated3.data;
12524
12761
  const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
12525
12762
  const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
12526
12763
  if (state.supervisorPid === void 0) {
@@ -12736,90 +12973,90 @@ function collectDoctorReport(params) {
12736
12973
  // src/frontdoor/controlSchemas.ts
12737
12974
  init_schema2();
12738
12975
  init_state();
12739
- var UsageListOutputSchema = z19.strictObject({ snapshots: z19.readonly(z19.array(UsageSnapshotSchema)) });
12740
- var UsageWindowsInputSchema = z19.strictObject({
12741
- identity: z19.string().min(1),
12742
- provider: z19.string().min(1).optional()
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()
12743
12980
  });
12744
- var EffectiveWindowSchema = z19.strictObject({
12981
+ var EffectiveWindowSchema = z20.strictObject({
12745
12982
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
12746
- reset: z19.boolean(),
12983
+ reset: z20.boolean(),
12747
12984
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
12748
- utilization: z19.number().optional(),
12985
+ utilization: z20.number().optional(),
12749
12986
  /** The reset instant, for a window that has not reset yet and reported one. */
12750
- resetsAtMs: z19.number().optional(),
12987
+ resetsAtMs: z20.number().optional(),
12751
12988
  /** The window's own status, for a window that has not reset yet. */
12752
- status: z19.string().optional()
12989
+ status: z20.string().optional()
12753
12990
  });
12754
- var UsageWindowsOutputSchema = z19.strictObject({
12755
- identity: z19.string(),
12756
- provider: z19.string(),
12991
+ var UsageWindowsOutputSchema = z20.strictObject({
12992
+ identity: z20.string(),
12993
+ provider: z20.string(),
12757
12994
  /** When the rate-limit state the windows come from was observed. */
12758
- observedAt: z19.iso.datetime().optional(),
12995
+ observedAt: z20.iso.datetime().optional(),
12759
12996
  fiveHour: EffectiveWindowSchema.optional(),
12760
12997
  sevenDay: EffectiveWindowSchema.optional()
12761
12998
  });
12762
- var UsageLiveOutputSchema = z19.strictObject({
12999
+ var UsageLiveOutputSchema = z20.strictObject({
12763
13000
  /** 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. */
12764
13001
  latest: RcLiveRateLimitSchema.optional(),
12765
13002
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
12766
- sessions: z19.readonly(z19.array(RcLiveRateLimitSchema))
13003
+ sessions: z20.readonly(z20.array(RcLiveRateLimitSchema))
12767
13004
  });
12768
- var FrontDoorSessionStatusSchema = z19.strictObject({
12769
- pid: z19.int().positive(),
12770
- startedAt: z19.number(),
12771
- alive: z19.boolean()
13005
+ var FrontDoorSessionStatusSchema = z20.strictObject({
13006
+ pid: z20.int().positive(),
13007
+ startedAt: z20.number(),
13008
+ alive: z20.boolean()
12772
13009
  });
12773
- var HeadroomSocketTargetSchema = z19.union([z19.strictObject({ socketPath: z19.string() }), z19.strictObject({ refused: z19.string() })]);
12774
- var FrontDoorStatusOutputSchema = z19.strictObject({
13010
+ var HeadroomSocketTargetSchema = z20.union([z20.strictObject({ socketPath: z20.string() }), z20.strictObject({ refused: z20.string() })]);
13011
+ var FrontDoorStatusOutputSchema = z20.strictObject({
12775
13012
  state: FrontDoorStateSchema,
12776
- supervisorAlive: z19.boolean(),
12777
- sessions: z19.readonly(z19.array(FrontDoorSessionStatusSchema)),
13013
+ supervisorAlive: z20.boolean(),
13014
+ sessions: z20.readonly(z20.array(FrontDoorSessionStatusSchema)),
12778
13015
  headroomSocket: HeadroomSocketTargetSchema.optional(),
12779
- logPath: z19.string(),
12780
- logExists: z19.boolean()
13016
+ logPath: z20.string(),
13017
+ logExists: z20.boolean()
12781
13018
  });
12782
- var FrontDoorSessionsOutputSchema = z19.strictObject({ sessions: z19.readonly(z19.array(FrontDoorSessionStatusSchema)) });
12783
- var CheckRunInputSchema = z19.strictObject({
12784
- path: z19.string().min(1),
12785
- identity: z19.string().min(1).optional()
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()
12786
13023
  }).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
12787
- var PoolPickInputSchema = z19.strictObject({
12788
- pool: z19.string().min(1),
12789
- path: z19.string().min(1)
13024
+ var PoolPickInputSchema = z20.strictObject({
13025
+ pool: z20.string().min(1),
13026
+ path: z20.string().min(1)
12790
13027
  }).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
12791
- var DoctorFindingSchema = z19.strictObject({
12792
- section: z19.enum(DOCTOR_SECTIONS),
12793
- subject: z19.string().optional(),
12794
- severity: z19.enum(DOCTOR_SEVERITIES),
12795
- message: z19.string()
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()
12796
13033
  });
12797
- var DoctorRunOutputSchema = z19.strictObject({
13034
+ var DoctorRunOutputSchema = z20.strictObject({
12798
13035
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
12799
- ok: z19.boolean(),
12800
- findings: z19.readonly(z19.array(DoctorFindingSchema))
12801
- });
12802
- var FrontDoorRestartOutputSchema = z19.strictObject({
12803
- action: z19.literal("restarting"),
12804
- previousPid: z19.int().positive()
12805
- });
12806
- var UpdateCheckOutputSchema = z19.strictObject({
12807
- current: z19.string(),
12808
- latest: z19.string(),
12809
- action: z19.enum(["current", "available", "updated"])
12810
- });
12811
- var CodexSignInSchema = z19.discriminatedUnion("state", [
12812
- z19.strictObject({ state: z19.literal("none") }),
12813
- z19.strictObject({ state: z19.literal("signed-in"), email: z19.string().optional(), planScope: z19.boolean(), accessTokenExpiresAt: z19.number() }),
12814
- z19.strictObject({ state: z19.literal("unreadable"), message: z19.string() })
13036
+ ok: z20.boolean(),
13037
+ findings: z20.readonly(z20.array(DoctorFindingSchema))
13038
+ });
13039
+ var FrontDoorRestartOutputSchema = z20.strictObject({
13040
+ action: z20.literal("restarting"),
13041
+ previousPid: z20.int().positive()
13042
+ });
13043
+ var UpdateCheckOutputSchema = z20.strictObject({
13044
+ current: z20.string(),
13045
+ latest: z20.string(),
13046
+ action: z20.enum(["current", "available", "updated"])
13047
+ });
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() })
12815
13052
  ]);
12816
- var CodexStatusOutputSchema = z19.strictObject({
13053
+ var CodexStatusOutputSchema = z20.strictObject({
12817
13054
  signIn: CodexSignInSchema,
12818
- codexProviders: z19.readonly(z19.array(z19.string()))
13055
+ codexProviders: z20.readonly(z20.array(z20.string()))
12819
13056
  });
12820
- var CodexLogoutOutputSchema = z19.strictObject({
12821
- hadGrant: z19.boolean(),
12822
- revoked: z19.boolean()
13057
+ var CodexLogoutOutputSchema = z20.strictObject({
13058
+ hadGrant: z20.boolean(),
13059
+ revoked: z20.boolean()
12823
13060
  });
12824
13061
 
12825
13062
  // src/frontdoor/codexApi.ts
@@ -12976,130 +13213,130 @@ init_providersStore();
12976
13213
 
12977
13214
  // src/frontdoor/configSchemas.ts
12978
13215
  init_schema();
12979
- import { z as z20 } from "zod";
12980
- var RemovalConfirmationSchema = z20.boolean();
12981
- var CredentialWriteSchema = (targets) => z20.strictObject({
12982
- sources: z20.array(RemoteCredentialSourceSchema).min(1).optional(),
12983
- target: z20.enum(targets).optional(),
12984
- cache: z20.union([z20.literal(false), CredentialCacheSchema]).optional()
12985
- });
12986
- var CredentialSummarySchema2 = z20.strictObject({
12987
- target: z20.enum(CREDENTIAL_TARGETS),
12988
- sources: z20.readonly(z20.array(
12989
- z20.discriminatedUnion("kind", [
12990
- z20.strictObject({ kind: z20.literal("env"), variable: z20.string() }),
12991
- z20.strictObject({ kind: z20.literal("file"), path: z20.string() }),
12992
- z20.strictObject({ kind: z20.literal("command"), program: z20.string() }),
12993
- z20.strictObject({ kind: z20.literal("op"), reference: z20.string() }),
12994
- z20.strictObject({ kind: z20.literal("keychain"), service: z20.string(), account: z20.string().optional() }),
12995
- z20.strictObject({ kind: z20.literal("literal") })
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()
13222
+ });
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") })
12996
13233
  ])
12997
13234
  )),
12998
13235
  cache: CredentialCacheSchema.optional()
12999
13236
  });
13000
- var mutationOutput = (kind, action) => z20.strictObject({ action: z20.literal(action), kind: z20.literal(kind), name: z20.string() });
13001
- var storedMutationOutput = (kind, action, value) => z20.strictObject({ action: z20.literal(action), kind: z20.literal(kind), name: z20.string(), value });
13002
- var IdentityValueSchema = z20.strictObject({
13003
- name: z20.string(),
13004
- defaultConfigProfile: z20.string().optional(),
13005
- allowAmbientCredential: z20.boolean(),
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(),
13006
13243
  credential: CredentialSummarySchema2.optional()
13007
13244
  });
13008
13245
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
13009
- var ProviderValueSchema = z20.strictObject({
13010
- name: z20.string(),
13011
- kind: z20.enum(PROVIDER_KINDS),
13012
- displayName: z20.string(),
13013
- baseUrl: z20.string().optional(),
13246
+ var ProviderValueSchema = z21.strictObject({
13247
+ name: z21.string(),
13248
+ kind: z21.enum(PROVIDER_KINDS),
13249
+ displayName: z21.string(),
13250
+ baseUrl: z21.string().optional(),
13014
13251
  codex: CodexProviderConfigSchema.optional(),
13015
13252
  credential: CredentialSummarySchema2,
13016
- env: z20.record(z20.string(), z20.string()).optional()
13253
+ env: z21.record(z21.string(), z21.string()).optional()
13017
13254
  });
13018
- var ConfigNameInputSchema = z20.strictObject({ name: z20.string().min(1) });
13255
+ var ConfigNameInputSchema = z21.strictObject({ name: z21.string().min(1) });
13019
13256
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
13020
- var ConfigIdentitySetInputSchema = z20.strictObject({
13021
- name: z20.string().min(1),
13022
- defaultConfigProfile: z20.union([z20.string().min(1), z20.literal(false)]).optional(),
13023
- allowAmbientCredential: z20.boolean().optional(),
13024
- credential: z20.union([z20.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
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()
13025
13262
  });
13026
13263
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
13027
- var ConfigIdentityRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13264
+ var ConfigIdentityRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13028
13265
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
13029
13266
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
13030
- var ConfigProfileAddInputSchema = z20.strictObject({
13031
- name: z20.string().min(1),
13032
- extends: z20.array(z20.string().min(1)).optional(),
13033
- description: z20.string().optional()
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()
13034
13271
  });
13035
13272
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
13036
- var ConfigProfileSetInputSchema = z20.strictObject({
13037
- name: z20.string().min(1),
13038
- category: z20.record(z20.string(), z20.boolean()).optional(),
13039
- entry: z20.record(z20.string(), z20.boolean()).optional(),
13040
- extends: z20.union([z20.array(z20.string().min(1)), z20.literal(false)]).optional(),
13041
- description: z20.union([z20.string(), z20.literal(false)]).optional(),
13042
- launch: z20.strictObject({
13043
- skipPermissions: z20.boolean().optional(),
13044
- remoteControl: z20.boolean().optional(),
13045
- headroom: z20.boolean().optional(),
13046
- trackUsage: z20.boolean().optional(),
13047
- provider: z20.union([z20.string().min(1), z20.literal(false)]).optional(),
13048
- claudeVersion: z20.union([z20.string().min(1), z20.literal(false)]).optional()
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()
13049
13286
  }).optional()
13050
13287
  });
13051
13288
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
13052
- var ConfigProfileRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13289
+ var ConfigProfileRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13053
13290
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
13054
13291
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
13055
- var PoolMembersInputSchema = z20.array(z20.string().min(1)).min(1);
13056
- var ConfigPoolAddInputSchema = z20.strictObject({
13057
- name: z20.string().min(1),
13292
+ var PoolMembersInputSchema = z21.array(z21.string().min(1)).min(1);
13293
+ var ConfigPoolAddInputSchema = z21.strictObject({
13294
+ name: z21.string().min(1),
13058
13295
  identities: PoolMembersInputSchema,
13059
- preference: z20.enum(POOL_PREFERENCES).optional()
13296
+ preference: z21.enum(POOL_PREFERENCES).optional()
13060
13297
  });
13061
13298
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
13062
- var ConfigPoolSetInputSchema = z20.strictObject({
13063
- name: z20.string().min(1),
13299
+ var ConfigPoolSetInputSchema = z21.strictObject({
13300
+ name: z21.string().min(1),
13064
13301
  identities: PoolMembersInputSchema.optional(),
13065
- preference: z20.union([z20.enum(POOL_PREFERENCES), z20.literal(false)]).optional()
13302
+ preference: z21.union([z21.enum(POOL_PREFERENCES), z21.literal(false)]).optional()
13066
13303
  });
13067
13304
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
13068
- var ConfigPoolRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13305
+ var ConfigPoolRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13069
13306
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
13070
13307
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
13071
- var ConfigProviderAddInputSchema = z20.strictObject({
13072
- name: z20.string().min(1),
13073
- kind: z20.enum(PROVIDER_KINDS).optional(),
13074
- displayName: z20.string().min(1),
13075
- baseUrl: z20.string().min(1).optional(),
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(),
13076
13313
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
13077
13314
  codex: CodexProviderConfigSchema.optional()
13078
13315
  });
13079
13316
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
13080
- var ConfigProviderSetInputSchema = z20.strictObject({
13081
- name: z20.string().min(1),
13082
- displayName: z20.string().min(1).optional(),
13083
- baseUrl: z20.string().min(1).optional(),
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(),
13084
13321
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
13085
13322
  codex: CodexProviderConfigSchema.optional()
13086
13323
  });
13087
13324
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
13088
- var ConfigProviderRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13325
+ var ConfigProviderRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13089
13326
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
13090
- var ConfigRuleAddInputSchema = z20.strictObject({
13091
- path: z20.string().min(1),
13092
- configProfile: z20.string().min(1).optional(),
13093
- identity: z20.string().min(1).optional()
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()
13094
13331
  });
13095
13332
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
13096
- var ConfigRuleSetInputSchema = z20.strictObject({
13097
- path: z20.string().min(1),
13098
- configProfile: z20.union([z20.string().min(1), z20.literal(false)]).optional(),
13099
- identity: z20.union([z20.string().min(1), z20.literal(false)]).optional()
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()
13100
13337
  });
13101
13338
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
13102
- var ConfigRuleRemoveInputSchema = z20.strictObject({ path: z20.string().min(1), confirm: RemovalConfirmationSchema });
13339
+ var ConfigRuleRemoveInputSchema = z21.strictObject({ path: z21.string().min(1), confirm: RemovalConfirmationSchema });
13103
13340
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
13104
13341
 
13105
13342
  // src/frontdoor/configApi.ts
@@ -13405,41 +13642,41 @@ import { openapi as openapi4 } from "@orpc/openapi";
13405
13642
  import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from "@orpc/server";
13406
13643
 
13407
13644
  // src/frontdoor/eventSchemas.ts
13408
- import { z as z21 } from "zod";
13645
+ import { z as z22 } from "zod";
13409
13646
  var DOOR_EVENT_SOURCE_RC = "rc";
13410
13647
  var LAUNCH_EVENT_SOURCE = "launch";
13411
13648
  var USAGE_EVENT_SOURCE = "usage";
13412
13649
  var DOOR_HEALTH_EVENT_SOURCE = "door";
13413
13650
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
13414
- var DoorEventSchema = z21.strictObject({
13415
- source: z21.string().min(1),
13651
+ var DoorEventSchema = z22.strictObject({
13652
+ source: z22.string().min(1),
13416
13653
  /** A positive integer because the backbone's counters start at one and only ever increase. */
13417
- sequence: z21.number().int().positive(),
13418
- payload: z21.unknown()
13419
- });
13420
- var DoorEventSourceQuerySchema = z21.strictObject({
13421
- sources: z21.array(z21.string().min(1)).min(1).optional()
13422
- });
13423
- var LaunchLifecycleEventSchema = z21.strictObject({
13424
- kind: z21.enum(["registered", "pruned", "ended"]),
13425
- pid: z21.number().int().positive(),
13426
- startedAt: z21.number(),
13427
- observedAt: z21.number()
13428
- });
13429
- var DoorHealthEventSchema = z21.discriminatedUnion("kind", [
13430
- z21.strictObject({ kind: z21.literal("generation"), pid: z21.number().int().positive(), providerPort: z21.number().int().positive(), connectPort: z21.number().int().positive(), directPort: z21.number().int().positive(), observedAt: z21.number() }),
13431
- z21.strictObject({ kind: z21.literal("listenerFailed"), pid: z21.number().int().positive(), listener: z21.enum(["provider", "connect", "direct"]), message: z21.string(), observedAt: z21.number() }),
13432
- z21.strictObject({ kind: z21.literal("binaryTurnover"), pid: z21.number().int().positive(), observedAt: z21.number() }),
13433
- z21.strictObject({ kind: z21.literal("idleShutdown"), pid: z21.number().int().positive(), observedAt: z21.number() })
13654
+ sequence: z22.number().int().positive(),
13655
+ payload: z22.unknown()
13656
+ });
13657
+ var DoorEventSourceQuerySchema = z22.strictObject({
13658
+ sources: z22.array(z22.string().min(1)).min(1).optional()
13659
+ });
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()
13665
+ });
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() })
13434
13671
  ]);
13435
- var QuotaExpiringEventSchema = z21.strictObject({
13436
- identity: z21.string().min(1),
13437
- provider: z21.string().min(1),
13438
- window: z21.enum(["fiveHour", "sevenDay"]),
13672
+ var QuotaExpiringEventSchema = z22.strictObject({
13673
+ identity: z22.string().min(1),
13674
+ provider: z22.string().min(1),
13675
+ window: z22.enum(["fiveHour", "sevenDay"]),
13439
13676
  /** 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. */
13440
- utilization: z21.number().min(0).max(1),
13441
- resetsAt: z21.iso.datetime(),
13442
- observedAt: z21.number()
13677
+ utilization: z22.number().min(0).max(1),
13678
+ resetsAt: z22.iso.datetime(),
13679
+ observedAt: z22.number()
13443
13680
  });
13444
13681
 
13445
13682
  // src/frontdoor/eventsApi.ts
@@ -13523,51 +13760,51 @@ import { openapi as openapi6 } from "@orpc/openapi";
13523
13760
 
13524
13761
  // src/frontdoor/launchSchemas.ts
13525
13762
  import path31 from "node:path";
13526
- import { z as z22 } from "zod";
13763
+ import { z as z23 } from "zod";
13527
13764
  init_claudeVersion();
13528
13765
  init_identity();
13529
- var LaunchResolveInputSchema = z22.strictObject({
13530
- path: z22.string().min(1),
13766
+ var LaunchResolveInputSchema = z23.strictObject({
13767
+ path: z23.string().min(1),
13531
13768
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
13532
- argv: z22.readonly(z22.array(z22.string())).optional(),
13769
+ argv: z23.readonly(z23.array(z23.string())).optional(),
13533
13770
  /** 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. */
13534
- env: z22.record(z22.string(), z22.string()).optional()
13771
+ env: z23.record(z23.string(), z23.string()).optional()
13535
13772
  }).refine((input) => path31.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13536
- var LaunchPoolDecisionSchema = z22.strictObject({
13537
- name: z22.string(),
13538
- reasons: z22.readonly(z22.array(z22.string())),
13539
- movedOff: z22.strictObject({ identity: z22.string(), reason: z22.string() }).optional()
13540
- });
13541
- var LaunchDecisionSchema = z22.strictObject({
13542
- identity: z22.string().optional(),
13543
- identitySource: z22.enum(IDENTITY_DECISION_SOURCES),
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()
13777
+ });
13778
+ var LaunchDecisionSchema = z23.strictObject({
13779
+ identity: z23.string().optional(),
13780
+ identitySource: z23.enum(IDENTITY_DECISION_SOURCES),
13544
13781
  pool: LaunchPoolDecisionSchema.optional(),
13545
- configDirEscapeHatch: z22.boolean(),
13546
- configDir: z22.string().optional(),
13547
- configProfile: z22.string().optional(),
13548
- configProfileSource: z22.enum(CONFIG_PROFILE_DECISION_SOURCES),
13549
- provider: z22.string().optional()
13550
- });
13551
- var LaunchFlagsSchema = z22.strictObject({
13552
- skipPermissions: z22.boolean(),
13553
- remoteControl: z22.boolean(),
13554
- headroom: z22.boolean(),
13555
- trackUsage: z22.boolean()
13556
- });
13557
- var LaunchResolveOutputSchema = z22.strictObject({
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()
13787
+ });
13788
+ var LaunchFlagsSchema = z23.strictObject({
13789
+ skipPermissions: z23.boolean(),
13790
+ remoteControl: z23.boolean(),
13791
+ headroom: z23.boolean(),
13792
+ trackUsage: z23.boolean()
13793
+ });
13794
+ var LaunchResolveOutputSchema = z23.strictObject({
13558
13795
  decision: LaunchDecisionSchema,
13559
13796
  flags: LaunchFlagsSchema,
13560
- claudeVersion: z22.strictObject({ version: z22.string(), source: z22.enum(CLAUDE_VERSION_SOURCES) }).optional(),
13797
+ claudeVersion: z23.strictObject({ version: z23.string(), source: z23.enum(CLAUDE_VERSION_SOURCES) }).optional(),
13561
13798
  /** The real `claude` binary the launch would spawn, on the door's host. */
13562
- bin: z22.string(),
13799
+ bin: z23.string(),
13563
13800
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
13564
- args: z22.readonly(z22.array(z22.string())),
13801
+ args: z23.readonly(z23.array(z23.string())),
13565
13802
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
13566
- credential: z22.strictObject({ subject: z22.enum(["provider", "identity"]), name: z22.string(), summary: CredentialSummarySchema }).optional(),
13567
- routing: z22.strictObject({ frontDoor: z22.boolean(), headroom: z22.boolean() }),
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() }),
13568
13805
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
13569
- environment: z22.readonly(z22.array(z22.string())),
13570
- warnings: z22.readonly(z22.array(z22.string()))
13806
+ environment: z23.readonly(z23.array(z23.string())),
13807
+ warnings: z23.readonly(z23.array(z23.string()))
13571
13808
  });
13572
13809
 
13573
13810
  // src/frontdoor/launchApi.ts
@@ -15834,6 +16071,8 @@ init_ownCli();
15834
16071
  export {
15835
16072
  AMBIENT_CREDENTIAL_VARS,
15836
16073
  CHECK_CREDENTIAL_APPLIES,
16074
+ CODEX_APP_SERVER_GENERATED_AGAINST,
16075
+ CODEX_APP_SERVER_TIMEOUT_MS,
15837
16076
  CONNECT_INTERCEPT_HOST,
15838
16077
  CONNECT_INTERCEPT_HOSTS,
15839
16078
  CONNECT_LIMITS,
@@ -15844,7 +16083,12 @@ export {
15844
16083
  CheckReportJsonSchema,
15845
16084
  CheckRunInputSchema,
15846
16085
  CliError,
16086
+ CodexAccountReadSchema,
16087
+ CodexAppServerProtocolError,
16088
+ CodexAppServerRequestError,
16089
+ CodexAppServerUnavailableError,
15847
16090
  CodexLogoutOutputSchema,
16091
+ CodexRateLimitsReadSchema,
15848
16092
  CodexSignInSchema,
15849
16093
  CodexStatusOutputSchema,
15850
16094
  ConfigIdentityAddOutputSchema,
@@ -16102,6 +16346,8 @@ export {
16102
16346
  rcSelfHostFromEnv,
16103
16347
  rcWebFetchAllowsPrivateFromEnv,
16104
16348
  readActiveIdentity2 as readActiveIdentity,
16349
+ readCodexAccount,
16350
+ readCodexRateLimits,
16105
16351
  readDirectoryRules,
16106
16352
  readFarmManifest,
16107
16353
  readFrontDoorControlMaterial,
@@ -16113,6 +16359,7 @@ export {
16113
16359
  readRcSelfHostRecord,
16114
16360
  readRcSessionFile,
16115
16361
  readUsageSnapshot,
16362
+ realCodexAppServerPort,
16116
16363
  realConnectCertStore,
16117
16364
  realConnectEffects,
16118
16365
  realRcControlTransport,