claude-use 9.7.2 → 9.9.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.7.2",
2642
+ version: "9.9.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
  });
@@ -5230,7 +5230,7 @@ var init_paths = __esm({
5230
5230
  });
5231
5231
 
5232
5232
  // src/credentialCache.ts
5233
- import { z as z11 } from "zod";
5233
+ import { z as z12 } from "zod";
5234
5234
  function effectiveStore(cache, platform) {
5235
5235
  return cache.store ?? (platform === "darwin" ? "keychain" : "file");
5236
5236
  }
@@ -5297,9 +5297,9 @@ var init_credentialCache = __esm({
5297
5297
  init_schema();
5298
5298
  init_preflight();
5299
5299
  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(),
5300
+ CachedCredentialSchema = z12.strictObject({
5301
+ token: z12.string().min(1),
5302
+ fetchedAt: z12.number().int().nonnegative(),
5303
5303
  source: CredentialSourceSchema
5304
5304
  });
5305
5305
  }
@@ -5901,7 +5901,7 @@ var init_envBool = __esm({
5901
5901
  });
5902
5902
 
5903
5903
  // src/launcher/claudeVersion.ts
5904
- function validated(value, origin) {
5904
+ function validated2(value, origin) {
5905
5905
  if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
5906
5906
  throw new InvalidClaudeVersionError(value, origin);
5907
5907
  }
@@ -5909,11 +5909,11 @@ function validated(value, origin) {
5909
5909
  }
5910
5910
  function resolveClaudeVersion(params) {
5911
5911
  if (params.flag !== void 0) {
5912
- return { version: validated(params.flag, "--claude-version"), source: "flag" };
5912
+ return { version: validated2(params.flag, "--claude-version"), source: "flag" };
5913
5913
  }
5914
5914
  const fromEnv = params.env.AGENT_SHIM_CLAUDE_VERSION;
5915
5915
  if (fromEnv !== void 0 && fromEnv !== "") {
5916
- return { version: validated(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
5916
+ return { version: validated2(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
5917
5917
  }
5918
5918
  return params.cascade === void 0 ? void 0 : { version: params.cascade, source: "cascade" };
5919
5919
  }
@@ -6001,7 +6001,7 @@ var init_commandDeps = __esm({
6001
6001
  // src/claudeShim.ts
6002
6002
  import fs8 from "node:fs";
6003
6003
  import path26 from "node:path";
6004
- import { z as z15 } from "zod";
6004
+ import { z as z16 } from "zod";
6005
6005
  function commandFilename(ownExecutablePath, commandName) {
6006
6006
  return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
6007
6007
  }
@@ -6051,10 +6051,10 @@ var init_claudeShim = __esm({
6051
6051
  init_store();
6052
6052
  init_realPorts();
6053
6053
  init_cliError();
6054
- ClaudeShimStateSchema = z15.strictObject({
6055
- targetPath: z15.string().min(1),
6056
- method: z15.enum(["hardlink", "copy"]),
6057
- installedAtMs: z15.number()
6054
+ ClaudeShimStateSchema = z16.strictObject({
6055
+ targetPath: z16.string().min(1),
6056
+ method: z16.enum(["hardlink", "copy"]),
6057
+ installedAtMs: z16.number()
6058
6058
  });
6059
6059
  nodeLinkFs = { link: fs8.linkSync, copyFile: fs8.copyFileSync, chmod: fs8.chmodSync };
6060
6060
  }
@@ -6510,7 +6510,7 @@ var init_headers = __esm({
6510
6510
  });
6511
6511
 
6512
6512
  // src/launcher/flags.ts
6513
- import path32 from "node:path";
6513
+ import path33 from "node:path";
6514
6514
  function resolveLaunchFlags(params) {
6515
6515
  return {
6516
6516
  skipPermissions: params.flags?.skipPermissions ?? parseEnvBool("AGENT_SHIM_SKIP_PERMISSIONS", params.env.AGENT_SHIM_SKIP_PERMISSIONS) ?? params.cascade?.skipPermissions ?? false,
@@ -6541,7 +6541,7 @@ function buildEnv(params) {
6541
6541
  const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
6542
6542
  let providerCustomHeaders;
6543
6543
  if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
6544
- env.CLAUDE_CONFIG_DIR = path32.join(params.identitiesDir, params.resolvedIdentityName);
6544
+ env.CLAUDE_CONFIG_DIR = path33.join(params.identitiesDir, params.resolvedIdentityName);
6545
6545
  }
6546
6546
  if (params.provider !== void 0) {
6547
6547
  const providerEnv = params.provider.definition.env ?? {};
@@ -6803,7 +6803,7 @@ var init_launchHook = __esm({
6803
6803
 
6804
6804
  // src/launcher.ts
6805
6805
  import { randomUUID as randomUUID4 } from "node:crypto";
6806
- import path33 from "node:path";
6806
+ import path34 from "node:path";
6807
6807
  function resolveIdentityCredential(identity, credential, env, port) {
6808
6808
  if (port === void 0) {
6809
6809
  return { ok: false, status: 1, message: `agent-shim: identity ${identity} needs its credential resolved, but this launcher has no credential port wired` };
@@ -6913,7 +6913,7 @@ function decideLaunch(params, readOnly) {
6913
6913
  identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
6914
6914
  globalDefaultConfigProfile: params.globalDefaultConfigProfile
6915
6915
  });
6916
- if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs12.readConfigFile(path33.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
6916
+ if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs12.readConfigFile(path34.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
6917
6917
  log.error(
6918
6918
  `agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
6919
6919
  );
@@ -7025,7 +7025,7 @@ function decideLaunch(params, readOnly) {
7025
7025
  extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
7026
7026
  passthrough: parsedArgv.rest
7027
7027
  });
7028
- const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : path33.join(paths.identitiesDir, identityDecision.name);
7028
+ const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : path34.join(paths.identitiesDir, identityDecision.name);
7029
7029
  const decision = {
7030
7030
  identitySource: identityDecision.source,
7031
7031
  configDirEscapeHatch: identityDecision.configDirEscapeHatch,
@@ -7066,7 +7066,7 @@ function prepareLaunch(params) {
7066
7066
  );
7067
7067
  const updateCheck = runLaunchUpdateCheck({
7068
7068
  mode: params.updateMode ?? "off",
7069
- checkPath: path33.join(paths.root, "update.check"),
7069
+ checkPath: path34.join(paths.root, "update.check"),
7070
7070
  currentVersion: package_default.version,
7071
7071
  port: params.update
7072
7072
  });
@@ -7182,10 +7182,10 @@ function resolveLaunch(params) {
7182
7182
  environment
7183
7183
  };
7184
7184
  }
7185
- function runLaunchPlan(plan, spawn2) {
7185
+ function runLaunchPlan(plan, spawn3) {
7186
7186
  try {
7187
7187
  plan.markChildStarted();
7188
- const result = spawn2.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
7188
+ const result = spawn3.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
7189
7189
  if (result.error !== void 0) {
7190
7190
  throw result.error;
7191
7191
  }
@@ -7226,12 +7226,12 @@ var init_launcher = __esm({
7226
7226
  });
7227
7227
 
7228
7228
  // src/ownCli.ts
7229
- import path34 from "node:path";
7229
+ import path35 from "node:path";
7230
7230
  function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
7231
7231
  if (distDir === void 0) {
7232
7232
  throw new OwnCliPathUnknownError();
7233
7233
  }
7234
- return path34.join(distDir, OWN_CLI_FILE_NAME);
7234
+ return path35.join(distDir, OWN_CLI_FILE_NAME);
7235
7235
  }
7236
7236
  var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
7237
7237
  var init_ownCli = __esm({
@@ -7320,10 +7320,10 @@ request.on("error", (error) => finish(failed, (error.code ? error.code + ": " :
7320
7320
 
7321
7321
  // src/frontdoor/trust.ts
7322
7322
  import { createHash as createHash6 } from "node:crypto";
7323
- import path35 from "node:path";
7323
+ import path36 from "node:path";
7324
7324
  function resolveTrustBundle(params) {
7325
7325
  const { caCertFile, bundlesDir, variable, inherited, fs: fs12 } = params;
7326
- if (inherited === void 0 || inherited === "" || path35.resolve(inherited) === path35.resolve(caCertFile)) {
7326
+ if (inherited === void 0 || inherited === "" || path36.resolve(inherited) === path36.resolve(caCertFile)) {
7327
7327
  return { path: caCertFile };
7328
7328
  }
7329
7329
  const caPem = fs12.readFileUtf8(caCertFile);
@@ -7341,7 +7341,7 @@ function resolveTrustBundle(params) {
7341
7341
  }
7342
7342
  const combined = `${inheritedPem.trimEnd()}
7343
7343
  ${caPem}`;
7344
- const bundle = path35.join(bundlesDir, `${createHash6("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
7344
+ const bundle = path36.join(bundlesDir, `${createHash6("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
7345
7345
  if (!fs12.exists(bundle)) {
7346
7346
  fs12.mkdirp(bundlesDir);
7347
7347
  fs12.writeFileAtomic(bundle, combined);
@@ -7689,7 +7689,7 @@ var init_anthropicUsageRefresh = __esm({
7689
7689
  });
7690
7690
 
7691
7691
  // src/usage/providerQuota.ts
7692
- import { z as z23 } from "zod";
7692
+ import { z as z24 } from "zod";
7693
7693
  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
7694
  var init_providerQuota = __esm({
7695
7695
  "src/usage/providerQuota.ts"() {
@@ -7707,35 +7707,35 @@ var init_providerQuota = __esm({
7707
7707
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
7708
7708
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7]
7709
7709
  ]);
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()
7710
+ ZaiLimitSchema = z24.object({
7711
+ type: z24.string(),
7712
+ unit: z24.number().int(),
7713
+ number: z24.number().int().positive(),
7714
+ percentage: z24.number().nonnegative(),
7715
+ nextResetTime: z24.number().positive().optional(),
7716
+ usage: z24.number().nonnegative().optional(),
7717
+ currentValue: z24.number().nonnegative().optional(),
7718
+ remaining: z24.number().nonnegative().optional()
7719
7719
  });
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) })
7720
+ ZaiResponseSchema = z24.object({
7721
+ success: z24.boolean(),
7722
+ msg: z24.string().optional(),
7723
+ data: z24.object({ level: z24.string().optional(), limits: z24.array(ZaiLimitSchema) })
7724
7724
  });
7725
7725
  OPENROUTER_HOST = "openrouter.ai";
7726
7726
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
7727
7727
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
7728
7728
  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()
7729
+ OpenRouterKeySchema = z24.object({
7730
+ data: z24.object({
7731
+ limit: z24.number().nonnegative().nullable(),
7732
+ limit_remaining: z24.number().nullable(),
7733
+ limit_reset: z24.string().nullable(),
7734
+ is_free_tier: z24.boolean().optional(),
7735
+ free_model_daily_requests: z24.object({ used: z24.number().nonnegative(), limit: z24.number().nonnegative(), remaining: z24.number() }).optional()
7736
7736
  })
7737
7737
  });
7738
- OpenRouterCreditsSchema = z23.object({ data: z23.object({ total_credits: z23.number().nonnegative(), total_usage: z23.number().nonnegative() }) });
7738
+ OpenRouterCreditsSchema = z24.object({ data: z24.object({ total_credits: z24.number().nonnegative(), total_usage: z24.number().nonnegative() }) });
7739
7739
  }
7740
7740
  });
7741
7741
 
@@ -8351,8 +8351,8 @@ function parseConnectTarget(authority) {
8351
8351
  function isInterceptedHost(host, interceptHosts) {
8352
8352
  return interceptHosts.includes(host);
8353
8353
  }
8354
- function servedByPipeline(path36) {
8355
- return path36?.startsWith(ROUTED_PATH_PREFIX) === true;
8354
+ function servedByPipeline(path37) {
8355
+ return path37?.startsWith(ROUTED_PATH_PREFIX) === true;
8356
8356
  }
8357
8357
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
8358
8358
  "connection",
@@ -8887,11 +8887,11 @@ function createRcSessionTracker(deps) {
8887
8887
  };
8888
8888
  const observeExchange = (request4) => {
8889
8889
  const method = (request4.method ?? "").toUpperCase();
8890
- const path36 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
8891
- if (!path36.startsWith(RC_SESSIONS_PATH_PREFIX)) {
8890
+ const path37 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
8891
+ if (!path37.startsWith(RC_SESSIONS_PATH_PREFIX)) {
8892
8892
  return void 0;
8893
8893
  }
8894
- const tail = path36.slice(RC_SESSIONS_PATH_PREFIX.length);
8894
+ const tail = path37.slice(RC_SESSIONS_PATH_PREFIX.length);
8895
8895
  const facts = {
8896
8896
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
8897
8897
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -9273,8 +9273,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
9273
9273
  function isRcReadFileEncoding(value) {
9274
9274
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
9275
9275
  }
9276
- function buildRcReadFilePayload(requestId, path36, options) {
9277
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path36, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
9276
+ function buildRcReadFilePayload(requestId, path37, options) {
9277
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path37, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
9278
9278
  }
9279
9279
  function buildRcFileSuggestionsPayload(requestId, query) {
9280
9280
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -9376,15 +9376,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
9376
9376
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
9377
9377
  return result.ok ? { ...result, requestId } : result;
9378
9378
  }
9379
- async function readRcSessionFile(deps, sessionId, path36, options) {
9380
- if (path36 === "") {
9379
+ async function readRcSessionFile(deps, sessionId, path37, options) {
9380
+ if (path37 === "") {
9381
9381
  return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
9382
9382
  }
9383
9383
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
9384
9384
  return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
9385
9385
  }
9386
9386
  const requestId = deps.newUuid();
9387
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path36, options), `read ${path36} from session ${sessionId}`);
9387
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path37, options), `read ${path37} from session ${sessionId}`);
9388
9388
  return result.ok ? { ...result, requestId } : result;
9389
9389
  }
9390
9390
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -9553,11 +9553,11 @@ function createRcControlHandler(deps) {
9553
9553
  path: "read-file",
9554
9554
  read: (body) => {
9555
9555
  const session = bodyString(body, "session");
9556
- const path36 = bodyString(body, "path");
9556
+ const path37 = bodyString(body, "path");
9557
9557
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
9558
9558
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
9559
- const refused2 = session === void 0 || path36 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
9560
- return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path36, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
9559
+ const refused2 = session === void 0 || path37 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
9560
+ return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path37, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
9561
9561
  }
9562
9562
  },
9563
9563
  {
@@ -9867,9 +9867,9 @@ function requestIdOfBody(body) {
9867
9867
  }
9868
9868
  function frontDoorRcControl(transport, token) {
9869
9869
  const headers = { authorization: `Bearer ${token}` };
9870
- const listAnswerOf = async (path36, what) => {
9870
+ const listAnswerOf = async (path37, what) => {
9871
9871
  try {
9872
- return await transport.request({ method: "GET", path: path36, headers });
9872
+ return await transport.request({ method: "GET", path: path37, headers });
9873
9873
  } catch (error) {
9874
9874
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
9875
9875
  }
@@ -9941,10 +9941,10 @@ function frontDoorRcControl(transport, token) {
9941
9941
  }
9942
9942
  return pending;
9943
9943
  };
9944
- const writeOf = async (path36, body, describeFailure) => {
9944
+ const writeOf = async (path37, body, describeFailure) => {
9945
9945
  let answer;
9946
9946
  try {
9947
- answer = await transport.request({ method: "POST", path: path36, headers: { ...headers, "content-type": "application/json" }, body });
9947
+ answer = await transport.request({ method: "POST", path: path37, headers: { ...headers, "content-type": "application/json" }, body });
9948
9948
  } catch (error) {
9949
9949
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
9950
9950
  }
@@ -9975,10 +9975,10 @@ function frontDoorRcControl(transport, token) {
9975
9975
  endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
9976
9976
  getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
9977
9977
  getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
9978
- readFile: async (sessionId, path36, options) => await writeOf(
9978
+ readFile: async (sessionId, path37, options) => await writeOf(
9979
9979
  `${CONTROL_PATH_PREFIX}/read-file`,
9980
- JSON.stringify({ session: sessionId, path: path36, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
9981
- (status, message) => `reading ${path36} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
9980
+ JSON.stringify({ session: sessionId, path: path37, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
9981
+ (status, message) => `reading ${path37} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
9982
9982
  ),
9983
9983
  fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
9984
9984
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -10137,12 +10137,12 @@ function tlsFacts(options) {
10137
10137
  }
10138
10138
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
10139
10139
  const agent = new ExemptTlsAgent();
10140
- const post = async (path36, headers, body) => await new Promise((resolve, reject) => {
10140
+ const post = async (path37, headers, body) => await new Promise((resolve, reject) => {
10141
10141
  const options = {
10142
10142
  host: target.host,
10143
10143
  port: target.port,
10144
10144
  method: "POST",
10145
- path: path36,
10145
+ path: path37,
10146
10146
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
10147
10147
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
10148
10148
  agent
@@ -10207,12 +10207,12 @@ function lateRcStreamDial(resolve) {
10207
10207
  }
10208
10208
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
10209
10209
  const agent = new ExemptTlsAgent();
10210
- const request4 = async (method, path36, headers, body, signal) => await new Promise((resolve, reject) => {
10210
+ const request4 = async (method, path37, headers, body, signal) => await new Promise((resolve, reject) => {
10211
10211
  const options = {
10212
10212
  host: target.host,
10213
10213
  port: target.port,
10214
10214
  method,
10215
- path: path36,
10215
+ path: path37,
10216
10216
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
10217
10217
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
10218
10218
  agent,
@@ -10254,9 +10254,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
10254
10254
  return { status, body: await readAll(response) };
10255
10255
  },
10256
10256
  openStream: async (sessionId, headers, resume, signal) => {
10257
- const path36 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
10257
+ const path37 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
10258
10258
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
10259
- const { status, response } = await request4("GET", path36, streamHeaders, void 0, signal);
10259
+ const { status, response } = await request4("GET", path37, streamHeaders, void 0, signal);
10260
10260
  if (!isSuccessful2(status)) {
10261
10261
  await readAll(response);
10262
10262
  return { status, chunks: NO_CHUNKS };
@@ -10896,6 +10896,242 @@ function frontDoorRcApiClient(port, ca, token) {
10896
10896
  return createORPCClient(frontDoorApiLink(port, ca, token));
10897
10897
  }
10898
10898
 
10899
+ // src/codex/appServer.ts
10900
+ init_cliError();
10901
+ init_package();
10902
+
10903
+ // src/codex/appServerSchemas.ts
10904
+ import { z as z5 } from "zod";
10905
+ var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
10906
+ var RateLimitWindowSchema = z5.object({
10907
+ usedPercent: z5.number(),
10908
+ resetsAt: z5.number().nullish(),
10909
+ windowDurationMins: z5.number().nullish()
10910
+ });
10911
+ var RateLimitSnapshotSchema = z5.object({
10912
+ limitId: z5.string().nullish(),
10913
+ limitName: z5.string().nullish(),
10914
+ planType: z5.string().nullish(),
10915
+ primary: RateLimitWindowSchema.nullish(),
10916
+ secondary: RateLimitWindowSchema.nullish(),
10917
+ rateLimitReachedType: z5.string().nullish(),
10918
+ spendControlReached: z5.boolean().nullish()
10919
+ });
10920
+ var RateLimitResetCreditSchema = z5.object({
10921
+ id: z5.string(),
10922
+ grantedAt: z5.number(),
10923
+ expiresAt: z5.number().nullish(),
10924
+ resetType: z5.string(),
10925
+ status: z5.string(),
10926
+ title: z5.string().nullish(),
10927
+ description: z5.string().nullish()
10928
+ });
10929
+ var CodexAccountSchema = z5.discriminatedUnion("type", [
10930
+ z5.object({ type: z5.literal("apiKey") }),
10931
+ z5.object({ type: z5.literal("chatgpt"), email: z5.string().nullable(), planType: z5.string() }),
10932
+ z5.object({ type: z5.literal("amazonBedrock"), usesCodexManagedCredentials: z5.boolean().default(false) })
10933
+ ]);
10934
+ var CodexAccountReadSchema = z5.object({
10935
+ account: CodexAccountSchema.nullable(),
10936
+ requiresOpenaiAuth: z5.boolean()
10937
+ });
10938
+ var CodexRateLimitsReadSchema = z5.object({
10939
+ rateLimits: RateLimitSnapshotSchema,
10940
+ rateLimitsByLimitId: z5.record(z5.string(), RateLimitSnapshotSchema).nullish(),
10941
+ rateLimitResetCredits: z5.object({ availableCount: z5.number(), credits: z5.array(RateLimitResetCreditSchema).nullish() }).nullish(),
10942
+ accountId: z5.string().nullish(),
10943
+ ordinaryUsageAllowed: z5.boolean().nullish()
10944
+ });
10945
+ var CodexInitializeResultSchema = z5.object({ userAgent: z5.string() });
10946
+
10947
+ // src/codex/appServer.ts
10948
+ var CodexAppServerUnavailableError = class extends CliError {
10949
+ constructor(detail) {
10950
+ super(`The Codex app-server is not available: ${detail}.`);
10951
+ this.name = "CodexAppServerUnavailableError";
10952
+ }
10953
+ };
10954
+ var CodexAppServerRequestError = class extends CliError {
10955
+ constructor(method, rpcCode, detail) {
10956
+ super(`Codex app-server ${method} failed (${String(rpcCode)}): ${detail}`);
10957
+ this.method = method;
10958
+ this.rpcCode = rpcCode;
10959
+ this.name = "CodexAppServerRequestError";
10960
+ }
10961
+ method;
10962
+ rpcCode;
10963
+ };
10964
+ var CodexAppServerProtocolError = class extends CliError {
10965
+ constructor(method, installedVersion, detail) {
10966
+ super(
10967
+ `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}`
10968
+ );
10969
+ this.method = method;
10970
+ this.installedVersion = installedVersion;
10971
+ this.name = "CodexAppServerProtocolError";
10972
+ }
10973
+ method;
10974
+ installedVersion;
10975
+ };
10976
+ var CODEX_APP_SERVER_TIMEOUT_MS = 3e4;
10977
+ var CLIENT_NAME = "agent-shim";
10978
+ function installedVersionOf(userAgent) {
10979
+ return /^[^/\s]+\/(\S+)/.exec(userAgent)?.[1];
10980
+ }
10981
+ function responseTo(message, id) {
10982
+ if (typeof message !== "object" || message === null || !("id" in message) || message.id !== id) {
10983
+ return void 0;
10984
+ }
10985
+ if ("error" in message && typeof message.error === "object" && message.error !== null) {
10986
+ const { error } = message;
10987
+ const code = "code" in error && typeof error.code === "number" ? error.code : 0;
10988
+ const detail = "message" in error && typeof error.message === "string" ? error.message : "no message";
10989
+ return { error: { code, message: detail } };
10990
+ }
10991
+ return "result" in message ? { result: message.result } : void 0;
10992
+ }
10993
+ async function withAppServer(port, options, ask) {
10994
+ const connection = await port.open({ bin: options.bin ?? "codex", codexHome: options.codexHome });
10995
+ let nextId = 0;
10996
+ const timeoutMs = options.timeoutMs ?? CODEX_APP_SERVER_TIMEOUT_MS;
10997
+ const stopper = AbortSignal.any([...options.signal === void 0 ? [] : [options.signal], AbortSignal.timeout(timeoutMs)]);
10998
+ const stopReason = () => {
10999
+ if (options.signal?.aborted !== true) {
11000
+ return new CodexAppServerUnavailableError(`it did not answer within ${String(timeoutMs)} ms`);
11001
+ }
11002
+ const reason = options.signal.reason;
11003
+ return reason instanceof Error ? reason : new Error(`the Codex app-server read was aborted: ${String(reason)}`);
11004
+ };
11005
+ const aborted = new Promise((_resolve, reject) => {
11006
+ if (stopper.aborted) {
11007
+ reject(stopReason());
11008
+ return;
11009
+ }
11010
+ stopper.addEventListener(
11011
+ "abort",
11012
+ () => {
11013
+ reject(stopReason());
11014
+ },
11015
+ { once: true }
11016
+ );
11017
+ });
11018
+ aborted.catch(() => void 0);
11019
+ const request4 = async (method, params) => {
11020
+ nextId += 1;
11021
+ const id = nextId;
11022
+ connection.send({ jsonrpc: "2.0", id, method, params });
11023
+ for (; ; ) {
11024
+ const message = await Promise.race([connection.receive(), aborted]);
11025
+ if (message === void 0) {
11026
+ throw new CodexAppServerUnavailableError(`it ended before answering ${method}`);
11027
+ }
11028
+ const response = responseTo(message, id);
11029
+ if (response === void 0) {
11030
+ continue;
11031
+ }
11032
+ if ("error" in response) {
11033
+ throw new CodexAppServerRequestError(method, response.error.code, response.error.message);
11034
+ }
11035
+ return response.result;
11036
+ }
11037
+ };
11038
+ try {
11039
+ const initialised = CodexInitializeResultSchema.safeParse(await request4("initialize", { clientInfo: { name: CLIENT_NAME, title: null, version: package_default.version } }));
11040
+ if (!initialised.success) {
11041
+ throw new CodexAppServerProtocolError("initialize", void 0, initialised.error.message);
11042
+ }
11043
+ connection.send({ jsonrpc: "2.0", method: "initialized" });
11044
+ return await ask(request4, installedVersionOf(initialised.data.userAgent));
11045
+ } finally {
11046
+ await connection.close();
11047
+ }
11048
+ }
11049
+ function validated(method, installedVersion, schema, value) {
11050
+ const parsed = schema.safeParse(value);
11051
+ if (!parsed.success) {
11052
+ throw new CodexAppServerProtocolError(method, installedVersion, parsed.error.message);
11053
+ }
11054
+ return parsed.data;
11055
+ }
11056
+ async function readCodexAccount(port, options) {
11057
+ return await withAppServer(port, options, async (request4, version) => validated("account/read", version, CodexAccountReadSchema, await request4("account/read", { refreshToken: false })));
11058
+ }
11059
+ async function readCodexRateLimits(port, options) {
11060
+ return await withAppServer(port, options, async (request4, version) => validated("account/rateLimits/read", version, CodexRateLimitsReadSchema, await request4("account/rateLimits/read", void 0)));
11061
+ }
11062
+
11063
+ // src/codex/realAppServer.ts
11064
+ import { spawn } from "node:child_process";
11065
+ import readline from "node:readline";
11066
+ var SHUTDOWN_GRACE_MS = 5e3;
11067
+ var realCodexAppServerPort = {
11068
+ open: async ({ bin, codexHome }) => {
11069
+ const child = spawn(bin, ["app-server"], { stdio: ["pipe", "pipe", "ignore"], env: { ...process.env, CODEX_HOME: codexHome } });
11070
+ await new Promise((resolve, reject) => {
11071
+ child.once("spawn", resolve);
11072
+ child.once("error", (error) => {
11073
+ reject(new CodexAppServerUnavailableError(`${bin} could not be started (${error.message})`));
11074
+ });
11075
+ });
11076
+ const exited = new Promise((resolve) => {
11077
+ child.once("exit", () => {
11078
+ resolve();
11079
+ });
11080
+ });
11081
+ const pending = [];
11082
+ const waiting = [];
11083
+ let ended = false;
11084
+ const deliver = (message) => {
11085
+ const waiter = waiting.shift();
11086
+ if (waiter === void 0) {
11087
+ pending.push(message);
11088
+ } else {
11089
+ waiter(message);
11090
+ }
11091
+ };
11092
+ const lines = readline.createInterface({ input: child.stdout });
11093
+ lines.on("line", (line) => {
11094
+ try {
11095
+ deliver(JSON.parse(line));
11096
+ } catch {
11097
+ }
11098
+ });
11099
+ lines.on("close", () => {
11100
+ ended = true;
11101
+ for (const waiter of waiting.splice(0)) {
11102
+ waiter(void 0);
11103
+ }
11104
+ });
11105
+ const connection = {
11106
+ send: (message) => {
11107
+ child.stdin.write(`${JSON.stringify(message)}
11108
+ `);
11109
+ },
11110
+ receive: async () => {
11111
+ if (pending.length > 0) {
11112
+ return pending.shift();
11113
+ }
11114
+ if (ended) {
11115
+ return void 0;
11116
+ }
11117
+ return await new Promise((resolve) => {
11118
+ waiting.push(resolve);
11119
+ });
11120
+ },
11121
+ close: async () => {
11122
+ child.stdin.end();
11123
+ const timer = setTimeout(() => {
11124
+ child.kill("SIGKILL");
11125
+ }, SHUTDOWN_GRACE_MS);
11126
+ await exited;
11127
+ clearTimeout(timer);
11128
+ lines.close();
11129
+ }
11130
+ };
11131
+ return connection;
11132
+ }
11133
+ };
11134
+
10899
11135
  // src/frontdoor/doorClient.ts
10900
11136
  init_cliError();
10901
11137
  init_realPorts();
@@ -11171,19 +11407,19 @@ function writePools(paths, pools) {
11171
11407
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
11172
11408
  }
11173
11409
  function poolCycleOf(pools, name) {
11174
- const walk = (current, path36) => {
11410
+ const walk = (current, path37) => {
11175
11411
  for (const entry of pools[current]?.identities ?? []) {
11176
11412
  const nested = poolNameOf(poolMemberIdentity(entry));
11177
11413
  if (nested === void 0) {
11178
11414
  continue;
11179
11415
  }
11180
11416
  if (nested === name) {
11181
- return [...path36, nested];
11417
+ return [...path37, nested];
11182
11418
  }
11183
- if (path36.includes(nested)) {
11419
+ if (path37.includes(nested)) {
11184
11420
  continue;
11185
11421
  }
11186
- const found = walk(nested, [...path36, nested]);
11422
+ const found = walk(nested, [...path37, nested]);
11187
11423
  if (found !== void 0) {
11188
11424
  return found;
11189
11425
  }
@@ -11294,7 +11530,7 @@ init_providersStore();
11294
11530
  init_projects();
11295
11531
  init_pipeline();
11296
11532
  import path25 from "node:path";
11297
- import { z as z12 } from "zod";
11533
+ import { z as z13 } from "zod";
11298
11534
  var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
11299
11535
  function projectFragmentOf(rawKey) {
11300
11536
  return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
@@ -11371,9 +11607,9 @@ function lookupKeychainService(run, farmRoot) {
11371
11607
  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
11608
  };
11373
11609
  }
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()
11610
+ var SettingsSecretsShapeSchema = z13.looseObject({
11611
+ env: z13.record(z13.string(), z13.unknown()).optional(),
11612
+ hooks: z13.record(z13.string(), z13.array(z13.unknown())).optional()
11377
11613
  });
11378
11614
  function hookCommandCountOf(group) {
11379
11615
  if (typeof group !== "object" || group === null) {
@@ -11669,7 +11905,7 @@ init_schema();
11669
11905
  init_claudeVersion();
11670
11906
  init_identity();
11671
11907
  init_projects();
11672
- import { z as z14 } from "zod";
11908
+ import { z as z15 } from "zod";
11673
11909
 
11674
11910
  // src/resolve/types.ts
11675
11911
  var LAYER_KINDS = [
@@ -11730,123 +11966,123 @@ var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
11730
11966
 
11731
11967
  // src/usage/pickReportSchema.ts
11732
11968
  init_plan2();
11733
- import { z as z13 } from "zod";
11734
- var PoolPickCandidateViewSchema = z13.strictObject({
11735
- identity: z13.string(),
11969
+ import { z as z14 } from "zod";
11970
+ var PoolPickCandidateViewSchema = z14.strictObject({
11971
+ identity: z14.string(),
11736
11972
  /** 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"]),
11973
+ class: z14.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
11738
11974
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
11739
- score: z13.number().optional(),
11975
+ score: z14.number().optional(),
11740
11976
  /** 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(),
11977
+ scoreWindow: z14.enum(["sevenDay", "fiveHour"]).optional(),
11742
11978
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
11743
- feasible: z13.boolean(),
11979
+ feasible: z14.boolean(),
11744
11980
  /** When an `ineligible` member can be used again, as an ISO instant. */
11745
- blockedUntil: z13.iso.datetime().optional(),
11981
+ blockedUntil: z14.iso.datetime().optional(),
11746
11982
  plan: PlanClassSchema,
11747
11983
  /** The facts behind the class and score, in the order they matter. */
11748
- reasons: z13.array(z13.string())
11984
+ reasons: z14.array(z14.string())
11749
11985
  });
11750
- var PoolPickReportSchema = z13.strictObject({
11751
- pool: z13.string(),
11752
- directory: z13.string(),
11986
+ var PoolPickReportSchema = z14.strictObject({
11987
+ pool: z14.string(),
11988
+ directory: z14.string(),
11753
11989
  /** The member a launch would run as, absent when every member is refused. */
11754
- pick: z13.string().optional(),
11755
- candidates: z13.array(PoolPickCandidateViewSchema),
11990
+ pick: z14.string().optional(),
11991
+ candidates: z14.array(PoolPickCandidateViewSchema),
11756
11992
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
11757
- missing: z13.array(z13.string()),
11993
+ missing: z14.array(z14.string()),
11758
11994
  /** When nothing can be picked, the soonest any member returns. */
11759
- earliestReturn: z13.strictObject({ identity: z13.string(), at: z13.iso.datetime() }).optional(),
11995
+ earliestReturn: z14.strictObject({ identity: z14.string(), at: z14.iso.datetime() }).optional(),
11760
11996
  /** 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(),
11997
+ movedOff: z14.strictObject({ identity: z14.string(), reason: z14.string() }).optional(),
11762
11998
  /** Why the last-pick record could not be read, when that is the case. */
11763
- stickyProblem: z13.string().optional()
11999
+ stickyProblem: z14.string().optional()
11764
12000
  });
11765
12001
 
11766
12002
  // src/checkReportSchema.ts
11767
12003
  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),
12004
+ var CheckLayerViewSchema = z15.strictObject({
12005
+ id: z15.int(),
12006
+ kind: z15.enum(LAYER_KINDS),
12007
+ source: z15.string()
12008
+ });
12009
+ var CheckEntryViewSchema = z15.strictObject({
12010
+ path: z15.string(),
12011
+ shared: z15.boolean(),
12012
+ via: z15.enum(DECISION_VIAS),
11777
12013
  /** 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(),
12014
+ category: z15.enum(CATEGORY_NAMES).nullable(),
12015
+ rule: z15.strictObject({ key: z15.string(), layer: z15.int() }).optional(),
11780
12016
  /** 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") })
12017
+ eliminated: z15.readonly(z15.array(z15.strictObject({ key: z15.string(), failed: z15.readonly(z15.array(z15.string())) }))).optional()
12018
+ });
12019
+ var CheckDiagnosticSchema = z15.strictObject({
12020
+ code: z15.enum(DIAGNOSTIC_CODES),
12021
+ severity: z15.enum(DIAGNOSTIC_SEVERITIES),
12022
+ message: z15.string(),
12023
+ subject: z15.string().optional(),
12024
+ layer: z15.int().optional()
12025
+ });
12026
+ var CheckAmbientCredentialSchema = z15.union([z15.strictObject({ ok: z15.literal(true) }), z15.strictObject({ ok: z15.literal(false), variable: z15.string(), message: z15.string() })]);
12027
+ var CheckKeychainSchema = z15.strictObject({
12028
+ checked: z15.literal(true),
12029
+ found: z15.boolean(),
12030
+ serviceName: z15.string().optional(),
12031
+ note: z15.string()
12032
+ });
12033
+ var CheckSettingsExposureSchema = z15.strictObject({
12034
+ file: z15.string(),
12035
+ envKeyNames: z15.readonly(z15.array(z15.string())),
12036
+ hookEventNames: z15.readonly(z15.array(z15.string())),
12037
+ hookCommandCount: z15.int().nonnegative()
12038
+ });
12039
+ var CredentialSourceSummarySchema = z15.union([
12040
+ z15.strictObject({ kind: z15.literal("env"), variable: z15.string() }),
12041
+ z15.strictObject({ kind: z15.literal("file"), path: z15.string() }),
12042
+ z15.strictObject({ kind: z15.literal("command"), program: z15.string() }),
12043
+ z15.strictObject({ kind: z15.literal("op"), reference: z15.string() }),
12044
+ z15.strictObject({ kind: z15.literal("keychain"), service: z15.string(), account: z15.string().optional() }),
12045
+ z15.strictObject({ kind: z15.literal("literal") })
11810
12046
  ]);
11811
- var CredentialSummarySchema = z14.strictObject({
11812
- target: z14.enum(CREDENTIAL_TARGETS),
11813
- sources: z14.readonly(z14.array(CredentialSourceSummarySchema)),
12047
+ var CredentialSummarySchema = z15.strictObject({
12048
+ target: z15.enum(CREDENTIAL_TARGETS),
12049
+ sources: z15.readonly(z15.array(CredentialSourceSummarySchema)),
11814
12050
  cache: CredentialCacheSchema.optional()
11815
12051
  });
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() })
12052
+ var CachedCredentialStateSchema = z15.union([
12053
+ z15.strictObject({ store: z15.enum(CREDENTIAL_CACHE_STORES), status: z15.literal("empty") }),
12054
+ z15.strictObject({ store: z15.enum(CREDENTIAL_CACHE_STORES), status: z15.literal("unreadable"), reason: z15.string() }),
12055
+ z15.strictObject({ store: z15.enum(CREDENTIAL_CACHE_STORES), status: z15.enum(["fresh", "expired"]), ageMs: z15.number(), expiresInMs: z15.number().optional() })
11820
12056
  ]);
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() })
12057
+ var CheckCredentialProviderSchema = z15.union([
12058
+ z15.strictObject({ name: z15.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
12059
+ z15.strictObject({ name: z15.string(), problem: z15.string() })
11824
12060
  ]);
11825
- var CheckCredentialSchema = z14.strictObject({
11826
- applies: z14.enum(CHECK_CREDENTIAL_APPLIES),
12061
+ var CheckCredentialSchema = z15.strictObject({
12062
+ applies: z15.enum(CHECK_CREDENTIAL_APPLIES),
11827
12063
  provider: CheckCredentialProviderSchema.optional(),
11828
12064
  identity: CredentialSummarySchema.optional(),
11829
12065
  identityCached: CachedCredentialStateSchema.optional()
11830
12066
  });
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()))
12067
+ var CheckClaudeVersionSchema = z15.strictObject({
12068
+ pinned: z15.strictObject({ version: z15.string(), source: z15.enum(CLAUDE_VERSION_SOURCES), installed: z15.boolean() }).optional(),
12069
+ highestInstalled: z15.string().optional(),
12070
+ installed: z15.readonly(z15.array(z15.string()))
11835
12071
  });
11836
- var CheckReportJsonSchema = z14.strictObject({
11837
- identity: z14.strictObject({ name: z14.string().nullable(), source: z14.enum(IDENTITY_DECISION_SOURCES) }),
12072
+ var CheckReportJsonSchema = z15.strictObject({
12073
+ identity: z15.strictObject({ name: z15.string().nullable(), source: z15.enum(IDENTITY_DECISION_SOURCES) }),
11838
12074
  /** The pool ranking, when the launch named a pool instead of an identity. */
11839
12075
  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() }))
12076
+ configProfile: z15.strictObject({ name: z15.string().nullable(), source: z15.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
12077
+ layers: z15.readonly(z15.array(CheckLayerViewSchema)),
12078
+ entries: z15.readonly(z15.array(CheckEntryViewSchema)),
12079
+ projectEncodingAmbiguities: z15.readonly(
12080
+ z15.array(z15.strictObject({ fragment: z15.string(), encoded: z15.string(), reason: z15.enum(ENCODING_AMBIGUITY_REASONS), detail: z15.string() }))
11845
12081
  ),
11846
- diagnostics: z14.readonly(z14.array(CheckDiagnosticSchema)),
12082
+ diagnostics: z15.readonly(z15.array(CheckDiagnosticSchema)),
11847
12083
  ambientCredential: CheckAmbientCredentialSchema,
11848
12084
  keychain: CheckKeychainSchema.optional(),
11849
- settingsExposure: z14.readonly(z14.array(CheckSettingsExposureSchema)),
12085
+ settingsExposure: z15.readonly(z15.array(CheckSettingsExposureSchema)),
11850
12086
  credential: CheckCredentialSchema,
11851
12087
  claudeVersion: CheckClaudeVersionSchema.optional()
11852
12088
  });
@@ -11856,8 +12092,8 @@ init_middleware();
11856
12092
  init_preflight();
11857
12093
 
11858
12094
  // src/frontdoor/controlSchemas.ts
11859
- import path29 from "node:path";
11860
- import { z as z19 } from "zod";
12095
+ import path30 from "node:path";
12096
+ import { z as z20 } from "zod";
11861
12097
 
11862
12098
  // src/doctorReport.ts
11863
12099
  init_claudeShim();
@@ -12027,27 +12263,49 @@ function removeIdentity(paths, name) {
12027
12263
  // src/doctorReport.ts
12028
12264
  init_realPorts();
12029
12265
  import fs10 from "node:fs";
12266
+ import path29 from "node:path";
12267
+
12268
+ // src/usage/signIn.ts
12030
12269
  import path28 from "node:path";
12270
+ var CREDENTIALS_FILE = ".credentials.json";
12271
+ function keychainHasItem(run, account) {
12272
+ return run.run("security", ["find-generic-password", "-a", account]).status === 0;
12273
+ }
12274
+ function decideSignIn(facts) {
12275
+ if (facts.hasCredentialBlock) {
12276
+ return { state: "token", detail: "supplies its own credential through a credential block, so a stored login is not what a launch uses" };
12277
+ }
12278
+ if (facts.keychainItem === true) {
12279
+ return { state: "signed-in", detail: "a login is stored in the macOS Keychain" };
12280
+ }
12281
+ if (facts.credentialsFile) {
12282
+ return { state: "signed-in", detail: `a login is stored in ${CREDENTIALS_FILE}` };
12283
+ }
12284
+ return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
12285
+ }
12286
+ function credentialsFilePath(farmRoot) {
12287
+ return path28.join(farmRoot, CREDENTIALS_FILE);
12288
+ }
12031
12289
 
12032
12290
  // src/codex/siwcStore.ts
12033
- import { z as z18 } from "zod";
12291
+ import { z as z19 } from "zod";
12034
12292
 
12035
12293
  // src/codex/auth.ts
12036
- import { z as z16 } from "zod";
12037
- var AuthFileSchema = z16.looseObject({
12038
- tokens: z16.looseObject({
12039
- access_token: z16.string().optional(),
12040
- refresh_token: z16.string().optional(),
12041
- id_token: z16.string().optional(),
12042
- account_id: z16.string().optional()
12294
+ import { z as z17 } from "zod";
12295
+ var AuthFileSchema = z17.looseObject({
12296
+ tokens: z17.looseObject({
12297
+ access_token: z17.string().optional(),
12298
+ refresh_token: z17.string().optional(),
12299
+ id_token: z17.string().optional(),
12300
+ account_id: z17.string().optional()
12043
12301
  }).nullish(),
12044
- last_refresh: z16.string().optional()
12302
+ last_refresh: z17.string().optional()
12045
12303
  });
12046
- var TokenGrantSchema = z16.looseObject({
12047
- access_token: z16.string().min(1).optional(),
12048
- refresh_token: z16.string().min(1).optional(),
12049
- id_token: z16.string().min(1).optional(),
12050
- account_id: z16.string().min(1).optional()
12304
+ var TokenGrantSchema = z17.looseObject({
12305
+ access_token: z17.string().min(1).optional(),
12306
+ refresh_token: z17.string().min(1).optional(),
12307
+ id_token: z17.string().min(1).optional(),
12308
+ account_id: z17.string().min(1).optional()
12051
12309
  });
12052
12310
  var CodexAuthError = class extends Error {
12053
12311
  constructor(message) {
@@ -12057,41 +12315,41 @@ var CodexAuthError = class extends Error {
12057
12315
  };
12058
12316
 
12059
12317
  // src/codex/siwc.ts
12060
- import { z as z17 } from "zod";
12318
+ import { z as z18 } from "zod";
12061
12319
  var SIWC_RESOURCE = "https://api.openai.com/v1";
12062
12320
  var SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
12063
12321
  var SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
12064
- var TokenResponseSchema = z17.looseObject({
12065
- access_token: z17.string().min(1),
12066
- refresh_token: z17.string().min(1).optional(),
12067
- id_token: z17.string().min(1).optional(),
12068
- expires_in: z17.number().positive(),
12069
- scope: z17.string().optional()
12322
+ var TokenResponseSchema = z18.looseObject({
12323
+ access_token: z18.string().min(1),
12324
+ refresh_token: z18.string().min(1).optional(),
12325
+ id_token: z18.string().min(1).optional(),
12326
+ expires_in: z18.number().positive(),
12327
+ scope: z18.string().optional()
12070
12328
  });
12071
- var JwtHeaderSchema = z17.looseObject({ alg: z17.string(), kid: z17.string().optional() });
12072
- var IdTokenClaimsSchema = z17.looseObject({
12073
- iss: z17.string(),
12074
- sub: z17.string().min(1),
12075
- aud: z17.union([z17.string(), z17.array(z17.string())]),
12076
- exp: z17.number(),
12077
- nonce: z17.string().optional(),
12078
- email: z17.string().optional()
12329
+ var JwtHeaderSchema = z18.looseObject({ alg: z18.string(), kid: z18.string().optional() });
12330
+ var IdTokenClaimsSchema = z18.looseObject({
12331
+ iss: z18.string(),
12332
+ sub: z18.string().min(1),
12333
+ aud: z18.union([z18.string(), z18.array(z18.string())]),
12334
+ exp: z18.number(),
12335
+ nonce: z18.string().optional(),
12336
+ email: z18.string().optional()
12079
12337
  });
12080
- var JwksSchema = z17.object({ keys: z17.array(z17.looseObject({ kid: z17.string().optional(), kty: z17.string() })) });
12338
+ var JwksSchema = z18.object({ keys: z18.array(z18.looseObject({ kid: z18.string().optional(), kty: z18.string() })) });
12081
12339
 
12082
12340
  // src/codex/siwcStore.ts
12083
- var SiwcGrantSchema = z18.strictObject({
12084
- clientId: z18.string().min(1),
12085
- sub: z18.string().min(1),
12086
- email: z18.string().optional(),
12087
- idToken: z18.string().min(1),
12088
- accessToken: z18.string().min(1),
12089
- refreshToken: z18.string().min(1),
12090
- scopes: z18.array(z18.string()).readonly(),
12341
+ var SiwcGrantSchema = z19.strictObject({
12342
+ clientId: z19.string().min(1),
12343
+ sub: z19.string().min(1),
12344
+ email: z19.string().optional(),
12345
+ idToken: z19.string().min(1),
12346
+ accessToken: z19.string().min(1),
12347
+ refreshToken: z19.string().min(1),
12348
+ scopes: z19.array(z19.string()).readonly(),
12091
12349
  /** When the access token stops working, in milliseconds since the epoch. */
12092
- expiresAt: z18.number()
12350
+ expiresAt: z19.number()
12093
12351
  });
12094
- var SiwcFileSchema = z18.strictObject({ registeredClientId: z18.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12352
+ var SiwcFileSchema = z19.strictObject({ registeredClientId: z19.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12095
12353
  function parseSiwcFile(raw, filePath) {
12096
12354
  let json;
12097
12355
  try {
@@ -12128,6 +12386,7 @@ var DOCTOR_SECTIONS = [
12128
12386
  "legacy-name",
12129
12387
  "config-profile",
12130
12388
  "identity",
12389
+ "sign-in",
12131
12390
  "pool",
12132
12391
  "provider",
12133
12392
  "keychain",
@@ -12170,7 +12429,7 @@ function tcpPortEraRecord(raw) {
12170
12429
  return (has("port") || has("lastPort")) && !has("socketPath");
12171
12430
  }
12172
12431
  function pushPathResolution(push, resolution) {
12173
- const ownDir = path28.dirname(resolution.ownExecutablePath);
12432
+ const ownDir = path29.dirname(resolution.ownExecutablePath);
12174
12433
  switch (resolution.agentShim.status) {
12175
12434
  case "ok":
12176
12435
  push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
@@ -12250,17 +12509,17 @@ function pushProvider(push, entry, cacheEnv, signIn) {
12250
12509
  push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
12251
12510
  return;
12252
12511
  }
12253
- const validated2 = ProviderSchema.safeParse(parsed);
12254
- if (!validated2.success) {
12255
- push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
12512
+ const validated3 = ProviderSchema.safeParse(parsed);
12513
+ if (!validated3.success) {
12514
+ push("provider", "fail", new ConfigValidationError(entry.path, validated3.error.issues).message, entry.name);
12256
12515
  return;
12257
12516
  }
12258
- const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
12259
- push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
12260
- if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
12517
+ const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated3.data.credential);
12518
+ push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated3.data)}, credential ${describeCredential(validated3.data.credential)})${cache.text}.`, entry.name);
12519
+ if (validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
12261
12520
  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);
12262
12521
  }
12263
- if (signIn !== void 0 && isCodexProvider(validated2.data) && validated2.data.codex?.login === "chatgpt-sign-in") {
12522
+ if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
12264
12523
  const problem = signInProblem(signIn);
12265
12524
  if (problem !== void 0) {
12266
12525
  push("provider", "warn", `${entry.name} uses the Sign in with ChatGPT login, but ${problem}`, entry.name);
@@ -12269,14 +12528,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
12269
12528
  }
12270
12529
  function pushLegacyName(push, params) {
12271
12530
  const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
12272
- if (legacyVariables.length === 0 && path28.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
12531
+ if (legacyVariables.length === 0 && path29.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
12273
12532
  push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
12274
12533
  return;
12275
12534
  }
12276
12535
  for (const name of legacyVariables) {
12277
12536
  push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
12278
12537
  }
12279
- if (path28.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
12538
+ if (path29.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
12280
12539
  push(
12281
12540
  "legacy-name",
12282
12541
  "warn",
@@ -12328,13 +12587,13 @@ function runDoctor(params) {
12328
12587
  pushLegacyName(push, params);
12329
12588
  const profileSources = /* @__PURE__ */ new Map();
12330
12589
  for (const entry of params.configProfiles) {
12331
- const validated2 = validateJson(ConfigProfileSchema, entry);
12332
- if (!validated2.ok) {
12333
- push("config-profile", "fail", validated2.message, entry.name);
12590
+ const validated3 = validateJson(ConfigProfileSchema, entry);
12591
+ if (!validated3.ok) {
12592
+ push("config-profile", "fail", validated3.message, entry.name);
12334
12593
  continue;
12335
12594
  }
12336
- profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
12337
- checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
12595
+ profileSources.set(entry.name, { name: entry.name, profile: validated3.data });
12596
+ checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated3.data.launch?.claudeVersion);
12338
12597
  }
12339
12598
  const loadProfile = (name) => profileSources.get(name);
12340
12599
  for (const name of profileSources.keys()) {
@@ -12350,13 +12609,13 @@ function runDoctor(params) {
12350
12609
  const validProfileNames = new Set(profileSources.keys());
12351
12610
  const validIdentityNames = /* @__PURE__ */ new Set();
12352
12611
  for (const entry of params.identities) {
12353
- const validated2 = validateJson(IdentitySchema, entry);
12354
- if (!validated2.ok) {
12355
- push("identity", "fail", validated2.message, entry.name);
12612
+ const validated3 = validateJson(IdentitySchema, entry);
12613
+ if (!validated3.ok) {
12614
+ push("identity", "fail", validated3.message, entry.name);
12356
12615
  continue;
12357
12616
  }
12358
12617
  validIdentityNames.add(entry.name);
12359
- const defaultProfile = validated2.data.defaultConfigProfile;
12618
+ const defaultProfile = validated3.data.defaultConfigProfile;
12360
12619
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
12361
12620
  push(
12362
12621
  "identity",
@@ -12365,7 +12624,7 @@ function runDoctor(params) {
12365
12624
  entry.name
12366
12625
  );
12367
12626
  } else {
12368
- const credential = validated2.data.credential;
12627
+ const credential = validated3.data.credential;
12369
12628
  const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
12370
12629
  push(
12371
12630
  "identity",
@@ -12373,6 +12632,18 @@ function runDoctor(params) {
12373
12632
  `${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
12374
12633
  entry.name
12375
12634
  );
12635
+ const signIn = decideSignIn({
12636
+ hasCredentialBlock: credential !== void 0,
12637
+ keychainItem: params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0,
12638
+ credentialsFile: entry.credentialsFilePresent,
12639
+ platform: params.platform
12640
+ });
12641
+ push(
12642
+ "sign-in",
12643
+ signIn.state === "signed-out" ? "warn" : "pass",
12644
+ signIn.state === "signed-out" ? `${entry.name} is signed out (${signIn.detail}). Run \`agent-shim run @${entry.name}\` and sign in.` : `${entry.name} ${signIn.state === "token" ? "uses a credential block" : "is signed in"} (${signIn.detail}).`,
12645
+ entry.name
12646
+ );
12376
12647
  }
12377
12648
  }
12378
12649
  const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
@@ -12418,18 +12689,18 @@ function runDoctor(params) {
12418
12689
  } else {
12419
12690
  for (const entry of params.identities) {
12420
12691
  const result = lookupKeychainService(params.run, entry.farmRoot);
12421
- push("keychain", result.found ? "pass" : "warn", result.note, entry.name);
12692
+ push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
12422
12693
  }
12423
12694
  }
12424
12695
  if (params.directoryRules.raw === void 0) {
12425
12696
  push("directory-rules", "pass", "No directory-rules.json configured.");
12426
12697
  } else {
12427
- const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
12428
- if (!validated2.ok) {
12429
- push("directory-rules", "fail", validated2.message);
12698
+ const validated3 = validateJson(DirectoryRulesSchema, params.directoryRules);
12699
+ if (!validated3.ok) {
12700
+ push("directory-rules", "fail", validated3.message);
12430
12701
  } else {
12431
12702
  push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
12432
- for (const rule of validated2.data.rules) {
12703
+ for (const rule of validated3.data.rules) {
12433
12704
  const badRefs = [];
12434
12705
  if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
12435
12706
  badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
@@ -12449,11 +12720,11 @@ function runDoctor(params) {
12449
12720
  if (params.globalConfig.raw === void 0) {
12450
12721
  push("global-config", "pass", "No config.json configured.");
12451
12722
  } else {
12452
- const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
12453
- if (!validated2.ok) {
12454
- push("global-config", "fail", validated2.message);
12723
+ const validated3 = validateJson(GlobalConfigSchema, params.globalConfig);
12724
+ if (!validated3.ok) {
12725
+ push("global-config", "fail", validated3.message);
12455
12726
  } else {
12456
- const defaultProfile = validated2.data.defaultConfigProfile;
12727
+ const defaultProfile = validated3.data.defaultConfigProfile;
12457
12728
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
12458
12729
  push(
12459
12730
  "global-config",
@@ -12462,18 +12733,18 @@ function runDoctor(params) {
12462
12733
  );
12463
12734
  } else {
12464
12735
  push("global-config", "pass", `${params.globalConfig.path} is valid.`);
12465
- checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
12736
+ checkPin("global-config", void 0, "config.json", validated3.data.launch?.claudeVersion);
12466
12737
  }
12467
12738
  }
12468
12739
  }
12469
12740
  if (params.categoriesLocal.raw === void 0) {
12470
12741
  push("categories-local", "pass", "No categories.local.json configured.");
12471
12742
  } else {
12472
- const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
12743
+ const validated3 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
12473
12744
  push(
12474
12745
  "categories-local",
12475
- validated2.ok ? "pass" : "fail",
12476
- validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
12746
+ validated3.ok ? "pass" : "fail",
12747
+ validated3.ok ? `${params.categoriesLocal.path} is valid.` : validated3.message
12477
12748
  );
12478
12749
  }
12479
12750
  if (params.headroom.state.raw === void 0) {
@@ -12481,11 +12752,11 @@ function runDoctor(params) {
12481
12752
  } else if (tcpPortEraRecord(params.headroom.state.raw)) {
12482
12753
  push("headroom", "pass", `${params.headroom.state.path} holds a previous release's TCP-port state record; the next launch through headroom claims over it.`);
12483
12754
  } else {
12484
- const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
12485
- if (!validated2.ok) {
12486
- push("headroom", "fail", validated2.message);
12755
+ const validated3 = validateJson(HeadroomStateSchema, params.headroom.state);
12756
+ if (!validated3.ok) {
12757
+ push("headroom", "fail", validated3.message);
12487
12758
  } else {
12488
- const state = validated2.data;
12759
+ const state = validated3.data;
12489
12760
  const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
12490
12761
  const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
12491
12762
  if (state.supervisorPid === void 0) {
@@ -12553,6 +12824,7 @@ var SECTION_TITLES = {
12553
12824
  "legacy-name": "Former `claude-use` name",
12554
12825
  "config-profile": "Configuration profiles",
12555
12826
  identity: "Identities",
12827
+ "sign-in": "Sign-in",
12556
12828
  pool: "Pools",
12557
12829
  provider: "Providers",
12558
12830
  keychain: "macOS Keychain",
@@ -12569,6 +12841,7 @@ var SECTION_ORDER = [
12569
12841
  "path-resolution",
12570
12842
  "config-profile",
12571
12843
  "identity",
12844
+ "sign-in",
12572
12845
  "pool",
12573
12846
  "provider",
12574
12847
  "keychain",
@@ -12618,18 +12891,18 @@ function collectDoctorReport(params) {
12618
12891
  const { paths } = params;
12619
12892
  const identityNames = fs10.existsSync(paths.identitiesDir) ? fs10.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
12620
12893
  const identities = identityNames.map((name) => {
12621
- const farmRoot = path28.join(paths.identitiesDir, name);
12622
- const identityPath = path28.join(farmRoot, "identity.json");
12623
- return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
12894
+ const farmRoot = path29.join(paths.identitiesDir, name);
12895
+ const identityPath = path29.join(farmRoot, "identity.json");
12896
+ return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: fs10.existsSync(credentialsFilePath(farmRoot)) };
12624
12897
  });
12625
12898
  const profileNames = fs10.existsSync(paths.configProfilesDir) ? fs10.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
12626
12899
  const configProfiles = profileNames.map((name) => {
12627
- const profilePath = path28.join(paths.configProfilesDir, `${name}.json`);
12900
+ const profilePath = path29.join(paths.configProfilesDir, `${name}.json`);
12628
12901
  return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
12629
12902
  });
12630
12903
  const providerNames = fs10.existsSync(paths.providersDir) ? fs10.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
12631
12904
  const providers = providerNames.map((name) => {
12632
- const providerPath = path28.join(paths.providersDir, `${name}.json`);
12905
+ const providerPath = path29.join(paths.providersDir, `${name}.json`);
12633
12906
  return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
12634
12907
  });
12635
12908
  const ownExecutablePath = realOwnExecutablePath();
@@ -12641,12 +12914,12 @@ function collectDoctorReport(params) {
12641
12914
  binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
12642
12915
  }
12643
12916
  const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
12644
- const pathDirs = (params.env.PATH ?? "").split(path28.delimiter).filter((dir) => dir !== "");
12917
+ const pathDirs = (params.env.PATH ?? "").split(path29.delimiter).filter((dir) => dir !== "");
12645
12918
  const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
12646
12919
  findPathShadow({
12647
12920
  pathDirs,
12648
- targetDir: path28.dirname(shimState.targetPath),
12649
- targetFilename: path28.basename(shimState.targetPath),
12921
+ targetDir: path29.dirname(shimState.targetPath),
12922
+ targetFilename: path29.basename(shimState.targetPath),
12650
12923
  findExecutableInDir
12651
12924
  }),
12652
12925
  shimState.targetPath,
@@ -12672,7 +12945,7 @@ function collectDoctorReport(params) {
12672
12945
  agentShim: refinePathShadow(
12673
12946
  findPathShadow({
12674
12947
  pathDirs,
12675
- targetDir: path28.dirname(ownExecutablePath),
12948
+ targetDir: path29.dirname(ownExecutablePath),
12676
12949
  targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
12677
12950
  findExecutableInDir
12678
12951
  }),
@@ -12699,90 +12972,90 @@ function collectDoctorReport(params) {
12699
12972
  // src/frontdoor/controlSchemas.ts
12700
12973
  init_schema2();
12701
12974
  init_state();
12702
- var UsageListOutputSchema = z19.strictObject({ snapshots: z19.readonly(z19.array(UsageSnapshotSchema)) });
12703
- var UsageWindowsInputSchema = z19.strictObject({
12704
- identity: z19.string().min(1),
12705
- provider: z19.string().min(1).optional()
12975
+ var UsageListOutputSchema = z20.strictObject({ snapshots: z20.readonly(z20.array(UsageSnapshotSchema)) });
12976
+ var UsageWindowsInputSchema = z20.strictObject({
12977
+ identity: z20.string().min(1),
12978
+ provider: z20.string().min(1).optional()
12706
12979
  });
12707
- var EffectiveWindowSchema = z19.strictObject({
12980
+ var EffectiveWindowSchema = z20.strictObject({
12708
12981
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
12709
- reset: z19.boolean(),
12982
+ reset: z20.boolean(),
12710
12983
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
12711
- utilization: z19.number().optional(),
12984
+ utilization: z20.number().optional(),
12712
12985
  /** The reset instant, for a window that has not reset yet and reported one. */
12713
- resetsAtMs: z19.number().optional(),
12986
+ resetsAtMs: z20.number().optional(),
12714
12987
  /** The window's own status, for a window that has not reset yet. */
12715
- status: z19.string().optional()
12988
+ status: z20.string().optional()
12716
12989
  });
12717
- var UsageWindowsOutputSchema = z19.strictObject({
12718
- identity: z19.string(),
12719
- provider: z19.string(),
12990
+ var UsageWindowsOutputSchema = z20.strictObject({
12991
+ identity: z20.string(),
12992
+ provider: z20.string(),
12720
12993
  /** When the rate-limit state the windows come from was observed. */
12721
- observedAt: z19.iso.datetime().optional(),
12994
+ observedAt: z20.iso.datetime().optional(),
12722
12995
  fiveHour: EffectiveWindowSchema.optional(),
12723
12996
  sevenDay: EffectiveWindowSchema.optional()
12724
12997
  });
12725
- var UsageLiveOutputSchema = z19.strictObject({
12998
+ var UsageLiveOutputSchema = z20.strictObject({
12726
12999
  /** 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. */
12727
13000
  latest: RcLiveRateLimitSchema.optional(),
12728
13001
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
12729
- sessions: z19.readonly(z19.array(RcLiveRateLimitSchema))
13002
+ sessions: z20.readonly(z20.array(RcLiveRateLimitSchema))
12730
13003
  });
12731
- var FrontDoorSessionStatusSchema = z19.strictObject({
12732
- pid: z19.int().positive(),
12733
- startedAt: z19.number(),
12734
- alive: z19.boolean()
13004
+ var FrontDoorSessionStatusSchema = z20.strictObject({
13005
+ pid: z20.int().positive(),
13006
+ startedAt: z20.number(),
13007
+ alive: z20.boolean()
12735
13008
  });
12736
- var HeadroomSocketTargetSchema = z19.union([z19.strictObject({ socketPath: z19.string() }), z19.strictObject({ refused: z19.string() })]);
12737
- var FrontDoorStatusOutputSchema = z19.strictObject({
13009
+ var HeadroomSocketTargetSchema = z20.union([z20.strictObject({ socketPath: z20.string() }), z20.strictObject({ refused: z20.string() })]);
13010
+ var FrontDoorStatusOutputSchema = z20.strictObject({
12738
13011
  state: FrontDoorStateSchema,
12739
- supervisorAlive: z19.boolean(),
12740
- sessions: z19.readonly(z19.array(FrontDoorSessionStatusSchema)),
13012
+ supervisorAlive: z20.boolean(),
13013
+ sessions: z20.readonly(z20.array(FrontDoorSessionStatusSchema)),
12741
13014
  headroomSocket: HeadroomSocketTargetSchema.optional(),
12742
- logPath: z19.string(),
12743
- logExists: z19.boolean()
12744
- });
12745
- var FrontDoorSessionsOutputSchema = z19.strictObject({ sessions: z19.readonly(z19.array(FrontDoorSessionStatusSchema)) });
12746
- var CheckRunInputSchema = z19.strictObject({
12747
- path: z19.string().min(1),
12748
- identity: z19.string().min(1).optional()
12749
- }).refine((input) => path29.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
12750
- var PoolPickInputSchema = z19.strictObject({
12751
- pool: z19.string().min(1),
12752
- path: z19.string().min(1)
12753
- }).refine((input) => path29.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
12754
- var DoctorFindingSchema = z19.strictObject({
12755
- section: z19.enum(DOCTOR_SECTIONS),
12756
- subject: z19.string().optional(),
12757
- severity: z19.enum(DOCTOR_SEVERITIES),
12758
- message: z19.string()
12759
- });
12760
- var DoctorRunOutputSchema = z19.strictObject({
13015
+ logPath: z20.string(),
13016
+ logExists: z20.boolean()
13017
+ });
13018
+ var FrontDoorSessionsOutputSchema = z20.strictObject({ sessions: z20.readonly(z20.array(FrontDoorSessionStatusSchema)) });
13019
+ var CheckRunInputSchema = z20.strictObject({
13020
+ path: z20.string().min(1),
13021
+ identity: z20.string().min(1).optional()
13022
+ }).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13023
+ var PoolPickInputSchema = z20.strictObject({
13024
+ pool: z20.string().min(1),
13025
+ path: z20.string().min(1)
13026
+ }).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13027
+ var DoctorFindingSchema = z20.strictObject({
13028
+ section: z20.enum(DOCTOR_SECTIONS),
13029
+ subject: z20.string().optional(),
13030
+ severity: z20.enum(DOCTOR_SEVERITIES),
13031
+ message: z20.string()
13032
+ });
13033
+ var DoctorRunOutputSchema = z20.strictObject({
12761
13034
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
12762
- ok: z19.boolean(),
12763
- findings: z19.readonly(z19.array(DoctorFindingSchema))
12764
- });
12765
- var FrontDoorRestartOutputSchema = z19.strictObject({
12766
- action: z19.literal("restarting"),
12767
- previousPid: z19.int().positive()
12768
- });
12769
- var UpdateCheckOutputSchema = z19.strictObject({
12770
- current: z19.string(),
12771
- latest: z19.string(),
12772
- action: z19.enum(["current", "available", "updated"])
12773
- });
12774
- var CodexSignInSchema = z19.discriminatedUnion("state", [
12775
- z19.strictObject({ state: z19.literal("none") }),
12776
- z19.strictObject({ state: z19.literal("signed-in"), email: z19.string().optional(), planScope: z19.boolean(), accessTokenExpiresAt: z19.number() }),
12777
- z19.strictObject({ state: z19.literal("unreadable"), message: z19.string() })
13035
+ ok: z20.boolean(),
13036
+ findings: z20.readonly(z20.array(DoctorFindingSchema))
13037
+ });
13038
+ var FrontDoorRestartOutputSchema = z20.strictObject({
13039
+ action: z20.literal("restarting"),
13040
+ previousPid: z20.int().positive()
13041
+ });
13042
+ var UpdateCheckOutputSchema = z20.strictObject({
13043
+ current: z20.string(),
13044
+ latest: z20.string(),
13045
+ action: z20.enum(["current", "available", "updated"])
13046
+ });
13047
+ var CodexSignInSchema = z20.discriminatedUnion("state", [
13048
+ z20.strictObject({ state: z20.literal("none") }),
13049
+ z20.strictObject({ state: z20.literal("signed-in"), email: z20.string().optional(), planScope: z20.boolean(), accessTokenExpiresAt: z20.number() }),
13050
+ z20.strictObject({ state: z20.literal("unreadable"), message: z20.string() })
12778
13051
  ]);
12779
- var CodexStatusOutputSchema = z19.strictObject({
13052
+ var CodexStatusOutputSchema = z20.strictObject({
12780
13053
  signIn: CodexSignInSchema,
12781
- codexProviders: z19.readonly(z19.array(z19.string()))
13054
+ codexProviders: z20.readonly(z20.array(z20.string()))
12782
13055
  });
12783
- var CodexLogoutOutputSchema = z19.strictObject({
12784
- hadGrant: z19.boolean(),
12785
- revoked: z19.boolean()
13056
+ var CodexLogoutOutputSchema = z20.strictObject({
13057
+ hadGrant: z20.boolean(),
13058
+ revoked: z20.boolean()
12786
13059
  });
12787
13060
 
12788
13061
  // src/frontdoor/codexApi.ts
@@ -12939,130 +13212,130 @@ init_providersStore();
12939
13212
 
12940
13213
  // src/frontdoor/configSchemas.ts
12941
13214
  init_schema();
12942
- import { z as z20 } from "zod";
12943
- var RemovalConfirmationSchema = z20.boolean();
12944
- var CredentialWriteSchema = (targets) => z20.strictObject({
12945
- sources: z20.array(RemoteCredentialSourceSchema).min(1).optional(),
12946
- target: z20.enum(targets).optional(),
12947
- cache: z20.union([z20.literal(false), CredentialCacheSchema]).optional()
12948
- });
12949
- var CredentialSummarySchema2 = z20.strictObject({
12950
- target: z20.enum(CREDENTIAL_TARGETS),
12951
- sources: z20.readonly(z20.array(
12952
- z20.discriminatedUnion("kind", [
12953
- z20.strictObject({ kind: z20.literal("env"), variable: z20.string() }),
12954
- z20.strictObject({ kind: z20.literal("file"), path: z20.string() }),
12955
- z20.strictObject({ kind: z20.literal("command"), program: z20.string() }),
12956
- z20.strictObject({ kind: z20.literal("op"), reference: z20.string() }),
12957
- z20.strictObject({ kind: z20.literal("keychain"), service: z20.string(), account: z20.string().optional() }),
12958
- z20.strictObject({ kind: z20.literal("literal") })
13215
+ import { z as z21 } from "zod";
13216
+ var RemovalConfirmationSchema = z21.boolean();
13217
+ var CredentialWriteSchema = (targets) => z21.strictObject({
13218
+ sources: z21.array(RemoteCredentialSourceSchema).min(1).optional(),
13219
+ target: z21.enum(targets).optional(),
13220
+ cache: z21.union([z21.literal(false), CredentialCacheSchema]).optional()
13221
+ });
13222
+ var CredentialSummarySchema2 = z21.strictObject({
13223
+ target: z21.enum(CREDENTIAL_TARGETS),
13224
+ sources: z21.readonly(z21.array(
13225
+ z21.discriminatedUnion("kind", [
13226
+ z21.strictObject({ kind: z21.literal("env"), variable: z21.string() }),
13227
+ z21.strictObject({ kind: z21.literal("file"), path: z21.string() }),
13228
+ z21.strictObject({ kind: z21.literal("command"), program: z21.string() }),
13229
+ z21.strictObject({ kind: z21.literal("op"), reference: z21.string() }),
13230
+ z21.strictObject({ kind: z21.literal("keychain"), service: z21.string(), account: z21.string().optional() }),
13231
+ z21.strictObject({ kind: z21.literal("literal") })
12959
13232
  ])
12960
13233
  )),
12961
13234
  cache: CredentialCacheSchema.optional()
12962
13235
  });
12963
- var mutationOutput = (kind, action) => z20.strictObject({ action: z20.literal(action), kind: z20.literal(kind), name: z20.string() });
12964
- var storedMutationOutput = (kind, action, value) => z20.strictObject({ action: z20.literal(action), kind: z20.literal(kind), name: z20.string(), value });
12965
- var IdentityValueSchema = z20.strictObject({
12966
- name: z20.string(),
12967
- defaultConfigProfile: z20.string().optional(),
12968
- allowAmbientCredential: z20.boolean(),
13236
+ var mutationOutput = (kind, action) => z21.strictObject({ action: z21.literal(action), kind: z21.literal(kind), name: z21.string() });
13237
+ var storedMutationOutput = (kind, action, value) => z21.strictObject({ action: z21.literal(action), kind: z21.literal(kind), name: z21.string(), value });
13238
+ var IdentityValueSchema = z21.strictObject({
13239
+ name: z21.string(),
13240
+ defaultConfigProfile: z21.string().optional(),
13241
+ allowAmbientCredential: z21.boolean(),
12969
13242
  credential: CredentialSummarySchema2.optional()
12970
13243
  });
12971
13244
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
12972
- var ProviderValueSchema = z20.strictObject({
12973
- name: z20.string(),
12974
- kind: z20.enum(PROVIDER_KINDS),
12975
- displayName: z20.string(),
12976
- baseUrl: z20.string().optional(),
13245
+ var ProviderValueSchema = z21.strictObject({
13246
+ name: z21.string(),
13247
+ kind: z21.enum(PROVIDER_KINDS),
13248
+ displayName: z21.string(),
13249
+ baseUrl: z21.string().optional(),
12977
13250
  codex: CodexProviderConfigSchema.optional(),
12978
13251
  credential: CredentialSummarySchema2,
12979
- env: z20.record(z20.string(), z20.string()).optional()
13252
+ env: z21.record(z21.string(), z21.string()).optional()
12980
13253
  });
12981
- var ConfigNameInputSchema = z20.strictObject({ name: z20.string().min(1) });
13254
+ var ConfigNameInputSchema = z21.strictObject({ name: z21.string().min(1) });
12982
13255
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
12983
- var ConfigIdentitySetInputSchema = z20.strictObject({
12984
- name: z20.string().min(1),
12985
- defaultConfigProfile: z20.union([z20.string().min(1), z20.literal(false)]).optional(),
12986
- allowAmbientCredential: z20.boolean().optional(),
12987
- credential: z20.union([z20.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
13256
+ var ConfigIdentitySetInputSchema = z21.strictObject({
13257
+ name: z21.string().min(1),
13258
+ defaultConfigProfile: z21.union([z21.string().min(1), z21.literal(false)]).optional(),
13259
+ allowAmbientCredential: z21.boolean().optional(),
13260
+ credential: z21.union([z21.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
12988
13261
  });
12989
13262
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
12990
- var ConfigIdentityRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13263
+ var ConfigIdentityRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
12991
13264
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
12992
13265
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
12993
- var ConfigProfileAddInputSchema = z20.strictObject({
12994
- name: z20.string().min(1),
12995
- extends: z20.array(z20.string().min(1)).optional(),
12996
- description: z20.string().optional()
13266
+ var ConfigProfileAddInputSchema = z21.strictObject({
13267
+ name: z21.string().min(1),
13268
+ extends: z21.array(z21.string().min(1)).optional(),
13269
+ description: z21.string().optional()
12997
13270
  });
12998
13271
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
12999
- var ConfigProfileSetInputSchema = z20.strictObject({
13000
- name: z20.string().min(1),
13001
- category: z20.record(z20.string(), z20.boolean()).optional(),
13002
- entry: z20.record(z20.string(), z20.boolean()).optional(),
13003
- extends: z20.union([z20.array(z20.string().min(1)), z20.literal(false)]).optional(),
13004
- description: z20.union([z20.string(), z20.literal(false)]).optional(),
13005
- launch: z20.strictObject({
13006
- skipPermissions: z20.boolean().optional(),
13007
- remoteControl: z20.boolean().optional(),
13008
- headroom: z20.boolean().optional(),
13009
- trackUsage: z20.boolean().optional(),
13010
- provider: z20.union([z20.string().min(1), z20.literal(false)]).optional(),
13011
- claudeVersion: z20.union([z20.string().min(1), z20.literal(false)]).optional()
13272
+ var ConfigProfileSetInputSchema = z21.strictObject({
13273
+ name: z21.string().min(1),
13274
+ category: z21.record(z21.string(), z21.boolean()).optional(),
13275
+ entry: z21.record(z21.string(), z21.boolean()).optional(),
13276
+ extends: z21.union([z21.array(z21.string().min(1)), z21.literal(false)]).optional(),
13277
+ description: z21.union([z21.string(), z21.literal(false)]).optional(),
13278
+ launch: z21.strictObject({
13279
+ skipPermissions: z21.boolean().optional(),
13280
+ remoteControl: z21.boolean().optional(),
13281
+ headroom: z21.boolean().optional(),
13282
+ trackUsage: z21.boolean().optional(),
13283
+ provider: z21.union([z21.string().min(1), z21.literal(false)]).optional(),
13284
+ claudeVersion: z21.union([z21.string().min(1), z21.literal(false)]).optional()
13012
13285
  }).optional()
13013
13286
  });
13014
13287
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
13015
- var ConfigProfileRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13288
+ var ConfigProfileRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13016
13289
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
13017
13290
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
13018
- var PoolMembersInputSchema = z20.array(z20.string().min(1)).min(1);
13019
- var ConfigPoolAddInputSchema = z20.strictObject({
13020
- name: z20.string().min(1),
13291
+ var PoolMembersInputSchema = z21.array(z21.string().min(1)).min(1);
13292
+ var ConfigPoolAddInputSchema = z21.strictObject({
13293
+ name: z21.string().min(1),
13021
13294
  identities: PoolMembersInputSchema,
13022
- preference: z20.enum(POOL_PREFERENCES).optional()
13295
+ preference: z21.enum(POOL_PREFERENCES).optional()
13023
13296
  });
13024
13297
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
13025
- var ConfigPoolSetInputSchema = z20.strictObject({
13026
- name: z20.string().min(1),
13298
+ var ConfigPoolSetInputSchema = z21.strictObject({
13299
+ name: z21.string().min(1),
13027
13300
  identities: PoolMembersInputSchema.optional(),
13028
- preference: z20.union([z20.enum(POOL_PREFERENCES), z20.literal(false)]).optional()
13301
+ preference: z21.union([z21.enum(POOL_PREFERENCES), z21.literal(false)]).optional()
13029
13302
  });
13030
13303
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
13031
- var ConfigPoolRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13304
+ var ConfigPoolRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13032
13305
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
13033
13306
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
13034
- var ConfigProviderAddInputSchema = z20.strictObject({
13035
- name: z20.string().min(1),
13036
- kind: z20.enum(PROVIDER_KINDS).optional(),
13037
- displayName: z20.string().min(1),
13038
- baseUrl: z20.string().min(1).optional(),
13307
+ var ConfigProviderAddInputSchema = z21.strictObject({
13308
+ name: z21.string().min(1),
13309
+ kind: z21.enum(PROVIDER_KINDS).optional(),
13310
+ displayName: z21.string().min(1),
13311
+ baseUrl: z21.string().min(1).optional(),
13039
13312
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
13040
13313
  codex: CodexProviderConfigSchema.optional()
13041
13314
  });
13042
13315
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
13043
- var ConfigProviderSetInputSchema = z20.strictObject({
13044
- name: z20.string().min(1),
13045
- displayName: z20.string().min(1).optional(),
13046
- baseUrl: z20.string().min(1).optional(),
13316
+ var ConfigProviderSetInputSchema = z21.strictObject({
13317
+ name: z21.string().min(1),
13318
+ displayName: z21.string().min(1).optional(),
13319
+ baseUrl: z21.string().min(1).optional(),
13047
13320
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
13048
13321
  codex: CodexProviderConfigSchema.optional()
13049
13322
  });
13050
13323
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
13051
- var ConfigProviderRemoveInputSchema = z20.strictObject({ name: z20.string().min(1), confirm: RemovalConfirmationSchema });
13324
+ var ConfigProviderRemoveInputSchema = z21.strictObject({ name: z21.string().min(1), confirm: RemovalConfirmationSchema });
13052
13325
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
13053
- var ConfigRuleAddInputSchema = z20.strictObject({
13054
- path: z20.string().min(1),
13055
- configProfile: z20.string().min(1).optional(),
13056
- identity: z20.string().min(1).optional()
13326
+ var ConfigRuleAddInputSchema = z21.strictObject({
13327
+ path: z21.string().min(1),
13328
+ configProfile: z21.string().min(1).optional(),
13329
+ identity: z21.string().min(1).optional()
13057
13330
  });
13058
13331
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
13059
- var ConfigRuleSetInputSchema = z20.strictObject({
13060
- path: z20.string().min(1),
13061
- configProfile: z20.union([z20.string().min(1), z20.literal(false)]).optional(),
13062
- identity: z20.union([z20.string().min(1), z20.literal(false)]).optional()
13332
+ var ConfigRuleSetInputSchema = z21.strictObject({
13333
+ path: z21.string().min(1),
13334
+ configProfile: z21.union([z21.string().min(1), z21.literal(false)]).optional(),
13335
+ identity: z21.union([z21.string().min(1), z21.literal(false)]).optional()
13063
13336
  });
13064
13337
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
13065
- var ConfigRuleRemoveInputSchema = z20.strictObject({ path: z20.string().min(1), confirm: RemovalConfirmationSchema });
13338
+ var ConfigRuleRemoveInputSchema = z21.strictObject({ path: z21.string().min(1), confirm: RemovalConfirmationSchema });
13066
13339
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
13067
13340
 
13068
13341
  // src/frontdoor/configApi.ts
@@ -13126,7 +13399,7 @@ function profileValue(name, paths) {
13126
13399
  function createConfigApiRouter(deps) {
13127
13400
  const authed = doorApiAuth(deps.expectedToken);
13128
13401
  const { paths } = deps;
13129
- const route = (path36, summary) => authed.meta(openapi3({ method: "POST", path: path36, summary, tags: [CONFIG_API_TAG] }));
13402
+ const route = (path37, summary) => authed.meta(openapi3({ method: "POST", path: path37, summary, tags: [CONFIG_API_TAG] }));
13130
13403
  return {
13131
13404
  config: {
13132
13405
  identity: {
@@ -13368,41 +13641,41 @@ import { openapi as openapi4 } from "@orpc/openapi";
13368
13641
  import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from "@orpc/server";
13369
13642
 
13370
13643
  // src/frontdoor/eventSchemas.ts
13371
- import { z as z21 } from "zod";
13644
+ import { z as z22 } from "zod";
13372
13645
  var DOOR_EVENT_SOURCE_RC = "rc";
13373
13646
  var LAUNCH_EVENT_SOURCE = "launch";
13374
13647
  var USAGE_EVENT_SOURCE = "usage";
13375
13648
  var DOOR_HEALTH_EVENT_SOURCE = "door";
13376
13649
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
13377
- var DoorEventSchema = z21.strictObject({
13378
- source: z21.string().min(1),
13650
+ var DoorEventSchema = z22.strictObject({
13651
+ source: z22.string().min(1),
13379
13652
  /** A positive integer because the backbone's counters start at one and only ever increase. */
13380
- sequence: z21.number().int().positive(),
13381
- payload: z21.unknown()
13382
- });
13383
- var DoorEventSourceQuerySchema = z21.strictObject({
13384
- sources: z21.array(z21.string().min(1)).min(1).optional()
13385
- });
13386
- var LaunchLifecycleEventSchema = z21.strictObject({
13387
- kind: z21.enum(["registered", "pruned", "ended"]),
13388
- pid: z21.number().int().positive(),
13389
- startedAt: z21.number(),
13390
- observedAt: z21.number()
13391
- });
13392
- var DoorHealthEventSchema = z21.discriminatedUnion("kind", [
13393
- 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() }),
13394
- z21.strictObject({ kind: z21.literal("listenerFailed"), pid: z21.number().int().positive(), listener: z21.enum(["provider", "connect", "direct"]), message: z21.string(), observedAt: z21.number() }),
13395
- z21.strictObject({ kind: z21.literal("binaryTurnover"), pid: z21.number().int().positive(), observedAt: z21.number() }),
13396
- z21.strictObject({ kind: z21.literal("idleShutdown"), pid: z21.number().int().positive(), observedAt: z21.number() })
13653
+ sequence: z22.number().int().positive(),
13654
+ payload: z22.unknown()
13655
+ });
13656
+ var DoorEventSourceQuerySchema = z22.strictObject({
13657
+ sources: z22.array(z22.string().min(1)).min(1).optional()
13658
+ });
13659
+ var LaunchLifecycleEventSchema = z22.strictObject({
13660
+ kind: z22.enum(["registered", "pruned", "ended"]),
13661
+ pid: z22.number().int().positive(),
13662
+ startedAt: z22.number(),
13663
+ observedAt: z22.number()
13664
+ });
13665
+ var DoorHealthEventSchema = z22.discriminatedUnion("kind", [
13666
+ 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() }),
13667
+ z22.strictObject({ kind: z22.literal("listenerFailed"), pid: z22.number().int().positive(), listener: z22.enum(["provider", "connect", "direct"]), message: z22.string(), observedAt: z22.number() }),
13668
+ z22.strictObject({ kind: z22.literal("binaryTurnover"), pid: z22.number().int().positive(), observedAt: z22.number() }),
13669
+ z22.strictObject({ kind: z22.literal("idleShutdown"), pid: z22.number().int().positive(), observedAt: z22.number() })
13397
13670
  ]);
13398
- var QuotaExpiringEventSchema = z21.strictObject({
13399
- identity: z21.string().min(1),
13400
- provider: z21.string().min(1),
13401
- window: z21.enum(["fiveHour", "sevenDay"]),
13671
+ var QuotaExpiringEventSchema = z22.strictObject({
13672
+ identity: z22.string().min(1),
13673
+ provider: z22.string().min(1),
13674
+ window: z22.enum(["fiveHour", "sevenDay"]),
13402
13675
  /** 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. */
13403
- utilization: z21.number().min(0).max(1),
13404
- resetsAt: z21.iso.datetime(),
13405
- observedAt: z21.number()
13676
+ utilization: z22.number().min(0).max(1),
13677
+ resetsAt: z22.iso.datetime(),
13678
+ observedAt: z22.number()
13406
13679
  });
13407
13680
 
13408
13681
  // src/frontdoor/eventsApi.ts
@@ -13485,52 +13758,52 @@ import { ORPCError as ORPCError5 } from "@orpc/client";
13485
13758
  import { openapi as openapi6 } from "@orpc/openapi";
13486
13759
 
13487
13760
  // src/frontdoor/launchSchemas.ts
13488
- import path30 from "node:path";
13489
- import { z as z22 } from "zod";
13761
+ import path31 from "node:path";
13762
+ import { z as z23 } from "zod";
13490
13763
  init_claudeVersion();
13491
13764
  init_identity();
13492
- var LaunchResolveInputSchema = z22.strictObject({
13493
- path: z22.string().min(1),
13765
+ var LaunchResolveInputSchema = z23.strictObject({
13766
+ path: z23.string().min(1),
13494
13767
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
13495
- argv: z22.readonly(z22.array(z22.string())).optional(),
13768
+ argv: z23.readonly(z23.array(z23.string())).optional(),
13496
13769
  /** 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. */
13497
- env: z22.record(z22.string(), z22.string()).optional()
13498
- }).refine((input) => path30.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13499
- var LaunchPoolDecisionSchema = z22.strictObject({
13500
- name: z22.string(),
13501
- reasons: z22.readonly(z22.array(z22.string())),
13502
- movedOff: z22.strictObject({ identity: z22.string(), reason: z22.string() }).optional()
13503
- });
13504
- var LaunchDecisionSchema = z22.strictObject({
13505
- identity: z22.string().optional(),
13506
- identitySource: z22.enum(IDENTITY_DECISION_SOURCES),
13770
+ env: z23.record(z23.string(), z23.string()).optional()
13771
+ }).refine((input) => path31.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13772
+ var LaunchPoolDecisionSchema = z23.strictObject({
13773
+ name: z23.string(),
13774
+ reasons: z23.readonly(z23.array(z23.string())),
13775
+ movedOff: z23.strictObject({ identity: z23.string(), reason: z23.string() }).optional()
13776
+ });
13777
+ var LaunchDecisionSchema = z23.strictObject({
13778
+ identity: z23.string().optional(),
13779
+ identitySource: z23.enum(IDENTITY_DECISION_SOURCES),
13507
13780
  pool: LaunchPoolDecisionSchema.optional(),
13508
- configDirEscapeHatch: z22.boolean(),
13509
- configDir: z22.string().optional(),
13510
- configProfile: z22.string().optional(),
13511
- configProfileSource: z22.enum(CONFIG_PROFILE_DECISION_SOURCES),
13512
- provider: z22.string().optional()
13513
- });
13514
- var LaunchFlagsSchema = z22.strictObject({
13515
- skipPermissions: z22.boolean(),
13516
- remoteControl: z22.boolean(),
13517
- headroom: z22.boolean(),
13518
- trackUsage: z22.boolean()
13519
- });
13520
- var LaunchResolveOutputSchema = z22.strictObject({
13781
+ configDirEscapeHatch: z23.boolean(),
13782
+ configDir: z23.string().optional(),
13783
+ configProfile: z23.string().optional(),
13784
+ configProfileSource: z23.enum(CONFIG_PROFILE_DECISION_SOURCES),
13785
+ provider: z23.string().optional()
13786
+ });
13787
+ var LaunchFlagsSchema = z23.strictObject({
13788
+ skipPermissions: z23.boolean(),
13789
+ remoteControl: z23.boolean(),
13790
+ headroom: z23.boolean(),
13791
+ trackUsage: z23.boolean()
13792
+ });
13793
+ var LaunchResolveOutputSchema = z23.strictObject({
13521
13794
  decision: LaunchDecisionSchema,
13522
13795
  flags: LaunchFlagsSchema,
13523
- claudeVersion: z22.strictObject({ version: z22.string(), source: z22.enum(CLAUDE_VERSION_SOURCES) }).optional(),
13796
+ claudeVersion: z23.strictObject({ version: z23.string(), source: z23.enum(CLAUDE_VERSION_SOURCES) }).optional(),
13524
13797
  /** The real `claude` binary the launch would spawn, on the door's host. */
13525
- bin: z22.string(),
13798
+ bin: z23.string(),
13526
13799
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
13527
- args: z22.readonly(z22.array(z22.string())),
13800
+ args: z23.readonly(z23.array(z23.string())),
13528
13801
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
13529
- credential: z22.strictObject({ subject: z22.enum(["provider", "identity"]), name: z22.string(), summary: CredentialSummarySchema }).optional(),
13530
- routing: z22.strictObject({ frontDoor: z22.boolean(), headroom: z22.boolean() }),
13802
+ credential: z23.strictObject({ subject: z23.enum(["provider", "identity"]), name: z23.string(), summary: CredentialSummarySchema }).optional(),
13803
+ routing: z23.strictObject({ frontDoor: z23.boolean(), headroom: z23.boolean() }),
13531
13804
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
13532
- environment: z22.readonly(z22.array(z22.string())),
13533
- warnings: z22.readonly(z22.array(z22.string()))
13805
+ environment: z23.readonly(z23.array(z23.string())),
13806
+ warnings: z23.readonly(z23.array(z23.string()))
13534
13807
  });
13535
13808
 
13536
13809
  // src/frontdoor/launchApi.ts
@@ -15591,8 +15864,8 @@ data: ${JSON.stringify(envelope)}
15591
15864
 
15592
15865
  // src/frontdoor/rcSelfHostMint.ts
15593
15866
  init_account();
15594
- import path31 from "node:path";
15595
- var CREDENTIALS_FILE = ".credentials.json";
15867
+ import path32 from "node:path";
15868
+ var CREDENTIALS_FILE2 = ".credentials.json";
15596
15869
  var CLAUDE_JSON2 = ".claude.json";
15597
15870
  var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
15598
15871
  var RC_SELF_HOST_RECORD_FILE = "credential.json";
@@ -15615,7 +15888,7 @@ function readJsonObject(fs12, file) {
15615
15888
  return isRecord11(parsed) ? parsed : void 0;
15616
15889
  }
15617
15890
  function readRcSelfHostRecord(fs12, frontdoorDir) {
15618
- const parsed = readJsonObject(fs12, path31.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
15891
+ const parsed = readJsonObject(fs12, path32.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
15619
15892
  if (parsed === void 0) {
15620
15893
  return void 0;
15621
15894
  }
@@ -15629,11 +15902,11 @@ function mintRcSelfHostCredential(deps) {
15629
15902
  if (!isIdentityName(deps.identity)) {
15630
15903
  throw new Error(`"${deps.identity}" is not a valid identity name.`);
15631
15904
  }
15632
- const identityDir = path31.join(deps.identitiesDir, deps.identity);
15633
- const credentialsFile = path31.join(identityDir, CREDENTIALS_FILE);
15634
- const claudeJsonFile = path31.join(identityDir, CLAUDE_JSON2);
15635
- const recordDir = path31.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
15636
- const recordFile = path31.join(recordDir, RC_SELF_HOST_RECORD_FILE);
15905
+ const identityDir = path32.join(deps.identitiesDir, deps.identity);
15906
+ const credentialsFile = path32.join(identityDir, CREDENTIALS_FILE2);
15907
+ const claudeJsonFile = path32.join(identityDir, CLAUDE_JSON2);
15908
+ const recordDir = path32.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
15909
+ const recordFile = path32.join(recordDir, RC_SELF_HOST_RECORD_FILE);
15637
15910
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
15638
15911
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
15639
15912
  const existingOauth = isRecord11(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
@@ -15649,7 +15922,7 @@ function mintRcSelfHostCredential(deps) {
15649
15922
  const organizationUuid = deps.newUuid();
15650
15923
  const accountUuid = deps.newUuid();
15651
15924
  const mintedAt = new Date(deps.now()).toISOString();
15652
- deps.fs.mkdirPrivate(path31.dirname(credentialsFile));
15925
+ deps.fs.mkdirPrivate(path32.dirname(credentialsFile));
15653
15926
  deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
15654
15927
  `);
15655
15928
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
@@ -15797,6 +16070,8 @@ init_ownCli();
15797
16070
  export {
15798
16071
  AMBIENT_CREDENTIAL_VARS,
15799
16072
  CHECK_CREDENTIAL_APPLIES,
16073
+ CODEX_APP_SERVER_GENERATED_AGAINST,
16074
+ CODEX_APP_SERVER_TIMEOUT_MS,
15800
16075
  CONNECT_INTERCEPT_HOST,
15801
16076
  CONNECT_INTERCEPT_HOSTS,
15802
16077
  CONNECT_LIMITS,
@@ -15807,7 +16082,12 @@ export {
15807
16082
  CheckReportJsonSchema,
15808
16083
  CheckRunInputSchema,
15809
16084
  CliError,
16085
+ CodexAccountReadSchema,
16086
+ CodexAppServerProtocolError,
16087
+ CodexAppServerRequestError,
16088
+ CodexAppServerUnavailableError,
15810
16089
  CodexLogoutOutputSchema,
16090
+ CodexRateLimitsReadSchema,
15811
16091
  CodexSignInSchema,
15812
16092
  CodexStatusOutputSchema,
15813
16093
  ConfigIdentityAddOutputSchema,
@@ -16065,6 +16345,8 @@ export {
16065
16345
  rcSelfHostFromEnv,
16066
16346
  rcWebFetchAllowsPrivateFromEnv,
16067
16347
  readActiveIdentity2 as readActiveIdentity,
16348
+ readCodexAccount,
16349
+ readCodexRateLimits,
16068
16350
  readDirectoryRules,
16069
16351
  readFarmManifest,
16070
16352
  readFrontDoorControlMaterial,
@@ -16076,6 +16358,7 @@ export {
16076
16358
  readRcSelfHostRecord,
16077
16359
  readRcSessionFile,
16078
16360
  readUsageSnapshot,
16361
+ realCodexAppServerPort,
16079
16362
  realConnectCertStore,
16080
16363
  realConnectEffects,
16081
16364
  realRcControlTransport,