claude-use 14.3.1 → 14.5.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
@@ -1480,7 +1480,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
1480
1480
  return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
1481
1481
  }
1482
1482
  function describeIgnoredKeys(filePath, ignored) {
1483
- const places = ignored.map(({ path: path56, keys }) => `${path56.length === 0 ? "" : `${path56.map(String).join(".")}.`}${keys.join(", ")}`);
1483
+ const places = ignored.map(({ path: path59, keys }) => `${path59.length === 0 ? "" : `${path59.map(String).join(".")}.`}${keys.join(", ")}`);
1484
1484
  return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
1485
1485
  }
1486
1486
  function noteIgnoredKeys(filePath, ignored) {
@@ -1502,9 +1502,9 @@ function restoreIgnoredKeys(filePath, value) {
1502
1502
  return value;
1503
1503
  }
1504
1504
  const restored = structuredClone(value);
1505
- for (const { path: path56, values } of ignored) {
1505
+ for (const { path: path59, values } of ignored) {
1506
1506
  let holder = restored;
1507
- for (const step of path56) {
1507
+ for (const step of path59) {
1508
1508
  holder = isRecord(holder) ? holder[step] : void 0;
1509
1509
  }
1510
1510
  if (isRecord(holder)) {
@@ -2663,6 +2663,7 @@ function planFarm(params) {
2663
2663
  const entries = [];
2664
2664
  const materialised = [];
2665
2665
  const links = [];
2666
+ const dangling = [];
2666
2667
  const conditionalPatterns = [...params.flattened.rules.values()].filter((rule) => rule.when !== void 0).map((rule) => rule.canonicalPattern);
2667
2668
  const conditionalRuleCouldReach = (dir) => conditionalPatterns.some((pattern) => patternCouldReachUnder(pattern, dir));
2668
2669
  const subtreeDecision = (rel) => {
@@ -2695,7 +2696,10 @@ function planFarm(params) {
2695
2696
  return;
2696
2697
  }
2697
2698
  if (!fact.isDirectory) {
2698
- if (decision?.shared === true) {
2699
+ if (decision?.shared === true && fact.isDanglingSymlink) {
2700
+ entries.push({ kind: "omit", rel });
2701
+ dangling.push(rel);
2702
+ } else if (decision?.shared === true) {
2699
2703
  entries.push({ kind: "link", rel, target: linkTarget(rel) });
2700
2704
  links.push({ rel, target: linkTarget(rel) });
2701
2705
  } else {
@@ -2730,7 +2734,7 @@ function planFarm(params) {
2730
2734
  for (const rel of children.get("") ?? []) {
2731
2735
  visit(rel);
2732
2736
  }
2733
- return { entries, materialised, links };
2737
+ return { entries, materialised, links, dangling };
2734
2738
  }
2735
2739
  var import_node_path5;
2736
2740
  var init_plan = __esm({
@@ -2975,6 +2979,14 @@ function topLevelNames(facts) {
2975
2979
  function descendPolicyFor(cascade, home) {
2976
2980
  return descendPolicy(flattenLayers(assembleCascade(cascade).layers, { home }).rules.values());
2977
2981
  }
2982
+ function danglingDiagnostic(rel) {
2983
+ return {
2984
+ code: "SHARED_ENTRY_DANGLING",
2985
+ severity: "warning",
2986
+ message: `"${rel}" is shared, but ~/.claude/${rel} is a symlink that leads nowhere, so the farm does not link it and this identity keeps its own copy. Once the symlink leads somewhere, the next launch, or \`agent-shim identity resync <identity>\` in this directory, links the entry.`,
2987
+ subject: rel
2988
+ };
2989
+ }
2978
2990
  function resolveDecisions(input) {
2979
2991
  const assembled = assembleCascade(input.cascade);
2980
2992
  const flattened = flattenLayers(assembled.layers, { home: input.facts.home });
@@ -2994,7 +3006,7 @@ function resolveDecisions(input) {
2994
3006
  classification,
2995
3007
  decisions: resolved.decisions,
2996
3008
  farm,
2997
- diagnostics: [...assembled.diagnostics, ...resolved.diagnostics]
3009
+ diagnostics: [...assembled.diagnostics, ...resolved.diagnostics, ...farm.dangling.map(danglingDiagnostic)]
2998
3010
  };
2999
3011
  }
3000
3012
  var init_pipeline = __esm({
@@ -3441,6 +3453,34 @@ function readFarmManifest(fs17, farmRoot) {
3441
3453
  const result = FarmManifestSchema.safeParse(parsed);
3442
3454
  return result.success ? result.data : void 0;
3443
3455
  }
3456
+ function danglingFarmLinks(fs17, farmRoot) {
3457
+ const manifest = readFarmManifest(fs17, farmRoot);
3458
+ const recorded = new Map((manifest?.links ?? []).map((link) => [link.rel, link.target]));
3459
+ const materialised = new Set(manifest?.materialised ?? []);
3460
+ const candidates = new Set(recorded.keys());
3461
+ const walk2 = (rel) => {
3462
+ const stat = fs17.lstat(import_node_path10.default.join(farmRoot, rel));
3463
+ if (stat?.kind === "symlink") {
3464
+ candidates.add(rel);
3465
+ } else if (stat?.kind === "dir" && materialised.has(rel)) {
3466
+ for (const name of fs17.readdir(import_node_path10.default.join(farmRoot, rel))) {
3467
+ walk2(`${rel}/${name}`);
3468
+ }
3469
+ }
3470
+ };
3471
+ for (const name of fs17.readdir(farmRoot)) {
3472
+ if (name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME) {
3473
+ walk2(name);
3474
+ }
3475
+ }
3476
+ return [...candidates].sort().filter((rel) => {
3477
+ const absolute = import_node_path10.default.join(farmRoot, rel);
3478
+ return fs17.lstat(absolute)?.kind === "symlink" && !fs17.resolves(absolute);
3479
+ }).map((rel) => {
3480
+ const target = recorded.get(rel);
3481
+ return target === void 0 ? { rel } : { rel, target };
3482
+ });
3483
+ }
3444
3484
  function buildEntryFacts(params) {
3445
3485
  const entries = /* @__PURE__ */ new Map();
3446
3486
  const visit = (rel) => {
@@ -3465,6 +3505,7 @@ function buildEntryFacts(params) {
3465
3505
  relPath: rel,
3466
3506
  isDirectory,
3467
3507
  isSymlink: stat.kind === "symlink",
3508
+ isDanglingSymlink: stat.kind === "symlink" && !params.fs.resolves(absolute),
3468
3509
  mtimeMs: stat.mtimeMs,
3469
3510
  latestMtimeMs,
3470
3511
  sizeBytes: stat.sizeBytes,
@@ -3827,6 +3868,7 @@ function resyncFarm(params) {
3827
3868
  farmRoot,
3828
3869
  noOp: true,
3829
3870
  manifest: previousManifest,
3871
+ previousManifest,
3830
3872
  resolved,
3831
3873
  adopted: outcome.adopted,
3832
3874
  recovery,
@@ -3849,6 +3891,7 @@ function resyncFarm(params) {
3849
3891
  farmRoot,
3850
3892
  noOp: false,
3851
3893
  manifest,
3894
+ ...previousManifest === void 0 ? {} : { previousManifest },
3852
3895
  resolved,
3853
3896
  adopted: outcome.adopted,
3854
3897
  recovery,
@@ -5813,8 +5856,8 @@ function parseConnectTarget(authority) {
5813
5856
  function isInterceptedHost(host, interceptHosts) {
5814
5857
  return interceptHosts.includes(host);
5815
5858
  }
5816
- function servedByPipeline(path56) {
5817
- return path56?.startsWith(ROUTED_PATH_PREFIX) === true;
5859
+ function servedByPipeline(path59) {
5860
+ return path59?.startsWith(ROUTED_PATH_PREFIX) === true;
5818
5861
  }
5819
5862
  function forwardableHeaders(headers) {
5820
5863
  const connectionTokens = new Set(
@@ -6678,8 +6721,8 @@ function pathnameOf(url) {
6678
6721
  return new URL(url ?? "/", "http://127.0.0.1").pathname;
6679
6722
  }
6680
6723
  function isRcSessionExchange(url) {
6681
- const path56 = pathnameOf(url);
6682
- return path56 === RC_SESSIONS_PATH_PREFIX || path56.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
6724
+ const path59 = pathnameOf(url);
6725
+ return path59 === RC_SESSIONS_PATH_PREFIX || path59.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
6683
6726
  }
6684
6727
  function isSuccessful(status) {
6685
6728
  return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE;
@@ -7414,8 +7457,8 @@ function buildRcGetContextUsagePayload(requestId, detail) {
7414
7457
  function isRcReadFileEncoding(value) {
7415
7458
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
7416
7459
  }
7417
- function buildRcReadFilePayload(requestId, path56, options) {
7418
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path56, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
7460
+ function buildRcReadFilePayload(requestId, path59, options) {
7461
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path59, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
7419
7462
  }
7420
7463
  function buildRcFileSuggestionsPayload(requestId, query) {
7421
7464
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -7549,15 +7592,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
7549
7592
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
7550
7593
  return result.ok ? { ...result, requestId } : result;
7551
7594
  }
7552
- async function readRcSessionFile(deps, sessionId, path56, options) {
7553
- if (path56 === "") {
7595
+ async function readRcSessionFile(deps, sessionId, path59, options) {
7596
+ if (path59 === "") {
7554
7597
  return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
7555
7598
  }
7556
7599
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
7557
7600
  return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
7558
7601
  }
7559
7602
  const requestId = deps.newUuid();
7560
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path56, options), `read ${path56} from session ${sessionId}`);
7603
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path59, options), `read ${path59} from session ${sessionId}`);
7561
7604
  return result.ok ? { ...result, requestId } : result;
7562
7605
  }
7563
7606
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -7631,7 +7674,7 @@ var init_machineLoad = __esm({
7631
7674
  function workerFactSchema(value) {
7632
7675
  return import_zod12.z.strictObject({ value, observedAt: import_zod12.z.number() });
7633
7676
  }
7634
- var import_zod12, RcPermissionModeSchema, RcSessionSummarySchema, RcQuestionOptionSchema, RcPendingQuestionSchema, RcPendingRequestSummarySchema, RcSessionStatusSchema, RcStreamEnvelopeSchema, RcStreamEventSchema, RcRateLimitWindowSchema, RcRateLimitInfoSchema, RcLiveRateLimitSchema, RcSessionQuerySchema, RcSendInputSchema, RcQuestionSelectionSchema, RcQuestionChoicesSchema, RcAnswerInputSchema, RcInterruptInputSchema, RcSetModelInputSchema, RcSetPermissionModeInputSchema, RcEndSessionInputSchema, RcGetUsageInputSchema, RcGetContextUsageInputSchema, RcReadFileInputSchema, RcFileSuggestionsInputSchema, RcKeepAliveInputSchema, RcMcpStatusInputSchema, RcMcpReconnectInputSchema, RcMcpAuthenticateInputSchema, RcMcpOAuthCallbackUrlInputSchema, RcTeleportInputSchema, RcListOutputSchema, RcStatusOutputSchema, RcPendingOutputSchema, RcWriteOutputSchema, RcControlWriteOutputSchema, RcAnswerOutputSchema;
7677
+ var import_zod12, RcPermissionModeSchema, RcSessionSummarySchema, RcQuestionOptionSchema, RcPendingQuestionSchema, RcPendingRequestSummarySchema, RcSessionStatusSchema, RcStreamEnvelopeSchema, RcStreamEventSchema, RcRateLimitWindowSchema, RcRateLimitInfoSchema, RcLiveRateLimitSchema, RcSessionQuerySchema, RcSendInputSchema, RcQuestionSelectionSchema, RcQuestionChoicesSchema, RcAnswerInputSchema, RcInterruptInputSchema, RcSetModelInputSchema, RcSetPermissionModeInputSchema, RcEndSessionInputSchema, RcGetUsageInputSchema, RcGetContextUsageInputSchema, RcReadFileInputSchema, RcFileSuggestionsInputSchema, RcKeepAliveInputSchema, RcMcpStatusInputSchema, RcMcpReconnectInputSchema, RcMcpAuthenticateInputSchema, RcMcpOAuthCallbackUrlInputSchema, RcTeleportInputSchema, RcListOutputSchema, RcSessionRouteSchema, RcStatusOutputSchema, RcPendingOutputSchema, RcWriteOutputSchema, RcControlWriteOutputSchema, RcAnswerOutputSchema;
7635
7678
  var init_rcSchemas = __esm({
7636
7679
  "src/frontdoor/rcSchemas.ts"() {
7637
7680
  "use strict";
@@ -7801,7 +7844,8 @@ var init_rcSchemas = __esm({
7801
7844
  marker: import_zod12.z.string().min(1)
7802
7845
  });
7803
7846
  RcListOutputSchema = import_zod12.z.strictObject({ sessions: import_zod12.z.readonly(import_zod12.z.array(RcSessionSummarySchema)) });
7804
- RcStatusOutputSchema = import_zod12.z.strictObject({ statuses: import_zod12.z.readonly(import_zod12.z.array(RcSessionStatusSchema)) });
7847
+ RcSessionRouteSchema = import_zod12.z.union([import_zod12.z.strictObject({ route: import_zod12.z.enum(["supervised", "launched", "self-hosted"]) }), import_zod12.z.strictObject({ route: import_zod12.z.null(), refused: import_zod12.z.string() })]);
7848
+ RcStatusOutputSchema = import_zod12.z.strictObject({ statuses: import_zod12.z.readonly(import_zod12.z.array(import_zod12.z.strictObject({ ...RcSessionStatusSchema.shape, route: RcSessionRouteSchema }))) });
7805
7849
  RcPendingOutputSchema = import_zod12.z.strictObject({
7806
7850
  pending: import_zod12.z.readonly(import_zod12.z.array(RcPendingRequestSummarySchema)),
7807
7851
  /** The sessions that had requests the door did not list (past the per-session cap, or with an id the protocol does not mint), each with how many: a question the caller expects may be among them. Absent when none did. */
@@ -7935,11 +7979,11 @@ function createRcControlHandler(deps) {
7935
7979
  path: "read-file",
7936
7980
  read: (body) => {
7937
7981
  const session = bodyString(body, "session");
7938
- const path56 = bodyString(body, "path");
7982
+ const path59 = bodyString(body, "path");
7939
7983
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
7940
7984
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
7941
- const refused2 = session === void 0 || path56 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
7942
- return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path56, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
7985
+ const refused2 = session === void 0 || path59 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
7986
+ return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path59, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
7943
7987
  }
7944
7988
  },
7945
7989
  {
@@ -8262,9 +8306,9 @@ function requestIdOfBody(body) {
8262
8306
  }
8263
8307
  function frontDoorRcControl(transport, token) {
8264
8308
  const headers = { authorization: `Bearer ${token}` };
8265
- const listAnswerOf = async (path56, what) => {
8309
+ const listAnswerOf = async (path59, what) => {
8266
8310
  try {
8267
- return await transport.request({ method: "GET", path: path56, headers });
8311
+ return await transport.request({ method: "GET", path: path59, headers });
8268
8312
  } catch (error) {
8269
8313
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
8270
8314
  }
@@ -8336,10 +8380,10 @@ function frontDoorRcControl(transport, token) {
8336
8380
  }
8337
8381
  return pending;
8338
8382
  };
8339
- const writeOf = async (path56, body, describeFailure2) => {
8383
+ const writeOf = async (path59, body, describeFailure2) => {
8340
8384
  let answer;
8341
8385
  try {
8342
- answer = await transport.request({ method: "POST", path: path56, headers: { ...headers, "content-type": "application/json" }, body });
8386
+ answer = await transport.request({ method: "POST", path: path59, headers: { ...headers, "content-type": "application/json" }, body });
8343
8387
  } catch (error) {
8344
8388
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
8345
8389
  }
@@ -8370,10 +8414,10 @@ function frontDoorRcControl(transport, token) {
8370
8414
  endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
8371
8415
  getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
8372
8416
  getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
8373
- readFile: async (sessionId, path56, options) => await writeOf(
8417
+ readFile: async (sessionId, path59, options) => await writeOf(
8374
8418
  `${CONTROL_PATH_PREFIX}/read-file`,
8375
- JSON.stringify({ session: sessionId, path: path56, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
8376
- (status, message) => `reading ${path56} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
8419
+ JSON.stringify({ session: sessionId, path: path59, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
8420
+ (status, message) => `reading ${path59} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
8377
8421
  ),
8378
8422
  fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
8379
8423
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -8610,12 +8654,12 @@ function tlsFacts(options) {
8610
8654
  }
8611
8655
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
8612
8656
  const agent = new ExemptTlsAgent();
8613
- const post = async (path56, headers, body) => await new Promise((resolve, reject) => {
8657
+ const post = async (path59, headers, body) => await new Promise((resolve, reject) => {
8614
8658
  const options = {
8615
8659
  host: target.host,
8616
8660
  port: target.port,
8617
8661
  method: "POST",
8618
- path: path56,
8662
+ path: path59,
8619
8663
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
8620
8664
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
8621
8665
  agent
@@ -8675,12 +8719,12 @@ function lateRcStreamDial(resolve) {
8675
8719
  }
8676
8720
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
8677
8721
  const agent = new ExemptTlsAgent();
8678
- const request4 = async (method, path56, headers, body, signal) => await new Promise((resolve, reject) => {
8722
+ const request4 = async (method, path59, headers, body, signal) => await new Promise((resolve, reject) => {
8679
8723
  const options = {
8680
8724
  host: target.host,
8681
8725
  port: target.port,
8682
8726
  method,
8683
- path: path56,
8727
+ path: path59,
8684
8728
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
8685
8729
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
8686
8730
  agent,
@@ -8722,9 +8766,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
8722
8766
  return { status, body: await readAll(response) };
8723
8767
  },
8724
8768
  openStream: async (sessionId, headers, resume, signal) => {
8725
- const path56 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
8769
+ const path59 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
8726
8770
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
8727
- const { status, response } = await request4("GET", path56, streamHeaders, void 0, signal);
8771
+ const { status, response } = await request4("GET", path59, streamHeaders, void 0, signal);
8728
8772
  if (!isSuccessful2(status)) {
8729
8773
  await readAll(response);
8730
8774
  return { status, chunks: NO_CHUNKS };
@@ -9216,9 +9260,9 @@ var init_identity2 = __esm({
9216
9260
  });
9217
9261
 
9218
9262
  // src/statusline/keys.ts
9219
- function valueAt(source, path56) {
9263
+ function valueAt(source, path59) {
9220
9264
  let current = source;
9221
- for (const part of path56) {
9265
+ for (const part of path59) {
9222
9266
  if (!isPlainObject(current)) {
9223
9267
  return void 0;
9224
9268
  }
@@ -9226,14 +9270,14 @@ function valueAt(source, path56) {
9226
9270
  }
9227
9271
  return current;
9228
9272
  }
9229
- function acceptsNull(path56) {
9230
- const layer = path56.reduceRight((inner, part) => ({ [part]: inner }), null);
9273
+ function acceptsNull(path59) {
9274
+ const layer = path59.reduceRight((inner, part) => ({ [part]: inner }), null);
9231
9275
  return StatuslineSchema.safeParse(layer).success;
9232
9276
  }
9233
- function keyOf(path56, declared) {
9277
+ function keyOf(path59, declared) {
9234
9278
  const optional = declared instanceof import_zod13.z.ZodOptional;
9235
9279
  const leaf = optional ? declared.unwrap() : declared;
9236
- const common = { path: path56.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path56), optional, unsettable: acceptsNull(path56) };
9280
+ const common = { path: path59.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path59), optional, unsettable: acceptsNull(path59) };
9237
9281
  if (leaf instanceof import_zod13.z.ZodNumber) {
9238
9282
  return { ...common, kind: "integer", choices: [] };
9239
9283
  }
@@ -9258,7 +9302,7 @@ function keyOf(path56, declared) {
9258
9302
  if (leaf instanceof import_zod13.z.ZodArray && leaf.element instanceof import_zod13.z.ZodString) {
9259
9303
  return { ...common, kind: "textList", choices: [] };
9260
9304
  }
9261
- throw new TypeError(`statusline setting ${path56.join(".")} has a kind the key listing does not describe`);
9305
+ throw new TypeError(`statusline setting ${path59.join(".")} has a kind the key listing does not describe`);
9262
9306
  }
9263
9307
  function walk(shape, prefix) {
9264
9308
  return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod13.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
@@ -9276,15 +9320,15 @@ var init_keys = __esm({
9276
9320
  });
9277
9321
 
9278
9322
  // src/statusline/change.ts
9279
- function keyNamed(path56) {
9280
- const found = statuslineKeys().find((key) => key.path === path56);
9323
+ function keyNamed(path59) {
9324
+ const found = statuslineKeys().find((key) => key.path === path59);
9281
9325
  if (found === void 0) {
9282
- throw new UsageError(`"${path56}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
9326
+ throw new UsageError(`"${path59}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
9283
9327
  }
9284
9328
  return found;
9285
9329
  }
9286
- function setAt(target, path56, value) {
9287
- const [head, ...rest] = path56;
9330
+ function setAt(target, path59, value) {
9331
+ const [head, ...rest] = path59;
9288
9332
  if (head === void 0) {
9289
9333
  return;
9290
9334
  }
@@ -9297,8 +9341,8 @@ function setAt(target, path56, value) {
9297
9341
  target[head] = next;
9298
9342
  setAt(next, rest, value);
9299
9343
  }
9300
- function removeAt(target, path56) {
9301
- const [head, ...rest] = path56;
9344
+ function removeAt(target, path59) {
9345
+ const [head, ...rest] = path59;
9302
9346
  if (head === void 0) {
9303
9347
  return;
9304
9348
  }
@@ -9316,13 +9360,13 @@ function removeAt(target, path56) {
9316
9360
  }
9317
9361
  function applyStatuslineChange(existing, change) {
9318
9362
  const draft = structuredClone(existing ?? {});
9319
- for (const [path56, value] of Object.entries(change.set ?? {})) {
9320
- keyNamed(path56);
9321
- setAt(draft, path56.split("."), value);
9363
+ for (const [path59, value] of Object.entries(change.set ?? {})) {
9364
+ keyNamed(path59);
9365
+ setAt(draft, path59.split("."), value);
9322
9366
  }
9323
- for (const path56 of change.unset ?? []) {
9324
- keyNamed(path56);
9325
- removeAt(draft, path56.split("."));
9367
+ for (const path59 of change.unset ?? []) {
9368
+ keyNamed(path59);
9369
+ removeAt(draft, path59.split("."));
9326
9370
  }
9327
9371
  const result = StatuslineSchema.safeParse(draft);
9328
9372
  if (!result.success) {
@@ -9558,19 +9602,19 @@ function writePools(paths, pools) {
9558
9602
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
9559
9603
  }
9560
9604
  function poolCycleOf(pools, name) {
9561
- const walk2 = (current, path56) => {
9605
+ const walk2 = (current, path59) => {
9562
9606
  for (const entry of pools[current]?.identities ?? []) {
9563
9607
  const nested = poolNameOf(poolMemberIdentity(entry));
9564
9608
  if (nested === void 0) {
9565
9609
  continue;
9566
9610
  }
9567
9611
  if (nested === name) {
9568
- return [...path56, nested];
9612
+ return [...path59, nested];
9569
9613
  }
9570
- if (path56.includes(nested)) {
9614
+ if (path59.includes(nested)) {
9571
9615
  continue;
9572
9616
  }
9573
- const found = walk2(nested, [...path56, nested]);
9617
+ const found = walk2(nested, [...path59, nested]);
9574
9618
  if (found !== void 0) {
9575
9619
  return found;
9576
9620
  }
@@ -11072,15 +11116,15 @@ function pathDirectories(target, ports) {
11072
11116
  }
11073
11117
  return directories;
11074
11118
  }
11075
- function headroomDirectoryRefusal(directory, stat, uid, remedy) {
11119
+ function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
11076
11120
  if (stat?.kind !== "dir") {
11077
11121
  return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
11078
11122
  }
11079
11123
  if (stat.uid !== uid && stat.uid !== ROOT_UID) {
11080
- return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${remedy ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
11124
+ return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${remedy2 ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
11081
11125
  }
11082
11126
  if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
11083
- return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${remedy ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
11127
+ return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${remedy2 ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
11084
11128
  }
11085
11129
  return void 0;
11086
11130
  }
@@ -11989,6 +12033,9 @@ var init_realPorts = __esm({
11989
12033
  const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
11990
12034
  return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
11991
12035
  },
12036
+ resolves(filePath) {
12037
+ return import_node_fs6.default.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
12038
+ },
11992
12039
  readdir(dirPath) {
11993
12040
  try {
11994
12041
  return import_node_fs6.default.readdirSync(dirPath);
@@ -14050,8 +14097,8 @@ var init_identityStore = __esm({
14050
14097
  init_identityRecords();
14051
14098
  init_launchRecords();
14052
14099
  IdentityNotFoundError = class extends CliError {
14053
- constructor(name, remedy = `Run \`agent-shim identity add ${name}\` first.`) {
14054
- super(`No identity named "${name}". ${remedy}`);
14100
+ constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
14101
+ super(`No identity named "${name}". ${remedy2}`);
14055
14102
  this.name = name;
14056
14103
  this.name = "IdentityNotFoundError";
14057
14104
  }
@@ -14109,7 +14156,7 @@ var init_package = __esm({
14109
14156
  "package.json"() {
14110
14157
  package_default = {
14111
14158
  name: "claude-use",
14112
- version: "14.3.1",
14159
+ version: "14.5.0",
14113
14160
  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.",
14114
14161
  license: "MIT",
14115
14162
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -14215,6 +14262,28 @@ var init_package = __esm({
14215
14262
  }
14216
14263
  });
14217
14264
 
14265
+ // src/supervise/sessionControl.ts
14266
+ var import_node_path33, import_zod24, RESULT_POLL_MS, SessionControlConversationSchema, REQUEST_INSTANT_DIGITS;
14267
+ var init_sessionControl = __esm({
14268
+ "src/supervise/sessionControl.ts"() {
14269
+ "use strict";
14270
+ import_node_path33 = __toESM(require("node:path"), 1);
14271
+ import_zod24 = require("zod");
14272
+ RESULT_POLL_MS = 250;
14273
+ SessionControlConversationSchema = import_zod24.z.object({ conversationId: import_zod24.z.string().min(1), transcriptPath: import_zod24.z.string().refine(import_node_path33.default.isAbsolute) });
14274
+ REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
14275
+ }
14276
+ });
14277
+
14278
+ // src/supervise/verifiedVersions.ts
14279
+ var RC_SESSION_COMMAND_VERIFIED_VERSIONS;
14280
+ var init_verifiedVersions = __esm({
14281
+ "src/supervise/verifiedVersions.ts"() {
14282
+ "use strict";
14283
+ RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319", "2.1.325"];
14284
+ }
14285
+ });
14286
+
14218
14287
  // src/launcher/claudeVersion.ts
14219
14288
  function validated2(value, origin) {
14220
14289
  if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
@@ -14340,10 +14409,10 @@ function isLauncherScript(candidate) {
14340
14409
  }
14341
14410
  function resolveOwnBinaryCheck(paths, contentSourcePath) {
14342
14411
  const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
14343
- const recordedTarget = state === void 0 ? void 0 : import_node_path33.default.resolve(state.targetPath);
14412
+ const recordedTarget = state === void 0 ? void 0 : import_node_path34.default.resolve(state.targetPath);
14344
14413
  let ownStat;
14345
14414
  return (candidate) => {
14346
- if (recordedTarget !== void 0 && import_node_path33.default.resolve(candidate) === recordedTarget) {
14415
+ if (recordedTarget !== void 0 && import_node_path34.default.resolve(candidate) === recordedTarget) {
14347
14416
  return true;
14348
14417
  }
14349
14418
  ownStat ??= statOrUndefined(contentSourcePath);
@@ -14367,31 +14436,31 @@ function statOrUndefined(target) {
14367
14436
  }
14368
14437
  }
14369
14438
  function findPathShadow(params) {
14370
- const resolvedTargetDir = import_node_path33.default.resolve(params.targetDir);
14439
+ const resolvedTargetDir = import_node_path34.default.resolve(params.targetDir);
14371
14440
  for (const dir of params.pathDirs) {
14372
14441
  const found = params.findExecutableInDir(dir, params.targetFilename);
14373
14442
  if (found === void 0) {
14374
14443
  continue;
14375
14444
  }
14376
- return import_node_path33.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
14445
+ return import_node_path34.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
14377
14446
  }
14378
- return params.pathDirs.some((dir) => import_node_path33.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
14447
+ return params.pathDirs.some((dir) => import_node_path34.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
14379
14448
  }
14380
- var import_node_fs9, import_node_path33, import_zod29, ClaudeShimStateSchema, SCRIPT_HEAD_BYTES, LAUNCHER_NAME, EXEC_RUN, nodeLinkFs;
14449
+ var import_node_fs9, import_node_path34, import_zod30, ClaudeShimStateSchema, SCRIPT_HEAD_BYTES, LAUNCHER_NAME, EXEC_RUN, nodeLinkFs;
14381
14450
  var init_claudeShim = __esm({
14382
14451
  "src/claudeShim.ts"() {
14383
14452
  "use strict";
14384
14453
  import_node_fs9 = __toESM(require("node:fs"), 1);
14385
- import_node_path33 = __toESM(require("node:path"), 1);
14386
- import_zod29 = require("zod");
14454
+ import_node_path34 = __toESM(require("node:path"), 1);
14455
+ import_zod30 = require("zod");
14387
14456
  init_commandDeps();
14388
14457
  init_store();
14389
14458
  init_realPorts();
14390
14459
  init_cliError();
14391
- ClaudeShimStateSchema = import_zod29.z.strictObject({
14392
- targetPath: import_zod29.z.string().min(1),
14393
- method: import_zod29.z.enum(["hardlink", "copy"]),
14394
- installedAtMs: import_zod29.z.number()
14460
+ ClaudeShimStateSchema = import_zod30.z.strictObject({
14461
+ targetPath: import_zod30.z.string().min(1),
14462
+ method: import_zod30.z.enum(["hardlink", "copy"]),
14463
+ installedAtMs: import_zod30.z.number()
14395
14464
  });
14396
14465
  SCRIPT_HEAD_BYTES = 4096;
14397
14466
  LAUNCHER_NAME = /\b(agent-shim|claude-use)\b/;
@@ -14807,15 +14876,15 @@ function aliasFindings(aliases, providerNames) {
14807
14876
  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.` };
14808
14877
  });
14809
14878
  }
14810
- var import_zod30, ProviderAliasesSchema;
14879
+ var import_zod31, ProviderAliasesSchema;
14811
14880
  var init_providerAliases = __esm({
14812
14881
  "src/providerAliases.ts"() {
14813
14882
  "use strict";
14814
- import_zod30 = require("zod");
14883
+ import_zod31 = require("zod");
14815
14884
  init_cliError();
14816
14885
  init_load();
14817
14886
  init_store();
14818
- ProviderAliasesSchema = import_zod30.z.record(import_zod30.z.string().min(1), import_zod30.z.string().min(1));
14887
+ ProviderAliasesSchema = import_zod31.z.record(import_zod31.z.string().min(1), import_zod31.z.string().min(1));
14819
14888
  }
14820
14889
  });
14821
14890
 
@@ -15392,18 +15461,18 @@ function expandTilde(value, home) {
15392
15461
  return home;
15393
15462
  }
15394
15463
  if (value.startsWith("~/")) {
15395
- return import_node_path37.default.join(home, value.slice(2));
15464
+ return import_node_path38.default.join(home, value.slice(2));
15396
15465
  }
15397
15466
  return value;
15398
15467
  }
15399
15468
  function normaliseRulePath(rulePath, home) {
15400
- return import_node_path37.default.resolve(expandTilde(rulePath, home));
15469
+ return import_node_path38.default.resolve(expandTilde(rulePath, home));
15401
15470
  }
15402
- var import_node_path37;
15471
+ var import_node_path38;
15403
15472
  var init_pathNorm = __esm({
15404
15473
  "src/pathNorm.ts"() {
15405
15474
  "use strict";
15406
- import_node_path37 = __toESM(require("node:path"), 1);
15475
+ import_node_path38 = __toESM(require("node:path"), 1);
15407
15476
  }
15408
15477
  });
15409
15478
 
@@ -15427,8 +15496,8 @@ function loadCascadeInput(params) {
15427
15496
  });
15428
15497
  const levels = [];
15429
15498
  for (const dir of dirs) {
15430
- const portable = loadConfigFile(import_node_path38.default.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path38.default.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
15431
- const portableLocal = loadConfigFile(import_node_path38.default.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path38.default.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
15499
+ const portable = loadConfigFile(import_node_path39.default.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path39.default.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
15500
+ const portableLocal = loadConfigFile(import_node_path39.default.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path39.default.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
15432
15501
  const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
15433
15502
  const entryOrder = directoryRules?.ruleEntryOrders[index];
15434
15503
  return {
@@ -15475,11 +15544,11 @@ function readDirectorySelections(loaded) {
15475
15544
  }
15476
15545
  return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
15477
15546
  }
15478
- var import_node_path38, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
15547
+ var import_node_path39, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
15479
15548
  var init_cascade = __esm({
15480
15549
  "src/launcher/cascade.ts"() {
15481
15550
  "use strict";
15482
- import_node_path38 = __toESM(require("node:path"), 1);
15551
+ import_node_path39 = __toESM(require("node:path"), 1);
15483
15552
  init_load();
15484
15553
  init_schema();
15485
15554
  init_pathNorm();
@@ -15572,8 +15641,8 @@ function resolveAgentShimHome(env = process.env, home = import_node_os5.default.
15572
15641
  if (fromEnv !== void 0 && fromEnv !== "") {
15573
15642
  return fromEnv;
15574
15643
  }
15575
- const current = import_node_path39.default.join(home, HOME_DIRNAME);
15576
- const legacy = import_node_path39.default.join(home, LEGACY_HOME_DIRNAME);
15644
+ const current = import_node_path40.default.join(home, HOME_DIRNAME);
15645
+ const legacy = import_node_path40.default.join(home, LEGACY_HOME_DIRNAME);
15577
15646
  return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
15578
15647
  }
15579
15648
  function isExistingDirectory(candidate) {
@@ -15584,71 +15653,72 @@ function resolveClaudeHome() {
15584
15653
  if (fromEnv !== void 0 && fromEnv !== "") {
15585
15654
  return fromEnv;
15586
15655
  }
15587
- return import_node_path39.default.join(import_node_os5.default.homedir(), ".claude");
15656
+ return import_node_path40.default.join(import_node_os5.default.homedir(), ".claude");
15588
15657
  }
15589
15658
  function buildLayoutPaths(root) {
15590
15659
  return {
15591
15660
  root,
15592
- identitiesDir: import_node_path39.default.join(root, "identities"),
15593
- configProfilesDir: import_node_path39.default.join(root, "config-profiles"),
15594
- providersDir: import_node_path39.default.join(root, "providers"),
15595
- providerAliasesFile: import_node_path39.default.join(root, "provider-aliases.json"),
15596
- directoryRulesFile: import_node_path39.default.join(root, "directory-rules.json"),
15597
- activeIdentityFile: import_node_path39.default.join(root, "active-identity"),
15598
- globalConfigFile: import_node_path39.default.join(root, "config.json"),
15599
- categoriesLocalFile: import_node_path39.default.join(root, "categories.local.json"),
15600
- claudeShimFile: import_node_path39.default.join(root, "claude-shim.json"),
15601
- headroomDir: import_node_path39.default.join(root, "headroom"),
15602
- headroomStateFile: import_node_path39.default.join(root, "headroom", "state.json"),
15603
- headroomRoutingFile: import_node_path39.default.join(root, "headroom", "routing.json"),
15604
- headroomLegacyStateFile: import_node_path39.default.join(root, "headroom", "state.v2.json"),
15605
- headroomAllowlistFile: import_node_path39.default.join(root, "headroom", "run", "allowlist.txt"),
15606
- headroomSocketDir: import_node_path39.default.join(root, "headroom", "run"),
15607
- headroomLockFile: import_node_path39.default.join(root, "headroom", "start.lock"),
15608
- headroomSessionsDir: import_node_path39.default.join(root, "headroom", "sessions"),
15609
- logsDir: import_node_path39.default.join(root, "logs"),
15610
- headroomLogPath: import_node_path39.default.join(root, "logs", "headroom.log"),
15611
- frontdoorDir: import_node_path39.default.join(root, "frontdoor"),
15612
- frontdoorCaDir: import_node_path39.default.join(root, "frontdoor", "ca"),
15613
- frontdoorCaCertFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.pem"),
15614
- frontdoorCaKeyFile: import_node_path39.default.join(root, "frontdoor", "ca", "ca.key"),
15615
- frontdoorCaBundlesDir: import_node_path39.default.join(root, "frontdoor", "ca", "bundles"),
15616
- chatgptSignInFile: import_node_path39.default.join(root, "codex", "chatgpt-sign-in.json"),
15617
- frontdoorStateFile: import_node_path39.default.join(root, "frontdoor", "state.json"),
15618
- frontdoorLockFile: import_node_path39.default.join(root, "frontdoor", "start.lock"),
15619
- frontdoorControlTokenFile: import_node_path39.default.join(root, "frontdoor", "control-token"),
15620
- frontdoorSessionsDir: import_node_path39.default.join(root, "frontdoor", "sessions"),
15621
- frontdoorDirectRecordsDir: import_node_path39.default.join(root, "frontdoor", "direct"),
15622
- frontdoorDrainingDir: import_node_path39.default.join(root, "frontdoor", "draining"),
15623
- frontdoorRcCredentialsDir: import_node_path39.default.join(root, "frontdoor", "rc-credentials"),
15624
- frontdoorLogPath: import_node_path39.default.join(root, "logs", "frontdoor.log"),
15625
- usageDir: import_node_path39.default.join(root, "usage"),
15626
- usageLogDir: import_node_path39.default.join(root, "usage", "log"),
15627
- usageSnapshotsDir: import_node_path39.default.join(root, "usage", "snapshots"),
15628
- statuslineDir: import_node_path39.default.join(root, "statusline"),
15629
- catalogueDir: import_node_path39.default.join(root, "catalogues"),
15630
- usagePicksFile: import_node_path39.default.join(root, "usage", "picks.json"),
15631
- usageAnchorsFile: import_node_path39.default.join(root, "usage", "anchors.json"),
15632
- usageJobsFile: import_node_path39.default.join(root, "usage", "jobs.json"),
15633
- jobLogsDir: import_node_path39.default.join(root, "logs", "jobs"),
15634
- identityRenamesDir: import_node_path39.default.join(root, "identity-renames"),
15635
- identityNameRenamesDir: import_node_path39.default.join(root, "identity-name-renames"),
15636
- launchesDir: import_node_path39.default.join(root, "launches"),
15637
- superviseDir: import_node_path39.default.join(root, "supervise"),
15638
- modelMovesDir: import_node_path39.default.join(root, "model-moves"),
15639
- mcpPermissionsFile: import_node_path39.default.join(root, "mcp", "permissions.json")
15661
+ identitiesDir: import_node_path40.default.join(root, "identities"),
15662
+ configProfilesDir: import_node_path40.default.join(root, "config-profiles"),
15663
+ providersDir: import_node_path40.default.join(root, "providers"),
15664
+ providerAliasesFile: import_node_path40.default.join(root, "provider-aliases.json"),
15665
+ directoryRulesFile: import_node_path40.default.join(root, "directory-rules.json"),
15666
+ activeIdentityFile: import_node_path40.default.join(root, "active-identity"),
15667
+ globalConfigFile: import_node_path40.default.join(root, "config.json"),
15668
+ categoriesLocalFile: import_node_path40.default.join(root, "categories.local.json"),
15669
+ claudeShimFile: import_node_path40.default.join(root, "claude-shim.json"),
15670
+ headroomDir: import_node_path40.default.join(root, "headroom"),
15671
+ headroomStateFile: import_node_path40.default.join(root, "headroom", "state.json"),
15672
+ headroomRoutingFile: import_node_path40.default.join(root, "headroom", "routing.json"),
15673
+ headroomLegacyStateFile: import_node_path40.default.join(root, "headroom", "state.v2.json"),
15674
+ headroomAllowlistFile: import_node_path40.default.join(root, "headroom", "run", "allowlist.txt"),
15675
+ headroomSocketDir: import_node_path40.default.join(root, "headroom", "run"),
15676
+ headroomLockFile: import_node_path40.default.join(root, "headroom", "start.lock"),
15677
+ headroomSessionsDir: import_node_path40.default.join(root, "headroom", "sessions"),
15678
+ logsDir: import_node_path40.default.join(root, "logs"),
15679
+ headroomLogPath: import_node_path40.default.join(root, "logs", "headroom.log"),
15680
+ frontdoorDir: import_node_path40.default.join(root, "frontdoor"),
15681
+ frontdoorCaDir: import_node_path40.default.join(root, "frontdoor", "ca"),
15682
+ frontdoorCaCertFile: import_node_path40.default.join(root, "frontdoor", "ca", "ca.pem"),
15683
+ frontdoorCaKeyFile: import_node_path40.default.join(root, "frontdoor", "ca", "ca.key"),
15684
+ frontdoorCaBundlesDir: import_node_path40.default.join(root, "frontdoor", "ca", "bundles"),
15685
+ chatgptSignInFile: import_node_path40.default.join(root, "codex", "chatgpt-sign-in.json"),
15686
+ frontdoorStateFile: import_node_path40.default.join(root, "frontdoor", "state.json"),
15687
+ frontdoorLockFile: import_node_path40.default.join(root, "frontdoor", "start.lock"),
15688
+ frontdoorControlTokenFile: import_node_path40.default.join(root, "frontdoor", "control-token"),
15689
+ frontdoorSessionsDir: import_node_path40.default.join(root, "frontdoor", "sessions"),
15690
+ frontdoorDirectRecordsDir: import_node_path40.default.join(root, "frontdoor", "direct"),
15691
+ frontdoorDrainingDir: import_node_path40.default.join(root, "frontdoor", "draining"),
15692
+ frontdoorRcCredentialsDir: import_node_path40.default.join(root, "frontdoor", "rc-credentials"),
15693
+ frontdoorLogPath: import_node_path40.default.join(root, "logs", "frontdoor.log"),
15694
+ usageDir: import_node_path40.default.join(root, "usage"),
15695
+ usageLogDir: import_node_path40.default.join(root, "usage", "log"),
15696
+ usageSnapshotsDir: import_node_path40.default.join(root, "usage", "snapshots"),
15697
+ statuslineDir: import_node_path40.default.join(root, "statusline"),
15698
+ catalogueDir: import_node_path40.default.join(root, "catalogues"),
15699
+ usagePicksFile: import_node_path40.default.join(root, "usage", "picks.json"),
15700
+ usageAnchorsFile: import_node_path40.default.join(root, "usage", "anchors.json"),
15701
+ usageJobsFile: import_node_path40.default.join(root, "usage", "jobs.json"),
15702
+ jobLogsDir: import_node_path40.default.join(root, "logs", "jobs"),
15703
+ identityRenamesDir: import_node_path40.default.join(root, "identity-renames"),
15704
+ identityNameRenamesDir: import_node_path40.default.join(root, "identity-name-renames"),
15705
+ launchesDir: import_node_path40.default.join(root, "launches"),
15706
+ launchControlDir: import_node_path40.default.join(root, "launch-control"),
15707
+ superviseDir: import_node_path40.default.join(root, "supervise"),
15708
+ modelMovesDir: import_node_path40.default.join(root, "model-moves"),
15709
+ mcpPermissionsFile: import_node_path40.default.join(root, "mcp", "permissions.json")
15640
15710
  };
15641
15711
  }
15642
15712
  function resolveLayoutPaths() {
15643
15713
  return buildLayoutPaths(resolveAgentShimHome());
15644
15714
  }
15645
- var import_node_fs12, import_node_os5, import_node_path39;
15715
+ var import_node_fs12, import_node_os5, import_node_path40;
15646
15716
  var init_paths = __esm({
15647
15717
  "src/paths.ts"() {
15648
15718
  "use strict";
15649
15719
  import_node_fs12 = __toESM(require("node:fs"), 1);
15650
15720
  import_node_os5 = __toESM(require("node:os"), 1);
15651
- import_node_path39 = __toESM(require("node:path"), 1);
15721
+ import_node_path40 = __toESM(require("node:path"), 1);
15652
15722
  init_legacy();
15653
15723
  }
15654
15724
  });
@@ -15662,16 +15732,16 @@ function catalogueReadFault(error) {
15662
15732
  return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
15663
15733
  }
15664
15734
  function catalogueStatusFile(paths, owner, name) {
15665
- return import_node_path41.default.join(import_node_path41.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
15735
+ return import_node_path42.default.join(import_node_path42.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
15666
15736
  }
15667
15737
  function catalogueFailureFile(paths, owner, name) {
15668
- return import_node_path41.default.join(import_node_path41.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
15738
+ return import_node_path42.default.join(import_node_path42.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
15669
15739
  }
15670
- var import_node_path41, UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
15740
+ var import_node_path42, UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
15671
15741
  var init_storedCatalogue = __esm({
15672
15742
  "src/storedCatalogue.ts"() {
15673
15743
  "use strict";
15674
- import_node_path41 = __toESM(require("node:path"), 1);
15744
+ import_node_path42 = __toESM(require("node:path"), 1);
15675
15745
  init_providerCatalogue();
15676
15746
  UnreadableCatalogueError = class extends Error {
15677
15747
  fault;
@@ -15761,7 +15831,7 @@ function readCatalogueFailure(fs17, paths, pid, generation, name) {
15761
15831
  const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
15762
15832
  if (raw === void 0) return void 0;
15763
15833
  try {
15764
- const value = import_zod32.z.strictObject({ reason: import_zod32.z.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: import_zod32.z.literal(true).optional(), settings: import_zod32.z.string().optional() }).safeParse(JSON.parse(raw));
15834
+ const value = import_zod33.z.strictObject({ reason: import_zod33.z.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: import_zod33.z.literal(true).optional(), settings: import_zod33.z.string().optional() }).safeParse(JSON.parse(raw));
15765
15835
  return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
15766
15836
  } catch {
15767
15837
  return void 0;
@@ -15771,17 +15841,17 @@ function readCatalogueStatus(fs17, paths, pid, generation, name) {
15771
15841
  const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
15772
15842
  if (raw === void 0) return void 0;
15773
15843
  try {
15774
- const value = import_zod32.z.strictObject({ status: import_zod32.z.enum(["running", "ready", "failed"]), fingerprint: import_zod32.z.string().min(1).optional(), recordedAt: import_zod32.z.number().optional() }).safeParse(JSON.parse(raw));
15844
+ const value = import_zod33.z.strictObject({ status: import_zod33.z.enum(["running", "ready", "failed"]), fingerprint: import_zod33.z.string().min(1).optional(), recordedAt: import_zod33.z.number().optional() }).safeParse(JSON.parse(raw));
15775
15845
  return value.success ? value.data : void 0;
15776
15846
  } catch {
15777
15847
  return void 0;
15778
15848
  }
15779
15849
  }
15780
- var import_zod32, CATALOGUE_FAILURE_REASON_MAX_CHARS;
15850
+ var import_zod33, CATALOGUE_FAILURE_REASON_MAX_CHARS;
15781
15851
  var init_catalogueState = __esm({
15782
15852
  "src/frontdoor/catalogueState.ts"() {
15783
15853
  "use strict";
15784
- import_zod32 = require("zod");
15854
+ import_zod33 = require("zod");
15785
15855
  init_storedCatalogue();
15786
15856
  init_tolerantReaders();
15787
15857
  CATALOGUE_FAILURE_REASON_MAX_CHARS = 600;
@@ -15789,25 +15859,25 @@ var init_catalogueState = __esm({
15789
15859
  });
15790
15860
 
15791
15861
  // src/codex/auth.ts
15792
- var import_zod33, AuthFileSchema, TokenGrantSchema, CodexAuthError;
15862
+ var import_zod34, AuthFileSchema, TokenGrantSchema, CodexAuthError;
15793
15863
  var init_auth = __esm({
15794
15864
  "src/codex/auth.ts"() {
15795
15865
  "use strict";
15796
- import_zod33 = require("zod");
15797
- AuthFileSchema = import_zod33.z.looseObject({
15798
- tokens: import_zod33.z.looseObject({
15799
- access_token: import_zod33.z.string().optional(),
15800
- refresh_token: import_zod33.z.string().optional(),
15801
- id_token: import_zod33.z.string().optional(),
15802
- account_id: import_zod33.z.string().optional()
15866
+ import_zod34 = require("zod");
15867
+ AuthFileSchema = import_zod34.z.looseObject({
15868
+ tokens: import_zod34.z.looseObject({
15869
+ access_token: import_zod34.z.string().optional(),
15870
+ refresh_token: import_zod34.z.string().optional(),
15871
+ id_token: import_zod34.z.string().optional(),
15872
+ account_id: import_zod34.z.string().optional()
15803
15873
  }).nullish(),
15804
- last_refresh: import_zod33.z.string().optional()
15874
+ last_refresh: import_zod34.z.string().optional()
15805
15875
  });
15806
- TokenGrantSchema = import_zod33.z.looseObject({
15807
- access_token: import_zod33.z.string().min(1).optional(),
15808
- refresh_token: import_zod33.z.string().min(1).optional(),
15809
- id_token: import_zod33.z.string().min(1).optional(),
15810
- account_id: import_zod33.z.string().min(1).optional()
15876
+ TokenGrantSchema = import_zod34.z.looseObject({
15877
+ access_token: import_zod34.z.string().min(1).optional(),
15878
+ refresh_token: import_zod34.z.string().min(1).optional(),
15879
+ id_token: import_zod34.z.string().min(1).optional(),
15880
+ account_id: import_zod34.z.string().min(1).optional()
15811
15881
  });
15812
15882
  CodexAuthError = class extends Error {
15813
15883
  constructor(message) {
@@ -15819,31 +15889,31 @@ var init_auth = __esm({
15819
15889
  });
15820
15890
 
15821
15891
  // src/codex/siwc.ts
15822
- var import_zod34, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
15892
+ var import_zod35, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
15823
15893
  var init_siwc = __esm({
15824
15894
  "src/codex/siwc.ts"() {
15825
15895
  "use strict";
15826
- import_zod34 = require("zod");
15896
+ import_zod35 = require("zod");
15827
15897
  SIWC_RESOURCE = "https://api.openai.com/v1";
15828
15898
  SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
15829
15899
  SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
15830
- TokenResponseSchema = import_zod34.z.looseObject({
15831
- access_token: import_zod34.z.string().min(1),
15832
- refresh_token: import_zod34.z.string().min(1).optional(),
15833
- id_token: import_zod34.z.string().min(1).optional(),
15834
- expires_in: import_zod34.z.number().positive(),
15835
- scope: import_zod34.z.string().optional()
15900
+ TokenResponseSchema = import_zod35.z.looseObject({
15901
+ access_token: import_zod35.z.string().min(1),
15902
+ refresh_token: import_zod35.z.string().min(1).optional(),
15903
+ id_token: import_zod35.z.string().min(1).optional(),
15904
+ expires_in: import_zod35.z.number().positive(),
15905
+ scope: import_zod35.z.string().optional()
15836
15906
  });
15837
- JwtHeaderSchema = import_zod34.z.looseObject({ alg: import_zod34.z.string(), kid: import_zod34.z.string().optional() });
15838
- IdTokenClaimsSchema = import_zod34.z.looseObject({
15839
- iss: import_zod34.z.string(),
15840
- sub: import_zod34.z.string().min(1),
15841
- aud: import_zod34.z.union([import_zod34.z.string(), import_zod34.z.array(import_zod34.z.string())]),
15842
- exp: import_zod34.z.number(),
15843
- nonce: import_zod34.z.string().optional(),
15844
- email: import_zod34.z.string().optional()
15907
+ JwtHeaderSchema = import_zod35.z.looseObject({ alg: import_zod35.z.string(), kid: import_zod35.z.string().optional() });
15908
+ IdTokenClaimsSchema = import_zod35.z.looseObject({
15909
+ iss: import_zod35.z.string(),
15910
+ sub: import_zod35.z.string().min(1),
15911
+ aud: import_zod35.z.union([import_zod35.z.string(), import_zod35.z.array(import_zod35.z.string())]),
15912
+ exp: import_zod35.z.number(),
15913
+ nonce: import_zod35.z.string().optional(),
15914
+ email: import_zod35.z.string().optional()
15845
15915
  });
15846
- JwksSchema = import_zod34.z.object({ keys: import_zod34.z.array(import_zod34.z.looseObject({ kid: import_zod34.z.string().optional(), kty: import_zod34.z.string() })) });
15916
+ JwksSchema = import_zod35.z.object({ keys: import_zod35.z.array(import_zod35.z.looseObject({ kid: import_zod35.z.string().optional(), kty: import_zod35.z.string() })) });
15847
15917
  }
15848
15918
  });
15849
15919
 
@@ -15861,25 +15931,25 @@ function parseSiwcFile(raw, filePath) {
15861
15931
  }
15862
15932
  return parsed.data;
15863
15933
  }
15864
- var import_zod35, SiwcGrantSchema, SiwcFileSchema;
15934
+ var import_zod36, SiwcGrantSchema, SiwcFileSchema;
15865
15935
  var init_siwcStore = __esm({
15866
15936
  "src/codex/siwcStore.ts"() {
15867
15937
  "use strict";
15868
- import_zod35 = require("zod");
15938
+ import_zod36 = require("zod");
15869
15939
  init_auth();
15870
15940
  init_siwc();
15871
- SiwcGrantSchema = import_zod35.z.strictObject({
15872
- clientId: import_zod35.z.string().min(1),
15873
- sub: import_zod35.z.string().min(1),
15874
- email: import_zod35.z.string().optional(),
15875
- idToken: import_zod35.z.string().min(1),
15876
- accessToken: import_zod35.z.string().min(1),
15877
- refreshToken: import_zod35.z.string().min(1),
15878
- scopes: import_zod35.z.array(import_zod35.z.string()).readonly(),
15941
+ SiwcGrantSchema = import_zod36.z.strictObject({
15942
+ clientId: import_zod36.z.string().min(1),
15943
+ sub: import_zod36.z.string().min(1),
15944
+ email: import_zod36.z.string().optional(),
15945
+ idToken: import_zod36.z.string().min(1),
15946
+ accessToken: import_zod36.z.string().min(1),
15947
+ refreshToken: import_zod36.z.string().min(1),
15948
+ scopes: import_zod36.z.array(import_zod36.z.string()).readonly(),
15879
15949
  /** When the access token stops working, in milliseconds since the epoch. */
15880
- expiresAt: import_zod35.z.number()
15950
+ expiresAt: import_zod36.z.number()
15881
15951
  });
15882
- SiwcFileSchema = import_zod35.z.strictObject({ registeredClientId: import_zod35.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
15952
+ SiwcFileSchema = import_zod36.z.strictObject({ registeredClientId: import_zod36.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
15883
15953
  }
15884
15954
  });
15885
15955
 
@@ -15969,18 +16039,18 @@ function signInCatalogueFingerprint(raw, filePath) {
15969
16039
  function savedCatalogueFingerprint(provider, paths, env, home, reader) {
15970
16040
  if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
15971
16041
  const configuredHome = env.CODEX_HOME;
15972
- const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path42.default.join(home, ".codex") : configuredHome;
15973
- return cliCatalogueFingerprint(reader.read(import_node_path42.default.join(codexHome, "auth.json")));
16042
+ const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path43.default.join(home, ".codex") : configuredHome;
16043
+ return cliCatalogueFingerprint(reader.read(import_node_path43.default.join(codexHome, "auth.json")));
15974
16044
  }
15975
- var import_node_crypto16, import_node_path42, import_zod36, CatalogueBindingSchema;
16045
+ var import_node_crypto16, import_node_path43, import_zod37, CatalogueBindingSchema;
15976
16046
  var init_catalogueCredential = __esm({
15977
16047
  "src/codex/catalogueCredential.ts"() {
15978
16048
  "use strict";
15979
16049
  import_node_crypto16 = require("node:crypto");
15980
- import_node_path42 = __toESM(require("node:path"), 1);
15981
- import_zod36 = require("zod");
16050
+ import_node_path43 = __toESM(require("node:path"), 1);
16051
+ import_zod37 = require("zod");
15982
16052
  init_siwcStore();
15983
- CatalogueBindingSchema = import_zod36.z.strictObject({ fingerprint: import_zod36.z.string().min(1), source: import_zod36.z.string().min(1), revision: import_zod36.z.string().min(1) });
16053
+ CatalogueBindingSchema = import_zod37.z.strictObject({ fingerprint: import_zod37.z.string().min(1), source: import_zod37.z.string().min(1), revision: import_zod37.z.string().min(1) });
15984
16054
  }
15985
16055
  });
15986
16056
 
@@ -16031,64 +16101,64 @@ var init_signatures = __esm({
16031
16101
  });
16032
16102
 
16033
16103
  // src/codex/anthropic.ts
16034
- var import_zod37, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
16104
+ var import_zod38, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
16035
16105
  var init_anthropic = __esm({
16036
16106
  "src/codex/anthropic.ts"() {
16037
16107
  "use strict";
16038
- import_zod37 = require("zod");
16039
- TextBlockSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("text"), text: import_zod37.z.string() });
16040
- Base64ImageSourceSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("base64"), media_type: import_zod37.z.string().min(1), data: import_zod37.z.string() });
16041
- UrlImageSourceSchema = import_zod37.z.looseObject({ type: import_zod37.z.literal("url"), url: import_zod37.z.string().min(1) });
16042
- ImageBlockSchema = import_zod37.z.looseObject({
16043
- type: import_zod37.z.literal("image"),
16044
- source: import_zod37.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
16108
+ import_zod38 = require("zod");
16109
+ TextBlockSchema = import_zod38.z.looseObject({ type: import_zod38.z.literal("text"), text: import_zod38.z.string() });
16110
+ Base64ImageSourceSchema = import_zod38.z.looseObject({ type: import_zod38.z.literal("base64"), media_type: import_zod38.z.string().min(1), data: import_zod38.z.string() });
16111
+ UrlImageSourceSchema = import_zod38.z.looseObject({ type: import_zod38.z.literal("url"), url: import_zod38.z.string().min(1) });
16112
+ ImageBlockSchema = import_zod38.z.looseObject({
16113
+ type: import_zod38.z.literal("image"),
16114
+ source: import_zod38.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
16045
16115
  });
16046
- ToolUseBlockSchema = import_zod37.z.looseObject({
16047
- type: import_zod37.z.literal("tool_use"),
16048
- id: import_zod37.z.string().min(1),
16049
- name: import_zod37.z.string().min(1),
16050
- input: import_zod37.z.unknown()
16116
+ ToolUseBlockSchema = import_zod38.z.looseObject({
16117
+ type: import_zod38.z.literal("tool_use"),
16118
+ id: import_zod38.z.string().min(1),
16119
+ name: import_zod38.z.string().min(1),
16120
+ input: import_zod38.z.unknown()
16051
16121
  });
16052
- ToolResultContentBlockSchema = import_zod37.z.union([TextBlockSchema, import_zod37.z.looseObject({ type: import_zod37.z.string() })]);
16053
- ToolResultBlockSchema = import_zod37.z.looseObject({
16054
- type: import_zod37.z.literal("tool_result"),
16055
- tool_use_id: import_zod37.z.string().min(1),
16056
- content: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(ToolResultContentBlockSchema)]).optional()
16122
+ ToolResultContentBlockSchema = import_zod38.z.union([TextBlockSchema, import_zod38.z.looseObject({ type: import_zod38.z.string() })]);
16123
+ ToolResultBlockSchema = import_zod38.z.looseObject({
16124
+ type: import_zod38.z.literal("tool_result"),
16125
+ tool_use_id: import_zod38.z.string().min(1),
16126
+ content: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.array(ToolResultContentBlockSchema)]).optional()
16057
16127
  });
16058
- OtherBlockSchema = import_zod37.z.looseObject({ type: import_zod37.z.string() });
16059
- ContentBlockSchema = import_zod37.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
16060
- MessageSchema = import_zod37.z.looseObject({
16061
- role: import_zod37.z.enum(["user", "assistant", "system"]),
16062
- content: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(ContentBlockSchema)])
16128
+ OtherBlockSchema = import_zod38.z.looseObject({ type: import_zod38.z.string() });
16129
+ ContentBlockSchema = import_zod38.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
16130
+ MessageSchema = import_zod38.z.looseObject({
16131
+ role: import_zod38.z.enum(["user", "assistant", "system"]),
16132
+ content: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.array(ContentBlockSchema)])
16063
16133
  });
16064
- ToolSchema = import_zod37.z.looseObject({
16065
- name: import_zod37.z.string().min(1),
16066
- description: import_zod37.z.string().optional(),
16067
- input_schema: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.unknown()).optional(),
16068
- allowed_domains: import_zod37.z.array(import_zod37.z.string()).optional(),
16069
- blocked_domains: import_zod37.z.array(import_zod37.z.string()).optional()
16134
+ ToolSchema = import_zod38.z.looseObject({
16135
+ name: import_zod38.z.string().min(1),
16136
+ description: import_zod38.z.string().optional(),
16137
+ input_schema: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()).optional(),
16138
+ allowed_domains: import_zod38.z.array(import_zod38.z.string()).optional(),
16139
+ blocked_domains: import_zod38.z.array(import_zod38.z.string()).optional()
16070
16140
  });
16071
- ToolChoiceSchema = import_zod37.z.union([
16072
- import_zod37.z.looseObject({ type: import_zod37.z.enum(["auto", "none", "any"]) }),
16073
- import_zod37.z.looseObject({ type: import_zod37.z.literal("tool"), name: import_zod37.z.string().min(1) })
16141
+ ToolChoiceSchema = import_zod38.z.union([
16142
+ import_zod38.z.looseObject({ type: import_zod38.z.enum(["auto", "none", "any"]) }),
16143
+ import_zod38.z.looseObject({ type: import_zod38.z.literal("tool"), name: import_zod38.z.string().min(1) })
16074
16144
  ]);
16075
- SystemSchema = import_zod37.z.union([import_zod37.z.string(), import_zod37.z.array(import_zod37.z.union([TextBlockSchema, OtherBlockSchema]))]);
16076
- MessagesRequestSchema = import_zod37.z.looseObject({
16077
- model: import_zod37.z.string().optional(),
16145
+ SystemSchema = import_zod38.z.union([import_zod38.z.string(), import_zod38.z.array(import_zod38.z.union([TextBlockSchema, OtherBlockSchema]))]);
16146
+ MessagesRequestSchema = import_zod38.z.looseObject({
16147
+ model: import_zod38.z.string().optional(),
16078
16148
  system: SystemSchema.optional(),
16079
- messages: import_zod37.z.array(MessageSchema),
16080
- tools: import_zod37.z.array(ToolSchema).optional(),
16149
+ messages: import_zod38.z.array(MessageSchema),
16150
+ tools: import_zod38.z.array(ToolSchema).optional(),
16081
16151
  tool_choice: ToolChoiceSchema.optional(),
16082
- stream: import_zod37.z.boolean().optional(),
16152
+ stream: import_zod38.z.boolean().optional(),
16083
16153
  /** `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. */
16084
- metadata: import_zod37.z.looseObject({ user_id: import_zod37.z.string().optional() }).optional(),
16154
+ metadata: import_zod38.z.looseObject({ user_id: import_zod38.z.string().optional() }).optional(),
16085
16155
  /** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
16086
- output_config: import_zod37.z.looseObject({ effort: import_zod37.z.string().optional(), format: import_zod37.z.object({ type: import_zod37.z.literal("json_schema"), schema: import_zod37.z.record(import_zod37.z.string(), import_zod37.z.unknown()) }).optional() }).optional()
16156
+ output_config: import_zod38.z.looseObject({ effort: import_zod38.z.string().optional(), format: import_zod38.z.object({ type: import_zod38.z.literal("json_schema"), schema: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()) }).optional() }).optional()
16087
16157
  });
16088
- CountTokensRequestSchema = import_zod37.z.looseObject({
16089
- system: import_zod37.z.unknown().optional(),
16090
- messages: import_zod37.z.unknown().optional(),
16091
- tools: import_zod37.z.unknown().optional()
16158
+ CountTokensRequestSchema = import_zod38.z.looseObject({
16159
+ system: import_zod38.z.unknown().optional(),
16160
+ messages: import_zod38.z.unknown().optional(),
16161
+ tools: import_zod38.z.unknown().optional()
16092
16162
  });
16093
16163
  }
16094
16164
  });
@@ -17048,7 +17118,7 @@ function buildEnv(params) {
17048
17118
  const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
17049
17119
  let providerCustomHeaders;
17050
17120
  if (!params.configDirEscapeHatch && params.identityId !== void 0) {
17051
- env.CLAUDE_CONFIG_DIR = import_node_path50.default.join(params.identitiesDir, params.identityId);
17121
+ env.CLAUDE_CONFIG_DIR = import_node_path51.default.join(params.identitiesDir, params.identityId);
17052
17122
  }
17053
17123
  if (params.provider !== void 0) {
17054
17124
  const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
@@ -17125,11 +17195,11 @@ function buildEnv(params) {
17125
17195
  injections.finish();
17126
17196
  return env;
17127
17197
  }
17128
- var import_node_path50, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
17198
+ var import_node_path51, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
17129
17199
  var init_flags = __esm({
17130
17200
  "src/launcher/flags.ts"() {
17131
17201
  "use strict";
17132
- import_node_path50 = __toESM(require("node:path"), 1);
17202
+ import_node_path51 = __toESM(require("node:path"), 1);
17133
17203
  init_envBool();
17134
17204
  init_cliError();
17135
17205
  init_conditions();
@@ -17222,7 +17292,7 @@ function newestTranscript(fs17, projectDir) {
17222
17292
  if (!name.endsWith(".jsonl")) {
17223
17293
  continue;
17224
17294
  }
17225
- const candidate = import_node_path51.default.join(projectDir, name);
17295
+ const candidate = import_node_path52.default.join(projectDir, name);
17226
17296
  const stat = fs17.lstat(candidate);
17227
17297
  if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
17228
17298
  newestMs = stat.mtimeMs;
@@ -17236,16 +17306,16 @@ function resumedContextTokens(fs17, params) {
17236
17306
  if (target === void 0) {
17237
17307
  return void 0;
17238
17308
  }
17239
- const projectDir = import_node_path51.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
17240
- const file = target.kind === "id" ? import_node_path51.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
17309
+ const projectDir = import_node_path52.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
17310
+ const file = target.kind === "id" ? import_node_path52.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
17241
17311
  const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
17242
17312
  return text === void 0 ? void 0 : contextTokensOfTranscript(text);
17243
17313
  }
17244
- var import_node_path51;
17314
+ var import_node_path52;
17245
17315
  var init_resumeContext = __esm({
17246
17316
  "src/usage/resumeContext.ts"() {
17247
17317
  "use strict";
17248
- import_node_path51 = __toESM(require("node:path"), 1);
17318
+ import_node_path52 = __toESM(require("node:path"), 1);
17249
17319
  }
17250
17320
  });
17251
17321
 
@@ -17780,6 +17850,235 @@ var init_spawn = __esm({
17780
17850
  }
17781
17851
  });
17782
17852
 
17853
+ // src/supervise/sessionControlPlugin.ts
17854
+ function removeAbandonedPlugins(parent, isRunning) {
17855
+ const uid = process.getuid?.();
17856
+ for (const name of (0, import_node_fs16.readdirSync)(parent)) {
17857
+ const pid = Number(/^agent-shim-control-(\d+)-/u.exec(name)?.[1]);
17858
+ if (!name.startsWith(STAGED_PREFIX) || !Number.isInteger(pid) || isRunning(pid)) {
17859
+ continue;
17860
+ }
17861
+ const entry = import_node_path53.default.join(parent, name);
17862
+ const stat = (0, import_node_fs16.lstatSync)(entry, { throwIfNoEntry: false });
17863
+ if (stat?.isDirectory() === true && (uid === void 0 || stat.uid === uid)) {
17864
+ (0, import_node_fs16.rmSync)(entry, { recursive: true, force: true });
17865
+ }
17866
+ }
17867
+ }
17868
+ function stageSessionControlPlugin(options = {}) {
17869
+ const parent = options.parent ?? (0, import_node_os9.tmpdir)();
17870
+ removeAbandonedPlugins(parent, options.isRunning ?? realIsProcessRunning);
17871
+ const directory = (0, import_node_fs16.mkdtempSync)(import_node_path53.default.join(parent, `${STAGED_PREFIX}${String(options.pid ?? process.pid)}-`));
17872
+ const { ready, session, requests, results } = sessionControlPluginPaths(directory);
17873
+ try {
17874
+ (0, import_node_fs16.mkdirSync)(import_node_path53.default.join(directory, ".claude-plugin"), { mode: 448 });
17875
+ (0, import_node_fs16.mkdirSync)(import_node_path53.default.join(directory, "hooks"), { mode: 448 });
17876
+ (0, import_node_fs16.mkdirSync)(requests, { mode: 448 });
17877
+ (0, import_node_fs16.mkdirSync)(results, { mode: 448 });
17878
+ (0, import_node_fs16.writeFileSync)(import_node_path53.default.join(directory, ".claude-plugin", "plugin.json"), JSON.stringify({ name: SESSION_CONTROL_PLUGIN_NAME, version: "2.1.0", description: "Compacts, sets goals and submits a person's turns in sessions agent-shim launched, in process" }), { mode: 384 });
17879
+ (0, import_node_fs16.writeFileSync)(import_node_path53.default.join(directory, "hooks", "hooks.json"), JSON.stringify({ modules: ["./register.js"] }), { mode: 384 });
17880
+ (0, import_node_fs16.writeFileSync)(import_node_path53.default.join(directory, "hooks", "register.js"), pluginSource(ready, session, requests, results), { mode: 384 });
17881
+ return { directory, ready, session, requests, results, release: () => {
17882
+ (0, import_node_fs16.rmSync)(directory, { recursive: true, force: true });
17883
+ } };
17884
+ } catch (error) {
17885
+ (0, import_node_fs16.rmSync)(directory, { recursive: true, force: true });
17886
+ throw error;
17887
+ }
17888
+ }
17889
+ function sessionControlPluginPaths(directory) {
17890
+ return { directory, ready: import_node_path53.default.join(directory, "ready.json"), session: import_node_path53.default.join(directory, "session.json"), requests: import_node_path53.default.join(directory, "requests"), results: import_node_path53.default.join(directory, "results") };
17891
+ }
17892
+ function pluginSource(ready, session, requests, results) {
17893
+ return `const REQUESTS = ${JSON.stringify(requests)};
17894
+ const RESULTS = ${JSON.stringify(results)};
17895
+ function compacted(id, value) {
17896
+ return { id, ...(typeof value?.skip === 'string' ? { kind: 'unchanged', skip: value.skip } : { kind: 'compacted', tokensBefore: value?.tokensBefore, tokensAfter: value?.tokensAfter }) };
17897
+ }
17898
+ async function resultNames($) {
17899
+ return new Set((await $.fs.list(RESULTS)).map((entry) => entry.name));
17900
+ }
17901
+ async function recordSession($, event, next) {
17902
+ const answer = await next(event);
17903
+ if (typeof event?.session_id === 'string' && typeof event?.transcript_path === 'string') {
17904
+ const record = JSON.stringify({ conversationId: event.session_id, transcriptPath: event.transcript_path });
17905
+ $.clock.after(0, async () => {
17906
+ await $.fs.write(${JSON.stringify(session)}, record);
17907
+ });
17908
+ }
17909
+ return answer;
17910
+ }
17911
+ export function register(on) {
17912
+ let running = false;
17913
+ on('classic.SessionStart', recordSession);
17914
+ on('classic.UserPromptSubmit', recordSession);
17915
+ on('classic.Stop', recordSession);
17916
+ on('classic.PostCompact', async ($, event, next) => {
17917
+ const answer = await next(event);
17918
+ $.clock.after(0, async () => {
17919
+ for (const name of await resultNames($)) {
17920
+ const text = await $.fs.read(RESULTS + '/' + name);
17921
+ if (typeof text !== 'string') continue;
17922
+ const current = JSON.parse(text);
17923
+ if (current.kind === 'running' && current.op === 'compact' && typeof current.id === 'string') {
17924
+ await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: current.id, kind: 'compacted' }));
17925
+ }
17926
+ }
17927
+ });
17928
+ return answer;
17929
+ });
17930
+ on('session.start', async ($, event, next) => {
17931
+ const answer = await next(event);
17932
+ const version = await $.session.version();
17933
+ await $.fs.write(${JSON.stringify(ready)}, JSON.stringify({ ready: true, version: version.version }));
17934
+ $.clock.every(1000, async () => {
17935
+ if (running) return;
17936
+ running = true;
17937
+ try {
17938
+ const done = await resultNames($);
17939
+ const names = (await $.fs.list(REQUESTS)).map((entry) => entry.name).filter((name) => !name.startsWith('.') && name.endsWith('.json') && !done.has(name)).sort();
17940
+ const name = names[0];
17941
+ if (name === undefined) return;
17942
+ const text = await $.fs.read(REQUESTS + '/' + name);
17943
+ if (typeof text !== 'string') return;
17944
+ const item = JSON.parse(text);
17945
+ if (typeof item.id !== 'string' || name !== item.id + '.json') {
17946
+ await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: name.slice(0, -5), error: 'the request is not one this plugin reads' }));
17947
+ return;
17948
+ }
17949
+ await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: item.id, kind: 'running', op: item.op }));
17950
+ let response;
17951
+ try {
17952
+ if (typeof item.expiresAt !== 'number' || await $.clock.now() >= item.expiresAt) throw new Error('the request expired before the session could run it, so it was not run');
17953
+ if (typeof item.conversationId !== 'string' || await $.session.id() !== item.conversationId) throw new Error('the conversation changed before the request ran');
17954
+ if (item.op === 'compact') {
17955
+ response = compacted(item.id, await $.session.compact(typeof item.instructions === 'string' ? { instructions: item.instructions } : {}));
17956
+ } else if (item.op === 'goal' && typeof item.args === 'string' && item.args.trim() !== '') {
17957
+ const ran = await $.command.run({ command: 'goal', args: item.args });
17958
+ response = { id: item.id, kind: 'ran', ...(typeof ran?.text === 'string' ? { text: ran.text } : {}) };
17959
+ } else if (item.op === 'turn' && typeof item.text === 'string' && item.text.trim() !== '') {
17960
+ const submitted = await $.prompt.submit({ text: item.text, asUser: true });
17961
+ if (typeof submitted?.drop === 'string') throw new Error('a hook dropped the prompt: ' + submitted.drop);
17962
+ response = { id: item.id, kind: 'submitted', text: submitted?.text, origin: submitted?.origin };
17963
+ } else {
17964
+ throw new Error('the request names no operation this plugin performs');
17965
+ }
17966
+ } catch (error) {
17967
+ response = { id: item.id, error: error instanceof Error ? error.message : String(error) };
17968
+ }
17969
+ await $.fs.write(RESULTS + '/' + name, JSON.stringify(response));
17970
+ } finally {
17971
+ running = false;
17972
+ }
17973
+ });
17974
+ return answer;
17975
+ });
17976
+ }
17977
+ `;
17978
+ }
17979
+ function withSessionControlPlugin(args, directory) {
17980
+ const end = args.indexOf("--");
17981
+ const result = [...args];
17982
+ result.splice(end === -1 ? result.length : end, 0, "--plugin-dir", directory);
17983
+ return result;
17984
+ }
17985
+ var import_node_fs16, import_node_os9, import_node_path53, SESSION_CONTROL_PLUGIN_NAME, STAGED_PREFIX;
17986
+ var init_sessionControlPlugin = __esm({
17987
+ "src/supervise/sessionControlPlugin.ts"() {
17988
+ "use strict";
17989
+ import_node_fs16 = require("node:fs");
17990
+ import_node_os9 = require("node:os");
17991
+ import_node_path53 = __toESM(require("node:path"), 1);
17992
+ init_realPorts();
17993
+ SESSION_CONTROL_PLUGIN_NAME = "agent-shim-control";
17994
+ STAGED_PREFIX = "agent-shim-control-";
17995
+ }
17996
+ });
17997
+
17998
+ // src/supervise/launchControl.ts
17999
+ function readRecord2(fs17, directory, name) {
18000
+ if (!name.endsWith(RECORD_SUFFIX3)) {
18001
+ return void 0;
18002
+ }
18003
+ const raw = fs17.readFileUtf8(import_node_path54.default.join(directory, name));
18004
+ if (raw === void 0) {
18005
+ return void 0;
18006
+ }
18007
+ try {
18008
+ const parsed = LaunchControlSchema.safeParse(JSON.parse(raw));
18009
+ return parsed.success ? parsed.data : void 0;
18010
+ } catch {
18011
+ return void 0;
18012
+ }
18013
+ }
18014
+ function registerLaunchControl(fs17, directory, control, isRunning) {
18015
+ fs17.mkdirPrivate(directory);
18016
+ for (const name of fs17.readdir(directory)) {
18017
+ const record = readRecord2(fs17, directory, name);
18018
+ if (record !== void 0 && !isRunning(record.pid)) {
18019
+ fs17.removeRecursive(import_node_path54.default.join(directory, name));
18020
+ }
18021
+ }
18022
+ const file = import_node_path54.default.join(directory, `${String(control.pid)}.${(0, import_node_crypto18.randomUUID)()}${RECORD_SUFFIX3}`);
18023
+ fs17.writeFilePrivate(file, `${JSON.stringify(LaunchControlSchema.parse(control))}
18024
+ `);
18025
+ return () => {
18026
+ fs17.removeRecursive(file);
18027
+ };
18028
+ }
18029
+ function launchLoadsControlPlugin(candidate) {
18030
+ const end = candidate.args.indexOf("--");
18031
+ const options = end === -1 ? candidate.args : candidate.args.slice(0, end);
18032
+ return !candidate.supervised && candidate.startsSession && !options.includes("--bare") && candidate.version !== void 0 && RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(candidate.version);
18033
+ }
18034
+ function stageControlPluginFor(candidate, stage, warn) {
18035
+ if (stage === void 0 || !launchLoadsControlPlugin(candidate)) {
18036
+ return void 0;
18037
+ }
18038
+ try {
18039
+ return stage();
18040
+ } catch (error) {
18041
+ warn(`agent-shim: the in-process control plugin could not be staged, so this session starts without it and the front door cannot reach it for goal, compaction and turn control: ${error instanceof Error ? error.message : String(error)}`);
18042
+ return void 0;
18043
+ }
18044
+ }
18045
+ function stageLaunchControl(params) {
18046
+ const plugin = stageSessionControlPlugin({ pid: params.pid, isRunning: params.isRunning, ...params.parent === void 0 ? {} : { parent: params.parent } });
18047
+ let unregister;
18048
+ try {
18049
+ unregister = registerLaunchControl(params.fs, params.paths.launchControlDir, { pid: params.pid, directory: plugin.directory }, params.isRunning);
18050
+ } catch (error) {
18051
+ plugin.release();
18052
+ throw error;
18053
+ }
18054
+ return {
18055
+ args: (args) => withSessionControlPlugin(args, plugin.directory),
18056
+ release: () => {
18057
+ unregister();
18058
+ plugin.release();
18059
+ }
18060
+ };
18061
+ }
18062
+ var import_node_path54, import_node_crypto18, import_zod49, LaunchControlSchema, RECORD_SUFFIX3;
18063
+ var init_launchControl = __esm({
18064
+ "src/supervise/launchControl.ts"() {
18065
+ "use strict";
18066
+ import_node_path54 = __toESM(require("node:path"), 1);
18067
+ import_node_crypto18 = require("node:crypto");
18068
+ import_zod49 = require("zod");
18069
+ init_sessionControl();
18070
+ init_sessionControlPlugin();
18071
+ init_verifiedVersions();
18072
+ LaunchControlSchema = import_zod49.z.strictObject({
18073
+ /** The launcher's process id, which tells a live channel from one a killed launcher left. */
18074
+ pid: import_zod49.z.number().int().positive(),
18075
+ /** The plugin's directory, its request and result files beneath it. */
18076
+ directory: import_zod49.z.string().min(1)
18077
+ });
18078
+ RECORD_SUFFIX3 = ".json";
18079
+ }
18080
+ });
18081
+
17783
18082
  // src/update/launchHook.ts
17784
18083
  function resolveUpdateMode(globalConfig) {
17785
18084
  return globalConfig?.update?.mode ?? "off";
@@ -17951,7 +18250,7 @@ function decideLaunch(params, readOnly, onRecorded) {
17951
18250
  const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
17952
18251
  const farm = farmIdentity === void 0 ? void 0 : params.farm;
17953
18252
  if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
17954
- warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, import_node_path52.default.join(paths.identitiesDir, farmIdentity));
18253
+ warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, import_node_path55.default.join(paths.identitiesDir, farmIdentity));
17955
18254
  }
17956
18255
  if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
17957
18256
  try {
@@ -18145,12 +18444,12 @@ function decideLaunch(params, readOnly, onRecorded) {
18145
18444
  if (definition.kind === "codex" && readOnly && cache !== void 0) {
18146
18445
  const binding = parseCatalogueBinding(stored.bindingText(name, owner));
18147
18446
  const configuredHome = catalogueEnv.CODEX_HOME;
18148
- const home = configuredHome === void 0 || configuredHome === "" ? import_node_path52.default.join(import_node_os9.default.homedir(), ".codex") : configuredHome;
18149
- const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path52.default.resolve(home, "auth.json");
18447
+ const home = configuredHome === void 0 || configuredHome === "" ? import_node_path55.default.join(import_node_os10.default.homedir(), ".codex") : configuredHome;
18448
+ const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path55.default.resolve(home, "auth.json");
18150
18449
  const revision = params.fs.fileRevision?.(source);
18151
18450
  if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
18152
18451
  }
18153
- const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os9.default.homedir(), reader) : void 0;
18452
+ const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os10.default.homedir(), reader) : void 0;
18154
18453
  if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
18155
18454
  if (isHttpProvider(definition) && cache !== void 0 && !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, definition)) return [[name, definition, []]];
18156
18455
  return [[name, definition, cache?.models ?? []]];
@@ -18168,7 +18467,7 @@ function decideLaunch(params, readOnly, onRecorded) {
18168
18467
  return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
18169
18468
  };
18170
18469
  const args = argsForSupervisor().args;
18171
- const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path52.default.join(paths.identitiesDir, farmIdentity);
18470
+ const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path55.default.join(paths.identitiesDir, farmIdentity);
18172
18471
  const decision = {
18173
18472
  identitySource: identityDecision.source,
18174
18473
  configDirEscapeHatch: identityDecision.configDirEscapeHatch,
@@ -18208,6 +18507,8 @@ function decideLaunch(params, readOnly, onRecorded) {
18208
18507
  models,
18209
18508
  globalModels,
18210
18509
  bin: discovered.path,
18510
+ binVersion: discovered.version,
18511
+ startsSession,
18211
18512
  args,
18212
18513
  argsForSupervisor,
18213
18514
  decision
@@ -18264,7 +18565,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
18264
18565
  let warnings = [];
18265
18566
  const updateCheck = runLaunchUpdateCheck({
18266
18567
  mode: params.updateMode ?? "off",
18267
- checkPath: import_node_path52.default.join(paths.root, "update.check"),
18568
+ checkPath: import_node_path55.default.join(paths.root, "update.check"),
18268
18569
  currentVersion: package_default.version,
18269
18570
  port: params.update
18270
18571
  });
@@ -18287,7 +18588,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
18287
18588
  classification: resyncFarmRuntime.classification,
18288
18589
  now: resyncFarmRuntime.now,
18289
18590
  uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
18290
- identityExists: () => params.fs.readConfigFile(import_node_path52.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
18591
+ identityExists: () => params.fs.readConfigFile(import_node_path55.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
18291
18592
  lock: resyncFarmRuntime.lock
18292
18593
  });
18293
18594
  } catch (error) {
@@ -18321,7 +18622,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
18321
18622
  log.error("agent-shim: this launch routes through the front-door daemon, but this launcher has no front-door port wired; refusing to launch without it.");
18322
18623
  proc.exit(1);
18323
18624
  }
18324
- const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto18.randomUUID)();
18625
+ const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto19.randomUUID)();
18325
18626
  const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
18326
18627
  const sessionModels = (0, import_node_util2.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
18327
18628
  const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
@@ -18366,16 +18667,17 @@ function prepareRegisteredLaunch(params, onRecorded) {
18366
18667
  proxyBypass: resolvedFlags.proxyBypass,
18367
18668
  ...resolvedFlags.statusline === void 0 ? {} : { statusline: resolvedFlags.statusline }
18368
18669
  });
18369
- const releases = [...unregisterLaunch === void 0 ? [] : [unregisterLaunch], ...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease]];
18670
+ const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
18671
+ const control = stageControlPluginFor({ args: picker.args, version: decided.binVersion, startsSession: decided.startsSession, supervised: params.supervised !== void 0 }, params.stageControlPlugin, log.warn);
18672
+ const releases = [...unregisterLaunch === void 0 ? [] : [unregisterLaunch], ...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease], ...control === void 0 ? [] : [control.release]];
18370
18673
  const release = () => {
18371
18674
  for (const registered of releases) {
18372
18675
  registered();
18373
18676
  }
18374
18677
  };
18375
- const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
18376
18678
  if (picker.pickerSuppressed) rows.push(noteRow("--settings was passed, so /model keeps Claude Code's own model names"));
18377
18679
  rows.push(...notes.map(noteRow));
18378
- return { finalEnv, release, picker, sessionId };
18680
+ return { finalEnv, release, args: control === void 0 ? picker.args : control.args(picker.args), sessionId };
18379
18681
  });
18380
18682
  const unreachable = reachability?.line();
18381
18683
  log.report(rows);
@@ -18384,7 +18686,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
18384
18686
  }
18385
18687
  printDiagnosticLines(log, warnings, { errorsAsWarnings: false });
18386
18688
  const hold = () => holdBeforeLaunch({ delayMs: resolvedFlags.delayMs, pause: resolvedFlags.pause }, params.hold, log);
18387
- return { bin: decided.bin, args: brought.picker.args, env: brought.finalEnv, sessionId: brought.sessionId, release: brought.release, markChildStarted: updateCheck.markChildStarted, hold, decision };
18689
+ return { bin: decided.bin, args: brought.args, env: brought.finalEnv, sessionId: brought.sessionId, release: brought.release, markChildStarted: updateCheck.markChildStarted, hold, decision };
18388
18690
  }
18389
18691
  function resolveLaunch(params) {
18390
18692
  const decided = decideLaunch(params, true);
@@ -18435,15 +18737,15 @@ function runLaunchPlan(plan, spawn3) {
18435
18737
  function runLauncher(params) {
18436
18738
  params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
18437
18739
  }
18438
- var import_node_crypto18, import_node_os9, import_node_util2, import_node_path52;
18740
+ var import_node_crypto19, import_node_os10, import_node_util2, import_node_path55;
18439
18741
  var init_launcher = __esm({
18440
18742
  "src/launcher.ts"() {
18441
18743
  "use strict";
18442
- import_node_crypto18 = require("node:crypto");
18443
- import_node_os9 = __toESM(require("node:os"), 1);
18744
+ import_node_crypto19 = require("node:crypto");
18745
+ import_node_os10 = __toESM(require("node:os"), 1);
18444
18746
  init_catalogueCredential();
18445
18747
  import_node_util2 = require("node:util");
18446
- import_node_path52 = __toESM(require("node:path"), 1);
18748
+ import_node_path55 = __toESM(require("node:path"), 1);
18447
18749
  init_package();
18448
18750
  init_envBool();
18449
18751
  init_argv();
@@ -18472,6 +18774,7 @@ var init_launcher = __esm({
18472
18774
  init_resumeContext();
18473
18775
  init_lock();
18474
18776
  init_spawn();
18777
+ init_launchControl();
18475
18778
  init_providersStore();
18476
18779
  init_load();
18477
18780
  init_flatten();
@@ -18497,13 +18800,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
18497
18800
  if (distDir === void 0) {
18498
18801
  throw new OwnCliPathUnknownError();
18499
18802
  }
18500
- return import_node_path53.default.join(distDir, OWN_CLI_FILE_NAME);
18803
+ return import_node_path56.default.join(distDir, OWN_CLI_FILE_NAME);
18501
18804
  }
18502
- var import_node_path53, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
18805
+ var import_node_path56, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
18503
18806
  var init_ownCli = __esm({
18504
18807
  "src/ownCli.ts"() {
18505
18808
  "use strict";
18506
- import_node_path53 = __toESM(require("node:path"), 1);
18809
+ import_node_path56 = __toESM(require("node:path"), 1);
18507
18810
  init_cliError();
18508
18811
  OWN_CLI_FILE_NAME = "cli.cjs";
18509
18812
  OwnCliPathUnknownError = class extends CliError {
@@ -18517,15 +18820,15 @@ var init_ownCli = __esm({
18517
18820
 
18518
18821
  // src/frontdoor/doorLog.ts
18519
18822
  function appendDoorLog(paths, line) {
18520
- import_node_fs16.default.mkdirSync(paths.logsDir, { recursive: true });
18521
- import_node_fs16.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
18823
+ import_node_fs17.default.mkdirSync(paths.logsDir, { recursive: true });
18824
+ import_node_fs17.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
18522
18825
  `);
18523
18826
  }
18524
- var import_node_fs16;
18827
+ var import_node_fs17;
18525
18828
  var init_doorLog = __esm({
18526
18829
  "src/frontdoor/doorLog.ts"() {
18527
18830
  "use strict";
18528
- import_node_fs16 = __toESM(require("node:fs"), 1);
18831
+ import_node_fs17 = __toESM(require("node:fs"), 1);
18529
18832
  }
18530
18833
  });
18531
18834
 
@@ -18546,7 +18849,7 @@ var init_selfIdentity = __esm({
18546
18849
  // src/frontdoor/trust.ts
18547
18850
  function resolveTrustBundle(params) {
18548
18851
  const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
18549
- if (inherited === void 0 || inherited === "" || import_node_path54.default.resolve(inherited) === import_node_path54.default.resolve(caCertFile)) {
18852
+ if (inherited === void 0 || inherited === "" || import_node_path57.default.resolve(inherited) === import_node_path57.default.resolve(caCertFile)) {
18550
18853
  return { path: caCertFile };
18551
18854
  }
18552
18855
  const caPem = fs17.readFileUtf8(caCertFile);
@@ -18564,19 +18867,19 @@ function resolveTrustBundle(params) {
18564
18867
  }
18565
18868
  const combined = `${inheritedPem.trimEnd()}
18566
18869
  ${caPem}`;
18567
- const bundle = import_node_path54.default.join(bundlesDir, `${(0, import_node_crypto19.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
18870
+ const bundle = import_node_path57.default.join(bundlesDir, `${(0, import_node_crypto20.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
18568
18871
  if (!fs17.exists(bundle)) {
18569
18872
  fs17.mkdirp(bundlesDir);
18570
18873
  fs17.writeFileAtomic(bundle, combined);
18571
18874
  }
18572
18875
  return { path: bundle };
18573
18876
  }
18574
- var import_node_crypto19, import_node_path54, BUNDLE_NAME_HEX_DIGITS;
18877
+ var import_node_crypto20, import_node_path57, BUNDLE_NAME_HEX_DIGITS;
18575
18878
  var init_trust = __esm({
18576
18879
  "src/frontdoor/trust.ts"() {
18577
18880
  "use strict";
18578
- import_node_crypto19 = require("node:crypto");
18579
- import_node_path54 = __toESM(require("node:path"), 1);
18881
+ import_node_crypto20 = require("node:crypto");
18882
+ import_node_path57 = __toESM(require("node:path"), 1);
18580
18883
  BUNDLE_NAME_HEX_DIGITS = 16;
18581
18884
  }
18582
18885
  });
@@ -18618,7 +18921,7 @@ function realEnsurePorts(paths, spawnDaemon) {
18618
18921
  }
18619
18922
  },
18620
18923
  // Read fresh for each probe: a replacement supervisor may have regenerated an unparseable CA, and the probe must trust exactly what the serving door's leaf chains to.
18621
- verifyListener: (port) => probeFrontDoorSync(port, import_node_fs17.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
18924
+ verifyListener: (port) => probeFrontDoorSync(port, import_node_fs18.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
18622
18925
  };
18623
18926
  }
18624
18927
  function realFrontDoorPort(paths, spawnDaemon) {
@@ -18647,7 +18950,7 @@ function realFrontDoorPort(paths, spawnDaemon) {
18647
18950
  let fingerprint;
18648
18951
  let loginFault;
18649
18952
  try {
18650
- fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os10.default.homedir(), new TolerantReader((file) => realFarmFs.readFileUtf8(file), (fault) => {
18953
+ fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os11.default.homedir(), new TolerantReader((file) => realFarmFs.readFileUtf8(file), (fault) => {
18651
18954
  loginFault = fault;
18652
18955
  }));
18653
18956
  } catch (error) {
@@ -18703,12 +19006,12 @@ function realFrontDoorPort(paths, spawnDaemon) {
18703
19006
  }
18704
19007
  };
18705
19008
  }
18706
- var import_node_fs17, import_node_os10, realTrustBundleFs;
19009
+ var import_node_fs18, import_node_os11, realTrustBundleFs;
18707
19010
  var init_realFrontDoorPort = __esm({
18708
19011
  "src/frontdoor/realFrontDoorPort.ts"() {
18709
19012
  "use strict";
18710
- import_node_fs17 = __toESM(require("node:fs"), 1);
18711
- import_node_os10 = __toESM(require("node:os"), 1);
19013
+ import_node_fs18 = __toESM(require("node:fs"), 1);
19014
+ import_node_os11 = __toESM(require("node:os"), 1);
18712
19015
  init_providersStore();
18713
19016
  init_schema();
18714
19017
  init_providerCatalogue();
@@ -18725,10 +19028,10 @@ var init_realFrontDoorPort = __esm({
18725
19028
  init_trust();
18726
19029
  init_monotonicClock();
18727
19030
  realTrustBundleFs = {
18728
- readFileUtf8: (file) => import_node_fs17.default.readFileSync(file, "utf8"),
18729
- exists: (file) => import_node_fs17.default.existsSync(file),
19031
+ readFileUtf8: (file) => import_node_fs18.default.readFileSync(file, "utf8"),
19032
+ exists: (file) => import_node_fs18.default.existsSync(file),
18730
19033
  mkdirp: (dir) => {
18731
- import_node_fs17.default.mkdirSync(dir, { recursive: true });
19034
+ import_node_fs18.default.mkdirSync(dir, { recursive: true });
18732
19035
  },
18733
19036
  writeFileAtomic: (file, contents) => {
18734
19037
  realFarmFs.writeFilePrivate(file, contents);
@@ -18739,7 +19042,7 @@ var init_realFrontDoorPort = __esm({
18739
19042
 
18740
19043
  // src/launchWiring.ts
18741
19044
  function buildFarmRuntime(paths, cwd, run = realRunPort) {
18742
- const home = import_node_os11.default.homedir();
19045
+ const home = import_node_os12.default.homedir();
18743
19046
  const read = cosmiconfigReader();
18744
19047
  const classification = loadClassification(paths);
18745
19048
  const loaded = loadCascadeInput({ paths, home, cwd, read });
@@ -18764,7 +19067,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
18764
19067
  ...cliOverride === void 0 ? {} : { cliOverride }
18765
19068
  }).input,
18766
19069
  now: () => Date.now(),
18767
- uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto20.randomUUID)()}`,
19070
+ uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto21.randomUUID)()}`,
18768
19071
  // Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
18769
19072
  lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
18770
19073
  },
@@ -18792,8 +19095,9 @@ function realPrepareLaunchParams(paths, options) {
18792
19095
  credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
18793
19096
  startBaseUrlProbe: realStartBaseUrlProbe,
18794
19097
  hold: realHoldPort,
18795
- hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path55.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
18796
- hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path55.default.join(paths.identitiesDir, identity), options.proc.env),
19098
+ hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path58.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
19099
+ hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path58.default.join(paths.identitiesDir, identity), options.proc.env),
19100
+ stageControlPlugin: () => stageLaunchControl({ fs: realFarmFs, paths, pid: process.pid, isRunning: realIsProcessRunning }),
18797
19101
  ...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
18798
19102
  ...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
18799
19103
  ...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
@@ -18857,13 +19161,13 @@ function resolveClaudeLaunch(options, run = realRunPort) {
18857
19161
  };
18858
19162
  return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
18859
19163
  }
18860
- var import_node_os11, import_node_path55, import_node_crypto20, LaunchRefusedError;
19164
+ var import_node_os12, import_node_path58, import_node_crypto21, LaunchRefusedError;
18861
19165
  var init_launchWiring = __esm({
18862
19166
  "src/launchWiring.ts"() {
18863
19167
  "use strict";
18864
- import_node_os11 = __toESM(require("node:os"), 1);
18865
- import_node_path55 = __toESM(require("node:path"), 1);
18866
- import_node_crypto20 = require("node:crypto");
19168
+ import_node_os12 = __toESM(require("node:os"), 1);
19169
+ import_node_path58 = __toESM(require("node:path"), 1);
19170
+ import_node_crypto21 = require("node:crypto");
18867
19171
  init_cliError();
18868
19172
  init_claudeShim();
18869
19173
  init_classify();
@@ -18878,6 +19182,7 @@ var init_launchWiring = __esm({
18878
19182
  init_paths();
18879
19183
  init_signIn();
18880
19184
  init_providerReachability();
19185
+ init_launchControl();
18881
19186
  init_realPorts();
18882
19187
  LaunchRefusedError = class extends CliError {
18883
19188
  exitCode;
@@ -19089,11 +19394,11 @@ var init_identityClaude = __esm({
19089
19394
  });
19090
19395
 
19091
19396
  // src/usage/providerQuota.ts
19092
- var import_zod48, 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;
19397
+ var import_zod50, 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;
19093
19398
  var init_providerQuota = __esm({
19094
19399
  "src/usage/providerQuota.ts"() {
19095
19400
  "use strict";
19096
- import_zod48 = require("zod");
19401
+ import_zod50 = require("zod");
19097
19402
  init_cloudUpstream();
19098
19403
  init_schema2();
19099
19404
  MS_PER_SECOND9 = 1e3;
@@ -19108,35 +19413,35 @@ var init_providerQuota = __esm({
19108
19413
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
19109
19414
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
19110
19415
  ]);
19111
- ZaiLimitSchema = import_zod48.z.object({
19112
- type: import_zod48.z.string(),
19113
- unit: import_zod48.z.number().int(),
19114
- number: import_zod48.z.number().int().positive(),
19115
- percentage: import_zod48.z.number().nonnegative(),
19116
- nextResetTime: import_zod48.z.number().positive().optional(),
19117
- usage: import_zod48.z.number().nonnegative().optional(),
19118
- currentValue: import_zod48.z.number().nonnegative().optional(),
19119
- remaining: import_zod48.z.number().nonnegative().optional()
19416
+ ZaiLimitSchema = import_zod50.z.object({
19417
+ type: import_zod50.z.string(),
19418
+ unit: import_zod50.z.number().int(),
19419
+ number: import_zod50.z.number().int().positive(),
19420
+ percentage: import_zod50.z.number().nonnegative(),
19421
+ nextResetTime: import_zod50.z.number().positive().optional(),
19422
+ usage: import_zod50.z.number().nonnegative().optional(),
19423
+ currentValue: import_zod50.z.number().nonnegative().optional(),
19424
+ remaining: import_zod50.z.number().nonnegative().optional()
19120
19425
  });
19121
- ZaiResponseSchema = import_zod48.z.object({
19122
- success: import_zod48.z.boolean(),
19123
- msg: import_zod48.z.string().optional(),
19124
- data: import_zod48.z.object({ level: import_zod48.z.string().optional(), limits: import_zod48.z.array(ZaiLimitSchema) })
19426
+ ZaiResponseSchema = import_zod50.z.object({
19427
+ success: import_zod50.z.boolean(),
19428
+ msg: import_zod50.z.string().optional(),
19429
+ data: import_zod50.z.object({ level: import_zod50.z.string().optional(), limits: import_zod50.z.array(ZaiLimitSchema) })
19125
19430
  });
19126
19431
  OPENROUTER_HOST = "openrouter.ai";
19127
19432
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
19128
19433
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
19129
19434
  MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
19130
- OpenRouterKeySchema = import_zod48.z.object({
19131
- data: import_zod48.z.object({
19132
- limit: import_zod48.z.number().nonnegative().nullable(),
19133
- limit_remaining: import_zod48.z.number().nullable(),
19134
- limit_reset: import_zod48.z.string().nullable(),
19135
- is_free_tier: import_zod48.z.boolean().optional(),
19136
- free_model_daily_requests: import_zod48.z.object({ used: import_zod48.z.number().nonnegative(), limit: import_zod48.z.number().nonnegative(), remaining: import_zod48.z.number() }).optional()
19435
+ OpenRouterKeySchema = import_zod50.z.object({
19436
+ data: import_zod50.z.object({
19437
+ limit: import_zod50.z.number().nonnegative().nullable(),
19438
+ limit_remaining: import_zod50.z.number().nullable(),
19439
+ limit_reset: import_zod50.z.string().nullable(),
19440
+ is_free_tier: import_zod50.z.boolean().optional(),
19441
+ free_model_daily_requests: import_zod50.z.object({ used: import_zod50.z.number().nonnegative(), limit: import_zod50.z.number().nonnegative(), remaining: import_zod50.z.number() }).optional()
19137
19442
  })
19138
19443
  });
19139
- OpenRouterCreditsSchema = import_zod48.z.object({ data: import_zod48.z.object({ total_credits: import_zod48.z.number().nonnegative(), total_usage: import_zod48.z.number().nonnegative() }) });
19444
+ OpenRouterCreditsSchema = import_zod50.z.object({ data: import_zod50.z.object({ total_credits: import_zod50.z.number().nonnegative(), total_usage: import_zod50.z.number().nonnegative() }) });
19140
19445
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
19141
19446
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
19142
19447
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
@@ -19144,21 +19449,21 @@ var init_providerQuota = __esm({
19144
19449
  DAYS_PER_WEEK2 = 7;
19145
19450
  FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
19146
19451
  WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
19147
- AntigravityBucketSchema = import_zod48.z.object({
19148
- bucketId: import_zod48.z.string(),
19149
- remainingFraction: import_zod48.z.number().optional(),
19150
- resetTime: import_zod48.z.string().optional()
19452
+ AntigravityBucketSchema = import_zod50.z.object({
19453
+ bucketId: import_zod50.z.string(),
19454
+ remainingFraction: import_zod50.z.number().optional(),
19455
+ resetTime: import_zod50.z.string().optional()
19151
19456
  });
19152
- AntigravitySummarySchema = import_zod48.z.object({ groups: import_zod48.z.array(import_zod48.z.object({ buckets: import_zod48.z.array(AntigravityBucketSchema) })) });
19153
- GoogleTokenInfoSchema = import_zod48.z.object({
19154
- email: import_zod48.z.string().optional(),
19155
- sub: import_zod48.z.string().optional()
19457
+ AntigravitySummarySchema = import_zod50.z.object({ groups: import_zod50.z.array(import_zod50.z.object({ buckets: import_zod50.z.array(AntigravityBucketSchema) })) });
19458
+ GoogleTokenInfoSchema = import_zod50.z.object({
19459
+ email: import_zod50.z.string().optional(),
19460
+ sub: import_zod50.z.string().optional()
19156
19461
  });
19157
- AntigravityUserSchema = import_zod48.z.object({
19462
+ AntigravityUserSchema = import_zod50.z.object({
19158
19463
  /** The code-assist tier context, which defaults to the free tier for every account. */
19159
- currentTier: import_zod48.z.object({ name: import_zod48.z.string().optional(), id: import_zod48.z.string().optional() }).optional(),
19464
+ currentTier: import_zod50.z.object({ name: import_zod50.z.string().optional(), id: import_zod50.z.string().optional() }).optional(),
19160
19465
  /** The account's paid subscription; absent when the account has none. */
19161
- paidTier: import_zod48.z.object({ name: import_zod48.z.string().optional(), id: import_zod48.z.string().optional() }).optional()
19466
+ paidTier: import_zod50.z.object({ name: import_zod50.z.string().optional(), id: import_zod50.z.string().optional() }).optional()
19162
19467
  });
19163
19468
  }
19164
19469
  });
@@ -19226,14 +19531,14 @@ function createRealAnthropicUsageRefresher(params) {
19226
19531
  },
19227
19532
  now: () => Date.now(),
19228
19533
  log: params.log,
19229
- concurrency: (0, import_node_os12.availableParallelism)()
19534
+ concurrency: (0, import_node_os13.availableParallelism)()
19230
19535
  });
19231
19536
  }
19232
- var import_node_os12, PROBE_LAUNCH_FLAGS;
19537
+ var import_node_os13, PROBE_LAUNCH_FLAGS;
19233
19538
  var init_realAnthropicUsageProbe = __esm({
19234
19539
  "src/usage/realAnthropicUsageProbe.ts"() {
19235
19540
  "use strict";
19236
- import_node_os12 = require("node:os");
19541
+ import_node_os13 = require("node:os");
19237
19542
  init_identityStore();
19238
19543
  init_anthropicUsageRefresh();
19239
19544
  init_identityClaude();
@@ -19900,15 +20205,13 @@ init_rcWrites();
19900
20205
  init_rcSchemas();
19901
20206
 
19902
20207
  // src/frontdoor/rcSlashCommandSchemas.ts
19903
- var import_zod24 = require("zod");
20208
+ var import_zod25 = require("zod");
19904
20209
 
19905
20210
  // src/frontdoor/rcSessionCommands.ts
19906
20211
  var import_promises = require("node:timers/promises");
19907
20212
  init_rcControl();
19908
-
19909
- // src/supervise/sessionControl.ts
19910
- var RESULT_POLL_MS = 250;
19911
- var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
20213
+ init_sessionControl();
20214
+ init_verifiedVersions();
19912
20215
 
19913
20216
  // src/frontdoor/rcSelfHostCommands.ts
19914
20217
  init_connectEffects();
@@ -20028,9 +20331,7 @@ function recognise(command, event, name, args) {
20028
20331
  }
20029
20332
  return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
20030
20333
  }
20031
- async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
20032
- const { name, args } = commandLine(command);
20033
- const text = args === "" ? `/${name}` : `/${name} ${args}`;
20334
+ async function writeAsPersonAndAwait(deps, sessionId, text, recogniseEvent, waitMs, signal) {
20034
20335
  const early = [];
20035
20336
  let after;
20036
20337
  let settle;
@@ -20043,10 +20344,10 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
20043
20344
  return;
20044
20345
  }
20045
20346
  if (isPeerDelivery(event, text)) {
20046
- 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` });
20347
+ settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message, so it did not read the write as a person's` });
20047
20348
  return;
20048
20349
  }
20049
- const outcome = recognise(command, event, name, args);
20350
+ const outcome = recogniseEvent(event);
20050
20351
  if (outcome !== void 0) {
20051
20352
  settle?.(outcome);
20052
20353
  }
@@ -20083,6 +20384,41 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
20083
20384
  detach();
20084
20385
  }
20085
20386
  }
20387
+ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
20388
+ const { name, args } = commandLine(command);
20389
+ const text = args === "" ? `/${name}` : `/${name} ${args}`;
20390
+ return await writeAsPersonAndAwait(deps, sessionId, text, (event) => recognise(command, event, name, args), waitMs, signal);
20391
+ }
20392
+ function userTextOf(message) {
20393
+ if (typeof message.content === "string") {
20394
+ return message.content;
20395
+ }
20396
+ if (!Array.isArray(message.content)) {
20397
+ return void 0;
20398
+ }
20399
+ const blocks = message.content;
20400
+ return blocks.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
20401
+ }
20402
+ function rcPersonTurnOf(event, text) {
20403
+ const payload = event.envelope.payload;
20404
+ if (!isRecord8(payload) || payload.type !== "user" || typeof payload.uuid !== "string" || !isRecord8(payload.origin) || payload.origin.kind !== "human" || !isRecord8(payload.message)) {
20405
+ return void 0;
20406
+ }
20407
+ return userTextOf(payload.message) === text ? payload.uuid : void 0;
20408
+ }
20409
+ async function runSelfHostedTurn(deps, sessionId, text, waitMs, signal) {
20410
+ return await writeAsPersonAndAwait(
20411
+ deps,
20412
+ sessionId,
20413
+ text,
20414
+ (event) => {
20415
+ const uuid = rcPersonTurnOf(event, text);
20416
+ return uuid === void 0 ? void 0 : { ok: true, report: { uuid } };
20417
+ },
20418
+ waitMs,
20419
+ signal
20420
+ );
20421
+ }
20086
20422
  function createRcClaudeCodeVersions(fanout) {
20087
20423
  const versions = /* @__PURE__ */ new Map();
20088
20424
  fanout.subscribe(void 0, (event) => {
@@ -20104,18 +20440,21 @@ function createRcClaudeCodeVersions(fanout) {
20104
20440
  }
20105
20441
 
20106
20442
  // src/frontdoor/rcSessionCommands.ts
20107
- var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
20108
20443
  var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
20109
20444
  var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
20110
20445
  var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
20111
20446
  var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
20447
+ var RC_TURN_TEXT_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
20112
20448
  var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
20113
20449
  function unverifiedVersionMessage(sessionId, version, source) {
20114
20450
  const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
20115
- 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`;
20451
+ return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal, compaction and turn control is verified only on Claude Code ${verified}` : `session ${sessionId} runs Claude Code ${version}, and goal, compaction and turn control is verified only on Claude Code ${verified}: the door will not act on a version whose behaviour it has not verified`;
20452
+ }
20453
+ function noPluginReason(sessionId) {
20454
+ return `no agent-shim launch's in-process control plugin records session ${sessionId}: it was started outside the launcher (with claude's own command, or agent-shim run --native), with --bare, on a Claude Code version the plugin is not verified on, or its plugin has not yet recorded its transcript, which it does from the session's first hook event`;
20116
20455
  }
20117
20456
  function unsupportedMessage(sessionId) {
20118
- 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.`;
20457
+ return `${noPluginReason(sessionId)}, 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(", ")} takes a message as a person's (running it when it is 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 another session's, and the door does not claim to be a person's app on a service it does not run. Start the session through agent-shim run on Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} without --bare, or run it against the door's self-hosted surface.`;
20119
20458
  }
20120
20459
  function createRcSessionCommands(deps) {
20121
20460
  const queues = /* @__PURE__ */ new Map();
@@ -20132,57 +20471,78 @@ function createRcSessionCommands(deps) {
20132
20471
  }
20133
20472
  }
20134
20473
  };
20474
+ const pluginRoute = async (sessionId, route, lookup2) => {
20475
+ const target = await lookup2(sessionId);
20476
+ if (target === void 0) {
20477
+ return void 0;
20478
+ }
20479
+ if ("refused" in target) {
20480
+ return { kind: "refused", message: target.refused };
20481
+ }
20482
+ if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
20483
+ return { kind: "refused", message: unverifiedVersionMessage(sessionId, target.version, route === "supervised" ? "its supervisor's control plugin has not loaded" : "its launch's control plugin has not loaded") };
20484
+ }
20485
+ return { kind: route, target };
20486
+ };
20487
+ const resolveRoute = async (sessionId) => {
20488
+ const supervised = await pluginRoute(sessionId, "supervised", deps.supervisedOf);
20489
+ if (supervised !== void 0) {
20490
+ return supervised;
20491
+ }
20492
+ const launched = deps.launchedOf === void 0 ? void 0 : await pluginRoute(sessionId, "launched", deps.launchedOf);
20493
+ if (launched !== void 0) {
20494
+ return launched;
20495
+ }
20496
+ if (!deps.isObserved(sessionId)) {
20497
+ return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}` };
20498
+ }
20499
+ if (deps.selfHost === void 0) {
20500
+ return { kind: "refused", message: unsupportedMessage(sessionId) };
20501
+ }
20502
+ const unavailable = deps.selfHost.unavailable();
20503
+ if (unavailable !== void 0) {
20504
+ return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}` };
20505
+ }
20506
+ const version = deps.selfHost.versionOf(sessionId);
20507
+ if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
20508
+ return { kind: "refused", message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
20509
+ }
20510
+ return { kind: "self-hosted", selfHost: deps.selfHost };
20511
+ };
20135
20512
  const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
20136
20513
  const { signal } = options;
20137
20514
  if (signal?.aborted === true) {
20138
20515
  return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
20139
20516
  }
20140
- const target = await deps.supervisedOf(sessionId);
20141
- if (target !== void 0 && "refused" in target) {
20142
- return { ok: false, message: target.refused };
20517
+ const resolved = await resolveRoute(sessionId);
20518
+ if (resolved.kind === "refused") {
20519
+ return { ok: false, message: resolved.message };
20143
20520
  }
20144
- if (target !== void 0) {
20145
- if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
20146
- return { ok: false, message: unverifiedVersionMessage(sessionId, target.version, "its supervisor's control plugin has not loaded") };
20147
- }
20148
- const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
20149
- const timeout = AbortSignal.timeout(waitMs);
20150
- const bounded3 = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
20521
+ if (resolved.kind !== "self-hosted") {
20522
+ const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
20523
+ const timeout2 = AbortSignal.timeout(waitMs2);
20524
+ const bounded3 = signal === void 0 ? timeout2 : AbortSignal.any([signal, timeout2]);
20151
20525
  try {
20152
- return await actions.supervised(target, bounded3, waitMs);
20526
+ return await actions.plugin(resolved.target, resolved.kind, bounded3, waitMs2);
20153
20527
  } catch (error) {
20154
- if (timeout.aborted) {
20155
- 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` };
20528
+ if (timeout2.aborted) {
20529
+ return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(waitMs2)} 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` };
20156
20530
  }
20157
20531
  return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
20158
20532
  }
20159
20533
  }
20160
- if (!deps.isObserved(sessionId)) {
20161
- return { ok: false, message: `the front door has not observed Remote Control session ${sessionId}` };
20534
+ const waitMs = options.waitMs ?? resolved.selfHost.defaultWaitMs;
20535
+ const timeout = AbortSignal.timeout(waitMs);
20536
+ const result = await actions.selfHosted(resolved.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
20537
+ if (!result.ok && timeout.aborted) {
20538
+ 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` };
20162
20539
  }
20163
- if (deps.selfHost !== void 0) {
20164
- const unavailable = deps.selfHost.unavailable();
20165
- if (unavailable !== void 0) {
20166
- 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}` };
20167
- }
20168
- const version = deps.selfHost.versionOf(sessionId);
20169
- if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
20170
- 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") };
20171
- }
20172
- const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
20173
- const timeout = AbortSignal.timeout(waitMs);
20174
- const result = await actions.selfHosted(deps.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
20175
- if (!result.ok && timeout.aborted) {
20176
- 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` };
20177
- }
20178
- return result;
20179
- }
20180
- return { ok: false, message: unsupportedMessage(sessionId) };
20540
+ return result;
20181
20541
  });
20182
20542
  const transcriptGoal = async (sessionId, target) => {
20183
20543
  const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
20184
20544
  if (goal === void 0) {
20185
- 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` };
20545
+ return { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where its goal is read from; retry once it has finished a turn` };
20186
20546
  }
20187
20547
  return { ok: true, report: goal };
20188
20548
  };
@@ -20196,12 +20556,64 @@ function createRcSessionCommands(deps) {
20196
20556
  }
20197
20557
  };
20198
20558
  const waitOf = (options) => options.waitMs;
20559
+ const transcriptPluginTurns = async (sessionId, target) => {
20560
+ const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
20561
+ return turns === void 0 ? { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where a turn is confirmed from; retry once it has finished a turn` } : { ok: true, report: turns };
20562
+ };
20199
20563
  return {
20564
+ /** Which route the verbs would take for the session now, or the refusal naming why none would; reads only, outside the session's queue, so a verb waiting on the session never delays it. */
20565
+ routeOf: async (sessionId) => {
20566
+ const resolved = await resolveRoute(sessionId);
20567
+ return resolved.kind === "refused" ? { route: null, refused: resolved.message } : { route: resolved.kind };
20568
+ },
20569
+ /**
20570
+ * Puts `text` into the session as a person's typed turn, and resolves once the session recorded it as a user entry from the person, never as a peer's message: on the supervised route a transcript row the control plugin submitted as the person's words (`origin: { kind: "plugin", asUser: true }`), on the self-hosted route the worker's mirrored entry with a person's origin (`{ kind: "human" }`). The text reaches the session's model as its user's words (`docs/rc-slash-commands.md`, the trust boundary). Refused unsent: text that is empty, starts with `/` (a slash command, which the goal and compaction verbs run), or is longer than one request carries. Resolves when the turn entered the session, not when the model has answered it.
20571
+ */
20572
+ turn: async (sessionId, text, options = {}) => {
20573
+ if (text.trim() === "") {
20574
+ return { ok: false, message: "a turn needs non-empty text" };
20575
+ }
20576
+ if (text.trimStart().startsWith("/")) {
20577
+ return { ok: false, message: "a turn's text starts with /, which the session would read as a slash command rather than a message, and the turn could not be confirmed as one; use the goal or compaction verbs for those commands, or start the text with something else" };
20578
+ }
20579
+ if (text.length > RC_TURN_TEXT_MAX_CHARS) {
20580
+ return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text.length)}` };
20581
+ }
20582
+ return await onRoute(sessionId, options, {
20583
+ plugin: async (target, route, signal, waitMs) => {
20584
+ const before = await transcriptPluginTurns(sessionId, target);
20585
+ if (!before.ok) {
20586
+ return before;
20587
+ }
20588
+ const submitted = await target.submitTurn(text, signal, waitMs);
20589
+ if (!submitted.asUser) {
20590
+ return { ok: false, message: `session ${sessionId}'s control plugin submitted the turn, but Claude Code did not stamp it as the person's words, so the model may read it framed as the plugin's` };
20591
+ }
20592
+ for (; ; ) {
20593
+ const after = await transcriptPluginTurns(sessionId, target);
20594
+ if (!after.ok) {
20595
+ return after;
20596
+ }
20597
+ if (after.report.count > before.report.count && after.report.last !== void 0) {
20598
+ return after.report.last.text === text ? { ok: true, report: { route, uuid: after.report.last.uuid } } : { ok: false, message: `session ${sessionId}'s transcript records a turn the control plugin submitted, but its text is not the text sent` };
20599
+ }
20600
+ if (signal.aborted) {
20601
+ return { ok: false, message: `session ${sessionId} accepted the turn but its transcript did not record it within ${String(waitMs)} ms; it is queued behind the running turn, so read the transcript before sending it again` };
20602
+ }
20603
+ await (0, import_promises.setTimeout)(RESULT_POLL_MS);
20604
+ }
20605
+ },
20606
+ selfHosted: async (selfHost, signal) => {
20607
+ const delivered = await runSelfHostedTurn(selfHost, sessionId, text, waitOf(options), signal);
20608
+ return delivered.ok ? { ok: true, report: { route: "self-hosted", uuid: delivered.report.uuid } } : delivered;
20609
+ }
20610
+ });
20611
+ },
20200
20612
  /** 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. */
20201
20613
  goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
20202
- supervised: async (target) => {
20614
+ plugin: async (target, route) => {
20203
20615
  const read = await transcriptGoal(sessionId, target);
20204
- return await Promise.resolve(read.ok ? { ok: true, report: { route: "supervised", goal: read.report } } : read);
20616
+ return read.ok ? { ok: true, report: { route, goal: read.report } } : read;
20205
20617
  },
20206
20618
  selfHosted: async (selfHost, signal) => {
20207
20619
  const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
@@ -20226,7 +20638,7 @@ function createRcSessionCommands(deps) {
20226
20638
  return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
20227
20639
  }
20228
20640
  return await onRoute(sessionId, options, {
20229
- supervised: async (target, signal, waitMs) => {
20641
+ plugin: async (target, route, signal, waitMs) => {
20230
20642
  const before = await transcriptGoal(sessionId, target);
20231
20643
  if (!before.ok) {
20232
20644
  return before;
@@ -20236,7 +20648,7 @@ function createRcSessionCommands(deps) {
20236
20648
  if (!after.ok) {
20237
20649
  return after;
20238
20650
  }
20239
- 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` };
20651
+ return after.report?.condition === trimmed ? { ok: true, report: { route, condition: trimmed, superseded: before.report?.condition ?? null } } : { ok: false, message: `session ${sessionId} ran /goal but its transcript does not record the goal as set` };
20240
20652
  },
20241
20653
  selfHosted: async (selfHost, signal) => {
20242
20654
  const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
@@ -20250,20 +20662,20 @@ function createRcSessionCommands(deps) {
20250
20662
  },
20251
20663
  /** 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). */
20252
20664
  goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
20253
- supervised: async (target, signal, waitMs) => {
20665
+ plugin: async (target, route, signal, waitMs) => {
20254
20666
  const before = await transcriptGoal(sessionId, target);
20255
20667
  if (!before.ok) {
20256
20668
  return before;
20257
20669
  }
20258
20670
  if (before.report === null) {
20259
- return { ok: true, report: { route: "supervised", cleared: null } };
20671
+ return { ok: true, report: { route, cleared: null } };
20260
20672
  }
20261
20673
  await target.runGoal("clear", signal, waitMs);
20262
20674
  const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
20263
20675
  if (!after.ok) {
20264
20676
  return after;
20265
20677
  }
20266
- 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}"` };
20678
+ return after.report === null ? { ok: true, report: { route, cleared: before.report.condition } } : { ok: false, message: `session ${sessionId} ran /goal clear but its transcript still records the goal "${after.report.condition}"` };
20267
20679
  },
20268
20680
  selfHosted: async (selfHost, signal) => {
20269
20681
  const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
@@ -20275,12 +20687,12 @@ function createRcSessionCommands(deps) {
20275
20687
  const instructions = options.instructions?.trim();
20276
20688
  const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
20277
20689
  return await onRoute(sessionId, options, {
20278
- supervised: async (target, signal, waitMs) => {
20690
+ plugin: async (target, route, signal, waitMs) => {
20279
20691
  const result = await target.compact(signal, given, waitMs);
20280
20692
  if (result.kind === "unchanged") {
20281
20693
  return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
20282
20694
  }
20283
- return { ok: true, report: { route: "supervised", trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
20695
+ return { ok: true, report: { route, trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
20284
20696
  },
20285
20697
  selfHosted: async (selfHost, signal) => {
20286
20698
  const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
@@ -20292,47 +20704,56 @@ function createRcSessionCommands(deps) {
20292
20704
  }
20293
20705
 
20294
20706
  // src/frontdoor/rcSlashCommandSchemas.ts
20295
- var WaitMsSchema = import_zod24.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
20296
- var RcGoalSessionInputSchema = import_zod24.z.strictObject({
20297
- session: import_zod24.z.string().min(1),
20707
+ var WaitMsSchema = import_zod25.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
20708
+ var RcGoalSessionInputSchema = import_zod25.z.strictObject({
20709
+ session: import_zod25.z.string().min(1),
20710
+ waitMs: WaitMsSchema
20711
+ });
20712
+ var RcGoalSetInputSchema = import_zod25.z.strictObject({
20713
+ session: import_zod25.z.string().min(1),
20714
+ condition: import_zod25.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
20298
20715
  waitMs: WaitMsSchema
20299
20716
  });
20300
- var RcGoalSetInputSchema = import_zod24.z.strictObject({
20301
- session: import_zod24.z.string().min(1),
20302
- condition: import_zod24.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
20717
+ var RcCompactInputSchema = import_zod25.z.strictObject({
20718
+ session: import_zod25.z.string().min(1),
20303
20719
  waitMs: WaitMsSchema
20304
20720
  });
20305
- var RcCompactInputSchema = import_zod24.z.strictObject({
20306
- session: import_zod24.z.string().min(1),
20721
+ var RcCompactWithInstructionsInputSchema = import_zod25.z.strictObject({
20722
+ session: import_zod25.z.string().min(1),
20723
+ instructions: import_zod25.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
20307
20724
  waitMs: WaitMsSchema
20308
20725
  });
20309
- var RcCompactWithInstructionsInputSchema = import_zod24.z.strictObject({
20310
- session: import_zod24.z.string().min(1),
20311
- instructions: import_zod24.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
20726
+ var RcTurnInputSchema = import_zod25.z.strictObject({
20727
+ session: import_zod25.z.string().min(1),
20728
+ text: import_zod25.z.string().min(1).max(RC_TURN_TEXT_MAX_CHARS),
20312
20729
  waitMs: WaitMsSchema
20313
20730
  });
20314
20731
  var commandAnswerShape = {
20315
- session: import_zod24.z.string(),
20316
- route: import_zod24.z.enum(["supervised", "self-hosted"])
20732
+ session: import_zod25.z.string(),
20733
+ route: import_zod25.z.enum(["supervised", "launched", "self-hosted"])
20317
20734
  };
20318
- var RcGoalGetOutputSchema = import_zod24.z.strictObject({
20735
+ var RcGoalGetOutputSchema = import_zod25.z.strictObject({
20319
20736
  ...commandAnswerShape,
20320
- goal: import_zod24.z.strictObject({ condition: import_zod24.z.string(), iterations: import_zod24.z.int().nonnegative(), lastCheck: import_zod24.z.string().optional() }).nullable()
20737
+ goal: import_zod25.z.strictObject({ condition: import_zod25.z.string(), iterations: import_zod25.z.int().nonnegative(), lastCheck: import_zod25.z.string().optional() }).nullable()
20321
20738
  });
20322
- var RcGoalSetOutputSchema = import_zod24.z.strictObject({
20739
+ var RcGoalSetOutputSchema = import_zod25.z.strictObject({
20323
20740
  ...commandAnswerShape,
20324
- condition: import_zod24.z.string(),
20325
- superseded: import_zod24.z.string().nullable()
20741
+ condition: import_zod25.z.string(),
20742
+ superseded: import_zod25.z.string().nullable()
20326
20743
  });
20327
- var RcGoalClearOutputSchema = import_zod24.z.strictObject({
20744
+ var RcGoalClearOutputSchema = import_zod25.z.strictObject({
20328
20745
  ...commandAnswerShape,
20329
- cleared: import_zod24.z.string().nullable()
20746
+ cleared: import_zod25.z.string().nullable()
20330
20747
  });
20331
- var RcCompactOutputSchema = import_zod24.z.strictObject({
20748
+ var RcTurnOutputSchema = import_zod25.z.strictObject({
20332
20749
  ...commandAnswerShape,
20333
- trigger: import_zod24.z.string(),
20334
- preTokens: import_zod24.z.number().optional(),
20335
- postTokens: import_zod24.z.number().optional()
20750
+ uuid: import_zod25.z.string()
20751
+ });
20752
+ var RcCompactOutputSchema = import_zod25.z.strictObject({
20753
+ ...commandAnswerShape,
20754
+ trigger: import_zod25.z.string(),
20755
+ preTokens: import_zod25.z.number().optional(),
20756
+ postTokens: import_zod25.z.number().optional()
20336
20757
  });
20337
20758
 
20338
20759
  // src/frontdoor/rcApi.ts
@@ -20384,12 +20805,12 @@ function createRcApiRouter(deps) {
20384
20805
  return {
20385
20806
  rc: {
20386
20807
  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() })),
20387
- status: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(({ input }) => {
20808
+ status: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(async ({ input }) => {
20388
20809
  const statuses = deps.statusOf(input.session);
20389
20810
  if (input.session !== void 0 && !statuses.some((entry) => entry.id === input.session)) {
20390
20811
  throw new import_client.ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
20391
20812
  }
20392
- return { statuses };
20813
+ return { statuses: await Promise.all(statuses.map(async (status) => ({ ...status, route: await deps.routeOf(status.id) }))) };
20393
20814
  }),
20394
20815
  pending: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/pending", summary: "Read the control requests awaiting an answer", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcPendingOutputSchema).handler(({ input }) => {
20395
20816
  const pending = deps.pendingOf(input.session);
@@ -20424,6 +20845,7 @@ function createRcApiRouter(deps) {
20424
20845
  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)))),
20425
20846
  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)))),
20426
20847
  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 }))),
20848
+ turn: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/turn", summary: "Put a person's typed turn into a session, which its model reads as its user's words", tags: [RC_DIRECTIVE_TAG] })).input(RcTurnInputSchema).output(RcTurnOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.turn(input.session, input.text, optionsOf(input.waitMs, signal)))),
20427
20849
  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 }) {
20428
20850
  const queue = [];
20429
20851
  let wake;
@@ -20505,7 +20927,7 @@ function createRcApiNodeHandler(deps) {
20505
20927
  return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
20506
20928
  }
20507
20929
  var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
20508
- var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
20930
+ var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions", "rc/turn"];
20509
20931
  function headersTimeoutOf(url, body) {
20510
20932
  if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
20511
20933
  return DEFAULT_HEADERS_TIMEOUT_MS;
@@ -20553,48 +20975,48 @@ init_cliError();
20553
20975
  init_package();
20554
20976
 
20555
20977
  // src/codex/appServerSchemas.ts
20556
- var import_zod25 = require("zod");
20978
+ var import_zod26 = require("zod");
20557
20979
  var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
20558
- var RateLimitWindowSchema = import_zod25.z.object({
20559
- usedPercent: import_zod25.z.number(),
20560
- resetsAt: import_zod25.z.number().nullish(),
20561
- windowDurationMins: import_zod25.z.number().nullish()
20562
- });
20563
- var RateLimitSnapshotSchema = import_zod25.z.object({
20564
- limitId: import_zod25.z.string().nullish(),
20565
- limitName: import_zod25.z.string().nullish(),
20566
- planType: import_zod25.z.string().nullish(),
20980
+ var RateLimitWindowSchema = import_zod26.z.object({
20981
+ usedPercent: import_zod26.z.number(),
20982
+ resetsAt: import_zod26.z.number().nullish(),
20983
+ windowDurationMins: import_zod26.z.number().nullish()
20984
+ });
20985
+ var RateLimitSnapshotSchema = import_zod26.z.object({
20986
+ limitId: import_zod26.z.string().nullish(),
20987
+ limitName: import_zod26.z.string().nullish(),
20988
+ planType: import_zod26.z.string().nullish(),
20567
20989
  primary: RateLimitWindowSchema.nullish(),
20568
20990
  secondary: RateLimitWindowSchema.nullish(),
20569
- rateLimitReachedType: import_zod25.z.string().nullish(),
20570
- spendControlReached: import_zod25.z.boolean().nullish()
20571
- });
20572
- var RateLimitResetCreditSchema = import_zod25.z.object({
20573
- id: import_zod25.z.string(),
20574
- grantedAt: import_zod25.z.number(),
20575
- expiresAt: import_zod25.z.number().nullish(),
20576
- resetType: import_zod25.z.string(),
20577
- status: import_zod25.z.string(),
20578
- title: import_zod25.z.string().nullish(),
20579
- description: import_zod25.z.string().nullish()
20580
- });
20581
- var CodexAccountSchema = import_zod25.z.discriminatedUnion("type", [
20582
- import_zod25.z.object({ type: import_zod25.z.literal("apiKey") }),
20583
- import_zod25.z.object({ type: import_zod25.z.literal("chatgpt"), email: import_zod25.z.string().nullable(), planType: import_zod25.z.string() }),
20584
- import_zod25.z.object({ type: import_zod25.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod25.z.boolean().default(false) })
20991
+ rateLimitReachedType: import_zod26.z.string().nullish(),
20992
+ spendControlReached: import_zod26.z.boolean().nullish()
20993
+ });
20994
+ var RateLimitResetCreditSchema = import_zod26.z.object({
20995
+ id: import_zod26.z.string(),
20996
+ grantedAt: import_zod26.z.number(),
20997
+ expiresAt: import_zod26.z.number().nullish(),
20998
+ resetType: import_zod26.z.string(),
20999
+ status: import_zod26.z.string(),
21000
+ title: import_zod26.z.string().nullish(),
21001
+ description: import_zod26.z.string().nullish()
21002
+ });
21003
+ var CodexAccountSchema = import_zod26.z.discriminatedUnion("type", [
21004
+ import_zod26.z.object({ type: import_zod26.z.literal("apiKey") }),
21005
+ import_zod26.z.object({ type: import_zod26.z.literal("chatgpt"), email: import_zod26.z.string().nullable(), planType: import_zod26.z.string() }),
21006
+ import_zod26.z.object({ type: import_zod26.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod26.z.boolean().default(false) })
20585
21007
  ]);
20586
- var CodexAccountReadSchema = import_zod25.z.object({
21008
+ var CodexAccountReadSchema = import_zod26.z.object({
20587
21009
  account: CodexAccountSchema.nullable(),
20588
- requiresOpenaiAuth: import_zod25.z.boolean()
21010
+ requiresOpenaiAuth: import_zod26.z.boolean()
20589
21011
  });
20590
- var CodexRateLimitsReadSchema = import_zod25.z.object({
21012
+ var CodexRateLimitsReadSchema = import_zod26.z.object({
20591
21013
  rateLimits: RateLimitSnapshotSchema,
20592
- rateLimitsByLimitId: import_zod25.z.record(import_zod25.z.string(), RateLimitSnapshotSchema).nullish(),
20593
- rateLimitResetCredits: import_zod25.z.object({ availableCount: import_zod25.z.number(), credits: import_zod25.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
20594
- accountId: import_zod25.z.string().nullish(),
20595
- ordinaryUsageAllowed: import_zod25.z.boolean().nullish()
21014
+ rateLimitsByLimitId: import_zod26.z.record(import_zod26.z.string(), RateLimitSnapshotSchema).nullish(),
21015
+ rateLimitResetCredits: import_zod26.z.object({ availableCount: import_zod26.z.number(), credits: import_zod26.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
21016
+ accountId: import_zod26.z.string().nullish(),
21017
+ ordinaryUsageAllowed: import_zod26.z.boolean().nullish()
20596
21018
  });
20597
- var CodexInitializeResultSchema = import_zod25.z.object({ userAgent: import_zod25.z.string() });
21019
+ var CodexInitializeResultSchema = import_zod26.z.object({ userAgent: import_zod26.z.string() });
20598
21020
 
20599
21021
  // src/codex/appServer.ts
20600
21022
  var CodexAppServerUnavailableError = class extends CliError {
@@ -20793,7 +21215,7 @@ var import_client8 = require("@orpc/client");
20793
21215
  var import_openapi9 = require("@orpc/openapi");
20794
21216
 
20795
21217
  // src/checkReportSchema.ts
20796
- var import_zod27 = require("zod");
21218
+ var import_zod28 = require("zod");
20797
21219
  init_schema();
20798
21220
  init_claudeVersion();
20799
21221
  init_identity2();
@@ -20852,135 +21274,137 @@ var DIAGNOSTIC_CODES = [
20852
21274
  /** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
20853
21275
  "FARM_SWAP_RECOVERED",
20854
21276
  /** A superseded farm could not be discarded because it still held data the new farm has its own entry for, so it was left on disk for the user to look at. */
20855
- "FARM_PREVIOUS_RETAINED"
21277
+ "FARM_PREVIOUS_RETAINED",
21278
+ /** A shared `~/.claude` entry is a symlink that reaches nothing, so the farm does not link it and the identity keeps its own copy until the entry leads somewhere. */
21279
+ "SHARED_ENTRY_DANGLING"
20856
21280
  ];
20857
21281
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
20858
21282
 
20859
21283
  // src/usage/pickReportSchema.ts
20860
- var import_zod26 = require("zod");
21284
+ var import_zod27 = require("zod");
20861
21285
  init_plan2();
20862
- var PoolPickCandidateViewSchema = import_zod26.z.strictObject({
20863
- identity: import_zod26.z.string(),
21286
+ var PoolPickCandidateViewSchema = import_zod27.z.strictObject({
21287
+ identity: import_zod27.z.string(),
20864
21288
  /** 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. */
20865
- class: import_zod26.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
21289
+ class: import_zod27.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
20866
21290
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
20867
- score: import_zod26.z.number().optional(),
21291
+ score: import_zod27.z.number().optional(),
20868
21292
  /** 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`. */
20869
- scoreWindow: import_zod26.z.enum(["sevenDay", "fiveHour"]).optional(),
21293
+ scoreWindow: import_zod27.z.enum(["sevenDay", "fiveHour"]).optional(),
20870
21294
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
20871
- feasible: import_zod26.z.boolean(),
21295
+ feasible: import_zod27.z.boolean(),
20872
21296
  /** When an `ineligible` member can be used again, as an ISO instant. */
20873
- blockedUntil: import_zod26.z.iso.datetime().optional(),
21297
+ blockedUntil: import_zod27.z.iso.datetime().optional(),
20874
21298
  plan: PlanClassSchema,
20875
21299
  /** The provider the member was ranked on, when its launch spends one in place of its Claude account: its windows, refusals and plan are the provider's own. Absent when ranked on the Claude account. */
20876
- provider: import_zod26.z.string().optional(),
21300
+ provider: import_zod27.z.string().optional(),
20877
21301
  /** The facts behind the class and score, in the order they matter. */
20878
- reasons: import_zod26.z.array(import_zod26.z.string())
21302
+ reasons: import_zod27.z.array(import_zod27.z.string())
20879
21303
  });
20880
- var PoolPickReportSchema = import_zod26.z.strictObject({
20881
- pool: import_zod26.z.string(),
20882
- directory: import_zod26.z.string(),
21304
+ var PoolPickReportSchema = import_zod27.z.strictObject({
21305
+ pool: import_zod27.z.string(),
21306
+ directory: import_zod27.z.string(),
20883
21307
  /** The member a launch would run as, absent when every member is refused. */
20884
- pick: import_zod26.z.string().optional(),
20885
- candidates: import_zod26.z.array(PoolPickCandidateViewSchema),
21308
+ pick: import_zod27.z.string().optional(),
21309
+ candidates: import_zod27.z.array(PoolPickCandidateViewSchema),
20886
21310
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
20887
- missing: import_zod26.z.array(import_zod26.z.string()),
21311
+ missing: import_zod27.z.array(import_zod27.z.string()),
20888
21312
  /** When nothing can be picked, the soonest any member returns. */
20889
- earliestReturn: import_zod26.z.strictObject({ identity: import_zod26.z.string(), at: import_zod26.z.iso.datetime() }).optional(),
21313
+ earliestReturn: import_zod27.z.strictObject({ identity: import_zod27.z.string(), at: import_zod27.z.iso.datetime() }).optional(),
20890
21314
  /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
20891
- movedOff: import_zod26.z.strictObject({ identity: import_zod26.z.string(), reason: import_zod26.z.string() }).optional(),
21315
+ movedOff: import_zod27.z.strictObject({ identity: import_zod27.z.string(), reason: import_zod27.z.string() }).optional(),
20892
21316
  /** Why the last-pick record could not be read, when that is the case. */
20893
- stickyProblem: import_zod26.z.string().optional()
21317
+ stickyProblem: import_zod27.z.string().optional()
20894
21318
  });
20895
21319
 
20896
21320
  // src/checkReportSchema.ts
20897
21321
  var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
20898
- var CheckLayerViewSchema = import_zod27.z.strictObject({
20899
- id: import_zod27.z.int(),
20900
- kind: import_zod27.z.enum(LAYER_KINDS),
20901
- source: import_zod27.z.string()
20902
- });
20903
- var CheckEntryViewSchema = import_zod27.z.strictObject({
20904
- path: import_zod27.z.string(),
20905
- shared: import_zod27.z.boolean(),
20906
- via: import_zod27.z.enum(DECISION_VIAS),
21322
+ var CheckLayerViewSchema = import_zod28.z.strictObject({
21323
+ id: import_zod28.z.int(),
21324
+ kind: import_zod28.z.enum(LAYER_KINDS),
21325
+ source: import_zod28.z.string()
21326
+ });
21327
+ var CheckEntryViewSchema = import_zod28.z.strictObject({
21328
+ path: import_zod28.z.string(),
21329
+ shared: import_zod28.z.boolean(),
21330
+ via: import_zod28.z.enum(DECISION_VIAS),
20907
21331
  /** The entry's real category, or null when nothing classifies it. */
20908
- category: import_zod27.z.enum(CATEGORY_NAMES).nullable(),
20909
- rule: import_zod27.z.strictObject({ key: import_zod27.z.string(), layer: import_zod27.z.int() }).optional(),
21332
+ category: import_zod28.z.enum(CATEGORY_NAMES).nullable(),
21333
+ rule: import_zod28.z.strictObject({ key: import_zod28.z.string(), layer: import_zod28.z.int() }).optional(),
20910
21334
  /** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
20911
- eliminated: import_zod27.z.readonly(import_zod27.z.array(import_zod27.z.strictObject({ key: import_zod27.z.string(), failed: import_zod27.z.readonly(import_zod27.z.array(import_zod27.z.string())) }))).optional()
20912
- });
20913
- var CheckDiagnosticSchema = import_zod27.z.strictObject({
20914
- code: import_zod27.z.enum(DIAGNOSTIC_CODES),
20915
- severity: import_zod27.z.enum(DIAGNOSTIC_SEVERITIES),
20916
- message: import_zod27.z.string(),
20917
- subject: import_zod27.z.string().optional(),
20918
- layer: import_zod27.z.int().optional()
20919
- });
20920
- var CheckAmbientCredentialSchema = import_zod27.z.union([import_zod27.z.strictObject({ ok: import_zod27.z.literal(true) }), import_zod27.z.strictObject({ ok: import_zod27.z.literal(false), variable: import_zod27.z.string(), message: import_zod27.z.string() })]);
20921
- var CheckKeychainSchema = import_zod27.z.strictObject({
20922
- checked: import_zod27.z.literal(true),
20923
- found: import_zod27.z.boolean(),
20924
- serviceName: import_zod27.z.string().optional(),
20925
- note: import_zod27.z.string()
20926
- });
20927
- var CheckSettingsExposureSchema = import_zod27.z.strictObject({
20928
- file: import_zod27.z.string(),
20929
- envKeyNames: import_zod27.z.readonly(import_zod27.z.array(import_zod27.z.string())),
20930
- hookEventNames: import_zod27.z.readonly(import_zod27.z.array(import_zod27.z.string())),
20931
- hookCommandCount: import_zod27.z.int().nonnegative()
20932
- });
20933
- var CredentialSourceSummarySchema = import_zod27.z.union([
20934
- import_zod27.z.strictObject({ kind: import_zod27.z.literal("env"), variable: import_zod27.z.string() }),
20935
- import_zod27.z.strictObject({ kind: import_zod27.z.literal("file"), path: import_zod27.z.string() }),
20936
- import_zod27.z.strictObject({ kind: import_zod27.z.literal("command"), program: import_zod27.z.string() }),
20937
- import_zod27.z.strictObject({ kind: import_zod27.z.literal("op"), reference: import_zod27.z.string() }),
20938
- import_zod27.z.strictObject({ kind: import_zod27.z.literal("keychain"), service: import_zod27.z.string(), account: import_zod27.z.string().optional() }),
20939
- import_zod27.z.strictObject({ kind: import_zod27.z.literal("literal") })
21335
+ 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()
21336
+ });
21337
+ var CheckDiagnosticSchema = import_zod28.z.strictObject({
21338
+ code: import_zod28.z.enum(DIAGNOSTIC_CODES),
21339
+ severity: import_zod28.z.enum(DIAGNOSTIC_SEVERITIES),
21340
+ message: import_zod28.z.string(),
21341
+ subject: import_zod28.z.string().optional(),
21342
+ layer: import_zod28.z.int().optional()
21343
+ });
21344
+ 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() })]);
21345
+ var CheckKeychainSchema = import_zod28.z.strictObject({
21346
+ checked: import_zod28.z.literal(true),
21347
+ found: import_zod28.z.boolean(),
21348
+ serviceName: import_zod28.z.string().optional(),
21349
+ note: import_zod28.z.string()
21350
+ });
21351
+ var CheckSettingsExposureSchema = import_zod28.z.strictObject({
21352
+ file: import_zod28.z.string(),
21353
+ envKeyNames: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
21354
+ hookEventNames: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
21355
+ hookCommandCount: import_zod28.z.int().nonnegative()
21356
+ });
21357
+ var CredentialSourceSummarySchema = import_zod28.z.union([
21358
+ import_zod28.z.strictObject({ kind: import_zod28.z.literal("env"), variable: import_zod28.z.string() }),
21359
+ import_zod28.z.strictObject({ kind: import_zod28.z.literal("file"), path: import_zod28.z.string() }),
21360
+ import_zod28.z.strictObject({ kind: import_zod28.z.literal("command"), program: import_zod28.z.string() }),
21361
+ import_zod28.z.strictObject({ kind: import_zod28.z.literal("op"), reference: import_zod28.z.string() }),
21362
+ import_zod28.z.strictObject({ kind: import_zod28.z.literal("keychain"), service: import_zod28.z.string(), account: import_zod28.z.string().optional() }),
21363
+ import_zod28.z.strictObject({ kind: import_zod28.z.literal("literal") })
20940
21364
  ]);
20941
- var CredentialSummarySchema = import_zod27.z.strictObject({
20942
- target: import_zod27.z.enum(CREDENTIAL_TARGETS),
20943
- sources: import_zod27.z.readonly(import_zod27.z.array(CredentialSourceSummarySchema)),
21365
+ var CredentialSummarySchema = import_zod28.z.strictObject({
21366
+ target: import_zod28.z.enum(CREDENTIAL_TARGETS),
21367
+ sources: import_zod28.z.readonly(import_zod28.z.array(CredentialSourceSummarySchema)),
20944
21368
  cache: CredentialCacheSchema.optional()
20945
21369
  });
20946
- var CachedCredentialStateSchema = import_zod27.z.union([
20947
- import_zod27.z.strictObject({ store: import_zod27.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod27.z.literal("empty") }),
20948
- import_zod27.z.strictObject({ store: import_zod27.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod27.z.literal("unreadable"), reason: import_zod27.z.string() }),
20949
- import_zod27.z.strictObject({ store: import_zod27.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod27.z.enum(["fresh", "expired"]), ageMs: import_zod27.z.number(), expiresInMs: import_zod27.z.number().optional() })
21370
+ var CachedCredentialStateSchema = import_zod28.z.union([
21371
+ import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.literal("empty") }),
21372
+ import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.literal("unreadable"), reason: import_zod28.z.string() }),
21373
+ 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() })
20950
21374
  ]);
20951
- var CheckCredentialProviderSchema = import_zod27.z.union([
20952
- import_zod27.z.strictObject({ name: import_zod27.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
20953
- import_zod27.z.strictObject({ name: import_zod27.z.string(), problem: import_zod27.z.string() })
21375
+ var CheckCredentialProviderSchema = import_zod28.z.union([
21376
+ import_zod28.z.strictObject({ name: import_zod28.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
21377
+ import_zod28.z.strictObject({ name: import_zod28.z.string(), problem: import_zod28.z.string() })
20954
21378
  ]);
20955
- var CheckProviderReachabilitySchema = import_zod27.z.union([
20956
- import_zod27.z.strictObject({ name: import_zod27.z.string(), baseUrl: import_zod27.z.string(), ok: import_zod27.z.literal(true) }),
20957
- import_zod27.z.strictObject({ name: import_zod27.z.string(), baseUrl: import_zod27.z.string(), ok: import_zod27.z.literal(false), message: import_zod27.z.string() })
21379
+ var CheckProviderReachabilitySchema = import_zod28.z.union([
21380
+ import_zod28.z.strictObject({ name: import_zod28.z.string(), baseUrl: import_zod28.z.string(), ok: import_zod28.z.literal(true) }),
21381
+ import_zod28.z.strictObject({ name: import_zod28.z.string(), baseUrl: import_zod28.z.string(), ok: import_zod28.z.literal(false), message: import_zod28.z.string() })
20958
21382
  ]);
20959
- var CheckCredentialSchema = import_zod27.z.strictObject({
20960
- applies: import_zod27.z.enum(CHECK_CREDENTIAL_APPLIES),
21383
+ var CheckCredentialSchema = import_zod28.z.strictObject({
21384
+ applies: import_zod28.z.enum(CHECK_CREDENTIAL_APPLIES),
20961
21385
  provider: CheckCredentialProviderSchema.optional(),
20962
21386
  identity: CredentialSummarySchema.optional(),
20963
21387
  identityCached: CachedCredentialStateSchema.optional()
20964
21388
  });
20965
- var CheckClaudeVersionSchema = import_zod27.z.strictObject({
20966
- pinned: import_zod27.z.strictObject({ version: import_zod27.z.string(), source: import_zod27.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod27.z.boolean() }).optional(),
20967
- highestInstalled: import_zod27.z.string().optional(),
20968
- installed: import_zod27.z.readonly(import_zod27.z.array(import_zod27.z.string()))
21389
+ var CheckClaudeVersionSchema = import_zod28.z.strictObject({
21390
+ pinned: import_zod28.z.strictObject({ version: import_zod28.z.string(), source: import_zod28.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod28.z.boolean() }).optional(),
21391
+ highestInstalled: import_zod28.z.string().optional(),
21392
+ installed: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string()))
20969
21393
  });
20970
- var CheckReportJsonSchema = import_zod27.z.strictObject({
20971
- identity: import_zod27.z.strictObject({ name: import_zod27.z.string().nullable(), source: import_zod27.z.enum(IDENTITY_DECISION_SOURCES) }),
21394
+ var CheckReportJsonSchema = import_zod28.z.strictObject({
21395
+ identity: import_zod28.z.strictObject({ name: import_zod28.z.string().nullable(), source: import_zod28.z.enum(IDENTITY_DECISION_SOURCES) }),
20972
21396
  /** The pool ranking, when the launch named a pool instead of an identity. */
20973
21397
  pool: PoolPickReportSchema.optional(),
20974
- configProfile: import_zod27.z.strictObject({ name: import_zod27.z.string().nullable(), source: import_zod27.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
20975
- layers: import_zod27.z.readonly(import_zod27.z.array(CheckLayerViewSchema)),
20976
- entries: import_zod27.z.readonly(import_zod27.z.array(CheckEntryViewSchema)),
20977
- projectEncodingAmbiguities: import_zod27.z.readonly(
20978
- import_zod27.z.array(import_zod27.z.strictObject({ fragment: import_zod27.z.string(), encoded: import_zod27.z.string(), reason: import_zod27.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod27.z.string() }))
21398
+ configProfile: import_zod28.z.strictObject({ name: import_zod28.z.string().nullable(), source: import_zod28.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
21399
+ layers: import_zod28.z.readonly(import_zod28.z.array(CheckLayerViewSchema)),
21400
+ entries: import_zod28.z.readonly(import_zod28.z.array(CheckEntryViewSchema)),
21401
+ projectEncodingAmbiguities: import_zod28.z.readonly(
21402
+ 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() }))
20979
21403
  ),
20980
- diagnostics: import_zod27.z.readonly(import_zod27.z.array(CheckDiagnosticSchema)),
21404
+ diagnostics: import_zod28.z.readonly(import_zod28.z.array(CheckDiagnosticSchema)),
20981
21405
  ambientCredential: CheckAmbientCredentialSchema,
20982
21406
  keychain: CheckKeychainSchema.optional(),
20983
- settingsExposure: import_zod27.z.readonly(import_zod27.z.array(CheckSettingsExposureSchema)),
21407
+ settingsExposure: import_zod28.z.readonly(import_zod28.z.array(CheckSettingsExposureSchema)),
20984
21408
  credential: CheckCredentialSchema,
20985
21409
  claudeVersion: CheckClaudeVersionSchema.optional(),
20986
21410
  providerReachability: CheckProviderReachabilitySchema.optional()
@@ -20992,28 +21416,28 @@ init_preflight();
20992
21416
  init_resets();
20993
21417
 
20994
21418
  // src/usage/resetsSchema.ts
20995
- var import_zod28 = require("zod");
20996
- var ResetRowSchema = import_zod28.z.strictObject({
20997
- identity: import_zod28.z.string(),
20998
- provider: import_zod28.z.string(),
21419
+ var import_zod29 = require("zod");
21420
+ var ResetRowSchema = import_zod29.z.strictObject({
21421
+ identity: import_zod29.z.string(),
21422
+ provider: import_zod29.z.string(),
20999
21423
  /** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
21000
- window: import_zod28.z.string(),
21424
+ window: import_zod29.z.string(),
21001
21425
  /** When the state the window comes from was observed, as an ISO instant. */
21002
- observedAt: import_zod28.z.iso.datetime(),
21426
+ observedAt: import_zod29.z.iso.datetime(),
21003
21427
  /** When the window resets, as an ISO instant; absent when the upstream reported none. */
21004
- resetsAt: import_zod28.z.iso.datetime().optional(),
21428
+ resetsAt: import_zod29.z.iso.datetime().optional(),
21005
21429
  /** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
21006
- reset: import_zod28.z.boolean(),
21430
+ reset: import_zod29.z.boolean(),
21007
21431
  /** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
21008
- utilization: import_zod28.z.number().optional(),
21432
+ utilization: import_zod29.z.number().optional(),
21009
21433
  /** The window's own status, for a window that has not reset yet. */
21010
- status: import_zod28.z.string().optional()
21434
+ status: import_zod29.z.string().optional()
21011
21435
  });
21012
- var ResetScheduleSchema = import_zod28.z.strictObject({ resets: import_zod28.z.readonly(import_zod28.z.array(ResetRowSchema)) });
21436
+ var ResetScheduleSchema = import_zod29.z.strictObject({ resets: import_zod29.z.readonly(import_zod29.z.array(ResetRowSchema)) });
21013
21437
 
21014
21438
  // src/frontdoor/controlSchemas.ts
21015
- var import_node_path44 = __toESM(require("node:path"), 1);
21016
- var import_zod38 = require("zod");
21439
+ var import_node_path45 = __toESM(require("node:path"), 1);
21440
+ var import_zod39 = require("zod");
21017
21441
 
21018
21442
  // src/codex/doctor.ts
21019
21443
  function codexIdentityFindings(entry, identity) {
@@ -21032,14 +21456,14 @@ init_identityStore();
21032
21456
  init_identityRecords();
21033
21457
 
21034
21458
  // src/doctorIdentityRecords.ts
21035
- var import_node_path34 = __toESM(require("node:path"), 1);
21459
+ var import_node_path35 = __toESM(require("node:path"), 1);
21036
21460
  init_identityRecords();
21037
21461
  function identityRecordFindings(records, displaced, nameRenames, strayNameRenameFiles) {
21038
21462
  return [
21039
21463
  ...strayNameRenameFiles.map((file) => ({
21040
21464
  severity: "warn",
21041
21465
  message: `${file} holds the record of a rename of an identity's name, but not under the file name that rename keeps it in, so nothing reads it or removes it. Remove it.`,
21042
- subject: import_node_path34.default.basename(file)
21466
+ subject: import_node_path35.default.basename(file)
21043
21467
  })),
21044
21468
  ...nameRenames.map(({ from, description }) => ({ severity: "fail", message: description, subject: from })),
21045
21469
  ...duplicateIdentityNames(records).map(({ name, ids }) => ({
@@ -21062,7 +21486,7 @@ var import_node_fs14 = __toESM(require("node:fs"), 1);
21062
21486
 
21063
21487
  // src/doctorPath.ts
21064
21488
  var import_node_fs10 = __toESM(require("node:fs"), 1);
21065
- var import_node_path35 = __toESM(require("node:path"), 1);
21489
+ var import_node_path36 = __toESM(require("node:path"), 1);
21066
21490
  init_blockingSpawn();
21067
21491
  init_realPorts();
21068
21492
  init_doorBounds();
@@ -21076,14 +21500,14 @@ function realpathOrSelf(target) {
21076
21500
  var MAX_FORWARDING_SCRIPT_BYTES = 8192;
21077
21501
  function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
21078
21502
  const executable = realpathOrSelf(target);
21079
- const trustedMise = import_node_path35.default.join(import_node_path35.default.dirname(trustedExecutable), "mise");
21080
- if (import_node_path35.default.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
21081
- const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", import_node_path35.default.basename(target)], { encoding: "utf8", env, timeout: BLOCKING_STEP_TIMEOUTS_MS.miseLookup });
21503
+ const trustedMise = import_node_path36.default.join(import_node_path36.default.dirname(trustedExecutable), "mise");
21504
+ if (import_node_path36.default.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
21505
+ const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", import_node_path36.default.basename(target)], { encoding: "utf8", env, timeout: BLOCKING_STEP_TIMEOUTS_MS.miseLookup });
21082
21506
  if (result.error !== void 0) return void 0;
21083
21507
  if (result.status === 0 && result.stdout.trim() !== "") return result.stdout.trim();
21084
21508
  if (!result.stderr.includes("not currently active")) return void 0;
21085
21509
  for (const dir of pathDirs) {
21086
- const candidate = findExecutableInDir(dir, import_node_path35.default.basename(target));
21510
+ const candidate = findExecutableInDir(dir, import_node_path36.default.basename(target));
21087
21511
  if (candidate !== void 0 && realpathOrSelf(candidate) !== executable) {
21088
21512
  try {
21089
21513
  const script = import_node_fs10.default.statSync(candidate).size <= MAX_FORWARDING_SCRIPT_BYTES ? realFsPort.readFileUtf8(candidate) : void 0;
@@ -21098,7 +21522,7 @@ function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
21098
21522
  }
21099
21523
 
21100
21524
  // src/doctorReport.ts
21101
- var import_node_path43 = __toESM(require("node:path"), 1);
21525
+ var import_node_path44 = __toESM(require("node:path"), 1);
21102
21526
  init_signIn();
21103
21527
  init_identityAccounts();
21104
21528
  init_read();
@@ -21163,11 +21587,11 @@ var CODEX_CATEGORIES = {
21163
21587
  };
21164
21588
 
21165
21589
  // src/codex/identity.ts
21166
- var import_node_path36 = __toESM(require("node:path"), 1);
21590
+ var import_node_path37 = __toESM(require("node:path"), 1);
21167
21591
  init_envBool();
21168
21592
  var CODEX_AMBIENT_CREDENTIALS = ["OPENAI_API_KEY", "CODEX_API_KEY", "CODEX_ACCESS_TOKEN", "OPENAI_IDENTITY_TOKEN_FILE", "OPENAI_FEDERATION_RULE_ID"];
21169
21593
  function canonicalCodexHome(env, home) {
21170
- return import_node_path36.default.resolve(env.AGENT_SHIM_CODEX_HOME === void 0 || env.AGENT_SHIM_CODEX_HOME === "" ? import_node_path36.default.join(home, ".codex") : env.AGENT_SHIM_CODEX_HOME);
21594
+ return import_node_path37.default.resolve(env.AGENT_SHIM_CODEX_HOME === void 0 || env.AGENT_SHIM_CODEX_HOME === "" ? import_node_path37.default.join(home, ".codex") : env.AGENT_SHIM_CODEX_HOME);
21171
21595
  }
21172
21596
  function codexCredentialGuard(env, allowAmbientCredential) {
21173
21597
  const variable = CODEX_AMBIENT_CREDENTIALS.find((key) => (env[key] ?? "") !== "");
@@ -21303,8 +21727,8 @@ init_realCredentialCache();
21303
21727
  init_providersStore();
21304
21728
  init_signIn();
21305
21729
  init_realPorts();
21306
- var import_node_path40 = __toESM(require("node:path"), 1);
21307
- var import_zod31 = require("zod");
21730
+ var import_node_path41 = __toESM(require("node:path"), 1);
21731
+ var import_zod32 = require("zod");
21308
21732
  init_envBool();
21309
21733
  init_load();
21310
21734
  init_schema();
@@ -21388,9 +21812,9 @@ function lookupKeychainService(run, farmRoot) {
21388
21812
  }
21389
21813
  return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
21390
21814
  }
21391
- var SettingsSecretsShapeSchema = import_zod31.z.looseObject({
21392
- env: import_zod31.z.record(import_zod31.z.string(), import_zod31.z.unknown()).optional(),
21393
- hooks: import_zod31.z.record(import_zod31.z.string(), import_zod31.z.array(import_zod31.z.unknown())).optional()
21815
+ var SettingsSecretsShapeSchema = import_zod32.z.looseObject({
21816
+ env: import_zod32.z.record(import_zod32.z.string(), import_zod32.z.unknown()).optional(),
21817
+ hooks: import_zod32.z.record(import_zod32.z.string(), import_zod32.z.array(import_zod32.z.unknown())).optional()
21394
21818
  });
21395
21819
  function hookCommandCountOf(group) {
21396
21820
  if (typeof group !== "object" || group === null) {
@@ -21670,10 +22094,10 @@ function collectCheckReport(params) {
21670
22094
  const providerName = cascadeProviderName(cascade, identityConfig?.provider);
21671
22095
  const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
21672
22096
  const identityId = identityDecision.name === void 0 ? void 0 : identityIdOf(paths, identityDecision.name);
21673
- const farmRoot = identityId === void 0 ? void 0 : import_node_path40.default.join(paths.identitiesDir, identityId);
22097
+ const farmRoot = identityId === void 0 ? void 0 : import_node_path41.default.join(paths.identitiesDir, identityId);
21674
22098
  const settingsFiles = isCodex ? {} : {
21675
- "settings.json": realFsPort.readFileUtf8(import_node_path40.default.join(claudeHome, "settings.json")),
21676
- "settings.local.json": realFsPort.readFileUtf8(import_node_path40.default.join(claudeHome, "settings.local.json"))
22099
+ "settings.json": realFsPort.readFileUtf8(import_node_path41.default.join(claudeHome, "settings.json")),
22100
+ "settings.local.json": realFsPort.readFileUtf8(import_node_path41.default.join(claudeHome, "settings.local.json"))
21677
22101
  };
21678
22102
  const report = runCheck({
21679
22103
  ...isCodex ? { agent: "codex" } : {},
@@ -21720,6 +22144,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
21720
22144
  }
21721
22145
  }
21722
22146
 
22147
+ // src/doctorFarmLinks.ts
22148
+ function remedy(agent, name, rel) {
22149
+ if (agent === "codex") {
22150
+ return `Codex cannot write through it. A launch with \`agent-shim run --agent codex @${name}\` resyncs the farm and leaves the link out.`;
22151
+ }
22152
+ const lost = rel === "sessions" ? " (an interactive session's record under sessions/ is lost, so the session is missing from `claude agents`)" : "";
22153
+ return `Claude Code cannot write through it${lost}. A launch through agent-shim resyncs the farm and leaves the link out, but a session started with this directory as CLAUDE_CONFIG_DIR does not. Run \`agent-shim identity resync ${name}\` in the directory those sessions start in to bring the farm up to date without launching.`;
22154
+ }
22155
+ function pushFarmLinkFindings(push, farms, agentOf) {
22156
+ let found = false;
22157
+ for (const farm of farms) {
22158
+ for (const link of farm.dangling) {
22159
+ found = true;
22160
+ const points = link.target === void 0 ? "" : ` to ${link.target}`;
22161
+ push("farm-links", "warn", `identities/${farm.id}/${link.rel} is a farm link${points} that leads nowhere, so ${remedy(agentOf.get(farm.name) ?? "claude", farm.name, link.rel)}`, farm.name);
22162
+ }
22163
+ }
22164
+ if (!found) {
22165
+ push("farm-links", "pass", "Every identity's farm links lead somewhere.");
22166
+ }
22167
+ }
22168
+
22169
+ // src/doctorReport.ts
22170
+ init_farm();
22171
+
21723
22172
  // src/frontdoor/catalogueFailures.ts
21724
22173
  init_state();
21725
22174
  init_catalogueState();
@@ -22129,6 +22578,7 @@ var DOCTOR_SECTIONS = [
22129
22578
  "config-profile",
22130
22579
  "identity",
22131
22580
  "sign-in",
22581
+ "farm-links",
22132
22582
  "pool",
22133
22583
  "provider",
22134
22584
  "keychain",
@@ -22174,7 +22624,7 @@ function tcpPortEraRecord(raw) {
22174
22624
  return (has("port") || has("lastPort")) && !has("socketPath");
22175
22625
  }
22176
22626
  function pushPathResolution(push, resolution) {
22177
- const ownDir = import_node_path43.default.dirname(resolution.ownExecutablePath);
22627
+ const ownDir = import_node_path44.default.dirname(resolution.ownExecutablePath);
22178
22628
  switch (resolution.agentShim.status) {
22179
22629
  case "ok":
22180
22630
  push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
@@ -22294,14 +22744,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
22294
22744
  }
22295
22745
  function pushLegacyName(push, params) {
22296
22746
  const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
22297
- if (legacyVariables.length === 0 && import_node_path43.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
22747
+ if (legacyVariables.length === 0 && import_node_path44.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
22298
22748
  push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
22299
22749
  return;
22300
22750
  }
22301
22751
  for (const name of legacyVariables) {
22302
22752
  push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
22303
22753
  }
22304
- if (import_node_path43.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
22754
+ if (import_node_path44.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
22305
22755
  push(
22306
22756
  "legacy-name",
22307
22757
  "warn",
@@ -22391,7 +22841,7 @@ function runDoctor(params) {
22391
22841
  push("identity", "warn", `identities/${name} cannot be reached (${code}), so it is not counted as an identity. Repair the permissions of the directory or of what a symlink points through, or remove the entry.`, name);
22392
22842
  }
22393
22843
  for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
22394
- push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, import_node_path43.default.basename(file));
22844
+ push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, import_node_path44.default.basename(file));
22395
22845
  }
22396
22846
  const validIdentityAgents = /* @__PURE__ */ new Map();
22397
22847
  const signedInAccounts = [];
@@ -22527,6 +22977,9 @@ function runDoctor(params) {
22527
22977
  push("provider", finding.level, finding.message, finding.alias);
22528
22978
  }
22529
22979
  pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
22980
+ if (params.farmLinks !== void 0) {
22981
+ pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
22982
+ }
22530
22983
  if (params.directoryRules.raw === void 0) {
22531
22984
  push("directory-rules", "pass", "No directory-rules.json configured.");
22532
22985
  } else {
@@ -22676,73 +23129,6 @@ function runDoctor(params) {
22676
23129
  }
22677
23130
  return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
22678
23131
  }
22679
- var SECTION_TITLES = {
22680
- models: "Virtual models",
22681
- "ambient-credential": "Ambient-credential exposure",
22682
- "binary-discovery": "Claude Code binary discovery",
22683
- "claude-shim": "`claude` command shim",
22684
- "path-resolution": "PATH resolution",
22685
- "legacy-name": "Former `claude-use` name",
22686
- "config-profile": "Configuration profiles",
22687
- identity: "Identities",
22688
- "sign-in": "Sign-in",
22689
- pool: "Pools",
22690
- provider: "Providers",
22691
- keychain: "macOS Keychain",
22692
- "directory-rules": "Directory rules",
22693
- "global-config": "Global config",
22694
- headroom: "Headroom daemon",
22695
- frontdoor: "Front door",
22696
- "categories-local": "categories.local.json",
22697
- "active-identity": "Active identity"
22698
- };
22699
- var SECTION_ORDER = [
22700
- "ambient-credential",
22701
- "binary-discovery",
22702
- "claude-shim",
22703
- "path-resolution",
22704
- "config-profile",
22705
- "identity",
22706
- "sign-in",
22707
- "pool",
22708
- "provider",
22709
- "keychain",
22710
- "directory-rules",
22711
- "global-config",
22712
- "headroom",
22713
- "frontdoor",
22714
- "categories-local",
22715
- "active-identity"
22716
- ];
22717
- function severityPrefix(severity) {
22718
- switch (severity) {
22719
- case "pass":
22720
- return "[PASS]";
22721
- case "warn":
22722
- return "[WARN]";
22723
- case "fail":
22724
- return "[FAIL]";
22725
- default:
22726
- return severity;
22727
- }
22728
- }
22729
- function formatDoctorReport(report) {
22730
- const lines = [];
22731
- for (const section of SECTION_ORDER) {
22732
- const sectionFindings = report.findings.filter((finding) => finding.section === section);
22733
- if (sectionFindings.length === 0) {
22734
- continue;
22735
- }
22736
- lines.push("", `${SECTION_TITLES[section]}:`);
22737
- for (const finding of sectionFindings) {
22738
- const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
22739
- lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
22740
- }
22741
- }
22742
- const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
22743
- lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
22744
- return lines;
22745
- }
22746
23132
  function servingDoorListeners(paths) {
22747
23133
  const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
22748
23134
  const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
@@ -22753,9 +23139,9 @@ function collectDoctorReport(params) {
22753
23139
  const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
22754
23140
  const records = identityRecords(paths);
22755
23141
  const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
22756
- const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(import_node_path43.default.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
22757
- const farmRoot = import_node_path43.default.join(paths.identitiesDir, id);
22758
- const identityPath = import_node_path43.default.join(farmRoot, "identity.json");
23142
+ const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(import_node_path44.default.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
23143
+ const farmRoot = import_node_path44.default.join(paths.identitiesDir, id);
23144
+ const identityPath = import_node_path44.default.join(farmRoot, "identity.json");
22759
23145
  return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs14.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
22760
23146
  });
22761
23147
  const usageSnapshots = {};
@@ -22773,12 +23159,12 @@ function collectDoctorReport(params) {
22773
23159
  }
22774
23160
  const profileNames = import_node_fs14.default.existsSync(paths.configProfilesDir) ? import_node_fs14.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
22775
23161
  const configProfiles = profileNames.map((name) => {
22776
- const profilePath = import_node_path43.default.join(paths.configProfilesDir, `${name}.json`);
23162
+ const profilePath = import_node_path44.default.join(paths.configProfilesDir, `${name}.json`);
22777
23163
  return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
22778
23164
  });
22779
23165
  const providerNames = import_node_fs14.default.existsSync(paths.providersDir) ? import_node_fs14.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
22780
23166
  const providers = providerNames.map((name) => {
22781
- const providerPath = import_node_path43.default.join(paths.providersDir, `${name}.json`);
23167
+ const providerPath = import_node_path44.default.join(paths.providersDir, `${name}.json`);
22782
23168
  return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
22783
23169
  });
22784
23170
  const ownExecutablePath = realOwnExecutablePath();
@@ -22790,12 +23176,12 @@ function collectDoctorReport(params) {
22790
23176
  binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
22791
23177
  }
22792
23178
  const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
22793
- const pathDirs = (params.env.PATH ?? "").split(import_node_path43.default.delimiter).filter((dir) => dir !== "");
23179
+ const pathDirs = (params.env.PATH ?? "").split(import_node_path44.default.delimiter).filter((dir) => dir !== "");
22794
23180
  const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
22795
23181
  findPathShadow({
22796
23182
  pathDirs,
22797
- targetDir: import_node_path43.default.dirname(shimState.targetPath),
22798
- targetFilename: import_node_path43.default.basename(shimState.targetPath),
23183
+ targetDir: import_node_path44.default.dirname(shimState.targetPath),
23184
+ targetFilename: import_node_path44.default.basename(shimState.targetPath),
22799
23185
  findExecutableInDir
22800
23186
  }),
22801
23187
  shimState.targetPath,
@@ -22815,6 +23201,7 @@ function collectDoctorReport(params) {
22815
23201
  chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
22816
23202
  installedClaudeVersions: realInstalledClaudeVersions(),
22817
23203
  identities,
23204
+ farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
22818
23205
  usageSnapshots,
22819
23206
  configProfiles,
22820
23207
  providers,
@@ -22823,7 +23210,7 @@ function collectDoctorReport(params) {
22823
23210
  catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
22824
23211
  renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
22825
23212
  unreachableIdentities,
22826
- identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path43.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
23213
+ identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path44.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
22827
23214
  directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
22828
23215
  globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
22829
23216
  models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
@@ -22838,7 +23225,7 @@ function collectDoctorReport(params) {
22838
23225
  agentShim: refinePathShadow(
22839
23226
  findPathShadow({
22840
23227
  pathDirs,
22841
- targetDir: import_node_path43.default.dirname(ownExecutablePath),
23228
+ targetDir: import_node_path44.default.dirname(ownExecutablePath),
22842
23229
  targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
22843
23230
  findExecutableInDir
22844
23231
  }),
@@ -22881,93 +23268,93 @@ function collectDoctorReport(params) {
22881
23268
  init_schema2();
22882
23269
  init_rcSchemas();
22883
23270
  init_state();
22884
- var UsageListOutputSchema = import_zod38.z.strictObject({ snapshots: import_zod38.z.readonly(import_zod38.z.array(UsageSnapshotSchema)) });
22885
- var UsageWindowsInputSchema = import_zod38.z.strictObject({
22886
- identity: import_zod38.z.string().min(1),
22887
- provider: import_zod38.z.string().min(1).optional()
23271
+ var UsageListOutputSchema = import_zod39.z.strictObject({ snapshots: import_zod39.z.readonly(import_zod39.z.array(UsageSnapshotSchema)) });
23272
+ var UsageWindowsInputSchema = import_zod39.z.strictObject({
23273
+ identity: import_zod39.z.string().min(1),
23274
+ provider: import_zod39.z.string().min(1).optional()
22888
23275
  });
22889
- var EffectiveWindowSchema = import_zod38.z.strictObject({
23276
+ var EffectiveWindowSchema = import_zod39.z.strictObject({
22890
23277
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
22891
- reset: import_zod38.z.boolean(),
23278
+ reset: import_zod39.z.boolean(),
22892
23279
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
22893
- utilization: import_zod38.z.number().optional(),
23280
+ utilization: import_zod39.z.number().optional(),
22894
23281
  /** The reset instant, for a window that has not reset yet and reported one. */
22895
- resetsAtMs: import_zod38.z.number().optional(),
23282
+ resetsAtMs: import_zod39.z.number().optional(),
22896
23283
  /** The window's own status, for a window that has not reset yet. */
22897
- status: import_zod38.z.string().optional()
23284
+ status: import_zod39.z.string().optional()
22898
23285
  });
22899
- var UsageWindowsOutputSchema = import_zod38.z.strictObject({
22900
- identity: import_zod38.z.string(),
22901
- provider: import_zod38.z.string(),
23286
+ var UsageWindowsOutputSchema = import_zod39.z.strictObject({
23287
+ identity: import_zod39.z.string(),
23288
+ provider: import_zod39.z.string(),
22902
23289
  /** When the rate-limit state the windows come from was observed. */
22903
- observedAt: import_zod38.z.iso.datetime().optional(),
23290
+ observedAt: import_zod39.z.iso.datetime().optional(),
22904
23291
  fiveHour: EffectiveWindowSchema.optional(),
22905
23292
  sevenDay: EffectiveWindowSchema.optional()
22906
23293
  });
22907
- var UsageLiveOutputSchema = import_zod38.z.strictObject({
23294
+ var UsageLiveOutputSchema = import_zod39.z.strictObject({
22908
23295
  /** 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. */
22909
23296
  latest: RcLiveRateLimitSchema.optional(),
22910
23297
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
22911
- sessions: import_zod38.z.readonly(import_zod38.z.array(RcLiveRateLimitSchema))
23298
+ sessions: import_zod39.z.readonly(import_zod39.z.array(RcLiveRateLimitSchema))
22912
23299
  });
22913
- var FrontDoorSessionStatusSchema = import_zod38.z.strictObject({
22914
- pid: import_zod38.z.int().positive(),
22915
- startedAt: import_zod38.z.number(),
22916
- alive: import_zod38.z.boolean()
23300
+ var FrontDoorSessionStatusSchema = import_zod39.z.strictObject({
23301
+ pid: import_zod39.z.int().positive(),
23302
+ startedAt: import_zod39.z.number(),
23303
+ alive: import_zod39.z.boolean()
22917
23304
  });
22918
- var HeadroomSocketTargetSchema = import_zod38.z.union([import_zod38.z.strictObject({ socketPath: import_zod38.z.string() }), import_zod38.z.strictObject({ refused: import_zod38.z.string() })]);
22919
- var FrontDoorStatusOutputSchema = import_zod38.z.strictObject({
23305
+ var HeadroomSocketTargetSchema = import_zod39.z.union([import_zod39.z.strictObject({ socketPath: import_zod39.z.string() }), import_zod39.z.strictObject({ refused: import_zod39.z.string() })]);
23306
+ var FrontDoorStatusOutputSchema = import_zod39.z.strictObject({
22920
23307
  state: FrontDoorStateSchema,
22921
- supervisorAlive: import_zod38.z.boolean(),
23308
+ supervisorAlive: import_zod39.z.boolean(),
22922
23309
  /** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
22923
- draining: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.number().int().positive())),
22924
- sessions: import_zod38.z.readonly(import_zod38.z.array(FrontDoorSessionStatusSchema)),
23310
+ draining: import_zod39.z.readonly(import_zod39.z.array(import_zod39.z.number().int().positive())),
23311
+ sessions: import_zod39.z.readonly(import_zod39.z.array(FrontDoorSessionStatusSchema)),
22925
23312
  headroomSocket: HeadroomSocketTargetSchema.optional(),
22926
- logPath: import_zod38.z.string(),
22927
- logExists: import_zod38.z.boolean()
23313
+ logPath: import_zod39.z.string(),
23314
+ logExists: import_zod39.z.boolean()
22928
23315
  });
22929
- var FrontDoorSessionsOutputSchema = import_zod38.z.strictObject({ sessions: import_zod38.z.readonly(import_zod38.z.array(FrontDoorSessionStatusSchema)) });
23316
+ var FrontDoorSessionsOutputSchema = import_zod39.z.strictObject({ sessions: import_zod39.z.readonly(import_zod39.z.array(FrontDoorSessionStatusSchema)) });
22930
23317
  var DOOR_REPORT_ENVIRONMENT_NOTE = "The report is collected in a worker thread of the door under the door's own environment and PATH, as a launch the door plans for itself would inherit them, not under the caller's shell: the identity is the caller's to name, the cascade is read from files at the path, and the environment-driven findings (AGENT_SHIM_IDENTITY, AGENT_SHIM_CONFIG_PROFILE, the Claude Code version pin, the ambient-credential check, and for doctor the PATH and shim findings) describe the door's launch. Run agent-shim check or agent-shim doctor from a shell for the caller's own reading.";
22931
- var CheckRunInputSchema = import_zod38.z.strictObject({
22932
- path: import_zod38.z.string().min(1),
22933
- identity: import_zod38.z.string().min(1).optional()
22934
- }).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" });
22935
- var PoolPickInputSchema = import_zod38.z.strictObject({
22936
- pool: import_zod38.z.string().min(1),
22937
- path: import_zod38.z.string().min(1)
22938
- }).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" });
22939
- var DoctorFindingSchema = import_zod38.z.strictObject({
22940
- section: import_zod38.z.enum(DOCTOR_SECTIONS),
22941
- subject: import_zod38.z.string().optional(),
22942
- severity: import_zod38.z.enum(DOCTOR_SEVERITIES),
22943
- message: import_zod38.z.string()
22944
- });
22945
- var DoctorRunOutputSchema = import_zod38.z.strictObject({
23318
+ var CheckRunInputSchema = import_zod39.z.strictObject({
23319
+ path: import_zod39.z.string().min(1),
23320
+ identity: import_zod39.z.string().min(1).optional()
23321
+ }).refine((input) => import_node_path45.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
23322
+ var PoolPickInputSchema = import_zod39.z.strictObject({
23323
+ pool: import_zod39.z.string().min(1),
23324
+ path: import_zod39.z.string().min(1)
23325
+ }).refine((input) => import_node_path45.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
23326
+ var DoctorFindingSchema = import_zod39.z.strictObject({
23327
+ section: import_zod39.z.enum(DOCTOR_SECTIONS),
23328
+ subject: import_zod39.z.string().optional(),
23329
+ severity: import_zod39.z.enum(DOCTOR_SEVERITIES),
23330
+ message: import_zod39.z.string()
23331
+ });
23332
+ var DoctorRunOutputSchema = import_zod39.z.strictObject({
22946
23333
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
22947
- ok: import_zod38.z.boolean(),
22948
- findings: import_zod38.z.readonly(import_zod38.z.array(DoctorFindingSchema))
22949
- });
22950
- var FrontDoorRestartOutputSchema = import_zod38.z.strictObject({
22951
- action: import_zod38.z.literal("restarting"),
22952
- previousPid: import_zod38.z.int().positive()
22953
- });
22954
- var UpdateCheckOutputSchema = import_zod38.z.strictObject({
22955
- current: import_zod38.z.string(),
22956
- latest: import_zod38.z.string(),
22957
- action: import_zod38.z.enum(["current", "available", "updated"])
22958
- });
22959
- var CodexSignInSchema = import_zod38.z.discriminatedUnion("state", [
22960
- import_zod38.z.strictObject({ state: import_zod38.z.literal("none") }),
22961
- import_zod38.z.strictObject({ state: import_zod38.z.literal("signed-in"), email: import_zod38.z.string().optional(), planScope: import_zod38.z.boolean(), accessTokenExpiresAt: import_zod38.z.number() }),
22962
- import_zod38.z.strictObject({ state: import_zod38.z.literal("unreadable"), message: import_zod38.z.string() })
23334
+ ok: import_zod39.z.boolean(),
23335
+ findings: import_zod39.z.readonly(import_zod39.z.array(DoctorFindingSchema))
23336
+ });
23337
+ var FrontDoorRestartOutputSchema = import_zod39.z.strictObject({
23338
+ action: import_zod39.z.literal("restarting"),
23339
+ previousPid: import_zod39.z.int().positive()
23340
+ });
23341
+ var UpdateCheckOutputSchema = import_zod39.z.strictObject({
23342
+ current: import_zod39.z.string(),
23343
+ latest: import_zod39.z.string(),
23344
+ action: import_zod39.z.enum(["current", "available", "updated"])
23345
+ });
23346
+ var CodexSignInSchema = import_zod39.z.discriminatedUnion("state", [
23347
+ import_zod39.z.strictObject({ state: import_zod39.z.literal("none") }),
23348
+ import_zod39.z.strictObject({ state: import_zod39.z.literal("signed-in"), email: import_zod39.z.string().optional(), planScope: import_zod39.z.boolean(), accessTokenExpiresAt: import_zod39.z.number() }),
23349
+ import_zod39.z.strictObject({ state: import_zod39.z.literal("unreadable"), message: import_zod39.z.string() })
22963
23350
  ]);
22964
- var CodexStatusOutputSchema = import_zod38.z.strictObject({
23351
+ var CodexStatusOutputSchema = import_zod39.z.strictObject({
22965
23352
  signIn: CodexSignInSchema,
22966
- codexProviders: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.string()))
23353
+ codexProviders: import_zod39.z.readonly(import_zod39.z.array(import_zod39.z.string()))
22967
23354
  });
22968
- var CodexLogoutOutputSchema = import_zod38.z.strictObject({
22969
- hadGrant: import_zod38.z.boolean(),
22970
- revoked: import_zod38.z.boolean()
23355
+ var CodexLogoutOutputSchema = import_zod39.z.strictObject({
23356
+ hadGrant: import_zod39.z.boolean(),
23357
+ revoked: import_zod39.z.boolean()
22971
23358
  });
22972
23359
 
22973
23360
  // src/frontdoor/codexApi.ts
@@ -22988,21 +23375,21 @@ function createCodexApiRouter(deps) {
22988
23375
 
22989
23376
  // src/frontdoor/doorWorker.ts
22990
23377
  var import_node_sea2 = require("node:sea");
22991
- var import_zod40 = require("zod");
23378
+ var import_zod41 = require("zod");
22992
23379
  init_cliError();
22993
23380
  init_doorBounds();
22994
23381
  init_providerCatalogue();
22995
23382
 
22996
23383
  // src/frontdoor/doorWorkerProtocol.ts
22997
- var import_zod39 = require("zod");
23384
+ var import_zod40 = require("zod");
22998
23385
  init_providerCatalogue();
22999
23386
  var doorWorkerInputSchemas = {
23000
23387
  /** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
23001
- check: import_zod39.z.strictObject({ root: import_zod39.z.string().min(1), path: import_zod39.z.string().min(1), identity: import_zod39.z.string().min(1).optional() }),
23388
+ check: import_zod40.z.strictObject({ root: import_zod40.z.string().min(1), path: import_zod40.z.string().min(1), identity: import_zod40.z.string().min(1).optional() }),
23002
23389
  /** `agent-shim doctor`. */
23003
- doctor: import_zod39.z.strictObject({ root: import_zod39.z.string().min(1) }),
23390
+ doctor: import_zod40.z.strictObject({ root: import_zod40.z.string().min(1) }),
23004
23391
  /** Fetch and store one provider's model catalogue for the door generation that asked. */
23005
- "refresh-catalogue": import_zod39.z.strictObject({ root: import_zod39.z.string().min(1), name: import_zod39.z.string().min(1), supervisorPid: import_zod39.z.int().positive(), generation: import_zod39.z.uuid() })
23392
+ "refresh-catalogue": import_zod40.z.strictObject({ root: import_zod40.z.string().min(1), name: import_zod40.z.string().min(1), supervisorPid: import_zod40.z.int().positive(), generation: import_zod40.z.uuid() })
23006
23393
  };
23007
23394
 
23008
23395
  // src/frontdoor/doorWorker.ts
@@ -23092,72 +23479,72 @@ init_baseUrlDisplay();
23092
23479
  init_providersStore();
23093
23480
 
23094
23481
  // src/frontdoor/configSchemas.ts
23095
- var import_zod41 = require("zod");
23482
+ var import_zod42 = require("zod");
23096
23483
  init_schema();
23097
23484
  init_names();
23098
23485
  init_keychainLogin();
23099
23486
  init_statusline();
23100
- var RemovalConfirmationSchema = import_zod41.z.boolean();
23101
- var CredentialWriteSchema = (targets) => import_zod41.z.strictObject({
23102
- sources: import_zod41.z.array(RemoteCredentialSourceSchema).min(1).optional(),
23103
- target: import_zod41.z.enum(targets).optional(),
23104
- cache: import_zod41.z.union([import_zod41.z.literal(false), CredentialCacheSchema]).optional()
23105
- });
23106
- var CredentialSummarySchema2 = import_zod41.z.strictObject({
23107
- target: import_zod41.z.enum(CREDENTIAL_TARGETS),
23108
- sources: import_zod41.z.readonly(import_zod41.z.array(
23109
- import_zod41.z.discriminatedUnion("kind", [
23110
- import_zod41.z.strictObject({ kind: import_zod41.z.literal("env"), variable: import_zod41.z.string() }),
23111
- import_zod41.z.strictObject({ kind: import_zod41.z.literal("file"), path: import_zod41.z.string() }),
23112
- import_zod41.z.strictObject({ kind: import_zod41.z.literal("command"), program: import_zod41.z.string() }),
23113
- import_zod41.z.strictObject({ kind: import_zod41.z.literal("op"), reference: import_zod41.z.string() }),
23114
- import_zod41.z.strictObject({ kind: import_zod41.z.literal("keychain"), service: import_zod41.z.string(), account: import_zod41.z.string().optional() }),
23115
- import_zod41.z.strictObject({ kind: import_zod41.z.literal("literal") })
23487
+ var RemovalConfirmationSchema = import_zod42.z.boolean();
23488
+ var CredentialWriteSchema = (targets) => import_zod42.z.strictObject({
23489
+ sources: import_zod42.z.array(RemoteCredentialSourceSchema).min(1).optional(),
23490
+ target: import_zod42.z.enum(targets).optional(),
23491
+ cache: import_zod42.z.union([import_zod42.z.literal(false), CredentialCacheSchema]).optional()
23492
+ });
23493
+ var CredentialSummarySchema2 = import_zod42.z.strictObject({
23494
+ target: import_zod42.z.enum(CREDENTIAL_TARGETS),
23495
+ sources: import_zod42.z.readonly(import_zod42.z.array(
23496
+ import_zod42.z.discriminatedUnion("kind", [
23497
+ import_zod42.z.strictObject({ kind: import_zod42.z.literal("env"), variable: import_zod42.z.string() }),
23498
+ import_zod42.z.strictObject({ kind: import_zod42.z.literal("file"), path: import_zod42.z.string() }),
23499
+ import_zod42.z.strictObject({ kind: import_zod42.z.literal("command"), program: import_zod42.z.string() }),
23500
+ import_zod42.z.strictObject({ kind: import_zod42.z.literal("op"), reference: import_zod42.z.string() }),
23501
+ import_zod42.z.strictObject({ kind: import_zod42.z.literal("keychain"), service: import_zod42.z.string(), account: import_zod42.z.string().optional() }),
23502
+ import_zod42.z.strictObject({ kind: import_zod42.z.literal("literal") })
23116
23503
  ])
23117
23504
  )),
23118
23505
  cache: CredentialCacheSchema.optional()
23119
23506
  });
23120
- var mutationOutput = (kind, action) => import_zod41.z.strictObject({ action: import_zod41.z.literal(action), kind: import_zod41.z.literal(kind), name: import_zod41.z.string() });
23121
- var storedMutationOutput = (kind, action, value) => import_zod41.z.strictObject({ action: import_zod41.z.literal(action), kind: import_zod41.z.literal(kind), name: import_zod41.z.string(), value });
23122
- var IdentityValueSchema = import_zod41.z.strictObject({
23123
- agent: import_zod41.z.enum(["claude", "codex"]).optional(),
23124
- name: import_zod41.z.string(),
23125
- label: import_zod41.z.string().optional(),
23126
- defaultConfigProfile: import_zod41.z.string().optional(),
23127
- provider: import_zod41.z.string().optional(),
23128
- allowAmbientCredential: import_zod41.z.boolean(),
23507
+ var mutationOutput = (kind, action) => import_zod42.z.strictObject({ action: import_zod42.z.literal(action), kind: import_zod42.z.literal(kind), name: import_zod42.z.string() });
23508
+ var storedMutationOutput = (kind, action, value) => import_zod42.z.strictObject({ action: import_zod42.z.literal(action), kind: import_zod42.z.literal(kind), name: import_zod42.z.string(), value });
23509
+ var IdentityValueSchema = import_zod42.z.strictObject({
23510
+ agent: import_zod42.z.enum(["claude", "codex"]).optional(),
23511
+ name: import_zod42.z.string(),
23512
+ label: import_zod42.z.string().optional(),
23513
+ defaultConfigProfile: import_zod42.z.string().optional(),
23514
+ provider: import_zod42.z.string().optional(),
23515
+ allowAmbientCredential: import_zod42.z.boolean(),
23129
23516
  credential: CredentialSummarySchema2.optional(),
23130
- anchors: import_zod41.z.array(AnchorSchema).optional()
23517
+ anchors: import_zod42.z.array(AnchorSchema).optional()
23131
23518
  });
23132
23519
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
23133
- var ProviderValueSchema = import_zod41.z.strictObject({
23134
- name: import_zod41.z.string(),
23135
- kind: import_zod41.z.enum(PROVIDER_KINDS),
23136
- displayName: import_zod41.z.string(),
23137
- baseUrl: import_zod41.z.string().optional(),
23520
+ var ProviderValueSchema = import_zod42.z.strictObject({
23521
+ name: import_zod42.z.string(),
23522
+ kind: import_zod42.z.enum(PROVIDER_KINDS),
23523
+ displayName: import_zod42.z.string(),
23524
+ baseUrl: import_zod42.z.string().optional(),
23138
23525
  codex: CodexProviderConfigSchema.optional(),
23139
23526
  credential: CredentialSummarySchema2.optional(),
23140
- env: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.string()).optional()
23527
+ env: import_zod42.z.record(import_zod42.z.string(), import_zod42.z.string()).optional()
23141
23528
  });
23142
- var ConfigNameInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1) });
23143
- var ConfigIdentityAddInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), keepKeychainLogin: import_zod41.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
23529
+ var ConfigNameInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1) });
23530
+ var ConfigIdentityAddInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), keepKeychainLogin: import_zod42.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
23144
23531
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
23145
- var ConfigIdentitySetInputSchema = import_zod41.z.strictObject({
23146
- name: import_zod41.z.string().min(1),
23532
+ var ConfigIdentitySetInputSchema = import_zod42.z.strictObject({
23533
+ name: import_zod42.z.string().min(1),
23147
23534
  /** The identity's display label; `false` clears it. */
23148
- label: import_zod41.z.union([IdentityLabelSchema, import_zod41.z.literal(false)]).optional(),
23149
- defaultConfigProfile: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
23535
+ label: import_zod42.z.union([IdentityLabelSchema, import_zod42.z.literal(false)]).optional(),
23536
+ defaultConfigProfile: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
23150
23537
  /** The provider the identity exists for; `false` clears it. */
23151
- provider: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
23152
- allowAmbientCredential: import_zod41.z.boolean().optional(),
23153
- credential: import_zod41.z.union([import_zod41.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
23538
+ provider: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
23539
+ allowAmbientCredential: import_zod42.z.boolean().optional(),
23540
+ credential: import_zod42.z.union([import_zod42.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
23154
23541
  /** `false` removes the anchors; a list replaces them. */
23155
- anchors: import_zod41.z.union([import_zod41.z.literal(false), import_zod41.z.array(AnchorSchema).min(1)]).optional()
23542
+ anchors: import_zod42.z.union([import_zod42.z.literal(false), import_zod42.z.array(AnchorSchema).min(1)]).optional()
23156
23543
  });
23157
23544
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
23158
- var ConfigIdentityRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
23545
+ var ConfigIdentityRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
23159
23546
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
23160
- var ConfigStatuslineSetSchema = import_zod41.z.record(import_zod41.z.string(), import_zod41.z.unknown()).superRefine((settings, context) => {
23547
+ var ConfigStatuslineSetSchema = import_zod42.z.record(import_zod42.z.string(), import_zod42.z.unknown()).superRefine((settings, context) => {
23161
23548
  for (const key of Object.keys(settings)) {
23162
23549
  if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
23163
23550
  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` });
@@ -23165,93 +23552,93 @@ var ConfigStatuslineSetSchema = import_zod41.z.record(import_zod41.z.string(), i
23165
23552
  }
23166
23553
  });
23167
23554
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
23168
- var ConfigProfileAddInputSchema = import_zod41.z.strictObject({
23169
- name: import_zod41.z.string().min(1),
23170
- extends: import_zod41.z.array(import_zod41.z.string().min(1)).optional(),
23171
- description: import_zod41.z.string().optional()
23555
+ var ConfigProfileAddInputSchema = import_zod42.z.strictObject({
23556
+ name: import_zod42.z.string().min(1),
23557
+ extends: import_zod42.z.array(import_zod42.z.string().min(1)).optional(),
23558
+ description: import_zod42.z.string().optional()
23172
23559
  });
23173
23560
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
23174
- var ConfigProfileSetInputSchema = import_zod41.z.strictObject({
23175
- name: import_zod41.z.string().min(1),
23176
- category: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.boolean()).optional(),
23177
- entry: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.boolean()).optional(),
23178
- extends: import_zod41.z.union([import_zod41.z.array(import_zod41.z.string().min(1)), import_zod41.z.literal(false)]).optional(),
23179
- description: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.literal(false)]).optional(),
23180
- launch: import_zod41.z.strictObject({
23181
- skipPermissions: import_zod41.z.boolean().optional(),
23182
- remoteControl: import_zod41.z.boolean().optional(),
23183
- headroom: import_zod41.z.boolean().optional(),
23184
- trackUsage: import_zod41.z.boolean().optional(),
23185
- provider: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
23186
- claudeVersion: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
23187
- delay: import_zod41.z.union([import_zod41.z.string().regex(DURATION_RE), import_zod41.z.literal(false)]).optional(),
23188
- pause: import_zod41.z.boolean().optional(),
23189
- explain: import_zod41.z.boolean().optional(),
23190
- proxyBypass: import_zod41.z.union([import_zod41.z.array(import_zod41.z.string().min(1)), import_zod41.z.literal(false)]).optional(),
23191
- statusline: import_zod41.z.strictObject({
23561
+ var ConfigProfileSetInputSchema = import_zod42.z.strictObject({
23562
+ name: import_zod42.z.string().min(1),
23563
+ category: import_zod42.z.record(import_zod42.z.string(), import_zod42.z.boolean()).optional(),
23564
+ entry: import_zod42.z.record(import_zod42.z.string(), import_zod42.z.boolean()).optional(),
23565
+ extends: import_zod42.z.union([import_zod42.z.array(import_zod42.z.string().min(1)), import_zod42.z.literal(false)]).optional(),
23566
+ description: import_zod42.z.union([import_zod42.z.string(), import_zod42.z.literal(false)]).optional(),
23567
+ launch: import_zod42.z.strictObject({
23568
+ skipPermissions: import_zod42.z.boolean().optional(),
23569
+ remoteControl: import_zod42.z.boolean().optional(),
23570
+ headroom: import_zod42.z.boolean().optional(),
23571
+ trackUsage: import_zod42.z.boolean().optional(),
23572
+ provider: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
23573
+ claudeVersion: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
23574
+ delay: import_zod42.z.union([import_zod42.z.string().regex(DURATION_RE), import_zod42.z.literal(false)]).optional(),
23575
+ pause: import_zod42.z.boolean().optional(),
23576
+ explain: import_zod42.z.boolean().optional(),
23577
+ proxyBypass: import_zod42.z.union([import_zod42.z.array(import_zod42.z.string().min(1)), import_zod42.z.literal(false)]).optional(),
23578
+ statusline: import_zod42.z.strictObject({
23192
23579
  set: ConfigStatuslineSetSchema.optional(),
23193
- unset: import_zod41.z.array(import_zod41.z.string()).optional()
23580
+ unset: import_zod42.z.array(import_zod42.z.string()).optional()
23194
23581
  }).optional()
23195
23582
  }).optional()
23196
23583
  });
23197
23584
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
23198
- var ConfigProfileRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
23585
+ var ConfigProfileRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
23199
23586
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
23200
23587
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
23201
- var PoolMembersInputSchema = import_zod41.z.array(import_zod41.z.string().min(1)).min(1);
23202
- var ConfigPoolAddInputSchema = import_zod41.z.strictObject({
23203
- name: import_zod41.z.string().min(1),
23588
+ var PoolMembersInputSchema = import_zod42.z.array(import_zod42.z.string().min(1)).min(1);
23589
+ var ConfigPoolAddInputSchema = import_zod42.z.strictObject({
23590
+ name: import_zod42.z.string().min(1),
23204
23591
  identities: PoolMembersInputSchema,
23205
- preference: import_zod41.z.enum(POOL_PREFERENCES).optional(),
23206
- resumeOnLimit: import_zod41.z.boolean().optional(),
23207
- compactBeforeLimit: import_zod41.z.boolean().optional(),
23592
+ preference: import_zod42.z.enum(POOL_PREFERENCES).optional(),
23593
+ resumeOnLimit: import_zod42.z.boolean().optional(),
23594
+ compactBeforeLimit: import_zod42.z.boolean().optional(),
23208
23595
  compactAtUtilisation: CompactAtUtilisationSchema.optional()
23209
23596
  });
23210
23597
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
23211
- var ConfigPoolSetInputSchema = import_zod41.z.strictObject({
23212
- name: import_zod41.z.string().min(1),
23598
+ var ConfigPoolSetInputSchema = import_zod42.z.strictObject({
23599
+ name: import_zod42.z.string().min(1),
23213
23600
  identities: PoolMembersInputSchema.optional(),
23214
- preference: import_zod41.z.union([import_zod41.z.enum(POOL_PREFERENCES), import_zod41.z.literal(false)]).optional(),
23215
- resumeOnLimit: import_zod41.z.boolean().optional(),
23216
- compactBeforeLimit: import_zod41.z.boolean().optional(),
23217
- compactAtUtilisation: import_zod41.z.union([CompactAtUtilisationSchema, import_zod41.z.literal(false)]).optional()
23601
+ preference: import_zod42.z.union([import_zod42.z.enum(POOL_PREFERENCES), import_zod42.z.literal(false)]).optional(),
23602
+ resumeOnLimit: import_zod42.z.boolean().optional(),
23603
+ compactBeforeLimit: import_zod42.z.boolean().optional(),
23604
+ compactAtUtilisation: import_zod42.z.union([CompactAtUtilisationSchema, import_zod42.z.literal(false)]).optional()
23218
23605
  });
23219
23606
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
23220
- var ConfigPoolRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
23607
+ var ConfigPoolRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
23221
23608
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
23222
23609
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
23223
- var ConfigProviderAddInputSchema = import_zod41.z.strictObject({
23224
- name: import_zod41.z.string().min(1),
23225
- kind: import_zod41.z.enum(PROVIDER_KINDS).optional(),
23226
- displayName: import_zod41.z.string().min(1),
23227
- baseUrl: import_zod41.z.string().min(1).optional(),
23610
+ var ConfigProviderAddInputSchema = import_zod42.z.strictObject({
23611
+ name: import_zod42.z.string().min(1),
23612
+ kind: import_zod42.z.enum(PROVIDER_KINDS).optional(),
23613
+ displayName: import_zod42.z.string().min(1),
23614
+ baseUrl: import_zod42.z.string().min(1).optional(),
23228
23615
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
23229
23616
  codex: CodexProviderConfigSchema.optional()
23230
23617
  });
23231
23618
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
23232
- var ConfigProviderSetInputSchema = import_zod41.z.strictObject({
23233
- name: import_zod41.z.string().min(1),
23234
- displayName: import_zod41.z.string().min(1).optional(),
23235
- baseUrl: import_zod41.z.string().min(1).optional(),
23619
+ var ConfigProviderSetInputSchema = import_zod42.z.strictObject({
23620
+ name: import_zod42.z.string().min(1),
23621
+ displayName: import_zod42.z.string().min(1).optional(),
23622
+ baseUrl: import_zod42.z.string().min(1).optional(),
23236
23623
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
23237
23624
  codex: CodexProviderConfigSchema.optional()
23238
23625
  });
23239
23626
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
23240
- var ConfigProviderRemoveInputSchema = import_zod41.z.strictObject({ name: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
23627
+ var ConfigProviderRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
23241
23628
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
23242
- var ConfigRuleAddInputSchema = import_zod41.z.strictObject({
23243
- path: import_zod41.z.string().min(1),
23244
- configProfile: import_zod41.z.string().min(1).optional(),
23245
- identity: import_zod41.z.string().min(1).optional()
23629
+ var ConfigRuleAddInputSchema = import_zod42.z.strictObject({
23630
+ path: import_zod42.z.string().min(1),
23631
+ configProfile: import_zod42.z.string().min(1).optional(),
23632
+ identity: import_zod42.z.string().min(1).optional()
23246
23633
  });
23247
23634
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
23248
- var ConfigRuleSetInputSchema = import_zod41.z.strictObject({
23249
- path: import_zod41.z.string().min(1),
23250
- configProfile: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional(),
23251
- identity: import_zod41.z.union([import_zod41.z.string().min(1), import_zod41.z.literal(false)]).optional()
23635
+ var ConfigRuleSetInputSchema = import_zod42.z.strictObject({
23636
+ path: import_zod42.z.string().min(1),
23637
+ configProfile: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
23638
+ identity: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional()
23252
23639
  });
23253
23640
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
23254
- var ConfigRuleRemoveInputSchema = import_zod41.z.strictObject({ path: import_zod41.z.string().min(1), confirm: RemovalConfirmationSchema });
23641
+ var ConfigRuleRemoveInputSchema = import_zod42.z.strictObject({ path: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
23255
23642
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
23256
23643
 
23257
23644
  // src/frontdoor/configApi.ts
@@ -23325,7 +23712,7 @@ function profileValue(name, paths) {
23325
23712
  function createConfigApiRouter(deps) {
23326
23713
  const authed = doorApiAuth(deps.expectedToken);
23327
23714
  const { paths } = deps;
23328
- const route = (path56, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path56, summary, tags: [CONFIG_API_TAG] }));
23715
+ const route = (path59, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path59, summary, tags: [CONFIG_API_TAG] }));
23329
23716
  return {
23330
23717
  config: {
23331
23718
  identity: {
@@ -23595,51 +23982,51 @@ var import_openapi4 = require("@orpc/openapi");
23595
23982
  var import_server3 = require("@orpc/server");
23596
23983
 
23597
23984
  // src/frontdoor/eventSchemas.ts
23598
- var import_zod42 = require("zod");
23985
+ var import_zod43 = require("zod");
23599
23986
  init_schema2();
23600
23987
  var DOOR_EVENT_SOURCE_RC = "rc";
23601
23988
  var LAUNCH_EVENT_SOURCE = "launch";
23602
23989
  var USAGE_EVENT_SOURCE = "usage";
23603
23990
  var DOOR_HEALTH_EVENT_SOURCE = "door";
23604
23991
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
23605
- var DoorEventSchema = import_zod42.z.strictObject({
23606
- source: import_zod42.z.string().min(1),
23992
+ var DoorEventSchema = import_zod43.z.strictObject({
23993
+ source: import_zod43.z.string().min(1),
23607
23994
  /** A positive integer because the backbone's counters start at one and only ever increase. */
23608
- sequence: import_zod42.z.number().int().positive(),
23609
- payload: import_zod42.z.unknown()
23610
- });
23611
- var DoorEventSourceQuerySchema = import_zod42.z.strictObject({
23612
- sources: import_zod42.z.array(import_zod42.z.string().min(1)).min(1).optional()
23613
- });
23614
- var LaunchLifecycleEventSchema = import_zod42.z.strictObject({
23615
- kind: import_zod42.z.enum(["registered", "pruned", "ended"]),
23616
- pid: import_zod42.z.number().int().positive(),
23617
- startedAt: import_zod42.z.number(),
23618
- observedAt: import_zod42.z.number()
23619
- });
23620
- var DoorHealthEventSchema = import_zod42.z.discriminatedUnion("kind", [
23621
- import_zod42.z.strictObject({ kind: import_zod42.z.literal("generation"), pid: import_zod42.z.number().int().positive(), providerPort: import_zod42.z.number().int().positive(), connectPort: import_zod42.z.number().int().positive(), directPort: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
23622
- import_zod42.z.strictObject({ kind: import_zod42.z.literal("listenerFailed"), pid: import_zod42.z.number().int().positive(), listener: import_zod42.z.enum(["provider", "connect", "direct"]), message: import_zod42.z.string(), observedAt: import_zod42.z.number() }),
23623
- import_zod42.z.strictObject({ kind: import_zod42.z.literal("binaryTurnover"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
23624
- import_zod42.z.strictObject({ kind: import_zod42.z.literal("idleShutdown"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
23625
- import_zod42.z.strictObject({ kind: import_zod42.z.literal("superseded"), pid: import_zod42.z.number().int().positive(), ownerPid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() }),
23626
- import_zod42.z.strictObject({ kind: import_zod42.z.literal("drained"), pid: import_zod42.z.number().int().positive(), observedAt: import_zod42.z.number() })
23995
+ sequence: import_zod43.z.number().int().positive(),
23996
+ payload: import_zod43.z.unknown()
23997
+ });
23998
+ var DoorEventSourceQuerySchema = import_zod43.z.strictObject({
23999
+ sources: import_zod43.z.array(import_zod43.z.string().min(1)).min(1).optional()
24000
+ });
24001
+ var LaunchLifecycleEventSchema = import_zod43.z.strictObject({
24002
+ kind: import_zod43.z.enum(["registered", "pruned", "ended"]),
24003
+ pid: import_zod43.z.number().int().positive(),
24004
+ startedAt: import_zod43.z.number(),
24005
+ observedAt: import_zod43.z.number()
24006
+ });
24007
+ var DoorHealthEventSchema = import_zod43.z.discriminatedUnion("kind", [
24008
+ import_zod43.z.strictObject({ kind: import_zod43.z.literal("generation"), pid: import_zod43.z.number().int().positive(), providerPort: import_zod43.z.number().int().positive(), connectPort: import_zod43.z.number().int().positive(), directPort: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
24009
+ import_zod43.z.strictObject({ kind: import_zod43.z.literal("listenerFailed"), pid: import_zod43.z.number().int().positive(), listener: import_zod43.z.enum(["provider", "connect", "direct"]), message: import_zod43.z.string(), observedAt: import_zod43.z.number() }),
24010
+ import_zod43.z.strictObject({ kind: import_zod43.z.literal("binaryTurnover"), pid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
24011
+ import_zod43.z.strictObject({ kind: import_zod43.z.literal("idleShutdown"), pid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
24012
+ import_zod43.z.strictObject({ kind: import_zod43.z.literal("superseded"), pid: import_zod43.z.number().int().positive(), ownerPid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
24013
+ import_zod43.z.strictObject({ kind: import_zod43.z.literal("drained"), pid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() })
23627
24014
  ]);
23628
- var QuotaExpiringEventSchema = import_zod42.z.strictObject({
24015
+ var QuotaExpiringEventSchema = import_zod43.z.strictObject({
23629
24016
  /** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
23630
- id: import_zod42.z.string().min(1),
24017
+ id: import_zod43.z.string().min(1),
23631
24018
  /** The identity's name when the event was published, absent for an identity no longer stored under the id. */
23632
- name: import_zod42.z.string().min(1).optional(),
23633
- provider: import_zod42.z.string().min(1),
23634
- window: import_zod42.z.enum(["fiveHour", "sevenDay"]),
24019
+ name: import_zod43.z.string().min(1).optional(),
24020
+ provider: import_zod43.z.string().min(1),
24021
+ window: import_zod43.z.enum(["fiveHour", "sevenDay"]),
23635
24022
  /** 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. */
23636
- utilization: import_zod42.z.number().min(0).max(1),
23637
- resetsAt: import_zod42.z.iso.datetime(),
23638
- observedAt: import_zod42.z.number()
24023
+ utilization: import_zod43.z.number().min(0).max(1),
24024
+ resetsAt: import_zod43.z.iso.datetime(),
24025
+ observedAt: import_zod43.z.number()
23639
24026
  });
23640
24027
  var UsageChangeEventSchema = UsageSnapshotSchema.extend({
23641
- id: import_zod42.z.string().min(1),
23642
- name: import_zod42.z.string().min(1).optional()
24028
+ id: import_zod43.z.string().min(1),
24029
+ name: import_zod43.z.string().min(1).optional()
23643
24030
  });
23644
24031
 
23645
24032
  // src/frontdoor/eventsApi.ts
@@ -23683,7 +24070,7 @@ function createEventsApiRouter(deps) {
23683
24070
  // src/frontdoor/lifecycleApi.ts
23684
24071
  var import_client4 = require("@orpc/client");
23685
24072
  var import_openapi5 = require("@orpc/openapi");
23686
- var import_zod43 = require("zod");
24073
+ var import_zod44 = require("zod");
23687
24074
  init_update();
23688
24075
  var FRONTDOOR_API_TAG = "frontdoor";
23689
24076
  var UPDATE_API_TAG = "update";
@@ -23691,7 +24078,7 @@ function createLifecycleApiRouter(deps) {
23691
24078
  const authed = doorApiAuth(deps.expectedToken);
23692
24079
  return {
23693
24080
  frontdoor: {
23694
- 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_zod43.z.strictObject({ requested: import_zod43.z.literal(true) })).handler(() => {
24081
+ 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_zod44.z.strictObject({ requested: import_zod44.z.literal(true) })).handler(() => {
23695
24082
  deps.refreshCatalogues();
23696
24083
  return { requested: true };
23697
24084
  }),
@@ -23727,65 +24114,65 @@ var import_openapi6 = require("@orpc/openapi");
23727
24114
  init_cliError();
23728
24115
 
23729
24116
  // src/frontdoor/launchSchemas.ts
23730
- var import_node_path45 = __toESM(require("node:path"), 1);
23731
- var import_zod44 = require("zod");
24117
+ var import_node_path46 = __toESM(require("node:path"), 1);
24118
+ var import_zod45 = require("zod");
23732
24119
  init_statusline();
23733
24120
  init_claudeVersion();
23734
24121
  init_identity2();
23735
- var LaunchResolveInputSchema = import_zod44.z.strictObject({
23736
- path: import_zod44.z.string().min(1),
24122
+ var LaunchResolveInputSchema = import_zod45.z.strictObject({
24123
+ path: import_zod45.z.string().min(1),
23737
24124
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
23738
- argv: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())).optional(),
24125
+ argv: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())).optional(),
23739
24126
  /** 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. */
23740
- env: import_zod44.z.record(import_zod44.z.string(), import_zod44.z.string()).optional()
23741
- }).refine((input) => import_node_path45.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
23742
- var LaunchPoolDecisionSchema = import_zod44.z.strictObject({
23743
- name: import_zod44.z.string(),
23744
- reasons: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
24127
+ env: import_zod45.z.record(import_zod45.z.string(), import_zod45.z.string()).optional()
24128
+ }).refine((input) => import_node_path46.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
24129
+ var LaunchPoolDecisionSchema = import_zod45.z.strictObject({
24130
+ name: import_zod45.z.string(),
24131
+ reasons: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())),
23745
24132
  /** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
23746
- provider: import_zod44.z.string().optional(),
23747
- movedOff: import_zod44.z.strictObject({ identity: import_zod44.z.string(), reason: import_zod44.z.string() }).optional()
24133
+ provider: import_zod45.z.string().optional(),
24134
+ movedOff: import_zod45.z.strictObject({ identity: import_zod45.z.string(), reason: import_zod45.z.string() }).optional()
23748
24135
  });
23749
- var LaunchDecisionSchema = import_zod44.z.strictObject({
23750
- identity: import_zod44.z.string().optional(),
23751
- identityId: import_zod44.z.string().optional(),
23752
- identitySource: import_zod44.z.enum(IDENTITY_DECISION_SOURCES),
24136
+ var LaunchDecisionSchema = import_zod45.z.strictObject({
24137
+ identity: import_zod45.z.string().optional(),
24138
+ identityId: import_zod45.z.string().optional(),
24139
+ identitySource: import_zod45.z.enum(IDENTITY_DECISION_SOURCES),
23753
24140
  pool: LaunchPoolDecisionSchema.optional(),
23754
24141
  /** 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. */
23755
- configDirEscapeHatch: import_zod44.z.boolean(),
23756
- configDir: import_zod44.z.string().optional(),
23757
- configProfile: import_zod44.z.string().optional(),
23758
- configProfileSource: import_zod44.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
23759
- provider: import_zod44.z.string().optional()
23760
- });
23761
- var LaunchFlagsSchema = import_zod44.z.strictObject({
23762
- skipPermissions: import_zod44.z.boolean(),
23763
- remoteControl: import_zod44.z.boolean(),
23764
- headroom: import_zod44.z.boolean(),
23765
- trackUsage: import_zod44.z.boolean(),
23766
- pause: import_zod44.z.boolean(),
23767
- explain: import_zod44.z.boolean(),
24142
+ configDirEscapeHatch: import_zod45.z.boolean(),
24143
+ configDir: import_zod45.z.string().optional(),
24144
+ configProfile: import_zod45.z.string().optional(),
24145
+ configProfileSource: import_zod45.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
24146
+ provider: import_zod45.z.string().optional()
24147
+ });
24148
+ var LaunchFlagsSchema = import_zod45.z.strictObject({
24149
+ skipPermissions: import_zod45.z.boolean(),
24150
+ remoteControl: import_zod45.z.boolean(),
24151
+ headroom: import_zod45.z.boolean(),
24152
+ trackUsage: import_zod45.z.boolean(),
24153
+ pause: import_zod45.z.boolean(),
24154
+ explain: import_zod45.z.boolean(),
23768
24155
  /** How long the launch waits after its own output before it starts claude, in milliseconds. */
23769
- delayMs: import_zod44.z.number(),
24156
+ delayMs: import_zod45.z.number(),
23770
24157
  /** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
23771
- proxyBypass: import_zod44.z.array(import_zod44.z.string()).readonly(),
24158
+ proxyBypass: import_zod45.z.array(import_zod45.z.string()).readonly(),
23772
24159
  /** How the session's built-in statusline looks, when the launch configures any of it. */
23773
24160
  statusline: StatuslineSchema.optional()
23774
24161
  });
23775
- var LaunchResolveOutputSchema = import_zod44.z.strictObject({
24162
+ var LaunchResolveOutputSchema = import_zod45.z.strictObject({
23776
24163
  decision: LaunchDecisionSchema,
23777
24164
  flags: LaunchFlagsSchema,
23778
- claudeVersion: import_zod44.z.strictObject({ version: import_zod44.z.string(), source: import_zod44.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
24165
+ claudeVersion: import_zod45.z.strictObject({ version: import_zod45.z.string(), source: import_zod45.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
23779
24166
  /** The real `claude` binary the launch would spawn, on the door's host. */
23780
- bin: import_zod44.z.string(),
24167
+ bin: import_zod45.z.string(),
23781
24168
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
23782
- args: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
24169
+ args: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())),
23783
24170
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
23784
- credential: import_zod44.z.strictObject({ subject: import_zod44.z.enum(["provider", "identity"]), name: import_zod44.z.string(), summary: CredentialSummarySchema }).optional(),
23785
- routing: import_zod44.z.strictObject({ frontDoor: import_zod44.z.boolean(), headroom: import_zod44.z.boolean() }),
24171
+ credential: import_zod45.z.strictObject({ subject: import_zod45.z.enum(["provider", "identity"]), name: import_zod45.z.string(), summary: CredentialSummarySchema }).optional(),
24172
+ routing: import_zod45.z.strictObject({ frontDoor: import_zod45.z.boolean(), headroom: import_zod45.z.boolean() }),
23786
24173
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
23787
- environment: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string())),
23788
- warnings: import_zod44.z.readonly(import_zod44.z.array(import_zod44.z.string()))
24174
+ environment: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())),
24175
+ warnings: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string()))
23789
24176
  });
23790
24177
 
23791
24178
  // src/frontdoor/launchApi.ts
@@ -23821,24 +24208,24 @@ function createLaunchApiRouter(deps) {
23821
24208
  // src/frontdoor/agentTreesApi.ts
23822
24209
  var import_client6 = require("@orpc/client");
23823
24210
  var import_openapi7 = require("@orpc/openapi");
23824
- var import_zod45 = require("zod");
24211
+ var import_zod46 = require("zod");
23825
24212
  init_liveTasks();
23826
24213
  init_schema3();
23827
24214
  init_cliError();
23828
- var AgentTreesListInputSchema = import_zod45.z.strictObject({
24215
+ var AgentTreesListInputSchema = import_zod46.z.strictObject({
23829
24216
  /** Only this identity's sessions. */
23830
- identity: import_zod45.z.string().optional(),
24217
+ identity: import_zod46.z.string().optional(),
23831
24218
  /** Include sessions that spawned no agent and ran no workflow. */
23832
- all: import_zod45.z.boolean().optional()
24219
+ all: import_zod46.z.boolean().optional()
23833
24220
  });
23834
- var AgentTreesListOutputSchema = import_zod45.z.array(SessionSummarySchema);
23835
- var AgentTreesShowInputSchema = import_zod45.z.strictObject({
24221
+ var AgentTreesListOutputSchema = import_zod46.z.array(SessionSummarySchema);
24222
+ var AgentTreesShowInputSchema = import_zod46.z.strictObject({
23836
24223
  /** A session id, or an unambiguous prefix of one. */
23837
- session: import_zod45.z.string().min(1),
24224
+ session: import_zod46.z.string().min(1),
23838
24225
  /** Look only in this identity. */
23839
- identity: import_zod45.z.string().optional()
24226
+ identity: import_zod46.z.string().optional()
23840
24227
  });
23841
- var AgentTreesShowOutputSchema = import_zod45.z.strictObject({ identities: import_zod45.z.array(import_zod45.z.string()), ...MergedAgentTreeSchema.shape });
24228
+ var AgentTreesShowOutputSchema = import_zod46.z.strictObject({ identities: import_zod46.z.array(import_zod46.z.string()), ...MergedAgentTreeSchema.shape });
23842
24229
  function asBadRequest(error) {
23843
24230
  if (error instanceof CliError) {
23844
24231
  throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
@@ -23891,7 +24278,7 @@ var import_openapi8 = require("@orpc/openapi");
23891
24278
  var import_server4 = require("@orpc/server");
23892
24279
 
23893
24280
  // src/frontdoor/rcEventLog.ts
23894
- var import_zod46 = require("zod");
24281
+ var import_zod47 = require("zod");
23895
24282
 
23896
24283
  // src/frontdoor/eventHub.ts
23897
24284
  var DOOR_EVENT_BUFFER_EVENTS = 100;
@@ -24016,46 +24403,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
24016
24403
  var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
24017
24404
  var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
24018
24405
  var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
24019
- var transitionBase = { session: import_zod46.z.string(), at: import_zod46.z.number() };
24020
- var cursorFields = { cursor: import_zod46.z.string(), sequence: import_zod46.z.int().positive() };
24021
- var sessionAppearedShape = { kind: import_zod46.z.literal("session-appeared"), ...transitionBase };
24022
- var sessionEndedShape = { kind: import_zod46.z.literal("session-ended"), reason: import_zod46.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
24023
- var workerStateShape = { kind: import_zod46.z.literal("worker-state"), state: import_zod46.z.string(), previous: import_zod46.z.string().optional(), ...transitionBase };
24024
- var pendingBornShape = { kind: import_zod46.z.literal("pending-born"), requestId: import_zod46.z.string(), type: import_zod46.z.string(), summary: import_zod46.z.string(), ...transitionBase };
24025
- var pendingRetiredShape = { kind: import_zod46.z.literal("pending-retired"), requestId: import_zod46.z.string(), reason: import_zod46.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
24026
- var RcSessionTransitionSchema = import_zod46.z.discriminatedUnion("kind", [
24027
- import_zod46.z.strictObject(sessionAppearedShape),
24028
- import_zod46.z.strictObject(sessionEndedShape),
24029
- import_zod46.z.strictObject(workerStateShape),
24030
- import_zod46.z.strictObject(pendingBornShape),
24031
- import_zod46.z.strictObject(pendingRetiredShape)
24406
+ var transitionBase = { session: import_zod47.z.string(), at: import_zod47.z.number() };
24407
+ var cursorFields = { cursor: import_zod47.z.string(), sequence: import_zod47.z.int().positive() };
24408
+ var sessionAppearedShape = { kind: import_zod47.z.literal("session-appeared"), ...transitionBase };
24409
+ var sessionEndedShape = { kind: import_zod47.z.literal("session-ended"), reason: import_zod47.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
24410
+ var workerStateShape = { kind: import_zod47.z.literal("worker-state"), state: import_zod47.z.string(), previous: import_zod47.z.string().optional(), ...transitionBase };
24411
+ var pendingBornShape = { kind: import_zod47.z.literal("pending-born"), requestId: import_zod47.z.string(), type: import_zod47.z.string(), summary: import_zod47.z.string(), ...transitionBase };
24412
+ var pendingRetiredShape = { kind: import_zod47.z.literal("pending-retired"), requestId: import_zod47.z.string(), reason: import_zod47.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
24413
+ var RcSessionTransitionSchema = import_zod47.z.discriminatedUnion("kind", [
24414
+ import_zod47.z.strictObject(sessionAppearedShape),
24415
+ import_zod47.z.strictObject(sessionEndedShape),
24416
+ import_zod47.z.strictObject(workerStateShape),
24417
+ import_zod47.z.strictObject(pendingBornShape),
24418
+ import_zod47.z.strictObject(pendingRetiredShape)
24032
24419
  ]);
24033
24420
  var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
24034
24421
  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;
24035
24422
  var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
24036
- var RcSessionEventSchema = import_zod46.z.discriminatedUnion("kind", [
24037
- import_zod46.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
24038
- import_zod46.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
24039
- import_zod46.z.strictObject({ ...cursorFields, ...workerStateShape }),
24040
- import_zod46.z.strictObject({ ...cursorFields, ...pendingBornShape }),
24041
- import_zod46.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
24423
+ var RcSessionEventSchema = import_zod47.z.discriminatedUnion("kind", [
24424
+ import_zod47.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
24425
+ import_zod47.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
24426
+ import_zod47.z.strictObject({ ...cursorFields, ...workerStateShape }),
24427
+ import_zod47.z.strictObject({ ...cursorFields, ...pendingBornShape }),
24428
+ import_zod47.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
24042
24429
  ]);
24043
- var RcSessionEventsReadInputSchema = import_zod46.z.strictObject({
24430
+ var RcSessionEventsReadInputSchema = import_zod47.z.strictObject({
24044
24431
  /** The cursor of the last event the caller saw; every retained event when omitted. */
24045
- since: import_zod46.z.string().min(1).optional(),
24432
+ since: import_zod47.z.string().min(1).optional(),
24046
24433
  /** One `cse_` session id; every session when omitted. */
24047
- session: import_zod46.z.string().min(1).optional(),
24434
+ session: import_zod47.z.string().min(1).optional(),
24048
24435
  /** The most events one answer carries; every event after `since` when omitted. */
24049
- limit: import_zod46.z.int().positive().optional()
24436
+ limit: import_zod47.z.int().positive().optional()
24050
24437
  });
24051
24438
  var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
24052
24439
  /** 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. */
24053
- limit: import_zod46.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
24440
+ limit: import_zod47.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
24054
24441
  });
24055
24442
  var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
24056
- var RcSessionEventsReadOutputSchema = import_zod46.z.discriminatedUnion("status", [
24057
- import_zod46.z.strictObject({ status: import_zod46.z.literal("ok"), events: import_zod46.z.readonly(import_zod46.z.array(RcSessionEventSchema)), cursor: import_zod46.z.string(), more: import_zod46.z.boolean(), head: import_zod46.z.string() }),
24058
- import_zod46.z.strictObject({ status: import_zod46.z.literal("expired"), message: import_zod46.z.string(), head: import_zod46.z.string() })
24443
+ var RcSessionEventsReadOutputSchema = import_zod47.z.discriminatedUnion("status", [
24444
+ import_zod47.z.strictObject({ status: import_zod47.z.literal("ok"), events: import_zod47.z.readonly(import_zod47.z.array(RcSessionEventSchema)), cursor: import_zod47.z.string(), more: import_zod47.z.boolean(), head: import_zod47.z.string() }),
24445
+ import_zod47.z.strictObject({ status: import_zod47.z.literal("expired"), message: import_zod47.z.string(), head: import_zod47.z.string() })
24059
24446
  ]);
24060
24447
  var CURSOR_SEPARATOR = ".";
24061
24448
  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";
@@ -24571,6 +24958,7 @@ function createQuotaExpiringPublisher(hub, deps) {
24571
24958
 
24572
24959
  // src/index.ts
24573
24960
  init_rcSchemas();
24961
+ init_verifiedVersions();
24574
24962
 
24575
24963
  // src/frontdoor/rcLiveUsage.ts
24576
24964
  init_rcSchemas();
@@ -26242,7 +26630,7 @@ data: ${JSON.stringify(envelope)}
26242
26630
  }
26243
26631
 
26244
26632
  // src/frontdoor/rcSelfHostMint.ts
26245
- var import_node_path46 = __toESM(require("node:path"), 1);
26633
+ var import_node_path47 = __toESM(require("node:path"), 1);
26246
26634
  init_identityRecords();
26247
26635
  init_account();
26248
26636
  var CREDENTIALS_FILE2 = ".credentials.json";
@@ -26268,7 +26656,7 @@ function readJsonObject(fs17, file) {
26268
26656
  return isRecord16(parsed) ? parsed : void 0;
26269
26657
  }
26270
26658
  function readRcSelfHostRecord(fs17, frontdoorDir) {
26271
- const parsed = readJsonObject(fs17, import_node_path46.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
26659
+ const parsed = readJsonObject(fs17, import_node_path47.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
26272
26660
  if (parsed === void 0) {
26273
26661
  return void 0;
26274
26662
  }
@@ -26286,11 +26674,11 @@ function mintRcSelfHostCredential(deps) {
26286
26674
  if (id === void 0) {
26287
26675
  throw new Error(`No identity named "${deps.identity}".`);
26288
26676
  }
26289
- const identityDir = import_node_path46.default.join(deps.identitiesDir, id);
26290
- const credentialsFile = import_node_path46.default.join(identityDir, CREDENTIALS_FILE2);
26291
- const claudeJsonFile = import_node_path46.default.join(identityDir, CLAUDE_JSON2);
26292
- const recordDir = import_node_path46.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
26293
- const recordFile2 = import_node_path46.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
26677
+ const identityDir = import_node_path47.default.join(deps.identitiesDir, id);
26678
+ const credentialsFile = import_node_path47.default.join(identityDir, CREDENTIALS_FILE2);
26679
+ const claudeJsonFile = import_node_path47.default.join(identityDir, CLAUDE_JSON2);
26680
+ const recordDir = import_node_path47.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
26681
+ const recordFile2 = import_node_path47.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
26294
26682
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
26295
26683
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
26296
26684
  const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
@@ -26306,7 +26694,7 @@ function mintRcSelfHostCredential(deps) {
26306
26694
  const organizationUuid = deps.newUuid();
26307
26695
  const accountUuid = deps.newUuid();
26308
26696
  const mintedAt = new Date(deps.now()).toISOString();
26309
- deps.fs.mkdirPrivate(import_node_path46.default.dirname(credentialsFile));
26697
+ deps.fs.mkdirPrivate(import_node_path47.default.dirname(credentialsFile));
26310
26698
  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)}
26311
26699
  `);
26312
26700
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
@@ -26342,7 +26730,7 @@ function mintRcSelfHostCredential(deps) {
26342
26730
  init_ensure2();
26343
26731
 
26344
26732
  // src/frontdoor/liveSessionRegistry.ts
26345
- var import_node_path47 = __toESM(require("node:path"), 1);
26733
+ var import_node_path48 = __toESM(require("node:path"), 1);
26346
26734
  init_capability();
26347
26735
  init_state();
26348
26736
  function sameStat(recorded, current) {
@@ -26366,7 +26754,7 @@ function createLiveSessionRegistry(ports) {
26366
26754
  const load = (name, stat) => {
26367
26755
  known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
26368
26756
  };
26369
- const statOf = (name) => fs17.lstat(import_node_path47.default.join(sessionsDir, name));
26757
+ const statOf = (name) => fs17.lstat(import_node_path48.default.join(sessionsDir, name));
26370
26758
  const reconcile = () => {
26371
26759
  const names = new Set(recordNames());
26372
26760
  let changed = false;
@@ -26440,8 +26828,8 @@ init_poolPick();
26440
26828
  init_liveTasks();
26441
26829
 
26442
26830
  // src/agents/read.ts
26443
- var import_node_path48 = __toESM(require("node:path"), 1);
26444
- var import_zod47 = require("zod");
26831
+ var import_node_path49 = __toESM(require("node:path"), 1);
26832
+ var import_zod48 = require("zod");
26445
26833
  init_schema3();
26446
26834
  var PROJECTS_DIR = "projects";
26447
26835
  var TASKS_DIR = "tasks";
@@ -26467,15 +26855,15 @@ function parseEntry2(project, entry) {
26467
26855
  }
26468
26856
  function listSessions2(fs17, configDir) {
26469
26857
  const found = [];
26470
- for (const project of fs17.readdir(import_node_path48.default.join(configDir, PROJECTS_DIR))) {
26471
- const projectDir = import_node_path48.default.join(configDir, PROJECTS_DIR, project);
26858
+ for (const project of fs17.readdir(import_node_path49.default.join(configDir, PROJECTS_DIR))) {
26859
+ const projectDir = import_node_path49.default.join(configDir, PROJECTS_DIR, project);
26472
26860
  const entries = /* @__PURE__ */ new Set();
26473
26861
  for (const name of fs17.readdir(projectDir)) {
26474
26862
  if (name.endsWith(TRANSCRIPT_SUFFIX)) {
26475
26863
  entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
26476
26864
  continue;
26477
26865
  }
26478
- const children = fs17.readdir(import_node_path48.default.join(projectDir, name));
26866
+ const children = fs17.readdir(import_node_path49.default.join(projectDir, name));
26479
26867
  if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
26480
26868
  entries.add(name);
26481
26869
  }
@@ -26495,8 +26883,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
26495
26883
  const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
26496
26884
  located.push({
26497
26885
  id,
26498
- metaPath: import_node_path48.default.join(relativeDir, name),
26499
- transcriptPath: import_node_path48.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
26886
+ metaPath: import_node_path49.default.join(relativeDir, name),
26887
+ transcriptPath: import_node_path49.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
26500
26888
  workflowRunId
26501
26889
  });
26502
26890
  }
@@ -26539,7 +26927,7 @@ function describeFailure(error) {
26539
26927
  }
26540
26928
  function readFileOrReport(fs17, configDir, relative, report) {
26541
26929
  try {
26542
- return fs17.readFileUtf8(import_node_path48.default.join(configDir, relative));
26930
+ return fs17.readFileUtf8(import_node_path49.default.join(configDir, relative));
26543
26931
  } catch (error) {
26544
26932
  report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
26545
26933
  return void 0;
@@ -26547,7 +26935,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
26547
26935
  }
26548
26936
  function listDirOrReport(fs17, configDir, relative, report) {
26549
26937
  try {
26550
- return fs17.readdir(import_node_path48.default.join(configDir, relative));
26938
+ return fs17.readdir(import_node_path49.default.join(configDir, relative));
26551
26939
  } catch (error) {
26552
26940
  report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
26553
26941
  return [];
@@ -26561,28 +26949,28 @@ function parseJson2(text) {
26561
26949
  return void 0;
26562
26950
  }
26563
26951
  }
26564
- var TaskFileSchema = import_zod47.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod47.z.array(import_zod47.z.string()).default([]), blockedBy: import_zod47.z.array(import_zod47.z.string()).default([]) });
26565
- var WorkflowRunFileSchema = import_zod47.z.object({
26566
- runId: import_zod47.z.string(),
26567
- workflowName: import_zod47.z.string().optional(),
26568
- status: import_zod47.z.string().optional(),
26569
- startTime: import_zod47.z.number().optional(),
26570
- phases: import_zod47.z.array(import_zod47.z.object({ title: import_zod47.z.string() })).default([]),
26571
- summary: import_zod47.z.string().optional()
26952
+ var TaskFileSchema = import_zod48.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod48.z.array(import_zod48.z.string()).default([]), blockedBy: import_zod48.z.array(import_zod48.z.string()).default([]) });
26953
+ var WorkflowRunFileSchema = import_zod48.z.object({
26954
+ runId: import_zod48.z.string(),
26955
+ workflowName: import_zod48.z.string().optional(),
26956
+ status: import_zod48.z.string().optional(),
26957
+ startTime: import_zod48.z.number().optional(),
26958
+ phases: import_zod48.z.array(import_zod48.z.object({ title: import_zod48.z.string() })).default([]),
26959
+ summary: import_zod48.z.string().optional()
26572
26960
  });
26573
26961
  function summariseSession(fs17, configDir, ref) {
26574
- const sessionRelative = import_node_path48.default.join(PROJECTS_DIR, ref.project, ref.entry);
26575
- const subagentsRelative = import_node_path48.default.join(sessionRelative, SUBAGENTS_DIR);
26576
- const workflowsUnderSubagents = import_node_path48.default.join(subagentsRelative, WORKFLOWS_DIR);
26962
+ const sessionRelative = import_node_path49.default.join(PROJECTS_DIR, ref.project, ref.entry);
26963
+ const subagentsRelative = import_node_path49.default.join(sessionRelative, SUBAGENTS_DIR);
26964
+ const workflowsUnderSubagents = import_node_path49.default.join(subagentsRelative, WORKFLOWS_DIR);
26577
26965
  const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
26578
- let agentCount = fs17.readdir(import_node_path48.default.join(configDir, subagentsRelative)).filter(isMeta).length;
26579
- for (const runDir of fs17.readdir(import_node_path48.default.join(configDir, workflowsUnderSubagents))) {
26966
+ let agentCount = fs17.readdir(import_node_path49.default.join(configDir, subagentsRelative)).filter(isMeta).length;
26967
+ for (const runDir of fs17.readdir(import_node_path49.default.join(configDir, workflowsUnderSubagents))) {
26580
26968
  if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
26581
- agentCount += fs17.readdir(import_node_path48.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
26969
+ agentCount += fs17.readdir(import_node_path49.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
26582
26970
  }
26583
26971
  }
26584
- const workflowRunCount = fs17.readdir(import_node_path48.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
26585
- const transcript = fs17.lstat(import_node_path48.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
26972
+ const workflowRunCount = fs17.readdir(import_node_path49.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
26973
+ const transcript = fs17.lstat(import_node_path49.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
26586
26974
  return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
26587
26975
  }
26588
26976
  function readSessionAgentTree(fs17, configDir, ref, options = {}) {
@@ -26590,13 +26978,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
26590
26978
  const report = (problem) => {
26591
26979
  problems.push(problem);
26592
26980
  };
26593
- const sessionRelative = import_node_path48.default.join(PROJECTS_DIR, ref.project, ref.entry);
26594
- const subagentsRelative = import_node_path48.default.join(sessionRelative, SUBAGENTS_DIR);
26595
- const workflowsUnderSubagents = import_node_path48.default.join(subagentsRelative, WORKFLOWS_DIR);
26981
+ const sessionRelative = import_node_path49.default.join(PROJECTS_DIR, ref.project, ref.entry);
26982
+ const subagentsRelative = import_node_path49.default.join(sessionRelative, SUBAGENTS_DIR);
26983
+ const workflowsUnderSubagents = import_node_path49.default.join(subagentsRelative, WORKFLOWS_DIR);
26596
26984
  const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
26597
26985
  for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
26598
26986
  if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
26599
- located.push(...locateAgents(fs17, configDir, import_node_path48.default.join(workflowsUnderSubagents, runDir), runDir, report));
26987
+ located.push(...locateAgents(fs17, configDir, import_node_path49.default.join(workflowsUnderSubagents, runDir), runDir, report));
26600
26988
  }
26601
26989
  }
26602
26990
  const agents = /* @__PURE__ */ new Map();
@@ -26637,7 +27025,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
26637
27025
  superseded: ref.superseded,
26638
27026
  agents: roots.sort().map(build),
26639
27027
  tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
26640
- workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path48.default.join(sessionRelative, WORKFLOWS_DIR), report),
27028
+ workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path49.default.join(sessionRelative, WORKFLOWS_DIR), report),
26641
27029
  problems
26642
27030
  };
26643
27031
  }
@@ -26702,12 +27090,12 @@ function ownTaskLists(sessionId) {
26702
27090
  function readTasks(fs17, configDir, ownLists, sharedLists, report) {
26703
27091
  const tasks = [];
26704
27092
  [...ownLists, ...sharedLists].forEach((scope, index) => {
26705
- const relativeDir = import_node_path48.default.join(TASKS_DIR, scope);
27093
+ const relativeDir = import_node_path49.default.join(TASKS_DIR, scope);
26706
27094
  for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
26707
27095
  if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
26708
27096
  continue;
26709
27097
  }
26710
- const relative = import_node_path48.default.join(relativeDir, name);
27098
+ const relative = import_node_path49.default.join(relativeDir, name);
26711
27099
  const text = readFileOrReport(fs17, configDir, relative, report);
26712
27100
  const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
26713
27101
  if (parsed.success) {
@@ -26725,7 +27113,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
26725
27113
  if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
26726
27114
  continue;
26727
27115
  }
26728
- const relative = import_node_path48.default.join(relativeDir, name);
27116
+ const relative = import_node_path49.default.join(relativeDir, name);
26729
27117
  const text = readFileOrReport(fs17, configDir, relative, report);
26730
27118
  const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
26731
27119
  if (!parsed.success) {
@@ -26741,7 +27129,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
26741
27129
  }
26742
27130
 
26743
27131
  // src/agents/sessions.ts
26744
- var import_node_path49 = __toESM(require("node:path"), 1);
27132
+ var import_node_path50 = __toESM(require("node:path"), 1);
26745
27133
  init_cliError();
26746
27134
  var SessionLookupError = class extends CliError {
26747
27135
  constructor(message) {
@@ -26753,7 +27141,7 @@ function historyStores(fs17, configDirOf, identities) {
26753
27141
  const byRealPath = /* @__PURE__ */ new Map();
26754
27142
  for (const identity of identities) {
26755
27143
  const configDir = configDirOf(identity);
26756
- const real = fs17.realpath(import_node_path49.default.join(configDir, "projects"));
27144
+ const real = fs17.realpath(import_node_path50.default.join(configDir, "projects"));
26757
27145
  if (real === void 0) {
26758
27146
  continue;
26759
27147
  }
@@ -26841,6 +27229,81 @@ init_names();
26841
27229
  init_providersStore();
26842
27230
  init_poolStore();
26843
27231
  init_directoryRulesStore();
27232
+
27233
+ // src/doctorFormat.ts
27234
+ var SECTION_TITLES = {
27235
+ models: "Virtual models",
27236
+ "ambient-credential": "Ambient-credential exposure",
27237
+ "binary-discovery": "Claude Code binary discovery",
27238
+ "claude-shim": "`claude` command shim",
27239
+ "path-resolution": "PATH resolution",
27240
+ "legacy-name": "Former `claude-use` name",
27241
+ "config-profile": "Configuration profiles",
27242
+ identity: "Identities",
27243
+ "sign-in": "Sign-in",
27244
+ "farm-links": "Farm links",
27245
+ pool: "Pools",
27246
+ provider: "Providers",
27247
+ keychain: "macOS Keychain",
27248
+ "directory-rules": "Directory rules",
27249
+ "global-config": "Global config",
27250
+ headroom: "Headroom daemon",
27251
+ frontdoor: "Front door",
27252
+ "categories-local": "categories.local.json",
27253
+ "active-identity": "Active identity"
27254
+ };
27255
+ var SECTION_ORDER = [
27256
+ "ambient-credential",
27257
+ "binary-discovery",
27258
+ "claude-shim",
27259
+ "path-resolution",
27260
+ "legacy-name",
27261
+ "config-profile",
27262
+ "identity",
27263
+ "sign-in",
27264
+ "farm-links",
27265
+ "pool",
27266
+ "provider",
27267
+ "keychain",
27268
+ "directory-rules",
27269
+ "global-config",
27270
+ "models",
27271
+ "headroom",
27272
+ "frontdoor",
27273
+ "categories-local",
27274
+ "active-identity"
27275
+ ];
27276
+ function severityPrefix(severity) {
27277
+ switch (severity) {
27278
+ case "pass":
27279
+ return "[PASS]";
27280
+ case "warn":
27281
+ return "[WARN]";
27282
+ case "fail":
27283
+ return "[FAIL]";
27284
+ default:
27285
+ return severity;
27286
+ }
27287
+ }
27288
+ function formatDoctorReport(report) {
27289
+ const lines = [];
27290
+ for (const section of SECTION_ORDER) {
27291
+ const sectionFindings = report.findings.filter((finding) => finding.section === section);
27292
+ if (sectionFindings.length === 0) {
27293
+ continue;
27294
+ }
27295
+ lines.push("", `${SECTION_TITLES[section]}:`);
27296
+ for (const finding of sectionFindings) {
27297
+ const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
27298
+ lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
27299
+ }
27300
+ }
27301
+ const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
27302
+ lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
27303
+ return lines;
27304
+ }
27305
+
27306
+ // src/index.ts
26844
27307
  init_launcher();
26845
27308
  init_spawn();
26846
27309
  init_launchWiring();
@@ -26850,7 +27313,7 @@ init_launcher();
26850
27313
  init_launchWiring();
26851
27314
 
26852
27315
  // src/poolUsageRefresh.ts
26853
- var import_node_os13 = __toESM(require("node:os"), 1);
27316
+ var import_node_os14 = __toESM(require("node:os"), 1);
26854
27317
  init_load();
26855
27318
  init_launchWiring();
26856
27319
  init_argv();
@@ -26913,7 +27376,7 @@ async function refreshPoolUsage(params) {
26913
27376
  }
26914
27377
  function poolSelectedByLaunch(options) {
26915
27378
  const paths = options.paths ?? resolveLayoutPaths();
26916
- const loaded = loadCascadeInput({ paths, home: import_node_os13.default.homedir(), cwd: options.cwd, read: cosmiconfigReader() });
27379
+ const loaded = loadCascadeInput({ paths, home: import_node_os14.default.homedir(), cwd: options.cwd, read: cosmiconfigReader() });
26917
27380
  return decideIdentity({
26918
27381
  env: options.env,
26919
27382
  argv0Identity: parseLauncherArgv(options.argv).identity,