claude-use 11.89.0 → 11.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -7268,30 +7268,30 @@ var init_state2 = __esm({
7268
7268
  });
7269
7269
 
7270
7270
  // src/headroom/earlierRelease.ts
7271
- function withoutOurSocket(commandLine, socketPath) {
7271
+ function withoutOurSocket(commandLine2, socketPath) {
7272
7272
  for (const argument of [`--uds ${socketPath}`, `--uds=${socketPath}`]) {
7273
7273
  let from = 0;
7274
7274
  for (; ; ) {
7275
- const index = commandLine.indexOf(argument, from);
7275
+ const index = commandLine2.indexOf(argument, from);
7276
7276
  if (index === -1) {
7277
7277
  break;
7278
7278
  }
7279
7279
  const end = index + argument.length;
7280
- const startsArgument = index === 0 || /\s/.test(commandLine.charAt(index - 1));
7281
- const endsArgument = end === commandLine.length || /\s/.test(commandLine.charAt(end));
7280
+ const startsArgument = index === 0 || /\s/.test(commandLine2.charAt(index - 1));
7281
+ const endsArgument = end === commandLine2.length || /\s/.test(commandLine2.charAt(end));
7282
7282
  if (startsArgument && endsArgument) {
7283
- return `${commandLine.slice(0, index)} ${commandLine.slice(end)}`;
7283
+ return `${commandLine2.slice(0, index)} ${commandLine2.slice(end)}`;
7284
7284
  }
7285
7285
  from = index + 1;
7286
7286
  }
7287
7287
  }
7288
7288
  return void 0;
7289
7289
  }
7290
- function daemonIdentity(commandLine, socketPath) {
7291
- if (commandLine === void 0) {
7290
+ function daemonIdentity(commandLine2, socketPath) {
7291
+ if (commandLine2 === void 0) {
7292
7292
  return "unreadable";
7293
7293
  }
7294
- const rest = withoutOurSocket(commandLine, socketPath);
7294
+ const rest = withoutOurSocket(commandLine2, socketPath);
7295
7295
  const argumentsList = rest === void 0 ? [] : rest.trim().split(/\s+/);
7296
7296
  if (rest === void 0 || !argumentsList.includes("proxy")) {
7297
7297
  return "not-headroom";
@@ -7390,8 +7390,8 @@ function ensureHeadroom(params) {
7390
7390
  writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
7391
7391
  return { socketPath: state.socketPath };
7392
7392
  }
7393
- const commandLine = commandLineOf(state.headroomPid);
7394
- const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine, socketPath: state.socketPath, recordedHash: state.allowlistHash });
7393
+ const commandLine2 = commandLineOf(state.headroomPid);
7394
+ const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine: commandLine2, socketPath: state.socketPath, recordedHash: state.allowlistHash });
7395
7395
  if (earlierRelease !== void 0) {
7396
7396
  if (earlierRelease.admitsServingDoor) {
7397
7397
  writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
@@ -7401,7 +7401,7 @@ function ensureHeadroom(params) {
7401
7401
  `the running headroom daemon (pid ${String(state.headroomPid)}) was ${EARLIER_RELEASE_ALLOWLIST}, and its allowlist cannot be shown to admit the serving front door; launch with --no-headroom until then. Supervisor and daemon log: ${paths.headroomLogPath}`
7402
7402
  );
7403
7403
  }
7404
- awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine, state.socketPath) };
7404
+ awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine2, state.socketPath) };
7405
7405
  }
7406
7406
  if (state.lastError !== void 0) {
7407
7407
  throw new HeadroomStartError(
@@ -9211,6 +9211,9 @@ function assessIdentity(member, nowMs) {
9211
9211
  const state = member.snapshot?.providers[ANTHROPIC_PROVIDER];
9212
9212
  const unified = unifiedOf(state);
9213
9213
  if (member.snapshot === void 0 || state === void 0 || unified === void 0) {
9214
+ if (plan.kind === "pay-per-use") {
9215
+ return { candidate: { ...base, class: "pay-per-use", usageUnrecorded: true, reasons: [...planReasons, "no usage recorded yet, so its spend is not tracked (turn on trackUsage for it)"] } };
9216
+ }
9214
9217
  return { candidate: { ...base, class: "unknown", reasons: ["no usage recorded yet, so its quota is unknown (turn on trackUsage for it)", ...planReasons] } };
9215
9218
  }
9216
9219
  const observedAgo = state.rateLimit === void 0 ? "" : ` (last seen ${formatAge(nowMs - Date.parse(state.rateLimit.observedAt))} ago)`;
@@ -9342,7 +9345,7 @@ function rankPool(input) {
9342
9345
  return { ...candidate, feasible: false, runsDryAtMs: nowMs + Math.min(...dryAfterMs), reasons: [...drySpots, ...candidate.reasons] };
9343
9346
  });
9344
9347
  const ordered = input.preference === "listed" ? [...candidates] : [...candidates].sort(
9345
- (left, right) => CLASS_ORDER[left.class] - CLASS_ORDER[right.class] || Number(left.policyDemoted ?? false) - Number(right.policyDemoted ?? false) || Number(right.feasible) - Number(left.feasible) || (right.headroom ?? 1) - (left.headroom ?? 1) || (right.score ?? 0) - (left.score ?? 0) || left.identity.localeCompare(right.identity)
9348
+ (left, right) => CLASS_ORDER[left.class] - CLASS_ORDER[right.class] || Number(left.policyDemoted ?? false) - Number(right.policyDemoted ?? false) || Number(right.feasible) - Number(left.feasible) || Number(left.usageUnrecorded ?? false) - Number(right.usageUnrecorded ?? false) || (right.headroom ?? 1) - (left.headroom ?? 1) || (right.score ?? 0) - (left.score ?? 0) || left.identity.localeCompare(right.identity)
9346
9349
  );
9347
9350
  const sticky = input.sticky;
9348
9351
  const stickyIndex = sticky === void 0 ? -1 : ordered.findIndex((candidate) => candidate.identity === sticky.identity);
@@ -10489,7 +10492,7 @@ var init_package = __esm({
10489
10492
  "package.json"() {
10490
10493
  package_default = {
10491
10494
  name: "claude-use",
10492
- version: "11.89.0",
10495
+ version: "11.90.0",
10493
10496
  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.",
10494
10497
  license: "MIT",
10495
10498
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -10835,7 +10838,7 @@ var init_paths = __esm({
10835
10838
  });
10836
10839
 
10837
10840
  // src/providerAliases.ts
10838
- import { z as z24 } from "zod";
10841
+ import { z as z25 } from "zod";
10839
10842
  function parseAliases(file, raw) {
10840
10843
  const parsed = ProviderAliasesSchema.safeParse(raw);
10841
10844
  if (!parsed.success) {
@@ -10874,7 +10877,7 @@ var init_providerAliases = __esm({
10874
10877
  init_cliError();
10875
10878
  init_load();
10876
10879
  init_store();
10877
- ProviderAliasesSchema = z24.record(z24.string().min(1), z24.string().min(1));
10880
+ ProviderAliasesSchema = z25.record(z25.string().min(1), z25.string().min(1));
10878
10881
  }
10879
10882
  });
10880
10883
 
@@ -11099,14 +11102,14 @@ function requireProviderExists(paths, name) {
11099
11102
  throw new ProviderNotFoundError(name);
11100
11103
  }
11101
11104
  }
11102
- function isRecord7(value) {
11105
+ function isRecord8(value) {
11103
11106
  return typeof value === "object" && value !== null && !Array.isArray(value);
11104
11107
  }
11105
11108
  function legacyProviderConversion(raw) {
11106
- if (!isRecord7(raw) || "credential" in raw) {
11109
+ if (!isRecord8(raw) || "credential" in raw) {
11107
11110
  return void 0;
11108
11111
  }
11109
- const env = isRecord7(raw.env) ? raw.env : void 0;
11112
+ const env = isRecord8(raw.env) ? raw.env : void 0;
11110
11113
  const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
11111
11114
  const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
11112
11115
  if (fields.length === 0) {
@@ -11589,7 +11592,7 @@ var init_headers = __esm({
11589
11592
 
11590
11593
  // src/launcher/injected.ts
11591
11594
  import { createHash as createHash8 } from "node:crypto";
11592
- import { z as z25 } from "zod";
11595
+ import { z as z26 } from "zod";
11593
11596
  function listKey(list) {
11594
11597
  return `${list},appended`;
11595
11598
  }
@@ -11682,7 +11685,7 @@ var init_injected = __esm({
11682
11685
  INJECTED_ENV = "AGENT_SHIM_INJECTED";
11683
11686
  CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
11684
11687
  HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
11685
- InjectedSchema = z25.record(z25.string(), z25.string());
11688
+ InjectedSchema = z26.record(z26.string(), z26.string());
11686
11689
  }
11687
11690
  });
11688
11691
 
@@ -11818,7 +11821,7 @@ var init_commandDeps = __esm({
11818
11821
  // src/claudeShim.ts
11819
11822
  import fs11 from "node:fs";
11820
11823
  import path38 from "node:path";
11821
- import { z as z30 } from "zod";
11824
+ import { z as z31 } from "zod";
11822
11825
  function commandFilename(ownExecutablePath, commandName) {
11823
11826
  return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
11824
11827
  }
@@ -11868,35 +11871,35 @@ var init_claudeShim = __esm({
11868
11871
  init_store();
11869
11872
  init_realPorts();
11870
11873
  init_cliError();
11871
- ClaudeShimStateSchema = z30.strictObject({
11872
- targetPath: z30.string().min(1),
11873
- method: z30.enum(["hardlink", "copy"]),
11874
- installedAtMs: z30.number()
11874
+ ClaudeShimStateSchema = z31.strictObject({
11875
+ targetPath: z31.string().min(1),
11876
+ method: z31.enum(["hardlink", "copy"]),
11877
+ installedAtMs: z31.number()
11875
11878
  });
11876
11879
  nodeLinkFs = { link: fs11.linkSync, copyFile: fs11.copyFileSync, chmod: fs11.chmodSync };
11877
11880
  }
11878
11881
  });
11879
11882
 
11880
11883
  // src/codex/auth.ts
11881
- import { z as z31 } from "zod";
11884
+ import { z as z32 } from "zod";
11882
11885
  var AuthFileSchema, TokenGrantSchema, CodexAuthError;
11883
11886
  var init_auth = __esm({
11884
11887
  "src/codex/auth.ts"() {
11885
11888
  "use strict";
11886
- AuthFileSchema = z31.looseObject({
11887
- tokens: z31.looseObject({
11888
- access_token: z31.string().optional(),
11889
- refresh_token: z31.string().optional(),
11890
- id_token: z31.string().optional(),
11891
- account_id: z31.string().optional()
11889
+ AuthFileSchema = z32.looseObject({
11890
+ tokens: z32.looseObject({
11891
+ access_token: z32.string().optional(),
11892
+ refresh_token: z32.string().optional(),
11893
+ id_token: z32.string().optional(),
11894
+ account_id: z32.string().optional()
11892
11895
  }).nullish(),
11893
- last_refresh: z31.string().optional()
11896
+ last_refresh: z32.string().optional()
11894
11897
  });
11895
- TokenGrantSchema = z31.looseObject({
11896
- access_token: z31.string().min(1).optional(),
11897
- refresh_token: z31.string().min(1).optional(),
11898
- id_token: z31.string().min(1).optional(),
11899
- account_id: z31.string().min(1).optional()
11898
+ TokenGrantSchema = z32.looseObject({
11899
+ access_token: z32.string().min(1).optional(),
11900
+ refresh_token: z32.string().min(1).optional(),
11901
+ id_token: z32.string().min(1).optional(),
11902
+ account_id: z32.string().min(1).optional()
11900
11903
  });
11901
11904
  CodexAuthError = class extends Error {
11902
11905
  constructor(message) {
@@ -11908,7 +11911,7 @@ var init_auth = __esm({
11908
11911
  });
11909
11912
 
11910
11913
  // src/codex/siwc.ts
11911
- import { z as z32 } from "zod";
11914
+ import { z as z33 } from "zod";
11912
11915
  var SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
11913
11916
  var init_siwc = __esm({
11914
11917
  "src/codex/siwc.ts"() {
@@ -11916,28 +11919,28 @@ var init_siwc = __esm({
11916
11919
  SIWC_RESOURCE = "https://api.openai.com/v1";
11917
11920
  SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
11918
11921
  SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
11919
- TokenResponseSchema = z32.looseObject({
11920
- access_token: z32.string().min(1),
11921
- refresh_token: z32.string().min(1).optional(),
11922
- id_token: z32.string().min(1).optional(),
11923
- expires_in: z32.number().positive(),
11924
- scope: z32.string().optional()
11922
+ TokenResponseSchema = z33.looseObject({
11923
+ access_token: z33.string().min(1),
11924
+ refresh_token: z33.string().min(1).optional(),
11925
+ id_token: z33.string().min(1).optional(),
11926
+ expires_in: z33.number().positive(),
11927
+ scope: z33.string().optional()
11925
11928
  });
11926
- JwtHeaderSchema = z32.looseObject({ alg: z32.string(), kid: z32.string().optional() });
11927
- IdTokenClaimsSchema = z32.looseObject({
11928
- iss: z32.string(),
11929
- sub: z32.string().min(1),
11930
- aud: z32.union([z32.string(), z32.array(z32.string())]),
11931
- exp: z32.number(),
11932
- nonce: z32.string().optional(),
11933
- email: z32.string().optional()
11929
+ JwtHeaderSchema = z33.looseObject({ alg: z33.string(), kid: z33.string().optional() });
11930
+ IdTokenClaimsSchema = z33.looseObject({
11931
+ iss: z33.string(),
11932
+ sub: z33.string().min(1),
11933
+ aud: z33.union([z33.string(), z33.array(z33.string())]),
11934
+ exp: z33.number(),
11935
+ nonce: z33.string().optional(),
11936
+ email: z33.string().optional()
11934
11937
  });
11935
- JwksSchema = z32.object({ keys: z32.array(z32.looseObject({ kid: z32.string().optional(), kty: z32.string() })) });
11938
+ JwksSchema = z33.object({ keys: z33.array(z33.looseObject({ kid: z33.string().optional(), kty: z33.string() })) });
11936
11939
  }
11937
11940
  });
11938
11941
 
11939
11942
  // src/codex/siwcStore.ts
11940
- import { z as z33 } from "zod";
11943
+ import { z as z34 } from "zod";
11941
11944
  function parseSiwcFile(raw, filePath) {
11942
11945
  let json;
11943
11946
  try {
@@ -11957,18 +11960,18 @@ var init_siwcStore = __esm({
11957
11960
  "use strict";
11958
11961
  init_auth();
11959
11962
  init_siwc();
11960
- SiwcGrantSchema = z33.strictObject({
11961
- clientId: z33.string().min(1),
11962
- sub: z33.string().min(1),
11963
- email: z33.string().optional(),
11964
- idToken: z33.string().min(1),
11965
- accessToken: z33.string().min(1),
11966
- refreshToken: z33.string().min(1),
11967
- scopes: z33.array(z33.string()).readonly(),
11963
+ SiwcGrantSchema = z34.strictObject({
11964
+ clientId: z34.string().min(1),
11965
+ sub: z34.string().min(1),
11966
+ email: z34.string().optional(),
11967
+ idToken: z34.string().min(1),
11968
+ accessToken: z34.string().min(1),
11969
+ refreshToken: z34.string().min(1),
11970
+ scopes: z34.array(z34.string()).readonly(),
11968
11971
  /** When the access token stops working, in milliseconds since the epoch. */
11969
- expiresAt: z33.number()
11972
+ expiresAt: z34.number()
11970
11973
  });
11971
- SiwcFileSchema = z33.strictObject({ registeredClientId: z33.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
11974
+ SiwcFileSchema = z34.strictObject({ registeredClientId: z34.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
11972
11975
  }
11973
11976
  });
11974
11977
 
@@ -12028,7 +12031,7 @@ var init_modelsStore = __esm({
12028
12031
  // src/codex/catalogueCredential.ts
12029
12032
  import { createHash as createHash9 } from "node:crypto";
12030
12033
  import path41 from "node:path";
12031
- import { z as z34 } from "zod";
12034
+ import { z as z35 } from "zod";
12032
12035
  function parseCatalogueBinding(raw) {
12033
12036
  if (raw === void 0) return void 0;
12034
12037
  try {
@@ -12069,7 +12072,7 @@ var init_catalogueCredential = __esm({
12069
12072
  "src/codex/catalogueCredential.ts"() {
12070
12073
  "use strict";
12071
12074
  init_siwcStore();
12072
- CatalogueBindingSchema = z34.strictObject({ fingerprint: z34.string().min(1), source: z34.string().min(1), revision: z34.string().min(1) });
12075
+ CatalogueBindingSchema = z35.strictObject({ fingerprint: z35.string().min(1), source: z35.string().min(1), revision: z35.string().min(1) });
12073
12076
  }
12074
12077
  });
12075
12078
 
@@ -12120,64 +12123,64 @@ var init_signatures = __esm({
12120
12123
  });
12121
12124
 
12122
12125
  // src/codex/anthropic.ts
12123
- import { z as z35 } from "zod";
12126
+ import { z as z36 } from "zod";
12124
12127
  var TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
12125
12128
  var init_anthropic = __esm({
12126
12129
  "src/codex/anthropic.ts"() {
12127
12130
  "use strict";
12128
- TextBlockSchema = z35.looseObject({ type: z35.literal("text"), text: z35.string() });
12129
- Base64ImageSourceSchema = z35.looseObject({ type: z35.literal("base64"), media_type: z35.string().min(1), data: z35.string() });
12130
- UrlImageSourceSchema = z35.looseObject({ type: z35.literal("url"), url: z35.string().min(1) });
12131
- ImageBlockSchema = z35.looseObject({
12132
- type: z35.literal("image"),
12133
- source: z35.union([Base64ImageSourceSchema, UrlImageSourceSchema])
12131
+ TextBlockSchema = z36.looseObject({ type: z36.literal("text"), text: z36.string() });
12132
+ Base64ImageSourceSchema = z36.looseObject({ type: z36.literal("base64"), media_type: z36.string().min(1), data: z36.string() });
12133
+ UrlImageSourceSchema = z36.looseObject({ type: z36.literal("url"), url: z36.string().min(1) });
12134
+ ImageBlockSchema = z36.looseObject({
12135
+ type: z36.literal("image"),
12136
+ source: z36.union([Base64ImageSourceSchema, UrlImageSourceSchema])
12134
12137
  });
12135
- ToolUseBlockSchema = z35.looseObject({
12136
- type: z35.literal("tool_use"),
12137
- id: z35.string().min(1),
12138
- name: z35.string().min(1),
12139
- input: z35.unknown()
12138
+ ToolUseBlockSchema = z36.looseObject({
12139
+ type: z36.literal("tool_use"),
12140
+ id: z36.string().min(1),
12141
+ name: z36.string().min(1),
12142
+ input: z36.unknown()
12140
12143
  });
12141
- ToolResultContentBlockSchema = z35.union([TextBlockSchema, z35.looseObject({ type: z35.string() })]);
12142
- ToolResultBlockSchema = z35.looseObject({
12143
- type: z35.literal("tool_result"),
12144
- tool_use_id: z35.string().min(1),
12145
- content: z35.union([z35.string(), z35.array(ToolResultContentBlockSchema)]).optional()
12144
+ ToolResultContentBlockSchema = z36.union([TextBlockSchema, z36.looseObject({ type: z36.string() })]);
12145
+ ToolResultBlockSchema = z36.looseObject({
12146
+ type: z36.literal("tool_result"),
12147
+ tool_use_id: z36.string().min(1),
12148
+ content: z36.union([z36.string(), z36.array(ToolResultContentBlockSchema)]).optional()
12146
12149
  });
12147
- OtherBlockSchema = z35.looseObject({ type: z35.string() });
12148
- ContentBlockSchema = z35.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
12149
- MessageSchema = z35.looseObject({
12150
- role: z35.enum(["user", "assistant", "system"]),
12151
- content: z35.union([z35.string(), z35.array(ContentBlockSchema)])
12150
+ OtherBlockSchema = z36.looseObject({ type: z36.string() });
12151
+ ContentBlockSchema = z36.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
12152
+ MessageSchema = z36.looseObject({
12153
+ role: z36.enum(["user", "assistant", "system"]),
12154
+ content: z36.union([z36.string(), z36.array(ContentBlockSchema)])
12152
12155
  });
12153
- ToolSchema = z35.looseObject({
12154
- name: z35.string().min(1),
12155
- description: z35.string().optional(),
12156
- input_schema: z35.record(z35.string(), z35.unknown()).optional(),
12157
- allowed_domains: z35.array(z35.string()).optional(),
12158
- blocked_domains: z35.array(z35.string()).optional()
12156
+ ToolSchema = z36.looseObject({
12157
+ name: z36.string().min(1),
12158
+ description: z36.string().optional(),
12159
+ input_schema: z36.record(z36.string(), z36.unknown()).optional(),
12160
+ allowed_domains: z36.array(z36.string()).optional(),
12161
+ blocked_domains: z36.array(z36.string()).optional()
12159
12162
  });
12160
- ToolChoiceSchema = z35.union([
12161
- z35.looseObject({ type: z35.enum(["auto", "none", "any"]) }),
12162
- z35.looseObject({ type: z35.literal("tool"), name: z35.string().min(1) })
12163
+ ToolChoiceSchema = z36.union([
12164
+ z36.looseObject({ type: z36.enum(["auto", "none", "any"]) }),
12165
+ z36.looseObject({ type: z36.literal("tool"), name: z36.string().min(1) })
12163
12166
  ]);
12164
- SystemSchema = z35.union([z35.string(), z35.array(z35.union([TextBlockSchema, OtherBlockSchema]))]);
12165
- MessagesRequestSchema = z35.looseObject({
12166
- model: z35.string().optional(),
12167
+ SystemSchema = z36.union([z36.string(), z36.array(z36.union([TextBlockSchema, OtherBlockSchema]))]);
12168
+ MessagesRequestSchema = z36.looseObject({
12169
+ model: z36.string().optional(),
12167
12170
  system: SystemSchema.optional(),
12168
- messages: z35.array(MessageSchema),
12169
- tools: z35.array(ToolSchema).optional(),
12171
+ messages: z36.array(MessageSchema),
12172
+ tools: z36.array(ToolSchema).optional(),
12170
12173
  tool_choice: ToolChoiceSchema.optional(),
12171
- stream: z35.boolean().optional(),
12174
+ stream: z36.boolean().optional(),
12172
12175
  /** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
12173
- metadata: z35.looseObject({ user_id: z35.string().optional() }).optional(),
12176
+ metadata: z36.looseObject({ user_id: z36.string().optional() }).optional(),
12174
12177
  /** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
12175
- output_config: z35.looseObject({ effort: z35.string().optional(), format: z35.object({ type: z35.literal("json_schema"), schema: z35.record(z35.string(), z35.unknown()) }).optional() }).optional()
12178
+ output_config: z36.looseObject({ effort: z36.string().optional(), format: z36.object({ type: z36.literal("json_schema"), schema: z36.record(z36.string(), z36.unknown()) }).optional() }).optional()
12176
12179
  });
12177
- CountTokensRequestSchema = z35.looseObject({
12178
- system: z35.unknown().optional(),
12179
- messages: z35.unknown().optional(),
12180
- tools: z35.unknown().optional()
12180
+ CountTokensRequestSchema = z36.looseObject({
12181
+ system: z36.unknown().optional(),
12182
+ messages: z36.unknown().optional(),
12183
+ tools: z36.unknown().optional()
12181
12184
  });
12182
12185
  }
12183
12186
  });
@@ -13531,7 +13534,7 @@ function withLauncherSettings(passthrough, settings) {
13531
13534
  }
13532
13535
  return [...kept, "--settings", settings, ...tail];
13533
13536
  }
13534
- function isRecord15(value) {
13537
+ function isRecord16(value) {
13535
13538
  return typeof value === "object" && value !== null && !Array.isArray(value);
13536
13539
  }
13537
13540
  function mergeSettings(parts) {
@@ -13542,7 +13545,7 @@ function mergeSettings(parts) {
13542
13545
  continue;
13543
13546
  }
13544
13547
  const parsed = JSON.parse(part);
13545
- if (!isRecord15(parsed)) {
13548
+ if (!isRecord16(parsed)) {
13546
13549
  throw new Error("a launch's settings part is not a JSON object");
13547
13550
  }
13548
13551
  for (const [key, value] of Object.entries(parsed)) {
@@ -15224,7 +15227,7 @@ var init_identityClaude = __esm({
15224
15227
  });
15225
15228
 
15226
15229
  // src/usage/providerQuota.ts
15227
- import { z as z44 } from "zod";
15230
+ import { z as z45 } from "zod";
15228
15231
  var MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, 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_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
15229
15232
  var init_providerQuota = __esm({
15230
15233
  "src/usage/providerQuota.ts"() {
@@ -15243,35 +15246,35 @@ var init_providerQuota = __esm({
15243
15246
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
15244
15247
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
15245
15248
  ]);
15246
- ZaiLimitSchema = z44.object({
15247
- type: z44.string(),
15248
- unit: z44.number().int(),
15249
- number: z44.number().int().positive(),
15250
- percentage: z44.number().nonnegative(),
15251
- nextResetTime: z44.number().positive().optional(),
15252
- usage: z44.number().nonnegative().optional(),
15253
- currentValue: z44.number().nonnegative().optional(),
15254
- remaining: z44.number().nonnegative().optional()
15249
+ ZaiLimitSchema = z45.object({
15250
+ type: z45.string(),
15251
+ unit: z45.number().int(),
15252
+ number: z45.number().int().positive(),
15253
+ percentage: z45.number().nonnegative(),
15254
+ nextResetTime: z45.number().positive().optional(),
15255
+ usage: z45.number().nonnegative().optional(),
15256
+ currentValue: z45.number().nonnegative().optional(),
15257
+ remaining: z45.number().nonnegative().optional()
15255
15258
  });
15256
- ZaiResponseSchema = z44.object({
15257
- success: z44.boolean(),
15258
- msg: z44.string().optional(),
15259
- data: z44.object({ level: z44.string().optional(), limits: z44.array(ZaiLimitSchema) })
15259
+ ZaiResponseSchema = z45.object({
15260
+ success: z45.boolean(),
15261
+ msg: z45.string().optional(),
15262
+ data: z45.object({ level: z45.string().optional(), limits: z45.array(ZaiLimitSchema) })
15260
15263
  });
15261
15264
  OPENROUTER_HOST = "openrouter.ai";
15262
15265
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
15263
15266
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
15264
15267
  MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15265
- OpenRouterKeySchema = z44.object({
15266
- data: z44.object({
15267
- limit: z44.number().nonnegative().nullable(),
15268
- limit_remaining: z44.number().nullable(),
15269
- limit_reset: z44.string().nullable(),
15270
- is_free_tier: z44.boolean().optional(),
15271
- free_model_daily_requests: z44.object({ used: z44.number().nonnegative(), limit: z44.number().nonnegative(), remaining: z44.number() }).optional()
15268
+ OpenRouterKeySchema = z45.object({
15269
+ data: z45.object({
15270
+ limit: z45.number().nonnegative().nullable(),
15271
+ limit_remaining: z45.number().nullable(),
15272
+ limit_reset: z45.string().nullable(),
15273
+ is_free_tier: z45.boolean().optional(),
15274
+ free_model_daily_requests: z45.object({ used: z45.number().nonnegative(), limit: z45.number().nonnegative(), remaining: z45.number() }).optional()
15272
15275
  })
15273
15276
  });
15274
- OpenRouterCreditsSchema = z44.object({ data: z44.object({ total_credits: z44.number().nonnegative(), total_usage: z44.number().nonnegative() }) });
15277
+ OpenRouterCreditsSchema = z45.object({ data: z45.object({ total_credits: z45.number().nonnegative(), total_usage: z45.number().nonnegative() }) });
15275
15278
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
15276
15279
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
15277
15280
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
@@ -15279,21 +15282,21 @@ var init_providerQuota = __esm({
15279
15282
  DAYS_PER_WEEK2 = 7;
15280
15283
  FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15281
15284
  WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15282
- AntigravityBucketSchema = z44.object({
15283
- bucketId: z44.string(),
15284
- remainingFraction: z44.number().optional(),
15285
- resetTime: z44.string().optional()
15285
+ AntigravityBucketSchema = z45.object({
15286
+ bucketId: z45.string(),
15287
+ remainingFraction: z45.number().optional(),
15288
+ resetTime: z45.string().optional()
15286
15289
  });
15287
- AntigravitySummarySchema = z44.object({ groups: z44.array(z44.object({ buckets: z44.array(AntigravityBucketSchema) })) });
15288
- GoogleTokenInfoSchema = z44.object({
15289
- email: z44.string().optional(),
15290
- sub: z44.string().optional()
15290
+ AntigravitySummarySchema = z45.object({ groups: z45.array(z45.object({ buckets: z45.array(AntigravityBucketSchema) })) });
15291
+ GoogleTokenInfoSchema = z45.object({
15292
+ email: z45.string().optional(),
15293
+ sub: z45.string().optional()
15291
15294
  });
15292
- AntigravityUserSchema = z44.object({
15295
+ AntigravityUserSchema = z45.object({
15293
15296
  /** The code-assist tier context, which defaults to the free tier for every account. */
15294
- currentTier: z44.object({ name: z44.string().optional(), id: z44.string().optional() }).optional(),
15297
+ currentTier: z45.object({ name: z45.string().optional(), id: z45.string().optional() }).optional(),
15295
15298
  /** The account's paid subscription; absent when the account has none. */
15296
- paidTier: z44.object({ name: z44.string().optional(), id: z44.string().optional() }).optional()
15299
+ paidTier: z45.object({ name: z45.string().optional(), id: z45.string().optional() }).optional()
15297
15300
  });
15298
15301
  }
15299
15302
  });
@@ -15946,9 +15949,11 @@ function createRcSessionTracker(deps) {
15946
15949
  if (id?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
15947
15950
  return void 0;
15948
15951
  }
15952
+ const isClientWrite = method === "POST" && (rest === `${id}/events` || rest === `${id}/teleport-events`);
15953
+ const sessionFacts = isClientWrite ? { ...facts, anthropicClientPlatform: void 0 } : facts;
15949
15954
  const tracked = entries.get(id);
15950
15955
  if (tracked !== void 0) {
15951
- refresh(tracked, facts);
15956
+ refresh(tracked, sessionFacts);
15952
15957
  }
15953
15958
  const bodyKind = method === "POST" && rest === `${id}/worker/events` ? "worker-events" : method === "POST" && rest === `${id}/events` ? "client-events" : method === "POST" && rest === `${id}/worker/heartbeat` ? "heartbeat" : method === "PUT" && rest === `${id}/worker` ? "worker-registration" : void 0;
15954
15959
  let chunks = [];
@@ -16018,7 +16023,7 @@ function createRcSessionTracker(deps) {
16018
16023
  }
16019
16024
  accepted = isSuccessful(status);
16020
16025
  if (accepted && !entries.has(id)) {
16021
- persistCredential(birth(id, facts));
16026
+ persistCredential(birth(id, sessionFacts));
16022
16027
  }
16023
16028
  file();
16024
16029
  },
@@ -17743,6 +17748,11 @@ import { OpenAPIHandler } from "@orpc/openapi/node";
17743
17748
  import { eventIterator, os as os3, withEventMeta } from "@orpc/server";
17744
17749
  import { BodyLimitPlugin, RPCHandler } from "@orpc/server/node";
17745
17750
  import { Agent as Agent3, fetch as undiciFetch } from "undici";
17751
+
17752
+ // src/supervise/compactTimeout.ts
17753
+ var COMPACT_TIMEOUT_MS = 9e5;
17754
+
17755
+ // src/frontdoor/rcApi.ts
17746
17756
  init_capability();
17747
17757
 
17748
17758
  // src/frontdoor/rcSchemas.ts
@@ -17914,6 +17924,438 @@ var RcAnswerOutputSchema = z22.strictObject({
17914
17924
  sequenceNums: z22.readonly(z22.array(z22.number()))
17915
17925
  });
17916
17926
 
17927
+ // src/frontdoor/rcSlashCommandSchemas.ts
17928
+ import { z as z23 } from "zod";
17929
+
17930
+ // src/frontdoor/rcSessionCommands.ts
17931
+ import { setTimeout as sleep } from "node:timers/promises";
17932
+
17933
+ // src/supervise/sessionControl.ts
17934
+ var RESULT_POLL_MS = 250;
17935
+ var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
17936
+
17937
+ // src/frontdoor/rcSelfHostCommands.ts
17938
+ var RC_PERSON_CLIENT_PLATFORM = "web_claude_ai";
17939
+ async function writeRcPersonMessage(deps, sessionId, text) {
17940
+ const credential = deps.credentialOf(sessionId);
17941
+ if (credential === void 0) {
17942
+ return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
17943
+ }
17944
+ if (credential.authorization === void 0) {
17945
+ return noOAuthCredentialResult(sessionId);
17946
+ }
17947
+ const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text)));
17948
+ const bytes = Buffer.byteLength(body, "utf8");
17949
+ if (bytes > CONTROL_BODY_CAP_BYTES) {
17950
+ return { ok: false, message: `the command for session ${sessionId} makes an event write of ${String(bytes)} bytes, over the ${String(CONTROL_BODY_CAP_BYTES)} bytes the door's self-hosted surface reads; shorten its arguments` };
17951
+ }
17952
+ let answer;
17953
+ try {
17954
+ answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders({ ...credential, anthropicClientPlatform: RC_PERSON_CLIENT_PLATFORM }), body);
17955
+ } catch (error) {
17956
+ return { ok: false, message: `the door could not write to its own self-hosted surface for session ${sessionId}: ${error instanceof Error ? error.message : String(error)}` };
17957
+ }
17958
+ const result = rcEventWriteResultFromAnswer(answer);
17959
+ if (result.ok) {
17960
+ deps.noteSequenceNums(sessionId, result.sequenceNums);
17961
+ }
17962
+ return result;
17963
+ }
17964
+ function isRecord7(value) {
17965
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17966
+ }
17967
+ function rcLocalCommandAnswerOf(event, command, args) {
17968
+ const payload = event.envelope.payload;
17969
+ if (!isRecord7(payload) || payload.type !== "assistant" || !isRecord7(payload.local_command_run) || payload.local_command_run.command !== command || payload.local_command_run.args !== args) {
17970
+ return void 0;
17971
+ }
17972
+ const message = payload.message;
17973
+ if (!isRecord7(message) || !Array.isArray(message.content)) {
17974
+ return void 0;
17975
+ }
17976
+ const blocks = message.content;
17977
+ const text = blocks.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
17978
+ const outcome = isRecord7(payload.local_command_outcome) && typeof payload.local_command_outcome.kind === "string" ? payload.local_command_outcome.kind : void 0;
17979
+ return { text, outcome };
17980
+ }
17981
+ function rcManualCompactBoundaryOf(event) {
17982
+ const payload = event.envelope.payload;
17983
+ if (!isRecord7(payload) || payload.type !== "system" || payload.subtype !== "compact_boundary" || !isRecord7(payload.compact_metadata)) {
17984
+ return void 0;
17985
+ }
17986
+ const metadata = payload.compact_metadata;
17987
+ if (metadata.trigger !== "manual" || typeof metadata.pre_tokens !== "number" || typeof metadata.post_tokens !== "number") {
17988
+ return void 0;
17989
+ }
17990
+ return { trigger: metadata.trigger, preTokens: metadata.pre_tokens, postTokens: metadata.post_tokens };
17991
+ }
17992
+ function isPeerDelivery(event, text) {
17993
+ const payload = event.envelope.payload;
17994
+ if (!isRecord7(payload) || payload.type !== "user" || !isRecord7(payload.origin) || payload.origin.kind !== "peer" || !isRecord7(payload.message)) {
17995
+ return false;
17996
+ }
17997
+ return typeof payload.message.content === "string" && payload.message.content.includes(text);
17998
+ }
17999
+ var NO_GOAL_PREFIX = "No goal set";
18000
+ var ACTIVE_GOAL_PATTERN = /^Goal active: (?<condition>[\s\S]*?) \((?:not yet evaluated|(?<iterations>\d+) turns?)\)(?:\nLast check: (?<lastCheck>[\s\S]*))?$/u;
18001
+ function parseRcGoalOutput(output) {
18002
+ if (output.startsWith(NO_GOAL_PREFIX)) {
18003
+ return { goal: null };
18004
+ }
18005
+ const groups = ACTIVE_GOAL_PATTERN.exec(output)?.groups;
18006
+ const condition = groups?.condition;
18007
+ if (condition === void 0) {
18008
+ return void 0;
18009
+ }
18010
+ return { goal: { condition, iterations: groups?.iterations === void 0 ? 0 : Number(groups.iterations), ...groups?.lastCheck === void 0 ? {} : { lastCheck: groups.lastCheck } } };
18011
+ }
18012
+ var GOAL_CLEARED_PREFIX = "Goal cleared: ";
18013
+ var GOAL_SET_PREFIX = "Goal set: ";
18014
+ function commandLine(command) {
18015
+ if (command.kind === "goal-set") {
18016
+ return { name: "goal", args: command.condition };
18017
+ }
18018
+ if (command.kind === "compact") {
18019
+ return { name: "compact", args: command.instructions ?? "" };
18020
+ }
18021
+ return { name: "goal", args: command.kind === "goal-clear" ? "clear" : "" };
18022
+ }
18023
+ function recognise(command, event, name, args) {
18024
+ if (command.kind === "compact") {
18025
+ const boundary = rcManualCompactBoundaryOf(event);
18026
+ if (boundary !== void 0) {
18027
+ return { ok: true, report: boundary };
18028
+ }
18029
+ }
18030
+ const answer = rcLocalCommandAnswerOf(event, name, args);
18031
+ if (answer === void 0) {
18032
+ return void 0;
18033
+ }
18034
+ if (answer.outcome === "failed") {
18035
+ return { ok: false, message: `the worker reported /${name} failed: ${answer.text}` };
18036
+ }
18037
+ if (command.kind === "goal-get") {
18038
+ const report = parseRcGoalOutput(answer.text);
18039
+ return report === void 0 ? { ok: false, message: `the worker answered /goal with text the verified versions never produce: ${answer.text}` } : { ok: true, report };
18040
+ }
18041
+ if (command.kind === "goal-set") {
18042
+ return answer.text.startsWith(GOAL_SET_PREFIX) ? { ok: true, report: { condition: answer.text.slice(GOAL_SET_PREFIX.length) } } : { ok: false, message: `the worker did not set the goal: ${answer.text}` };
18043
+ }
18044
+ if (command.kind === "goal-clear") {
18045
+ if (answer.text.startsWith(GOAL_CLEARED_PREFIX)) {
18046
+ return { ok: true, report: { cleared: answer.text.slice(GOAL_CLEARED_PREFIX.length) } };
18047
+ }
18048
+ return answer.text === NO_GOAL_PREFIX ? { ok: true, report: { cleared: null } } : { ok: false, message: `the worker answered /goal clear with text the verified versions never produce: ${answer.text}` };
18049
+ }
18050
+ return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
18051
+ }
18052
+ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
18053
+ const { name, args } = commandLine(command);
18054
+ const text = args === "" ? `/${name}` : `/${name} ${args}`;
18055
+ const early = [];
18056
+ let after;
18057
+ let settle;
18058
+ const judge = (event) => {
18059
+ if (after === void 0) {
18060
+ early.push(event);
18061
+ return;
18062
+ }
18063
+ if (event.envelope.sequence_num <= after || event.envelope.source !== "worker") {
18064
+ return;
18065
+ }
18066
+ if (isPeerDelivery(event, text)) {
18067
+ settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message instead of running it, so it did not read the write as a person's` });
18068
+ return;
18069
+ }
18070
+ const outcome = recognise(command, event, name, args);
18071
+ if (outcome !== void 0) {
18072
+ settle?.(outcome);
18073
+ }
18074
+ };
18075
+ const detach = deps.fanout.subscribe(sessionId, judge);
18076
+ let cancelTimer;
18077
+ const onAbort = () => {
18078
+ settle?.({ ok: false, message: `the request for ${text} on session ${sessionId} was aborted before the worker answered` });
18079
+ };
18080
+ signal.addEventListener("abort", onAbort, { once: true });
18081
+ try {
18082
+ const answered = new Promise((resolve) => {
18083
+ settle = resolve;
18084
+ });
18085
+ const written = await writeRcPersonMessage(deps.personWrite, sessionId, text);
18086
+ if (!written.ok) {
18087
+ return written;
18088
+ }
18089
+ if (signal.aborted) {
18090
+ return { ok: false, message: `the request for ${text} on session ${sessionId} was aborted after it was written (sequence_num ${written.sequenceNums.join(", ")})` };
18091
+ }
18092
+ after = Math.max(...written.sequenceNums);
18093
+ const bound = waitMs ?? deps.defaultWaitMs;
18094
+ cancelTimer = deps.setTimer(() => {
18095
+ settle?.({ ok: false, message: `${text} was delivered to session ${sessionId} (sequence_num ${written.sequenceNums.join(", ")}) but the worker reported no outcome within ${String(bound)} ms; it may still be queued behind a running turn, so read the session's stream before sending it again` });
18096
+ }, bound);
18097
+ for (const event of early.splice(0)) {
18098
+ judge(event);
18099
+ }
18100
+ return await answered;
18101
+ } finally {
18102
+ signal.removeEventListener("abort", onAbort);
18103
+ cancelTimer?.();
18104
+ detach();
18105
+ }
18106
+ }
18107
+ function createRcClaudeCodeVersions(fanout) {
18108
+ const versions = /* @__PURE__ */ new Map();
18109
+ fanout.subscribe(void 0, (event) => {
18110
+ const payload = event.envelope.payload;
18111
+ if (event.envelope.source === "worker" && isRecord7(payload) && payload.type === "system" && payload.subtype === "init" && typeof payload.claude_code_version === "string") {
18112
+ versions.set(event.session, payload.claude_code_version);
18113
+ }
18114
+ });
18115
+ return {
18116
+ versionOf: (sessionId) => versions.get(sessionId),
18117
+ sweep: (isTracked) => {
18118
+ for (const sessionId of [...versions.keys()]) {
18119
+ if (!isTracked(sessionId)) {
18120
+ versions.delete(sessionId);
18121
+ }
18122
+ }
18123
+ }
18124
+ };
18125
+ }
18126
+
18127
+ // src/frontdoor/rcSessionCommands.ts
18128
+ var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
18129
+ var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
18130
+ var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
18131
+ var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
18132
+ var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
18133
+ var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
18134
+ function unverifiedVersionMessage(sessionId, version, source) {
18135
+ const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
18136
+ return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal and compaction control is verified only on Claude Code ${verified}` : `session ${sessionId} runs Claude Code ${version}, and goal and compaction control is verified only on Claude Code ${verified}: the door will not act on a version whose behaviour it has not verified`;
18137
+ }
18138
+ function unsupportedMessage(sessionId) {
18139
+ return `session ${sessionId} was not launched under an agent-shim supervisor, so the door has no in-process channel into it, and it is not on the door's own self-hosted surface. Over the real Remote Control service, Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} runs a slash command only when a person's app wrote it and treats any other writer as a peer, whose message the model reads as text, and the door does not claim to be a person's app on a service it does not run. Launch the session under a pool with resumeOnLimit (which supervises it), or run it against the door's self-hosted surface.`;
18140
+ }
18141
+ function createRcSessionCommands(deps) {
18142
+ const queues = /* @__PURE__ */ new Map();
18143
+ const serialised = async (sessionId, work) => {
18144
+ const before = queues.get(sessionId) ?? Promise.resolve();
18145
+ const run = before.then(work, work);
18146
+ const settled = run.then(() => void 0, () => void 0);
18147
+ queues.set(sessionId, settled);
18148
+ try {
18149
+ return await run;
18150
+ } finally {
18151
+ if (queues.get(sessionId) === settled) {
18152
+ queues.delete(sessionId);
18153
+ }
18154
+ }
18155
+ };
18156
+ const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
18157
+ const signal = options.signal ?? new AbortController().signal;
18158
+ if (signal.aborted) {
18159
+ return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
18160
+ }
18161
+ const target = await deps.supervisedOf(sessionId);
18162
+ if (target !== void 0 && "refused" in target) {
18163
+ return { ok: false, message: target.refused };
18164
+ }
18165
+ if (target !== void 0) {
18166
+ if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
18167
+ return { ok: false, message: unverifiedVersionMessage(sessionId, target.version, "its supervisor's control plugin has not loaded") };
18168
+ }
18169
+ const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
18170
+ const timeout = AbortSignal.timeout(waitMs);
18171
+ const bounded3 = AbortSignal.any([signal, timeout]);
18172
+ try {
18173
+ return await actions.supervised(target, bounded3, waitMs);
18174
+ } catch (error) {
18175
+ if (timeout.aborted) {
18176
+ return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(waitMs)} ms. A request the plugin had not started is withdrawn; one it had started runs once the session is idle (a turn waiting on a permission prompt holds it), so read the session's goal or transcript before asking again` };
18177
+ }
18178
+ return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
18179
+ }
18180
+ }
18181
+ if (!deps.isObserved(sessionId)) {
18182
+ return { ok: false, message: `the front door has not observed Remote Control session ${sessionId}` };
18183
+ }
18184
+ if (deps.selfHost !== void 0) {
18185
+ const unavailable = deps.selfHost.unavailable();
18186
+ if (unavailable !== void 0) {
18187
+ return { ok: false, message: `session ${sessionId} was not launched under an agent-shim supervisor, and the door's self-hosted surface cannot take a command: ${unavailable}` };
18188
+ }
18189
+ const version = deps.selfHost.versionOf(sessionId);
18190
+ if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
18191
+ return { ok: false, message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
18192
+ }
18193
+ const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
18194
+ const timeout = AbortSignal.timeout(waitMs);
18195
+ const result = await actions.selfHosted(deps.selfHost, AbortSignal.any([signal, timeout]));
18196
+ if (!result.ok && timeout.aborted) {
18197
+ return { ok: false, message: `session ${sessionId}'s worker did not answer within ${String(waitMs)} ms in all; it may still be queued behind a running turn, so read the session's stream before asking again` };
18198
+ }
18199
+ return result;
18200
+ }
18201
+ return { ok: false, message: unsupportedMessage(sessionId) };
18202
+ });
18203
+ const transcriptGoal = async (sessionId, target) => {
18204
+ const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
18205
+ if (goal === void 0) {
18206
+ return { ok: false, message: `session ${sessionId}'s supervisor has not recorded its transcript yet, which is where its goal is read from; retry once it has finished a turn` };
18207
+ }
18208
+ return { ok: true, report: goal };
18209
+ };
18210
+ const settledGoal = async (sessionId, target, signal, holds) => {
18211
+ for (; ; ) {
18212
+ const read = await transcriptGoal(sessionId, target);
18213
+ if (!read.ok || holds(read.report) || signal.aborted) {
18214
+ return read;
18215
+ }
18216
+ await sleep(RESULT_POLL_MS);
18217
+ }
18218
+ };
18219
+ const waitOf = (options) => options.waitMs;
18220
+ return {
18221
+ /** Reads the session's goal: from the transcript for a supervised session, with no effect on it; by running `/goal` on the self-hosted surface otherwise. */
18222
+ goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
18223
+ supervised: async (target) => {
18224
+ const read = await transcriptGoal(sessionId, target);
18225
+ return await Promise.resolve(read.ok ? { ok: true, report: { route: "supervised", goal: read.report } } : read);
18226
+ },
18227
+ selfHosted: async (selfHost, signal) => {
18228
+ const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
18229
+ return read.ok ? { ok: true, report: { route: "self-hosted", goal: read.report.goal } } : read;
18230
+ }
18231
+ }),
18232
+ /**
18233
+ * Sets the session's goal: the goal check then keeps the session working until the condition holds, and the condition reaches its model as a directive (`docs/rc-slash-commands.md`, the trust boundary). Refused unsent: an empty condition, one `/goal` reads as a clear, and one longer than it accepts. The answer names the goal it replaced.
18234
+ */
18235
+ goalSet: async (sessionId, condition, options = {}) => {
18236
+ const trimmed = condition.trim();
18237
+ if (trimmed === "") {
18238
+ return { ok: false, message: "a goal set needs a non-empty condition" };
18239
+ }
18240
+ if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
18241
+ return { ok: false, message: `"${trimmed}" cannot be set as a goal condition: /goal reads ${RC_GOAL_CLEAR_WORDS.join(", ")} as a request to clear the goal, so use the clear verb for that` };
18242
+ }
18243
+ if (/[\r\n]/u.test(trimmed)) {
18244
+ return { ok: false, message: "a goal condition is one line: /goal reads its condition from the line it is typed on, and both routes confirm the goal by the exact condition, so a condition spanning lines is refused rather than set as something else" };
18245
+ }
18246
+ if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
18247
+ return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
18248
+ }
18249
+ return await onRoute(sessionId, options, {
18250
+ supervised: async (target, signal, waitMs) => {
18251
+ const before = await transcriptGoal(sessionId, target);
18252
+ if (!before.ok) {
18253
+ return before;
18254
+ }
18255
+ await target.runGoal(trimmed, signal, waitMs);
18256
+ const after = await settledGoal(sessionId, target, signal, (goal) => goal?.condition === trimmed);
18257
+ if (!after.ok) {
18258
+ return after;
18259
+ }
18260
+ return after.report?.condition === trimmed ? { ok: true, report: { route: "supervised", condition: trimmed, superseded: before.report?.condition ?? null } } : { ok: false, message: `session ${sessionId} ran /goal but its transcript does not record the goal as set` };
18261
+ },
18262
+ selfHosted: async (selfHost, signal) => {
18263
+ const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
18264
+ if (!before.ok) {
18265
+ return before;
18266
+ }
18267
+ const set = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-set", condition: trimmed }, waitOf(options), signal);
18268
+ return set.ok ? { ok: true, report: { route: "self-hosted", condition: set.report.condition, superseded: before.report.goal?.condition ?? null } } : set;
18269
+ }
18270
+ });
18271
+ },
18272
+ /** Clears the session's goal and names the condition it cleared, or `null` when there was none, which is not a failure (clearing is idempotent). */
18273
+ goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
18274
+ supervised: async (target, signal, waitMs) => {
18275
+ const before = await transcriptGoal(sessionId, target);
18276
+ if (!before.ok) {
18277
+ return before;
18278
+ }
18279
+ if (before.report === null) {
18280
+ return { ok: true, report: { route: "supervised", cleared: null } };
18281
+ }
18282
+ await target.runGoal("clear", signal, waitMs);
18283
+ const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
18284
+ if (!after.ok) {
18285
+ return after;
18286
+ }
18287
+ return after.report === null ? { ok: true, report: { route: "supervised", cleared: before.report.condition } } : { ok: false, message: `session ${sessionId} ran /goal clear but its transcript still records the goal "${after.report.condition}"` };
18288
+ },
18289
+ selfHosted: async (selfHost, signal) => {
18290
+ const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
18291
+ return cleared.ok ? { ok: true, report: { route: "self-hosted", cleared: cleared.report.cleared } } : cleared;
18292
+ }
18293
+ }),
18294
+ /** Compacts the session's conversation, with custom summary instructions when given, and resolves with the outcome: the trigger and token counts, or the session's reason for not compacting. */
18295
+ compact: async (sessionId, options = {}) => {
18296
+ const instructions = options.instructions?.trim();
18297
+ const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
18298
+ return await onRoute(sessionId, options, {
18299
+ supervised: async (target, signal, waitMs) => {
18300
+ const result = await target.compact(signal, given, waitMs);
18301
+ if (result.kind === "unchanged") {
18302
+ return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
18303
+ }
18304
+ return { ok: true, report: { route: "supervised", trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
18305
+ },
18306
+ selfHosted: async (selfHost, signal) => {
18307
+ const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
18308
+ return compacted.ok ? { ok: true, report: { route: "self-hosted", ...compacted.report } } : compacted;
18309
+ }
18310
+ });
18311
+ }
18312
+ };
18313
+ }
18314
+
18315
+ // src/frontdoor/rcSlashCommandSchemas.ts
18316
+ var WaitMsSchema = z23.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
18317
+ var RcGoalSessionInputSchema = z23.strictObject({
18318
+ session: z23.string().min(1),
18319
+ waitMs: WaitMsSchema
18320
+ });
18321
+ var RcGoalSetInputSchema = z23.strictObject({
18322
+ session: z23.string().min(1),
18323
+ condition: z23.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
18324
+ waitMs: WaitMsSchema
18325
+ });
18326
+ var RcCompactInputSchema = z23.strictObject({
18327
+ session: z23.string().min(1),
18328
+ waitMs: WaitMsSchema
18329
+ });
18330
+ var RcCompactWithInstructionsInputSchema = z23.strictObject({
18331
+ session: z23.string().min(1),
18332
+ instructions: z23.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
18333
+ waitMs: WaitMsSchema
18334
+ });
18335
+ var commandAnswerShape = {
18336
+ session: z23.string(),
18337
+ route: z23.enum(["supervised", "self-hosted"])
18338
+ };
18339
+ var RcGoalGetOutputSchema = z23.strictObject({
18340
+ ...commandAnswerShape,
18341
+ goal: z23.strictObject({ condition: z23.string(), iterations: z23.int().nonnegative(), lastCheck: z23.string().optional() }).nullable()
18342
+ });
18343
+ var RcGoalSetOutputSchema = z23.strictObject({
18344
+ ...commandAnswerShape,
18345
+ condition: z23.string(),
18346
+ superseded: z23.string().nullable()
18347
+ });
18348
+ var RcGoalClearOutputSchema = z23.strictObject({
18349
+ ...commandAnswerShape,
18350
+ cleared: z23.string().nullable()
18351
+ });
18352
+ var RcCompactOutputSchema = z23.strictObject({
18353
+ ...commandAnswerShape,
18354
+ trigger: z23.string(),
18355
+ preTokens: z23.number().optional(),
18356
+ postTokens: z23.number().optional()
18357
+ });
18358
+
17917
18359
  // src/frontdoor/rcApi.ts
17918
18360
  var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
17919
18361
  var RC_OPENAPI_DOC_PATH = "/openapi.json";
@@ -17935,6 +18377,7 @@ function doorApiAuth(expectedToken) {
17935
18377
  });
17936
18378
  }
17937
18379
  var RC_API_TAG = "remote-control";
18380
+ var RC_DIRECTIVE_TAG = "remote-control-directives";
17938
18381
  function createRcApiRouter(deps) {
17939
18382
  const authed = doorApiAuth(deps.expectedToken);
17940
18383
  const delivered = (sessionId, result) => {
@@ -17952,6 +18395,13 @@ function createRcApiRouter(deps) {
17952
18395
  }
17953
18396
  return { request: result.requestId, sequenceNums: result.sequenceNums };
17954
18397
  };
18398
+ const commanded = (sessionId, result) => {
18399
+ if (!result.ok) {
18400
+ throw new ORPCError("BAD_GATEWAY", { message: result.message });
18401
+ }
18402
+ return { session: sessionId, ...result.report };
18403
+ };
18404
+ const optionsOf = (waitMs, signal) => ({ ...waitMs === void 0 ? {} : { waitMs }, ...signal === void 0 ? {} : { signal } });
17955
18405
  return {
17956
18406
  rc: {
17957
18407
  list: authed.meta(openapi({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
@@ -17988,6 +18438,11 @@ function createRcApiRouter(deps) {
17988
18438
  mcpAuthenticate: authed.meta(openapi({ method: "POST", path: "/rest/rc/mcp-authenticate", summary: "Start OAuth for one MCP server on a session", tags: [RC_API_TAG] })).input(RcMcpAuthenticateInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.mcpAuthenticate(input.session, input.serverName, input.redirectUri)) })),
17989
18439
  mcpOAuthCallbackUrl: authed.meta(openapi({ method: "POST", path: "/rest/rc/mcp-oauth-callback-url", summary: "Hand a completed MCP OAuth callback to a session", tags: [RC_API_TAG] })).input(RcMcpOAuthCallbackUrlInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.mcpOAuthCallbackUrl(input.session, input.serverName, input.callbackUrl)) })),
17990
18440
  teleport: authed.meta(openapi({ method: "POST", path: "/rest/rc/teleport", summary: "Teleport a session to a conversation marker", tags: [RC_API_TAG] })).input(RcTeleportInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.teleport(input.session, input.marker)) })),
18441
+ goalGet: authed.meta(openapi({ method: "POST", path: "/rest/rc/goal/get", summary: "Read a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalGetOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalGet(input.session, optionsOf(input.waitMs, signal)))),
18442
+ goalSet: authed.meta(openapi({ method: "POST", path: "/rest/rc/goal/set", summary: "Set a session's goal, a directive its model then works to", tags: [RC_DIRECTIVE_TAG] })).input(RcGoalSetInputSchema).output(RcGoalSetOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalSet(input.session, input.condition, optionsOf(input.waitMs, signal)))),
18443
+ goalClear: authed.meta(openapi({ method: "POST", path: "/rest/rc/goal/clear", summary: "Clear a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalClearOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalClear(input.session, optionsOf(input.waitMs, signal)))),
18444
+ compact: authed.meta(openapi({ method: "POST", path: "/rest/rc/compact", summary: "Compact a session's conversation", tags: [RC_API_TAG] })).input(RcCompactInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, optionsOf(input.waitMs, signal)))),
18445
+ compactWithInstructions: authed.meta(openapi({ method: "POST", path: "/rest/rc/compact-with-instructions", summary: "Compact a session's conversation under summary instructions, a directive to its model", tags: [RC_DIRECTIVE_TAG] })).input(RcCompactWithInstructionsInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, { ...optionsOf(input.waitMs, signal), instructions: input.instructions }))),
17991
18446
  subscribe: authed.meta(openapi({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(eventIterator(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
17992
18447
  const queue = [];
17993
18448
  let wake;
@@ -18068,8 +18523,27 @@ function doorApiNodeHandlerOf(router, expectedToken) {
18068
18523
  function createRcApiNodeHandler(deps) {
18069
18524
  return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
18070
18525
  }
18526
+ var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
18527
+ var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
18528
+ function headersTimeoutOf(url, body) {
18529
+ if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
18530
+ return DEFAULT_HEADERS_TIMEOUT_MS;
18531
+ }
18532
+ const parsed = body === void 0 ? void 0 : JSON.parse(body.toString("utf8"));
18533
+ const waitMs = typeof parsed === "object" && parsed !== null && "json" in parsed && typeof parsed.json === "object" && parsed.json !== null && "waitMs" in parsed.json && typeof parsed.json.waitMs === "number" ? parsed.json.waitMs : COMPACT_TIMEOUT_MS;
18534
+ return Math.min(waitMs + DEFAULT_HEADERS_TIMEOUT_MS, RC_SESSION_COMMAND_MAX_WAIT_MS);
18535
+ }
18071
18536
  function frontDoorApiLink(port, ca, token) {
18072
- const dispatcher = new Agent3({ connect: { ca } });
18537
+ const dispatchers = /* @__PURE__ */ new Map();
18538
+ const dispatcherFor = (headersTimeout) => {
18539
+ const existing = dispatchers.get(headersTimeout);
18540
+ if (existing !== void 0) {
18541
+ return existing;
18542
+ }
18543
+ const created = new Agent3({ connect: { ca }, headersTimeout });
18544
+ dispatchers.set(headersTimeout, created);
18545
+ return created;
18546
+ };
18073
18547
  return new RPCLink({
18074
18548
  origin: `https://127.0.0.1:${String(port)}`,
18075
18549
  url: RC_ORPC_PATH_PREFIX,
@@ -18082,7 +18556,7 @@ function frontDoorApiLink(port, ca, token) {
18082
18556
  method: request4.method,
18083
18557
  headers: [...request4.headers],
18084
18558
  ...body === void 0 ? {} : { body },
18085
- dispatcher,
18559
+ dispatcher: dispatcherFor(headersTimeoutOf(request4.url, body)),
18086
18560
  ...options.signal === void 0 ? {} : { signal: options.signal }
18087
18561
  });
18088
18562
  return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
@@ -18098,48 +18572,48 @@ init_cliError();
18098
18572
  init_package();
18099
18573
 
18100
18574
  // src/codex/appServerSchemas.ts
18101
- import { z as z23 } from "zod";
18575
+ import { z as z24 } from "zod";
18102
18576
  var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
18103
- var RateLimitWindowSchema = z23.object({
18104
- usedPercent: z23.number(),
18105
- resetsAt: z23.number().nullish(),
18106
- windowDurationMins: z23.number().nullish()
18107
- });
18108
- var RateLimitSnapshotSchema = z23.object({
18109
- limitId: z23.string().nullish(),
18110
- limitName: z23.string().nullish(),
18111
- planType: z23.string().nullish(),
18577
+ var RateLimitWindowSchema = z24.object({
18578
+ usedPercent: z24.number(),
18579
+ resetsAt: z24.number().nullish(),
18580
+ windowDurationMins: z24.number().nullish()
18581
+ });
18582
+ var RateLimitSnapshotSchema = z24.object({
18583
+ limitId: z24.string().nullish(),
18584
+ limitName: z24.string().nullish(),
18585
+ planType: z24.string().nullish(),
18112
18586
  primary: RateLimitWindowSchema.nullish(),
18113
18587
  secondary: RateLimitWindowSchema.nullish(),
18114
- rateLimitReachedType: z23.string().nullish(),
18115
- spendControlReached: z23.boolean().nullish()
18116
- });
18117
- var RateLimitResetCreditSchema = z23.object({
18118
- id: z23.string(),
18119
- grantedAt: z23.number(),
18120
- expiresAt: z23.number().nullish(),
18121
- resetType: z23.string(),
18122
- status: z23.string(),
18123
- title: z23.string().nullish(),
18124
- description: z23.string().nullish()
18125
- });
18126
- var CodexAccountSchema = z23.discriminatedUnion("type", [
18127
- z23.object({ type: z23.literal("apiKey") }),
18128
- z23.object({ type: z23.literal("chatgpt"), email: z23.string().nullable(), planType: z23.string() }),
18129
- z23.object({ type: z23.literal("amazonBedrock"), usesCodexManagedCredentials: z23.boolean().default(false) })
18588
+ rateLimitReachedType: z24.string().nullish(),
18589
+ spendControlReached: z24.boolean().nullish()
18590
+ });
18591
+ var RateLimitResetCreditSchema = z24.object({
18592
+ id: z24.string(),
18593
+ grantedAt: z24.number(),
18594
+ expiresAt: z24.number().nullish(),
18595
+ resetType: z24.string(),
18596
+ status: z24.string(),
18597
+ title: z24.string().nullish(),
18598
+ description: z24.string().nullish()
18599
+ });
18600
+ var CodexAccountSchema = z24.discriminatedUnion("type", [
18601
+ z24.object({ type: z24.literal("apiKey") }),
18602
+ z24.object({ type: z24.literal("chatgpt"), email: z24.string().nullable(), planType: z24.string() }),
18603
+ z24.object({ type: z24.literal("amazonBedrock"), usesCodexManagedCredentials: z24.boolean().default(false) })
18130
18604
  ]);
18131
- var CodexAccountReadSchema = z23.object({
18605
+ var CodexAccountReadSchema = z24.object({
18132
18606
  account: CodexAccountSchema.nullable(),
18133
- requiresOpenaiAuth: z23.boolean()
18607
+ requiresOpenaiAuth: z24.boolean()
18134
18608
  });
18135
- var CodexRateLimitsReadSchema = z23.object({
18609
+ var CodexRateLimitsReadSchema = z24.object({
18136
18610
  rateLimits: RateLimitSnapshotSchema,
18137
- rateLimitsByLimitId: z23.record(z23.string(), RateLimitSnapshotSchema).nullish(),
18138
- rateLimitResetCredits: z23.object({ availableCount: z23.number(), credits: z23.array(RateLimitResetCreditSchema).nullish() }).nullish(),
18139
- accountId: z23.string().nullish(),
18140
- ordinaryUsageAllowed: z23.boolean().nullish()
18611
+ rateLimitsByLimitId: z24.record(z24.string(), RateLimitSnapshotSchema).nullish(),
18612
+ rateLimitResetCredits: z24.object({ availableCount: z24.number(), credits: z24.array(RateLimitResetCreditSchema).nullish() }).nullish(),
18613
+ accountId: z24.string().nullish(),
18614
+ ordinaryUsageAllowed: z24.boolean().nullish()
18141
18615
  });
18142
- var CodexInitializeResultSchema = z23.object({ userAgent: z23.string() });
18616
+ var CodexInitializeResultSchema = z24.object({ userAgent: z24.string() });
18143
18617
 
18144
18618
  // src/codex/appServer.ts
18145
18619
  var CodexAppServerUnavailableError = class extends CliError {
@@ -18479,7 +18953,7 @@ init_projects();
18479
18953
  init_injected();
18480
18954
  init_pipeline();
18481
18955
  import path37 from "node:path";
18482
- import { z as z26 } from "zod";
18956
+ import { z as z27 } from "zod";
18483
18957
  var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
18484
18958
  function projectFragmentOf(rawKey) {
18485
18959
  return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
@@ -18548,9 +19022,9 @@ function lookupKeychainService(run, farmRoot) {
18548
19022
  }
18549
19023
  return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
18550
19024
  }
18551
- var SettingsSecretsShapeSchema = z26.looseObject({
18552
- env: z26.record(z26.string(), z26.unknown()).optional(),
18553
- hooks: z26.record(z26.string(), z26.array(z26.unknown())).optional()
19025
+ var SettingsSecretsShapeSchema = z27.looseObject({
19026
+ env: z27.record(z27.string(), z27.unknown()).optional(),
19027
+ hooks: z27.record(z27.string(), z27.array(z27.unknown())).optional()
18554
19028
  });
18555
19029
  function hookCommandCountOf(group) {
18556
19030
  if (typeof group !== "object" || group === null) {
@@ -18855,7 +19329,7 @@ init_schema();
18855
19329
  init_claudeVersion();
18856
19330
  init_identity();
18857
19331
  init_projects();
18858
- import { z as z28 } from "zod";
19332
+ import { z as z29 } from "zod";
18859
19333
 
18860
19334
  // src/resolve/types.ts
18861
19335
  var LAYER_KINDS = [
@@ -18916,123 +19390,123 @@ var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
18916
19390
 
18917
19391
  // src/usage/pickReportSchema.ts
18918
19392
  init_plan2();
18919
- import { z as z27 } from "zod";
18920
- var PoolPickCandidateViewSchema = z27.strictObject({
18921
- identity: z27.string(),
18922
- /** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
18923
- class: z27.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
19393
+ import { z as z28 } from "zod";
19394
+ var PoolPickCandidateViewSchema = z28.strictObject({
19395
+ identity: z28.string(),
19396
+ /** In pick order: `scored` has usable quota data, `unknown` has none and no plan known to bill by use, `pay-per-use` bills by use whether or not usage is recorded, `ineligible` is refused right now. */
19397
+ class: z28.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
18924
19398
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
18925
- score: z27.number().optional(),
19399
+ score: z28.number().optional(),
18926
19400
  /** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation or its measured-ratio five-hour term outranks the weekly one; present with `score`. */
18927
- scoreWindow: z27.enum(["sevenDay", "fiveHour"]).optional(),
19401
+ scoreWindow: z28.enum(["sevenDay", "fiveHour"]).optional(),
18928
19402
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
18929
- feasible: z27.boolean(),
19403
+ feasible: z28.boolean(),
18930
19404
  /** When an `ineligible` member can be used again, as an ISO instant. */
18931
- blockedUntil: z27.iso.datetime().optional(),
19405
+ blockedUntil: z28.iso.datetime().optional(),
18932
19406
  plan: PlanClassSchema,
18933
19407
  /** The facts behind the class and score, in the order they matter. */
18934
- reasons: z27.array(z27.string())
19408
+ reasons: z28.array(z28.string())
18935
19409
  });
18936
- var PoolPickReportSchema = z27.strictObject({
18937
- pool: z27.string(),
18938
- directory: z27.string(),
19410
+ var PoolPickReportSchema = z28.strictObject({
19411
+ pool: z28.string(),
19412
+ directory: z28.string(),
18939
19413
  /** The member a launch would run as, absent when every member is refused. */
18940
- pick: z27.string().optional(),
18941
- candidates: z27.array(PoolPickCandidateViewSchema),
19414
+ pick: z28.string().optional(),
19415
+ candidates: z28.array(PoolPickCandidateViewSchema),
18942
19416
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
18943
- missing: z27.array(z27.string()),
19417
+ missing: z28.array(z28.string()),
18944
19418
  /** When nothing can be picked, the soonest any member returns. */
18945
- earliestReturn: z27.strictObject({ identity: z27.string(), at: z27.iso.datetime() }).optional(),
19419
+ earliestReturn: z28.strictObject({ identity: z28.string(), at: z28.iso.datetime() }).optional(),
18946
19420
  /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
18947
- movedOff: z27.strictObject({ identity: z27.string(), reason: z27.string() }).optional(),
19421
+ movedOff: z28.strictObject({ identity: z28.string(), reason: z28.string() }).optional(),
18948
19422
  /** Why the last-pick record could not be read, when that is the case. */
18949
- stickyProblem: z27.string().optional()
19423
+ stickyProblem: z28.string().optional()
18950
19424
  });
18951
19425
 
18952
19426
  // src/checkReportSchema.ts
18953
19427
  var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
18954
- var CheckLayerViewSchema = z28.strictObject({
18955
- id: z28.int(),
18956
- kind: z28.enum(LAYER_KINDS),
18957
- source: z28.string()
18958
- });
18959
- var CheckEntryViewSchema = z28.strictObject({
18960
- path: z28.string(),
18961
- shared: z28.boolean(),
18962
- via: z28.enum(DECISION_VIAS),
19428
+ var CheckLayerViewSchema = z29.strictObject({
19429
+ id: z29.int(),
19430
+ kind: z29.enum(LAYER_KINDS),
19431
+ source: z29.string()
19432
+ });
19433
+ var CheckEntryViewSchema = z29.strictObject({
19434
+ path: z29.string(),
19435
+ shared: z29.boolean(),
19436
+ via: z29.enum(DECISION_VIAS),
18963
19437
  /** The entry's real category, or null when nothing classifies it. */
18964
- category: z28.enum(CATEGORY_NAMES).nullable(),
18965
- rule: z28.strictObject({ key: z28.string(), layer: z28.int() }).optional(),
19438
+ category: z29.enum(CATEGORY_NAMES).nullable(),
19439
+ rule: z29.strictObject({ key: z29.string(), layer: z29.int() }).optional(),
18966
19440
  /** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
18967
- eliminated: z28.readonly(z28.array(z28.strictObject({ key: z28.string(), failed: z28.readonly(z28.array(z28.string())) }))).optional()
18968
- });
18969
- var CheckDiagnosticSchema = z28.strictObject({
18970
- code: z28.enum(DIAGNOSTIC_CODES),
18971
- severity: z28.enum(DIAGNOSTIC_SEVERITIES),
18972
- message: z28.string(),
18973
- subject: z28.string().optional(),
18974
- layer: z28.int().optional()
18975
- });
18976
- var CheckAmbientCredentialSchema = z28.union([z28.strictObject({ ok: z28.literal(true) }), z28.strictObject({ ok: z28.literal(false), variable: z28.string(), message: z28.string() })]);
18977
- var CheckKeychainSchema = z28.strictObject({
18978
- checked: z28.literal(true),
18979
- found: z28.boolean(),
18980
- serviceName: z28.string().optional(),
18981
- note: z28.string()
18982
- });
18983
- var CheckSettingsExposureSchema = z28.strictObject({
18984
- file: z28.string(),
18985
- envKeyNames: z28.readonly(z28.array(z28.string())),
18986
- hookEventNames: z28.readonly(z28.array(z28.string())),
18987
- hookCommandCount: z28.int().nonnegative()
18988
- });
18989
- var CredentialSourceSummarySchema = z28.union([
18990
- z28.strictObject({ kind: z28.literal("env"), variable: z28.string() }),
18991
- z28.strictObject({ kind: z28.literal("file"), path: z28.string() }),
18992
- z28.strictObject({ kind: z28.literal("command"), program: z28.string() }),
18993
- z28.strictObject({ kind: z28.literal("op"), reference: z28.string() }),
18994
- z28.strictObject({ kind: z28.literal("keychain"), service: z28.string(), account: z28.string().optional() }),
18995
- z28.strictObject({ kind: z28.literal("literal") })
19441
+ eliminated: z29.readonly(z29.array(z29.strictObject({ key: z29.string(), failed: z29.readonly(z29.array(z29.string())) }))).optional()
19442
+ });
19443
+ var CheckDiagnosticSchema = z29.strictObject({
19444
+ code: z29.enum(DIAGNOSTIC_CODES),
19445
+ severity: z29.enum(DIAGNOSTIC_SEVERITIES),
19446
+ message: z29.string(),
19447
+ subject: z29.string().optional(),
19448
+ layer: z29.int().optional()
19449
+ });
19450
+ var CheckAmbientCredentialSchema = z29.union([z29.strictObject({ ok: z29.literal(true) }), z29.strictObject({ ok: z29.literal(false), variable: z29.string(), message: z29.string() })]);
19451
+ var CheckKeychainSchema = z29.strictObject({
19452
+ checked: z29.literal(true),
19453
+ found: z29.boolean(),
19454
+ serviceName: z29.string().optional(),
19455
+ note: z29.string()
19456
+ });
19457
+ var CheckSettingsExposureSchema = z29.strictObject({
19458
+ file: z29.string(),
19459
+ envKeyNames: z29.readonly(z29.array(z29.string())),
19460
+ hookEventNames: z29.readonly(z29.array(z29.string())),
19461
+ hookCommandCount: z29.int().nonnegative()
19462
+ });
19463
+ var CredentialSourceSummarySchema = z29.union([
19464
+ z29.strictObject({ kind: z29.literal("env"), variable: z29.string() }),
19465
+ z29.strictObject({ kind: z29.literal("file"), path: z29.string() }),
19466
+ z29.strictObject({ kind: z29.literal("command"), program: z29.string() }),
19467
+ z29.strictObject({ kind: z29.literal("op"), reference: z29.string() }),
19468
+ z29.strictObject({ kind: z29.literal("keychain"), service: z29.string(), account: z29.string().optional() }),
19469
+ z29.strictObject({ kind: z29.literal("literal") })
18996
19470
  ]);
18997
- var CredentialSummarySchema = z28.strictObject({
18998
- target: z28.enum(CREDENTIAL_TARGETS),
18999
- sources: z28.readonly(z28.array(CredentialSourceSummarySchema)),
19471
+ var CredentialSummarySchema = z29.strictObject({
19472
+ target: z29.enum(CREDENTIAL_TARGETS),
19473
+ sources: z29.readonly(z29.array(CredentialSourceSummarySchema)),
19000
19474
  cache: CredentialCacheSchema.optional()
19001
19475
  });
19002
- var CachedCredentialStateSchema = z28.union([
19003
- z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.literal("empty") }),
19004
- z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.literal("unreadable"), reason: z28.string() }),
19005
- z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.enum(["fresh", "expired"]), ageMs: z28.number(), expiresInMs: z28.number().optional() })
19476
+ var CachedCredentialStateSchema = z29.union([
19477
+ z29.strictObject({ store: z29.enum(CREDENTIAL_CACHE_STORES), status: z29.literal("empty") }),
19478
+ z29.strictObject({ store: z29.enum(CREDENTIAL_CACHE_STORES), status: z29.literal("unreadable"), reason: z29.string() }),
19479
+ z29.strictObject({ store: z29.enum(CREDENTIAL_CACHE_STORES), status: z29.enum(["fresh", "expired"]), ageMs: z29.number(), expiresInMs: z29.number().optional() })
19006
19480
  ]);
19007
- var CheckCredentialProviderSchema = z28.union([
19008
- z28.strictObject({ name: z28.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
19009
- z28.strictObject({ name: z28.string(), problem: z28.string() })
19481
+ var CheckCredentialProviderSchema = z29.union([
19482
+ z29.strictObject({ name: z29.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
19483
+ z29.strictObject({ name: z29.string(), problem: z29.string() })
19010
19484
  ]);
19011
- var CheckCredentialSchema = z28.strictObject({
19012
- applies: z28.enum(CHECK_CREDENTIAL_APPLIES),
19485
+ var CheckCredentialSchema = z29.strictObject({
19486
+ applies: z29.enum(CHECK_CREDENTIAL_APPLIES),
19013
19487
  provider: CheckCredentialProviderSchema.optional(),
19014
19488
  identity: CredentialSummarySchema.optional(),
19015
19489
  identityCached: CachedCredentialStateSchema.optional()
19016
19490
  });
19017
- var CheckClaudeVersionSchema = z28.strictObject({
19018
- pinned: z28.strictObject({ version: z28.string(), source: z28.enum(CLAUDE_VERSION_SOURCES), installed: z28.boolean() }).optional(),
19019
- highestInstalled: z28.string().optional(),
19020
- installed: z28.readonly(z28.array(z28.string()))
19491
+ var CheckClaudeVersionSchema = z29.strictObject({
19492
+ pinned: z29.strictObject({ version: z29.string(), source: z29.enum(CLAUDE_VERSION_SOURCES), installed: z29.boolean() }).optional(),
19493
+ highestInstalled: z29.string().optional(),
19494
+ installed: z29.readonly(z29.array(z29.string()))
19021
19495
  });
19022
- var CheckReportJsonSchema = z28.strictObject({
19023
- identity: z28.strictObject({ name: z28.string().nullable(), source: z28.enum(IDENTITY_DECISION_SOURCES) }),
19496
+ var CheckReportJsonSchema = z29.strictObject({
19497
+ identity: z29.strictObject({ name: z29.string().nullable(), source: z29.enum(IDENTITY_DECISION_SOURCES) }),
19024
19498
  /** The pool ranking, when the launch named a pool instead of an identity. */
19025
19499
  pool: PoolPickReportSchema.optional(),
19026
- configProfile: z28.strictObject({ name: z28.string().nullable(), source: z28.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
19027
- layers: z28.readonly(z28.array(CheckLayerViewSchema)),
19028
- entries: z28.readonly(z28.array(CheckEntryViewSchema)),
19029
- projectEncodingAmbiguities: z28.readonly(
19030
- z28.array(z28.strictObject({ fragment: z28.string(), encoded: z28.string(), reason: z28.enum(ENCODING_AMBIGUITY_REASONS), detail: z28.string() }))
19500
+ configProfile: z29.strictObject({ name: z29.string().nullable(), source: z29.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
19501
+ layers: z29.readonly(z29.array(CheckLayerViewSchema)),
19502
+ entries: z29.readonly(z29.array(CheckEntryViewSchema)),
19503
+ projectEncodingAmbiguities: z29.readonly(
19504
+ z29.array(z29.strictObject({ fragment: z29.string(), encoded: z29.string(), reason: z29.enum(ENCODING_AMBIGUITY_REASONS), detail: z29.string() }))
19031
19505
  ),
19032
- diagnostics: z28.readonly(z28.array(CheckDiagnosticSchema)),
19506
+ diagnostics: z29.readonly(z29.array(CheckDiagnosticSchema)),
19033
19507
  ambientCredential: CheckAmbientCredentialSchema,
19034
19508
  keychain: CheckKeychainSchema.optional(),
19035
- settingsExposure: z28.readonly(z28.array(CheckSettingsExposureSchema)),
19509
+ settingsExposure: z29.readonly(z29.array(CheckSettingsExposureSchema)),
19036
19510
  credential: CheckCredentialSchema,
19037
19511
  claudeVersion: CheckClaudeVersionSchema.optional()
19038
19512
  });
@@ -19043,28 +19517,28 @@ init_preflight();
19043
19517
  init_resets();
19044
19518
 
19045
19519
  // src/usage/resetsSchema.ts
19046
- import { z as z29 } from "zod";
19047
- var ResetRowSchema = z29.strictObject({
19048
- identity: z29.string(),
19049
- provider: z29.string(),
19520
+ import { z as z30 } from "zod";
19521
+ var ResetRowSchema = z30.strictObject({
19522
+ identity: z30.string(),
19523
+ provider: z30.string(),
19050
19524
  /** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
19051
- window: z29.string(),
19525
+ window: z30.string(),
19052
19526
  /** When the state the window comes from was observed, as an ISO instant. */
19053
- observedAt: z29.iso.datetime(),
19527
+ observedAt: z30.iso.datetime(),
19054
19528
  /** When the window resets, as an ISO instant; absent when the upstream reported none. */
19055
- resetsAt: z29.iso.datetime().optional(),
19529
+ resetsAt: z30.iso.datetime().optional(),
19056
19530
  /** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
19057
- reset: z29.boolean(),
19531
+ reset: z30.boolean(),
19058
19532
  /** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
19059
- utilization: z29.number().optional(),
19533
+ utilization: z30.number().optional(),
19060
19534
  /** The window's own status, for a window that has not reset yet. */
19061
- status: z29.string().optional()
19535
+ status: z30.string().optional()
19062
19536
  });
19063
- var ResetScheduleSchema = z29.strictObject({ resets: z29.readonly(z29.array(ResetRowSchema)) });
19537
+ var ResetScheduleSchema = z30.strictObject({ resets: z30.readonly(z30.array(ResetRowSchema)) });
19064
19538
 
19065
19539
  // src/frontdoor/controlSchemas.ts
19066
19540
  import path43 from "node:path";
19067
- import { z as z36 } from "zod";
19541
+ import { z as z37 } from "zod";
19068
19542
 
19069
19543
  // src/codex/doctor.ts
19070
19544
  function codexIdentityFindings(entry, identity) {
@@ -20291,92 +20765,92 @@ function collectDoctorReport(params) {
20291
20765
  // src/frontdoor/controlSchemas.ts
20292
20766
  init_schema2();
20293
20767
  init_state();
20294
- var UsageListOutputSchema = z36.strictObject({ snapshots: z36.readonly(z36.array(UsageSnapshotSchema)) });
20295
- var UsageWindowsInputSchema = z36.strictObject({
20296
- identity: z36.string().min(1),
20297
- provider: z36.string().min(1).optional()
20768
+ var UsageListOutputSchema = z37.strictObject({ snapshots: z37.readonly(z37.array(UsageSnapshotSchema)) });
20769
+ var UsageWindowsInputSchema = z37.strictObject({
20770
+ identity: z37.string().min(1),
20771
+ provider: z37.string().min(1).optional()
20298
20772
  });
20299
- var EffectiveWindowSchema = z36.strictObject({
20773
+ var EffectiveWindowSchema = z37.strictObject({
20300
20774
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
20301
- reset: z36.boolean(),
20775
+ reset: z37.boolean(),
20302
20776
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
20303
- utilization: z36.number().optional(),
20777
+ utilization: z37.number().optional(),
20304
20778
  /** The reset instant, for a window that has not reset yet and reported one. */
20305
- resetsAtMs: z36.number().optional(),
20779
+ resetsAtMs: z37.number().optional(),
20306
20780
  /** The window's own status, for a window that has not reset yet. */
20307
- status: z36.string().optional()
20781
+ status: z37.string().optional()
20308
20782
  });
20309
- var UsageWindowsOutputSchema = z36.strictObject({
20310
- identity: z36.string(),
20311
- provider: z36.string(),
20783
+ var UsageWindowsOutputSchema = z37.strictObject({
20784
+ identity: z37.string(),
20785
+ provider: z37.string(),
20312
20786
  /** When the rate-limit state the windows come from was observed. */
20313
- observedAt: z36.iso.datetime().optional(),
20787
+ observedAt: z37.iso.datetime().optional(),
20314
20788
  fiveHour: EffectiveWindowSchema.optional(),
20315
20789
  sevenDay: EffectiveWindowSchema.optional()
20316
20790
  });
20317
- var UsageLiveOutputSchema = z36.strictObject({
20791
+ var UsageLiveOutputSchema = z37.strictObject({
20318
20792
  /** 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. */
20319
20793
  latest: RcLiveRateLimitSchema.optional(),
20320
20794
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
20321
- sessions: z36.readonly(z36.array(RcLiveRateLimitSchema))
20795
+ sessions: z37.readonly(z37.array(RcLiveRateLimitSchema))
20322
20796
  });
20323
- var FrontDoorSessionStatusSchema = z36.strictObject({
20324
- pid: z36.int().positive(),
20325
- startedAt: z36.number(),
20326
- alive: z36.boolean()
20797
+ var FrontDoorSessionStatusSchema = z37.strictObject({
20798
+ pid: z37.int().positive(),
20799
+ startedAt: z37.number(),
20800
+ alive: z37.boolean()
20327
20801
  });
20328
- var HeadroomSocketTargetSchema = z36.union([z36.strictObject({ socketPath: z36.string() }), z36.strictObject({ refused: z36.string() })]);
20329
- var FrontDoorStatusOutputSchema = z36.strictObject({
20802
+ var HeadroomSocketTargetSchema = z37.union([z37.strictObject({ socketPath: z37.string() }), z37.strictObject({ refused: z37.string() })]);
20803
+ var FrontDoorStatusOutputSchema = z37.strictObject({
20330
20804
  state: FrontDoorStateSchema,
20331
- supervisorAlive: z36.boolean(),
20805
+ supervisorAlive: z37.boolean(),
20332
20806
  /** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
20333
- draining: z36.readonly(z36.array(z36.number().int().positive())),
20334
- sessions: z36.readonly(z36.array(FrontDoorSessionStatusSchema)),
20807
+ draining: z37.readonly(z37.array(z37.number().int().positive())),
20808
+ sessions: z37.readonly(z37.array(FrontDoorSessionStatusSchema)),
20335
20809
  headroomSocket: HeadroomSocketTargetSchema.optional(),
20336
- logPath: z36.string(),
20337
- logExists: z36.boolean()
20810
+ logPath: z37.string(),
20811
+ logExists: z37.boolean()
20338
20812
  });
20339
- var FrontDoorSessionsOutputSchema = z36.strictObject({ sessions: z36.readonly(z36.array(FrontDoorSessionStatusSchema)) });
20340
- var CheckRunInputSchema = z36.strictObject({
20341
- path: z36.string().min(1),
20342
- identity: z36.string().min(1).optional()
20813
+ var FrontDoorSessionsOutputSchema = z37.strictObject({ sessions: z37.readonly(z37.array(FrontDoorSessionStatusSchema)) });
20814
+ var CheckRunInputSchema = z37.strictObject({
20815
+ path: z37.string().min(1),
20816
+ identity: z37.string().min(1).optional()
20343
20817
  }).refine((input) => path43.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20344
- var PoolPickInputSchema = z36.strictObject({
20345
- pool: z36.string().min(1),
20346
- path: z36.string().min(1)
20818
+ var PoolPickInputSchema = z37.strictObject({
20819
+ pool: z37.string().min(1),
20820
+ path: z37.string().min(1)
20347
20821
  }).refine((input) => path43.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20348
- var DoctorFindingSchema = z36.strictObject({
20349
- section: z36.enum(DOCTOR_SECTIONS),
20350
- subject: z36.string().optional(),
20351
- severity: z36.enum(DOCTOR_SEVERITIES),
20352
- message: z36.string()
20822
+ var DoctorFindingSchema = z37.strictObject({
20823
+ section: z37.enum(DOCTOR_SECTIONS),
20824
+ subject: z37.string().optional(),
20825
+ severity: z37.enum(DOCTOR_SEVERITIES),
20826
+ message: z37.string()
20353
20827
  });
20354
- var DoctorRunOutputSchema = z36.strictObject({
20828
+ var DoctorRunOutputSchema = z37.strictObject({
20355
20829
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
20356
- ok: z36.boolean(),
20357
- findings: z36.readonly(z36.array(DoctorFindingSchema))
20358
- });
20359
- var FrontDoorRestartOutputSchema = z36.strictObject({
20360
- action: z36.literal("restarting"),
20361
- previousPid: z36.int().positive()
20362
- });
20363
- var UpdateCheckOutputSchema = z36.strictObject({
20364
- current: z36.string(),
20365
- latest: z36.string(),
20366
- action: z36.enum(["current", "available", "updated"])
20367
- });
20368
- var CodexSignInSchema = z36.discriminatedUnion("state", [
20369
- z36.strictObject({ state: z36.literal("none") }),
20370
- z36.strictObject({ state: z36.literal("signed-in"), email: z36.string().optional(), planScope: z36.boolean(), accessTokenExpiresAt: z36.number() }),
20371
- z36.strictObject({ state: z36.literal("unreadable"), message: z36.string() })
20830
+ ok: z37.boolean(),
20831
+ findings: z37.readonly(z37.array(DoctorFindingSchema))
20832
+ });
20833
+ var FrontDoorRestartOutputSchema = z37.strictObject({
20834
+ action: z37.literal("restarting"),
20835
+ previousPid: z37.int().positive()
20836
+ });
20837
+ var UpdateCheckOutputSchema = z37.strictObject({
20838
+ current: z37.string(),
20839
+ latest: z37.string(),
20840
+ action: z37.enum(["current", "available", "updated"])
20841
+ });
20842
+ var CodexSignInSchema = z37.discriminatedUnion("state", [
20843
+ z37.strictObject({ state: z37.literal("none") }),
20844
+ z37.strictObject({ state: z37.literal("signed-in"), email: z37.string().optional(), planScope: z37.boolean(), accessTokenExpiresAt: z37.number() }),
20845
+ z37.strictObject({ state: z37.literal("unreadable"), message: z37.string() })
20372
20846
  ]);
20373
- var CodexStatusOutputSchema = z36.strictObject({
20847
+ var CodexStatusOutputSchema = z37.strictObject({
20374
20848
  signIn: CodexSignInSchema,
20375
- codexProviders: z36.readonly(z36.array(z36.string()))
20849
+ codexProviders: z37.readonly(z37.array(z37.string()))
20376
20850
  });
20377
- var CodexLogoutOutputSchema = z36.strictObject({
20378
- hadGrant: z36.boolean(),
20379
- revoked: z36.boolean()
20851
+ var CodexLogoutOutputSchema = z37.strictObject({
20852
+ hadGrant: z37.boolean(),
20853
+ revoked: z37.boolean()
20380
20854
  });
20381
20855
 
20382
20856
  // src/frontdoor/codexApi.ts
@@ -20444,67 +20918,67 @@ init_schema();
20444
20918
  init_names();
20445
20919
  init_keychainLogin();
20446
20920
  init_statusline();
20447
- import { z as z37 } from "zod";
20448
- var RemovalConfirmationSchema = z37.boolean();
20449
- var CredentialWriteSchema = (targets) => z37.strictObject({
20450
- sources: z37.array(RemoteCredentialSourceSchema).min(1).optional(),
20451
- target: z37.enum(targets).optional(),
20452
- cache: z37.union([z37.literal(false), CredentialCacheSchema]).optional()
20453
- });
20454
- var CredentialSummarySchema2 = z37.strictObject({
20455
- target: z37.enum(CREDENTIAL_TARGETS),
20456
- sources: z37.readonly(z37.array(
20457
- z37.discriminatedUnion("kind", [
20458
- z37.strictObject({ kind: z37.literal("env"), variable: z37.string() }),
20459
- z37.strictObject({ kind: z37.literal("file"), path: z37.string() }),
20460
- z37.strictObject({ kind: z37.literal("command"), program: z37.string() }),
20461
- z37.strictObject({ kind: z37.literal("op"), reference: z37.string() }),
20462
- z37.strictObject({ kind: z37.literal("keychain"), service: z37.string(), account: z37.string().optional() }),
20463
- z37.strictObject({ kind: z37.literal("literal") })
20921
+ import { z as z38 } from "zod";
20922
+ var RemovalConfirmationSchema = z38.boolean();
20923
+ var CredentialWriteSchema = (targets) => z38.strictObject({
20924
+ sources: z38.array(RemoteCredentialSourceSchema).min(1).optional(),
20925
+ target: z38.enum(targets).optional(),
20926
+ cache: z38.union([z38.literal(false), CredentialCacheSchema]).optional()
20927
+ });
20928
+ var CredentialSummarySchema2 = z38.strictObject({
20929
+ target: z38.enum(CREDENTIAL_TARGETS),
20930
+ sources: z38.readonly(z38.array(
20931
+ z38.discriminatedUnion("kind", [
20932
+ z38.strictObject({ kind: z38.literal("env"), variable: z38.string() }),
20933
+ z38.strictObject({ kind: z38.literal("file"), path: z38.string() }),
20934
+ z38.strictObject({ kind: z38.literal("command"), program: z38.string() }),
20935
+ z38.strictObject({ kind: z38.literal("op"), reference: z38.string() }),
20936
+ z38.strictObject({ kind: z38.literal("keychain"), service: z38.string(), account: z38.string().optional() }),
20937
+ z38.strictObject({ kind: z38.literal("literal") })
20464
20938
  ])
20465
20939
  )),
20466
20940
  cache: CredentialCacheSchema.optional()
20467
20941
  });
20468
- var mutationOutput = (kind, action) => z37.strictObject({ action: z37.literal(action), kind: z37.literal(kind), name: z37.string() });
20469
- var storedMutationOutput = (kind, action, value) => z37.strictObject({ action: z37.literal(action), kind: z37.literal(kind), name: z37.string(), value });
20470
- var IdentityValueSchema = z37.strictObject({
20471
- name: z37.string(),
20472
- label: z37.string().optional(),
20473
- defaultConfigProfile: z37.string().optional(),
20474
- provider: z37.string().optional(),
20475
- allowAmbientCredential: z37.boolean(),
20942
+ var mutationOutput = (kind, action) => z38.strictObject({ action: z38.literal(action), kind: z38.literal(kind), name: z38.string() });
20943
+ var storedMutationOutput = (kind, action, value) => z38.strictObject({ action: z38.literal(action), kind: z38.literal(kind), name: z38.string(), value });
20944
+ var IdentityValueSchema = z38.strictObject({
20945
+ name: z38.string(),
20946
+ label: z38.string().optional(),
20947
+ defaultConfigProfile: z38.string().optional(),
20948
+ provider: z38.string().optional(),
20949
+ allowAmbientCredential: z38.boolean(),
20476
20950
  credential: CredentialSummarySchema2.optional(),
20477
- anchors: z37.array(AnchorSchema).optional()
20951
+ anchors: z38.array(AnchorSchema).optional()
20478
20952
  });
20479
20953
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
20480
- var ProviderValueSchema = z37.strictObject({
20481
- name: z37.string(),
20482
- kind: z37.enum(PROVIDER_KINDS),
20483
- displayName: z37.string(),
20484
- baseUrl: z37.string().optional(),
20954
+ var ProviderValueSchema = z38.strictObject({
20955
+ name: z38.string(),
20956
+ kind: z38.enum(PROVIDER_KINDS),
20957
+ displayName: z38.string(),
20958
+ baseUrl: z38.string().optional(),
20485
20959
  codex: CodexProviderConfigSchema.optional(),
20486
20960
  credential: CredentialSummarySchema2.optional(),
20487
- env: z37.record(z37.string(), z37.string()).optional()
20961
+ env: z38.record(z38.string(), z38.string()).optional()
20488
20962
  });
20489
- var ConfigNameInputSchema = z37.strictObject({ name: z37.string().min(1) });
20490
- var ConfigIdentityAddInputSchema = z37.strictObject({ name: z37.string().min(1), keepKeychainLogin: z37.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
20963
+ var ConfigNameInputSchema = z38.strictObject({ name: z38.string().min(1) });
20964
+ var ConfigIdentityAddInputSchema = z38.strictObject({ name: z38.string().min(1), keepKeychainLogin: z38.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
20491
20965
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
20492
- var ConfigIdentitySetInputSchema = z37.strictObject({
20493
- name: z37.string().min(1),
20966
+ var ConfigIdentitySetInputSchema = z38.strictObject({
20967
+ name: z38.string().min(1),
20494
20968
  /** The identity's display label; `false` clears it. */
20495
- label: z37.union([IdentityLabelSchema, z37.literal(false)]).optional(),
20496
- defaultConfigProfile: z37.union([z37.string().min(1), z37.literal(false)]).optional(),
20969
+ label: z38.union([IdentityLabelSchema, z38.literal(false)]).optional(),
20970
+ defaultConfigProfile: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
20497
20971
  /** The provider the identity exists for; `false` clears it. */
20498
- provider: z37.union([z37.string().min(1), z37.literal(false)]).optional(),
20499
- allowAmbientCredential: z37.boolean().optional(),
20500
- credential: z37.union([z37.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
20972
+ provider: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
20973
+ allowAmbientCredential: z38.boolean().optional(),
20974
+ credential: z38.union([z38.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
20501
20975
  /** `false` removes the anchors; a list replaces them. */
20502
- anchors: z37.union([z37.literal(false), z37.array(AnchorSchema).min(1)]).optional()
20976
+ anchors: z38.union([z38.literal(false), z38.array(AnchorSchema).min(1)]).optional()
20503
20977
  });
20504
20978
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
20505
- var ConfigIdentityRemoveInputSchema = z37.strictObject({ name: z37.string().min(1), confirm: RemovalConfirmationSchema });
20979
+ var ConfigIdentityRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
20506
20980
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
20507
- var ConfigStatuslineSetSchema = z37.record(z37.string(), z37.unknown()).superRefine((settings, context) => {
20981
+ var ConfigStatuslineSetSchema = z38.record(z38.string(), z38.unknown()).superRefine((settings, context) => {
20508
20982
  for (const key of Object.keys(settings)) {
20509
20983
  if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
20510
20984
  context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
@@ -20512,93 +20986,93 @@ var ConfigStatuslineSetSchema = z37.record(z37.string(), z37.unknown()).superRef
20512
20986
  }
20513
20987
  });
20514
20988
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
20515
- var ConfigProfileAddInputSchema = z37.strictObject({
20516
- name: z37.string().min(1),
20517
- extends: z37.array(z37.string().min(1)).optional(),
20518
- description: z37.string().optional()
20989
+ var ConfigProfileAddInputSchema = z38.strictObject({
20990
+ name: z38.string().min(1),
20991
+ extends: z38.array(z38.string().min(1)).optional(),
20992
+ description: z38.string().optional()
20519
20993
  });
20520
20994
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
20521
- var ConfigProfileSetInputSchema = z37.strictObject({
20522
- name: z37.string().min(1),
20523
- category: z37.record(z37.string(), z37.boolean()).optional(),
20524
- entry: z37.record(z37.string(), z37.boolean()).optional(),
20525
- extends: z37.union([z37.array(z37.string().min(1)), z37.literal(false)]).optional(),
20526
- description: z37.union([z37.string(), z37.literal(false)]).optional(),
20527
- launch: z37.strictObject({
20528
- skipPermissions: z37.boolean().optional(),
20529
- remoteControl: z37.boolean().optional(),
20530
- headroom: z37.boolean().optional(),
20531
- trackUsage: z37.boolean().optional(),
20532
- provider: z37.union([z37.string().min(1), z37.literal(false)]).optional(),
20533
- claudeVersion: z37.union([z37.string().min(1), z37.literal(false)]).optional(),
20534
- delay: z37.union([z37.string().regex(DURATION_RE), z37.literal(false)]).optional(),
20535
- pause: z37.boolean().optional(),
20536
- explain: z37.boolean().optional(),
20537
- proxyBypass: z37.union([z37.array(z37.string().min(1)), z37.literal(false)]).optional(),
20538
- statusline: z37.strictObject({
20995
+ var ConfigProfileSetInputSchema = z38.strictObject({
20996
+ name: z38.string().min(1),
20997
+ category: z38.record(z38.string(), z38.boolean()).optional(),
20998
+ entry: z38.record(z38.string(), z38.boolean()).optional(),
20999
+ extends: z38.union([z38.array(z38.string().min(1)), z38.literal(false)]).optional(),
21000
+ description: z38.union([z38.string(), z38.literal(false)]).optional(),
21001
+ launch: z38.strictObject({
21002
+ skipPermissions: z38.boolean().optional(),
21003
+ remoteControl: z38.boolean().optional(),
21004
+ headroom: z38.boolean().optional(),
21005
+ trackUsage: z38.boolean().optional(),
21006
+ provider: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
21007
+ claudeVersion: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
21008
+ delay: z38.union([z38.string().regex(DURATION_RE), z38.literal(false)]).optional(),
21009
+ pause: z38.boolean().optional(),
21010
+ explain: z38.boolean().optional(),
21011
+ proxyBypass: z38.union([z38.array(z38.string().min(1)), z38.literal(false)]).optional(),
21012
+ statusline: z38.strictObject({
20539
21013
  set: ConfigStatuslineSetSchema.optional(),
20540
- unset: z37.array(z37.string()).optional()
21014
+ unset: z38.array(z38.string()).optional()
20541
21015
  }).optional()
20542
21016
  }).optional()
20543
21017
  });
20544
21018
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
20545
- var ConfigProfileRemoveInputSchema = z37.strictObject({ name: z37.string().min(1), confirm: RemovalConfirmationSchema });
21019
+ var ConfigProfileRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
20546
21020
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
20547
21021
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
20548
- var PoolMembersInputSchema = z37.array(z37.string().min(1)).min(1);
20549
- var ConfigPoolAddInputSchema = z37.strictObject({
20550
- name: z37.string().min(1),
21022
+ var PoolMembersInputSchema = z38.array(z38.string().min(1)).min(1);
21023
+ var ConfigPoolAddInputSchema = z38.strictObject({
21024
+ name: z38.string().min(1),
20551
21025
  identities: PoolMembersInputSchema,
20552
- preference: z37.enum(POOL_PREFERENCES).optional(),
20553
- resumeOnLimit: z37.boolean().optional(),
20554
- compactBeforeLimit: z37.boolean().optional(),
21026
+ preference: z38.enum(POOL_PREFERENCES).optional(),
21027
+ resumeOnLimit: z38.boolean().optional(),
21028
+ compactBeforeLimit: z38.boolean().optional(),
20555
21029
  compactAtUtilisation: CompactAtUtilisationSchema.optional()
20556
21030
  });
20557
21031
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
20558
- var ConfigPoolSetInputSchema = z37.strictObject({
20559
- name: z37.string().min(1),
21032
+ var ConfigPoolSetInputSchema = z38.strictObject({
21033
+ name: z38.string().min(1),
20560
21034
  identities: PoolMembersInputSchema.optional(),
20561
- preference: z37.union([z37.enum(POOL_PREFERENCES), z37.literal(false)]).optional(),
20562
- resumeOnLimit: z37.boolean().optional(),
20563
- compactBeforeLimit: z37.boolean().optional(),
20564
- compactAtUtilisation: z37.union([CompactAtUtilisationSchema, z37.literal(false)]).optional()
21035
+ preference: z38.union([z38.enum(POOL_PREFERENCES), z38.literal(false)]).optional(),
21036
+ resumeOnLimit: z38.boolean().optional(),
21037
+ compactBeforeLimit: z38.boolean().optional(),
21038
+ compactAtUtilisation: z38.union([CompactAtUtilisationSchema, z38.literal(false)]).optional()
20565
21039
  });
20566
21040
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
20567
- var ConfigPoolRemoveInputSchema = z37.strictObject({ name: z37.string().min(1), confirm: RemovalConfirmationSchema });
21041
+ var ConfigPoolRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
20568
21042
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
20569
21043
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
20570
- var ConfigProviderAddInputSchema = z37.strictObject({
20571
- name: z37.string().min(1),
20572
- kind: z37.enum(PROVIDER_KINDS).optional(),
20573
- displayName: z37.string().min(1),
20574
- baseUrl: z37.string().min(1).optional(),
21044
+ var ConfigProviderAddInputSchema = z38.strictObject({
21045
+ name: z38.string().min(1),
21046
+ kind: z38.enum(PROVIDER_KINDS).optional(),
21047
+ displayName: z38.string().min(1),
21048
+ baseUrl: z38.string().min(1).optional(),
20575
21049
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
20576
21050
  codex: CodexProviderConfigSchema.optional()
20577
21051
  });
20578
21052
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
20579
- var ConfigProviderSetInputSchema = z37.strictObject({
20580
- name: z37.string().min(1),
20581
- displayName: z37.string().min(1).optional(),
20582
- baseUrl: z37.string().min(1).optional(),
21053
+ var ConfigProviderSetInputSchema = z38.strictObject({
21054
+ name: z38.string().min(1),
21055
+ displayName: z38.string().min(1).optional(),
21056
+ baseUrl: z38.string().min(1).optional(),
20583
21057
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
20584
21058
  codex: CodexProviderConfigSchema.optional()
20585
21059
  });
20586
21060
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
20587
- var ConfigProviderRemoveInputSchema = z37.strictObject({ name: z37.string().min(1), confirm: RemovalConfirmationSchema });
21061
+ var ConfigProviderRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
20588
21062
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
20589
- var ConfigRuleAddInputSchema = z37.strictObject({
20590
- path: z37.string().min(1),
20591
- configProfile: z37.string().min(1).optional(),
20592
- identity: z37.string().min(1).optional()
21063
+ var ConfigRuleAddInputSchema = z38.strictObject({
21064
+ path: z38.string().min(1),
21065
+ configProfile: z38.string().min(1).optional(),
21066
+ identity: z38.string().min(1).optional()
20593
21067
  });
20594
21068
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
20595
- var ConfigRuleSetInputSchema = z37.strictObject({
20596
- path: z37.string().min(1),
20597
- configProfile: z37.union([z37.string().min(1), z37.literal(false)]).optional(),
20598
- identity: z37.union([z37.string().min(1), z37.literal(false)]).optional()
21069
+ var ConfigRuleSetInputSchema = z38.strictObject({
21070
+ path: z38.string().min(1),
21071
+ configProfile: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
21072
+ identity: z38.union([z38.string().min(1), z38.literal(false)]).optional()
20599
21073
  });
20600
21074
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
20601
- var ConfigRuleRemoveInputSchema = z37.strictObject({ path: z37.string().min(1), confirm: RemovalConfirmationSchema });
21075
+ var ConfigRuleRemoveInputSchema = z38.strictObject({ path: z38.string().min(1), confirm: RemovalConfirmationSchema });
20602
21076
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
20603
21077
 
20604
21078
  // src/frontdoor/configApi.ts
@@ -20951,50 +21425,50 @@ import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from
20951
21425
 
20952
21426
  // src/frontdoor/eventSchemas.ts
20953
21427
  init_schema2();
20954
- import { z as z38 } from "zod";
21428
+ import { z as z39 } from "zod";
20955
21429
  var DOOR_EVENT_SOURCE_RC = "rc";
20956
21430
  var LAUNCH_EVENT_SOURCE = "launch";
20957
21431
  var USAGE_EVENT_SOURCE = "usage";
20958
21432
  var DOOR_HEALTH_EVENT_SOURCE = "door";
20959
21433
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
20960
- var DoorEventSchema = z38.strictObject({
20961
- source: z38.string().min(1),
21434
+ var DoorEventSchema = z39.strictObject({
21435
+ source: z39.string().min(1),
20962
21436
  /** A positive integer because the backbone's counters start at one and only ever increase. */
20963
- sequence: z38.number().int().positive(),
20964
- payload: z38.unknown()
20965
- });
20966
- var DoorEventSourceQuerySchema = z38.strictObject({
20967
- sources: z38.array(z38.string().min(1)).min(1).optional()
20968
- });
20969
- var LaunchLifecycleEventSchema = z38.strictObject({
20970
- kind: z38.enum(["registered", "pruned", "ended"]),
20971
- pid: z38.number().int().positive(),
20972
- startedAt: z38.number(),
20973
- observedAt: z38.number()
20974
- });
20975
- var DoorHealthEventSchema = z38.discriminatedUnion("kind", [
20976
- z38.strictObject({ kind: z38.literal("generation"), pid: z38.number().int().positive(), providerPort: z38.number().int().positive(), connectPort: z38.number().int().positive(), directPort: z38.number().int().positive(), observedAt: z38.number() }),
20977
- z38.strictObject({ kind: z38.literal("listenerFailed"), pid: z38.number().int().positive(), listener: z38.enum(["provider", "connect", "direct"]), message: z38.string(), observedAt: z38.number() }),
20978
- z38.strictObject({ kind: z38.literal("binaryTurnover"), pid: z38.number().int().positive(), observedAt: z38.number() }),
20979
- z38.strictObject({ kind: z38.literal("idleShutdown"), pid: z38.number().int().positive(), observedAt: z38.number() }),
20980
- z38.strictObject({ kind: z38.literal("superseded"), pid: z38.number().int().positive(), ownerPid: z38.number().int().positive(), observedAt: z38.number() }),
20981
- z38.strictObject({ kind: z38.literal("drained"), pid: z38.number().int().positive(), observedAt: z38.number() })
21437
+ sequence: z39.number().int().positive(),
21438
+ payload: z39.unknown()
21439
+ });
21440
+ var DoorEventSourceQuerySchema = z39.strictObject({
21441
+ sources: z39.array(z39.string().min(1)).min(1).optional()
21442
+ });
21443
+ var LaunchLifecycleEventSchema = z39.strictObject({
21444
+ kind: z39.enum(["registered", "pruned", "ended"]),
21445
+ pid: z39.number().int().positive(),
21446
+ startedAt: z39.number(),
21447
+ observedAt: z39.number()
21448
+ });
21449
+ var DoorHealthEventSchema = z39.discriminatedUnion("kind", [
21450
+ z39.strictObject({ kind: z39.literal("generation"), pid: z39.number().int().positive(), providerPort: z39.number().int().positive(), connectPort: z39.number().int().positive(), directPort: z39.number().int().positive(), observedAt: z39.number() }),
21451
+ z39.strictObject({ kind: z39.literal("listenerFailed"), pid: z39.number().int().positive(), listener: z39.enum(["provider", "connect", "direct"]), message: z39.string(), observedAt: z39.number() }),
21452
+ z39.strictObject({ kind: z39.literal("binaryTurnover"), pid: z39.number().int().positive(), observedAt: z39.number() }),
21453
+ z39.strictObject({ kind: z39.literal("idleShutdown"), pid: z39.number().int().positive(), observedAt: z39.number() }),
21454
+ z39.strictObject({ kind: z39.literal("superseded"), pid: z39.number().int().positive(), ownerPid: z39.number().int().positive(), observedAt: z39.number() }),
21455
+ z39.strictObject({ kind: z39.literal("drained"), pid: z39.number().int().positive(), observedAt: z39.number() })
20982
21456
  ]);
20983
- var QuotaExpiringEventSchema = z38.strictObject({
21457
+ var QuotaExpiringEventSchema = z39.strictObject({
20984
21458
  /** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
20985
- id: z38.string().min(1),
21459
+ id: z39.string().min(1),
20986
21460
  /** The identity's name when the event was published, absent for an identity no longer stored under the id. */
20987
- name: z38.string().min(1).optional(),
20988
- provider: z38.string().min(1),
20989
- window: z38.enum(["fiveHour", "sevenDay"]),
21461
+ name: z39.string().min(1).optional(),
21462
+ provider: z39.string().min(1),
21463
+ window: z39.enum(["fiveHour", "sevenDay"]),
20990
21464
  /** 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. */
20991
- utilization: z38.number().min(0).max(1),
20992
- resetsAt: z38.iso.datetime(),
20993
- observedAt: z38.number()
21465
+ utilization: z39.number().min(0).max(1),
21466
+ resetsAt: z39.iso.datetime(),
21467
+ observedAt: z39.number()
20994
21468
  });
20995
21469
  var UsageChangeEventSchema = UsageSnapshotSchema.extend({
20996
- id: z38.string().min(1),
20997
- name: z38.string().min(1).optional()
21470
+ id: z39.string().min(1),
21471
+ name: z39.string().min(1).optional()
20998
21472
  });
20999
21473
 
21000
21474
  // src/frontdoor/eventsApi.ts
@@ -21039,14 +21513,14 @@ function createEventsApiRouter(deps) {
21039
21513
  init_update();
21040
21514
  import { ORPCError as ORPCError4 } from "@orpc/client";
21041
21515
  import { openapi as openapi5 } from "@orpc/openapi";
21042
- import { z as z39 } from "zod";
21516
+ import { z as z40 } from "zod";
21043
21517
  var FRONTDOOR_API_TAG = "frontdoor";
21044
21518
  var UPDATE_API_TAG = "update";
21045
21519
  function createLifecycleApiRouter(deps) {
21046
21520
  const authed = doorApiAuth(deps.expectedToken);
21047
21521
  return {
21048
21522
  frontdoor: {
21049
- refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z39.strictObject({ requested: z39.literal(true) })).handler(() => {
21523
+ refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z40.strictObject({ requested: z40.literal(true) })).handler(() => {
21050
21524
  deps.refreshCatalogues();
21051
21525
  return { requested: true };
21052
21526
  }),
@@ -21083,62 +21557,62 @@ import { openapi as openapi6 } from "@orpc/openapi";
21083
21557
 
21084
21558
  // src/frontdoor/launchSchemas.ts
21085
21559
  import path44 from "node:path";
21086
- import { z as z40 } from "zod";
21560
+ import { z as z41 } from "zod";
21087
21561
  init_statusline();
21088
21562
  init_claudeVersion();
21089
21563
  init_identity();
21090
- var LaunchResolveInputSchema = z40.strictObject({
21091
- path: z40.string().min(1),
21564
+ var LaunchResolveInputSchema = z41.strictObject({
21565
+ path: z41.string().min(1),
21092
21566
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
21093
- argv: z40.readonly(z40.array(z40.string())).optional(),
21567
+ argv: z41.readonly(z41.array(z41.string())).optional(),
21094
21568
  /** 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. */
21095
- env: z40.record(z40.string(), z40.string()).optional()
21569
+ env: z41.record(z41.string(), z41.string()).optional()
21096
21570
  }).refine((input) => path44.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
21097
- var LaunchPoolDecisionSchema = z40.strictObject({
21098
- name: z40.string(),
21099
- reasons: z40.readonly(z40.array(z40.string())),
21100
- movedOff: z40.strictObject({ identity: z40.string(), reason: z40.string() }).optional()
21101
- });
21102
- var LaunchDecisionSchema = z40.strictObject({
21103
- identity: z40.string().optional(),
21104
- identityId: z40.string().optional(),
21105
- identitySource: z40.enum(IDENTITY_DECISION_SOURCES),
21571
+ var LaunchPoolDecisionSchema = z41.strictObject({
21572
+ name: z41.string(),
21573
+ reasons: z41.readonly(z41.array(z41.string())),
21574
+ movedOff: z41.strictObject({ identity: z41.string(), reason: z41.string() }).optional()
21575
+ });
21576
+ var LaunchDecisionSchema = z41.strictObject({
21577
+ identity: z41.string().optional(),
21578
+ identityId: z41.string().optional(),
21579
+ identitySource: z41.enum(IDENTITY_DECISION_SOURCES),
21106
21580
  pool: LaunchPoolDecisionSchema.optional(),
21107
21581
  /** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
21108
- configDirEscapeHatch: z40.boolean(),
21109
- configDir: z40.string().optional(),
21110
- configProfile: z40.string().optional(),
21111
- configProfileSource: z40.enum(CONFIG_PROFILE_DECISION_SOURCES),
21112
- provider: z40.string().optional()
21113
- });
21114
- var LaunchFlagsSchema = z40.strictObject({
21115
- skipPermissions: z40.boolean(),
21116
- remoteControl: z40.boolean(),
21117
- headroom: z40.boolean(),
21118
- trackUsage: z40.boolean(),
21119
- pause: z40.boolean(),
21120
- explain: z40.boolean(),
21582
+ configDirEscapeHatch: z41.boolean(),
21583
+ configDir: z41.string().optional(),
21584
+ configProfile: z41.string().optional(),
21585
+ configProfileSource: z41.enum(CONFIG_PROFILE_DECISION_SOURCES),
21586
+ provider: z41.string().optional()
21587
+ });
21588
+ var LaunchFlagsSchema = z41.strictObject({
21589
+ skipPermissions: z41.boolean(),
21590
+ remoteControl: z41.boolean(),
21591
+ headroom: z41.boolean(),
21592
+ trackUsage: z41.boolean(),
21593
+ pause: z41.boolean(),
21594
+ explain: z41.boolean(),
21121
21595
  /** How long the launch waits after its own output before it starts claude, in milliseconds. */
21122
- delayMs: z40.number(),
21596
+ delayMs: z41.number(),
21123
21597
  /** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
21124
- proxyBypass: z40.array(z40.string()).readonly(),
21598
+ proxyBypass: z41.array(z41.string()).readonly(),
21125
21599
  /** How the session's built-in statusline looks, when the launch configures any of it. */
21126
21600
  statusline: StatuslineSchema.optional()
21127
21601
  });
21128
- var LaunchResolveOutputSchema = z40.strictObject({
21602
+ var LaunchResolveOutputSchema = z41.strictObject({
21129
21603
  decision: LaunchDecisionSchema,
21130
21604
  flags: LaunchFlagsSchema,
21131
- claudeVersion: z40.strictObject({ version: z40.string(), source: z40.enum(CLAUDE_VERSION_SOURCES) }).optional(),
21605
+ claudeVersion: z41.strictObject({ version: z41.string(), source: z41.enum(CLAUDE_VERSION_SOURCES) }).optional(),
21132
21606
  /** The real `claude` binary the launch would spawn, on the door's host. */
21133
- bin: z40.string(),
21607
+ bin: z41.string(),
21134
21608
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
21135
- args: z40.readonly(z40.array(z40.string())),
21609
+ args: z41.readonly(z41.array(z41.string())),
21136
21610
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
21137
- credential: z40.strictObject({ subject: z40.enum(["provider", "identity"]), name: z40.string(), summary: CredentialSummarySchema }).optional(),
21138
- routing: z40.strictObject({ frontDoor: z40.boolean(), headroom: z40.boolean() }),
21611
+ credential: z41.strictObject({ subject: z41.enum(["provider", "identity"]), name: z41.string(), summary: CredentialSummarySchema }).optional(),
21612
+ routing: z41.strictObject({ frontDoor: z41.boolean(), headroom: z41.boolean() }),
21139
21613
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
21140
- environment: z40.readonly(z40.array(z40.string())),
21141
- warnings: z40.readonly(z40.array(z40.string()))
21614
+ environment: z41.readonly(z41.array(z41.string())),
21615
+ warnings: z41.readonly(z41.array(z41.string()))
21142
21616
  });
21143
21617
 
21144
21618
  // src/frontdoor/launchApi.ts
@@ -21174,22 +21648,22 @@ function createLaunchApiRouter(deps) {
21174
21648
  // src/frontdoor/agentTreesApi.ts
21175
21649
  import { ORPCError as ORPCError6 } from "@orpc/client";
21176
21650
  import { openapi as openapi7 } from "@orpc/openapi";
21177
- import { z as z41 } from "zod";
21651
+ import { z as z42 } from "zod";
21178
21652
  init_cliError();
21179
- var AgentTreesListInputSchema = z41.strictObject({
21653
+ var AgentTreesListInputSchema = z42.strictObject({
21180
21654
  /** Only this identity's sessions. */
21181
- identity: z41.string().optional(),
21655
+ identity: z42.string().optional(),
21182
21656
  /** Include sessions that spawned no agent and ran no workflow. */
21183
- all: z41.boolean().optional()
21657
+ all: z42.boolean().optional()
21184
21658
  });
21185
- var AgentTreesListOutputSchema = z41.array(SessionSummarySchema);
21186
- var AgentTreesShowInputSchema = z41.strictObject({
21659
+ var AgentTreesListOutputSchema = z42.array(SessionSummarySchema);
21660
+ var AgentTreesShowInputSchema = z42.strictObject({
21187
21661
  /** A session id, or an unambiguous prefix of one. */
21188
- session: z41.string().min(1),
21662
+ session: z42.string().min(1),
21189
21663
  /** Look only in this identity. */
21190
- identity: z41.string().optional()
21664
+ identity: z42.string().optional()
21191
21665
  });
21192
- var AgentTreesShowOutputSchema = z41.strictObject({ identities: z41.array(z41.string()), ...MergedAgentTreeSchema.shape });
21666
+ var AgentTreesShowOutputSchema = z42.strictObject({ identities: z42.array(z42.string()), ...MergedAgentTreeSchema.shape });
21193
21667
  function asBadRequest(error) {
21194
21668
  if (error instanceof CliError) {
21195
21669
  throw new ORPCError6("BAD_REQUEST", { message: error.message });
@@ -21242,7 +21716,7 @@ import { openapi as openapi8 } from "@orpc/openapi";
21242
21716
  import { eventIterator as eventIterator3, withEventMeta as withEventMeta3 } from "@orpc/server";
21243
21717
 
21244
21718
  // src/frontdoor/rcEventLog.ts
21245
- import { z as z42 } from "zod";
21719
+ import { z as z43 } from "zod";
21246
21720
 
21247
21721
  // src/frontdoor/eventHub.ts
21248
21722
  var DOOR_EVENT_BUFFER_EVENTS = 100;
@@ -21365,46 +21839,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
21365
21839
  var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
21366
21840
  var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
21367
21841
  var RC_PENDING_RETIRE_REASONS = ["answered", "expired", "session-ended"];
21368
- var transitionBase = { session: z42.string(), at: z42.number() };
21369
- var cursorFields = { cursor: z42.string(), sequence: z42.int().positive() };
21370
- var sessionAppearedShape = { kind: z42.literal("session-appeared"), ...transitionBase };
21371
- var sessionEndedShape = { kind: z42.literal("session-ended"), reason: z42.enum(RC_SESSION_END_REASONS), ...transitionBase };
21372
- var workerStateShape = { kind: z42.literal("worker-state"), state: z42.string(), previous: z42.string().optional(), ...transitionBase };
21373
- var pendingBornShape = { kind: z42.literal("pending-born"), requestId: z42.string(), type: z42.string(), summary: z42.string(), ...transitionBase };
21374
- var pendingRetiredShape = { kind: z42.literal("pending-retired"), requestId: z42.string(), reason: z42.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
21375
- var RcSessionTransitionSchema = z42.discriminatedUnion("kind", [
21376
- z42.strictObject(sessionAppearedShape),
21377
- z42.strictObject(sessionEndedShape),
21378
- z42.strictObject(workerStateShape),
21379
- z42.strictObject(pendingBornShape),
21380
- z42.strictObject(pendingRetiredShape)
21842
+ var transitionBase = { session: z43.string(), at: z43.number() };
21843
+ var cursorFields = { cursor: z43.string(), sequence: z43.int().positive() };
21844
+ var sessionAppearedShape = { kind: z43.literal("session-appeared"), ...transitionBase };
21845
+ var sessionEndedShape = { kind: z43.literal("session-ended"), reason: z43.enum(RC_SESSION_END_REASONS), ...transitionBase };
21846
+ var workerStateShape = { kind: z43.literal("worker-state"), state: z43.string(), previous: z43.string().optional(), ...transitionBase };
21847
+ var pendingBornShape = { kind: z43.literal("pending-born"), requestId: z43.string(), type: z43.string(), summary: z43.string(), ...transitionBase };
21848
+ var pendingRetiredShape = { kind: z43.literal("pending-retired"), requestId: z43.string(), reason: z43.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
21849
+ var RcSessionTransitionSchema = z43.discriminatedUnion("kind", [
21850
+ z43.strictObject(sessionAppearedShape),
21851
+ z43.strictObject(sessionEndedShape),
21852
+ z43.strictObject(workerStateShape),
21853
+ z43.strictObject(pendingBornShape),
21854
+ z43.strictObject(pendingRetiredShape)
21381
21855
  ]);
21382
21856
  var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
21383
21857
  var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
21384
21858
  var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
21385
- var RcSessionEventSchema = z42.discriminatedUnion("kind", [
21386
- z42.strictObject({ ...cursorFields, ...sessionAppearedShape }),
21387
- z42.strictObject({ ...cursorFields, ...sessionEndedShape }),
21388
- z42.strictObject({ ...cursorFields, ...workerStateShape }),
21389
- z42.strictObject({ ...cursorFields, ...pendingBornShape }),
21390
- z42.strictObject({ ...cursorFields, ...pendingRetiredShape })
21859
+ var RcSessionEventSchema = z43.discriminatedUnion("kind", [
21860
+ z43.strictObject({ ...cursorFields, ...sessionAppearedShape }),
21861
+ z43.strictObject({ ...cursorFields, ...sessionEndedShape }),
21862
+ z43.strictObject({ ...cursorFields, ...workerStateShape }),
21863
+ z43.strictObject({ ...cursorFields, ...pendingBornShape }),
21864
+ z43.strictObject({ ...cursorFields, ...pendingRetiredShape })
21391
21865
  ]);
21392
- var RcSessionEventsReadInputSchema = z42.strictObject({
21866
+ var RcSessionEventsReadInputSchema = z43.strictObject({
21393
21867
  /** The cursor of the last event the caller saw; every retained event when omitted. */
21394
- since: z42.string().min(1).optional(),
21868
+ since: z43.string().min(1).optional(),
21395
21869
  /** One `cse_` session id; every session when omitted. */
21396
- session: z42.string().min(1).optional(),
21870
+ session: z43.string().min(1).optional(),
21397
21871
  /** The most events one answer carries; every event after `since` when omitted. */
21398
- limit: z42.int().positive().optional()
21872
+ limit: z43.int().positive().optional()
21399
21873
  });
21400
21874
  var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
21401
21875
  /** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
21402
- limit: z42.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
21876
+ limit: z43.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
21403
21877
  });
21404
21878
  var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
21405
- var RcSessionEventsReadOutputSchema = z42.discriminatedUnion("status", [
21406
- z42.strictObject({ status: z42.literal("ok"), events: z42.readonly(z42.array(RcSessionEventSchema)), cursor: z42.string(), more: z42.boolean(), head: z42.string() }),
21407
- z42.strictObject({ status: z42.literal("expired"), message: z42.string(), head: z42.string() })
21879
+ var RcSessionEventsReadOutputSchema = z43.discriminatedUnion("status", [
21880
+ z43.strictObject({ status: z43.literal("ok"), events: z43.readonly(z43.array(RcSessionEventSchema)), cursor: z43.string(), more: z43.boolean(), head: z43.string() }),
21881
+ z43.strictObject({ status: z43.literal("expired"), message: z43.string(), head: z43.string() })
21408
21882
  ]);
21409
21883
  var CURSOR_SEPARATOR = ".";
21410
21884
  var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
@@ -21903,15 +22377,15 @@ function createQuotaExpiringPublisher(hub, deps) {
21903
22377
 
21904
22378
  // src/frontdoor/rcLiveUsage.ts
21905
22379
  var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
21906
- function isRecord8(value) {
22380
+ function isRecord9(value) {
21907
22381
  return typeof value === "object" && value !== null && !Array.isArray(value);
21908
22382
  }
21909
22383
  function rcRateLimitInfoOf(event) {
21910
22384
  const payload = event.envelope.payload;
21911
- if (!isRecord8(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
22385
+ if (!isRecord9(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
21912
22386
  return void 0;
21913
22387
  }
21914
- if (!isRecord8(payload.rate_limit_info)) {
22388
+ if (!isRecord9(payload.rate_limit_info)) {
21915
22389
  return void 0;
21916
22390
  }
21917
22391
  const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
@@ -21999,7 +22473,7 @@ function createSseParser() {
21999
22473
  }
22000
22474
  };
22001
22475
  }
22002
- function isRecord9(value) {
22476
+ function isRecord10(value) {
22003
22477
  return typeof value === "object" && value !== null && !Array.isArray(value);
22004
22478
  }
22005
22479
  function sequenceNumOf(value) {
@@ -22021,7 +22495,7 @@ function parseRcStreamEnvelope(parsed) {
22021
22495
  } catch {
22022
22496
  return void 0;
22023
22497
  }
22024
- if (!isRecord9(data)) {
22498
+ if (!isRecord10(data)) {
22025
22499
  return void 0;
22026
22500
  }
22027
22501
  const eventType = data.event_type;
@@ -22268,7 +22742,13 @@ init_capability();
22268
22742
  // src/frontdoor/rcSelfHostEndpoints.ts
22269
22743
  var RC_SOURCE_WORKER = "worker";
22270
22744
  var RC_SOURCE_CLIENT = "client";
22271
- function isRecord10(value) {
22745
+ var CLIENT_PLATFORM_HEADER = "anthropic-client-platform";
22746
+ function withClientPlatform(payload, headers) {
22747
+ const rest = Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "client_platform"));
22748
+ const platform = headers[CLIENT_PLATFORM_HEADER];
22749
+ return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
22750
+ }
22751
+ function isRecord11(value) {
22272
22752
  return typeof value === "object" && value !== null && !Array.isArray(value);
22273
22753
  }
22274
22754
  function parseJsonObject2(body) {
@@ -22278,7 +22758,7 @@ function parseJsonObject2(body) {
22278
22758
  } catch {
22279
22759
  return void 0;
22280
22760
  }
22281
- return isRecord10(parsed) ? parsed : void 0;
22761
+ return isRecord11(parsed) ? parsed : void 0;
22282
22762
  }
22283
22763
  function nonEmptyString2(record, field) {
22284
22764
  const value = record === void 0 ? void 0 : record[field];
@@ -22352,11 +22832,11 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
22352
22832
  }
22353
22833
  const results = [];
22354
22834
  for (const event of events) {
22355
- if (!isRecord10(event) || !isRecord10(event.payload)) {
22835
+ if (!isRecord11(event) || !isRecord11(event.payload)) {
22356
22836
  await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a teleport write is an object carrying one payload object" } });
22357
22837
  return true;
22358
22838
  }
22359
- const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, event.payload);
22839
+ const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
22360
22840
  results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
22361
22841
  }
22362
22842
  ctx.sweep();
@@ -22452,7 +22932,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
22452
22932
  // src/frontdoor/rcSelfHostConversations.ts
22453
22933
  var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
22454
22934
  var RC_CONVERSATION_ID_PREFIX = "conv_";
22455
- function isRecord11(value) {
22935
+ function isRecord12(value) {
22456
22936
  return typeof value === "object" && value !== null && !Array.isArray(value);
22457
22937
  }
22458
22938
  function parseJsonObject3(body) {
@@ -22462,7 +22942,7 @@ function parseJsonObject3(body) {
22462
22942
  } catch {
22463
22943
  return void 0;
22464
22944
  }
22465
- return isRecord11(parsed) ? parsed : void 0;
22945
+ return isRecord12(parsed) ? parsed : void 0;
22466
22946
  }
22467
22947
  function nonEmptyString3(record, field) {
22468
22948
  const value = record === void 0 ? void 0 : record[field];
@@ -22516,11 +22996,11 @@ async function serveRcConversations(ctx, pathname, method) {
22516
22996
  }
22517
22997
  const results = [];
22518
22998
  for (const event of events) {
22519
- if (!isRecord11(event) || !isRecord11(event.payload)) {
22999
+ if (!isRecord12(event) || !isRecord12(event.payload)) {
22520
23000
  await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
22521
23001
  return;
22522
23002
  }
22523
- const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, event.payload);
23003
+ const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
22524
23004
  results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
22525
23005
  }
22526
23006
  ctx.sweep();
@@ -22548,7 +23028,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
22548
23028
  var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
22549
23029
  var MS_PER_SECOND6 = 1e3;
22550
23030
  var HTTP_SERVICE_UNAVAILABLE = 503;
22551
- function isRecord12(value) {
23031
+ function isRecord13(value) {
22552
23032
  return typeof value === "object" && value !== null && !Array.isArray(value);
22553
23033
  }
22554
23034
  function parseJsonObject4(body) {
@@ -22558,7 +23038,7 @@ function parseJsonObject4(body) {
22558
23038
  } catch {
22559
23039
  return void 0;
22560
23040
  }
22561
- return isRecord12(parsed) ? parsed : void 0;
23041
+ return isRecord13(parsed) ? parsed : void 0;
22562
23042
  }
22563
23043
  function growthBookFeatures() {
22564
23044
  return {
@@ -22912,7 +23392,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
22912
23392
  var RC_STREAM_EVENT_NAME2 = "client_event";
22913
23393
  var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
22914
23394
  var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
22915
- function isRecord13(value) {
23395
+ function isRecord14(value) {
22916
23396
  return typeof value === "object" && value !== null && !Array.isArray(value);
22917
23397
  }
22918
23398
  function isWebSearchRefusal(value) {
@@ -22996,7 +23476,7 @@ function parseJsonObject5(body) {
22996
23476
  } catch {
22997
23477
  return void 0;
22998
23478
  }
22999
- return isRecord13(parsed) ? parsed : void 0;
23479
+ return isRecord14(parsed) ? parsed : void 0;
23000
23480
  }
23001
23481
  function mintWorkerJwt(randomToken, issuedAt) {
23002
23482
  const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
@@ -23256,7 +23736,7 @@ data: ${JSON.stringify(envelope)}
23256
23736
  if (status !== void 0) {
23257
23737
  session.workerStatus = status;
23258
23738
  }
23259
- if (isRecord13(body?.external_metadata)) {
23739
+ if (isRecord14(body?.external_metadata)) {
23260
23740
  session.externalMetadata = body.external_metadata;
23261
23741
  }
23262
23742
  await answerJson2(response, HTTP_STATUS.ok, {});
@@ -23286,7 +23766,7 @@ data: ${JSON.stringify(envelope)}
23286
23766
  }
23287
23767
  const results = [];
23288
23768
  for (const event of events) {
23289
- if (!isRecord13(event) || !isRecord13(event.payload)) {
23769
+ if (!isRecord14(event) || !isRecord14(event.payload)) {
23290
23770
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a batch is an object carrying one payload object" } });
23291
23771
  return;
23292
23772
  }
@@ -23319,7 +23799,7 @@ data: ${JSON.stringify(envelope)}
23319
23799
  return;
23320
23800
  }
23321
23801
  for (const event of events) {
23322
- if (isRecord13(event)) {
23802
+ if (isRecord14(event)) {
23323
23803
  session.internalEvents.push({ eventId: deps.newUuid(), body: event });
23324
23804
  }
23325
23805
  }
@@ -23415,11 +23895,11 @@ data: ${JSON.stringify(envelope)}
23415
23895
  }
23416
23896
  const results = [];
23417
23897
  for (const event of events) {
23418
- if (!isRecord13(event) || !isRecord13(event.payload)) {
23898
+ if (!isRecord14(event) || !isRecord14(event.payload)) {
23419
23899
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
23420
23900
  return;
23421
23901
  }
23422
- const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, event.payload);
23902
+ const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
23423
23903
  results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
23424
23904
  }
23425
23905
  sweep();
@@ -23553,7 +24033,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
23553
24033
  var RC_SELF_HOST_RECORD_FILE = "credential.json";
23554
24034
  var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
23555
24035
  var SELF_HOST_SUBSCRIPTION_TYPE = "max";
23556
- function isRecord14(value) {
24036
+ function isRecord15(value) {
23557
24037
  return typeof value === "object" && value !== null && !Array.isArray(value);
23558
24038
  }
23559
24039
  function readJsonObject(fs17, file) {
@@ -23567,7 +24047,7 @@ function readJsonObject(fs17, file) {
23567
24047
  } catch {
23568
24048
  return void 0;
23569
24049
  }
23570
- return isRecord14(parsed) ? parsed : void 0;
24050
+ return isRecord15(parsed) ? parsed : void 0;
23571
24051
  }
23572
24052
  function readRcSelfHostRecord(fs17, frontdoorDir) {
23573
24053
  const parsed = readJsonObject(fs17, path45.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
@@ -23595,7 +24075,7 @@ function mintRcSelfHostCredential(deps) {
23595
24075
  const recordFile2 = path45.join(recordDir, RC_SELF_HOST_RECORD_FILE);
23596
24076
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
23597
24077
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
23598
- const existingOauth = isRecord14(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
24078
+ const existingOauth = isRecord15(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
23599
24079
  const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
23600
24080
  const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
23601
24081
  if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
@@ -23612,7 +24092,7 @@ function mintRcSelfHostCredential(deps) {
23612
24092
  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)}
23613
24093
  `);
23614
24094
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
23615
- const existingBlock = (value) => isRecord14(value) ? value : {};
24095
+ const existingBlock = (value) => isRecord15(value) ? value : {};
23616
24096
  deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
23617
24097
  ...claudeJson,
23618
24098
  oauthAccount: {
@@ -23735,7 +24215,7 @@ init_poolPick();
23735
24215
 
23736
24216
  // src/agents/read.ts
23737
24217
  import path47 from "node:path";
23738
- import { z as z43 } from "zod";
24218
+ import { z as z44 } from "zod";
23739
24219
  var PROJECTS_DIR = "projects";
23740
24220
  var TASKS_DIR = "tasks";
23741
24221
  var SUBAGENTS_DIR = "subagents";
@@ -23854,14 +24334,14 @@ function parseJson2(text) {
23854
24334
  return void 0;
23855
24335
  }
23856
24336
  }
23857
- var TaskFileSchema = z43.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z43.array(z43.string()).default([]), blockedBy: z43.array(z43.string()).default([]) });
23858
- var WorkflowRunFileSchema = z43.object({
23859
- runId: z43.string(),
23860
- workflowName: z43.string().optional(),
23861
- status: z43.string().optional(),
23862
- startTime: z43.number().optional(),
23863
- phases: z43.array(z43.object({ title: z43.string() })).default([]),
23864
- summary: z43.string().optional()
24337
+ var TaskFileSchema = z44.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z44.array(z44.string()).default([]), blockedBy: z44.array(z44.string()).default([]) });
24338
+ var WorkflowRunFileSchema = z44.object({
24339
+ runId: z44.string(),
24340
+ workflowName: z44.string().optional(),
24341
+ status: z44.string().optional(),
24342
+ startTime: z44.number().optional(),
24343
+ phases: z44.array(z44.object({ title: z44.string() })).default([]),
24344
+ summary: z44.string().optional()
23865
24345
  });
23866
24346
  function summariseSession(fs17, configDir, ref) {
23867
24347
  const sessionRelative = path47.join(PROJECTS_DIR, ref.project, ref.entry);
@@ -24365,6 +24845,8 @@ export {
24365
24845
  QUOTA_EXPIRING_EVENT_SOURCE,
24366
24846
  QuotaExpiringEventSchema,
24367
24847
  RC_CONTEXT_USAGE_DETAILS,
24848
+ RC_GOAL_CLEAR_WORDS,
24849
+ RC_GOAL_CONDITION_MAX_CHARS,
24368
24850
  RC_IDLE_EXPIRY_MS,
24369
24851
  RC_ORPC_PATH_PREFIX,
24370
24852
  RC_PENDING_DEADLINE_MS,
@@ -24380,6 +24862,8 @@ export {
24380
24862
  RC_SELF_HOST_SCOPE_LIST,
24381
24863
  RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
24382
24864
  RC_SESSIONS_PATH_PREFIX,
24865
+ RC_SESSION_COMMAND_MAX_WAIT_MS,
24866
+ RC_SESSION_COMMAND_VERIFIED_VERSIONS,
24383
24867
  RC_SESSION_END_REASONS,
24384
24868
  RC_SESSION_EVENT_LOG_CAPACITY,
24385
24869
  RC_STREAM_BACKOFF_MS,
@@ -24475,11 +24959,13 @@ export {
24475
24959
  createQuotaExpiringPublisher,
24476
24960
  createRcApiNodeHandler,
24477
24961
  createRcApiRouter,
24962
+ createRcClaudeCodeVersions,
24478
24963
  createRcControlHandler,
24479
24964
  createRcCredentialStore,
24480
24965
  createRcEventFanout,
24481
24966
  createRcLiveUsage,
24482
24967
  createRcSelfHostSurface,
24968
+ createRcSessionCommands,
24483
24969
  createRcSessionEventLog,
24484
24970
  createRcSessionEventsApiRouter,
24485
24971
  createRcSessionRegistryReader,
@@ -24542,6 +25028,7 @@ export {
24542
25028
  mintRcSelfHostCredential,
24543
25029
  observingRoutedRoute,
24544
25030
  parseConnectTarget,
25031
+ parseRcGoalOutput,
24545
25032
  parseRcStreamEnvelope,
24546
25033
  planOf,
24547
25034
  poolIdentities,
@@ -24553,6 +25040,8 @@ export {
24553
25040
  rankPool,
24554
25041
  rcEventWriteResultFromAnswer,
24555
25042
  rcFanoutOnDoorHub,
25043
+ rcLocalCommandAnswerOf,
25044
+ rcManualCompactBoundaryOf,
24556
25045
  rcObserverAsPassthrough,
24557
25046
  rcRateLimitInfoOf,
24558
25047
  rcSelfHostFromEnv,