claude-use 11.89.1 → 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.cjs CHANGED
@@ -7294,30 +7294,30 @@ var init_state2 = __esm({
7294
7294
  });
7295
7295
 
7296
7296
  // src/headroom/earlierRelease.ts
7297
- function withoutOurSocket(commandLine, socketPath) {
7297
+ function withoutOurSocket(commandLine2, socketPath) {
7298
7298
  for (const argument of [`--uds ${socketPath}`, `--uds=${socketPath}`]) {
7299
7299
  let from = 0;
7300
7300
  for (; ; ) {
7301
- const index = commandLine.indexOf(argument, from);
7301
+ const index = commandLine2.indexOf(argument, from);
7302
7302
  if (index === -1) {
7303
7303
  break;
7304
7304
  }
7305
7305
  const end = index + argument.length;
7306
- const startsArgument = index === 0 || /\s/.test(commandLine.charAt(index - 1));
7307
- const endsArgument = end === commandLine.length || /\s/.test(commandLine.charAt(end));
7306
+ const startsArgument = index === 0 || /\s/.test(commandLine2.charAt(index - 1));
7307
+ const endsArgument = end === commandLine2.length || /\s/.test(commandLine2.charAt(end));
7308
7308
  if (startsArgument && endsArgument) {
7309
- return `${commandLine.slice(0, index)} ${commandLine.slice(end)}`;
7309
+ return `${commandLine2.slice(0, index)} ${commandLine2.slice(end)}`;
7310
7310
  }
7311
7311
  from = index + 1;
7312
7312
  }
7313
7313
  }
7314
7314
  return void 0;
7315
7315
  }
7316
- function daemonIdentity(commandLine, socketPath) {
7317
- if (commandLine === void 0) {
7316
+ function daemonIdentity(commandLine2, socketPath) {
7317
+ if (commandLine2 === void 0) {
7318
7318
  return "unreadable";
7319
7319
  }
7320
- const rest = withoutOurSocket(commandLine, socketPath);
7320
+ const rest = withoutOurSocket(commandLine2, socketPath);
7321
7321
  const argumentsList = rest === void 0 ? [] : rest.trim().split(/\s+/);
7322
7322
  if (rest === void 0 || !argumentsList.includes("proxy")) {
7323
7323
  return "not-headroom";
@@ -7416,8 +7416,8 @@ function ensureHeadroom(params) {
7416
7416
  writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
7417
7417
  return { socketPath: state.socketPath };
7418
7418
  }
7419
- const commandLine = commandLineOf(state.headroomPid);
7420
- const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine, socketPath: state.socketPath, recordedHash: state.allowlistHash });
7419
+ const commandLine2 = commandLineOf(state.headroomPid);
7420
+ const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine: commandLine2, socketPath: state.socketPath, recordedHash: state.allowlistHash });
7421
7421
  if (earlierRelease !== void 0) {
7422
7422
  if (earlierRelease.admitsServingDoor) {
7423
7423
  writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
@@ -7427,7 +7427,7 @@ function ensureHeadroom(params) {
7427
7427
  `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}`
7428
7428
  );
7429
7429
  }
7430
- awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine, state.socketPath) };
7430
+ awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine2, state.socketPath) };
7431
7431
  }
7432
7432
  if (state.lastError !== void 0) {
7433
7433
  throw new HeadroomStartError(
@@ -10519,7 +10519,7 @@ var init_package = __esm({
10519
10519
  "package.json"() {
10520
10520
  package_default = {
10521
10521
  name: "claude-use",
10522
- version: "11.89.1",
10522
+ version: "11.90.0",
10523
10523
  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.",
10524
10524
  license: "MIT",
10525
10525
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -10898,15 +10898,15 @@ function aliasFindings(aliases, providerNames) {
10898
10898
  return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
10899
10899
  });
10900
10900
  }
10901
- var import_zod24, ProviderAliasesSchema;
10901
+ var import_zod25, ProviderAliasesSchema;
10902
10902
  var init_providerAliases = __esm({
10903
10903
  "src/providerAliases.ts"() {
10904
10904
  "use strict";
10905
- import_zod24 = require("zod");
10905
+ import_zod25 = require("zod");
10906
10906
  init_cliError();
10907
10907
  init_load();
10908
10908
  init_store();
10909
- ProviderAliasesSchema = import_zod24.z.record(import_zod24.z.string().min(1), import_zod24.z.string().min(1));
10909
+ ProviderAliasesSchema = import_zod25.z.record(import_zod25.z.string().min(1), import_zod25.z.string().min(1));
10910
10910
  }
10911
10911
  });
10912
10912
 
@@ -11130,14 +11130,14 @@ function requireProviderExists(paths, name) {
11130
11130
  throw new ProviderNotFoundError(name);
11131
11131
  }
11132
11132
  }
11133
- function isRecord7(value) {
11133
+ function isRecord8(value) {
11134
11134
  return typeof value === "object" && value !== null && !Array.isArray(value);
11135
11135
  }
11136
11136
  function legacyProviderConversion(raw) {
11137
- if (!isRecord7(raw) || "credential" in raw) {
11137
+ if (!isRecord8(raw) || "credential" in raw) {
11138
11138
  return void 0;
11139
11139
  }
11140
- const env = isRecord7(raw.env) ? raw.env : void 0;
11140
+ const env = isRecord8(raw.env) ? raw.env : void 0;
11141
11141
  const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
11142
11142
  const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
11143
11143
  if (fields.length === 0) {
@@ -11704,17 +11704,17 @@ function withoutInjected(env) {
11704
11704
  });
11705
11705
  return Object.fromEntries(entries);
11706
11706
  }
11707
- var import_node_crypto13, import_zod25, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
11707
+ var import_node_crypto13, import_zod26, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
11708
11708
  var init_injected = __esm({
11709
11709
  "src/launcher/injected.ts"() {
11710
11710
  "use strict";
11711
11711
  import_node_crypto13 = require("node:crypto");
11712
- import_zod25 = require("zod");
11712
+ import_zod26 = require("zod");
11713
11713
  init_headers();
11714
11714
  INJECTED_ENV = "AGENT_SHIM_INJECTED";
11715
11715
  CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
11716
11716
  HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
11717
- InjectedSchema = import_zod25.z.record(import_zod25.z.string(), import_zod25.z.string());
11717
+ InjectedSchema = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.string());
11718
11718
  }
11719
11719
  });
11720
11720
 
@@ -11889,46 +11889,46 @@ function findPathShadow(params) {
11889
11889
  }
11890
11890
  return params.pathDirs.some((dir) => import_node_path38.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
11891
11891
  }
11892
- var import_node_fs11, import_node_path38, import_zod30, ClaudeShimStateSchema, nodeLinkFs;
11892
+ var import_node_fs11, import_node_path38, import_zod31, ClaudeShimStateSchema, nodeLinkFs;
11893
11893
  var init_claudeShim = __esm({
11894
11894
  "src/claudeShim.ts"() {
11895
11895
  "use strict";
11896
11896
  import_node_fs11 = __toESM(require("node:fs"), 1);
11897
11897
  import_node_path38 = __toESM(require("node:path"), 1);
11898
- import_zod30 = require("zod");
11898
+ import_zod31 = require("zod");
11899
11899
  init_commandDeps();
11900
11900
  init_store();
11901
11901
  init_realPorts();
11902
11902
  init_cliError();
11903
- ClaudeShimStateSchema = import_zod30.z.strictObject({
11904
- targetPath: import_zod30.z.string().min(1),
11905
- method: import_zod30.z.enum(["hardlink", "copy"]),
11906
- installedAtMs: import_zod30.z.number()
11903
+ ClaudeShimStateSchema = import_zod31.z.strictObject({
11904
+ targetPath: import_zod31.z.string().min(1),
11905
+ method: import_zod31.z.enum(["hardlink", "copy"]),
11906
+ installedAtMs: import_zod31.z.number()
11907
11907
  });
11908
11908
  nodeLinkFs = { link: import_node_fs11.default.linkSync, copyFile: import_node_fs11.default.copyFileSync, chmod: import_node_fs11.default.chmodSync };
11909
11909
  }
11910
11910
  });
11911
11911
 
11912
11912
  // src/codex/auth.ts
11913
- var import_zod31, AuthFileSchema, TokenGrantSchema, CodexAuthError;
11913
+ var import_zod32, AuthFileSchema, TokenGrantSchema, CodexAuthError;
11914
11914
  var init_auth = __esm({
11915
11915
  "src/codex/auth.ts"() {
11916
11916
  "use strict";
11917
- import_zod31 = require("zod");
11918
- AuthFileSchema = import_zod31.z.looseObject({
11919
- tokens: import_zod31.z.looseObject({
11920
- access_token: import_zod31.z.string().optional(),
11921
- refresh_token: import_zod31.z.string().optional(),
11922
- id_token: import_zod31.z.string().optional(),
11923
- account_id: import_zod31.z.string().optional()
11917
+ import_zod32 = require("zod");
11918
+ AuthFileSchema = import_zod32.z.looseObject({
11919
+ tokens: import_zod32.z.looseObject({
11920
+ access_token: import_zod32.z.string().optional(),
11921
+ refresh_token: import_zod32.z.string().optional(),
11922
+ id_token: import_zod32.z.string().optional(),
11923
+ account_id: import_zod32.z.string().optional()
11924
11924
  }).nullish(),
11925
- last_refresh: import_zod31.z.string().optional()
11925
+ last_refresh: import_zod32.z.string().optional()
11926
11926
  });
11927
- TokenGrantSchema = import_zod31.z.looseObject({
11928
- access_token: import_zod31.z.string().min(1).optional(),
11929
- refresh_token: import_zod31.z.string().min(1).optional(),
11930
- id_token: import_zod31.z.string().min(1).optional(),
11931
- account_id: import_zod31.z.string().min(1).optional()
11927
+ TokenGrantSchema = import_zod32.z.looseObject({
11928
+ access_token: import_zod32.z.string().min(1).optional(),
11929
+ refresh_token: import_zod32.z.string().min(1).optional(),
11930
+ id_token: import_zod32.z.string().min(1).optional(),
11931
+ account_id: import_zod32.z.string().min(1).optional()
11932
11932
  });
11933
11933
  CodexAuthError = class extends Error {
11934
11934
  constructor(message) {
@@ -11940,31 +11940,31 @@ var init_auth = __esm({
11940
11940
  });
11941
11941
 
11942
11942
  // src/codex/siwc.ts
11943
- var import_zod32, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
11943
+ var import_zod33, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
11944
11944
  var init_siwc = __esm({
11945
11945
  "src/codex/siwc.ts"() {
11946
11946
  "use strict";
11947
- import_zod32 = require("zod");
11947
+ import_zod33 = require("zod");
11948
11948
  SIWC_RESOURCE = "https://api.openai.com/v1";
11949
11949
  SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
11950
11950
  SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
11951
- TokenResponseSchema = import_zod32.z.looseObject({
11952
- access_token: import_zod32.z.string().min(1),
11953
- refresh_token: import_zod32.z.string().min(1).optional(),
11954
- id_token: import_zod32.z.string().min(1).optional(),
11955
- expires_in: import_zod32.z.number().positive(),
11956
- scope: import_zod32.z.string().optional()
11951
+ TokenResponseSchema = import_zod33.z.looseObject({
11952
+ access_token: import_zod33.z.string().min(1),
11953
+ refresh_token: import_zod33.z.string().min(1).optional(),
11954
+ id_token: import_zod33.z.string().min(1).optional(),
11955
+ expires_in: import_zod33.z.number().positive(),
11956
+ scope: import_zod33.z.string().optional()
11957
11957
  });
11958
- JwtHeaderSchema = import_zod32.z.looseObject({ alg: import_zod32.z.string(), kid: import_zod32.z.string().optional() });
11959
- IdTokenClaimsSchema = import_zod32.z.looseObject({
11960
- iss: import_zod32.z.string(),
11961
- sub: import_zod32.z.string().min(1),
11962
- aud: import_zod32.z.union([import_zod32.z.string(), import_zod32.z.array(import_zod32.z.string())]),
11963
- exp: import_zod32.z.number(),
11964
- nonce: import_zod32.z.string().optional(),
11965
- email: import_zod32.z.string().optional()
11958
+ JwtHeaderSchema = import_zod33.z.looseObject({ alg: import_zod33.z.string(), kid: import_zod33.z.string().optional() });
11959
+ IdTokenClaimsSchema = import_zod33.z.looseObject({
11960
+ iss: import_zod33.z.string(),
11961
+ sub: import_zod33.z.string().min(1),
11962
+ aud: import_zod33.z.union([import_zod33.z.string(), import_zod33.z.array(import_zod33.z.string())]),
11963
+ exp: import_zod33.z.number(),
11964
+ nonce: import_zod33.z.string().optional(),
11965
+ email: import_zod33.z.string().optional()
11966
11966
  });
11967
- JwksSchema = import_zod32.z.object({ keys: import_zod32.z.array(import_zod32.z.looseObject({ kid: import_zod32.z.string().optional(), kty: import_zod32.z.string() })) });
11967
+ JwksSchema = import_zod33.z.object({ keys: import_zod33.z.array(import_zod33.z.looseObject({ kid: import_zod33.z.string().optional(), kty: import_zod33.z.string() })) });
11968
11968
  }
11969
11969
  });
11970
11970
 
@@ -11982,25 +11982,25 @@ function parseSiwcFile(raw, filePath) {
11982
11982
  }
11983
11983
  return parsed.data;
11984
11984
  }
11985
- var import_zod33, SiwcGrantSchema, SiwcFileSchema;
11985
+ var import_zod34, SiwcGrantSchema, SiwcFileSchema;
11986
11986
  var init_siwcStore = __esm({
11987
11987
  "src/codex/siwcStore.ts"() {
11988
11988
  "use strict";
11989
- import_zod33 = require("zod");
11989
+ import_zod34 = require("zod");
11990
11990
  init_auth();
11991
11991
  init_siwc();
11992
- SiwcGrantSchema = import_zod33.z.strictObject({
11993
- clientId: import_zod33.z.string().min(1),
11994
- sub: import_zod33.z.string().min(1),
11995
- email: import_zod33.z.string().optional(),
11996
- idToken: import_zod33.z.string().min(1),
11997
- accessToken: import_zod33.z.string().min(1),
11998
- refreshToken: import_zod33.z.string().min(1),
11999
- scopes: import_zod33.z.array(import_zod33.z.string()).readonly(),
11992
+ SiwcGrantSchema = import_zod34.z.strictObject({
11993
+ clientId: import_zod34.z.string().min(1),
11994
+ sub: import_zod34.z.string().min(1),
11995
+ email: import_zod34.z.string().optional(),
11996
+ idToken: import_zod34.z.string().min(1),
11997
+ accessToken: import_zod34.z.string().min(1),
11998
+ refreshToken: import_zod34.z.string().min(1),
11999
+ scopes: import_zod34.z.array(import_zod34.z.string()).readonly(),
12000
12000
  /** When the access token stops working, in milliseconds since the epoch. */
12001
- expiresAt: import_zod33.z.number()
12001
+ expiresAt: import_zod34.z.number()
12002
12002
  });
12003
- SiwcFileSchema = import_zod33.z.strictObject({ registeredClientId: import_zod33.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12003
+ SiwcFileSchema = import_zod34.z.strictObject({ registeredClientId: import_zod34.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
12004
12004
  }
12005
12005
  });
12006
12006
 
@@ -12093,15 +12093,15 @@ function savedCatalogueFingerprint(provider, paths, env, home, read) {
12093
12093
  const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path41.default.join(home, ".codex") : configuredHome;
12094
12094
  return cliCatalogueFingerprint(read(import_node_path41.default.join(codexHome, "auth.json")));
12095
12095
  }
12096
- var import_node_crypto14, import_node_path41, import_zod34, CatalogueBindingSchema;
12096
+ var import_node_crypto14, import_node_path41, import_zod35, CatalogueBindingSchema;
12097
12097
  var init_catalogueCredential = __esm({
12098
12098
  "src/codex/catalogueCredential.ts"() {
12099
12099
  "use strict";
12100
12100
  import_node_crypto14 = require("node:crypto");
12101
12101
  import_node_path41 = __toESM(require("node:path"), 1);
12102
- import_zod34 = require("zod");
12102
+ import_zod35 = require("zod");
12103
12103
  init_siwcStore();
12104
- CatalogueBindingSchema = import_zod34.z.strictObject({ fingerprint: import_zod34.z.string().min(1), source: import_zod34.z.string().min(1), revision: import_zod34.z.string().min(1) });
12104
+ CatalogueBindingSchema = import_zod35.z.strictObject({ fingerprint: import_zod35.z.string().min(1), source: import_zod35.z.string().min(1), revision: import_zod35.z.string().min(1) });
12105
12105
  }
12106
12106
  });
12107
12107
 
@@ -12152,64 +12152,64 @@ var init_signatures = __esm({
12152
12152
  });
12153
12153
 
12154
12154
  // src/codex/anthropic.ts
12155
- var import_zod35, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
12155
+ var import_zod36, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
12156
12156
  var init_anthropic = __esm({
12157
12157
  "src/codex/anthropic.ts"() {
12158
12158
  "use strict";
12159
- import_zod35 = require("zod");
12160
- TextBlockSchema = import_zod35.z.looseObject({ type: import_zod35.z.literal("text"), text: import_zod35.z.string() });
12161
- Base64ImageSourceSchema = import_zod35.z.looseObject({ type: import_zod35.z.literal("base64"), media_type: import_zod35.z.string().min(1), data: import_zod35.z.string() });
12162
- UrlImageSourceSchema = import_zod35.z.looseObject({ type: import_zod35.z.literal("url"), url: import_zod35.z.string().min(1) });
12163
- ImageBlockSchema = import_zod35.z.looseObject({
12164
- type: import_zod35.z.literal("image"),
12165
- source: import_zod35.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
12159
+ import_zod36 = require("zod");
12160
+ TextBlockSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("text"), text: import_zod36.z.string() });
12161
+ Base64ImageSourceSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("base64"), media_type: import_zod36.z.string().min(1), data: import_zod36.z.string() });
12162
+ UrlImageSourceSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("url"), url: import_zod36.z.string().min(1) });
12163
+ ImageBlockSchema = import_zod36.z.looseObject({
12164
+ type: import_zod36.z.literal("image"),
12165
+ source: import_zod36.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
12166
12166
  });
12167
- ToolUseBlockSchema = import_zod35.z.looseObject({
12168
- type: import_zod35.z.literal("tool_use"),
12169
- id: import_zod35.z.string().min(1),
12170
- name: import_zod35.z.string().min(1),
12171
- input: import_zod35.z.unknown()
12167
+ ToolUseBlockSchema = import_zod36.z.looseObject({
12168
+ type: import_zod36.z.literal("tool_use"),
12169
+ id: import_zod36.z.string().min(1),
12170
+ name: import_zod36.z.string().min(1),
12171
+ input: import_zod36.z.unknown()
12172
12172
  });
12173
- ToolResultContentBlockSchema = import_zod35.z.union([TextBlockSchema, import_zod35.z.looseObject({ type: import_zod35.z.string() })]);
12174
- ToolResultBlockSchema = import_zod35.z.looseObject({
12175
- type: import_zod35.z.literal("tool_result"),
12176
- tool_use_id: import_zod35.z.string().min(1),
12177
- content: import_zod35.z.union([import_zod35.z.string(), import_zod35.z.array(ToolResultContentBlockSchema)]).optional()
12173
+ ToolResultContentBlockSchema = import_zod36.z.union([TextBlockSchema, import_zod36.z.looseObject({ type: import_zod36.z.string() })]);
12174
+ ToolResultBlockSchema = import_zod36.z.looseObject({
12175
+ type: import_zod36.z.literal("tool_result"),
12176
+ tool_use_id: import_zod36.z.string().min(1),
12177
+ content: import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(ToolResultContentBlockSchema)]).optional()
12178
12178
  });
12179
- OtherBlockSchema = import_zod35.z.looseObject({ type: import_zod35.z.string() });
12180
- ContentBlockSchema = import_zod35.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
12181
- MessageSchema = import_zod35.z.looseObject({
12182
- role: import_zod35.z.enum(["user", "assistant", "system"]),
12183
- content: import_zod35.z.union([import_zod35.z.string(), import_zod35.z.array(ContentBlockSchema)])
12179
+ OtherBlockSchema = import_zod36.z.looseObject({ type: import_zod36.z.string() });
12180
+ ContentBlockSchema = import_zod36.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
12181
+ MessageSchema = import_zod36.z.looseObject({
12182
+ role: import_zod36.z.enum(["user", "assistant", "system"]),
12183
+ content: import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(ContentBlockSchema)])
12184
12184
  });
12185
- ToolSchema = import_zod35.z.looseObject({
12186
- name: import_zod35.z.string().min(1),
12187
- description: import_zod35.z.string().optional(),
12188
- input_schema: import_zod35.z.record(import_zod35.z.string(), import_zod35.z.unknown()).optional(),
12189
- allowed_domains: import_zod35.z.array(import_zod35.z.string()).optional(),
12190
- blocked_domains: import_zod35.z.array(import_zod35.z.string()).optional()
12185
+ ToolSchema = import_zod36.z.looseObject({
12186
+ name: import_zod36.z.string().min(1),
12187
+ description: import_zod36.z.string().optional(),
12188
+ input_schema: import_zod36.z.record(import_zod36.z.string(), import_zod36.z.unknown()).optional(),
12189
+ allowed_domains: import_zod36.z.array(import_zod36.z.string()).optional(),
12190
+ blocked_domains: import_zod36.z.array(import_zod36.z.string()).optional()
12191
12191
  });
12192
- ToolChoiceSchema = import_zod35.z.union([
12193
- import_zod35.z.looseObject({ type: import_zod35.z.enum(["auto", "none", "any"]) }),
12194
- import_zod35.z.looseObject({ type: import_zod35.z.literal("tool"), name: import_zod35.z.string().min(1) })
12192
+ ToolChoiceSchema = import_zod36.z.union([
12193
+ import_zod36.z.looseObject({ type: import_zod36.z.enum(["auto", "none", "any"]) }),
12194
+ import_zod36.z.looseObject({ type: import_zod36.z.literal("tool"), name: import_zod36.z.string().min(1) })
12195
12195
  ]);
12196
- SystemSchema = import_zod35.z.union([import_zod35.z.string(), import_zod35.z.array(import_zod35.z.union([TextBlockSchema, OtherBlockSchema]))]);
12197
- MessagesRequestSchema = import_zod35.z.looseObject({
12198
- model: import_zod35.z.string().optional(),
12196
+ SystemSchema = import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(import_zod36.z.union([TextBlockSchema, OtherBlockSchema]))]);
12197
+ MessagesRequestSchema = import_zod36.z.looseObject({
12198
+ model: import_zod36.z.string().optional(),
12199
12199
  system: SystemSchema.optional(),
12200
- messages: import_zod35.z.array(MessageSchema),
12201
- tools: import_zod35.z.array(ToolSchema).optional(),
12200
+ messages: import_zod36.z.array(MessageSchema),
12201
+ tools: import_zod36.z.array(ToolSchema).optional(),
12202
12202
  tool_choice: ToolChoiceSchema.optional(),
12203
- stream: import_zod35.z.boolean().optional(),
12203
+ stream: import_zod36.z.boolean().optional(),
12204
12204
  /** `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. */
12205
- metadata: import_zod35.z.looseObject({ user_id: import_zod35.z.string().optional() }).optional(),
12205
+ metadata: import_zod36.z.looseObject({ user_id: import_zod36.z.string().optional() }).optional(),
12206
12206
  /** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
12207
- output_config: import_zod35.z.looseObject({ effort: import_zod35.z.string().optional(), format: import_zod35.z.object({ type: import_zod35.z.literal("json_schema"), schema: import_zod35.z.record(import_zod35.z.string(), import_zod35.z.unknown()) }).optional() }).optional()
12207
+ output_config: import_zod36.z.looseObject({ effort: import_zod36.z.string().optional(), format: import_zod36.z.object({ type: import_zod36.z.literal("json_schema"), schema: import_zod36.z.record(import_zod36.z.string(), import_zod36.z.unknown()) }).optional() }).optional()
12208
12208
  });
12209
- CountTokensRequestSchema = import_zod35.z.looseObject({
12210
- system: import_zod35.z.unknown().optional(),
12211
- messages: import_zod35.z.unknown().optional(),
12212
- tools: import_zod35.z.unknown().optional()
12209
+ CountTokensRequestSchema = import_zod36.z.looseObject({
12210
+ system: import_zod36.z.unknown().optional(),
12211
+ messages: import_zod36.z.unknown().optional(),
12212
+ tools: import_zod36.z.unknown().optional()
12213
12213
  });
12214
12214
  }
12215
12215
  });
@@ -13565,7 +13565,7 @@ function withLauncherSettings(passthrough, settings) {
13565
13565
  }
13566
13566
  return [...kept, "--settings", settings, ...tail];
13567
13567
  }
13568
- function isRecord15(value) {
13568
+ function isRecord16(value) {
13569
13569
  return typeof value === "object" && value !== null && !Array.isArray(value);
13570
13570
  }
13571
13571
  function mergeSettings(parts) {
@@ -13576,7 +13576,7 @@ function mergeSettings(parts) {
13576
13576
  continue;
13577
13577
  }
13578
13578
  const parsed = JSON.parse(part);
13579
- if (!isRecord15(parsed)) {
13579
+ if (!isRecord16(parsed)) {
13580
13580
  throw new Error("a launch's settings part is not a JSON object");
13581
13581
  }
13582
13582
  for (const [key, value] of Object.entries(parsed)) {
@@ -15260,11 +15260,11 @@ var init_identityClaude = __esm({
15260
15260
  });
15261
15261
 
15262
15262
  // src/usage/providerQuota.ts
15263
- var import_zod44, 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;
15263
+ var import_zod45, 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;
15264
15264
  var init_providerQuota = __esm({
15265
15265
  "src/usage/providerQuota.ts"() {
15266
15266
  "use strict";
15267
- import_zod44 = require("zod");
15267
+ import_zod45 = require("zod");
15268
15268
  init_cloudUpstream();
15269
15269
  init_schema2();
15270
15270
  MS_PER_SECOND9 = 1e3;
@@ -15279,35 +15279,35 @@ var init_providerQuota = __esm({
15279
15279
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
15280
15280
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
15281
15281
  ]);
15282
- ZaiLimitSchema = import_zod44.z.object({
15283
- type: import_zod44.z.string(),
15284
- unit: import_zod44.z.number().int(),
15285
- number: import_zod44.z.number().int().positive(),
15286
- percentage: import_zod44.z.number().nonnegative(),
15287
- nextResetTime: import_zod44.z.number().positive().optional(),
15288
- usage: import_zod44.z.number().nonnegative().optional(),
15289
- currentValue: import_zod44.z.number().nonnegative().optional(),
15290
- remaining: import_zod44.z.number().nonnegative().optional()
15282
+ ZaiLimitSchema = import_zod45.z.object({
15283
+ type: import_zod45.z.string(),
15284
+ unit: import_zod45.z.number().int(),
15285
+ number: import_zod45.z.number().int().positive(),
15286
+ percentage: import_zod45.z.number().nonnegative(),
15287
+ nextResetTime: import_zod45.z.number().positive().optional(),
15288
+ usage: import_zod45.z.number().nonnegative().optional(),
15289
+ currentValue: import_zod45.z.number().nonnegative().optional(),
15290
+ remaining: import_zod45.z.number().nonnegative().optional()
15291
15291
  });
15292
- ZaiResponseSchema = import_zod44.z.object({
15293
- success: import_zod44.z.boolean(),
15294
- msg: import_zod44.z.string().optional(),
15295
- data: import_zod44.z.object({ level: import_zod44.z.string().optional(), limits: import_zod44.z.array(ZaiLimitSchema) })
15292
+ ZaiResponseSchema = import_zod45.z.object({
15293
+ success: import_zod45.z.boolean(),
15294
+ msg: import_zod45.z.string().optional(),
15295
+ data: import_zod45.z.object({ level: import_zod45.z.string().optional(), limits: import_zod45.z.array(ZaiLimitSchema) })
15296
15296
  });
15297
15297
  OPENROUTER_HOST = "openrouter.ai";
15298
15298
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
15299
15299
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
15300
15300
  MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15301
- OpenRouterKeySchema = import_zod44.z.object({
15302
- data: import_zod44.z.object({
15303
- limit: import_zod44.z.number().nonnegative().nullable(),
15304
- limit_remaining: import_zod44.z.number().nullable(),
15305
- limit_reset: import_zod44.z.string().nullable(),
15306
- is_free_tier: import_zod44.z.boolean().optional(),
15307
- free_model_daily_requests: import_zod44.z.object({ used: import_zod44.z.number().nonnegative(), limit: import_zod44.z.number().nonnegative(), remaining: import_zod44.z.number() }).optional()
15301
+ OpenRouterKeySchema = import_zod45.z.object({
15302
+ data: import_zod45.z.object({
15303
+ limit: import_zod45.z.number().nonnegative().nullable(),
15304
+ limit_remaining: import_zod45.z.number().nullable(),
15305
+ limit_reset: import_zod45.z.string().nullable(),
15306
+ is_free_tier: import_zod45.z.boolean().optional(),
15307
+ free_model_daily_requests: import_zod45.z.object({ used: import_zod45.z.number().nonnegative(), limit: import_zod45.z.number().nonnegative(), remaining: import_zod45.z.number() }).optional()
15308
15308
  })
15309
15309
  });
15310
- OpenRouterCreditsSchema = import_zod44.z.object({ data: import_zod44.z.object({ total_credits: import_zod44.z.number().nonnegative(), total_usage: import_zod44.z.number().nonnegative() }) });
15310
+ OpenRouterCreditsSchema = import_zod45.z.object({ data: import_zod45.z.object({ total_credits: import_zod45.z.number().nonnegative(), total_usage: import_zod45.z.number().nonnegative() }) });
15311
15311
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
15312
15312
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
15313
15313
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
@@ -15315,21 +15315,21 @@ var init_providerQuota = __esm({
15315
15315
  DAYS_PER_WEEK2 = 7;
15316
15316
  FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15317
15317
  WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15318
- AntigravityBucketSchema = import_zod44.z.object({
15319
- bucketId: import_zod44.z.string(),
15320
- remainingFraction: import_zod44.z.number().optional(),
15321
- resetTime: import_zod44.z.string().optional()
15318
+ AntigravityBucketSchema = import_zod45.z.object({
15319
+ bucketId: import_zod45.z.string(),
15320
+ remainingFraction: import_zod45.z.number().optional(),
15321
+ resetTime: import_zod45.z.string().optional()
15322
15322
  });
15323
- AntigravitySummarySchema = import_zod44.z.object({ groups: import_zod44.z.array(import_zod44.z.object({ buckets: import_zod44.z.array(AntigravityBucketSchema) })) });
15324
- GoogleTokenInfoSchema = import_zod44.z.object({
15325
- email: import_zod44.z.string().optional(),
15326
- sub: import_zod44.z.string().optional()
15323
+ AntigravitySummarySchema = import_zod45.z.object({ groups: import_zod45.z.array(import_zod45.z.object({ buckets: import_zod45.z.array(AntigravityBucketSchema) })) });
15324
+ GoogleTokenInfoSchema = import_zod45.z.object({
15325
+ email: import_zod45.z.string().optional(),
15326
+ sub: import_zod45.z.string().optional()
15327
15327
  });
15328
- AntigravityUserSchema = import_zod44.z.object({
15328
+ AntigravityUserSchema = import_zod45.z.object({
15329
15329
  /** The code-assist tier context, which defaults to the free tier for every account. */
15330
- currentTier: import_zod44.z.object({ name: import_zod44.z.string().optional(), id: import_zod44.z.string().optional() }).optional(),
15330
+ currentTier: import_zod45.z.object({ name: import_zod45.z.string().optional(), id: import_zod45.z.string().optional() }).optional(),
15331
15331
  /** The account's paid subscription; absent when the account has none. */
15332
- paidTier: import_zod44.z.object({ name: import_zod44.z.string().optional(), id: import_zod44.z.string().optional() }).optional()
15332
+ paidTier: import_zod45.z.object({ name: import_zod45.z.string().optional(), id: import_zod45.z.string().optional() }).optional()
15333
15333
  });
15334
15334
  }
15335
15335
  });
@@ -15549,6 +15549,8 @@ __export(index_exports, {
15549
15549
  QUOTA_EXPIRING_EVENT_SOURCE: () => QUOTA_EXPIRING_EVENT_SOURCE,
15550
15550
  QuotaExpiringEventSchema: () => QuotaExpiringEventSchema,
15551
15551
  RC_CONTEXT_USAGE_DETAILS: () => RC_CONTEXT_USAGE_DETAILS,
15552
+ RC_GOAL_CLEAR_WORDS: () => RC_GOAL_CLEAR_WORDS,
15553
+ RC_GOAL_CONDITION_MAX_CHARS: () => RC_GOAL_CONDITION_MAX_CHARS,
15552
15554
  RC_IDLE_EXPIRY_MS: () => RC_IDLE_EXPIRY_MS,
15553
15555
  RC_ORPC_PATH_PREFIX: () => RC_ORPC_PATH_PREFIX,
15554
15556
  RC_PENDING_DEADLINE_MS: () => RC_PENDING_DEADLINE_MS,
@@ -15564,6 +15566,8 @@ __export(index_exports, {
15564
15566
  RC_SELF_HOST_SCOPE_LIST: () => RC_SELF_HOST_SCOPE_LIST,
15565
15567
  RC_SELF_HOST_WORKER_JWT_TTL_SECONDS: () => RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
15566
15568
  RC_SESSIONS_PATH_PREFIX: () => RC_SESSIONS_PATH_PREFIX,
15569
+ RC_SESSION_COMMAND_MAX_WAIT_MS: () => RC_SESSION_COMMAND_MAX_WAIT_MS,
15570
+ RC_SESSION_COMMAND_VERIFIED_VERSIONS: () => RC_SESSION_COMMAND_VERIFIED_VERSIONS,
15567
15571
  RC_SESSION_END_REASONS: () => RC_SESSION_END_REASONS,
15568
15572
  RC_SESSION_EVENT_LOG_CAPACITY: () => RC_SESSION_EVENT_LOG_CAPACITY,
15569
15573
  RC_STREAM_BACKOFF_MS: () => RC_STREAM_BACKOFF_MS,
@@ -15659,11 +15663,13 @@ __export(index_exports, {
15659
15663
  createQuotaExpiringPublisher: () => createQuotaExpiringPublisher,
15660
15664
  createRcApiNodeHandler: () => createRcApiNodeHandler,
15661
15665
  createRcApiRouter: () => createRcApiRouter,
15666
+ createRcClaudeCodeVersions: () => createRcClaudeCodeVersions,
15662
15667
  createRcControlHandler: () => createRcControlHandler,
15663
15668
  createRcCredentialStore: () => createRcCredentialStore,
15664
15669
  createRcEventFanout: () => createRcEventFanout,
15665
15670
  createRcLiveUsage: () => createRcLiveUsage,
15666
15671
  createRcSelfHostSurface: () => createRcSelfHostSurface,
15672
+ createRcSessionCommands: () => createRcSessionCommands,
15667
15673
  createRcSessionEventLog: () => createRcSessionEventLog,
15668
15674
  createRcSessionEventsApiRouter: () => createRcSessionEventsApiRouter,
15669
15675
  createRcSessionRegistryReader: () => createRcSessionRegistryReader,
@@ -15726,6 +15732,7 @@ __export(index_exports, {
15726
15732
  mintRcSelfHostCredential: () => mintRcSelfHostCredential,
15727
15733
  observingRoutedRoute: () => observingRoutedRoute,
15728
15734
  parseConnectTarget: () => parseConnectTarget,
15735
+ parseRcGoalOutput: () => parseRcGoalOutput,
15729
15736
  parseRcStreamEnvelope: () => parseRcStreamEnvelope,
15730
15737
  planOf: () => planOf,
15731
15738
  poolIdentities: () => poolIdentities,
@@ -15737,6 +15744,8 @@ __export(index_exports, {
15737
15744
  rankPool: () => rankPool,
15738
15745
  rcEventWriteResultFromAnswer: () => rcEventWriteResultFromAnswer,
15739
15746
  rcFanoutOnDoorHub: () => rcFanoutOnDoorHub,
15747
+ rcLocalCommandAnswerOf: () => rcLocalCommandAnswerOf,
15748
+ rcManualCompactBoundaryOf: () => rcManualCompactBoundaryOf,
15740
15749
  rcObserverAsPassthrough: () => rcObserverAsPassthrough,
15741
15750
  rcRateLimitInfoOf: () => rcRateLimitInfoOf,
15742
15751
  rcSelfHostFromEnv: () => rcSelfHostFromEnv,
@@ -16391,9 +16400,11 @@ function createRcSessionTracker(deps) {
16391
16400
  if (id?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
16392
16401
  return void 0;
16393
16402
  }
16403
+ const isClientWrite = method === "POST" && (rest === `${id}/events` || rest === `${id}/teleport-events`);
16404
+ const sessionFacts = isClientWrite ? { ...facts, anthropicClientPlatform: void 0 } : facts;
16394
16405
  const tracked = entries.get(id);
16395
16406
  if (tracked !== void 0) {
16396
- refresh(tracked, facts);
16407
+ refresh(tracked, sessionFacts);
16397
16408
  }
16398
16409
  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;
16399
16410
  let chunks = [];
@@ -16463,7 +16474,7 @@ function createRcSessionTracker(deps) {
16463
16474
  }
16464
16475
  accepted = isSuccessful(status);
16465
16476
  if (accepted && !entries.has(id)) {
16466
- persistCredential(birth(id, facts));
16477
+ persistCredential(birth(id, sessionFacts));
16467
16478
  }
16468
16479
  file();
16469
16480
  },
@@ -18188,6 +18199,11 @@ var import_server2 = require("@orpc/server");
18188
18199
  var import_node2 = require("@orpc/server/node");
18189
18200
  var import_undici = require("undici");
18190
18201
  init_package();
18202
+
18203
+ // src/supervise/compactTimeout.ts
18204
+ var COMPACT_TIMEOUT_MS = 9e5;
18205
+
18206
+ // src/frontdoor/rcApi.ts
18191
18207
  init_capability();
18192
18208
 
18193
18209
  // src/frontdoor/rcSchemas.ts
@@ -18359,6 +18375,438 @@ var RcAnswerOutputSchema = import_zod22.z.strictObject({
18359
18375
  sequenceNums: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.number()))
18360
18376
  });
18361
18377
 
18378
+ // src/frontdoor/rcSlashCommandSchemas.ts
18379
+ var import_zod23 = require("zod");
18380
+
18381
+ // src/frontdoor/rcSessionCommands.ts
18382
+ var import_promises = require("node:timers/promises");
18383
+
18384
+ // src/supervise/sessionControl.ts
18385
+ var RESULT_POLL_MS = 250;
18386
+ var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
18387
+
18388
+ // src/frontdoor/rcSelfHostCommands.ts
18389
+ var RC_PERSON_CLIENT_PLATFORM = "web_claude_ai";
18390
+ async function writeRcPersonMessage(deps, sessionId, text) {
18391
+ const credential = deps.credentialOf(sessionId);
18392
+ if (credential === void 0) {
18393
+ return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
18394
+ }
18395
+ if (credential.authorization === void 0) {
18396
+ return noOAuthCredentialResult(sessionId);
18397
+ }
18398
+ const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text)));
18399
+ const bytes = Buffer.byteLength(body, "utf8");
18400
+ if (bytes > CONTROL_BODY_CAP_BYTES) {
18401
+ 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` };
18402
+ }
18403
+ let answer;
18404
+ try {
18405
+ answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders({ ...credential, anthropicClientPlatform: RC_PERSON_CLIENT_PLATFORM }), body);
18406
+ } catch (error) {
18407
+ 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)}` };
18408
+ }
18409
+ const result = rcEventWriteResultFromAnswer(answer);
18410
+ if (result.ok) {
18411
+ deps.noteSequenceNums(sessionId, result.sequenceNums);
18412
+ }
18413
+ return result;
18414
+ }
18415
+ function isRecord7(value) {
18416
+ return typeof value === "object" && value !== null && !Array.isArray(value);
18417
+ }
18418
+ function rcLocalCommandAnswerOf(event, command, args) {
18419
+ const payload = event.envelope.payload;
18420
+ if (!isRecord7(payload) || payload.type !== "assistant" || !isRecord7(payload.local_command_run) || payload.local_command_run.command !== command || payload.local_command_run.args !== args) {
18421
+ return void 0;
18422
+ }
18423
+ const message = payload.message;
18424
+ if (!isRecord7(message) || !Array.isArray(message.content)) {
18425
+ return void 0;
18426
+ }
18427
+ const blocks = message.content;
18428
+ const text = blocks.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
18429
+ const outcome = isRecord7(payload.local_command_outcome) && typeof payload.local_command_outcome.kind === "string" ? payload.local_command_outcome.kind : void 0;
18430
+ return { text, outcome };
18431
+ }
18432
+ function rcManualCompactBoundaryOf(event) {
18433
+ const payload = event.envelope.payload;
18434
+ if (!isRecord7(payload) || payload.type !== "system" || payload.subtype !== "compact_boundary" || !isRecord7(payload.compact_metadata)) {
18435
+ return void 0;
18436
+ }
18437
+ const metadata = payload.compact_metadata;
18438
+ if (metadata.trigger !== "manual" || typeof metadata.pre_tokens !== "number" || typeof metadata.post_tokens !== "number") {
18439
+ return void 0;
18440
+ }
18441
+ return { trigger: metadata.trigger, preTokens: metadata.pre_tokens, postTokens: metadata.post_tokens };
18442
+ }
18443
+ function isPeerDelivery(event, text) {
18444
+ const payload = event.envelope.payload;
18445
+ if (!isRecord7(payload) || payload.type !== "user" || !isRecord7(payload.origin) || payload.origin.kind !== "peer" || !isRecord7(payload.message)) {
18446
+ return false;
18447
+ }
18448
+ return typeof payload.message.content === "string" && payload.message.content.includes(text);
18449
+ }
18450
+ var NO_GOAL_PREFIX = "No goal set";
18451
+ var ACTIVE_GOAL_PATTERN = /^Goal active: (?<condition>[\s\S]*?) \((?:not yet evaluated|(?<iterations>\d+) turns?)\)(?:\nLast check: (?<lastCheck>[\s\S]*))?$/u;
18452
+ function parseRcGoalOutput(output) {
18453
+ if (output.startsWith(NO_GOAL_PREFIX)) {
18454
+ return { goal: null };
18455
+ }
18456
+ const groups = ACTIVE_GOAL_PATTERN.exec(output)?.groups;
18457
+ const condition = groups?.condition;
18458
+ if (condition === void 0) {
18459
+ return void 0;
18460
+ }
18461
+ return { goal: { condition, iterations: groups?.iterations === void 0 ? 0 : Number(groups.iterations), ...groups?.lastCheck === void 0 ? {} : { lastCheck: groups.lastCheck } } };
18462
+ }
18463
+ var GOAL_CLEARED_PREFIX = "Goal cleared: ";
18464
+ var GOAL_SET_PREFIX = "Goal set: ";
18465
+ function commandLine(command) {
18466
+ if (command.kind === "goal-set") {
18467
+ return { name: "goal", args: command.condition };
18468
+ }
18469
+ if (command.kind === "compact") {
18470
+ return { name: "compact", args: command.instructions ?? "" };
18471
+ }
18472
+ return { name: "goal", args: command.kind === "goal-clear" ? "clear" : "" };
18473
+ }
18474
+ function recognise(command, event, name, args) {
18475
+ if (command.kind === "compact") {
18476
+ const boundary = rcManualCompactBoundaryOf(event);
18477
+ if (boundary !== void 0) {
18478
+ return { ok: true, report: boundary };
18479
+ }
18480
+ }
18481
+ const answer = rcLocalCommandAnswerOf(event, name, args);
18482
+ if (answer === void 0) {
18483
+ return void 0;
18484
+ }
18485
+ if (answer.outcome === "failed") {
18486
+ return { ok: false, message: `the worker reported /${name} failed: ${answer.text}` };
18487
+ }
18488
+ if (command.kind === "goal-get") {
18489
+ const report = parseRcGoalOutput(answer.text);
18490
+ return report === void 0 ? { ok: false, message: `the worker answered /goal with text the verified versions never produce: ${answer.text}` } : { ok: true, report };
18491
+ }
18492
+ if (command.kind === "goal-set") {
18493
+ 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}` };
18494
+ }
18495
+ if (command.kind === "goal-clear") {
18496
+ if (answer.text.startsWith(GOAL_CLEARED_PREFIX)) {
18497
+ return { ok: true, report: { cleared: answer.text.slice(GOAL_CLEARED_PREFIX.length) } };
18498
+ }
18499
+ 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}` };
18500
+ }
18501
+ return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
18502
+ }
18503
+ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
18504
+ const { name, args } = commandLine(command);
18505
+ const text = args === "" ? `/${name}` : `/${name} ${args}`;
18506
+ const early = [];
18507
+ let after;
18508
+ let settle;
18509
+ const judge = (event) => {
18510
+ if (after === void 0) {
18511
+ early.push(event);
18512
+ return;
18513
+ }
18514
+ if (event.envelope.sequence_num <= after || event.envelope.source !== "worker") {
18515
+ return;
18516
+ }
18517
+ if (isPeerDelivery(event, text)) {
18518
+ 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` });
18519
+ return;
18520
+ }
18521
+ const outcome = recognise(command, event, name, args);
18522
+ if (outcome !== void 0) {
18523
+ settle?.(outcome);
18524
+ }
18525
+ };
18526
+ const detach = deps.fanout.subscribe(sessionId, judge);
18527
+ let cancelTimer;
18528
+ const onAbort = () => {
18529
+ settle?.({ ok: false, message: `the request for ${text} on session ${sessionId} was aborted before the worker answered` });
18530
+ };
18531
+ signal.addEventListener("abort", onAbort, { once: true });
18532
+ try {
18533
+ const answered = new Promise((resolve) => {
18534
+ settle = resolve;
18535
+ });
18536
+ const written = await writeRcPersonMessage(deps.personWrite, sessionId, text);
18537
+ if (!written.ok) {
18538
+ return written;
18539
+ }
18540
+ if (signal.aborted) {
18541
+ return { ok: false, message: `the request for ${text} on session ${sessionId} was aborted after it was written (sequence_num ${written.sequenceNums.join(", ")})` };
18542
+ }
18543
+ after = Math.max(...written.sequenceNums);
18544
+ const bound = waitMs ?? deps.defaultWaitMs;
18545
+ cancelTimer = deps.setTimer(() => {
18546
+ 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` });
18547
+ }, bound);
18548
+ for (const event of early.splice(0)) {
18549
+ judge(event);
18550
+ }
18551
+ return await answered;
18552
+ } finally {
18553
+ signal.removeEventListener("abort", onAbort);
18554
+ cancelTimer?.();
18555
+ detach();
18556
+ }
18557
+ }
18558
+ function createRcClaudeCodeVersions(fanout) {
18559
+ const versions = /* @__PURE__ */ new Map();
18560
+ fanout.subscribe(void 0, (event) => {
18561
+ const payload = event.envelope.payload;
18562
+ if (event.envelope.source === "worker" && isRecord7(payload) && payload.type === "system" && payload.subtype === "init" && typeof payload.claude_code_version === "string") {
18563
+ versions.set(event.session, payload.claude_code_version);
18564
+ }
18565
+ });
18566
+ return {
18567
+ versionOf: (sessionId) => versions.get(sessionId),
18568
+ sweep: (isTracked) => {
18569
+ for (const sessionId of [...versions.keys()]) {
18570
+ if (!isTracked(sessionId)) {
18571
+ versions.delete(sessionId);
18572
+ }
18573
+ }
18574
+ }
18575
+ };
18576
+ }
18577
+
18578
+ // src/frontdoor/rcSessionCommands.ts
18579
+ var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
18580
+ var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
18581
+ var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
18582
+ var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
18583
+ var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
18584
+ var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
18585
+ function unverifiedVersionMessage(sessionId, version, source) {
18586
+ const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
18587
+ 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`;
18588
+ }
18589
+ function unsupportedMessage(sessionId) {
18590
+ 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.`;
18591
+ }
18592
+ function createRcSessionCommands(deps) {
18593
+ const queues = /* @__PURE__ */ new Map();
18594
+ const serialised = async (sessionId, work) => {
18595
+ const before = queues.get(sessionId) ?? Promise.resolve();
18596
+ const run = before.then(work, work);
18597
+ const settled = run.then(() => void 0, () => void 0);
18598
+ queues.set(sessionId, settled);
18599
+ try {
18600
+ return await run;
18601
+ } finally {
18602
+ if (queues.get(sessionId) === settled) {
18603
+ queues.delete(sessionId);
18604
+ }
18605
+ }
18606
+ };
18607
+ const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
18608
+ const signal = options.signal ?? new AbortController().signal;
18609
+ if (signal.aborted) {
18610
+ return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
18611
+ }
18612
+ const target = await deps.supervisedOf(sessionId);
18613
+ if (target !== void 0 && "refused" in target) {
18614
+ return { ok: false, message: target.refused };
18615
+ }
18616
+ if (target !== void 0) {
18617
+ if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
18618
+ return { ok: false, message: unverifiedVersionMessage(sessionId, target.version, "its supervisor's control plugin has not loaded") };
18619
+ }
18620
+ const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
18621
+ const timeout = AbortSignal.timeout(waitMs);
18622
+ const bounded3 = AbortSignal.any([signal, timeout]);
18623
+ try {
18624
+ return await actions.supervised(target, bounded3, waitMs);
18625
+ } catch (error) {
18626
+ if (timeout.aborted) {
18627
+ 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` };
18628
+ }
18629
+ return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
18630
+ }
18631
+ }
18632
+ if (!deps.isObserved(sessionId)) {
18633
+ return { ok: false, message: `the front door has not observed Remote Control session ${sessionId}` };
18634
+ }
18635
+ if (deps.selfHost !== void 0) {
18636
+ const unavailable = deps.selfHost.unavailable();
18637
+ if (unavailable !== void 0) {
18638
+ 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}` };
18639
+ }
18640
+ const version = deps.selfHost.versionOf(sessionId);
18641
+ if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
18642
+ 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") };
18643
+ }
18644
+ const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
18645
+ const timeout = AbortSignal.timeout(waitMs);
18646
+ const result = await actions.selfHosted(deps.selfHost, AbortSignal.any([signal, timeout]));
18647
+ if (!result.ok && timeout.aborted) {
18648
+ 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` };
18649
+ }
18650
+ return result;
18651
+ }
18652
+ return { ok: false, message: unsupportedMessage(sessionId) };
18653
+ });
18654
+ const transcriptGoal = async (sessionId, target) => {
18655
+ const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
18656
+ if (goal === void 0) {
18657
+ 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` };
18658
+ }
18659
+ return { ok: true, report: goal };
18660
+ };
18661
+ const settledGoal = async (sessionId, target, signal, holds) => {
18662
+ for (; ; ) {
18663
+ const read = await transcriptGoal(sessionId, target);
18664
+ if (!read.ok || holds(read.report) || signal.aborted) {
18665
+ return read;
18666
+ }
18667
+ await (0, import_promises.setTimeout)(RESULT_POLL_MS);
18668
+ }
18669
+ };
18670
+ const waitOf = (options) => options.waitMs;
18671
+ return {
18672
+ /** 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. */
18673
+ goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
18674
+ supervised: async (target) => {
18675
+ const read = await transcriptGoal(sessionId, target);
18676
+ return await Promise.resolve(read.ok ? { ok: true, report: { route: "supervised", goal: read.report } } : read);
18677
+ },
18678
+ selfHosted: async (selfHost, signal) => {
18679
+ const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
18680
+ return read.ok ? { ok: true, report: { route: "self-hosted", goal: read.report.goal } } : read;
18681
+ }
18682
+ }),
18683
+ /**
18684
+ * 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.
18685
+ */
18686
+ goalSet: async (sessionId, condition, options = {}) => {
18687
+ const trimmed = condition.trim();
18688
+ if (trimmed === "") {
18689
+ return { ok: false, message: "a goal set needs a non-empty condition" };
18690
+ }
18691
+ if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
18692
+ 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` };
18693
+ }
18694
+ if (/[\r\n]/u.test(trimmed)) {
18695
+ 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" };
18696
+ }
18697
+ if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
18698
+ return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
18699
+ }
18700
+ return await onRoute(sessionId, options, {
18701
+ supervised: async (target, signal, waitMs) => {
18702
+ const before = await transcriptGoal(sessionId, target);
18703
+ if (!before.ok) {
18704
+ return before;
18705
+ }
18706
+ await target.runGoal(trimmed, signal, waitMs);
18707
+ const after = await settledGoal(sessionId, target, signal, (goal) => goal?.condition === trimmed);
18708
+ if (!after.ok) {
18709
+ return after;
18710
+ }
18711
+ 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` };
18712
+ },
18713
+ selfHosted: async (selfHost, signal) => {
18714
+ const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
18715
+ if (!before.ok) {
18716
+ return before;
18717
+ }
18718
+ const set = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-set", condition: trimmed }, waitOf(options), signal);
18719
+ return set.ok ? { ok: true, report: { route: "self-hosted", condition: set.report.condition, superseded: before.report.goal?.condition ?? null } } : set;
18720
+ }
18721
+ });
18722
+ },
18723
+ /** 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). */
18724
+ goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
18725
+ supervised: async (target, signal, waitMs) => {
18726
+ const before = await transcriptGoal(sessionId, target);
18727
+ if (!before.ok) {
18728
+ return before;
18729
+ }
18730
+ if (before.report === null) {
18731
+ return { ok: true, report: { route: "supervised", cleared: null } };
18732
+ }
18733
+ await target.runGoal("clear", signal, waitMs);
18734
+ const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
18735
+ if (!after.ok) {
18736
+ return after;
18737
+ }
18738
+ 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}"` };
18739
+ },
18740
+ selfHosted: async (selfHost, signal) => {
18741
+ const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
18742
+ return cleared.ok ? { ok: true, report: { route: "self-hosted", cleared: cleared.report.cleared } } : cleared;
18743
+ }
18744
+ }),
18745
+ /** 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. */
18746
+ compact: async (sessionId, options = {}) => {
18747
+ const instructions = options.instructions?.trim();
18748
+ const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
18749
+ return await onRoute(sessionId, options, {
18750
+ supervised: async (target, signal, waitMs) => {
18751
+ const result = await target.compact(signal, given, waitMs);
18752
+ if (result.kind === "unchanged") {
18753
+ return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
18754
+ }
18755
+ return { ok: true, report: { route: "supervised", trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
18756
+ },
18757
+ selfHosted: async (selfHost, signal) => {
18758
+ const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
18759
+ return compacted.ok ? { ok: true, report: { route: "self-hosted", ...compacted.report } } : compacted;
18760
+ }
18761
+ });
18762
+ }
18763
+ };
18764
+ }
18765
+
18766
+ // src/frontdoor/rcSlashCommandSchemas.ts
18767
+ var WaitMsSchema = import_zod23.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
18768
+ var RcGoalSessionInputSchema = import_zod23.z.strictObject({
18769
+ session: import_zod23.z.string().min(1),
18770
+ waitMs: WaitMsSchema
18771
+ });
18772
+ var RcGoalSetInputSchema = import_zod23.z.strictObject({
18773
+ session: import_zod23.z.string().min(1),
18774
+ condition: import_zod23.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
18775
+ waitMs: WaitMsSchema
18776
+ });
18777
+ var RcCompactInputSchema = import_zod23.z.strictObject({
18778
+ session: import_zod23.z.string().min(1),
18779
+ waitMs: WaitMsSchema
18780
+ });
18781
+ var RcCompactWithInstructionsInputSchema = import_zod23.z.strictObject({
18782
+ session: import_zod23.z.string().min(1),
18783
+ instructions: import_zod23.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
18784
+ waitMs: WaitMsSchema
18785
+ });
18786
+ var commandAnswerShape = {
18787
+ session: import_zod23.z.string(),
18788
+ route: import_zod23.z.enum(["supervised", "self-hosted"])
18789
+ };
18790
+ var RcGoalGetOutputSchema = import_zod23.z.strictObject({
18791
+ ...commandAnswerShape,
18792
+ goal: import_zod23.z.strictObject({ condition: import_zod23.z.string(), iterations: import_zod23.z.int().nonnegative(), lastCheck: import_zod23.z.string().optional() }).nullable()
18793
+ });
18794
+ var RcGoalSetOutputSchema = import_zod23.z.strictObject({
18795
+ ...commandAnswerShape,
18796
+ condition: import_zod23.z.string(),
18797
+ superseded: import_zod23.z.string().nullable()
18798
+ });
18799
+ var RcGoalClearOutputSchema = import_zod23.z.strictObject({
18800
+ ...commandAnswerShape,
18801
+ cleared: import_zod23.z.string().nullable()
18802
+ });
18803
+ var RcCompactOutputSchema = import_zod23.z.strictObject({
18804
+ ...commandAnswerShape,
18805
+ trigger: import_zod23.z.string(),
18806
+ preTokens: import_zod23.z.number().optional(),
18807
+ postTokens: import_zod23.z.number().optional()
18808
+ });
18809
+
18362
18810
  // src/frontdoor/rcApi.ts
18363
18811
  var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
18364
18812
  var RC_OPENAPI_DOC_PATH = "/openapi.json";
@@ -18380,6 +18828,7 @@ function doorApiAuth(expectedToken) {
18380
18828
  });
18381
18829
  }
18382
18830
  var RC_API_TAG = "remote-control";
18831
+ var RC_DIRECTIVE_TAG = "remote-control-directives";
18383
18832
  function createRcApiRouter(deps) {
18384
18833
  const authed = doorApiAuth(deps.expectedToken);
18385
18834
  const delivered = (sessionId, result) => {
@@ -18397,6 +18846,13 @@ function createRcApiRouter(deps) {
18397
18846
  }
18398
18847
  return { request: result.requestId, sequenceNums: result.sequenceNums };
18399
18848
  };
18849
+ const commanded = (sessionId, result) => {
18850
+ if (!result.ok) {
18851
+ throw new import_client.ORPCError("BAD_GATEWAY", { message: result.message });
18852
+ }
18853
+ return { session: sessionId, ...result.report };
18854
+ };
18855
+ const optionsOf = (waitMs, signal) => ({ ...waitMs === void 0 ? {} : { waitMs }, ...signal === void 0 ? {} : { signal } });
18400
18856
  return {
18401
18857
  rc: {
18402
18858
  list: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
@@ -18433,6 +18889,11 @@ function createRcApiRouter(deps) {
18433
18889
  mcpAuthenticate: authed.meta((0, import_openapi.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)) })),
18434
18890
  mcpOAuthCallbackUrl: authed.meta((0, import_openapi.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)) })),
18435
18891
  teleport: authed.meta((0, import_openapi.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)) })),
18892
+ goalGet: authed.meta((0, import_openapi.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)))),
18893
+ goalSet: authed.meta((0, import_openapi.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)))),
18894
+ goalClear: authed.meta((0, import_openapi.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)))),
18895
+ compact: authed.meta((0, import_openapi.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)))),
18896
+ compactWithInstructions: authed.meta((0, import_openapi.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 }))),
18436
18897
  subscribe: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output((0, import_server2.eventIterator)(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
18437
18898
  const queue = [];
18438
18899
  let wake;
@@ -18513,8 +18974,27 @@ function doorApiNodeHandlerOf(router, expectedToken) {
18513
18974
  function createRcApiNodeHandler(deps) {
18514
18975
  return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
18515
18976
  }
18977
+ var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
18978
+ var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
18979
+ function headersTimeoutOf(url, body) {
18980
+ if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
18981
+ return DEFAULT_HEADERS_TIMEOUT_MS;
18982
+ }
18983
+ const parsed = body === void 0 ? void 0 : JSON.parse(body.toString("utf8"));
18984
+ 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;
18985
+ return Math.min(waitMs + DEFAULT_HEADERS_TIMEOUT_MS, RC_SESSION_COMMAND_MAX_WAIT_MS);
18986
+ }
18516
18987
  function frontDoorApiLink(port, ca, token) {
18517
- const dispatcher = new import_undici.Agent({ connect: { ca } });
18988
+ const dispatchers = /* @__PURE__ */ new Map();
18989
+ const dispatcherFor = (headersTimeout) => {
18990
+ const existing = dispatchers.get(headersTimeout);
18991
+ if (existing !== void 0) {
18992
+ return existing;
18993
+ }
18994
+ const created = new import_undici.Agent({ connect: { ca }, headersTimeout });
18995
+ dispatchers.set(headersTimeout, created);
18996
+ return created;
18997
+ };
18518
18998
  return new import_fetch.RPCLink({
18519
18999
  origin: `https://127.0.0.1:${String(port)}`,
18520
19000
  url: RC_ORPC_PATH_PREFIX,
@@ -18527,7 +19007,7 @@ function frontDoorApiLink(port, ca, token) {
18527
19007
  method: request4.method,
18528
19008
  headers: [...request4.headers],
18529
19009
  ...body === void 0 ? {} : { body },
18530
- dispatcher,
19010
+ dispatcher: dispatcherFor(headersTimeoutOf(request4.url, body)),
18531
19011
  ...options.signal === void 0 ? {} : { signal: options.signal }
18532
19012
  });
18533
19013
  return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
@@ -18543,48 +19023,48 @@ init_cliError();
18543
19023
  init_package();
18544
19024
 
18545
19025
  // src/codex/appServerSchemas.ts
18546
- var import_zod23 = require("zod");
19026
+ var import_zod24 = require("zod");
18547
19027
  var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
18548
- var RateLimitWindowSchema = import_zod23.z.object({
18549
- usedPercent: import_zod23.z.number(),
18550
- resetsAt: import_zod23.z.number().nullish(),
18551
- windowDurationMins: import_zod23.z.number().nullish()
18552
- });
18553
- var RateLimitSnapshotSchema = import_zod23.z.object({
18554
- limitId: import_zod23.z.string().nullish(),
18555
- limitName: import_zod23.z.string().nullish(),
18556
- planType: import_zod23.z.string().nullish(),
19028
+ var RateLimitWindowSchema = import_zod24.z.object({
19029
+ usedPercent: import_zod24.z.number(),
19030
+ resetsAt: import_zod24.z.number().nullish(),
19031
+ windowDurationMins: import_zod24.z.number().nullish()
19032
+ });
19033
+ var RateLimitSnapshotSchema = import_zod24.z.object({
19034
+ limitId: import_zod24.z.string().nullish(),
19035
+ limitName: import_zod24.z.string().nullish(),
19036
+ planType: import_zod24.z.string().nullish(),
18557
19037
  primary: RateLimitWindowSchema.nullish(),
18558
19038
  secondary: RateLimitWindowSchema.nullish(),
18559
- rateLimitReachedType: import_zod23.z.string().nullish(),
18560
- spendControlReached: import_zod23.z.boolean().nullish()
18561
- });
18562
- var RateLimitResetCreditSchema = import_zod23.z.object({
18563
- id: import_zod23.z.string(),
18564
- grantedAt: import_zod23.z.number(),
18565
- expiresAt: import_zod23.z.number().nullish(),
18566
- resetType: import_zod23.z.string(),
18567
- status: import_zod23.z.string(),
18568
- title: import_zod23.z.string().nullish(),
18569
- description: import_zod23.z.string().nullish()
18570
- });
18571
- var CodexAccountSchema = import_zod23.z.discriminatedUnion("type", [
18572
- import_zod23.z.object({ type: import_zod23.z.literal("apiKey") }),
18573
- import_zod23.z.object({ type: import_zod23.z.literal("chatgpt"), email: import_zod23.z.string().nullable(), planType: import_zod23.z.string() }),
18574
- import_zod23.z.object({ type: import_zod23.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod23.z.boolean().default(false) })
19039
+ rateLimitReachedType: import_zod24.z.string().nullish(),
19040
+ spendControlReached: import_zod24.z.boolean().nullish()
19041
+ });
19042
+ var RateLimitResetCreditSchema = import_zod24.z.object({
19043
+ id: import_zod24.z.string(),
19044
+ grantedAt: import_zod24.z.number(),
19045
+ expiresAt: import_zod24.z.number().nullish(),
19046
+ resetType: import_zod24.z.string(),
19047
+ status: import_zod24.z.string(),
19048
+ title: import_zod24.z.string().nullish(),
19049
+ description: import_zod24.z.string().nullish()
19050
+ });
19051
+ var CodexAccountSchema = import_zod24.z.discriminatedUnion("type", [
19052
+ import_zod24.z.object({ type: import_zod24.z.literal("apiKey") }),
19053
+ import_zod24.z.object({ type: import_zod24.z.literal("chatgpt"), email: import_zod24.z.string().nullable(), planType: import_zod24.z.string() }),
19054
+ import_zod24.z.object({ type: import_zod24.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod24.z.boolean().default(false) })
18575
19055
  ]);
18576
- var CodexAccountReadSchema = import_zod23.z.object({
19056
+ var CodexAccountReadSchema = import_zod24.z.object({
18577
19057
  account: CodexAccountSchema.nullable(),
18578
- requiresOpenaiAuth: import_zod23.z.boolean()
19058
+ requiresOpenaiAuth: import_zod24.z.boolean()
18579
19059
  });
18580
- var CodexRateLimitsReadSchema = import_zod23.z.object({
19060
+ var CodexRateLimitsReadSchema = import_zod24.z.object({
18581
19061
  rateLimits: RateLimitSnapshotSchema,
18582
- rateLimitsByLimitId: import_zod23.z.record(import_zod23.z.string(), RateLimitSnapshotSchema).nullish(),
18583
- rateLimitResetCredits: import_zod23.z.object({ availableCount: import_zod23.z.number(), credits: import_zod23.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
18584
- accountId: import_zod23.z.string().nullish(),
18585
- ordinaryUsageAllowed: import_zod23.z.boolean().nullish()
19062
+ rateLimitsByLimitId: import_zod24.z.record(import_zod24.z.string(), RateLimitSnapshotSchema).nullish(),
19063
+ rateLimitResetCredits: import_zod24.z.object({ availableCount: import_zod24.z.number(), credits: import_zod24.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
19064
+ accountId: import_zod24.z.string().nullish(),
19065
+ ordinaryUsageAllowed: import_zod24.z.boolean().nullish()
18586
19066
  });
18587
- var CodexInitializeResultSchema = import_zod23.z.object({ userAgent: import_zod23.z.string() });
19067
+ var CodexInitializeResultSchema = import_zod24.z.object({ userAgent: import_zod24.z.string() });
18588
19068
 
18589
19069
  // src/codex/appServer.ts
18590
19070
  var CodexAppServerUnavailableError = class extends CliError {
@@ -18911,7 +19391,7 @@ init_providersStore();
18911
19391
  init_signIn();
18912
19392
  init_realPorts();
18913
19393
  var import_node_path37 = __toESM(require("node:path"), 1);
18914
- var import_zod26 = require("zod");
19394
+ var import_zod27 = require("zod");
18915
19395
  init_envBool();
18916
19396
  init_load();
18917
19397
  init_schema();
@@ -18993,9 +19473,9 @@ function lookupKeychainService(run, farmRoot) {
18993
19473
  }
18994
19474
  return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
18995
19475
  }
18996
- var SettingsSecretsShapeSchema = import_zod26.z.looseObject({
18997
- env: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.unknown()).optional(),
18998
- hooks: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.array(import_zod26.z.unknown())).optional()
19476
+ var SettingsSecretsShapeSchema = import_zod27.z.looseObject({
19477
+ env: import_zod27.z.record(import_zod27.z.string(), import_zod27.z.unknown()).optional(),
19478
+ hooks: import_zod27.z.record(import_zod27.z.string(), import_zod27.z.array(import_zod27.z.unknown())).optional()
18999
19479
  });
19000
19480
  function hookCommandCountOf(group) {
19001
19481
  if (typeof group !== "object" || group === null) {
@@ -19296,7 +19776,7 @@ function collectCheckReport(params) {
19296
19776
  }
19297
19777
 
19298
19778
  // src/checkReportSchema.ts
19299
- var import_zod28 = require("zod");
19779
+ var import_zod29 = require("zod");
19300
19780
  init_schema();
19301
19781
  init_claudeVersion();
19302
19782
  init_identity();
@@ -19360,124 +19840,124 @@ var DIAGNOSTIC_CODES = [
19360
19840
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
19361
19841
 
19362
19842
  // src/usage/pickReportSchema.ts
19363
- var import_zod27 = require("zod");
19843
+ var import_zod28 = require("zod");
19364
19844
  init_plan2();
19365
- var PoolPickCandidateViewSchema = import_zod27.z.strictObject({
19366
- identity: import_zod27.z.string(),
19845
+ var PoolPickCandidateViewSchema = import_zod28.z.strictObject({
19846
+ identity: import_zod28.z.string(),
19367
19847
  /** 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. */
19368
- class: import_zod27.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
19848
+ class: import_zod28.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
19369
19849
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
19370
- score: import_zod27.z.number().optional(),
19850
+ score: import_zod28.z.number().optional(),
19371
19851
  /** 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`. */
19372
- scoreWindow: import_zod27.z.enum(["sevenDay", "fiveHour"]).optional(),
19852
+ scoreWindow: import_zod28.z.enum(["sevenDay", "fiveHour"]).optional(),
19373
19853
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
19374
- feasible: import_zod27.z.boolean(),
19854
+ feasible: import_zod28.z.boolean(),
19375
19855
  /** When an `ineligible` member can be used again, as an ISO instant. */
19376
- blockedUntil: import_zod27.z.iso.datetime().optional(),
19856
+ blockedUntil: import_zod28.z.iso.datetime().optional(),
19377
19857
  plan: PlanClassSchema,
19378
19858
  /** The facts behind the class and score, in the order they matter. */
19379
- reasons: import_zod27.z.array(import_zod27.z.string())
19859
+ reasons: import_zod28.z.array(import_zod28.z.string())
19380
19860
  });
19381
- var PoolPickReportSchema = import_zod27.z.strictObject({
19382
- pool: import_zod27.z.string(),
19383
- directory: import_zod27.z.string(),
19861
+ var PoolPickReportSchema = import_zod28.z.strictObject({
19862
+ pool: import_zod28.z.string(),
19863
+ directory: import_zod28.z.string(),
19384
19864
  /** The member a launch would run as, absent when every member is refused. */
19385
- pick: import_zod27.z.string().optional(),
19386
- candidates: import_zod27.z.array(PoolPickCandidateViewSchema),
19865
+ pick: import_zod28.z.string().optional(),
19866
+ candidates: import_zod28.z.array(PoolPickCandidateViewSchema),
19387
19867
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
19388
- missing: import_zod27.z.array(import_zod27.z.string()),
19868
+ missing: import_zod28.z.array(import_zod28.z.string()),
19389
19869
  /** When nothing can be picked, the soonest any member returns. */
19390
- earliestReturn: import_zod27.z.strictObject({ identity: import_zod27.z.string(), at: import_zod27.z.iso.datetime() }).optional(),
19870
+ earliestReturn: import_zod28.z.strictObject({ identity: import_zod28.z.string(), at: import_zod28.z.iso.datetime() }).optional(),
19391
19871
  /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
19392
- movedOff: import_zod27.z.strictObject({ identity: import_zod27.z.string(), reason: import_zod27.z.string() }).optional(),
19872
+ movedOff: import_zod28.z.strictObject({ identity: import_zod28.z.string(), reason: import_zod28.z.string() }).optional(),
19393
19873
  /** Why the last-pick record could not be read, when that is the case. */
19394
- stickyProblem: import_zod27.z.string().optional()
19874
+ stickyProblem: import_zod28.z.string().optional()
19395
19875
  });
19396
19876
 
19397
19877
  // src/checkReportSchema.ts
19398
19878
  var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
19399
- var CheckLayerViewSchema = import_zod28.z.strictObject({
19400
- id: import_zod28.z.int(),
19401
- kind: import_zod28.z.enum(LAYER_KINDS),
19402
- source: import_zod28.z.string()
19403
- });
19404
- var CheckEntryViewSchema = import_zod28.z.strictObject({
19405
- path: import_zod28.z.string(),
19406
- shared: import_zod28.z.boolean(),
19407
- via: import_zod28.z.enum(DECISION_VIAS),
19879
+ var CheckLayerViewSchema = import_zod29.z.strictObject({
19880
+ id: import_zod29.z.int(),
19881
+ kind: import_zod29.z.enum(LAYER_KINDS),
19882
+ source: import_zod29.z.string()
19883
+ });
19884
+ var CheckEntryViewSchema = import_zod29.z.strictObject({
19885
+ path: import_zod29.z.string(),
19886
+ shared: import_zod29.z.boolean(),
19887
+ via: import_zod29.z.enum(DECISION_VIAS),
19408
19888
  /** The entry's real category, or null when nothing classifies it. */
19409
- category: import_zod28.z.enum(CATEGORY_NAMES).nullable(),
19410
- rule: import_zod28.z.strictObject({ key: import_zod28.z.string(), layer: import_zod28.z.int() }).optional(),
19889
+ category: import_zod29.z.enum(CATEGORY_NAMES).nullable(),
19890
+ rule: import_zod29.z.strictObject({ key: import_zod29.z.string(), layer: import_zod29.z.int() }).optional(),
19411
19891
  /** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
19412
- eliminated: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.strictObject({ key: import_zod28.z.string(), failed: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())) }))).optional()
19413
- });
19414
- var CheckDiagnosticSchema = import_zod28.z.strictObject({
19415
- code: import_zod28.z.enum(DIAGNOSTIC_CODES),
19416
- severity: import_zod28.z.enum(DIAGNOSTIC_SEVERITIES),
19417
- message: import_zod28.z.string(),
19418
- subject: import_zod28.z.string().optional(),
19419
- layer: import_zod28.z.int().optional()
19420
- });
19421
- var CheckAmbientCredentialSchema = import_zod28.z.union([import_zod28.z.strictObject({ ok: import_zod28.z.literal(true) }), import_zod28.z.strictObject({ ok: import_zod28.z.literal(false), variable: import_zod28.z.string(), message: import_zod28.z.string() })]);
19422
- var CheckKeychainSchema = import_zod28.z.strictObject({
19423
- checked: import_zod28.z.literal(true),
19424
- found: import_zod28.z.boolean(),
19425
- serviceName: import_zod28.z.string().optional(),
19426
- note: import_zod28.z.string()
19427
- });
19428
- var CheckSettingsExposureSchema = import_zod28.z.strictObject({
19429
- file: import_zod28.z.string(),
19430
- envKeyNames: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
19431
- hookEventNames: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
19432
- hookCommandCount: import_zod28.z.int().nonnegative()
19433
- });
19434
- var CredentialSourceSummarySchema = import_zod28.z.union([
19435
- import_zod28.z.strictObject({ kind: import_zod28.z.literal("env"), variable: import_zod28.z.string() }),
19436
- import_zod28.z.strictObject({ kind: import_zod28.z.literal("file"), path: import_zod28.z.string() }),
19437
- import_zod28.z.strictObject({ kind: import_zod28.z.literal("command"), program: import_zod28.z.string() }),
19438
- import_zod28.z.strictObject({ kind: import_zod28.z.literal("op"), reference: import_zod28.z.string() }),
19439
- import_zod28.z.strictObject({ kind: import_zod28.z.literal("keychain"), service: import_zod28.z.string(), account: import_zod28.z.string().optional() }),
19440
- import_zod28.z.strictObject({ kind: import_zod28.z.literal("literal") })
19892
+ eliminated: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.strictObject({ key: import_zod29.z.string(), failed: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())) }))).optional()
19893
+ });
19894
+ var CheckDiagnosticSchema = import_zod29.z.strictObject({
19895
+ code: import_zod29.z.enum(DIAGNOSTIC_CODES),
19896
+ severity: import_zod29.z.enum(DIAGNOSTIC_SEVERITIES),
19897
+ message: import_zod29.z.string(),
19898
+ subject: import_zod29.z.string().optional(),
19899
+ layer: import_zod29.z.int().optional()
19900
+ });
19901
+ var CheckAmbientCredentialSchema = import_zod29.z.union([import_zod29.z.strictObject({ ok: import_zod29.z.literal(true) }), import_zod29.z.strictObject({ ok: import_zod29.z.literal(false), variable: import_zod29.z.string(), message: import_zod29.z.string() })]);
19902
+ var CheckKeychainSchema = import_zod29.z.strictObject({
19903
+ checked: import_zod29.z.literal(true),
19904
+ found: import_zod29.z.boolean(),
19905
+ serviceName: import_zod29.z.string().optional(),
19906
+ note: import_zod29.z.string()
19907
+ });
19908
+ var CheckSettingsExposureSchema = import_zod29.z.strictObject({
19909
+ file: import_zod29.z.string(),
19910
+ envKeyNames: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())),
19911
+ hookEventNames: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())),
19912
+ hookCommandCount: import_zod29.z.int().nonnegative()
19913
+ });
19914
+ var CredentialSourceSummarySchema = import_zod29.z.union([
19915
+ import_zod29.z.strictObject({ kind: import_zod29.z.literal("env"), variable: import_zod29.z.string() }),
19916
+ import_zod29.z.strictObject({ kind: import_zod29.z.literal("file"), path: import_zod29.z.string() }),
19917
+ import_zod29.z.strictObject({ kind: import_zod29.z.literal("command"), program: import_zod29.z.string() }),
19918
+ import_zod29.z.strictObject({ kind: import_zod29.z.literal("op"), reference: import_zod29.z.string() }),
19919
+ import_zod29.z.strictObject({ kind: import_zod29.z.literal("keychain"), service: import_zod29.z.string(), account: import_zod29.z.string().optional() }),
19920
+ import_zod29.z.strictObject({ kind: import_zod29.z.literal("literal") })
19441
19921
  ]);
19442
- var CredentialSummarySchema = import_zod28.z.strictObject({
19443
- target: import_zod28.z.enum(CREDENTIAL_TARGETS),
19444
- sources: import_zod28.z.readonly(import_zod28.z.array(CredentialSourceSummarySchema)),
19922
+ var CredentialSummarySchema = import_zod29.z.strictObject({
19923
+ target: import_zod29.z.enum(CREDENTIAL_TARGETS),
19924
+ sources: import_zod29.z.readonly(import_zod29.z.array(CredentialSourceSummarySchema)),
19445
19925
  cache: CredentialCacheSchema.optional()
19446
19926
  });
19447
- var CachedCredentialStateSchema = import_zod28.z.union([
19448
- import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.literal("empty") }),
19449
- import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.literal("unreadable"), reason: import_zod28.z.string() }),
19450
- import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.enum(["fresh", "expired"]), ageMs: import_zod28.z.number(), expiresInMs: import_zod28.z.number().optional() })
19927
+ var CachedCredentialStateSchema = import_zod29.z.union([
19928
+ import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.literal("empty") }),
19929
+ import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.literal("unreadable"), reason: import_zod29.z.string() }),
19930
+ import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.enum(["fresh", "expired"]), ageMs: import_zod29.z.number(), expiresInMs: import_zod29.z.number().optional() })
19451
19931
  ]);
19452
- var CheckCredentialProviderSchema = import_zod28.z.union([
19453
- import_zod28.z.strictObject({ name: import_zod28.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
19454
- import_zod28.z.strictObject({ name: import_zod28.z.string(), problem: import_zod28.z.string() })
19932
+ var CheckCredentialProviderSchema = import_zod29.z.union([
19933
+ import_zod29.z.strictObject({ name: import_zod29.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
19934
+ import_zod29.z.strictObject({ name: import_zod29.z.string(), problem: import_zod29.z.string() })
19455
19935
  ]);
19456
- var CheckCredentialSchema = import_zod28.z.strictObject({
19457
- applies: import_zod28.z.enum(CHECK_CREDENTIAL_APPLIES),
19936
+ var CheckCredentialSchema = import_zod29.z.strictObject({
19937
+ applies: import_zod29.z.enum(CHECK_CREDENTIAL_APPLIES),
19458
19938
  provider: CheckCredentialProviderSchema.optional(),
19459
19939
  identity: CredentialSummarySchema.optional(),
19460
19940
  identityCached: CachedCredentialStateSchema.optional()
19461
19941
  });
19462
- var CheckClaudeVersionSchema = import_zod28.z.strictObject({
19463
- pinned: import_zod28.z.strictObject({ version: import_zod28.z.string(), source: import_zod28.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod28.z.boolean() }).optional(),
19464
- highestInstalled: import_zod28.z.string().optional(),
19465
- installed: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string()))
19942
+ var CheckClaudeVersionSchema = import_zod29.z.strictObject({
19943
+ pinned: import_zod29.z.strictObject({ version: import_zod29.z.string(), source: import_zod29.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod29.z.boolean() }).optional(),
19944
+ highestInstalled: import_zod29.z.string().optional(),
19945
+ installed: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string()))
19466
19946
  });
19467
- var CheckReportJsonSchema = import_zod28.z.strictObject({
19468
- identity: import_zod28.z.strictObject({ name: import_zod28.z.string().nullable(), source: import_zod28.z.enum(IDENTITY_DECISION_SOURCES) }),
19947
+ var CheckReportJsonSchema = import_zod29.z.strictObject({
19948
+ identity: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(IDENTITY_DECISION_SOURCES) }),
19469
19949
  /** The pool ranking, when the launch named a pool instead of an identity. */
19470
19950
  pool: PoolPickReportSchema.optional(),
19471
- configProfile: import_zod28.z.strictObject({ name: import_zod28.z.string().nullable(), source: import_zod28.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
19472
- layers: import_zod28.z.readonly(import_zod28.z.array(CheckLayerViewSchema)),
19473
- entries: import_zod28.z.readonly(import_zod28.z.array(CheckEntryViewSchema)),
19474
- projectEncodingAmbiguities: import_zod28.z.readonly(
19475
- import_zod28.z.array(import_zod28.z.strictObject({ fragment: import_zod28.z.string(), encoded: import_zod28.z.string(), reason: import_zod28.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod28.z.string() }))
19951
+ configProfile: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
19952
+ layers: import_zod29.z.readonly(import_zod29.z.array(CheckLayerViewSchema)),
19953
+ entries: import_zod29.z.readonly(import_zod29.z.array(CheckEntryViewSchema)),
19954
+ projectEncodingAmbiguities: import_zod29.z.readonly(
19955
+ import_zod29.z.array(import_zod29.z.strictObject({ fragment: import_zod29.z.string(), encoded: import_zod29.z.string(), reason: import_zod29.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod29.z.string() }))
19476
19956
  ),
19477
- diagnostics: import_zod28.z.readonly(import_zod28.z.array(CheckDiagnosticSchema)),
19957
+ diagnostics: import_zod29.z.readonly(import_zod29.z.array(CheckDiagnosticSchema)),
19478
19958
  ambientCredential: CheckAmbientCredentialSchema,
19479
19959
  keychain: CheckKeychainSchema.optional(),
19480
- settingsExposure: import_zod28.z.readonly(import_zod28.z.array(CheckSettingsExposureSchema)),
19960
+ settingsExposure: import_zod29.z.readonly(import_zod29.z.array(CheckSettingsExposureSchema)),
19481
19961
  credential: CheckCredentialSchema,
19482
19962
  claudeVersion: CheckClaudeVersionSchema.optional()
19483
19963
  });
@@ -19488,28 +19968,28 @@ init_preflight();
19488
19968
  init_resets();
19489
19969
 
19490
19970
  // src/usage/resetsSchema.ts
19491
- var import_zod29 = require("zod");
19492
- var ResetRowSchema = import_zod29.z.strictObject({
19493
- identity: import_zod29.z.string(),
19494
- provider: import_zod29.z.string(),
19971
+ var import_zod30 = require("zod");
19972
+ var ResetRowSchema = import_zod30.z.strictObject({
19973
+ identity: import_zod30.z.string(),
19974
+ provider: import_zod30.z.string(),
19495
19975
  /** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
19496
- window: import_zod29.z.string(),
19976
+ window: import_zod30.z.string(),
19497
19977
  /** When the state the window comes from was observed, as an ISO instant. */
19498
- observedAt: import_zod29.z.iso.datetime(),
19978
+ observedAt: import_zod30.z.iso.datetime(),
19499
19979
  /** When the window resets, as an ISO instant; absent when the upstream reported none. */
19500
- resetsAt: import_zod29.z.iso.datetime().optional(),
19980
+ resetsAt: import_zod30.z.iso.datetime().optional(),
19501
19981
  /** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
19502
- reset: import_zod29.z.boolean(),
19982
+ reset: import_zod30.z.boolean(),
19503
19983
  /** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
19504
- utilization: import_zod29.z.number().optional(),
19984
+ utilization: import_zod30.z.number().optional(),
19505
19985
  /** The window's own status, for a window that has not reset yet. */
19506
- status: import_zod29.z.string().optional()
19986
+ status: import_zod30.z.string().optional()
19507
19987
  });
19508
- var ResetScheduleSchema = import_zod29.z.strictObject({ resets: import_zod29.z.readonly(import_zod29.z.array(ResetRowSchema)) });
19988
+ var ResetScheduleSchema = import_zod30.z.strictObject({ resets: import_zod30.z.readonly(import_zod30.z.array(ResetRowSchema)) });
19509
19989
 
19510
19990
  // src/frontdoor/controlSchemas.ts
19511
19991
  var import_node_path43 = __toESM(require("node:path"), 1);
19512
- var import_zod36 = require("zod");
19992
+ var import_zod37 = require("zod");
19513
19993
 
19514
19994
  // src/codex/doctor.ts
19515
19995
  function codexIdentityFindings(entry, identity) {
@@ -20736,92 +21216,92 @@ function collectDoctorReport(params) {
20736
21216
  // src/frontdoor/controlSchemas.ts
20737
21217
  init_schema2();
20738
21218
  init_state();
20739
- var UsageListOutputSchema = import_zod36.z.strictObject({ snapshots: import_zod36.z.readonly(import_zod36.z.array(UsageSnapshotSchema)) });
20740
- var UsageWindowsInputSchema = import_zod36.z.strictObject({
20741
- identity: import_zod36.z.string().min(1),
20742
- provider: import_zod36.z.string().min(1).optional()
21219
+ var UsageListOutputSchema = import_zod37.z.strictObject({ snapshots: import_zod37.z.readonly(import_zod37.z.array(UsageSnapshotSchema)) });
21220
+ var UsageWindowsInputSchema = import_zod37.z.strictObject({
21221
+ identity: import_zod37.z.string().min(1),
21222
+ provider: import_zod37.z.string().min(1).optional()
20743
21223
  });
20744
- var EffectiveWindowSchema = import_zod36.z.strictObject({
21224
+ var EffectiveWindowSchema = import_zod37.z.strictObject({
20745
21225
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
20746
- reset: import_zod36.z.boolean(),
21226
+ reset: import_zod37.z.boolean(),
20747
21227
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
20748
- utilization: import_zod36.z.number().optional(),
21228
+ utilization: import_zod37.z.number().optional(),
20749
21229
  /** The reset instant, for a window that has not reset yet and reported one. */
20750
- resetsAtMs: import_zod36.z.number().optional(),
21230
+ resetsAtMs: import_zod37.z.number().optional(),
20751
21231
  /** The window's own status, for a window that has not reset yet. */
20752
- status: import_zod36.z.string().optional()
21232
+ status: import_zod37.z.string().optional()
20753
21233
  });
20754
- var UsageWindowsOutputSchema = import_zod36.z.strictObject({
20755
- identity: import_zod36.z.string(),
20756
- provider: import_zod36.z.string(),
21234
+ var UsageWindowsOutputSchema = import_zod37.z.strictObject({
21235
+ identity: import_zod37.z.string(),
21236
+ provider: import_zod37.z.string(),
20757
21237
  /** When the rate-limit state the windows come from was observed. */
20758
- observedAt: import_zod36.z.iso.datetime().optional(),
21238
+ observedAt: import_zod37.z.iso.datetime().optional(),
20759
21239
  fiveHour: EffectiveWindowSchema.optional(),
20760
21240
  sevenDay: EffectiveWindowSchema.optional()
20761
21241
  });
20762
- var UsageLiveOutputSchema = import_zod36.z.strictObject({
21242
+ var UsageLiveOutputSchema = import_zod37.z.strictObject({
20763
21243
  /** 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. */
20764
21244
  latest: RcLiveRateLimitSchema.optional(),
20765
21245
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
20766
- sessions: import_zod36.z.readonly(import_zod36.z.array(RcLiveRateLimitSchema))
21246
+ sessions: import_zod37.z.readonly(import_zod37.z.array(RcLiveRateLimitSchema))
20767
21247
  });
20768
- var FrontDoorSessionStatusSchema = import_zod36.z.strictObject({
20769
- pid: import_zod36.z.int().positive(),
20770
- startedAt: import_zod36.z.number(),
20771
- alive: import_zod36.z.boolean()
21248
+ var FrontDoorSessionStatusSchema = import_zod37.z.strictObject({
21249
+ pid: import_zod37.z.int().positive(),
21250
+ startedAt: import_zod37.z.number(),
21251
+ alive: import_zod37.z.boolean()
20772
21252
  });
20773
- var HeadroomSocketTargetSchema = import_zod36.z.union([import_zod36.z.strictObject({ socketPath: import_zod36.z.string() }), import_zod36.z.strictObject({ refused: import_zod36.z.string() })]);
20774
- var FrontDoorStatusOutputSchema = import_zod36.z.strictObject({
21253
+ var HeadroomSocketTargetSchema = import_zod37.z.union([import_zod37.z.strictObject({ socketPath: import_zod37.z.string() }), import_zod37.z.strictObject({ refused: import_zod37.z.string() })]);
21254
+ var FrontDoorStatusOutputSchema = import_zod37.z.strictObject({
20775
21255
  state: FrontDoorStateSchema,
20776
- supervisorAlive: import_zod36.z.boolean(),
21256
+ supervisorAlive: import_zod37.z.boolean(),
20777
21257
  /** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
20778
- draining: import_zod36.z.readonly(import_zod36.z.array(import_zod36.z.number().int().positive())),
20779
- sessions: import_zod36.z.readonly(import_zod36.z.array(FrontDoorSessionStatusSchema)),
21258
+ draining: import_zod37.z.readonly(import_zod37.z.array(import_zod37.z.number().int().positive())),
21259
+ sessions: import_zod37.z.readonly(import_zod37.z.array(FrontDoorSessionStatusSchema)),
20780
21260
  headroomSocket: HeadroomSocketTargetSchema.optional(),
20781
- logPath: import_zod36.z.string(),
20782
- logExists: import_zod36.z.boolean()
21261
+ logPath: import_zod37.z.string(),
21262
+ logExists: import_zod37.z.boolean()
20783
21263
  });
20784
- var FrontDoorSessionsOutputSchema = import_zod36.z.strictObject({ sessions: import_zod36.z.readonly(import_zod36.z.array(FrontDoorSessionStatusSchema)) });
20785
- var CheckRunInputSchema = import_zod36.z.strictObject({
20786
- path: import_zod36.z.string().min(1),
20787
- identity: import_zod36.z.string().min(1).optional()
21264
+ var FrontDoorSessionsOutputSchema = import_zod37.z.strictObject({ sessions: import_zod37.z.readonly(import_zod37.z.array(FrontDoorSessionStatusSchema)) });
21265
+ var CheckRunInputSchema = import_zod37.z.strictObject({
21266
+ path: import_zod37.z.string().min(1),
21267
+ identity: import_zod37.z.string().min(1).optional()
20788
21268
  }).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20789
- var PoolPickInputSchema = import_zod36.z.strictObject({
20790
- pool: import_zod36.z.string().min(1),
20791
- path: import_zod36.z.string().min(1)
21269
+ var PoolPickInputSchema = import_zod37.z.strictObject({
21270
+ pool: import_zod37.z.string().min(1),
21271
+ path: import_zod37.z.string().min(1)
20792
21272
  }).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20793
- var DoctorFindingSchema = import_zod36.z.strictObject({
20794
- section: import_zod36.z.enum(DOCTOR_SECTIONS),
20795
- subject: import_zod36.z.string().optional(),
20796
- severity: import_zod36.z.enum(DOCTOR_SEVERITIES),
20797
- message: import_zod36.z.string()
21273
+ var DoctorFindingSchema = import_zod37.z.strictObject({
21274
+ section: import_zod37.z.enum(DOCTOR_SECTIONS),
21275
+ subject: import_zod37.z.string().optional(),
21276
+ severity: import_zod37.z.enum(DOCTOR_SEVERITIES),
21277
+ message: import_zod37.z.string()
20798
21278
  });
20799
- var DoctorRunOutputSchema = import_zod36.z.strictObject({
21279
+ var DoctorRunOutputSchema = import_zod37.z.strictObject({
20800
21280
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
20801
- ok: import_zod36.z.boolean(),
20802
- findings: import_zod36.z.readonly(import_zod36.z.array(DoctorFindingSchema))
20803
- });
20804
- var FrontDoorRestartOutputSchema = import_zod36.z.strictObject({
20805
- action: import_zod36.z.literal("restarting"),
20806
- previousPid: import_zod36.z.int().positive()
20807
- });
20808
- var UpdateCheckOutputSchema = import_zod36.z.strictObject({
20809
- current: import_zod36.z.string(),
20810
- latest: import_zod36.z.string(),
20811
- action: import_zod36.z.enum(["current", "available", "updated"])
20812
- });
20813
- var CodexSignInSchema = import_zod36.z.discriminatedUnion("state", [
20814
- import_zod36.z.strictObject({ state: import_zod36.z.literal("none") }),
20815
- import_zod36.z.strictObject({ state: import_zod36.z.literal("signed-in"), email: import_zod36.z.string().optional(), planScope: import_zod36.z.boolean(), accessTokenExpiresAt: import_zod36.z.number() }),
20816
- import_zod36.z.strictObject({ state: import_zod36.z.literal("unreadable"), message: import_zod36.z.string() })
21281
+ ok: import_zod37.z.boolean(),
21282
+ findings: import_zod37.z.readonly(import_zod37.z.array(DoctorFindingSchema))
21283
+ });
21284
+ var FrontDoorRestartOutputSchema = import_zod37.z.strictObject({
21285
+ action: import_zod37.z.literal("restarting"),
21286
+ previousPid: import_zod37.z.int().positive()
21287
+ });
21288
+ var UpdateCheckOutputSchema = import_zod37.z.strictObject({
21289
+ current: import_zod37.z.string(),
21290
+ latest: import_zod37.z.string(),
21291
+ action: import_zod37.z.enum(["current", "available", "updated"])
21292
+ });
21293
+ var CodexSignInSchema = import_zod37.z.discriminatedUnion("state", [
21294
+ import_zod37.z.strictObject({ state: import_zod37.z.literal("none") }),
21295
+ import_zod37.z.strictObject({ state: import_zod37.z.literal("signed-in"), email: import_zod37.z.string().optional(), planScope: import_zod37.z.boolean(), accessTokenExpiresAt: import_zod37.z.number() }),
21296
+ import_zod37.z.strictObject({ state: import_zod37.z.literal("unreadable"), message: import_zod37.z.string() })
20817
21297
  ]);
20818
- var CodexStatusOutputSchema = import_zod36.z.strictObject({
21298
+ var CodexStatusOutputSchema = import_zod37.z.strictObject({
20819
21299
  signIn: CodexSignInSchema,
20820
- codexProviders: import_zod36.z.readonly(import_zod36.z.array(import_zod36.z.string()))
21300
+ codexProviders: import_zod37.z.readonly(import_zod37.z.array(import_zod37.z.string()))
20821
21301
  });
20822
- var CodexLogoutOutputSchema = import_zod36.z.strictObject({
20823
- hadGrant: import_zod36.z.boolean(),
20824
- revoked: import_zod36.z.boolean()
21302
+ var CodexLogoutOutputSchema = import_zod37.z.strictObject({
21303
+ hadGrant: import_zod37.z.boolean(),
21304
+ revoked: import_zod37.z.boolean()
20825
21305
  });
20826
21306
 
20827
21307
  // src/frontdoor/codexApi.ts
@@ -20885,71 +21365,71 @@ init_poolStore();
20885
21365
  init_providersStore();
20886
21366
 
20887
21367
  // src/frontdoor/configSchemas.ts
20888
- var import_zod37 = require("zod");
21368
+ var import_zod38 = require("zod");
20889
21369
  init_schema();
20890
21370
  init_names();
20891
21371
  init_keychainLogin();
20892
21372
  init_statusline();
20893
- var RemovalConfirmationSchema = import_zod37.z.boolean();
20894
- var CredentialWriteSchema = (targets) => import_zod37.z.strictObject({
20895
- sources: import_zod37.z.array(RemoteCredentialSourceSchema).min(1).optional(),
20896
- target: import_zod37.z.enum(targets).optional(),
20897
- cache: import_zod37.z.union([import_zod37.z.literal(false), CredentialCacheSchema]).optional()
20898
- });
20899
- var CredentialSummarySchema2 = import_zod37.z.strictObject({
20900
- target: import_zod37.z.enum(CREDENTIAL_TARGETS),
20901
- sources: import_zod37.z.readonly(import_zod37.z.array(
20902
- import_zod37.z.discriminatedUnion("kind", [
20903
- import_zod37.z.strictObject({ kind: import_zod37.z.literal("env"), variable: import_zod37.z.string() }),
20904
- import_zod37.z.strictObject({ kind: import_zod37.z.literal("file"), path: import_zod37.z.string() }),
20905
- import_zod37.z.strictObject({ kind: import_zod37.z.literal("command"), program: import_zod37.z.string() }),
20906
- import_zod37.z.strictObject({ kind: import_zod37.z.literal("op"), reference: import_zod37.z.string() }),
20907
- import_zod37.z.strictObject({ kind: import_zod37.z.literal("keychain"), service: import_zod37.z.string(), account: import_zod37.z.string().optional() }),
20908
- import_zod37.z.strictObject({ kind: import_zod37.z.literal("literal") })
21373
+ var RemovalConfirmationSchema = import_zod38.z.boolean();
21374
+ var CredentialWriteSchema = (targets) => import_zod38.z.strictObject({
21375
+ sources: import_zod38.z.array(RemoteCredentialSourceSchema).min(1).optional(),
21376
+ target: import_zod38.z.enum(targets).optional(),
21377
+ cache: import_zod38.z.union([import_zod38.z.literal(false), CredentialCacheSchema]).optional()
21378
+ });
21379
+ var CredentialSummarySchema2 = import_zod38.z.strictObject({
21380
+ target: import_zod38.z.enum(CREDENTIAL_TARGETS),
21381
+ sources: import_zod38.z.readonly(import_zod38.z.array(
21382
+ import_zod38.z.discriminatedUnion("kind", [
21383
+ import_zod38.z.strictObject({ kind: import_zod38.z.literal("env"), variable: import_zod38.z.string() }),
21384
+ import_zod38.z.strictObject({ kind: import_zod38.z.literal("file"), path: import_zod38.z.string() }),
21385
+ import_zod38.z.strictObject({ kind: import_zod38.z.literal("command"), program: import_zod38.z.string() }),
21386
+ import_zod38.z.strictObject({ kind: import_zod38.z.literal("op"), reference: import_zod38.z.string() }),
21387
+ import_zod38.z.strictObject({ kind: import_zod38.z.literal("keychain"), service: import_zod38.z.string(), account: import_zod38.z.string().optional() }),
21388
+ import_zod38.z.strictObject({ kind: import_zod38.z.literal("literal") })
20909
21389
  ])
20910
21390
  )),
20911
21391
  cache: CredentialCacheSchema.optional()
20912
21392
  });
20913
- var mutationOutput = (kind, action) => import_zod37.z.strictObject({ action: import_zod37.z.literal(action), kind: import_zod37.z.literal(kind), name: import_zod37.z.string() });
20914
- var storedMutationOutput = (kind, action, value) => import_zod37.z.strictObject({ action: import_zod37.z.literal(action), kind: import_zod37.z.literal(kind), name: import_zod37.z.string(), value });
20915
- var IdentityValueSchema = import_zod37.z.strictObject({
20916
- name: import_zod37.z.string(),
20917
- label: import_zod37.z.string().optional(),
20918
- defaultConfigProfile: import_zod37.z.string().optional(),
20919
- provider: import_zod37.z.string().optional(),
20920
- allowAmbientCredential: import_zod37.z.boolean(),
21393
+ var mutationOutput = (kind, action) => import_zod38.z.strictObject({ action: import_zod38.z.literal(action), kind: import_zod38.z.literal(kind), name: import_zod38.z.string() });
21394
+ var storedMutationOutput = (kind, action, value) => import_zod38.z.strictObject({ action: import_zod38.z.literal(action), kind: import_zod38.z.literal(kind), name: import_zod38.z.string(), value });
21395
+ var IdentityValueSchema = import_zod38.z.strictObject({
21396
+ name: import_zod38.z.string(),
21397
+ label: import_zod38.z.string().optional(),
21398
+ defaultConfigProfile: import_zod38.z.string().optional(),
21399
+ provider: import_zod38.z.string().optional(),
21400
+ allowAmbientCredential: import_zod38.z.boolean(),
20921
21401
  credential: CredentialSummarySchema2.optional(),
20922
- anchors: import_zod37.z.array(AnchorSchema).optional()
21402
+ anchors: import_zod38.z.array(AnchorSchema).optional()
20923
21403
  });
20924
21404
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
20925
- var ProviderValueSchema = import_zod37.z.strictObject({
20926
- name: import_zod37.z.string(),
20927
- kind: import_zod37.z.enum(PROVIDER_KINDS),
20928
- displayName: import_zod37.z.string(),
20929
- baseUrl: import_zod37.z.string().optional(),
21405
+ var ProviderValueSchema = import_zod38.z.strictObject({
21406
+ name: import_zod38.z.string(),
21407
+ kind: import_zod38.z.enum(PROVIDER_KINDS),
21408
+ displayName: import_zod38.z.string(),
21409
+ baseUrl: import_zod38.z.string().optional(),
20930
21410
  codex: CodexProviderConfigSchema.optional(),
20931
21411
  credential: CredentialSummarySchema2.optional(),
20932
- env: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.string()).optional()
21412
+ env: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.string()).optional()
20933
21413
  });
20934
- var ConfigNameInputSchema = import_zod37.z.strictObject({ name: import_zod37.z.string().min(1) });
20935
- var ConfigIdentityAddInputSchema = import_zod37.z.strictObject({ name: import_zod37.z.string().min(1), keepKeychainLogin: import_zod37.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
21414
+ var ConfigNameInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1) });
21415
+ var ConfigIdentityAddInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), keepKeychainLogin: import_zod38.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
20936
21416
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
20937
- var ConfigIdentitySetInputSchema = import_zod37.z.strictObject({
20938
- name: import_zod37.z.string().min(1),
21417
+ var ConfigIdentitySetInputSchema = import_zod38.z.strictObject({
21418
+ name: import_zod38.z.string().min(1),
20939
21419
  /** The identity's display label; `false` clears it. */
20940
- label: import_zod37.z.union([IdentityLabelSchema, import_zod37.z.literal(false)]).optional(),
20941
- defaultConfigProfile: import_zod37.z.union([import_zod37.z.string().min(1), import_zod37.z.literal(false)]).optional(),
21420
+ label: import_zod38.z.union([IdentityLabelSchema, import_zod38.z.literal(false)]).optional(),
21421
+ defaultConfigProfile: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
20942
21422
  /** The provider the identity exists for; `false` clears it. */
20943
- provider: import_zod37.z.union([import_zod37.z.string().min(1), import_zod37.z.literal(false)]).optional(),
20944
- allowAmbientCredential: import_zod37.z.boolean().optional(),
20945
- credential: import_zod37.z.union([import_zod37.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
21423
+ provider: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
21424
+ allowAmbientCredential: import_zod38.z.boolean().optional(),
21425
+ credential: import_zod38.z.union([import_zod38.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
20946
21426
  /** `false` removes the anchors; a list replaces them. */
20947
- anchors: import_zod37.z.union([import_zod37.z.literal(false), import_zod37.z.array(AnchorSchema).min(1)]).optional()
21427
+ anchors: import_zod38.z.union([import_zod38.z.literal(false), import_zod38.z.array(AnchorSchema).min(1)]).optional()
20948
21428
  });
20949
21429
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
20950
- var ConfigIdentityRemoveInputSchema = import_zod37.z.strictObject({ name: import_zod37.z.string().min(1), confirm: RemovalConfirmationSchema });
21430
+ var ConfigIdentityRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
20951
21431
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
20952
- var ConfigStatuslineSetSchema = import_zod37.z.record(import_zod37.z.string(), import_zod37.z.unknown()).superRefine((settings, context) => {
21432
+ var ConfigStatuslineSetSchema = import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()).superRefine((settings, context) => {
20953
21433
  for (const key of Object.keys(settings)) {
20954
21434
  if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
20955
21435
  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` });
@@ -20957,93 +21437,93 @@ var ConfigStatuslineSetSchema = import_zod37.z.record(import_zod37.z.string(), i
20957
21437
  }
20958
21438
  });
20959
21439
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
20960
- var ConfigProfileAddInputSchema = import_zod37.z.strictObject({
20961
- name: import_zod37.z.string().min(1),
20962
- extends: import_zod37.z.array(import_zod37.z.string().min(1)).optional(),
20963
- description: import_zod37.z.string().optional()
21440
+ var ConfigProfileAddInputSchema = import_zod38.z.strictObject({
21441
+ name: import_zod38.z.string().min(1),
21442
+ extends: import_zod38.z.array(import_zod38.z.string().min(1)).optional(),
21443
+ description: import_zod38.z.string().optional()
20964
21444
  });
20965
21445
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
20966
- var ConfigProfileSetInputSchema = import_zod37.z.strictObject({
20967
- name: import_zod37.z.string().min(1),
20968
- category: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.boolean()).optional(),
20969
- entry: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.boolean()).optional(),
20970
- extends: import_zod37.z.union([import_zod37.z.array(import_zod37.z.string().min(1)), import_zod37.z.literal(false)]).optional(),
20971
- description: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.literal(false)]).optional(),
20972
- launch: import_zod37.z.strictObject({
20973
- skipPermissions: import_zod37.z.boolean().optional(),
20974
- remoteControl: import_zod37.z.boolean().optional(),
20975
- headroom: import_zod37.z.boolean().optional(),
20976
- trackUsage: import_zod37.z.boolean().optional(),
20977
- provider: import_zod37.z.union([import_zod37.z.string().min(1), import_zod37.z.literal(false)]).optional(),
20978
- claudeVersion: import_zod37.z.union([import_zod37.z.string().min(1), import_zod37.z.literal(false)]).optional(),
20979
- delay: import_zod37.z.union([import_zod37.z.string().regex(DURATION_RE), import_zod37.z.literal(false)]).optional(),
20980
- pause: import_zod37.z.boolean().optional(),
20981
- explain: import_zod37.z.boolean().optional(),
20982
- proxyBypass: import_zod37.z.union([import_zod37.z.array(import_zod37.z.string().min(1)), import_zod37.z.literal(false)]).optional(),
20983
- statusline: import_zod37.z.strictObject({
21446
+ var ConfigProfileSetInputSchema = import_zod38.z.strictObject({
21447
+ name: import_zod38.z.string().min(1),
21448
+ category: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.boolean()).optional(),
21449
+ entry: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.boolean()).optional(),
21450
+ extends: import_zod38.z.union([import_zod38.z.array(import_zod38.z.string().min(1)), import_zod38.z.literal(false)]).optional(),
21451
+ description: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.literal(false)]).optional(),
21452
+ launch: import_zod38.z.strictObject({
21453
+ skipPermissions: import_zod38.z.boolean().optional(),
21454
+ remoteControl: import_zod38.z.boolean().optional(),
21455
+ headroom: import_zod38.z.boolean().optional(),
21456
+ trackUsage: import_zod38.z.boolean().optional(),
21457
+ provider: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
21458
+ claudeVersion: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
21459
+ delay: import_zod38.z.union([import_zod38.z.string().regex(DURATION_RE), import_zod38.z.literal(false)]).optional(),
21460
+ pause: import_zod38.z.boolean().optional(),
21461
+ explain: import_zod38.z.boolean().optional(),
21462
+ proxyBypass: import_zod38.z.union([import_zod38.z.array(import_zod38.z.string().min(1)), import_zod38.z.literal(false)]).optional(),
21463
+ statusline: import_zod38.z.strictObject({
20984
21464
  set: ConfigStatuslineSetSchema.optional(),
20985
- unset: import_zod37.z.array(import_zod37.z.string()).optional()
21465
+ unset: import_zod38.z.array(import_zod38.z.string()).optional()
20986
21466
  }).optional()
20987
21467
  }).optional()
20988
21468
  });
20989
21469
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
20990
- var ConfigProfileRemoveInputSchema = import_zod37.z.strictObject({ name: import_zod37.z.string().min(1), confirm: RemovalConfirmationSchema });
21470
+ var ConfigProfileRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
20991
21471
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
20992
21472
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
20993
- var PoolMembersInputSchema = import_zod37.z.array(import_zod37.z.string().min(1)).min(1);
20994
- var ConfigPoolAddInputSchema = import_zod37.z.strictObject({
20995
- name: import_zod37.z.string().min(1),
21473
+ var PoolMembersInputSchema = import_zod38.z.array(import_zod38.z.string().min(1)).min(1);
21474
+ var ConfigPoolAddInputSchema = import_zod38.z.strictObject({
21475
+ name: import_zod38.z.string().min(1),
20996
21476
  identities: PoolMembersInputSchema,
20997
- preference: import_zod37.z.enum(POOL_PREFERENCES).optional(),
20998
- resumeOnLimit: import_zod37.z.boolean().optional(),
20999
- compactBeforeLimit: import_zod37.z.boolean().optional(),
21477
+ preference: import_zod38.z.enum(POOL_PREFERENCES).optional(),
21478
+ resumeOnLimit: import_zod38.z.boolean().optional(),
21479
+ compactBeforeLimit: import_zod38.z.boolean().optional(),
21000
21480
  compactAtUtilisation: CompactAtUtilisationSchema.optional()
21001
21481
  });
21002
21482
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
21003
- var ConfigPoolSetInputSchema = import_zod37.z.strictObject({
21004
- name: import_zod37.z.string().min(1),
21483
+ var ConfigPoolSetInputSchema = import_zod38.z.strictObject({
21484
+ name: import_zod38.z.string().min(1),
21005
21485
  identities: PoolMembersInputSchema.optional(),
21006
- preference: import_zod37.z.union([import_zod37.z.enum(POOL_PREFERENCES), import_zod37.z.literal(false)]).optional(),
21007
- resumeOnLimit: import_zod37.z.boolean().optional(),
21008
- compactBeforeLimit: import_zod37.z.boolean().optional(),
21009
- compactAtUtilisation: import_zod37.z.union([CompactAtUtilisationSchema, import_zod37.z.literal(false)]).optional()
21486
+ preference: import_zod38.z.union([import_zod38.z.enum(POOL_PREFERENCES), import_zod38.z.literal(false)]).optional(),
21487
+ resumeOnLimit: import_zod38.z.boolean().optional(),
21488
+ compactBeforeLimit: import_zod38.z.boolean().optional(),
21489
+ compactAtUtilisation: import_zod38.z.union([CompactAtUtilisationSchema, import_zod38.z.literal(false)]).optional()
21010
21490
  });
21011
21491
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
21012
- var ConfigPoolRemoveInputSchema = import_zod37.z.strictObject({ name: import_zod37.z.string().min(1), confirm: RemovalConfirmationSchema });
21492
+ var ConfigPoolRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
21013
21493
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
21014
21494
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
21015
- var ConfigProviderAddInputSchema = import_zod37.z.strictObject({
21016
- name: import_zod37.z.string().min(1),
21017
- kind: import_zod37.z.enum(PROVIDER_KINDS).optional(),
21018
- displayName: import_zod37.z.string().min(1),
21019
- baseUrl: import_zod37.z.string().min(1).optional(),
21495
+ var ConfigProviderAddInputSchema = import_zod38.z.strictObject({
21496
+ name: import_zod38.z.string().min(1),
21497
+ kind: import_zod38.z.enum(PROVIDER_KINDS).optional(),
21498
+ displayName: import_zod38.z.string().min(1),
21499
+ baseUrl: import_zod38.z.string().min(1).optional(),
21020
21500
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
21021
21501
  codex: CodexProviderConfigSchema.optional()
21022
21502
  });
21023
21503
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
21024
- var ConfigProviderSetInputSchema = import_zod37.z.strictObject({
21025
- name: import_zod37.z.string().min(1),
21026
- displayName: import_zod37.z.string().min(1).optional(),
21027
- baseUrl: import_zod37.z.string().min(1).optional(),
21504
+ var ConfigProviderSetInputSchema = import_zod38.z.strictObject({
21505
+ name: import_zod38.z.string().min(1),
21506
+ displayName: import_zod38.z.string().min(1).optional(),
21507
+ baseUrl: import_zod38.z.string().min(1).optional(),
21028
21508
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
21029
21509
  codex: CodexProviderConfigSchema.optional()
21030
21510
  });
21031
21511
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
21032
- var ConfigProviderRemoveInputSchema = import_zod37.z.strictObject({ name: import_zod37.z.string().min(1), confirm: RemovalConfirmationSchema });
21512
+ var ConfigProviderRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
21033
21513
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
21034
- var ConfigRuleAddInputSchema = import_zod37.z.strictObject({
21035
- path: import_zod37.z.string().min(1),
21036
- configProfile: import_zod37.z.string().min(1).optional(),
21037
- identity: import_zod37.z.string().min(1).optional()
21514
+ var ConfigRuleAddInputSchema = import_zod38.z.strictObject({
21515
+ path: import_zod38.z.string().min(1),
21516
+ configProfile: import_zod38.z.string().min(1).optional(),
21517
+ identity: import_zod38.z.string().min(1).optional()
21038
21518
  });
21039
21519
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
21040
- var ConfigRuleSetInputSchema = import_zod37.z.strictObject({
21041
- path: import_zod37.z.string().min(1),
21042
- configProfile: import_zod37.z.union([import_zod37.z.string().min(1), import_zod37.z.literal(false)]).optional(),
21043
- identity: import_zod37.z.union([import_zod37.z.string().min(1), import_zod37.z.literal(false)]).optional()
21520
+ var ConfigRuleSetInputSchema = import_zod38.z.strictObject({
21521
+ path: import_zod38.z.string().min(1),
21522
+ configProfile: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
21523
+ identity: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional()
21044
21524
  });
21045
21525
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
21046
- var ConfigRuleRemoveInputSchema = import_zod37.z.strictObject({ path: import_zod37.z.string().min(1), confirm: RemovalConfirmationSchema });
21526
+ var ConfigRuleRemoveInputSchema = import_zod38.z.strictObject({ path: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
21047
21527
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
21048
21528
 
21049
21529
  // src/frontdoor/configApi.ts
@@ -21395,51 +21875,51 @@ var import_openapi4 = require("@orpc/openapi");
21395
21875
  var import_server3 = require("@orpc/server");
21396
21876
 
21397
21877
  // src/frontdoor/eventSchemas.ts
21398
- var import_zod38 = require("zod");
21878
+ var import_zod39 = require("zod");
21399
21879
  init_schema2();
21400
21880
  var DOOR_EVENT_SOURCE_RC = "rc";
21401
21881
  var LAUNCH_EVENT_SOURCE = "launch";
21402
21882
  var USAGE_EVENT_SOURCE = "usage";
21403
21883
  var DOOR_HEALTH_EVENT_SOURCE = "door";
21404
21884
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
21405
- var DoorEventSchema = import_zod38.z.strictObject({
21406
- source: import_zod38.z.string().min(1),
21885
+ var DoorEventSchema = import_zod39.z.strictObject({
21886
+ source: import_zod39.z.string().min(1),
21407
21887
  /** A positive integer because the backbone's counters start at one and only ever increase. */
21408
- sequence: import_zod38.z.number().int().positive(),
21409
- payload: import_zod38.z.unknown()
21410
- });
21411
- var DoorEventSourceQuerySchema = import_zod38.z.strictObject({
21412
- sources: import_zod38.z.array(import_zod38.z.string().min(1)).min(1).optional()
21413
- });
21414
- var LaunchLifecycleEventSchema = import_zod38.z.strictObject({
21415
- kind: import_zod38.z.enum(["registered", "pruned", "ended"]),
21416
- pid: import_zod38.z.number().int().positive(),
21417
- startedAt: import_zod38.z.number(),
21418
- observedAt: import_zod38.z.number()
21419
- });
21420
- var DoorHealthEventSchema = import_zod38.z.discriminatedUnion("kind", [
21421
- import_zod38.z.strictObject({ kind: import_zod38.z.literal("generation"), pid: import_zod38.z.number().int().positive(), providerPort: import_zod38.z.number().int().positive(), connectPort: import_zod38.z.number().int().positive(), directPort: import_zod38.z.number().int().positive(), observedAt: import_zod38.z.number() }),
21422
- import_zod38.z.strictObject({ kind: import_zod38.z.literal("listenerFailed"), pid: import_zod38.z.number().int().positive(), listener: import_zod38.z.enum(["provider", "connect", "direct"]), message: import_zod38.z.string(), observedAt: import_zod38.z.number() }),
21423
- import_zod38.z.strictObject({ kind: import_zod38.z.literal("binaryTurnover"), pid: import_zod38.z.number().int().positive(), observedAt: import_zod38.z.number() }),
21424
- import_zod38.z.strictObject({ kind: import_zod38.z.literal("idleShutdown"), pid: import_zod38.z.number().int().positive(), observedAt: import_zod38.z.number() }),
21425
- import_zod38.z.strictObject({ kind: import_zod38.z.literal("superseded"), pid: import_zod38.z.number().int().positive(), ownerPid: import_zod38.z.number().int().positive(), observedAt: import_zod38.z.number() }),
21426
- import_zod38.z.strictObject({ kind: import_zod38.z.literal("drained"), pid: import_zod38.z.number().int().positive(), observedAt: import_zod38.z.number() })
21888
+ sequence: import_zod39.z.number().int().positive(),
21889
+ payload: import_zod39.z.unknown()
21890
+ });
21891
+ var DoorEventSourceQuerySchema = import_zod39.z.strictObject({
21892
+ sources: import_zod39.z.array(import_zod39.z.string().min(1)).min(1).optional()
21893
+ });
21894
+ var LaunchLifecycleEventSchema = import_zod39.z.strictObject({
21895
+ kind: import_zod39.z.enum(["registered", "pruned", "ended"]),
21896
+ pid: import_zod39.z.number().int().positive(),
21897
+ startedAt: import_zod39.z.number(),
21898
+ observedAt: import_zod39.z.number()
21899
+ });
21900
+ var DoorHealthEventSchema = import_zod39.z.discriminatedUnion("kind", [
21901
+ import_zod39.z.strictObject({ kind: import_zod39.z.literal("generation"), pid: import_zod39.z.number().int().positive(), providerPort: import_zod39.z.number().int().positive(), connectPort: import_zod39.z.number().int().positive(), directPort: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
21902
+ import_zod39.z.strictObject({ kind: import_zod39.z.literal("listenerFailed"), pid: import_zod39.z.number().int().positive(), listener: import_zod39.z.enum(["provider", "connect", "direct"]), message: import_zod39.z.string(), observedAt: import_zod39.z.number() }),
21903
+ import_zod39.z.strictObject({ kind: import_zod39.z.literal("binaryTurnover"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
21904
+ import_zod39.z.strictObject({ kind: import_zod39.z.literal("idleShutdown"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
21905
+ import_zod39.z.strictObject({ kind: import_zod39.z.literal("superseded"), pid: import_zod39.z.number().int().positive(), ownerPid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
21906
+ import_zod39.z.strictObject({ kind: import_zod39.z.literal("drained"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() })
21427
21907
  ]);
21428
- var QuotaExpiringEventSchema = import_zod38.z.strictObject({
21908
+ var QuotaExpiringEventSchema = import_zod39.z.strictObject({
21429
21909
  /** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
21430
- id: import_zod38.z.string().min(1),
21910
+ id: import_zod39.z.string().min(1),
21431
21911
  /** The identity's name when the event was published, absent for an identity no longer stored under the id. */
21432
- name: import_zod38.z.string().min(1).optional(),
21433
- provider: import_zod38.z.string().min(1),
21434
- window: import_zod38.z.enum(["fiveHour", "sevenDay"]),
21912
+ name: import_zod39.z.string().min(1).optional(),
21913
+ provider: import_zod39.z.string().min(1),
21914
+ window: import_zod39.z.enum(["fiveHour", "sevenDay"]),
21435
21915
  /** 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. */
21436
- utilization: import_zod38.z.number().min(0).max(1),
21437
- resetsAt: import_zod38.z.iso.datetime(),
21438
- observedAt: import_zod38.z.number()
21916
+ utilization: import_zod39.z.number().min(0).max(1),
21917
+ resetsAt: import_zod39.z.iso.datetime(),
21918
+ observedAt: import_zod39.z.number()
21439
21919
  });
21440
21920
  var UsageChangeEventSchema = UsageSnapshotSchema.extend({
21441
- id: import_zod38.z.string().min(1),
21442
- name: import_zod38.z.string().min(1).optional()
21921
+ id: import_zod39.z.string().min(1),
21922
+ name: import_zod39.z.string().min(1).optional()
21443
21923
  });
21444
21924
 
21445
21925
  // src/frontdoor/eventsApi.ts
@@ -21483,7 +21963,7 @@ function createEventsApiRouter(deps) {
21483
21963
  // src/frontdoor/lifecycleApi.ts
21484
21964
  var import_client4 = require("@orpc/client");
21485
21965
  var import_openapi5 = require("@orpc/openapi");
21486
- var import_zod39 = require("zod");
21966
+ var import_zod40 = require("zod");
21487
21967
  init_update();
21488
21968
  var FRONTDOOR_API_TAG = "frontdoor";
21489
21969
  var UPDATE_API_TAG = "update";
@@ -21491,7 +21971,7 @@ function createLifecycleApiRouter(deps) {
21491
21971
  const authed = doorApiAuth(deps.expectedToken);
21492
21972
  return {
21493
21973
  frontdoor: {
21494
- refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(import_zod39.z.strictObject({ requested: import_zod39.z.literal(true) })).handler(() => {
21974
+ refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(import_zod40.z.strictObject({ requested: import_zod40.z.literal(true) })).handler(() => {
21495
21975
  deps.refreshCatalogues();
21496
21976
  return { requested: true };
21497
21977
  }),
@@ -21528,62 +22008,62 @@ init_cliError();
21528
22008
 
21529
22009
  // src/frontdoor/launchSchemas.ts
21530
22010
  var import_node_path44 = __toESM(require("node:path"), 1);
21531
- var import_zod40 = require("zod");
22011
+ var import_zod41 = require("zod");
21532
22012
  init_statusline();
21533
22013
  init_claudeVersion();
21534
22014
  init_identity();
21535
- var LaunchResolveInputSchema = import_zod40.z.strictObject({
21536
- path: import_zod40.z.string().min(1),
22015
+ var LaunchResolveInputSchema = import_zod41.z.strictObject({
22016
+ path: import_zod41.z.string().min(1),
21537
22017
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
21538
- argv: import_zod40.z.readonly(import_zod40.z.array(import_zod40.z.string())).optional(),
22018
+ argv: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())).optional(),
21539
22019
  /** 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. */
21540
- env: import_zod40.z.record(import_zod40.z.string(), import_zod40.z.string()).optional()
22020
+ env: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.string()).optional()
21541
22021
  }).refine((input) => import_node_path44.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
21542
- var LaunchPoolDecisionSchema = import_zod40.z.strictObject({
21543
- name: import_zod40.z.string(),
21544
- reasons: import_zod40.z.readonly(import_zod40.z.array(import_zod40.z.string())),
21545
- movedOff: import_zod40.z.strictObject({ identity: import_zod40.z.string(), reason: import_zod40.z.string() }).optional()
21546
- });
21547
- var LaunchDecisionSchema = import_zod40.z.strictObject({
21548
- identity: import_zod40.z.string().optional(),
21549
- identityId: import_zod40.z.string().optional(),
21550
- identitySource: import_zod40.z.enum(IDENTITY_DECISION_SOURCES),
22022
+ var LaunchPoolDecisionSchema = import_zod41.z.strictObject({
22023
+ name: import_zod41.z.string(),
22024
+ reasons: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
22025
+ movedOff: import_zod41.z.strictObject({ identity: import_zod41.z.string(), reason: import_zod41.z.string() }).optional()
22026
+ });
22027
+ var LaunchDecisionSchema = import_zod41.z.strictObject({
22028
+ identity: import_zod41.z.string().optional(),
22029
+ identityId: import_zod41.z.string().optional(),
22030
+ identitySource: import_zod41.z.enum(IDENTITY_DECISION_SOURCES),
21551
22031
  pool: LaunchPoolDecisionSchema.optional(),
21552
22032
  /** 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. */
21553
- configDirEscapeHatch: import_zod40.z.boolean(),
21554
- configDir: import_zod40.z.string().optional(),
21555
- configProfile: import_zod40.z.string().optional(),
21556
- configProfileSource: import_zod40.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
21557
- provider: import_zod40.z.string().optional()
21558
- });
21559
- var LaunchFlagsSchema = import_zod40.z.strictObject({
21560
- skipPermissions: import_zod40.z.boolean(),
21561
- remoteControl: import_zod40.z.boolean(),
21562
- headroom: import_zod40.z.boolean(),
21563
- trackUsage: import_zod40.z.boolean(),
21564
- pause: import_zod40.z.boolean(),
21565
- explain: import_zod40.z.boolean(),
22033
+ configDirEscapeHatch: import_zod41.z.boolean(),
22034
+ configDir: import_zod41.z.string().optional(),
22035
+ configProfile: import_zod41.z.string().optional(),
22036
+ configProfileSource: import_zod41.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
22037
+ provider: import_zod41.z.string().optional()
22038
+ });
22039
+ var LaunchFlagsSchema = import_zod41.z.strictObject({
22040
+ skipPermissions: import_zod41.z.boolean(),
22041
+ remoteControl: import_zod41.z.boolean(),
22042
+ headroom: import_zod41.z.boolean(),
22043
+ trackUsage: import_zod41.z.boolean(),
22044
+ pause: import_zod41.z.boolean(),
22045
+ explain: import_zod41.z.boolean(),
21566
22046
  /** How long the launch waits after its own output before it starts claude, in milliseconds. */
21567
- delayMs: import_zod40.z.number(),
22047
+ delayMs: import_zod41.z.number(),
21568
22048
  /** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
21569
- proxyBypass: import_zod40.z.array(import_zod40.z.string()).readonly(),
22049
+ proxyBypass: import_zod41.z.array(import_zod41.z.string()).readonly(),
21570
22050
  /** How the session's built-in statusline looks, when the launch configures any of it. */
21571
22051
  statusline: StatuslineSchema.optional()
21572
22052
  });
21573
- var LaunchResolveOutputSchema = import_zod40.z.strictObject({
22053
+ var LaunchResolveOutputSchema = import_zod41.z.strictObject({
21574
22054
  decision: LaunchDecisionSchema,
21575
22055
  flags: LaunchFlagsSchema,
21576
- claudeVersion: import_zod40.z.strictObject({ version: import_zod40.z.string(), source: import_zod40.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
22056
+ claudeVersion: import_zod41.z.strictObject({ version: import_zod41.z.string(), source: import_zod41.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
21577
22057
  /** The real `claude` binary the launch would spawn, on the door's host. */
21578
- bin: import_zod40.z.string(),
22058
+ bin: import_zod41.z.string(),
21579
22059
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
21580
- args: import_zod40.z.readonly(import_zod40.z.array(import_zod40.z.string())),
22060
+ args: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
21581
22061
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
21582
- credential: import_zod40.z.strictObject({ subject: import_zod40.z.enum(["provider", "identity"]), name: import_zod40.z.string(), summary: CredentialSummarySchema }).optional(),
21583
- routing: import_zod40.z.strictObject({ frontDoor: import_zod40.z.boolean(), headroom: import_zod40.z.boolean() }),
22062
+ credential: import_zod41.z.strictObject({ subject: import_zod41.z.enum(["provider", "identity"]), name: import_zod41.z.string(), summary: CredentialSummarySchema }).optional(),
22063
+ routing: import_zod41.z.strictObject({ frontDoor: import_zod41.z.boolean(), headroom: import_zod41.z.boolean() }),
21584
22064
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
21585
- environment: import_zod40.z.readonly(import_zod40.z.array(import_zod40.z.string())),
21586
- warnings: import_zod40.z.readonly(import_zod40.z.array(import_zod40.z.string()))
22065
+ environment: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
22066
+ warnings: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string()))
21587
22067
  });
21588
22068
 
21589
22069
  // src/frontdoor/launchApi.ts
@@ -21619,22 +22099,22 @@ function createLaunchApiRouter(deps) {
21619
22099
  // src/frontdoor/agentTreesApi.ts
21620
22100
  var import_client6 = require("@orpc/client");
21621
22101
  var import_openapi7 = require("@orpc/openapi");
21622
- var import_zod41 = require("zod");
22102
+ var import_zod42 = require("zod");
21623
22103
  init_cliError();
21624
- var AgentTreesListInputSchema = import_zod41.z.strictObject({
22104
+ var AgentTreesListInputSchema = import_zod42.z.strictObject({
21625
22105
  /** Only this identity's sessions. */
21626
- identity: import_zod41.z.string().optional(),
22106
+ identity: import_zod42.z.string().optional(),
21627
22107
  /** Include sessions that spawned no agent and ran no workflow. */
21628
- all: import_zod41.z.boolean().optional()
22108
+ all: import_zod42.z.boolean().optional()
21629
22109
  });
21630
- var AgentTreesListOutputSchema = import_zod41.z.array(SessionSummarySchema);
21631
- var AgentTreesShowInputSchema = import_zod41.z.strictObject({
22110
+ var AgentTreesListOutputSchema = import_zod42.z.array(SessionSummarySchema);
22111
+ var AgentTreesShowInputSchema = import_zod42.z.strictObject({
21632
22112
  /** A session id, or an unambiguous prefix of one. */
21633
- session: import_zod41.z.string().min(1),
22113
+ session: import_zod42.z.string().min(1),
21634
22114
  /** Look only in this identity. */
21635
- identity: import_zod41.z.string().optional()
22115
+ identity: import_zod42.z.string().optional()
21636
22116
  });
21637
- var AgentTreesShowOutputSchema = import_zod41.z.strictObject({ identities: import_zod41.z.array(import_zod41.z.string()), ...MergedAgentTreeSchema.shape });
22117
+ var AgentTreesShowOutputSchema = import_zod42.z.strictObject({ identities: import_zod42.z.array(import_zod42.z.string()), ...MergedAgentTreeSchema.shape });
21638
22118
  function asBadRequest(error) {
21639
22119
  if (error instanceof CliError) {
21640
22120
  throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
@@ -21687,7 +22167,7 @@ var import_openapi8 = require("@orpc/openapi");
21687
22167
  var import_server4 = require("@orpc/server");
21688
22168
 
21689
22169
  // src/frontdoor/rcEventLog.ts
21690
- var import_zod42 = require("zod");
22170
+ var import_zod43 = require("zod");
21691
22171
 
21692
22172
  // src/frontdoor/eventHub.ts
21693
22173
  var DOOR_EVENT_BUFFER_EVENTS = 100;
@@ -21810,46 +22290,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
21810
22290
  var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
21811
22291
  var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
21812
22292
  var RC_PENDING_RETIRE_REASONS = ["answered", "expired", "session-ended"];
21813
- var transitionBase = { session: import_zod42.z.string(), at: import_zod42.z.number() };
21814
- var cursorFields = { cursor: import_zod42.z.string(), sequence: import_zod42.z.int().positive() };
21815
- var sessionAppearedShape = { kind: import_zod42.z.literal("session-appeared"), ...transitionBase };
21816
- var sessionEndedShape = { kind: import_zod42.z.literal("session-ended"), reason: import_zod42.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
21817
- var workerStateShape = { kind: import_zod42.z.literal("worker-state"), state: import_zod42.z.string(), previous: import_zod42.z.string().optional(), ...transitionBase };
21818
- var pendingBornShape = { kind: import_zod42.z.literal("pending-born"), requestId: import_zod42.z.string(), type: import_zod42.z.string(), summary: import_zod42.z.string(), ...transitionBase };
21819
- var pendingRetiredShape = { kind: import_zod42.z.literal("pending-retired"), requestId: import_zod42.z.string(), reason: import_zod42.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
21820
- var RcSessionTransitionSchema = import_zod42.z.discriminatedUnion("kind", [
21821
- import_zod42.z.strictObject(sessionAppearedShape),
21822
- import_zod42.z.strictObject(sessionEndedShape),
21823
- import_zod42.z.strictObject(workerStateShape),
21824
- import_zod42.z.strictObject(pendingBornShape),
21825
- import_zod42.z.strictObject(pendingRetiredShape)
22293
+ var transitionBase = { session: import_zod43.z.string(), at: import_zod43.z.number() };
22294
+ var cursorFields = { cursor: import_zod43.z.string(), sequence: import_zod43.z.int().positive() };
22295
+ var sessionAppearedShape = { kind: import_zod43.z.literal("session-appeared"), ...transitionBase };
22296
+ var sessionEndedShape = { kind: import_zod43.z.literal("session-ended"), reason: import_zod43.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
22297
+ var workerStateShape = { kind: import_zod43.z.literal("worker-state"), state: import_zod43.z.string(), previous: import_zod43.z.string().optional(), ...transitionBase };
22298
+ var pendingBornShape = { kind: import_zod43.z.literal("pending-born"), requestId: import_zod43.z.string(), type: import_zod43.z.string(), summary: import_zod43.z.string(), ...transitionBase };
22299
+ var pendingRetiredShape = { kind: import_zod43.z.literal("pending-retired"), requestId: import_zod43.z.string(), reason: import_zod43.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
22300
+ var RcSessionTransitionSchema = import_zod43.z.discriminatedUnion("kind", [
22301
+ import_zod43.z.strictObject(sessionAppearedShape),
22302
+ import_zod43.z.strictObject(sessionEndedShape),
22303
+ import_zod43.z.strictObject(workerStateShape),
22304
+ import_zod43.z.strictObject(pendingBornShape),
22305
+ import_zod43.z.strictObject(pendingRetiredShape)
21826
22306
  ]);
21827
22307
  var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
21828
22308
  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;
21829
22309
  var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
21830
- var RcSessionEventSchema = import_zod42.z.discriminatedUnion("kind", [
21831
- import_zod42.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
21832
- import_zod42.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
21833
- import_zod42.z.strictObject({ ...cursorFields, ...workerStateShape }),
21834
- import_zod42.z.strictObject({ ...cursorFields, ...pendingBornShape }),
21835
- import_zod42.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
22310
+ var RcSessionEventSchema = import_zod43.z.discriminatedUnion("kind", [
22311
+ import_zod43.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
22312
+ import_zod43.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
22313
+ import_zod43.z.strictObject({ ...cursorFields, ...workerStateShape }),
22314
+ import_zod43.z.strictObject({ ...cursorFields, ...pendingBornShape }),
22315
+ import_zod43.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
21836
22316
  ]);
21837
- var RcSessionEventsReadInputSchema = import_zod42.z.strictObject({
22317
+ var RcSessionEventsReadInputSchema = import_zod43.z.strictObject({
21838
22318
  /** The cursor of the last event the caller saw; every retained event when omitted. */
21839
- since: import_zod42.z.string().min(1).optional(),
22319
+ since: import_zod43.z.string().min(1).optional(),
21840
22320
  /** One `cse_` session id; every session when omitted. */
21841
- session: import_zod42.z.string().min(1).optional(),
22321
+ session: import_zod43.z.string().min(1).optional(),
21842
22322
  /** The most events one answer carries; every event after `since` when omitted. */
21843
- limit: import_zod42.z.int().positive().optional()
22323
+ limit: import_zod43.z.int().positive().optional()
21844
22324
  });
21845
22325
  var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
21846
22326
  /** 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. */
21847
- limit: import_zod42.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
22327
+ limit: import_zod43.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
21848
22328
  });
21849
22329
  var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
21850
- var RcSessionEventsReadOutputSchema = import_zod42.z.discriminatedUnion("status", [
21851
- import_zod42.z.strictObject({ status: import_zod42.z.literal("ok"), events: import_zod42.z.readonly(import_zod42.z.array(RcSessionEventSchema)), cursor: import_zod42.z.string(), more: import_zod42.z.boolean(), head: import_zod42.z.string() }),
21852
- import_zod42.z.strictObject({ status: import_zod42.z.literal("expired"), message: import_zod42.z.string(), head: import_zod42.z.string() })
22330
+ var RcSessionEventsReadOutputSchema = import_zod43.z.discriminatedUnion("status", [
22331
+ import_zod43.z.strictObject({ status: import_zod43.z.literal("ok"), events: import_zod43.z.readonly(import_zod43.z.array(RcSessionEventSchema)), cursor: import_zod43.z.string(), more: import_zod43.z.boolean(), head: import_zod43.z.string() }),
22332
+ import_zod43.z.strictObject({ status: import_zod43.z.literal("expired"), message: import_zod43.z.string(), head: import_zod43.z.string() })
21853
22333
  ]);
21854
22334
  var CURSOR_SEPARATOR = ".";
21855
22335
  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";
@@ -22348,15 +22828,15 @@ function createQuotaExpiringPublisher(hub, deps) {
22348
22828
 
22349
22829
  // src/frontdoor/rcLiveUsage.ts
22350
22830
  var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
22351
- function isRecord8(value) {
22831
+ function isRecord9(value) {
22352
22832
  return typeof value === "object" && value !== null && !Array.isArray(value);
22353
22833
  }
22354
22834
  function rcRateLimitInfoOf(event) {
22355
22835
  const payload = event.envelope.payload;
22356
- if (!isRecord8(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
22836
+ if (!isRecord9(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
22357
22837
  return void 0;
22358
22838
  }
22359
- if (!isRecord8(payload.rate_limit_info)) {
22839
+ if (!isRecord9(payload.rate_limit_info)) {
22360
22840
  return void 0;
22361
22841
  }
22362
22842
  const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
@@ -22444,7 +22924,7 @@ function createSseParser() {
22444
22924
  }
22445
22925
  };
22446
22926
  }
22447
- function isRecord9(value) {
22927
+ function isRecord10(value) {
22448
22928
  return typeof value === "object" && value !== null && !Array.isArray(value);
22449
22929
  }
22450
22930
  function sequenceNumOf(value) {
@@ -22466,7 +22946,7 @@ function parseRcStreamEnvelope(parsed) {
22466
22946
  } catch {
22467
22947
  return void 0;
22468
22948
  }
22469
- if (!isRecord9(data)) {
22949
+ if (!isRecord10(data)) {
22470
22950
  return void 0;
22471
22951
  }
22472
22952
  const eventType = data.event_type;
@@ -22713,7 +23193,13 @@ init_capability();
22713
23193
  // src/frontdoor/rcSelfHostEndpoints.ts
22714
23194
  var RC_SOURCE_WORKER = "worker";
22715
23195
  var RC_SOURCE_CLIENT = "client";
22716
- function isRecord10(value) {
23196
+ var CLIENT_PLATFORM_HEADER = "anthropic-client-platform";
23197
+ function withClientPlatform(payload, headers) {
23198
+ const rest = Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "client_platform"));
23199
+ const platform = headers[CLIENT_PLATFORM_HEADER];
23200
+ return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
23201
+ }
23202
+ function isRecord11(value) {
22717
23203
  return typeof value === "object" && value !== null && !Array.isArray(value);
22718
23204
  }
22719
23205
  function parseJsonObject2(body) {
@@ -22723,7 +23209,7 @@ function parseJsonObject2(body) {
22723
23209
  } catch {
22724
23210
  return void 0;
22725
23211
  }
22726
- return isRecord10(parsed) ? parsed : void 0;
23212
+ return isRecord11(parsed) ? parsed : void 0;
22727
23213
  }
22728
23214
  function nonEmptyString2(record, field) {
22729
23215
  const value = record === void 0 ? void 0 : record[field];
@@ -22797,11 +23283,11 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
22797
23283
  }
22798
23284
  const results = [];
22799
23285
  for (const event of events) {
22800
- if (!isRecord10(event) || !isRecord10(event.payload)) {
23286
+ if (!isRecord11(event) || !isRecord11(event.payload)) {
22801
23287
  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" } });
22802
23288
  return true;
22803
23289
  }
22804
- const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, event.payload);
23290
+ const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
22805
23291
  results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
22806
23292
  }
22807
23293
  ctx.sweep();
@@ -22897,7 +23383,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
22897
23383
  // src/frontdoor/rcSelfHostConversations.ts
22898
23384
  var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
22899
23385
  var RC_CONVERSATION_ID_PREFIX = "conv_";
22900
- function isRecord11(value) {
23386
+ function isRecord12(value) {
22901
23387
  return typeof value === "object" && value !== null && !Array.isArray(value);
22902
23388
  }
22903
23389
  function parseJsonObject3(body) {
@@ -22907,7 +23393,7 @@ function parseJsonObject3(body) {
22907
23393
  } catch {
22908
23394
  return void 0;
22909
23395
  }
22910
- return isRecord11(parsed) ? parsed : void 0;
23396
+ return isRecord12(parsed) ? parsed : void 0;
22911
23397
  }
22912
23398
  function nonEmptyString3(record, field) {
22913
23399
  const value = record === void 0 ? void 0 : record[field];
@@ -22961,11 +23447,11 @@ async function serveRcConversations(ctx, pathname, method) {
22961
23447
  }
22962
23448
  const results = [];
22963
23449
  for (const event of events) {
22964
- if (!isRecord11(event) || !isRecord11(event.payload)) {
23450
+ if (!isRecord12(event) || !isRecord12(event.payload)) {
22965
23451
  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" } });
22966
23452
  return;
22967
23453
  }
22968
- const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, event.payload);
23454
+ const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
22969
23455
  results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
22970
23456
  }
22971
23457
  ctx.sweep();
@@ -22993,7 +23479,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
22993
23479
  var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
22994
23480
  var MS_PER_SECOND6 = 1e3;
22995
23481
  var HTTP_SERVICE_UNAVAILABLE = 503;
22996
- function isRecord12(value) {
23482
+ function isRecord13(value) {
22997
23483
  return typeof value === "object" && value !== null && !Array.isArray(value);
22998
23484
  }
22999
23485
  function parseJsonObject4(body) {
@@ -23003,7 +23489,7 @@ function parseJsonObject4(body) {
23003
23489
  } catch {
23004
23490
  return void 0;
23005
23491
  }
23006
- return isRecord12(parsed) ? parsed : void 0;
23492
+ return isRecord13(parsed) ? parsed : void 0;
23007
23493
  }
23008
23494
  function growthBookFeatures() {
23009
23495
  return {
@@ -23357,7 +23843,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
23357
23843
  var RC_STREAM_EVENT_NAME2 = "client_event";
23358
23844
  var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
23359
23845
  var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
23360
- function isRecord13(value) {
23846
+ function isRecord14(value) {
23361
23847
  return typeof value === "object" && value !== null && !Array.isArray(value);
23362
23848
  }
23363
23849
  function isWebSearchRefusal(value) {
@@ -23441,7 +23927,7 @@ function parseJsonObject5(body) {
23441
23927
  } catch {
23442
23928
  return void 0;
23443
23929
  }
23444
- return isRecord13(parsed) ? parsed : void 0;
23930
+ return isRecord14(parsed) ? parsed : void 0;
23445
23931
  }
23446
23932
  function mintWorkerJwt(randomToken, issuedAt) {
23447
23933
  const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
@@ -23701,7 +24187,7 @@ data: ${JSON.stringify(envelope)}
23701
24187
  if (status !== void 0) {
23702
24188
  session.workerStatus = status;
23703
24189
  }
23704
- if (isRecord13(body?.external_metadata)) {
24190
+ if (isRecord14(body?.external_metadata)) {
23705
24191
  session.externalMetadata = body.external_metadata;
23706
24192
  }
23707
24193
  await answerJson2(response, HTTP_STATUS.ok, {});
@@ -23731,7 +24217,7 @@ data: ${JSON.stringify(envelope)}
23731
24217
  }
23732
24218
  const results = [];
23733
24219
  for (const event of events) {
23734
- if (!isRecord13(event) || !isRecord13(event.payload)) {
24220
+ if (!isRecord14(event) || !isRecord14(event.payload)) {
23735
24221
  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" } });
23736
24222
  return;
23737
24223
  }
@@ -23764,7 +24250,7 @@ data: ${JSON.stringify(envelope)}
23764
24250
  return;
23765
24251
  }
23766
24252
  for (const event of events) {
23767
- if (isRecord13(event)) {
24253
+ if (isRecord14(event)) {
23768
24254
  session.internalEvents.push({ eventId: deps.newUuid(), body: event });
23769
24255
  }
23770
24256
  }
@@ -23860,11 +24346,11 @@ data: ${JSON.stringify(envelope)}
23860
24346
  }
23861
24347
  const results = [];
23862
24348
  for (const event of events) {
23863
- if (!isRecord13(event) || !isRecord13(event.payload)) {
24349
+ if (!isRecord14(event) || !isRecord14(event.payload)) {
23864
24350
  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" } });
23865
24351
  return;
23866
24352
  }
23867
- const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, event.payload);
24353
+ const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
23868
24354
  results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
23869
24355
  }
23870
24356
  sweep();
@@ -23998,7 +24484,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
23998
24484
  var RC_SELF_HOST_RECORD_FILE = "credential.json";
23999
24485
  var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
24000
24486
  var SELF_HOST_SUBSCRIPTION_TYPE = "max";
24001
- function isRecord14(value) {
24487
+ function isRecord15(value) {
24002
24488
  return typeof value === "object" && value !== null && !Array.isArray(value);
24003
24489
  }
24004
24490
  function readJsonObject(fs17, file) {
@@ -24012,7 +24498,7 @@ function readJsonObject(fs17, file) {
24012
24498
  } catch {
24013
24499
  return void 0;
24014
24500
  }
24015
- return isRecord14(parsed) ? parsed : void 0;
24501
+ return isRecord15(parsed) ? parsed : void 0;
24016
24502
  }
24017
24503
  function readRcSelfHostRecord(fs17, frontdoorDir) {
24018
24504
  const parsed = readJsonObject(fs17, import_node_path45.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
@@ -24040,7 +24526,7 @@ function mintRcSelfHostCredential(deps) {
24040
24526
  const recordFile2 = import_node_path45.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
24041
24527
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
24042
24528
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
24043
- const existingOauth = isRecord14(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
24529
+ const existingOauth = isRecord15(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
24044
24530
  const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
24045
24531
  const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
24046
24532
  if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
@@ -24057,7 +24543,7 @@ function mintRcSelfHostCredential(deps) {
24057
24543
  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)}
24058
24544
  `);
24059
24545
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
24060
- const existingBlock = (value) => isRecord14(value) ? value : {};
24546
+ const existingBlock = (value) => isRecord15(value) ? value : {};
24061
24547
  deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
24062
24548
  ...claudeJson,
24063
24549
  oauthAccount: {
@@ -24180,7 +24666,7 @@ init_poolPick();
24180
24666
 
24181
24667
  // src/agents/read.ts
24182
24668
  var import_node_path47 = __toESM(require("node:path"), 1);
24183
- var import_zod43 = require("zod");
24669
+ var import_zod44 = require("zod");
24184
24670
  var PROJECTS_DIR = "projects";
24185
24671
  var TASKS_DIR = "tasks";
24186
24672
  var SUBAGENTS_DIR = "subagents";
@@ -24299,14 +24785,14 @@ function parseJson2(text) {
24299
24785
  return void 0;
24300
24786
  }
24301
24787
  }
24302
- var TaskFileSchema = import_zod43.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod43.z.array(import_zod43.z.string()).default([]), blockedBy: import_zod43.z.array(import_zod43.z.string()).default([]) });
24303
- var WorkflowRunFileSchema = import_zod43.z.object({
24304
- runId: import_zod43.z.string(),
24305
- workflowName: import_zod43.z.string().optional(),
24306
- status: import_zod43.z.string().optional(),
24307
- startTime: import_zod43.z.number().optional(),
24308
- phases: import_zod43.z.array(import_zod43.z.object({ title: import_zod43.z.string() })).default([]),
24309
- summary: import_zod43.z.string().optional()
24788
+ var TaskFileSchema = import_zod44.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod44.z.array(import_zod44.z.string()).default([]), blockedBy: import_zod44.z.array(import_zod44.z.string()).default([]) });
24789
+ var WorkflowRunFileSchema = import_zod44.z.object({
24790
+ runId: import_zod44.z.string(),
24791
+ workflowName: import_zod44.z.string().optional(),
24792
+ status: import_zod44.z.string().optional(),
24793
+ startTime: import_zod44.z.number().optional(),
24794
+ phases: import_zod44.z.array(import_zod44.z.object({ title: import_zod44.z.string() })).default([]),
24795
+ summary: import_zod44.z.string().optional()
24310
24796
  });
24311
24797
  function summariseSession(fs17, configDir, ref) {
24312
24798
  const sessionRelative = import_node_path47.default.join(PROJECTS_DIR, ref.project, ref.entry);
@@ -24811,6 +25297,8 @@ init_ownCli();
24811
25297
  QUOTA_EXPIRING_EVENT_SOURCE,
24812
25298
  QuotaExpiringEventSchema,
24813
25299
  RC_CONTEXT_USAGE_DETAILS,
25300
+ RC_GOAL_CLEAR_WORDS,
25301
+ RC_GOAL_CONDITION_MAX_CHARS,
24814
25302
  RC_IDLE_EXPIRY_MS,
24815
25303
  RC_ORPC_PATH_PREFIX,
24816
25304
  RC_PENDING_DEADLINE_MS,
@@ -24826,6 +25314,8 @@ init_ownCli();
24826
25314
  RC_SELF_HOST_SCOPE_LIST,
24827
25315
  RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
24828
25316
  RC_SESSIONS_PATH_PREFIX,
25317
+ RC_SESSION_COMMAND_MAX_WAIT_MS,
25318
+ RC_SESSION_COMMAND_VERIFIED_VERSIONS,
24829
25319
  RC_SESSION_END_REASONS,
24830
25320
  RC_SESSION_EVENT_LOG_CAPACITY,
24831
25321
  RC_STREAM_BACKOFF_MS,
@@ -24921,11 +25411,13 @@ init_ownCli();
24921
25411
  createQuotaExpiringPublisher,
24922
25412
  createRcApiNodeHandler,
24923
25413
  createRcApiRouter,
25414
+ createRcClaudeCodeVersions,
24924
25415
  createRcControlHandler,
24925
25416
  createRcCredentialStore,
24926
25417
  createRcEventFanout,
24927
25418
  createRcLiveUsage,
24928
25419
  createRcSelfHostSurface,
25420
+ createRcSessionCommands,
24929
25421
  createRcSessionEventLog,
24930
25422
  createRcSessionEventsApiRouter,
24931
25423
  createRcSessionRegistryReader,
@@ -24988,6 +25480,7 @@ init_ownCli();
24988
25480
  mintRcSelfHostCredential,
24989
25481
  observingRoutedRoute,
24990
25482
  parseConnectTarget,
25483
+ parseRcGoalOutput,
24991
25484
  parseRcStreamEnvelope,
24992
25485
  planOf,
24993
25486
  poolIdentities,
@@ -24999,6 +25492,8 @@ init_ownCli();
24999
25492
  rankPool,
25000
25493
  rcEventWriteResultFromAnswer,
25001
25494
  rcFanoutOnDoorHub,
25495
+ rcLocalCommandAnswerOf,
25496
+ rcManualCompactBoundaryOf,
25002
25497
  rcObserverAsPassthrough,
25003
25498
  rcRateLimitInfoOf,
25004
25499
  rcSelfHostFromEnv,