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.cjs CHANGED
@@ -626,9 +626,9 @@ function applyPatch(filePath, schema, patch, options = {}) {
626
626
  if (!result.success) {
627
627
  throw new ConfigValidationError(filePath, result.error.issues);
628
628
  }
629
- const validated2 = result.data;
630
- writeJsonAtomic(filePath, validated2, storeFs);
631
- return validated2;
629
+ const validated3 = result.data;
630
+ writeJsonAtomic(filePath, validated3, storeFs);
631
+ return validated3;
632
632
  }
633
633
  var import_node_fs, import_node_path3, import_node_crypto, nodeStoreFs;
634
634
  var init_store = __esm({
@@ -2663,7 +2663,7 @@ var init_package = __esm({
2663
2663
  "package.json"() {
2664
2664
  package_default = {
2665
2665
  name: "claude-use",
2666
- version: "9.7.2",
2666
+ version: "9.9.0",
2667
2667
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
2668
2668
  license: "MIT",
2669
2669
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -2891,37 +2891,37 @@ function readStartLock(fs12, lockFile) {
2891
2891
  return void 0;
2892
2892
  }
2893
2893
  }
2894
- var import_node_crypto6, import_node_path11, import_zod5, HEADROOM_ANTHROPIC_UPSTREAM, HeadroomStateSchema, HeadroomSessionSchema, HeadroomLockSchema;
2894
+ var import_node_crypto6, import_node_path11, import_zod6, HEADROOM_ANTHROPIC_UPSTREAM, HeadroomStateSchema, HeadroomSessionSchema, HeadroomLockSchema;
2895
2895
  var init_state2 = __esm({
2896
2896
  "src/headroom/state.ts"() {
2897
2897
  "use strict";
2898
2898
  import_node_crypto6 = require("node:crypto");
2899
2899
  import_node_path11 = __toESM(require("node:path"), 1);
2900
- import_zod5 = require("zod");
2900
+ import_zod6 = require("zod");
2901
2901
  init_schema();
2902
2902
  HEADROOM_ANTHROPIC_UPSTREAM = "https://api.anthropic.com";
2903
- HeadroomStateSchema = import_zod5.z.strictObject({
2903
+ HeadroomStateSchema = import_zod6.z.strictObject({
2904
2904
  /** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
2905
- supervisorPid: import_zod5.z.number().int().positive().optional(),
2905
+ supervisorPid: import_zod6.z.number().int().positive().optional(),
2906
2906
  /** The headroom proxy process itself. Absent while the supervisor is between restarts. */
2907
- headroomPid: import_zod5.z.number().int().positive().optional(),
2907
+ headroomPid: import_zod6.z.number().int().positive().optional(),
2908
2908
  /**
2909
2909
  * 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.
2910
2910
  */
2911
- socketPath: import_zod5.z.string().min(1).optional(),
2911
+ socketPath: import_zod6.z.string().min(1).optional(),
2912
2912
  /** The `headroom --version` output of the running install. */
2913
- version: import_zod5.z.string().optional(),
2913
+ version: import_zod6.z.string().optional(),
2914
2914
  /** Hash of the allowlist the running proxy was started with, so a provider-file change is detected as drift. */
2915
- allowlistHash: import_zod5.z.string().optional(),
2915
+ allowlistHash: import_zod6.z.string().optional(),
2916
2916
  /** Hash of the token-saving settings the running proxy was started with, so a settings change is detected as drift. */
2917
- settingsHash: import_zod5.z.string().optional(),
2917
+ settingsHash: import_zod6.z.string().optional(),
2918
2918
  /** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
2919
- installedSource: import_zod5.z.string().optional(),
2919
+ installedSource: import_zod6.z.string().optional(),
2920
2920
  /** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
2921
- lastError: import_zod5.z.string().optional()
2921
+ lastError: import_zod6.z.string().optional()
2922
2922
  });
2923
- HeadroomSessionSchema = import_zod5.z.strictObject({ pid: import_zod5.z.number().int().positive(), startedAt: import_zod5.z.number(), supervisorPid: import_zod5.z.number().int().positive() });
2924
- HeadroomLockSchema = import_zod5.z.strictObject({ pid: import_zod5.z.number().int().positive(), at: import_zod5.z.number() });
2923
+ HeadroomSessionSchema = import_zod6.z.strictObject({ pid: import_zod6.z.number().int().positive(), startedAt: import_zod6.z.number(), supervisorPid: import_zod6.z.number().int().positive() });
2924
+ HeadroomLockSchema = import_zod6.z.strictObject({ pid: import_zod6.z.number().int().positive(), at: import_zod6.z.number() });
2925
2925
  }
2926
2926
  });
2927
2927
 
@@ -3128,14 +3128,14 @@ function pinnedGitCommit(spec) {
3128
3128
  const ref = GIT_SPEC_RE.exec(spec)?.[1];
3129
3129
  return ref !== void 0 && COMMIT_SHA_RE.test(ref) ? ref.toLowerCase() : void 0;
3130
3130
  }
3131
- var import_zod6, GIT_SPEC_RE, COMMIT_SHA_RE, DirectUrlSchema;
3131
+ var import_zod7, GIT_SPEC_RE, COMMIT_SHA_RE, DirectUrlSchema;
3132
3132
  var init_source = __esm({
3133
3133
  "src/headroom/source.ts"() {
3134
3134
  "use strict";
3135
- import_zod6 = require("zod");
3135
+ import_zod7 = require("zod");
3136
3136
  GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
3137
3137
  COMMIT_SHA_RE = /^[0-9a-f]{40}$/i;
3138
- DirectUrlSchema = import_zod6.z.object({ vcs_info: import_zod6.z.object({ commit_id: import_zod6.z.string() }) });
3138
+ DirectUrlSchema = import_zod7.z.object({ vcs_info: import_zod7.z.object({ commit_id: import_zod7.z.string() }) });
3139
3139
  }
3140
3140
  });
3141
3141
 
@@ -3421,7 +3421,7 @@ function realIsProcessAlive(pid) {
3421
3421
  }
3422
3422
  }
3423
3423
  function realIsProcessZombie(pid) {
3424
- const result = (0, import_node_child_process.spawnSync)("ps", ["-o", "stat=", "-p", String(pid)], { encoding: "utf8" });
3424
+ const result = (0, import_node_child_process2.spawnSync)("ps", ["-o", "stat=", "-p", String(pid)], { encoding: "utf8" });
3425
3425
  return result.status === 0 && result.stdout.trim().startsWith("Z");
3426
3426
  }
3427
3427
  function realIsProcessRunning(pid) {
@@ -3432,7 +3432,7 @@ function expandHome2(filePath) {
3432
3432
  }
3433
3433
  function hasDesktopSession() {
3434
3434
  if (process.platform === "darwin") {
3435
- const result = (0, import_node_child_process.spawnSync)("launchctl", ["managername"], { encoding: "utf8" });
3435
+ const result = (0, import_node_child_process2.spawnSync)("launchctl", ["managername"], { encoding: "utf8" });
3436
3436
  return result.status === 0 && result.stdout.trim() === MACOS_GUI_SESSION_MANAGER;
3437
3437
  }
3438
3438
  if (process.platform === "win32") {
@@ -3475,7 +3475,7 @@ function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
3475
3475
  import_node_fs2.default.mkdirSync(import_node_path13.default.dirname(logPath), { recursive: true });
3476
3476
  const logFd = import_node_fs2.default.openSync(logPath, "a");
3477
3477
  try {
3478
- const child = (0, import_node_child_process.spawn)(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
3478
+ const child = (0, import_node_child_process2.spawn)(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
3479
3479
  child.unref();
3480
3480
  if (child.pid === void 0) {
3481
3481
  throw new Error(`spawning ${subcommand} returned no pid`);
@@ -3624,11 +3624,11 @@ function realResolveClaudeBinary(isOwnBinary) {
3624
3624
  function realInstalledClaudeVersions() {
3625
3625
  return installedVersions(listVersionsDir(defaultVersionsDir()));
3626
3626
  }
3627
- var import_node_child_process, import_node_crypto8, import_node_fs2, import_node_os2, import_node_path13, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
3627
+ var import_node_child_process2, import_node_crypto8, import_node_fs2, import_node_os2, import_node_path13, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
3628
3628
  var init_realPorts = __esm({
3629
3629
  "src/realPorts.ts"() {
3630
3630
  "use strict";
3631
- import_node_child_process = require("node:child_process");
3631
+ import_node_child_process2 = require("node:child_process");
3632
3632
  import_node_crypto8 = require("node:crypto");
3633
3633
  import_node_fs2 = __toESM(require("node:fs"), 1);
3634
3634
  import_node_os2 = __toESM(require("node:os"), 1);
@@ -3767,7 +3767,7 @@ var init_realPorts = __esm({
3767
3767
  INT32_BYTE_LENGTH = 4;
3768
3768
  realRunPort = {
3769
3769
  run(command, args) {
3770
- const result = (0, import_node_child_process.spawnSync)(command, [...args], { encoding: "utf8" });
3770
+ const result = (0, import_node_child_process2.spawnSync)(command, [...args], { encoding: "utf8" });
3771
3771
  return { status: result.status, stdout: result.stdout, stderr: result.stderr };
3772
3772
  }
3773
3773
  };
@@ -3790,7 +3790,7 @@ var init_realPorts = __esm({
3790
3790
  },
3791
3791
  runCommand(argv, options) {
3792
3792
  const [command, ...args] = argv;
3793
- const result = (0, import_node_child_process.spawnSync)(command, args, {
3793
+ const result = (0, import_node_child_process2.spawnSync)(command, args, {
3794
3794
  encoding: "utf8",
3795
3795
  timeout: options.timeoutMs,
3796
3796
  stdio: options.interactive ? ["inherit", "pipe", "inherit"] : ["ignore", "pipe", "pipe"]
@@ -3828,7 +3828,7 @@ var init_realPorts = __esm({
3828
3828
  };
3829
3829
  realSpawnPort = {
3830
3830
  spawnSync(command, args, options) {
3831
- const result = (0, import_node_child_process.spawnSync)(command, args, options);
3831
+ const result = (0, import_node_child_process2.spawnSync)(command, args, options);
3832
3832
  return { status: result.status, signal: result.signal, ...result.error === void 0 ? {} : { error: result.error } };
3833
3833
  }
3834
3834
  };
@@ -4040,149 +4040,149 @@ var init_identity = __esm({
4040
4040
  });
4041
4041
 
4042
4042
  // src/usage/schema.ts
4043
- var import_zod7, USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
4043
+ var import_zod8, USAGE_SCHEMA_VERSION, VersionSchema, InstantSchema, TokenCountSchema, TokenUsageSchema, LIMIT_KINDS, LimitClassificationSchema, UsageRecordSchema, QuotaWindowSchema, ExtraUsageSpendSchema, UnifiedRateLimitSchema, RateLimitStateSchema, LimitEventSchema, ProviderQuotaWindowSchema, ProviderQuotaSchema, ProviderUsageStateSchema, AccountMetadataSchema, UsageSnapshotSchema;
4044
4044
  var init_schema2 = __esm({
4045
4045
  "src/usage/schema.ts"() {
4046
4046
  "use strict";
4047
- import_zod7 = require("zod");
4047
+ import_zod8 = require("zod");
4048
4048
  USAGE_SCHEMA_VERSION = 1;
4049
- VersionSchema = import_zod7.z.literal(USAGE_SCHEMA_VERSION);
4050
- InstantSchema = import_zod7.z.iso.datetime();
4051
- TokenCountSchema = import_zod7.z.number().int().nonnegative();
4052
- TokenUsageSchema = import_zod7.z.strictObject({
4049
+ VersionSchema = import_zod8.z.literal(USAGE_SCHEMA_VERSION);
4050
+ InstantSchema = import_zod8.z.iso.datetime();
4051
+ TokenCountSchema = import_zod8.z.number().int().nonnegative();
4052
+ TokenUsageSchema = import_zod8.z.strictObject({
4053
4053
  inputTokens: TokenCountSchema.optional(),
4054
4054
  outputTokens: TokenCountSchema.optional(),
4055
4055
  cacheCreationInputTokens: TokenCountSchema.optional(),
4056
4056
  cacheReadInputTokens: TokenCountSchema.optional()
4057
4057
  });
4058
4058
  LIMIT_KINDS = ["rate-limited", "quota-exhausted"];
4059
- LimitClassificationSchema = import_zod7.z.strictObject({
4060
- kind: import_zod7.z.enum(LIMIT_KINDS),
4059
+ LimitClassificationSchema = import_zod8.z.strictObject({
4060
+ kind: import_zod8.z.enum(LIMIT_KINDS),
4061
4061
  /** Seconds to wait before retrying, from the response's `retry-after`. */
4062
- retryAfterSeconds: import_zod7.z.number().nonnegative().optional(),
4062
+ retryAfterSeconds: import_zod8.z.number().nonnegative().optional(),
4063
4063
  /** When the limiting window resets, from the upstream's own reset header. */
4064
4064
  resetAt: InstantSchema.optional(),
4065
4065
  /** The window the upstream named as the binding one (`anthropic-ratelimit-unified-representative-claim`), such as `five_hour` or `seven_day`. */
4066
- window: import_zod7.z.string().optional(),
4066
+ window: import_zod8.z.string().optional(),
4067
4067
  /** 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. */
4068
- evidence: import_zod7.z.array(import_zod7.z.string())
4068
+ evidence: import_zod8.z.array(import_zod8.z.string())
4069
4069
  });
4070
- UsageRecordSchema = import_zod7.z.strictObject({
4070
+ UsageRecordSchema = import_zod8.z.strictObject({
4071
4071
  schemaVersion: VersionSchema,
4072
4072
  /** When the front door received the request. */
4073
4073
  at: InstantSchema,
4074
4074
  /** The launching identity, when the launch resolved one. */
4075
- identity: import_zod7.z.string().optional(),
4075
+ identity: import_zod8.z.string().optional(),
4076
4076
  /** `anthropic` for an OAuth session's request to Claude Code's own API, otherwise the provider's name. */
4077
- provider: import_zod7.z.string(),
4077
+ provider: import_zod8.z.string(),
4078
4078
  /** The launch's session id, generated per launch. */
4079
- sessionId: import_zod7.z.string().optional(),
4079
+ sessionId: import_zod8.z.string().optional(),
4080
4080
  /** The project the launch ran in (its git repository root), when the launch sent one: headroom launches do. */
4081
- project: import_zod7.z.string().optional(),
4081
+ project: import_zod8.z.string().optional(),
4082
4082
  /** The front-door route that served the request. */
4083
- route: import_zod7.z.string(),
4084
- method: import_zod7.z.string(),
4083
+ route: import_zod8.z.string(),
4084
+ method: import_zod8.z.string(),
4085
4085
  /** The API path as the upstream sees it (`/v1/messages`), without the provider prefix or a query string. */
4086
- endpoint: import_zod7.z.string(),
4086
+ endpoint: import_zod8.z.string(),
4087
4087
  /** The model the response named. */
4088
- model: import_zod7.z.string().optional(),
4089
- status: import_zod7.z.number().int(),
4088
+ model: import_zod8.z.string().optional(),
4089
+ status: import_zod8.z.number().int(),
4090
4090
  /** Milliseconds from the request's arrival to its response head. */
4091
- latencyMs: import_zod7.z.number().int().nonnegative(),
4091
+ latencyMs: import_zod8.z.number().int().nonnegative(),
4092
4092
  /** Milliseconds from the request's arrival to the end of its response body. */
4093
- durationMs: import_zod7.z.number().int().nonnegative(),
4093
+ durationMs: import_zod8.z.number().int().nonnegative(),
4094
4094
  /** Whether the client received the whole body. */
4095
- outcome: import_zod7.z.enum(["completed", "aborted"]),
4095
+ outcome: import_zod8.z.enum(["completed", "aborted"]),
4096
4096
  usage: TokenUsageSchema.optional(),
4097
4097
  /** The response's quota and rate-limit headers, by name (see `isRateLimitHeader`). */
4098
- rateLimitHeaders: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.string()).optional(),
4098
+ rateLimitHeaders: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.string()).optional(),
4099
4099
  limit: LimitClassificationSchema.optional(),
4100
4100
  /** The upstream's request id (`request-id`), for matching a record to the provider's own logs. */
4101
- requestId: import_zod7.z.string().optional()
4101
+ requestId: import_zod8.z.string().optional()
4102
4102
  });
4103
- QuotaWindowSchema = import_zod7.z.strictObject({
4103
+ QuotaWindowSchema = import_zod8.z.strictObject({
4104
4104
  /** The fraction of the window used, as the upstream reports it (0 to 1). */
4105
- utilization: import_zod7.z.number().nonnegative().optional(),
4105
+ utilization: import_zod8.z.number().nonnegative().optional(),
4106
4106
  resetsAt: InstantSchema.optional(),
4107
4107
  /** The window's own status (`allowed`, `allowed_warning`, `rejected`). */
4108
- status: import_zod7.z.string().optional(),
4108
+ status: import_zod8.z.string().optional(),
4109
4109
  /** 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. */
4110
- graceUtilization: import_zod7.z.number().nonnegative().optional()
4110
+ graceUtilization: import_zod8.z.number().nonnegative().optional()
4111
4111
  });
4112
- ExtraUsageSpendSchema = import_zod7.z.strictObject({
4112
+ ExtraUsageSpendSchema = import_zod8.z.strictObject({
4113
4113
  /** Spent so far in the allowance's period, in the currency's minor units (pence, cents). */
4114
- usedMinor: import_zod7.z.number().nonnegative(),
4114
+ usedMinor: import_zod8.z.number().nonnegative(),
4115
4115
  /** The allowance's cap in the same units, when it has one. */
4116
- limitMinor: import_zod7.z.number().nonnegative().optional(),
4116
+ limitMinor: import_zod8.z.number().nonnegative().optional(),
4117
4117
  /** The ISO 4217 currency code. */
4118
- currency: import_zod7.z.string()
4118
+ currency: import_zod8.z.string()
4119
4119
  });
4120
- UnifiedRateLimitSchema = import_zod7.z.strictObject({
4120
+ UnifiedRateLimitSchema = import_zod8.z.strictObject({
4121
4121
  /** The overall status: `allowed`, `allowed_warning` or `rejected`. */
4122
- status: import_zod7.z.string().optional(),
4122
+ status: import_zod8.z.string().optional(),
4123
4123
  fiveHour: QuotaWindowSchema.optional(),
4124
4124
  sevenDay: QuotaWindowSchema.optional(),
4125
4125
  /** 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. */
4126
4126
  sevenDayOverageIncluded: QuotaWindowSchema.optional(),
4127
4127
  /** The window that currently binds. */
4128
- representativeClaim: import_zod7.z.string().optional(),
4128
+ representativeClaim: import_zod8.z.string().optional(),
4129
4129
  /** When the binding window resets. */
4130
4130
  resetAt: InstantSchema.optional(),
4131
4131
  /** Whether usage beyond the plan (extra usage) is available: `allowed` or `rejected`. */
4132
- overageStatus: import_zod7.z.string().optional(),
4132
+ overageStatus: import_zod8.z.string().optional(),
4133
4133
  /** 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. */
4134
- overageUtilization: import_zod7.z.number().nonnegative().optional(),
4134
+ overageUtilization: import_zod8.z.number().nonnegative().optional(),
4135
4135
  /** When the extra-usage allowance resets. */
4136
4136
  overageResetsAt: InstantSchema.optional(),
4137
4137
  /** Why extra usage is unavailable, as the upstream names it (`out_of_credits`, for one). */
4138
- overageDisabledReason: import_zod7.z.string().optional(),
4138
+ overageDisabledReason: import_zod8.z.string().optional(),
4139
4139
  /** Whether the response was served on extra usage, as the upstream states it. */
4140
- overageInUse: import_zod7.z.boolean().optional(),
4140
+ overageInUse: import_zod8.z.boolean().optional(),
4141
4141
  /** The allowance in money, from the usage endpoint (the response headers state only the fraction). */
4142
4142
  extraUsageSpend: ExtraUsageSpendSchema.optional(),
4143
4143
  /** True when the upstream offers a fallback while a window is rejected: some requests, by model, are still served, though the rest are refused. */
4144
- fallbackAvailable: import_zod7.z.boolean().optional()
4144
+ fallbackAvailable: import_zod8.z.boolean().optional()
4145
4145
  });
4146
- RateLimitStateSchema = import_zod7.z.strictObject({
4146
+ RateLimitStateSchema = import_zod8.z.strictObject({
4147
4147
  observedAt: InstantSchema,
4148
4148
  /** Every quota and rate-limit header on that response, by name. */
4149
- headers: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.string()),
4149
+ headers: import_zod8.z.record(import_zod8.z.string(), import_zod8.z.string()),
4150
4150
  unified: UnifiedRateLimitSchema.optional(),
4151
4151
  /** 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. */
4152
4152
  planWindowsUnavailableAt: InstantSchema.optional()
4153
4153
  });
4154
4154
  LimitEventSchema = LimitClassificationSchema.extend({
4155
4155
  observedAt: InstantSchema,
4156
- status: import_zod7.z.number().int()
4156
+ status: import_zod8.z.number().int()
4157
4157
  });
4158
- ProviderQuotaWindowSchema = import_zod7.z.strictObject({
4158
+ ProviderQuotaWindowSchema = import_zod8.z.strictObject({
4159
4159
  /** What the window measures, in the provider's terms (`tokens`, `tool-calls`). */
4160
- measures: import_zod7.z.string(),
4160
+ measures: import_zod8.z.string(),
4161
4161
  /** 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. */
4162
- periodMs: import_zod7.z.number().int().positive().optional(),
4162
+ periodMs: import_zod8.z.number().int().positive().optional(),
4163
4163
  /** The provider's own description of the period when `periodMs` could not be derived, such as `unit 4 x 1`. */
4164
- period: import_zod7.z.string().optional(),
4164
+ period: import_zod8.z.string().optional(),
4165
4165
  /** The fraction of the window used (0 to 1). */
4166
- utilization: import_zod7.z.number().nonnegative(),
4166
+ utilization: import_zod8.z.number().nonnegative(),
4167
4167
  resetsAt: InstantSchema.optional(),
4168
4168
  /** Absolute counts, when the provider reports them for this window. */
4169
- limit: import_zod7.z.number().nonnegative().optional(),
4170
- used: import_zod7.z.number().nonnegative().optional(),
4171
- remaining: import_zod7.z.number().nonnegative().optional()
4169
+ limit: import_zod8.z.number().nonnegative().optional(),
4170
+ used: import_zod8.z.number().nonnegative().optional(),
4171
+ remaining: import_zod8.z.number().nonnegative().optional()
4172
4172
  });
4173
- ProviderQuotaSchema = import_zod7.z.strictObject({
4173
+ ProviderQuotaSchema = import_zod8.z.strictObject({
4174
4174
  observedAt: InstantSchema,
4175
4175
  /** Which usage endpoint produced it (`z.ai`). */
4176
- source: import_zod7.z.string(),
4176
+ source: import_zod8.z.string(),
4177
4177
  /** The subscription level the endpoint reports, when it does. */
4178
- level: import_zod7.z.string().optional(),
4179
- windows: import_zod7.z.array(ProviderQuotaWindowSchema)
4178
+ level: import_zod8.z.string().optional(),
4179
+ windows: import_zod8.z.array(ProviderQuotaWindowSchema)
4180
4180
  });
4181
- ProviderUsageStateSchema = import_zod7.z.strictObject({
4181
+ ProviderUsageStateSchema = import_zod8.z.strictObject({
4182
4182
  /** 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. */
4183
4183
  lastRequestAt: InstantSchema.optional(),
4184
- lastStatus: import_zod7.z.number().int().optional(),
4185
- lastModel: import_zod7.z.string().optional(),
4184
+ lastStatus: import_zod8.z.number().int().optional(),
4185
+ lastModel: import_zod8.z.string().optional(),
4186
4186
  /** The latest rate-limit state, from the last response that carried any rate-limit header. */
4187
4187
  rateLimit: RateLimitStateSchema.optional(),
4188
4188
  /** The latest classified refusal. It stays after later successes, so a reader compares its `resetAt` (or `observedAt` plus `retryAfterSeconds`) with the current time. */
@@ -4190,31 +4190,31 @@ var init_schema2 = __esm({
4190
4190
  /** The latest quota the provider's usage endpoint reported, for providers whose quota is not visible in response headers. */
4191
4191
  quota: ProviderQuotaSchema.optional()
4192
4192
  });
4193
- AccountMetadataSchema = import_zod7.z.strictObject({
4194
- accountUuid: import_zod7.z.string().optional(),
4195
- emailAddress: import_zod7.z.string().optional(),
4196
- displayName: import_zod7.z.string().optional(),
4197
- organizationUuid: import_zod7.z.string().optional(),
4198
- organizationName: import_zod7.z.string().optional(),
4199
- organizationType: import_zod7.z.string().optional(),
4200
- organizationRole: import_zod7.z.string().optional(),
4201
- workspaceRole: import_zod7.z.string().optional(),
4202
- billingType: import_zod7.z.string().optional(),
4203
- seatTier: import_zod7.z.string().optional(),
4204
- organizationRateLimitTier: import_zod7.z.string().optional(),
4205
- userRateLimitTier: import_zod7.z.string().optional(),
4206
- hasExtraUsageEnabled: import_zod7.z.boolean().optional(),
4207
- subscriptionCreatedAt: import_zod7.z.string().optional(),
4208
- accountCreatedAt: import_zod7.z.string().optional()
4193
+ AccountMetadataSchema = import_zod8.z.strictObject({
4194
+ accountUuid: import_zod8.z.string().optional(),
4195
+ emailAddress: import_zod8.z.string().optional(),
4196
+ displayName: import_zod8.z.string().optional(),
4197
+ organizationUuid: import_zod8.z.string().optional(),
4198
+ organizationName: import_zod8.z.string().optional(),
4199
+ organizationType: import_zod8.z.string().optional(),
4200
+ organizationRole: import_zod8.z.string().optional(),
4201
+ workspaceRole: import_zod8.z.string().optional(),
4202
+ billingType: import_zod8.z.string().optional(),
4203
+ seatTier: import_zod8.z.string().optional(),
4204
+ organizationRateLimitTier: import_zod8.z.string().optional(),
4205
+ userRateLimitTier: import_zod8.z.string().optional(),
4206
+ hasExtraUsageEnabled: import_zod8.z.boolean().optional(),
4207
+ subscriptionCreatedAt: import_zod8.z.string().optional(),
4208
+ accountCreatedAt: import_zod8.z.string().optional()
4209
4209
  });
4210
- UsageSnapshotSchema = import_zod7.z.strictObject({
4210
+ UsageSnapshotSchema = import_zod8.z.strictObject({
4211
4211
  schemaVersion: VersionSchema,
4212
- identity: import_zod7.z.string(),
4212
+ identity: import_zod8.z.string(),
4213
4213
  updatedAt: InstantSchema,
4214
4214
  /** The identity's account metadata as of `updatedAt`. */
4215
4215
  account: AccountMetadataSchema.optional(),
4216
4216
  /** Latest state per provider, keyed by provider name (`anthropic` for OAuth sessions). */
4217
- providers: import_zod7.z.record(import_zod7.z.string(), ProviderUsageStateSchema)
4217
+ providers: import_zod8.z.record(import_zod8.z.string(), ProviderUsageStateSchema)
4218
4218
  });
4219
4219
  }
4220
4220
  });
@@ -4321,24 +4321,24 @@ function planOf(account) {
4321
4321
  }
4322
4322
  return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
4323
4323
  }
4324
- var import_zod8, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
4324
+ var import_zod9, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
4325
4325
  var init_plan2 = __esm({
4326
4326
  "src/usage/plan.ts"() {
4327
4327
  "use strict";
4328
- import_zod8 = require("zod");
4329
- PlanClassSchema = import_zod8.z.union([
4330
- import_zod8.z.strictObject({
4331
- kind: import_zod8.z.literal("subscription"),
4328
+ import_zod9 = require("zod");
4329
+ PlanClassSchema = import_zod9.z.union([
4330
+ import_zod9.z.strictObject({
4331
+ kind: import_zod9.z.literal("subscription"),
4332
4332
  /** The plan's size as a multiple of the smallest subscription tier (Max 5x is 5, Max 20x is 20). */
4333
- capacity: import_zod8.z.number().positive(),
4333
+ capacity: import_zod9.z.number().positive(),
4334
4334
  /** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
4335
- recognised: import_zod8.z.boolean(),
4335
+ recognised: import_zod9.z.boolean(),
4336
4336
  /** The tier string the classification rests on, when the account had one. */
4337
- tier: import_zod8.z.string().optional()
4337
+ tier: import_zod9.z.string().optional()
4338
4338
  }),
4339
- import_zod8.z.strictObject({
4340
- kind: import_zod8.z.literal("pay-per-use"),
4341
- tier: import_zod8.z.string().optional()
4339
+ import_zod9.z.strictObject({
4340
+ kind: import_zod9.z.literal("pay-per-use"),
4341
+ tier: import_zod9.z.string().optional()
4342
4342
  })
4343
4343
  ]);
4344
4344
  TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
@@ -4439,21 +4439,21 @@ var init_rateLimit = __esm({
4439
4439
  });
4440
4440
 
4441
4441
  // src/usage/scan.ts
4442
- var import_zod9, AnthropicUsageSchema, ErrorObjectSchema;
4442
+ var import_zod10, AnthropicUsageSchema, ErrorObjectSchema;
4443
4443
  var init_scan = __esm({
4444
4444
  "src/usage/scan.ts"() {
4445
4445
  "use strict";
4446
- import_zod9 = require("zod");
4447
- AnthropicUsageSchema = import_zod9.z.looseObject({
4448
- input_tokens: import_zod9.z.number().int().nonnegative().nullish(),
4449
- output_tokens: import_zod9.z.number().int().nonnegative().nullish(),
4450
- cache_creation_input_tokens: import_zod9.z.number().int().nonnegative().nullish(),
4451
- cache_read_input_tokens: import_zod9.z.number().int().nonnegative().nullish()
4446
+ import_zod10 = require("zod");
4447
+ AnthropicUsageSchema = import_zod10.z.looseObject({
4448
+ input_tokens: import_zod10.z.number().int().nonnegative().nullish(),
4449
+ output_tokens: import_zod10.z.number().int().nonnegative().nullish(),
4450
+ cache_creation_input_tokens: import_zod10.z.number().int().nonnegative().nullish(),
4451
+ cache_read_input_tokens: import_zod10.z.number().int().nonnegative().nullish()
4452
4452
  });
4453
- ErrorObjectSchema = import_zod9.z.looseObject({
4454
- type: import_zod9.z.string().optional(),
4455
- code: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number()]).optional(),
4456
- message: import_zod9.z.string().optional()
4453
+ ErrorObjectSchema = import_zod10.z.looseObject({
4454
+ type: import_zod10.z.string().optional(),
4455
+ code: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]).optional(),
4456
+ message: import_zod10.z.string().optional()
4457
4457
  });
4458
4458
  }
4459
4459
  });
@@ -5156,12 +5156,12 @@ function recordStickyPick(fs12, picksFile, directory, identity, nowMs) {
5156
5156
  fs12.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
5157
5157
  `);
5158
5158
  }
5159
- var import_node_path20, import_zod10, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
5159
+ var import_node_path20, import_zod11, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
5160
5160
  var init_poolPick = __esm({
5161
5161
  "src/usage/poolPick.ts"() {
5162
5162
  "use strict";
5163
5163
  import_node_path20 = __toESM(require("node:path"), 1);
5164
- import_zod10 = require("zod");
5164
+ import_zod11 = require("zod");
5165
5165
  init_cliError();
5166
5166
  init_identity();
5167
5167
  init_schema();
@@ -5177,10 +5177,10 @@ var init_poolPick = __esm({
5177
5177
  }
5178
5178
  };
5179
5179
  SCHEMA_VERSION = 1;
5180
- PickEntrySchema = import_zod10.z.strictObject({ identity: import_zod10.z.string().min(1), at: import_zod10.z.iso.datetime() });
5181
- PicksFileSchema = import_zod10.z.strictObject({
5182
- schemaVersion: import_zod10.z.literal(SCHEMA_VERSION),
5183
- picks: import_zod10.z.record(import_zod10.z.string().min(1), PickEntrySchema)
5180
+ PickEntrySchema = import_zod11.z.strictObject({ identity: import_zod11.z.string().min(1), at: import_zod11.z.iso.datetime() });
5181
+ PicksFileSchema = import_zod11.z.strictObject({
5182
+ schemaVersion: import_zod11.z.literal(SCHEMA_VERSION),
5183
+ picks: import_zod11.z.record(import_zod11.z.string().min(1), PickEntrySchema)
5184
5184
  });
5185
5185
  }
5186
5186
  });
@@ -5316,17 +5316,17 @@ function formatCachedCredentialState(state) {
5316
5316
  }
5317
5317
  return state.status === "fresh" ? `${age}, expires in ${formatAge(state.expiresInMs)}` : `${age}, expired ${formatAge(-state.expiresInMs)} ago`;
5318
5318
  }
5319
- var import_zod11, MS_PER_UNIT, CachedCredentialSchema;
5319
+ var import_zod12, MS_PER_UNIT, CachedCredentialSchema;
5320
5320
  var init_credentialCache = __esm({
5321
5321
  "src/credentialCache.ts"() {
5322
5322
  "use strict";
5323
- import_zod11 = require("zod");
5323
+ import_zod12 = require("zod");
5324
5324
  init_schema();
5325
5325
  init_preflight();
5326
5326
  MS_PER_UNIT = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
5327
- CachedCredentialSchema = import_zod11.z.strictObject({
5328
- token: import_zod11.z.string().min(1),
5329
- fetchedAt: import_zod11.z.number().int().nonnegative(),
5327
+ CachedCredentialSchema = import_zod12.z.strictObject({
5328
+ token: import_zod12.z.string().min(1),
5329
+ fetchedAt: import_zod12.z.number().int().nonnegative(),
5330
5330
  source: CredentialSourceSchema
5331
5331
  });
5332
5332
  }
@@ -5352,7 +5352,7 @@ function requireKeychain() {
5352
5352
  }
5353
5353
  }
5354
5354
  function security(args, stdin) {
5355
- const result = (0, import_node_child_process2.spawnSync)("security", args, { encoding: "utf8", ...stdin === void 0 ? {} : { input: stdin }, stdio: ["pipe", "pipe", "ignore"] });
5355
+ const result = (0, import_node_child_process3.spawnSync)("security", args, { encoding: "utf8", ...stdin === void 0 ? {} : { input: stdin }, stdio: ["pipe", "pipe", "ignore"] });
5356
5356
  return { status: result.status, stdout: result.stdout };
5357
5357
  }
5358
5358
  function createRealCredentialCache(root) {
@@ -5403,11 +5403,11 @@ function createRealCredentialCache(root) {
5403
5403
  function realCredentialCacheEnv(paths) {
5404
5404
  return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
5405
5405
  }
5406
- var import_node_child_process2, import_node_fs5, import_node_path23, KEYCHAIN_CACHE_SERVICE, CACHE_DIR_MODE, CACHE_FILE_MODE;
5406
+ var import_node_child_process3, import_node_fs5, import_node_path23, KEYCHAIN_CACHE_SERVICE, CACHE_DIR_MODE, CACHE_FILE_MODE;
5407
5407
  var init_realCredentialCache = __esm({
5408
5408
  "src/realCredentialCache.ts"() {
5409
5409
  "use strict";
5410
- import_node_child_process2 = require("node:child_process");
5410
+ import_node_child_process3 = require("node:child_process");
5411
5411
  import_node_fs5 = __toESM(require("node:fs"), 1);
5412
5412
  import_node_path23 = __toESM(require("node:path"), 1);
5413
5413
  init_credentialCache();
@@ -5928,7 +5928,7 @@ var init_envBool = __esm({
5928
5928
  });
5929
5929
 
5930
5930
  // src/launcher/claudeVersion.ts
5931
- function validated(value, origin) {
5931
+ function validated2(value, origin) {
5932
5932
  if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
5933
5933
  throw new InvalidClaudeVersionError(value, origin);
5934
5934
  }
@@ -5936,11 +5936,11 @@ function validated(value, origin) {
5936
5936
  }
5937
5937
  function resolveClaudeVersion(params) {
5938
5938
  if (params.flag !== void 0) {
5939
- return { version: validated(params.flag, "--claude-version"), source: "flag" };
5939
+ return { version: validated2(params.flag, "--claude-version"), source: "flag" };
5940
5940
  }
5941
5941
  const fromEnv = params.env.AGENT_SHIM_CLAUDE_VERSION;
5942
5942
  if (fromEnv !== void 0 && fromEnv !== "") {
5943
- return { version: validated(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
5943
+ return { version: validated2(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
5944
5944
  }
5945
5945
  return params.cascade === void 0 ? void 0 : { version: params.cascade, source: "cascade" };
5946
5946
  }
@@ -6067,21 +6067,21 @@ function findPathShadow(params) {
6067
6067
  }
6068
6068
  return params.pathDirs.some((dir) => import_node_path26.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
6069
6069
  }
6070
- var import_node_fs7, import_node_path26, import_zod15, ClaudeShimStateSchema, nodeLinkFs;
6070
+ var import_node_fs7, import_node_path26, import_zod16, ClaudeShimStateSchema, nodeLinkFs;
6071
6071
  var init_claudeShim = __esm({
6072
6072
  "src/claudeShim.ts"() {
6073
6073
  "use strict";
6074
6074
  import_node_fs7 = __toESM(require("node:fs"), 1);
6075
6075
  import_node_path26 = __toESM(require("node:path"), 1);
6076
- import_zod15 = require("zod");
6076
+ import_zod16 = require("zod");
6077
6077
  init_commandDeps();
6078
6078
  init_store();
6079
6079
  init_realPorts();
6080
6080
  init_cliError();
6081
- ClaudeShimStateSchema = import_zod15.z.strictObject({
6082
- targetPath: import_zod15.z.string().min(1),
6083
- method: import_zod15.z.enum(["hardlink", "copy"]),
6084
- installedAtMs: import_zod15.z.number()
6081
+ ClaudeShimStateSchema = import_zod16.z.strictObject({
6082
+ targetPath: import_zod16.z.string().min(1),
6083
+ method: import_zod16.z.enum(["hardlink", "copy"]),
6084
+ installedAtMs: import_zod16.z.number()
6085
6085
  });
6086
6086
  nodeLinkFs = { link: import_node_fs7.default.linkSync, copyFile: import_node_fs7.default.copyFileSync, chmod: import_node_fs7.default.chmodSync };
6087
6087
  }
@@ -6567,7 +6567,7 @@ function buildEnv(params) {
6567
6567
  const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
6568
6568
  let providerCustomHeaders;
6569
6569
  if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
6570
- env.CLAUDE_CONFIG_DIR = import_node_path32.default.join(params.identitiesDir, params.resolvedIdentityName);
6570
+ env.CLAUDE_CONFIG_DIR = import_node_path33.default.join(params.identitiesDir, params.resolvedIdentityName);
6571
6571
  }
6572
6572
  if (params.provider !== void 0) {
6573
6573
  const providerEnv = params.provider.definition.env ?? {};
@@ -6611,11 +6611,11 @@ function buildEnv(params) {
6611
6611
  }
6612
6612
  return env;
6613
6613
  }
6614
- var import_node_path32, LOOPBACK_HOSTS;
6614
+ var import_node_path33, LOOPBACK_HOSTS;
6615
6615
  var init_flags = __esm({
6616
6616
  "src/launcher/flags.ts"() {
6617
6617
  "use strict";
6618
- import_node_path32 = __toESM(require("node:path"), 1);
6618
+ import_node_path33 = __toESM(require("node:path"), 1);
6619
6619
  init_envBool();
6620
6620
  init_credential();
6621
6621
  init_headers();
@@ -6938,7 +6938,7 @@ function decideLaunch(params, readOnly) {
6938
6938
  identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
6939
6939
  globalDefaultConfigProfile: params.globalDefaultConfigProfile
6940
6940
  });
6941
- if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs12.readConfigFile(import_node_path33.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
6941
+ if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs12.readConfigFile(import_node_path34.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
6942
6942
  log.error(
6943
6943
  `agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
6944
6944
  );
@@ -7050,7 +7050,7 @@ function decideLaunch(params, readOnly) {
7050
7050
  extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
7051
7051
  passthrough: parsedArgv.rest
7052
7052
  });
7053
- const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path33.default.join(paths.identitiesDir, identityDecision.name);
7053
+ const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path34.default.join(paths.identitiesDir, identityDecision.name);
7054
7054
  const decision = {
7055
7055
  identitySource: identityDecision.source,
7056
7056
  configDirEscapeHatch: identityDecision.configDirEscapeHatch,
@@ -7091,7 +7091,7 @@ function prepareLaunch(params) {
7091
7091
  );
7092
7092
  const updateCheck = runLaunchUpdateCheck({
7093
7093
  mode: params.updateMode ?? "off",
7094
- checkPath: import_node_path33.default.join(paths.root, "update.check"),
7094
+ checkPath: import_node_path34.default.join(paths.root, "update.check"),
7095
7095
  currentVersion: package_default.version,
7096
7096
  port: params.update
7097
7097
  });
@@ -7207,10 +7207,10 @@ function resolveLaunch(params) {
7207
7207
  environment
7208
7208
  };
7209
7209
  }
7210
- function runLaunchPlan(plan, spawn2) {
7210
+ function runLaunchPlan(plan, spawn3) {
7211
7211
  try {
7212
7212
  plan.markChildStarted();
7213
- const result = spawn2.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
7213
+ const result = spawn3.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
7214
7214
  if (result.error !== void 0) {
7215
7215
  throw result.error;
7216
7216
  }
@@ -7222,12 +7222,12 @@ function runLaunchPlan(plan, spawn2) {
7222
7222
  function runLauncher(params) {
7223
7223
  params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
7224
7224
  }
7225
- var import_node_crypto10, import_node_path33;
7225
+ var import_node_crypto10, import_node_path34;
7226
7226
  var init_launcher = __esm({
7227
7227
  "src/launcher.ts"() {
7228
7228
  "use strict";
7229
7229
  import_node_crypto10 = require("node:crypto");
7230
- import_node_path33 = __toESM(require("node:path"), 1);
7230
+ import_node_path34 = __toESM(require("node:path"), 1);
7231
7231
  init_package();
7232
7232
  init_envBool();
7233
7233
  init_argv();
@@ -7258,13 +7258,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
7258
7258
  if (distDir === void 0) {
7259
7259
  throw new OwnCliPathUnknownError();
7260
7260
  }
7261
- return import_node_path34.default.join(distDir, OWN_CLI_FILE_NAME);
7261
+ return import_node_path35.default.join(distDir, OWN_CLI_FILE_NAME);
7262
7262
  }
7263
- var import_node_path34, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
7263
+ var import_node_path35, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
7264
7264
  var init_ownCli = __esm({
7265
7265
  "src/ownCli.ts"() {
7266
7266
  "use strict";
7267
- import_node_path34 = __toESM(require("node:path"), 1);
7267
+ import_node_path35 = __toESM(require("node:path"), 1);
7268
7268
  init_cliError();
7269
7269
  OWN_CLI_FILE_NAME = "cli.cjs";
7270
7270
  OwnCliPathUnknownError = class extends CliError {
@@ -7349,7 +7349,7 @@ request.on("error", (error) => finish(failed, (error.code ? error.code + ": " :
7349
7349
  // src/frontdoor/trust.ts
7350
7350
  function resolveTrustBundle(params) {
7351
7351
  const { caCertFile, bundlesDir, variable, inherited, fs: fs12 } = params;
7352
- if (inherited === void 0 || inherited === "" || import_node_path35.default.resolve(inherited) === import_node_path35.default.resolve(caCertFile)) {
7352
+ if (inherited === void 0 || inherited === "" || import_node_path36.default.resolve(inherited) === import_node_path36.default.resolve(caCertFile)) {
7353
7353
  return { path: caCertFile };
7354
7354
  }
7355
7355
  const caPem = fs12.readFileUtf8(caCertFile);
@@ -7367,19 +7367,19 @@ function resolveTrustBundle(params) {
7367
7367
  }
7368
7368
  const combined = `${inheritedPem.trimEnd()}
7369
7369
  ${caPem}`;
7370
- const bundle = import_node_path35.default.join(bundlesDir, `${(0, import_node_crypto11.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
7370
+ const bundle = import_node_path36.default.join(bundlesDir, `${(0, import_node_crypto11.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
7371
7371
  if (!fs12.exists(bundle)) {
7372
7372
  fs12.mkdirp(bundlesDir);
7373
7373
  fs12.writeFileAtomic(bundle, combined);
7374
7374
  }
7375
7375
  return { path: bundle };
7376
7376
  }
7377
- var import_node_crypto11, import_node_path35, BUNDLE_NAME_HEX_DIGITS;
7377
+ var import_node_crypto11, import_node_path36, BUNDLE_NAME_HEX_DIGITS;
7378
7378
  var init_trust = __esm({
7379
7379
  "src/frontdoor/trust.ts"() {
7380
7380
  "use strict";
7381
7381
  import_node_crypto11 = require("node:crypto");
7382
- import_node_path35 = __toESM(require("node:path"), 1);
7382
+ import_node_path36 = __toESM(require("node:path"), 1);
7383
7383
  BUNDLE_NAME_HEX_DIGITS = 16;
7384
7384
  }
7385
7385
  });
@@ -7717,11 +7717,11 @@ var init_anthropicUsageRefresh = __esm({
7717
7717
  });
7718
7718
 
7719
7719
  // src/usage/providerQuota.ts
7720
- var import_zod23, 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;
7720
+ var import_zod24, 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;
7721
7721
  var init_providerQuota = __esm({
7722
7722
  "src/usage/providerQuota.ts"() {
7723
7723
  "use strict";
7724
- import_zod23 = require("zod");
7724
+ import_zod24 = require("zod");
7725
7725
  init_schema2();
7726
7726
  MS_PER_SECOND7 = 1e3;
7727
7727
  SECONDS_PER_HOUR = 3600;
@@ -7735,35 +7735,35 @@ var init_providerQuota = __esm({
7735
7735
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
7736
7736
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7]
7737
7737
  ]);
7738
- ZaiLimitSchema = import_zod23.z.object({
7739
- type: import_zod23.z.string(),
7740
- unit: import_zod23.z.number().int(),
7741
- number: import_zod23.z.number().int().positive(),
7742
- percentage: import_zod23.z.number().nonnegative(),
7743
- nextResetTime: import_zod23.z.number().positive().optional(),
7744
- usage: import_zod23.z.number().nonnegative().optional(),
7745
- currentValue: import_zod23.z.number().nonnegative().optional(),
7746
- remaining: import_zod23.z.number().nonnegative().optional()
7738
+ ZaiLimitSchema = import_zod24.z.object({
7739
+ type: import_zod24.z.string(),
7740
+ unit: import_zod24.z.number().int(),
7741
+ number: import_zod24.z.number().int().positive(),
7742
+ percentage: import_zod24.z.number().nonnegative(),
7743
+ nextResetTime: import_zod24.z.number().positive().optional(),
7744
+ usage: import_zod24.z.number().nonnegative().optional(),
7745
+ currentValue: import_zod24.z.number().nonnegative().optional(),
7746
+ remaining: import_zod24.z.number().nonnegative().optional()
7747
7747
  });
7748
- ZaiResponseSchema = import_zod23.z.object({
7749
- success: import_zod23.z.boolean(),
7750
- msg: import_zod23.z.string().optional(),
7751
- data: import_zod23.z.object({ level: import_zod23.z.string().optional(), limits: import_zod23.z.array(ZaiLimitSchema) })
7748
+ ZaiResponseSchema = import_zod24.z.object({
7749
+ success: import_zod24.z.boolean(),
7750
+ msg: import_zod24.z.string().optional(),
7751
+ data: import_zod24.z.object({ level: import_zod24.z.string().optional(), limits: import_zod24.z.array(ZaiLimitSchema) })
7752
7752
  });
7753
7753
  OPENROUTER_HOST = "openrouter.ai";
7754
7754
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
7755
7755
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
7756
7756
  MS_PER_DAY3 = HOURS_PER_DAY3 * SECONDS_PER_HOUR * MS_PER_SECOND7;
7757
- OpenRouterKeySchema = import_zod23.z.object({
7758
- data: import_zod23.z.object({
7759
- limit: import_zod23.z.number().nonnegative().nullable(),
7760
- limit_remaining: import_zod23.z.number().nullable(),
7761
- limit_reset: import_zod23.z.string().nullable(),
7762
- is_free_tier: import_zod23.z.boolean().optional(),
7763
- free_model_daily_requests: import_zod23.z.object({ used: import_zod23.z.number().nonnegative(), limit: import_zod23.z.number().nonnegative(), remaining: import_zod23.z.number() }).optional()
7757
+ OpenRouterKeySchema = import_zod24.z.object({
7758
+ data: import_zod24.z.object({
7759
+ limit: import_zod24.z.number().nonnegative().nullable(),
7760
+ limit_remaining: import_zod24.z.number().nullable(),
7761
+ limit_reset: import_zod24.z.string().nullable(),
7762
+ is_free_tier: import_zod24.z.boolean().optional(),
7763
+ free_model_daily_requests: import_zod24.z.object({ used: import_zod24.z.number().nonnegative(), limit: import_zod24.z.number().nonnegative(), remaining: import_zod24.z.number() }).optional()
7764
7764
  })
7765
7765
  });
7766
- OpenRouterCreditsSchema = import_zod23.z.object({ data: import_zod23.z.object({ total_credits: import_zod23.z.number().nonnegative(), total_usage: import_zod23.z.number().nonnegative() }) });
7766
+ OpenRouterCreditsSchema = import_zod24.z.object({ data: import_zod24.z.object({ total_credits: import_zod24.z.number().nonnegative(), total_usage: import_zod24.z.number().nonnegative() }) });
7767
7767
  }
7768
7768
  });
7769
7769
 
@@ -7885,6 +7885,8 @@ var index_exports = {};
7885
7885
  __export(index_exports, {
7886
7886
  AMBIENT_CREDENTIAL_VARS: () => AMBIENT_CREDENTIAL_VARS,
7887
7887
  CHECK_CREDENTIAL_APPLIES: () => CHECK_CREDENTIAL_APPLIES,
7888
+ CODEX_APP_SERVER_GENERATED_AGAINST: () => CODEX_APP_SERVER_GENERATED_AGAINST,
7889
+ CODEX_APP_SERVER_TIMEOUT_MS: () => CODEX_APP_SERVER_TIMEOUT_MS,
7888
7890
  CONNECT_INTERCEPT_HOST: () => CONNECT_INTERCEPT_HOST,
7889
7891
  CONNECT_INTERCEPT_HOSTS: () => CONNECT_INTERCEPT_HOSTS,
7890
7892
  CONNECT_LIMITS: () => CONNECT_LIMITS,
@@ -7895,7 +7897,12 @@ __export(index_exports, {
7895
7897
  CheckReportJsonSchema: () => CheckReportJsonSchema,
7896
7898
  CheckRunInputSchema: () => CheckRunInputSchema,
7897
7899
  CliError: () => CliError,
7900
+ CodexAccountReadSchema: () => CodexAccountReadSchema,
7901
+ CodexAppServerProtocolError: () => CodexAppServerProtocolError,
7902
+ CodexAppServerRequestError: () => CodexAppServerRequestError,
7903
+ CodexAppServerUnavailableError: () => CodexAppServerUnavailableError,
7898
7904
  CodexLogoutOutputSchema: () => CodexLogoutOutputSchema,
7905
+ CodexRateLimitsReadSchema: () => CodexRateLimitsReadSchema,
7899
7906
  CodexSignInSchema: () => CodexSignInSchema,
7900
7907
  CodexStatusOutputSchema: () => CodexStatusOutputSchema,
7901
7908
  ConfigIdentityAddOutputSchema: () => ConfigIdentityAddOutputSchema,
@@ -8153,6 +8160,8 @@ __export(index_exports, {
8153
8160
  rcSelfHostFromEnv: () => rcSelfHostFromEnv,
8154
8161
  rcWebFetchAllowsPrivateFromEnv: () => rcWebFetchAllowsPrivateFromEnv,
8155
8162
  readActiveIdentity: () => readActiveIdentity2,
8163
+ readCodexAccount: () => readCodexAccount,
8164
+ readCodexRateLimits: () => readCodexRateLimits,
8156
8165
  readDirectoryRules: () => readDirectoryRules,
8157
8166
  readFarmManifest: () => readFarmManifest,
8158
8167
  readFrontDoorControlMaterial: () => readFrontDoorControlMaterial,
@@ -8164,6 +8173,7 @@ __export(index_exports, {
8164
8173
  readRcSelfHostRecord: () => readRcSelfHostRecord,
8165
8174
  readRcSessionFile: () => readRcSessionFile,
8166
8175
  readUsageSnapshot: () => readUsageSnapshot,
8176
+ realCodexAppServerPort: () => realCodexAppServerPort,
8167
8177
  realConnectCertStore: () => realConnectCertStore,
8168
8178
  realConnectEffects: () => realConnectEffects,
8169
8179
  realRcControlTransport: () => realRcControlTransport,
@@ -8723,8 +8733,8 @@ function parseConnectTarget(authority) {
8723
8733
  function isInterceptedHost(host, interceptHosts) {
8724
8734
  return interceptHosts.includes(host);
8725
8735
  }
8726
- function servedByPipeline(path36) {
8727
- return path36?.startsWith(ROUTED_PATH_PREFIX) === true;
8736
+ function servedByPipeline(path37) {
8737
+ return path37?.startsWith(ROUTED_PATH_PREFIX) === true;
8728
8738
  }
8729
8739
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
8730
8740
  "connection",
@@ -9259,11 +9269,11 @@ function createRcSessionTracker(deps) {
9259
9269
  };
9260
9270
  const observeExchange = (request4) => {
9261
9271
  const method = (request4.method ?? "").toUpperCase();
9262
- const path36 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
9263
- if (!path36.startsWith(RC_SESSIONS_PATH_PREFIX)) {
9272
+ const path37 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
9273
+ if (!path37.startsWith(RC_SESSIONS_PATH_PREFIX)) {
9264
9274
  return void 0;
9265
9275
  }
9266
- const tail = path36.slice(RC_SESSIONS_PATH_PREFIX.length);
9276
+ const tail = path37.slice(RC_SESSIONS_PATH_PREFIX.length);
9267
9277
  const facts = {
9268
9278
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
9269
9279
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -9645,8 +9655,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
9645
9655
  function isRcReadFileEncoding(value) {
9646
9656
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
9647
9657
  }
9648
- function buildRcReadFilePayload(requestId, path36, options) {
9649
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path36, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
9658
+ function buildRcReadFilePayload(requestId, path37, options) {
9659
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path37, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
9650
9660
  }
9651
9661
  function buildRcFileSuggestionsPayload(requestId, query) {
9652
9662
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -9748,15 +9758,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
9748
9758
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
9749
9759
  return result.ok ? { ...result, requestId } : result;
9750
9760
  }
9751
- async function readRcSessionFile(deps, sessionId, path36, options) {
9752
- if (path36 === "") {
9761
+ async function readRcSessionFile(deps, sessionId, path37, options) {
9762
+ if (path37 === "") {
9753
9763
  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" };
9754
9764
  }
9755
9765
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
9756
9766
  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" };
9757
9767
  }
9758
9768
  const requestId = deps.newUuid();
9759
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path36, options), `read ${path36} from session ${sessionId}`);
9769
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path37, options), `read ${path37} from session ${sessionId}`);
9760
9770
  return result.ok ? { ...result, requestId } : result;
9761
9771
  }
9762
9772
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -9925,11 +9935,11 @@ function createRcControlHandler(deps) {
9925
9935
  path: "read-file",
9926
9936
  read: (body) => {
9927
9937
  const session = bodyString(body, "session");
9928
- const path36 = bodyString(body, "path");
9938
+ const path37 = bodyString(body, "path");
9929
9939
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
9930
9940
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
9931
- const refused2 = session === void 0 || path36 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
9932
- 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 } }) };
9941
+ const refused2 = session === void 0 || path37 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
9942
+ 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 } }) };
9933
9943
  }
9934
9944
  },
9935
9945
  {
@@ -10239,9 +10249,9 @@ function requestIdOfBody(body) {
10239
10249
  }
10240
10250
  function frontDoorRcControl(transport, token) {
10241
10251
  const headers = { authorization: `Bearer ${token}` };
10242
- const listAnswerOf = async (path36, what) => {
10252
+ const listAnswerOf = async (path37, what) => {
10243
10253
  try {
10244
- return await transport.request({ method: "GET", path: path36, headers });
10254
+ return await transport.request({ method: "GET", path: path37, headers });
10245
10255
  } catch (error) {
10246
10256
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
10247
10257
  }
@@ -10313,10 +10323,10 @@ function frontDoorRcControl(transport, token) {
10313
10323
  }
10314
10324
  return pending;
10315
10325
  };
10316
- const writeOf = async (path36, body, describeFailure) => {
10326
+ const writeOf = async (path37, body, describeFailure) => {
10317
10327
  let answer;
10318
10328
  try {
10319
- answer = await transport.request({ method: "POST", path: path36, headers: { ...headers, "content-type": "application/json" }, body });
10329
+ answer = await transport.request({ method: "POST", path: path37, headers: { ...headers, "content-type": "application/json" }, body });
10320
10330
  } catch (error) {
10321
10331
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
10322
10332
  }
@@ -10347,10 +10357,10 @@ function frontDoorRcControl(transport, token) {
10347
10357
  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}`),
10348
10358
  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}`),
10349
10359
  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}`),
10350
- readFile: async (sessionId, path36, options) => await writeOf(
10360
+ readFile: async (sessionId, path37, options) => await writeOf(
10351
10361
  `${CONTROL_PATH_PREFIX}/read-file`,
10352
- JSON.stringify({ session: sessionId, path: path36, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
10353
- (status, message) => `reading ${path36} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
10362
+ JSON.stringify({ session: sessionId, path: path37, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
10363
+ (status, message) => `reading ${path37} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
10354
10364
  ),
10355
10365
  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}`),
10356
10366
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -10509,12 +10519,12 @@ function tlsFacts(options) {
10509
10519
  }
10510
10520
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
10511
10521
  const agent = new ExemptTlsAgent();
10512
- const post = async (path36, headers, body) => await new Promise((resolve, reject) => {
10522
+ const post = async (path37, headers, body) => await new Promise((resolve, reject) => {
10513
10523
  const options = {
10514
10524
  host: target.host,
10515
10525
  port: target.port,
10516
10526
  method: "POST",
10517
- path: path36,
10527
+ path: path37,
10518
10528
  // 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.
10519
10529
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
10520
10530
  agent
@@ -10579,12 +10589,12 @@ function lateRcStreamDial(resolve) {
10579
10589
  }
10580
10590
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
10581
10591
  const agent = new ExemptTlsAgent();
10582
- const request4 = async (method, path36, headers, body, signal) => await new Promise((resolve, reject) => {
10592
+ const request4 = async (method, path37, headers, body, signal) => await new Promise((resolve, reject) => {
10583
10593
  const options = {
10584
10594
  host: target.host,
10585
10595
  port: target.port,
10586
10596
  method,
10587
- path: path36,
10597
+ path: path37,
10588
10598
  // 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.
10589
10599
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
10590
10600
  agent,
@@ -10626,9 +10636,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
10626
10636
  return { status, body: await readAll(response) };
10627
10637
  },
10628
10638
  openStream: async (sessionId, headers, resume, signal) => {
10629
- 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)}`;
10639
+ 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)}`;
10630
10640
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
10631
- const { status, response } = await request4("GET", path36, streamHeaders, void 0, signal);
10641
+ const { status, response } = await request4("GET", path37, streamHeaders, void 0, signal);
10632
10642
  if (!isSuccessful2(status)) {
10633
10643
  await readAll(response);
10634
10644
  return { status, chunks: NO_CHUNKS };
@@ -11268,6 +11278,242 @@ function frontDoorRcApiClient(port, ca, token) {
11268
11278
  return (0, import_client.createORPCClient)(frontDoorApiLink(port, ca, token));
11269
11279
  }
11270
11280
 
11281
+ // src/codex/appServer.ts
11282
+ init_cliError();
11283
+ init_package();
11284
+
11285
+ // src/codex/appServerSchemas.ts
11286
+ var import_zod5 = require("zod");
11287
+ var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
11288
+ var RateLimitWindowSchema = import_zod5.z.object({
11289
+ usedPercent: import_zod5.z.number(),
11290
+ resetsAt: import_zod5.z.number().nullish(),
11291
+ windowDurationMins: import_zod5.z.number().nullish()
11292
+ });
11293
+ var RateLimitSnapshotSchema = import_zod5.z.object({
11294
+ limitId: import_zod5.z.string().nullish(),
11295
+ limitName: import_zod5.z.string().nullish(),
11296
+ planType: import_zod5.z.string().nullish(),
11297
+ primary: RateLimitWindowSchema.nullish(),
11298
+ secondary: RateLimitWindowSchema.nullish(),
11299
+ rateLimitReachedType: import_zod5.z.string().nullish(),
11300
+ spendControlReached: import_zod5.z.boolean().nullish()
11301
+ });
11302
+ var RateLimitResetCreditSchema = import_zod5.z.object({
11303
+ id: import_zod5.z.string(),
11304
+ grantedAt: import_zod5.z.number(),
11305
+ expiresAt: import_zod5.z.number().nullish(),
11306
+ resetType: import_zod5.z.string(),
11307
+ status: import_zod5.z.string(),
11308
+ title: import_zod5.z.string().nullish(),
11309
+ description: import_zod5.z.string().nullish()
11310
+ });
11311
+ var CodexAccountSchema = import_zod5.z.discriminatedUnion("type", [
11312
+ import_zod5.z.object({ type: import_zod5.z.literal("apiKey") }),
11313
+ import_zod5.z.object({ type: import_zod5.z.literal("chatgpt"), email: import_zod5.z.string().nullable(), planType: import_zod5.z.string() }),
11314
+ import_zod5.z.object({ type: import_zod5.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod5.z.boolean().default(false) })
11315
+ ]);
11316
+ var CodexAccountReadSchema = import_zod5.z.object({
11317
+ account: CodexAccountSchema.nullable(),
11318
+ requiresOpenaiAuth: import_zod5.z.boolean()
11319
+ });
11320
+ var CodexRateLimitsReadSchema = import_zod5.z.object({
11321
+ rateLimits: RateLimitSnapshotSchema,
11322
+ rateLimitsByLimitId: import_zod5.z.record(import_zod5.z.string(), RateLimitSnapshotSchema).nullish(),
11323
+ rateLimitResetCredits: import_zod5.z.object({ availableCount: import_zod5.z.number(), credits: import_zod5.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
11324
+ accountId: import_zod5.z.string().nullish(),
11325
+ ordinaryUsageAllowed: import_zod5.z.boolean().nullish()
11326
+ });
11327
+ var CodexInitializeResultSchema = import_zod5.z.object({ userAgent: import_zod5.z.string() });
11328
+
11329
+ // src/codex/appServer.ts
11330
+ var CodexAppServerUnavailableError = class extends CliError {
11331
+ constructor(detail) {
11332
+ super(`The Codex app-server is not available: ${detail}.`);
11333
+ this.name = "CodexAppServerUnavailableError";
11334
+ }
11335
+ };
11336
+ var CodexAppServerRequestError = class extends CliError {
11337
+ constructor(method, rpcCode, detail) {
11338
+ super(`Codex app-server ${method} failed (${String(rpcCode)}): ${detail}`);
11339
+ this.method = method;
11340
+ this.rpcCode = rpcCode;
11341
+ this.name = "CodexAppServerRequestError";
11342
+ }
11343
+ method;
11344
+ rpcCode;
11345
+ };
11346
+ var CodexAppServerProtocolError = class extends CliError {
11347
+ constructor(method, installedVersion, detail) {
11348
+ super(
11349
+ `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}`
11350
+ );
11351
+ this.method = method;
11352
+ this.installedVersion = installedVersion;
11353
+ this.name = "CodexAppServerProtocolError";
11354
+ }
11355
+ method;
11356
+ installedVersion;
11357
+ };
11358
+ var CODEX_APP_SERVER_TIMEOUT_MS = 3e4;
11359
+ var CLIENT_NAME = "agent-shim";
11360
+ function installedVersionOf(userAgent) {
11361
+ return /^[^/\s]+\/(\S+)/.exec(userAgent)?.[1];
11362
+ }
11363
+ function responseTo(message, id) {
11364
+ if (typeof message !== "object" || message === null || !("id" in message) || message.id !== id) {
11365
+ return void 0;
11366
+ }
11367
+ if ("error" in message && typeof message.error === "object" && message.error !== null) {
11368
+ const { error } = message;
11369
+ const code = "code" in error && typeof error.code === "number" ? error.code : 0;
11370
+ const detail = "message" in error && typeof error.message === "string" ? error.message : "no message";
11371
+ return { error: { code, message: detail } };
11372
+ }
11373
+ return "result" in message ? { result: message.result } : void 0;
11374
+ }
11375
+ async function withAppServer(port, options, ask) {
11376
+ const connection = await port.open({ bin: options.bin ?? "codex", codexHome: options.codexHome });
11377
+ let nextId = 0;
11378
+ const timeoutMs = options.timeoutMs ?? CODEX_APP_SERVER_TIMEOUT_MS;
11379
+ const stopper = AbortSignal.any([...options.signal === void 0 ? [] : [options.signal], AbortSignal.timeout(timeoutMs)]);
11380
+ const stopReason = () => {
11381
+ if (options.signal?.aborted !== true) {
11382
+ return new CodexAppServerUnavailableError(`it did not answer within ${String(timeoutMs)} ms`);
11383
+ }
11384
+ const reason = options.signal.reason;
11385
+ return reason instanceof Error ? reason : new Error(`the Codex app-server read was aborted: ${String(reason)}`);
11386
+ };
11387
+ const aborted = new Promise((_resolve, reject) => {
11388
+ if (stopper.aborted) {
11389
+ reject(stopReason());
11390
+ return;
11391
+ }
11392
+ stopper.addEventListener(
11393
+ "abort",
11394
+ () => {
11395
+ reject(stopReason());
11396
+ },
11397
+ { once: true }
11398
+ );
11399
+ });
11400
+ aborted.catch(() => void 0);
11401
+ const request4 = async (method, params) => {
11402
+ nextId += 1;
11403
+ const id = nextId;
11404
+ connection.send({ jsonrpc: "2.0", id, method, params });
11405
+ for (; ; ) {
11406
+ const message = await Promise.race([connection.receive(), aborted]);
11407
+ if (message === void 0) {
11408
+ throw new CodexAppServerUnavailableError(`it ended before answering ${method}`);
11409
+ }
11410
+ const response = responseTo(message, id);
11411
+ if (response === void 0) {
11412
+ continue;
11413
+ }
11414
+ if ("error" in response) {
11415
+ throw new CodexAppServerRequestError(method, response.error.code, response.error.message);
11416
+ }
11417
+ return response.result;
11418
+ }
11419
+ };
11420
+ try {
11421
+ const initialised = CodexInitializeResultSchema.safeParse(await request4("initialize", { clientInfo: { name: CLIENT_NAME, title: null, version: package_default.version } }));
11422
+ if (!initialised.success) {
11423
+ throw new CodexAppServerProtocolError("initialize", void 0, initialised.error.message);
11424
+ }
11425
+ connection.send({ jsonrpc: "2.0", method: "initialized" });
11426
+ return await ask(request4, installedVersionOf(initialised.data.userAgent));
11427
+ } finally {
11428
+ await connection.close();
11429
+ }
11430
+ }
11431
+ function validated(method, installedVersion, schema, value) {
11432
+ const parsed = schema.safeParse(value);
11433
+ if (!parsed.success) {
11434
+ throw new CodexAppServerProtocolError(method, installedVersion, parsed.error.message);
11435
+ }
11436
+ return parsed.data;
11437
+ }
11438
+ async function readCodexAccount(port, options) {
11439
+ return await withAppServer(port, options, async (request4, version) => validated("account/read", version, CodexAccountReadSchema, await request4("account/read", { refreshToken: false })));
11440
+ }
11441
+ async function readCodexRateLimits(port, options) {
11442
+ return await withAppServer(port, options, async (request4, version) => validated("account/rateLimits/read", version, CodexRateLimitsReadSchema, await request4("account/rateLimits/read", void 0)));
11443
+ }
11444
+
11445
+ // src/codex/realAppServer.ts
11446
+ var import_node_child_process = require("node:child_process");
11447
+ var import_node_readline = __toESM(require("node:readline"), 1);
11448
+ var SHUTDOWN_GRACE_MS = 5e3;
11449
+ var realCodexAppServerPort = {
11450
+ open: async ({ bin, codexHome }) => {
11451
+ const child = (0, import_node_child_process.spawn)(bin, ["app-server"], { stdio: ["pipe", "pipe", "ignore"], env: { ...process.env, CODEX_HOME: codexHome } });
11452
+ await new Promise((resolve, reject) => {
11453
+ child.once("spawn", resolve);
11454
+ child.once("error", (error) => {
11455
+ reject(new CodexAppServerUnavailableError(`${bin} could not be started (${error.message})`));
11456
+ });
11457
+ });
11458
+ const exited = new Promise((resolve) => {
11459
+ child.once("exit", () => {
11460
+ resolve();
11461
+ });
11462
+ });
11463
+ const pending = [];
11464
+ const waiting = [];
11465
+ let ended = false;
11466
+ const deliver = (message) => {
11467
+ const waiter = waiting.shift();
11468
+ if (waiter === void 0) {
11469
+ pending.push(message);
11470
+ } else {
11471
+ waiter(message);
11472
+ }
11473
+ };
11474
+ const lines = import_node_readline.default.createInterface({ input: child.stdout });
11475
+ lines.on("line", (line) => {
11476
+ try {
11477
+ deliver(JSON.parse(line));
11478
+ } catch {
11479
+ }
11480
+ });
11481
+ lines.on("close", () => {
11482
+ ended = true;
11483
+ for (const waiter of waiting.splice(0)) {
11484
+ waiter(void 0);
11485
+ }
11486
+ });
11487
+ const connection = {
11488
+ send: (message) => {
11489
+ child.stdin.write(`${JSON.stringify(message)}
11490
+ `);
11491
+ },
11492
+ receive: async () => {
11493
+ if (pending.length > 0) {
11494
+ return pending.shift();
11495
+ }
11496
+ if (ended) {
11497
+ return void 0;
11498
+ }
11499
+ return await new Promise((resolve) => {
11500
+ waiting.push(resolve);
11501
+ });
11502
+ },
11503
+ close: async () => {
11504
+ child.stdin.end();
11505
+ const timer = setTimeout(() => {
11506
+ child.kill("SIGKILL");
11507
+ }, SHUTDOWN_GRACE_MS);
11508
+ await exited;
11509
+ clearTimeout(timer);
11510
+ lines.close();
11511
+ }
11512
+ };
11513
+ return connection;
11514
+ }
11515
+ };
11516
+
11271
11517
  // src/frontdoor/doorClient.ts
11272
11518
  init_cliError();
11273
11519
  init_realPorts();
@@ -11543,19 +11789,19 @@ function writePools(paths, pools) {
11543
11789
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
11544
11790
  }
11545
11791
  function poolCycleOf(pools, name) {
11546
- const walk = (current, path36) => {
11792
+ const walk = (current, path37) => {
11547
11793
  for (const entry of pools[current]?.identities ?? []) {
11548
11794
  const nested = poolNameOf(poolMemberIdentity(entry));
11549
11795
  if (nested === void 0) {
11550
11796
  continue;
11551
11797
  }
11552
11798
  if (nested === name) {
11553
- return [...path36, nested];
11799
+ return [...path37, nested];
11554
11800
  }
11555
- if (path36.includes(nested)) {
11801
+ if (path37.includes(nested)) {
11556
11802
  continue;
11557
11803
  }
11558
- const found = walk(nested, [...path36, nested]);
11804
+ const found = walk(nested, [...path37, nested]);
11559
11805
  if (found !== void 0) {
11560
11806
  return found;
11561
11807
  }
@@ -11655,7 +11901,7 @@ init_realCredentialCache();
11655
11901
  init_providersStore();
11656
11902
  init_realPorts();
11657
11903
  var import_node_path25 = __toESM(require("node:path"), 1);
11658
- var import_zod12 = require("zod");
11904
+ var import_zod13 = require("zod");
11659
11905
  init_envBool();
11660
11906
  init_load();
11661
11907
  init_schema();
@@ -11743,9 +11989,9 @@ function lookupKeychainService(run, farmRoot) {
11743
11989
  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}".`
11744
11990
  };
11745
11991
  }
11746
- var SettingsSecretsShapeSchema = import_zod12.z.looseObject({
11747
- env: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.unknown()).optional(),
11748
- hooks: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.array(import_zod12.z.unknown())).optional()
11992
+ var SettingsSecretsShapeSchema = import_zod13.z.looseObject({
11993
+ env: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional(),
11994
+ hooks: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.array(import_zod13.z.unknown())).optional()
11749
11995
  });
11750
11996
  function hookCommandCountOf(group) {
11751
11997
  if (typeof group !== "object" || group === null) {
@@ -12037,7 +12283,7 @@ function collectCheckReport(params) {
12037
12283
  }
12038
12284
 
12039
12285
  // src/checkReportSchema.ts
12040
- var import_zod14 = require("zod");
12286
+ var import_zod15 = require("zod");
12041
12287
  init_schema();
12042
12288
  init_claudeVersion();
12043
12289
  init_identity();
@@ -12101,124 +12347,124 @@ var DIAGNOSTIC_CODES = [
12101
12347
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
12102
12348
 
12103
12349
  // src/usage/pickReportSchema.ts
12104
- var import_zod13 = require("zod");
12350
+ var import_zod14 = require("zod");
12105
12351
  init_plan2();
12106
- var PoolPickCandidateViewSchema = import_zod13.z.strictObject({
12107
- identity: import_zod13.z.string(),
12352
+ var PoolPickCandidateViewSchema = import_zod14.z.strictObject({
12353
+ identity: import_zod14.z.string(),
12108
12354
  /** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
12109
- class: import_zod13.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
12355
+ class: import_zod14.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
12110
12356
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
12111
- score: import_zod13.z.number().optional(),
12357
+ score: import_zod14.z.number().optional(),
12112
12358
  /** 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`. */
12113
- scoreWindow: import_zod13.z.enum(["sevenDay", "fiveHour"]).optional(),
12359
+ scoreWindow: import_zod14.z.enum(["sevenDay", "fiveHour"]).optional(),
12114
12360
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
12115
- feasible: import_zod13.z.boolean(),
12361
+ feasible: import_zod14.z.boolean(),
12116
12362
  /** When an `ineligible` member can be used again, as an ISO instant. */
12117
- blockedUntil: import_zod13.z.iso.datetime().optional(),
12363
+ blockedUntil: import_zod14.z.iso.datetime().optional(),
12118
12364
  plan: PlanClassSchema,
12119
12365
  /** The facts behind the class and score, in the order they matter. */
12120
- reasons: import_zod13.z.array(import_zod13.z.string())
12366
+ reasons: import_zod14.z.array(import_zod14.z.string())
12121
12367
  });
12122
- var PoolPickReportSchema = import_zod13.z.strictObject({
12123
- pool: import_zod13.z.string(),
12124
- directory: import_zod13.z.string(),
12368
+ var PoolPickReportSchema = import_zod14.z.strictObject({
12369
+ pool: import_zod14.z.string(),
12370
+ directory: import_zod14.z.string(),
12125
12371
  /** The member a launch would run as, absent when every member is refused. */
12126
- pick: import_zod13.z.string().optional(),
12127
- candidates: import_zod13.z.array(PoolPickCandidateViewSchema),
12372
+ pick: import_zod14.z.string().optional(),
12373
+ candidates: import_zod14.z.array(PoolPickCandidateViewSchema),
12128
12374
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
12129
- missing: import_zod13.z.array(import_zod13.z.string()),
12375
+ missing: import_zod14.z.array(import_zod14.z.string()),
12130
12376
  /** When nothing can be picked, the soonest any member returns. */
12131
- earliestReturn: import_zod13.z.strictObject({ identity: import_zod13.z.string(), at: import_zod13.z.iso.datetime() }).optional(),
12377
+ earliestReturn: import_zod14.z.strictObject({ identity: import_zod14.z.string(), at: import_zod14.z.iso.datetime() }).optional(),
12132
12378
  /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
12133
- movedOff: import_zod13.z.strictObject({ identity: import_zod13.z.string(), reason: import_zod13.z.string() }).optional(),
12379
+ movedOff: import_zod14.z.strictObject({ identity: import_zod14.z.string(), reason: import_zod14.z.string() }).optional(),
12134
12380
  /** Why the last-pick record could not be read, when that is the case. */
12135
- stickyProblem: import_zod13.z.string().optional()
12381
+ stickyProblem: import_zod14.z.string().optional()
12136
12382
  });
12137
12383
 
12138
12384
  // src/checkReportSchema.ts
12139
12385
  var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
12140
- var CheckLayerViewSchema = import_zod14.z.strictObject({
12141
- id: import_zod14.z.int(),
12142
- kind: import_zod14.z.enum(LAYER_KINDS),
12143
- source: import_zod14.z.string()
12386
+ var CheckLayerViewSchema = import_zod15.z.strictObject({
12387
+ id: import_zod15.z.int(),
12388
+ kind: import_zod15.z.enum(LAYER_KINDS),
12389
+ source: import_zod15.z.string()
12144
12390
  });
12145
- var CheckEntryViewSchema = import_zod14.z.strictObject({
12146
- path: import_zod14.z.string(),
12147
- shared: import_zod14.z.boolean(),
12148
- via: import_zod14.z.enum(DECISION_VIAS),
12391
+ var CheckEntryViewSchema = import_zod15.z.strictObject({
12392
+ path: import_zod15.z.string(),
12393
+ shared: import_zod15.z.boolean(),
12394
+ via: import_zod15.z.enum(DECISION_VIAS),
12149
12395
  /** The entry's real category, or null when nothing classifies it. */
12150
- category: import_zod14.z.enum(CATEGORY_NAMES).nullable(),
12151
- rule: import_zod14.z.strictObject({ key: import_zod14.z.string(), layer: import_zod14.z.int() }).optional(),
12396
+ category: import_zod15.z.enum(CATEGORY_NAMES).nullable(),
12397
+ rule: import_zod15.z.strictObject({ key: import_zod15.z.string(), layer: import_zod15.z.int() }).optional(),
12152
12398
  /** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
12153
- eliminated: import_zod14.z.readonly(import_zod14.z.array(import_zod14.z.strictObject({ key: import_zod14.z.string(), failed: import_zod14.z.readonly(import_zod14.z.array(import_zod14.z.string())) }))).optional()
12399
+ eliminated: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.strictObject({ key: import_zod15.z.string(), failed: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string())) }))).optional()
12154
12400
  });
12155
- var CheckDiagnosticSchema = import_zod14.z.strictObject({
12156
- code: import_zod14.z.enum(DIAGNOSTIC_CODES),
12157
- severity: import_zod14.z.enum(DIAGNOSTIC_SEVERITIES),
12158
- message: import_zod14.z.string(),
12159
- subject: import_zod14.z.string().optional(),
12160
- layer: import_zod14.z.int().optional()
12401
+ var CheckDiagnosticSchema = import_zod15.z.strictObject({
12402
+ code: import_zod15.z.enum(DIAGNOSTIC_CODES),
12403
+ severity: import_zod15.z.enum(DIAGNOSTIC_SEVERITIES),
12404
+ message: import_zod15.z.string(),
12405
+ subject: import_zod15.z.string().optional(),
12406
+ layer: import_zod15.z.int().optional()
12161
12407
  });
12162
- var CheckAmbientCredentialSchema = import_zod14.z.union([import_zod14.z.strictObject({ ok: import_zod14.z.literal(true) }), import_zod14.z.strictObject({ ok: import_zod14.z.literal(false), variable: import_zod14.z.string(), message: import_zod14.z.string() })]);
12163
- var CheckKeychainSchema = import_zod14.z.strictObject({
12164
- checked: import_zod14.z.literal(true),
12165
- found: import_zod14.z.boolean(),
12166
- serviceName: import_zod14.z.string().optional(),
12167
- note: import_zod14.z.string()
12408
+ var CheckAmbientCredentialSchema = import_zod15.z.union([import_zod15.z.strictObject({ ok: import_zod15.z.literal(true) }), import_zod15.z.strictObject({ ok: import_zod15.z.literal(false), variable: import_zod15.z.string(), message: import_zod15.z.string() })]);
12409
+ var CheckKeychainSchema = import_zod15.z.strictObject({
12410
+ checked: import_zod15.z.literal(true),
12411
+ found: import_zod15.z.boolean(),
12412
+ serviceName: import_zod15.z.string().optional(),
12413
+ note: import_zod15.z.string()
12168
12414
  });
12169
- var CheckSettingsExposureSchema = import_zod14.z.strictObject({
12170
- file: import_zod14.z.string(),
12171
- envKeyNames: import_zod14.z.readonly(import_zod14.z.array(import_zod14.z.string())),
12172
- hookEventNames: import_zod14.z.readonly(import_zod14.z.array(import_zod14.z.string())),
12173
- hookCommandCount: import_zod14.z.int().nonnegative()
12415
+ var CheckSettingsExposureSchema = import_zod15.z.strictObject({
12416
+ file: import_zod15.z.string(),
12417
+ envKeyNames: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string())),
12418
+ hookEventNames: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string())),
12419
+ hookCommandCount: import_zod15.z.int().nonnegative()
12174
12420
  });
12175
- var CredentialSourceSummarySchema = import_zod14.z.union([
12176
- import_zod14.z.strictObject({ kind: import_zod14.z.literal("env"), variable: import_zod14.z.string() }),
12177
- import_zod14.z.strictObject({ kind: import_zod14.z.literal("file"), path: import_zod14.z.string() }),
12178
- import_zod14.z.strictObject({ kind: import_zod14.z.literal("command"), program: import_zod14.z.string() }),
12179
- import_zod14.z.strictObject({ kind: import_zod14.z.literal("op"), reference: import_zod14.z.string() }),
12180
- import_zod14.z.strictObject({ kind: import_zod14.z.literal("keychain"), service: import_zod14.z.string(), account: import_zod14.z.string().optional() }),
12181
- import_zod14.z.strictObject({ kind: import_zod14.z.literal("literal") })
12421
+ var CredentialSourceSummarySchema = import_zod15.z.union([
12422
+ import_zod15.z.strictObject({ kind: import_zod15.z.literal("env"), variable: import_zod15.z.string() }),
12423
+ import_zod15.z.strictObject({ kind: import_zod15.z.literal("file"), path: import_zod15.z.string() }),
12424
+ import_zod15.z.strictObject({ kind: import_zod15.z.literal("command"), program: import_zod15.z.string() }),
12425
+ import_zod15.z.strictObject({ kind: import_zod15.z.literal("op"), reference: import_zod15.z.string() }),
12426
+ import_zod15.z.strictObject({ kind: import_zod15.z.literal("keychain"), service: import_zod15.z.string(), account: import_zod15.z.string().optional() }),
12427
+ import_zod15.z.strictObject({ kind: import_zod15.z.literal("literal") })
12182
12428
  ]);
12183
- var CredentialSummarySchema = import_zod14.z.strictObject({
12184
- target: import_zod14.z.enum(CREDENTIAL_TARGETS),
12185
- sources: import_zod14.z.readonly(import_zod14.z.array(CredentialSourceSummarySchema)),
12429
+ var CredentialSummarySchema = import_zod15.z.strictObject({
12430
+ target: import_zod15.z.enum(CREDENTIAL_TARGETS),
12431
+ sources: import_zod15.z.readonly(import_zod15.z.array(CredentialSourceSummarySchema)),
12186
12432
  cache: CredentialCacheSchema.optional()
12187
12433
  });
12188
- var CachedCredentialStateSchema = import_zod14.z.union([
12189
- import_zod14.z.strictObject({ store: import_zod14.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod14.z.literal("empty") }),
12190
- import_zod14.z.strictObject({ store: import_zod14.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod14.z.literal("unreadable"), reason: import_zod14.z.string() }),
12191
- import_zod14.z.strictObject({ store: import_zod14.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod14.z.enum(["fresh", "expired"]), ageMs: import_zod14.z.number(), expiresInMs: import_zod14.z.number().optional() })
12434
+ var CachedCredentialStateSchema = import_zod15.z.union([
12435
+ import_zod15.z.strictObject({ store: import_zod15.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod15.z.literal("empty") }),
12436
+ import_zod15.z.strictObject({ store: import_zod15.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod15.z.literal("unreadable"), reason: import_zod15.z.string() }),
12437
+ import_zod15.z.strictObject({ store: import_zod15.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod15.z.enum(["fresh", "expired"]), ageMs: import_zod15.z.number(), expiresInMs: import_zod15.z.number().optional() })
12192
12438
  ]);
12193
- var CheckCredentialProviderSchema = import_zod14.z.union([
12194
- import_zod14.z.strictObject({ name: import_zod14.z.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
12195
- import_zod14.z.strictObject({ name: import_zod14.z.string(), problem: import_zod14.z.string() })
12439
+ var CheckCredentialProviderSchema = import_zod15.z.union([
12440
+ import_zod15.z.strictObject({ name: import_zod15.z.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
12441
+ import_zod15.z.strictObject({ name: import_zod15.z.string(), problem: import_zod15.z.string() })
12196
12442
  ]);
12197
- var CheckCredentialSchema = import_zod14.z.strictObject({
12198
- applies: import_zod14.z.enum(CHECK_CREDENTIAL_APPLIES),
12443
+ var CheckCredentialSchema = import_zod15.z.strictObject({
12444
+ applies: import_zod15.z.enum(CHECK_CREDENTIAL_APPLIES),
12199
12445
  provider: CheckCredentialProviderSchema.optional(),
12200
12446
  identity: CredentialSummarySchema.optional(),
12201
12447
  identityCached: CachedCredentialStateSchema.optional()
12202
12448
  });
12203
- var CheckClaudeVersionSchema = import_zod14.z.strictObject({
12204
- pinned: import_zod14.z.strictObject({ version: import_zod14.z.string(), source: import_zod14.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod14.z.boolean() }).optional(),
12205
- highestInstalled: import_zod14.z.string().optional(),
12206
- installed: import_zod14.z.readonly(import_zod14.z.array(import_zod14.z.string()))
12449
+ var CheckClaudeVersionSchema = import_zod15.z.strictObject({
12450
+ pinned: import_zod15.z.strictObject({ version: import_zod15.z.string(), source: import_zod15.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod15.z.boolean() }).optional(),
12451
+ highestInstalled: import_zod15.z.string().optional(),
12452
+ installed: import_zod15.z.readonly(import_zod15.z.array(import_zod15.z.string()))
12207
12453
  });
12208
- var CheckReportJsonSchema = import_zod14.z.strictObject({
12209
- identity: import_zod14.z.strictObject({ name: import_zod14.z.string().nullable(), source: import_zod14.z.enum(IDENTITY_DECISION_SOURCES) }),
12454
+ var CheckReportJsonSchema = import_zod15.z.strictObject({
12455
+ identity: import_zod15.z.strictObject({ name: import_zod15.z.string().nullable(), source: import_zod15.z.enum(IDENTITY_DECISION_SOURCES) }),
12210
12456
  /** The pool ranking, when the launch named a pool instead of an identity. */
12211
12457
  pool: PoolPickReportSchema.optional(),
12212
- configProfile: import_zod14.z.strictObject({ name: import_zod14.z.string().nullable(), source: import_zod14.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
12213
- layers: import_zod14.z.readonly(import_zod14.z.array(CheckLayerViewSchema)),
12214
- entries: import_zod14.z.readonly(import_zod14.z.array(CheckEntryViewSchema)),
12215
- projectEncodingAmbiguities: import_zod14.z.readonly(
12216
- import_zod14.z.array(import_zod14.z.strictObject({ fragment: import_zod14.z.string(), encoded: import_zod14.z.string(), reason: import_zod14.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod14.z.string() }))
12458
+ configProfile: import_zod15.z.strictObject({ name: import_zod15.z.string().nullable(), source: import_zod15.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
12459
+ layers: import_zod15.z.readonly(import_zod15.z.array(CheckLayerViewSchema)),
12460
+ entries: import_zod15.z.readonly(import_zod15.z.array(CheckEntryViewSchema)),
12461
+ projectEncodingAmbiguities: import_zod15.z.readonly(
12462
+ import_zod15.z.array(import_zod15.z.strictObject({ fragment: import_zod15.z.string(), encoded: import_zod15.z.string(), reason: import_zod15.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod15.z.string() }))
12217
12463
  ),
12218
- diagnostics: import_zod14.z.readonly(import_zod14.z.array(CheckDiagnosticSchema)),
12464
+ diagnostics: import_zod15.z.readonly(import_zod15.z.array(CheckDiagnosticSchema)),
12219
12465
  ambientCredential: CheckAmbientCredentialSchema,
12220
12466
  keychain: CheckKeychainSchema.optional(),
12221
- settingsExposure: import_zod14.z.readonly(import_zod14.z.array(CheckSettingsExposureSchema)),
12467
+ settingsExposure: import_zod15.z.readonly(import_zod15.z.array(CheckSettingsExposureSchema)),
12222
12468
  credential: CheckCredentialSchema,
12223
12469
  claudeVersion: CheckClaudeVersionSchema.optional()
12224
12470
  });
@@ -12228,8 +12474,8 @@ init_middleware();
12228
12474
  init_preflight();
12229
12475
 
12230
12476
  // src/frontdoor/controlSchemas.ts
12231
- var import_node_path29 = __toESM(require("node:path"), 1);
12232
- var import_zod19 = require("zod");
12477
+ var import_node_path30 = __toESM(require("node:path"), 1);
12478
+ var import_zod20 = require("zod");
12233
12479
 
12234
12480
  // src/doctorReport.ts
12235
12481
  init_claudeShim();
@@ -12399,27 +12645,49 @@ function removeIdentity(paths, name) {
12399
12645
  // src/doctorReport.ts
12400
12646
  init_realPorts();
12401
12647
  var import_node_fs9 = __toESM(require("node:fs"), 1);
12648
+ var import_node_path29 = __toESM(require("node:path"), 1);
12649
+
12650
+ // src/usage/signIn.ts
12402
12651
  var import_node_path28 = __toESM(require("node:path"), 1);
12652
+ var CREDENTIALS_FILE = ".credentials.json";
12653
+ function keychainHasItem(run, account) {
12654
+ return run.run("security", ["find-generic-password", "-a", account]).status === 0;
12655
+ }
12656
+ function decideSignIn(facts) {
12657
+ if (facts.hasCredentialBlock) {
12658
+ return { state: "token", detail: "supplies its own credential through a credential block, so a stored login is not what a launch uses" };
12659
+ }
12660
+ if (facts.keychainItem === true) {
12661
+ return { state: "signed-in", detail: "a login is stored in the macOS Keychain" };
12662
+ }
12663
+ if (facts.credentialsFile) {
12664
+ return { state: "signed-in", detail: `a login is stored in ${CREDENTIALS_FILE}` };
12665
+ }
12666
+ return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
12667
+ }
12668
+ function credentialsFilePath(farmRoot) {
12669
+ return import_node_path28.default.join(farmRoot, CREDENTIALS_FILE);
12670
+ }
12403
12671
 
12404
12672
  // src/codex/siwcStore.ts
12405
- var import_zod18 = require("zod");
12673
+ var import_zod19 = require("zod");
12406
12674
 
12407
12675
  // src/codex/auth.ts
12408
- var import_zod16 = require("zod");
12409
- var AuthFileSchema = import_zod16.z.looseObject({
12410
- tokens: import_zod16.z.looseObject({
12411
- access_token: import_zod16.z.string().optional(),
12412
- refresh_token: import_zod16.z.string().optional(),
12413
- id_token: import_zod16.z.string().optional(),
12414
- account_id: import_zod16.z.string().optional()
12676
+ var import_zod17 = require("zod");
12677
+ var AuthFileSchema = import_zod17.z.looseObject({
12678
+ tokens: import_zod17.z.looseObject({
12679
+ access_token: import_zod17.z.string().optional(),
12680
+ refresh_token: import_zod17.z.string().optional(),
12681
+ id_token: import_zod17.z.string().optional(),
12682
+ account_id: import_zod17.z.string().optional()
12415
12683
  }).nullish(),
12416
- last_refresh: import_zod16.z.string().optional()
12684
+ last_refresh: import_zod17.z.string().optional()
12417
12685
  });
12418
- var TokenGrantSchema = import_zod16.z.looseObject({
12419
- access_token: import_zod16.z.string().min(1).optional(),
12420
- refresh_token: import_zod16.z.string().min(1).optional(),
12421
- id_token: import_zod16.z.string().min(1).optional(),
12422
- account_id: import_zod16.z.string().min(1).optional()
12686
+ var TokenGrantSchema = import_zod17.z.looseObject({
12687
+ access_token: import_zod17.z.string().min(1).optional(),
12688
+ refresh_token: import_zod17.z.string().min(1).optional(),
12689
+ id_token: import_zod17.z.string().min(1).optional(),
12690
+ account_id: import_zod17.z.string().min(1).optional()
12423
12691
  });
12424
12692
  var CodexAuthError = class extends Error {
12425
12693
  constructor(message) {
@@ -12429,41 +12697,41 @@ var CodexAuthError = class extends Error {
12429
12697
  };
12430
12698
 
12431
12699
  // src/codex/siwc.ts
12432
- var import_zod17 = require("zod");
12700
+ var import_zod18 = require("zod");
12433
12701
  var SIWC_RESOURCE = "https://api.openai.com/v1";
12434
12702
  var SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
12435
12703
  var SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
12436
- var TokenResponseSchema = import_zod17.z.looseObject({
12437
- access_token: import_zod17.z.string().min(1),
12438
- refresh_token: import_zod17.z.string().min(1).optional(),
12439
- id_token: import_zod17.z.string().min(1).optional(),
12440
- expires_in: import_zod17.z.number().positive(),
12441
- scope: import_zod17.z.string().optional()
12704
+ var TokenResponseSchema = import_zod18.z.looseObject({
12705
+ access_token: import_zod18.z.string().min(1),
12706
+ refresh_token: import_zod18.z.string().min(1).optional(),
12707
+ id_token: import_zod18.z.string().min(1).optional(),
12708
+ expires_in: import_zod18.z.number().positive(),
12709
+ scope: import_zod18.z.string().optional()
12442
12710
  });
12443
- var JwtHeaderSchema = import_zod17.z.looseObject({ alg: import_zod17.z.string(), kid: import_zod17.z.string().optional() });
12444
- var IdTokenClaimsSchema = import_zod17.z.looseObject({
12445
- iss: import_zod17.z.string(),
12446
- sub: import_zod17.z.string().min(1),
12447
- aud: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.array(import_zod17.z.string())]),
12448
- exp: import_zod17.z.number(),
12449
- nonce: import_zod17.z.string().optional(),
12450
- email: import_zod17.z.string().optional()
12711
+ var JwtHeaderSchema = import_zod18.z.looseObject({ alg: import_zod18.z.string(), kid: import_zod18.z.string().optional() });
12712
+ var IdTokenClaimsSchema = import_zod18.z.looseObject({
12713
+ iss: import_zod18.z.string(),
12714
+ sub: import_zod18.z.string().min(1),
12715
+ aud: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.array(import_zod18.z.string())]),
12716
+ exp: import_zod18.z.number(),
12717
+ nonce: import_zod18.z.string().optional(),
12718
+ email: import_zod18.z.string().optional()
12451
12719
  });
12452
- var JwksSchema = import_zod17.z.object({ keys: import_zod17.z.array(import_zod17.z.looseObject({ kid: import_zod17.z.string().optional(), kty: import_zod17.z.string() })) });
12720
+ var JwksSchema = import_zod18.z.object({ keys: import_zod18.z.array(import_zod18.z.looseObject({ kid: import_zod18.z.string().optional(), kty: import_zod18.z.string() })) });
12453
12721
 
12454
12722
  // src/codex/siwcStore.ts
12455
- var SiwcGrantSchema = import_zod18.z.strictObject({
12456
- clientId: import_zod18.z.string().min(1),
12457
- sub: import_zod18.z.string().min(1),
12458
- email: import_zod18.z.string().optional(),
12459
- idToken: import_zod18.z.string().min(1),
12460
- accessToken: import_zod18.z.string().min(1),
12461
- refreshToken: import_zod18.z.string().min(1),
12462
- scopes: import_zod18.z.array(import_zod18.z.string()).readonly(),
12723
+ var SiwcGrantSchema = import_zod19.z.strictObject({
12724
+ clientId: import_zod19.z.string().min(1),
12725
+ sub: import_zod19.z.string().min(1),
12726
+ email: import_zod19.z.string().optional(),
12727
+ idToken: import_zod19.z.string().min(1),
12728
+ accessToken: import_zod19.z.string().min(1),
12729
+ refreshToken: import_zod19.z.string().min(1),
12730
+ scopes: import_zod19.z.array(import_zod19.z.string()).readonly(),
12463
12731
  /** When the access token stops working, in milliseconds since the epoch. */
12464
- expiresAt: import_zod18.z.number()
12732
+ expiresAt: import_zod19.z.number()
12465
12733
  });
12466
- var SiwcFileSchema = import_zod18.z.strictObject({ registeredClientId: import_zod18.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12734
+ var SiwcFileSchema = import_zod19.z.strictObject({ registeredClientId: import_zod19.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12467
12735
  function parseSiwcFile(raw, filePath) {
12468
12736
  let json;
12469
12737
  try {
@@ -12500,6 +12768,7 @@ var DOCTOR_SECTIONS = [
12500
12768
  "legacy-name",
12501
12769
  "config-profile",
12502
12770
  "identity",
12771
+ "sign-in",
12503
12772
  "pool",
12504
12773
  "provider",
12505
12774
  "keychain",
@@ -12542,7 +12811,7 @@ function tcpPortEraRecord(raw) {
12542
12811
  return (has("port") || has("lastPort")) && !has("socketPath");
12543
12812
  }
12544
12813
  function pushPathResolution(push, resolution) {
12545
- const ownDir = import_node_path28.default.dirname(resolution.ownExecutablePath);
12814
+ const ownDir = import_node_path29.default.dirname(resolution.ownExecutablePath);
12546
12815
  switch (resolution.agentShim.status) {
12547
12816
  case "ok":
12548
12817
  push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
@@ -12622,17 +12891,17 @@ function pushProvider(push, entry, cacheEnv, signIn) {
12622
12891
  push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
12623
12892
  return;
12624
12893
  }
12625
- const validated2 = ProviderSchema.safeParse(parsed);
12626
- if (!validated2.success) {
12627
- push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
12894
+ const validated3 = ProviderSchema.safeParse(parsed);
12895
+ if (!validated3.success) {
12896
+ push("provider", "fail", new ConfigValidationError(entry.path, validated3.error.issues).message, entry.name);
12628
12897
  return;
12629
12898
  }
12630
- const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
12631
- push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
12632
- if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
12899
+ const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated3.data.credential);
12900
+ push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated3.data)}, credential ${describeCredential(validated3.data.credential)})${cache.text}.`, entry.name);
12901
+ if (validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
12633
12902
  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);
12634
12903
  }
12635
- if (signIn !== void 0 && isCodexProvider(validated2.data) && validated2.data.codex?.login === "chatgpt-sign-in") {
12904
+ if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
12636
12905
  const problem = signInProblem(signIn);
12637
12906
  if (problem !== void 0) {
12638
12907
  push("provider", "warn", `${entry.name} uses the Sign in with ChatGPT login, but ${problem}`, entry.name);
@@ -12641,14 +12910,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
12641
12910
  }
12642
12911
  function pushLegacyName(push, params) {
12643
12912
  const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
12644
- if (legacyVariables.length === 0 && import_node_path28.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
12913
+ if (legacyVariables.length === 0 && import_node_path29.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
12645
12914
  push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
12646
12915
  return;
12647
12916
  }
12648
12917
  for (const name of legacyVariables) {
12649
12918
  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);
12650
12919
  }
12651
- if (import_node_path28.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
12920
+ if (import_node_path29.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
12652
12921
  push(
12653
12922
  "legacy-name",
12654
12923
  "warn",
@@ -12700,13 +12969,13 @@ function runDoctor(params) {
12700
12969
  pushLegacyName(push, params);
12701
12970
  const profileSources = /* @__PURE__ */ new Map();
12702
12971
  for (const entry of params.configProfiles) {
12703
- const validated2 = validateJson(ConfigProfileSchema, entry);
12704
- if (!validated2.ok) {
12705
- push("config-profile", "fail", validated2.message, entry.name);
12972
+ const validated3 = validateJson(ConfigProfileSchema, entry);
12973
+ if (!validated3.ok) {
12974
+ push("config-profile", "fail", validated3.message, entry.name);
12706
12975
  continue;
12707
12976
  }
12708
- profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
12709
- checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
12977
+ profileSources.set(entry.name, { name: entry.name, profile: validated3.data });
12978
+ checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated3.data.launch?.claudeVersion);
12710
12979
  }
12711
12980
  const loadProfile = (name) => profileSources.get(name);
12712
12981
  for (const name of profileSources.keys()) {
@@ -12722,13 +12991,13 @@ function runDoctor(params) {
12722
12991
  const validProfileNames = new Set(profileSources.keys());
12723
12992
  const validIdentityNames = /* @__PURE__ */ new Set();
12724
12993
  for (const entry of params.identities) {
12725
- const validated2 = validateJson(IdentitySchema, entry);
12726
- if (!validated2.ok) {
12727
- push("identity", "fail", validated2.message, entry.name);
12994
+ const validated3 = validateJson(IdentitySchema, entry);
12995
+ if (!validated3.ok) {
12996
+ push("identity", "fail", validated3.message, entry.name);
12728
12997
  continue;
12729
12998
  }
12730
12999
  validIdentityNames.add(entry.name);
12731
- const defaultProfile = validated2.data.defaultConfigProfile;
13000
+ const defaultProfile = validated3.data.defaultConfigProfile;
12732
13001
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
12733
13002
  push(
12734
13003
  "identity",
@@ -12737,7 +13006,7 @@ function runDoctor(params) {
12737
13006
  entry.name
12738
13007
  );
12739
13008
  } else {
12740
- const credential = validated2.data.credential;
13009
+ const credential = validated3.data.credential;
12741
13010
  const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
12742
13011
  push(
12743
13012
  "identity",
@@ -12745,6 +13014,18 @@ function runDoctor(params) {
12745
13014
  `${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
12746
13015
  entry.name
12747
13016
  );
13017
+ const signIn = decideSignIn({
13018
+ hasCredentialBlock: credential !== void 0,
13019
+ keychainItem: params.platform === "darwin" && params.run !== void 0 ? keychainHasItem(params.run, entry.farmRoot) : void 0,
13020
+ credentialsFile: entry.credentialsFilePresent,
13021
+ platform: params.platform
13022
+ });
13023
+ push(
13024
+ "sign-in",
13025
+ signIn.state === "signed-out" ? "warn" : "pass",
13026
+ 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}).`,
13027
+ entry.name
13028
+ );
12748
13029
  }
12749
13030
  }
12750
13031
  const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
@@ -12790,18 +13071,18 @@ function runDoctor(params) {
12790
13071
  } else {
12791
13072
  for (const entry of params.identities) {
12792
13073
  const result = lookupKeychainService(params.run, entry.farmRoot);
12793
- push("keychain", result.found ? "pass" : "warn", result.note, entry.name);
13074
+ push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
12794
13075
  }
12795
13076
  }
12796
13077
  if (params.directoryRules.raw === void 0) {
12797
13078
  push("directory-rules", "pass", "No directory-rules.json configured.");
12798
13079
  } else {
12799
- const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
12800
- if (!validated2.ok) {
12801
- push("directory-rules", "fail", validated2.message);
13080
+ const validated3 = validateJson(DirectoryRulesSchema, params.directoryRules);
13081
+ if (!validated3.ok) {
13082
+ push("directory-rules", "fail", validated3.message);
12802
13083
  } else {
12803
13084
  push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
12804
- for (const rule of validated2.data.rules) {
13085
+ for (const rule of validated3.data.rules) {
12805
13086
  const badRefs = [];
12806
13087
  if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
12807
13088
  badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
@@ -12821,11 +13102,11 @@ function runDoctor(params) {
12821
13102
  if (params.globalConfig.raw === void 0) {
12822
13103
  push("global-config", "pass", "No config.json configured.");
12823
13104
  } else {
12824
- const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
12825
- if (!validated2.ok) {
12826
- push("global-config", "fail", validated2.message);
13105
+ const validated3 = validateJson(GlobalConfigSchema, params.globalConfig);
13106
+ if (!validated3.ok) {
13107
+ push("global-config", "fail", validated3.message);
12827
13108
  } else {
12828
- const defaultProfile = validated2.data.defaultConfigProfile;
13109
+ const defaultProfile = validated3.data.defaultConfigProfile;
12829
13110
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
12830
13111
  push(
12831
13112
  "global-config",
@@ -12834,18 +13115,18 @@ function runDoctor(params) {
12834
13115
  );
12835
13116
  } else {
12836
13117
  push("global-config", "pass", `${params.globalConfig.path} is valid.`);
12837
- checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
13118
+ checkPin("global-config", void 0, "config.json", validated3.data.launch?.claudeVersion);
12838
13119
  }
12839
13120
  }
12840
13121
  }
12841
13122
  if (params.categoriesLocal.raw === void 0) {
12842
13123
  push("categories-local", "pass", "No categories.local.json configured.");
12843
13124
  } else {
12844
- const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
13125
+ const validated3 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
12845
13126
  push(
12846
13127
  "categories-local",
12847
- validated2.ok ? "pass" : "fail",
12848
- validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
13128
+ validated3.ok ? "pass" : "fail",
13129
+ validated3.ok ? `${params.categoriesLocal.path} is valid.` : validated3.message
12849
13130
  );
12850
13131
  }
12851
13132
  if (params.headroom.state.raw === void 0) {
@@ -12853,11 +13134,11 @@ function runDoctor(params) {
12853
13134
  } else if (tcpPortEraRecord(params.headroom.state.raw)) {
12854
13135
  push("headroom", "pass", `${params.headroom.state.path} holds a previous release's TCP-port state record; the next launch through headroom claims over it.`);
12855
13136
  } else {
12856
- const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
12857
- if (!validated2.ok) {
12858
- push("headroom", "fail", validated2.message);
13137
+ const validated3 = validateJson(HeadroomStateSchema, params.headroom.state);
13138
+ if (!validated3.ok) {
13139
+ push("headroom", "fail", validated3.message);
12859
13140
  } else {
12860
- const state = validated2.data;
13141
+ const state = validated3.data;
12861
13142
  const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
12862
13143
  const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
12863
13144
  if (state.supervisorPid === void 0) {
@@ -12925,6 +13206,7 @@ var SECTION_TITLES = {
12925
13206
  "legacy-name": "Former `claude-use` name",
12926
13207
  "config-profile": "Configuration profiles",
12927
13208
  identity: "Identities",
13209
+ "sign-in": "Sign-in",
12928
13210
  pool: "Pools",
12929
13211
  provider: "Providers",
12930
13212
  keychain: "macOS Keychain",
@@ -12941,6 +13223,7 @@ var SECTION_ORDER = [
12941
13223
  "path-resolution",
12942
13224
  "config-profile",
12943
13225
  "identity",
13226
+ "sign-in",
12944
13227
  "pool",
12945
13228
  "provider",
12946
13229
  "keychain",
@@ -12990,18 +13273,18 @@ function collectDoctorReport(params) {
12990
13273
  const { paths } = params;
12991
13274
  const identityNames = import_node_fs9.default.existsSync(paths.identitiesDir) ? import_node_fs9.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
12992
13275
  const identities = identityNames.map((name) => {
12993
- const farmRoot = import_node_path28.default.join(paths.identitiesDir, name);
12994
- const identityPath = import_node_path28.default.join(farmRoot, "identity.json");
12995
- return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
13276
+ const farmRoot = import_node_path29.default.join(paths.identitiesDir, name);
13277
+ const identityPath = import_node_path29.default.join(farmRoot, "identity.json");
13278
+ return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs9.default.existsSync(credentialsFilePath(farmRoot)) };
12996
13279
  });
12997
13280
  const profileNames = import_node_fs9.default.existsSync(paths.configProfilesDir) ? import_node_fs9.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
12998
13281
  const configProfiles = profileNames.map((name) => {
12999
- const profilePath = import_node_path28.default.join(paths.configProfilesDir, `${name}.json`);
13282
+ const profilePath = import_node_path29.default.join(paths.configProfilesDir, `${name}.json`);
13000
13283
  return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
13001
13284
  });
13002
13285
  const providerNames = import_node_fs9.default.existsSync(paths.providersDir) ? import_node_fs9.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
13003
13286
  const providers = providerNames.map((name) => {
13004
- const providerPath = import_node_path28.default.join(paths.providersDir, `${name}.json`);
13287
+ const providerPath = import_node_path29.default.join(paths.providersDir, `${name}.json`);
13005
13288
  return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
13006
13289
  });
13007
13290
  const ownExecutablePath = realOwnExecutablePath();
@@ -13013,12 +13296,12 @@ function collectDoctorReport(params) {
13013
13296
  binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
13014
13297
  }
13015
13298
  const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
13016
- const pathDirs = (params.env.PATH ?? "").split(import_node_path28.default.delimiter).filter((dir) => dir !== "");
13299
+ const pathDirs = (params.env.PATH ?? "").split(import_node_path29.default.delimiter).filter((dir) => dir !== "");
13017
13300
  const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
13018
13301
  findPathShadow({
13019
13302
  pathDirs,
13020
- targetDir: import_node_path28.default.dirname(shimState.targetPath),
13021
- targetFilename: import_node_path28.default.basename(shimState.targetPath),
13303
+ targetDir: import_node_path29.default.dirname(shimState.targetPath),
13304
+ targetFilename: import_node_path29.default.basename(shimState.targetPath),
13022
13305
  findExecutableInDir
13023
13306
  }),
13024
13307
  shimState.targetPath,
@@ -13044,7 +13327,7 @@ function collectDoctorReport(params) {
13044
13327
  agentShim: refinePathShadow(
13045
13328
  findPathShadow({
13046
13329
  pathDirs,
13047
- targetDir: import_node_path28.default.dirname(ownExecutablePath),
13330
+ targetDir: import_node_path29.default.dirname(ownExecutablePath),
13048
13331
  targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
13049
13332
  findExecutableInDir
13050
13333
  }),
@@ -13071,90 +13354,90 @@ function collectDoctorReport(params) {
13071
13354
  // src/frontdoor/controlSchemas.ts
13072
13355
  init_schema2();
13073
13356
  init_state();
13074
- var UsageListOutputSchema = import_zod19.z.strictObject({ snapshots: import_zod19.z.readonly(import_zod19.z.array(UsageSnapshotSchema)) });
13075
- var UsageWindowsInputSchema = import_zod19.z.strictObject({
13076
- identity: import_zod19.z.string().min(1),
13077
- provider: import_zod19.z.string().min(1).optional()
13357
+ var UsageListOutputSchema = import_zod20.z.strictObject({ snapshots: import_zod20.z.readonly(import_zod20.z.array(UsageSnapshotSchema)) });
13358
+ var UsageWindowsInputSchema = import_zod20.z.strictObject({
13359
+ identity: import_zod20.z.string().min(1),
13360
+ provider: import_zod20.z.string().min(1).optional()
13078
13361
  });
13079
- var EffectiveWindowSchema = import_zod19.z.strictObject({
13362
+ var EffectiveWindowSchema = import_zod20.z.strictObject({
13080
13363
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
13081
- reset: import_zod19.z.boolean(),
13364
+ reset: import_zod20.z.boolean(),
13082
13365
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
13083
- utilization: import_zod19.z.number().optional(),
13366
+ utilization: import_zod20.z.number().optional(),
13084
13367
  /** The reset instant, for a window that has not reset yet and reported one. */
13085
- resetsAtMs: import_zod19.z.number().optional(),
13368
+ resetsAtMs: import_zod20.z.number().optional(),
13086
13369
  /** The window's own status, for a window that has not reset yet. */
13087
- status: import_zod19.z.string().optional()
13370
+ status: import_zod20.z.string().optional()
13088
13371
  });
13089
- var UsageWindowsOutputSchema = import_zod19.z.strictObject({
13090
- identity: import_zod19.z.string(),
13091
- provider: import_zod19.z.string(),
13372
+ var UsageWindowsOutputSchema = import_zod20.z.strictObject({
13373
+ identity: import_zod20.z.string(),
13374
+ provider: import_zod20.z.string(),
13092
13375
  /** When the rate-limit state the windows come from was observed. */
13093
- observedAt: import_zod19.z.iso.datetime().optional(),
13376
+ observedAt: import_zod20.z.iso.datetime().optional(),
13094
13377
  fiveHour: EffectiveWindowSchema.optional(),
13095
13378
  sevenDay: EffectiveWindowSchema.optional()
13096
13379
  });
13097
- var UsageLiveOutputSchema = import_zod19.z.strictObject({
13380
+ var UsageLiveOutputSchema = import_zod20.z.strictObject({
13098
13381
  /** 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. */
13099
13382
  latest: RcLiveRateLimitSchema.optional(),
13100
13383
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
13101
- sessions: import_zod19.z.readonly(import_zod19.z.array(RcLiveRateLimitSchema))
13384
+ sessions: import_zod20.z.readonly(import_zod20.z.array(RcLiveRateLimitSchema))
13102
13385
  });
13103
- var FrontDoorSessionStatusSchema = import_zod19.z.strictObject({
13104
- pid: import_zod19.z.int().positive(),
13105
- startedAt: import_zod19.z.number(),
13106
- alive: import_zod19.z.boolean()
13386
+ var FrontDoorSessionStatusSchema = import_zod20.z.strictObject({
13387
+ pid: import_zod20.z.int().positive(),
13388
+ startedAt: import_zod20.z.number(),
13389
+ alive: import_zod20.z.boolean()
13107
13390
  });
13108
- var HeadroomSocketTargetSchema = import_zod19.z.union([import_zod19.z.strictObject({ socketPath: import_zod19.z.string() }), import_zod19.z.strictObject({ refused: import_zod19.z.string() })]);
13109
- var FrontDoorStatusOutputSchema = import_zod19.z.strictObject({
13391
+ var HeadroomSocketTargetSchema = import_zod20.z.union([import_zod20.z.strictObject({ socketPath: import_zod20.z.string() }), import_zod20.z.strictObject({ refused: import_zod20.z.string() })]);
13392
+ var FrontDoorStatusOutputSchema = import_zod20.z.strictObject({
13110
13393
  state: FrontDoorStateSchema,
13111
- supervisorAlive: import_zod19.z.boolean(),
13112
- sessions: import_zod19.z.readonly(import_zod19.z.array(FrontDoorSessionStatusSchema)),
13394
+ supervisorAlive: import_zod20.z.boolean(),
13395
+ sessions: import_zod20.z.readonly(import_zod20.z.array(FrontDoorSessionStatusSchema)),
13113
13396
  headroomSocket: HeadroomSocketTargetSchema.optional(),
13114
- logPath: import_zod19.z.string(),
13115
- logExists: import_zod19.z.boolean()
13397
+ logPath: import_zod20.z.string(),
13398
+ logExists: import_zod20.z.boolean()
13116
13399
  });
13117
- var FrontDoorSessionsOutputSchema = import_zod19.z.strictObject({ sessions: import_zod19.z.readonly(import_zod19.z.array(FrontDoorSessionStatusSchema)) });
13118
- var CheckRunInputSchema = import_zod19.z.strictObject({
13119
- path: import_zod19.z.string().min(1),
13120
- identity: import_zod19.z.string().min(1).optional()
13121
- }).refine((input) => import_node_path29.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13122
- var PoolPickInputSchema = import_zod19.z.strictObject({
13123
- pool: import_zod19.z.string().min(1),
13124
- path: import_zod19.z.string().min(1)
13125
- }).refine((input) => import_node_path29.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13126
- var DoctorFindingSchema = import_zod19.z.strictObject({
13127
- section: import_zod19.z.enum(DOCTOR_SECTIONS),
13128
- subject: import_zod19.z.string().optional(),
13129
- severity: import_zod19.z.enum(DOCTOR_SEVERITIES),
13130
- message: import_zod19.z.string()
13400
+ var FrontDoorSessionsOutputSchema = import_zod20.z.strictObject({ sessions: import_zod20.z.readonly(import_zod20.z.array(FrontDoorSessionStatusSchema)) });
13401
+ var CheckRunInputSchema = import_zod20.z.strictObject({
13402
+ path: import_zod20.z.string().min(1),
13403
+ identity: import_zod20.z.string().min(1).optional()
13404
+ }).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13405
+ var PoolPickInputSchema = import_zod20.z.strictObject({
13406
+ pool: import_zod20.z.string().min(1),
13407
+ path: import_zod20.z.string().min(1)
13408
+ }).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13409
+ var DoctorFindingSchema = import_zod20.z.strictObject({
13410
+ section: import_zod20.z.enum(DOCTOR_SECTIONS),
13411
+ subject: import_zod20.z.string().optional(),
13412
+ severity: import_zod20.z.enum(DOCTOR_SEVERITIES),
13413
+ message: import_zod20.z.string()
13131
13414
  });
13132
- var DoctorRunOutputSchema = import_zod19.z.strictObject({
13415
+ var DoctorRunOutputSchema = import_zod20.z.strictObject({
13133
13416
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
13134
- ok: import_zod19.z.boolean(),
13135
- findings: import_zod19.z.readonly(import_zod19.z.array(DoctorFindingSchema))
13417
+ ok: import_zod20.z.boolean(),
13418
+ findings: import_zod20.z.readonly(import_zod20.z.array(DoctorFindingSchema))
13136
13419
  });
13137
- var FrontDoorRestartOutputSchema = import_zod19.z.strictObject({
13138
- action: import_zod19.z.literal("restarting"),
13139
- previousPid: import_zod19.z.int().positive()
13420
+ var FrontDoorRestartOutputSchema = import_zod20.z.strictObject({
13421
+ action: import_zod20.z.literal("restarting"),
13422
+ previousPid: import_zod20.z.int().positive()
13140
13423
  });
13141
- var UpdateCheckOutputSchema = import_zod19.z.strictObject({
13142
- current: import_zod19.z.string(),
13143
- latest: import_zod19.z.string(),
13144
- action: import_zod19.z.enum(["current", "available", "updated"])
13424
+ var UpdateCheckOutputSchema = import_zod20.z.strictObject({
13425
+ current: import_zod20.z.string(),
13426
+ latest: import_zod20.z.string(),
13427
+ action: import_zod20.z.enum(["current", "available", "updated"])
13145
13428
  });
13146
- var CodexSignInSchema = import_zod19.z.discriminatedUnion("state", [
13147
- import_zod19.z.strictObject({ state: import_zod19.z.literal("none") }),
13148
- import_zod19.z.strictObject({ state: import_zod19.z.literal("signed-in"), email: import_zod19.z.string().optional(), planScope: import_zod19.z.boolean(), accessTokenExpiresAt: import_zod19.z.number() }),
13149
- import_zod19.z.strictObject({ state: import_zod19.z.literal("unreadable"), message: import_zod19.z.string() })
13429
+ var CodexSignInSchema = import_zod20.z.discriminatedUnion("state", [
13430
+ import_zod20.z.strictObject({ state: import_zod20.z.literal("none") }),
13431
+ import_zod20.z.strictObject({ state: import_zod20.z.literal("signed-in"), email: import_zod20.z.string().optional(), planScope: import_zod20.z.boolean(), accessTokenExpiresAt: import_zod20.z.number() }),
13432
+ import_zod20.z.strictObject({ state: import_zod20.z.literal("unreadable"), message: import_zod20.z.string() })
13150
13433
  ]);
13151
- var CodexStatusOutputSchema = import_zod19.z.strictObject({
13434
+ var CodexStatusOutputSchema = import_zod20.z.strictObject({
13152
13435
  signIn: CodexSignInSchema,
13153
- codexProviders: import_zod19.z.readonly(import_zod19.z.array(import_zod19.z.string()))
13436
+ codexProviders: import_zod20.z.readonly(import_zod20.z.array(import_zod20.z.string()))
13154
13437
  });
13155
- var CodexLogoutOutputSchema = import_zod19.z.strictObject({
13156
- hadGrant: import_zod19.z.boolean(),
13157
- revoked: import_zod19.z.boolean()
13438
+ var CodexLogoutOutputSchema = import_zod20.z.strictObject({
13439
+ hadGrant: import_zod20.z.boolean(),
13440
+ revoked: import_zod20.z.boolean()
13158
13441
  });
13159
13442
 
13160
13443
  // src/frontdoor/codexApi.ts
@@ -13310,131 +13593,131 @@ init_identity();
13310
13593
  init_providersStore();
13311
13594
 
13312
13595
  // src/frontdoor/configSchemas.ts
13313
- var import_zod20 = require("zod");
13596
+ var import_zod21 = require("zod");
13314
13597
  init_schema();
13315
- var RemovalConfirmationSchema = import_zod20.z.boolean();
13316
- var CredentialWriteSchema = (targets) => import_zod20.z.strictObject({
13317
- sources: import_zod20.z.array(RemoteCredentialSourceSchema).min(1).optional(),
13318
- target: import_zod20.z.enum(targets).optional(),
13319
- cache: import_zod20.z.union([import_zod20.z.literal(false), CredentialCacheSchema]).optional()
13598
+ var RemovalConfirmationSchema = import_zod21.z.boolean();
13599
+ var CredentialWriteSchema = (targets) => import_zod21.z.strictObject({
13600
+ sources: import_zod21.z.array(RemoteCredentialSourceSchema).min(1).optional(),
13601
+ target: import_zod21.z.enum(targets).optional(),
13602
+ cache: import_zod21.z.union([import_zod21.z.literal(false), CredentialCacheSchema]).optional()
13320
13603
  });
13321
- var CredentialSummarySchema2 = import_zod20.z.strictObject({
13322
- target: import_zod20.z.enum(CREDENTIAL_TARGETS),
13323
- sources: import_zod20.z.readonly(import_zod20.z.array(
13324
- import_zod20.z.discriminatedUnion("kind", [
13325
- import_zod20.z.strictObject({ kind: import_zod20.z.literal("env"), variable: import_zod20.z.string() }),
13326
- import_zod20.z.strictObject({ kind: import_zod20.z.literal("file"), path: import_zod20.z.string() }),
13327
- import_zod20.z.strictObject({ kind: import_zod20.z.literal("command"), program: import_zod20.z.string() }),
13328
- import_zod20.z.strictObject({ kind: import_zod20.z.literal("op"), reference: import_zod20.z.string() }),
13329
- import_zod20.z.strictObject({ kind: import_zod20.z.literal("keychain"), service: import_zod20.z.string(), account: import_zod20.z.string().optional() }),
13330
- import_zod20.z.strictObject({ kind: import_zod20.z.literal("literal") })
13604
+ var CredentialSummarySchema2 = import_zod21.z.strictObject({
13605
+ target: import_zod21.z.enum(CREDENTIAL_TARGETS),
13606
+ sources: import_zod21.z.readonly(import_zod21.z.array(
13607
+ import_zod21.z.discriminatedUnion("kind", [
13608
+ import_zod21.z.strictObject({ kind: import_zod21.z.literal("env"), variable: import_zod21.z.string() }),
13609
+ import_zod21.z.strictObject({ kind: import_zod21.z.literal("file"), path: import_zod21.z.string() }),
13610
+ import_zod21.z.strictObject({ kind: import_zod21.z.literal("command"), program: import_zod21.z.string() }),
13611
+ import_zod21.z.strictObject({ kind: import_zod21.z.literal("op"), reference: import_zod21.z.string() }),
13612
+ import_zod21.z.strictObject({ kind: import_zod21.z.literal("keychain"), service: import_zod21.z.string(), account: import_zod21.z.string().optional() }),
13613
+ import_zod21.z.strictObject({ kind: import_zod21.z.literal("literal") })
13331
13614
  ])
13332
13615
  )),
13333
13616
  cache: CredentialCacheSchema.optional()
13334
13617
  });
13335
- var mutationOutput = (kind, action) => import_zod20.z.strictObject({ action: import_zod20.z.literal(action), kind: import_zod20.z.literal(kind), name: import_zod20.z.string() });
13336
- var storedMutationOutput = (kind, action, value) => import_zod20.z.strictObject({ action: import_zod20.z.literal(action), kind: import_zod20.z.literal(kind), name: import_zod20.z.string(), value });
13337
- var IdentityValueSchema = import_zod20.z.strictObject({
13338
- name: import_zod20.z.string(),
13339
- defaultConfigProfile: import_zod20.z.string().optional(),
13340
- allowAmbientCredential: import_zod20.z.boolean(),
13618
+ var mutationOutput = (kind, action) => import_zod21.z.strictObject({ action: import_zod21.z.literal(action), kind: import_zod21.z.literal(kind), name: import_zod21.z.string() });
13619
+ var storedMutationOutput = (kind, action, value) => import_zod21.z.strictObject({ action: import_zod21.z.literal(action), kind: import_zod21.z.literal(kind), name: import_zod21.z.string(), value });
13620
+ var IdentityValueSchema = import_zod21.z.strictObject({
13621
+ name: import_zod21.z.string(),
13622
+ defaultConfigProfile: import_zod21.z.string().optional(),
13623
+ allowAmbientCredential: import_zod21.z.boolean(),
13341
13624
  credential: CredentialSummarySchema2.optional()
13342
13625
  });
13343
13626
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
13344
- var ProviderValueSchema = import_zod20.z.strictObject({
13345
- name: import_zod20.z.string(),
13346
- kind: import_zod20.z.enum(PROVIDER_KINDS),
13347
- displayName: import_zod20.z.string(),
13348
- baseUrl: import_zod20.z.string().optional(),
13627
+ var ProviderValueSchema = import_zod21.z.strictObject({
13628
+ name: import_zod21.z.string(),
13629
+ kind: import_zod21.z.enum(PROVIDER_KINDS),
13630
+ displayName: import_zod21.z.string(),
13631
+ baseUrl: import_zod21.z.string().optional(),
13349
13632
  codex: CodexProviderConfigSchema.optional(),
13350
13633
  credential: CredentialSummarySchema2,
13351
- env: import_zod20.z.record(import_zod20.z.string(), import_zod20.z.string()).optional()
13634
+ env: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.string()).optional()
13352
13635
  });
13353
- var ConfigNameInputSchema = import_zod20.z.strictObject({ name: import_zod20.z.string().min(1) });
13636
+ var ConfigNameInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1) });
13354
13637
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
13355
- var ConfigIdentitySetInputSchema = import_zod20.z.strictObject({
13356
- name: import_zod20.z.string().min(1),
13357
- defaultConfigProfile: import_zod20.z.union([import_zod20.z.string().min(1), import_zod20.z.literal(false)]).optional(),
13358
- allowAmbientCredential: import_zod20.z.boolean().optional(),
13359
- credential: import_zod20.z.union([import_zod20.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
13638
+ var ConfigIdentitySetInputSchema = import_zod21.z.strictObject({
13639
+ name: import_zod21.z.string().min(1),
13640
+ defaultConfigProfile: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional(),
13641
+ allowAmbientCredential: import_zod21.z.boolean().optional(),
13642
+ credential: import_zod21.z.union([import_zod21.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional()
13360
13643
  });
13361
13644
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
13362
- var ConfigIdentityRemoveInputSchema = import_zod20.z.strictObject({ name: import_zod20.z.string().min(1), confirm: RemovalConfirmationSchema });
13645
+ var ConfigIdentityRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
13363
13646
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
13364
13647
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
13365
- var ConfigProfileAddInputSchema = import_zod20.z.strictObject({
13366
- name: import_zod20.z.string().min(1),
13367
- extends: import_zod20.z.array(import_zod20.z.string().min(1)).optional(),
13368
- description: import_zod20.z.string().optional()
13648
+ var ConfigProfileAddInputSchema = import_zod21.z.strictObject({
13649
+ name: import_zod21.z.string().min(1),
13650
+ extends: import_zod21.z.array(import_zod21.z.string().min(1)).optional(),
13651
+ description: import_zod21.z.string().optional()
13369
13652
  });
13370
13653
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
13371
- var ConfigProfileSetInputSchema = import_zod20.z.strictObject({
13372
- name: import_zod20.z.string().min(1),
13373
- category: import_zod20.z.record(import_zod20.z.string(), import_zod20.z.boolean()).optional(),
13374
- entry: import_zod20.z.record(import_zod20.z.string(), import_zod20.z.boolean()).optional(),
13375
- extends: import_zod20.z.union([import_zod20.z.array(import_zod20.z.string().min(1)), import_zod20.z.literal(false)]).optional(),
13376
- description: import_zod20.z.union([import_zod20.z.string(), import_zod20.z.literal(false)]).optional(),
13377
- launch: import_zod20.z.strictObject({
13378
- skipPermissions: import_zod20.z.boolean().optional(),
13379
- remoteControl: import_zod20.z.boolean().optional(),
13380
- headroom: import_zod20.z.boolean().optional(),
13381
- trackUsage: import_zod20.z.boolean().optional(),
13382
- provider: import_zod20.z.union([import_zod20.z.string().min(1), import_zod20.z.literal(false)]).optional(),
13383
- claudeVersion: import_zod20.z.union([import_zod20.z.string().min(1), import_zod20.z.literal(false)]).optional()
13654
+ var ConfigProfileSetInputSchema = import_zod21.z.strictObject({
13655
+ name: import_zod21.z.string().min(1),
13656
+ category: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.boolean()).optional(),
13657
+ entry: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.boolean()).optional(),
13658
+ extends: import_zod21.z.union([import_zod21.z.array(import_zod21.z.string().min(1)), import_zod21.z.literal(false)]).optional(),
13659
+ description: import_zod21.z.union([import_zod21.z.string(), import_zod21.z.literal(false)]).optional(),
13660
+ launch: import_zod21.z.strictObject({
13661
+ skipPermissions: import_zod21.z.boolean().optional(),
13662
+ remoteControl: import_zod21.z.boolean().optional(),
13663
+ headroom: import_zod21.z.boolean().optional(),
13664
+ trackUsage: import_zod21.z.boolean().optional(),
13665
+ provider: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional(),
13666
+ claudeVersion: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional()
13384
13667
  }).optional()
13385
13668
  });
13386
13669
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
13387
- var ConfigProfileRemoveInputSchema = import_zod20.z.strictObject({ name: import_zod20.z.string().min(1), confirm: RemovalConfirmationSchema });
13670
+ var ConfigProfileRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
13388
13671
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
13389
13672
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
13390
- var PoolMembersInputSchema = import_zod20.z.array(import_zod20.z.string().min(1)).min(1);
13391
- var ConfigPoolAddInputSchema = import_zod20.z.strictObject({
13392
- name: import_zod20.z.string().min(1),
13673
+ var PoolMembersInputSchema = import_zod21.z.array(import_zod21.z.string().min(1)).min(1);
13674
+ var ConfigPoolAddInputSchema = import_zod21.z.strictObject({
13675
+ name: import_zod21.z.string().min(1),
13393
13676
  identities: PoolMembersInputSchema,
13394
- preference: import_zod20.z.enum(POOL_PREFERENCES).optional()
13677
+ preference: import_zod21.z.enum(POOL_PREFERENCES).optional()
13395
13678
  });
13396
13679
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
13397
- var ConfigPoolSetInputSchema = import_zod20.z.strictObject({
13398
- name: import_zod20.z.string().min(1),
13680
+ var ConfigPoolSetInputSchema = import_zod21.z.strictObject({
13681
+ name: import_zod21.z.string().min(1),
13399
13682
  identities: PoolMembersInputSchema.optional(),
13400
- preference: import_zod20.z.union([import_zod20.z.enum(POOL_PREFERENCES), import_zod20.z.literal(false)]).optional()
13683
+ preference: import_zod21.z.union([import_zod21.z.enum(POOL_PREFERENCES), import_zod21.z.literal(false)]).optional()
13401
13684
  });
13402
13685
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
13403
- var ConfigPoolRemoveInputSchema = import_zod20.z.strictObject({ name: import_zod20.z.string().min(1), confirm: RemovalConfirmationSchema });
13686
+ var ConfigPoolRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
13404
13687
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
13405
13688
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
13406
- var ConfigProviderAddInputSchema = import_zod20.z.strictObject({
13407
- name: import_zod20.z.string().min(1),
13408
- kind: import_zod20.z.enum(PROVIDER_KINDS).optional(),
13409
- displayName: import_zod20.z.string().min(1),
13410
- baseUrl: import_zod20.z.string().min(1).optional(),
13689
+ var ConfigProviderAddInputSchema = import_zod21.z.strictObject({
13690
+ name: import_zod21.z.string().min(1),
13691
+ kind: import_zod21.z.enum(PROVIDER_KINDS).optional(),
13692
+ displayName: import_zod21.z.string().min(1),
13693
+ baseUrl: import_zod21.z.string().min(1).optional(),
13411
13694
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
13412
13695
  codex: CodexProviderConfigSchema.optional()
13413
13696
  });
13414
13697
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
13415
- var ConfigProviderSetInputSchema = import_zod20.z.strictObject({
13416
- name: import_zod20.z.string().min(1),
13417
- displayName: import_zod20.z.string().min(1).optional(),
13418
- baseUrl: import_zod20.z.string().min(1).optional(),
13698
+ var ConfigProviderSetInputSchema = import_zod21.z.strictObject({
13699
+ name: import_zod21.z.string().min(1),
13700
+ displayName: import_zod21.z.string().min(1).optional(),
13701
+ baseUrl: import_zod21.z.string().min(1).optional(),
13419
13702
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
13420
13703
  codex: CodexProviderConfigSchema.optional()
13421
13704
  });
13422
13705
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
13423
- var ConfigProviderRemoveInputSchema = import_zod20.z.strictObject({ name: import_zod20.z.string().min(1), confirm: RemovalConfirmationSchema });
13706
+ var ConfigProviderRemoveInputSchema = import_zod21.z.strictObject({ name: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
13424
13707
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
13425
- var ConfigRuleAddInputSchema = import_zod20.z.strictObject({
13426
- path: import_zod20.z.string().min(1),
13427
- configProfile: import_zod20.z.string().min(1).optional(),
13428
- identity: import_zod20.z.string().min(1).optional()
13708
+ var ConfigRuleAddInputSchema = import_zod21.z.strictObject({
13709
+ path: import_zod21.z.string().min(1),
13710
+ configProfile: import_zod21.z.string().min(1).optional(),
13711
+ identity: import_zod21.z.string().min(1).optional()
13429
13712
  });
13430
13713
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
13431
- var ConfigRuleSetInputSchema = import_zod20.z.strictObject({
13432
- path: import_zod20.z.string().min(1),
13433
- configProfile: import_zod20.z.union([import_zod20.z.string().min(1), import_zod20.z.literal(false)]).optional(),
13434
- identity: import_zod20.z.union([import_zod20.z.string().min(1), import_zod20.z.literal(false)]).optional()
13714
+ var ConfigRuleSetInputSchema = import_zod21.z.strictObject({
13715
+ path: import_zod21.z.string().min(1),
13716
+ configProfile: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional(),
13717
+ identity: import_zod21.z.union([import_zod21.z.string().min(1), import_zod21.z.literal(false)]).optional()
13435
13718
  });
13436
13719
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
13437
- var ConfigRuleRemoveInputSchema = import_zod20.z.strictObject({ path: import_zod20.z.string().min(1), confirm: RemovalConfirmationSchema });
13720
+ var ConfigRuleRemoveInputSchema = import_zod21.z.strictObject({ path: import_zod21.z.string().min(1), confirm: RemovalConfirmationSchema });
13438
13721
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
13439
13722
 
13440
13723
  // src/frontdoor/configApi.ts
@@ -13498,7 +13781,7 @@ function profileValue(name, paths) {
13498
13781
  function createConfigApiRouter(deps) {
13499
13782
  const authed = doorApiAuth(deps.expectedToken);
13500
13783
  const { paths } = deps;
13501
- const route = (path36, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path36, summary, tags: [CONFIG_API_TAG] }));
13784
+ const route = (path37, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path37, summary, tags: [CONFIG_API_TAG] }));
13502
13785
  return {
13503
13786
  config: {
13504
13787
  identity: {
@@ -13740,41 +14023,41 @@ var import_openapi4 = require("@orpc/openapi");
13740
14023
  var import_server3 = require("@orpc/server");
13741
14024
 
13742
14025
  // src/frontdoor/eventSchemas.ts
13743
- var import_zod21 = require("zod");
14026
+ var import_zod22 = require("zod");
13744
14027
  var DOOR_EVENT_SOURCE_RC = "rc";
13745
14028
  var LAUNCH_EVENT_SOURCE = "launch";
13746
14029
  var USAGE_EVENT_SOURCE = "usage";
13747
14030
  var DOOR_HEALTH_EVENT_SOURCE = "door";
13748
14031
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
13749
- var DoorEventSchema = import_zod21.z.strictObject({
13750
- source: import_zod21.z.string().min(1),
14032
+ var DoorEventSchema = import_zod22.z.strictObject({
14033
+ source: import_zod22.z.string().min(1),
13751
14034
  /** A positive integer because the backbone's counters start at one and only ever increase. */
13752
- sequence: import_zod21.z.number().int().positive(),
13753
- payload: import_zod21.z.unknown()
14035
+ sequence: import_zod22.z.number().int().positive(),
14036
+ payload: import_zod22.z.unknown()
13754
14037
  });
13755
- var DoorEventSourceQuerySchema = import_zod21.z.strictObject({
13756
- sources: import_zod21.z.array(import_zod21.z.string().min(1)).min(1).optional()
14038
+ var DoorEventSourceQuerySchema = import_zod22.z.strictObject({
14039
+ sources: import_zod22.z.array(import_zod22.z.string().min(1)).min(1).optional()
13757
14040
  });
13758
- var LaunchLifecycleEventSchema = import_zod21.z.strictObject({
13759
- kind: import_zod21.z.enum(["registered", "pruned", "ended"]),
13760
- pid: import_zod21.z.number().int().positive(),
13761
- startedAt: import_zod21.z.number(),
13762
- observedAt: import_zod21.z.number()
14041
+ var LaunchLifecycleEventSchema = import_zod22.z.strictObject({
14042
+ kind: import_zod22.z.enum(["registered", "pruned", "ended"]),
14043
+ pid: import_zod22.z.number().int().positive(),
14044
+ startedAt: import_zod22.z.number(),
14045
+ observedAt: import_zod22.z.number()
13763
14046
  });
13764
- var DoorHealthEventSchema = import_zod21.z.discriminatedUnion("kind", [
13765
- import_zod21.z.strictObject({ kind: import_zod21.z.literal("generation"), pid: import_zod21.z.number().int().positive(), providerPort: import_zod21.z.number().int().positive(), connectPort: import_zod21.z.number().int().positive(), directPort: import_zod21.z.number().int().positive(), observedAt: import_zod21.z.number() }),
13766
- import_zod21.z.strictObject({ kind: import_zod21.z.literal("listenerFailed"), pid: import_zod21.z.number().int().positive(), listener: import_zod21.z.enum(["provider", "connect", "direct"]), message: import_zod21.z.string(), observedAt: import_zod21.z.number() }),
13767
- import_zod21.z.strictObject({ kind: import_zod21.z.literal("binaryTurnover"), pid: import_zod21.z.number().int().positive(), observedAt: import_zod21.z.number() }),
13768
- import_zod21.z.strictObject({ kind: import_zod21.z.literal("idleShutdown"), pid: import_zod21.z.number().int().positive(), observedAt: import_zod21.z.number() })
14047
+ var DoorHealthEventSchema = import_zod22.z.discriminatedUnion("kind", [
14048
+ import_zod22.z.strictObject({ kind: import_zod22.z.literal("generation"), pid: import_zod22.z.number().int().positive(), providerPort: import_zod22.z.number().int().positive(), connectPort: import_zod22.z.number().int().positive(), directPort: import_zod22.z.number().int().positive(), observedAt: import_zod22.z.number() }),
14049
+ import_zod22.z.strictObject({ kind: import_zod22.z.literal("listenerFailed"), pid: import_zod22.z.number().int().positive(), listener: import_zod22.z.enum(["provider", "connect", "direct"]), message: import_zod22.z.string(), observedAt: import_zod22.z.number() }),
14050
+ import_zod22.z.strictObject({ kind: import_zod22.z.literal("binaryTurnover"), pid: import_zod22.z.number().int().positive(), observedAt: import_zod22.z.number() }),
14051
+ import_zod22.z.strictObject({ kind: import_zod22.z.literal("idleShutdown"), pid: import_zod22.z.number().int().positive(), observedAt: import_zod22.z.number() })
13769
14052
  ]);
13770
- var QuotaExpiringEventSchema = import_zod21.z.strictObject({
13771
- identity: import_zod21.z.string().min(1),
13772
- provider: import_zod21.z.string().min(1),
13773
- window: import_zod21.z.enum(["fiveHour", "sevenDay"]),
14053
+ var QuotaExpiringEventSchema = import_zod22.z.strictObject({
14054
+ identity: import_zod22.z.string().min(1),
14055
+ provider: import_zod22.z.string().min(1),
14056
+ window: import_zod22.z.enum(["fiveHour", "sevenDay"]),
13774
14057
  /** 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. */
13775
- utilization: import_zod21.z.number().min(0).max(1),
13776
- resetsAt: import_zod21.z.iso.datetime(),
13777
- observedAt: import_zod21.z.number()
14058
+ utilization: import_zod22.z.number().min(0).max(1),
14059
+ resetsAt: import_zod22.z.iso.datetime(),
14060
+ observedAt: import_zod22.z.number()
13778
14061
  });
13779
14062
 
13780
14063
  // src/frontdoor/eventsApi.ts
@@ -13857,52 +14140,52 @@ var import_openapi6 = require("@orpc/openapi");
13857
14140
  init_cliError();
13858
14141
 
13859
14142
  // src/frontdoor/launchSchemas.ts
13860
- var import_node_path30 = __toESM(require("node:path"), 1);
13861
- var import_zod22 = require("zod");
14143
+ var import_node_path31 = __toESM(require("node:path"), 1);
14144
+ var import_zod23 = require("zod");
13862
14145
  init_claudeVersion();
13863
14146
  init_identity();
13864
- var LaunchResolveInputSchema = import_zod22.z.strictObject({
13865
- path: import_zod22.z.string().min(1),
14147
+ var LaunchResolveInputSchema = import_zod23.z.strictObject({
14148
+ path: import_zod23.z.string().min(1),
13866
14149
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
13867
- argv: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.string())).optional(),
14150
+ argv: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())).optional(),
13868
14151
  /** 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. */
13869
- env: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).optional()
13870
- }).refine((input) => import_node_path30.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
13871
- var LaunchPoolDecisionSchema = import_zod22.z.strictObject({
13872
- name: import_zod22.z.string(),
13873
- reasons: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.string())),
13874
- movedOff: import_zod22.z.strictObject({ identity: import_zod22.z.string(), reason: import_zod22.z.string() }).optional()
14152
+ env: import_zod23.z.record(import_zod23.z.string(), import_zod23.z.string()).optional()
14153
+ }).refine((input) => import_node_path31.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
14154
+ var LaunchPoolDecisionSchema = import_zod23.z.strictObject({
14155
+ name: import_zod23.z.string(),
14156
+ reasons: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())),
14157
+ movedOff: import_zod23.z.strictObject({ identity: import_zod23.z.string(), reason: import_zod23.z.string() }).optional()
13875
14158
  });
13876
- var LaunchDecisionSchema = import_zod22.z.strictObject({
13877
- identity: import_zod22.z.string().optional(),
13878
- identitySource: import_zod22.z.enum(IDENTITY_DECISION_SOURCES),
14159
+ var LaunchDecisionSchema = import_zod23.z.strictObject({
14160
+ identity: import_zod23.z.string().optional(),
14161
+ identitySource: import_zod23.z.enum(IDENTITY_DECISION_SOURCES),
13879
14162
  pool: LaunchPoolDecisionSchema.optional(),
13880
- configDirEscapeHatch: import_zod22.z.boolean(),
13881
- configDir: import_zod22.z.string().optional(),
13882
- configProfile: import_zod22.z.string().optional(),
13883
- configProfileSource: import_zod22.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
13884
- provider: import_zod22.z.string().optional()
14163
+ configDirEscapeHatch: import_zod23.z.boolean(),
14164
+ configDir: import_zod23.z.string().optional(),
14165
+ configProfile: import_zod23.z.string().optional(),
14166
+ configProfileSource: import_zod23.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
14167
+ provider: import_zod23.z.string().optional()
13885
14168
  });
13886
- var LaunchFlagsSchema = import_zod22.z.strictObject({
13887
- skipPermissions: import_zod22.z.boolean(),
13888
- remoteControl: import_zod22.z.boolean(),
13889
- headroom: import_zod22.z.boolean(),
13890
- trackUsage: import_zod22.z.boolean()
14169
+ var LaunchFlagsSchema = import_zod23.z.strictObject({
14170
+ skipPermissions: import_zod23.z.boolean(),
14171
+ remoteControl: import_zod23.z.boolean(),
14172
+ headroom: import_zod23.z.boolean(),
14173
+ trackUsage: import_zod23.z.boolean()
13891
14174
  });
13892
- var LaunchResolveOutputSchema = import_zod22.z.strictObject({
14175
+ var LaunchResolveOutputSchema = import_zod23.z.strictObject({
13893
14176
  decision: LaunchDecisionSchema,
13894
14177
  flags: LaunchFlagsSchema,
13895
- claudeVersion: import_zod22.z.strictObject({ version: import_zod22.z.string(), source: import_zod22.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
14178
+ claudeVersion: import_zod23.z.strictObject({ version: import_zod23.z.string(), source: import_zod23.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
13896
14179
  /** The real `claude` binary the launch would spawn, on the door's host. */
13897
- bin: import_zod22.z.string(),
14180
+ bin: import_zod23.z.string(),
13898
14181
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
13899
- args: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.string())),
14182
+ args: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())),
13900
14183
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
13901
- credential: import_zod22.z.strictObject({ subject: import_zod22.z.enum(["provider", "identity"]), name: import_zod22.z.string(), summary: CredentialSummarySchema }).optional(),
13902
- routing: import_zod22.z.strictObject({ frontDoor: import_zod22.z.boolean(), headroom: import_zod22.z.boolean() }),
14184
+ credential: import_zod23.z.strictObject({ subject: import_zod23.z.enum(["provider", "identity"]), name: import_zod23.z.string(), summary: CredentialSummarySchema }).optional(),
14185
+ routing: import_zod23.z.strictObject({ frontDoor: import_zod23.z.boolean(), headroom: import_zod23.z.boolean() }),
13903
14186
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
13904
- environment: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.string())),
13905
- warnings: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.string()))
14187
+ environment: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string())),
14188
+ warnings: import_zod23.z.readonly(import_zod23.z.array(import_zod23.z.string()))
13906
14189
  });
13907
14190
 
13908
14191
  // src/frontdoor/launchApi.ts
@@ -15962,9 +16245,9 @@ data: ${JSON.stringify(envelope)}
15962
16245
  }
15963
16246
 
15964
16247
  // src/frontdoor/rcSelfHostMint.ts
15965
- var import_node_path31 = __toESM(require("node:path"), 1);
16248
+ var import_node_path32 = __toESM(require("node:path"), 1);
15966
16249
  init_account();
15967
- var CREDENTIALS_FILE = ".credentials.json";
16250
+ var CREDENTIALS_FILE2 = ".credentials.json";
15968
16251
  var CLAUDE_JSON2 = ".claude.json";
15969
16252
  var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
15970
16253
  var RC_SELF_HOST_RECORD_FILE = "credential.json";
@@ -15987,7 +16270,7 @@ function readJsonObject(fs12, file) {
15987
16270
  return isRecord11(parsed) ? parsed : void 0;
15988
16271
  }
15989
16272
  function readRcSelfHostRecord(fs12, frontdoorDir) {
15990
- const parsed = readJsonObject(fs12, import_node_path31.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
16273
+ const parsed = readJsonObject(fs12, import_node_path32.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
15991
16274
  if (parsed === void 0) {
15992
16275
  return void 0;
15993
16276
  }
@@ -16001,11 +16284,11 @@ function mintRcSelfHostCredential(deps) {
16001
16284
  if (!isIdentityName(deps.identity)) {
16002
16285
  throw new Error(`"${deps.identity}" is not a valid identity name.`);
16003
16286
  }
16004
- const identityDir = import_node_path31.default.join(deps.identitiesDir, deps.identity);
16005
- const credentialsFile = import_node_path31.default.join(identityDir, CREDENTIALS_FILE);
16006
- const claudeJsonFile = import_node_path31.default.join(identityDir, CLAUDE_JSON2);
16007
- const recordDir = import_node_path31.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
16008
- const recordFile = import_node_path31.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
16287
+ const identityDir = import_node_path32.default.join(deps.identitiesDir, deps.identity);
16288
+ const credentialsFile = import_node_path32.default.join(identityDir, CREDENTIALS_FILE2);
16289
+ const claudeJsonFile = import_node_path32.default.join(identityDir, CLAUDE_JSON2);
16290
+ const recordDir = import_node_path32.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
16291
+ const recordFile = import_node_path32.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
16009
16292
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
16010
16293
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
16011
16294
  const existingOauth = isRecord11(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
@@ -16021,7 +16304,7 @@ function mintRcSelfHostCredential(deps) {
16021
16304
  const organizationUuid = deps.newUuid();
16022
16305
  const accountUuid = deps.newUuid();
16023
16306
  const mintedAt = new Date(deps.now()).toISOString();
16024
- deps.fs.mkdirPrivate(import_node_path31.default.dirname(credentialsFile));
16307
+ deps.fs.mkdirPrivate(import_node_path32.default.dirname(credentialsFile));
16025
16308
  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)}
16026
16309
  `);
16027
16310
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
@@ -16170,6 +16453,8 @@ init_ownCli();
16170
16453
  0 && (module.exports = {
16171
16454
  AMBIENT_CREDENTIAL_VARS,
16172
16455
  CHECK_CREDENTIAL_APPLIES,
16456
+ CODEX_APP_SERVER_GENERATED_AGAINST,
16457
+ CODEX_APP_SERVER_TIMEOUT_MS,
16173
16458
  CONNECT_INTERCEPT_HOST,
16174
16459
  CONNECT_INTERCEPT_HOSTS,
16175
16460
  CONNECT_LIMITS,
@@ -16180,7 +16465,12 @@ init_ownCli();
16180
16465
  CheckReportJsonSchema,
16181
16466
  CheckRunInputSchema,
16182
16467
  CliError,
16468
+ CodexAccountReadSchema,
16469
+ CodexAppServerProtocolError,
16470
+ CodexAppServerRequestError,
16471
+ CodexAppServerUnavailableError,
16183
16472
  CodexLogoutOutputSchema,
16473
+ CodexRateLimitsReadSchema,
16184
16474
  CodexSignInSchema,
16185
16475
  CodexStatusOutputSchema,
16186
16476
  ConfigIdentityAddOutputSchema,
@@ -16438,6 +16728,8 @@ init_ownCli();
16438
16728
  rcSelfHostFromEnv,
16439
16729
  rcWebFetchAllowsPrivateFromEnv,
16440
16730
  readActiveIdentity,
16731
+ readCodexAccount,
16732
+ readCodexRateLimits,
16441
16733
  readDirectoryRules,
16442
16734
  readFarmManifest,
16443
16735
  readFrontDoorControlMaterial,
@@ -16449,6 +16741,7 @@ init_ownCli();
16449
16741
  readRcSelfHostRecord,
16450
16742
  readRcSessionFile,
16451
16743
  readUsageSnapshot,
16744
+ realCodexAppServerPort,
16452
16745
  realConnectCertStore,
16453
16746
  realConnectEffects,
16454
16747
  realRcControlTransport,