agent-shim 11.87.5 → 11.88.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5164,7 +5164,7 @@ var init_package = __esm({
5164
5164
  "package.json"() {
5165
5165
  package_default = {
5166
5166
  name: "agent-shim",
5167
- version: "11.87.5",
5167
+ version: "11.88.1",
5168
5168
  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.",
5169
5169
  license: "MIT",
5170
5170
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -6722,8 +6722,10 @@ var init_realPorts = __esm({
6722
6722
  init_ensure();
6723
6723
  init_supervisor2();
6724
6724
  init_state2();
6725
+ init_sameDirectory();
6725
6726
  init_logStyle();
6726
6727
  realFsPort = {
6728
+ sameDirectory,
6727
6729
  fileRevision(filePath) {
6728
6730
  try {
6729
6731
  const stat = fs4.statSync(filePath, { bigint: true });
@@ -7155,19 +7157,21 @@ function readActiveIdentity(fs17, activeIdentityFile) {
7155
7157
  function isNonEmpty(value) {
7156
7158
  return value !== void 0 && value !== "";
7157
7159
  }
7158
- function selected(selector, source) {
7160
+ function selected(selector, source, supersededConfigDir) {
7159
7161
  if (!IdentitySelectorSchema.safeParse(selector).success) {
7160
7162
  throw new UnsafeNameError(selector, "identity", `${FILE_NAME_RULE}, or be pool:<name> for a pool`, IDENTITY_SOURCE_LABELS[source]);
7161
7163
  }
7162
7164
  const pool = poolNameOf(selector);
7163
- return pool === void 0 ? { name: selector, source, configDirEscapeHatch: false } : { pool, source, configDirEscapeHatch: false };
7165
+ const superseded = supersededConfigDir === void 0 ? {} : { supersededConfigDir };
7166
+ return pool === void 0 ? { name: selector, source, configDirEscapeHatch: false, ...superseded } : { pool, source, configDirEscapeHatch: false, ...superseded };
7164
7167
  }
7165
7168
  function decideIdentity(params) {
7166
- if (isNonEmpty(params.env.CLAUDE_CONFIG_DIR)) {
7167
- return { source: "config-dir-escape-hatch", configDirEscapeHatch: true };
7168
- }
7169
+ const inheritedConfigDir = isNonEmpty(params.env.CLAUDE_CONFIG_DIR) ? params.env.CLAUDE_CONFIG_DIR : void 0;
7169
7170
  if (isNonEmpty(params.argv0Identity)) {
7170
- return selected(params.argv0Identity, "argv");
7171
+ return selected(params.argv0Identity, "argv", inheritedConfigDir);
7172
+ }
7173
+ if (inheritedConfigDir !== void 0) {
7174
+ return { source: "config-dir-escape-hatch", configDirEscapeHatch: true };
7171
7175
  }
7172
7176
  if (isNonEmpty(params.env.AGENT_SHIM_IDENTITY)) {
7173
7177
  return selected(params.env.AGENT_SHIM_IDENTITY, "env");
@@ -7245,7 +7249,7 @@ var init_identity = __esm({
7245
7249
  init_identityRecords();
7246
7250
  init_sameDirectory();
7247
7251
  IDENTITY_DECISION_SOURCES = [
7248
- /** `CLAUDE_CONFIG_DIR` was already set: identity resolution is skipped entirely and the real binary uses whatever it already points to. */
7252
+ /** `CLAUDE_CONFIG_DIR` was already set and nothing on the command line names an identity: identity resolution is skipped entirely and the real binary uses whatever it already points to. */
7249
7253
  "config-dir-escape-hatch",
7250
7254
  /** A leading `@name` argv[0] positional, or its explicit form `--identity <name>`. */
7251
7255
  "argv",
@@ -11532,6 +11536,156 @@ var init_claudeVersion = __esm({
11532
11536
  }
11533
11537
  });
11534
11538
 
11539
+ // src/headroom/headers.ts
11540
+ function mergeAnthropicCustomHeaders(existing, additions) {
11541
+ const merged = /* @__PURE__ */ new Map();
11542
+ for (const block of existing) {
11543
+ if (block === void 0) {
11544
+ continue;
11545
+ }
11546
+ for (const line of block.split("\n")) {
11547
+ const entry = parseCustomHeaderLine(line);
11548
+ if (entry === void 0) {
11549
+ continue;
11550
+ }
11551
+ merged.set(entry.name, entry.value);
11552
+ }
11553
+ }
11554
+ for (const entry of additions) {
11555
+ merged.set(entry.name, entry.value);
11556
+ }
11557
+ return [...merged].map(([name, value]) => `${name}: ${value}`).join("\n");
11558
+ }
11559
+ function parseAnthropicCustomHeaders(block) {
11560
+ return block.split("\n").flatMap((line) => {
11561
+ const entry = parseCustomHeaderLine(line);
11562
+ return entry === void 0 ? [] : [entry];
11563
+ });
11564
+ }
11565
+ function withoutAnthropicCustomHeaders(block, remove) {
11566
+ const lines = block.split("\n");
11567
+ const kept = lines.filter((line) => {
11568
+ const entry = parseCustomHeaderLine(line);
11569
+ return entry === void 0 || !remove(entry);
11570
+ });
11571
+ return kept.length === lines.length ? block : kept.join("\n");
11572
+ }
11573
+ function parseCustomHeaderLine(line) {
11574
+ const trimmed = line.trim();
11575
+ if (trimmed === "") {
11576
+ return void 0;
11577
+ }
11578
+ const colon = trimmed.indexOf(":");
11579
+ if (colon <= 0) {
11580
+ return void 0;
11581
+ }
11582
+ return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
11583
+ }
11584
+ var init_headers = __esm({
11585
+ "src/headroom/headers.ts"() {
11586
+ "use strict";
11587
+ }
11588
+ });
11589
+
11590
+ // src/launcher/injected.ts
11591
+ import { createHash as createHash8 } from "node:crypto";
11592
+ import { z as z24 } from "zod";
11593
+ function listKey(list) {
11594
+ return `${list},appended`;
11595
+ }
11596
+ function digest2(value) {
11597
+ return createHash8("sha256").update(value).digest("hex");
11598
+ }
11599
+ function recordedDigests(env) {
11600
+ const raw = env[INJECTED_ENV];
11601
+ if (raw === void 0 || raw === "") {
11602
+ return {};
11603
+ }
11604
+ let parsed;
11605
+ try {
11606
+ parsed = JSON.parse(raw);
11607
+ } catch {
11608
+ return {};
11609
+ }
11610
+ const result = InjectedSchema.safeParse(parsed);
11611
+ return result.success ? result.data : {};
11612
+ }
11613
+ function recordInjections(base) {
11614
+ const env = { ...base };
11615
+ const digests = new Map(Object.entries(recordedDigests(env)));
11616
+ return {
11617
+ env,
11618
+ set: (name, value) => {
11619
+ env[name] = value;
11620
+ digests.set(name, digest2(value));
11621
+ },
11622
+ unset: (name) => {
11623
+ env[name] = void 0;
11624
+ digests.delete(name);
11625
+ },
11626
+ recordHeaders: (names) => {
11627
+ const block = env[CUSTOM_HEADERS_ENV];
11628
+ for (const entry of block === void 0 ? [] : parseAnthropicCustomHeaders(block)) {
11629
+ if (names.includes(entry.name)) {
11630
+ digests.set(`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`, digest2(entry.value));
11631
+ }
11632
+ }
11633
+ },
11634
+ recordBypassHosts: (list, hosts) => {
11635
+ const recordedHosts = [.../* @__PURE__ */ new Set([...digests.get(listKey(list))?.split(",") ?? [], ...hosts.map((host) => host.trim().toLowerCase()).filter((host) => host !== "")])];
11636
+ if (recordedHosts.length > 0) {
11637
+ digests.set(listKey(list), recordedHosts.join(","));
11638
+ }
11639
+ },
11640
+ finish: () => {
11641
+ if (digests.size > 0) {
11642
+ env[INJECTED_ENV] = JSON.stringify(Object.fromEntries(digests));
11643
+ }
11644
+ }
11645
+ };
11646
+ }
11647
+ function withoutRecordedHosts(list, value, digests) {
11648
+ const recordedHosts = new Set(digests[listKey(list)]?.split(","));
11649
+ const entries = value.split(",");
11650
+ const kept = entries.filter((entry) => !recordedHosts.has(entry.trim().toLowerCase()));
11651
+ return kept.length === entries.length ? value : kept.join(",");
11652
+ }
11653
+ function launchEnvironment(env, configDirEscapeHatch) {
11654
+ return configDirEscapeHatch ? env : withoutInjected(env);
11655
+ }
11656
+ function withoutInjected(env) {
11657
+ const digests = recordedDigests(env);
11658
+ const entries = Object.entries(env).flatMap(([name, value]) => {
11659
+ if (name === INJECTED_ENV) {
11660
+ return [];
11661
+ }
11662
+ if (value === void 0) {
11663
+ return [[name, value]];
11664
+ }
11665
+ if (name === CUSTOM_HEADERS_ENV) {
11666
+ const remaining = withoutAnthropicCustomHeaders(value, (entry) => digests[`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`] === digest2(entry.value));
11667
+ return remaining !== value && remaining.trim() === "" ? [] : [[name, remaining]];
11668
+ }
11669
+ if (name === "NO_PROXY" || name === "no_proxy") {
11670
+ const remaining = withoutRecordedHosts(name, value, digests);
11671
+ return remaining !== value && remaining.split(",").every((entry) => entry.trim() === "") ? [] : [[name, remaining]];
11672
+ }
11673
+ return digests[name] === digest2(value) ? [] : [[name, value]];
11674
+ });
11675
+ return Object.fromEntries(entries);
11676
+ }
11677
+ var INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
11678
+ var init_injected = __esm({
11679
+ "src/launcher/injected.ts"() {
11680
+ "use strict";
11681
+ init_headers();
11682
+ INJECTED_ENV = "AGENT_SHIM_INJECTED";
11683
+ CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
11684
+ HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
11685
+ InjectedSchema = z24.record(z24.string(), z24.string());
11686
+ }
11687
+ });
11688
+
11535
11689
  // src/launcher/guard.ts
11536
11690
  function detectAmbientCredential(env, injected) {
11537
11691
  for (const variable of AMBIENT_CREDENTIAL_VARS) {
@@ -11570,10 +11724,22 @@ function evaluateAmbientCredentialGuard(params) {
11570
11724
  message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
11571
11725
  };
11572
11726
  }
11727
+ function ambientCredentialFinding(env) {
11728
+ const named = detectAmbientCredential(launchEnvironment(env, false));
11729
+ if (named !== void 0) {
11730
+ return { severity: "warn", message: formatAmbientCredentialGuardMessage(named.variable) };
11731
+ }
11732
+ const bare = env.CLAUDE_CONFIG_DIR === void 0 || env.CLAUDE_CONFIG_DIR === "" ? void 0 : detectAmbientCredential(env);
11733
+ if (bare !== void 0) {
11734
+ return { severity: "warn", message: `${bare.variable} was set in this session by the launcher that started it. A launch that names an identity drops it, but a launch naming none keeps the session's CLAUDE_CONFIG_DIR and environment and is refused. Name an identity, as in \`claude @<name>\`.` };
11735
+ }
11736
+ return { severity: "pass", message: "No ambient-credential environment variable is set." };
11737
+ }
11573
11738
  var AMBIENT_CREDENTIAL_VARS;
11574
11739
  var init_guard = __esm({
11575
11740
  "src/launcher/guard.ts"() {
11576
11741
  "use strict";
11742
+ init_injected();
11577
11743
  AMBIENT_CREDENTIAL_VARS = [
11578
11744
  "ANTHROPIC_API_KEY",
11579
11745
  "ANTHROPIC_AUTH_TOKEN",
@@ -11652,7 +11818,7 @@ var init_commandDeps = __esm({
11652
11818
  // src/claudeShim.ts
11653
11819
  import fs11 from "node:fs";
11654
11820
  import path37 from "node:path";
11655
- import { z as z28 } from "zod";
11821
+ import { z as z29 } from "zod";
11656
11822
  function commandFilename(ownExecutablePath, commandName) {
11657
11823
  return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
11658
11824
  }
@@ -11702,35 +11868,35 @@ var init_claudeShim = __esm({
11702
11868
  init_store();
11703
11869
  init_realPorts();
11704
11870
  init_cliError();
11705
- ClaudeShimStateSchema = z28.strictObject({
11706
- targetPath: z28.string().min(1),
11707
- method: z28.enum(["hardlink", "copy"]),
11708
- installedAtMs: z28.number()
11871
+ ClaudeShimStateSchema = z29.strictObject({
11872
+ targetPath: z29.string().min(1),
11873
+ method: z29.enum(["hardlink", "copy"]),
11874
+ installedAtMs: z29.number()
11709
11875
  });
11710
11876
  nodeLinkFs = { link: fs11.linkSync, copyFile: fs11.copyFileSync, chmod: fs11.chmodSync };
11711
11877
  }
11712
11878
  });
11713
11879
 
11714
11880
  // src/codex/auth.ts
11715
- import { z as z29 } from "zod";
11881
+ import { z as z30 } from "zod";
11716
11882
  var AuthFileSchema, TokenGrantSchema, CodexAuthError;
11717
11883
  var init_auth = __esm({
11718
11884
  "src/codex/auth.ts"() {
11719
11885
  "use strict";
11720
- AuthFileSchema = z29.looseObject({
11721
- tokens: z29.looseObject({
11722
- access_token: z29.string().optional(),
11723
- refresh_token: z29.string().optional(),
11724
- id_token: z29.string().optional(),
11725
- account_id: z29.string().optional()
11886
+ AuthFileSchema = z30.looseObject({
11887
+ tokens: z30.looseObject({
11888
+ access_token: z30.string().optional(),
11889
+ refresh_token: z30.string().optional(),
11890
+ id_token: z30.string().optional(),
11891
+ account_id: z30.string().optional()
11726
11892
  }).nullish(),
11727
- last_refresh: z29.string().optional()
11893
+ last_refresh: z30.string().optional()
11728
11894
  });
11729
- TokenGrantSchema = z29.looseObject({
11730
- access_token: z29.string().min(1).optional(),
11731
- refresh_token: z29.string().min(1).optional(),
11732
- id_token: z29.string().min(1).optional(),
11733
- account_id: z29.string().min(1).optional()
11895
+ TokenGrantSchema = z30.looseObject({
11896
+ access_token: z30.string().min(1).optional(),
11897
+ refresh_token: z30.string().min(1).optional(),
11898
+ id_token: z30.string().min(1).optional(),
11899
+ account_id: z30.string().min(1).optional()
11734
11900
  });
11735
11901
  CodexAuthError = class extends Error {
11736
11902
  constructor(message) {
@@ -11742,7 +11908,7 @@ var init_auth = __esm({
11742
11908
  });
11743
11909
 
11744
11910
  // src/codex/siwc.ts
11745
- import { z as z30 } from "zod";
11911
+ import { z as z31 } from "zod";
11746
11912
  var SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
11747
11913
  var init_siwc = __esm({
11748
11914
  "src/codex/siwc.ts"() {
@@ -11750,28 +11916,28 @@ var init_siwc = __esm({
11750
11916
  SIWC_RESOURCE = "https://api.openai.com/v1";
11751
11917
  SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
11752
11918
  SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
11753
- TokenResponseSchema = z30.looseObject({
11754
- access_token: z30.string().min(1),
11755
- refresh_token: z30.string().min(1).optional(),
11756
- id_token: z30.string().min(1).optional(),
11757
- expires_in: z30.number().positive(),
11758
- scope: z30.string().optional()
11919
+ TokenResponseSchema = z31.looseObject({
11920
+ access_token: z31.string().min(1),
11921
+ refresh_token: z31.string().min(1).optional(),
11922
+ id_token: z31.string().min(1).optional(),
11923
+ expires_in: z31.number().positive(),
11924
+ scope: z31.string().optional()
11759
11925
  });
11760
- JwtHeaderSchema = z30.looseObject({ alg: z30.string(), kid: z30.string().optional() });
11761
- IdTokenClaimsSchema = z30.looseObject({
11762
- iss: z30.string(),
11763
- sub: z30.string().min(1),
11764
- aud: z30.union([z30.string(), z30.array(z30.string())]),
11765
- exp: z30.number(),
11766
- nonce: z30.string().optional(),
11767
- email: z30.string().optional()
11926
+ JwtHeaderSchema = z31.looseObject({ alg: z31.string(), kid: z31.string().optional() });
11927
+ IdTokenClaimsSchema = z31.looseObject({
11928
+ iss: z31.string(),
11929
+ sub: z31.string().min(1),
11930
+ aud: z31.union([z31.string(), z31.array(z31.string())]),
11931
+ exp: z31.number(),
11932
+ nonce: z31.string().optional(),
11933
+ email: z31.string().optional()
11768
11934
  });
11769
- JwksSchema = z30.object({ keys: z30.array(z30.looseObject({ kid: z30.string().optional(), kty: z30.string() })) });
11935
+ JwksSchema = z31.object({ keys: z31.array(z31.looseObject({ kid: z31.string().optional(), kty: z31.string() })) });
11770
11936
  }
11771
11937
  });
11772
11938
 
11773
11939
  // src/codex/siwcStore.ts
11774
- import { z as z31 } from "zod";
11940
+ import { z as z32 } from "zod";
11775
11941
  function parseSiwcFile(raw, filePath) {
11776
11942
  let json;
11777
11943
  try {
@@ -11791,18 +11957,18 @@ var init_siwcStore = __esm({
11791
11957
  "use strict";
11792
11958
  init_auth();
11793
11959
  init_siwc();
11794
- SiwcGrantSchema = z31.strictObject({
11795
- clientId: z31.string().min(1),
11796
- sub: z31.string().min(1),
11797
- email: z31.string().optional(),
11798
- idToken: z31.string().min(1),
11799
- accessToken: z31.string().min(1),
11800
- refreshToken: z31.string().min(1),
11801
- scopes: z31.array(z31.string()).readonly(),
11960
+ SiwcGrantSchema = z32.strictObject({
11961
+ clientId: z32.string().min(1),
11962
+ sub: z32.string().min(1),
11963
+ email: z32.string().optional(),
11964
+ idToken: z32.string().min(1),
11965
+ accessToken: z32.string().min(1),
11966
+ refreshToken: z32.string().min(1),
11967
+ scopes: z32.array(z32.string()).readonly(),
11802
11968
  /** When the access token stops working, in milliseconds since the epoch. */
11803
- expiresAt: z31.number()
11969
+ expiresAt: z32.number()
11804
11970
  });
11805
- SiwcFileSchema = z31.strictObject({ registeredClientId: z31.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
11971
+ SiwcFileSchema = z32.strictObject({ registeredClientId: z32.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
11806
11972
  }
11807
11973
  });
11808
11974
 
@@ -11860,9 +12026,9 @@ var init_modelsStore = __esm({
11860
12026
  });
11861
12027
 
11862
12028
  // src/codex/catalogueCredential.ts
11863
- import { createHash as createHash8 } from "node:crypto";
12029
+ import { createHash as createHash9 } from "node:crypto";
11864
12030
  import path40 from "node:path";
11865
- import { z as z32 } from "zod";
12031
+ import { z as z33 } from "zod";
11866
12032
  function parseCatalogueBinding(raw) {
11867
12033
  if (raw === void 0) return void 0;
11868
12034
  try {
@@ -11873,7 +12039,7 @@ function parseCatalogueBinding(raw) {
11873
12039
  }
11874
12040
  }
11875
12041
  function catalogueCredentialFingerprint(cli, token, accountId) {
11876
- return createHash8("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
12042
+ return createHash9("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
11877
12043
  }
11878
12044
  function cliCatalogueFingerprint(raw) {
11879
12045
  if (raw === void 0) return void 0;
@@ -11903,7 +12069,7 @@ var init_catalogueCredential = __esm({
11903
12069
  "src/codex/catalogueCredential.ts"() {
11904
12070
  "use strict";
11905
12071
  init_siwcStore();
11906
- CatalogueBindingSchema = z32.strictObject({ fingerprint: z32.string().min(1), source: z32.string().min(1), revision: z32.string().min(1) });
12072
+ CatalogueBindingSchema = z33.strictObject({ fingerprint: z33.string().min(1), source: z33.string().min(1), revision: z33.string().min(1) });
11907
12073
  }
11908
12074
  });
11909
12075
 
@@ -11954,64 +12120,64 @@ var init_signatures = __esm({
11954
12120
  });
11955
12121
 
11956
12122
  // src/codex/anthropic.ts
11957
- import { z as z33 } from "zod";
12123
+ import { z as z34 } from "zod";
11958
12124
  var TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
11959
12125
  var init_anthropic = __esm({
11960
12126
  "src/codex/anthropic.ts"() {
11961
12127
  "use strict";
11962
- TextBlockSchema = z33.looseObject({ type: z33.literal("text"), text: z33.string() });
11963
- Base64ImageSourceSchema = z33.looseObject({ type: z33.literal("base64"), media_type: z33.string().min(1), data: z33.string() });
11964
- UrlImageSourceSchema = z33.looseObject({ type: z33.literal("url"), url: z33.string().min(1) });
11965
- ImageBlockSchema = z33.looseObject({
11966
- type: z33.literal("image"),
11967
- source: z33.union([Base64ImageSourceSchema, UrlImageSourceSchema])
12128
+ TextBlockSchema = z34.looseObject({ type: z34.literal("text"), text: z34.string() });
12129
+ Base64ImageSourceSchema = z34.looseObject({ type: z34.literal("base64"), media_type: z34.string().min(1), data: z34.string() });
12130
+ UrlImageSourceSchema = z34.looseObject({ type: z34.literal("url"), url: z34.string().min(1) });
12131
+ ImageBlockSchema = z34.looseObject({
12132
+ type: z34.literal("image"),
12133
+ source: z34.union([Base64ImageSourceSchema, UrlImageSourceSchema])
11968
12134
  });
11969
- ToolUseBlockSchema = z33.looseObject({
11970
- type: z33.literal("tool_use"),
11971
- id: z33.string().min(1),
11972
- name: z33.string().min(1),
11973
- input: z33.unknown()
12135
+ ToolUseBlockSchema = z34.looseObject({
12136
+ type: z34.literal("tool_use"),
12137
+ id: z34.string().min(1),
12138
+ name: z34.string().min(1),
12139
+ input: z34.unknown()
11974
12140
  });
11975
- ToolResultContentBlockSchema = z33.union([TextBlockSchema, z33.looseObject({ type: z33.string() })]);
11976
- ToolResultBlockSchema = z33.looseObject({
11977
- type: z33.literal("tool_result"),
11978
- tool_use_id: z33.string().min(1),
11979
- content: z33.union([z33.string(), z33.array(ToolResultContentBlockSchema)]).optional()
12141
+ ToolResultContentBlockSchema = z34.union([TextBlockSchema, z34.looseObject({ type: z34.string() })]);
12142
+ ToolResultBlockSchema = z34.looseObject({
12143
+ type: z34.literal("tool_result"),
12144
+ tool_use_id: z34.string().min(1),
12145
+ content: z34.union([z34.string(), z34.array(ToolResultContentBlockSchema)]).optional()
11980
12146
  });
11981
- OtherBlockSchema = z33.looseObject({ type: z33.string() });
11982
- ContentBlockSchema = z33.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
11983
- MessageSchema = z33.looseObject({
11984
- role: z33.enum(["user", "assistant", "system"]),
11985
- content: z33.union([z33.string(), z33.array(ContentBlockSchema)])
12147
+ OtherBlockSchema = z34.looseObject({ type: z34.string() });
12148
+ ContentBlockSchema = z34.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
12149
+ MessageSchema = z34.looseObject({
12150
+ role: z34.enum(["user", "assistant", "system"]),
12151
+ content: z34.union([z34.string(), z34.array(ContentBlockSchema)])
11986
12152
  });
11987
- ToolSchema = z33.looseObject({
11988
- name: z33.string().min(1),
11989
- description: z33.string().optional(),
11990
- input_schema: z33.record(z33.string(), z33.unknown()).optional(),
11991
- allowed_domains: z33.array(z33.string()).optional(),
11992
- blocked_domains: z33.array(z33.string()).optional()
12153
+ ToolSchema = z34.looseObject({
12154
+ name: z34.string().min(1),
12155
+ description: z34.string().optional(),
12156
+ input_schema: z34.record(z34.string(), z34.unknown()).optional(),
12157
+ allowed_domains: z34.array(z34.string()).optional(),
12158
+ blocked_domains: z34.array(z34.string()).optional()
11993
12159
  });
11994
- ToolChoiceSchema = z33.union([
11995
- z33.looseObject({ type: z33.enum(["auto", "none", "any"]) }),
11996
- z33.looseObject({ type: z33.literal("tool"), name: z33.string().min(1) })
12160
+ ToolChoiceSchema = z34.union([
12161
+ z34.looseObject({ type: z34.enum(["auto", "none", "any"]) }),
12162
+ z34.looseObject({ type: z34.literal("tool"), name: z34.string().min(1) })
11997
12163
  ]);
11998
- SystemSchema = z33.union([z33.string(), z33.array(z33.union([TextBlockSchema, OtherBlockSchema]))]);
11999
- MessagesRequestSchema = z33.looseObject({
12000
- model: z33.string().optional(),
12164
+ SystemSchema = z34.union([z34.string(), z34.array(z34.union([TextBlockSchema, OtherBlockSchema]))]);
12165
+ MessagesRequestSchema = z34.looseObject({
12166
+ model: z34.string().optional(),
12001
12167
  system: SystemSchema.optional(),
12002
- messages: z33.array(MessageSchema),
12003
- tools: z33.array(ToolSchema).optional(),
12168
+ messages: z34.array(MessageSchema),
12169
+ tools: z34.array(ToolSchema).optional(),
12004
12170
  tool_choice: ToolChoiceSchema.optional(),
12005
- stream: z33.boolean().optional(),
12171
+ stream: z34.boolean().optional(),
12006
12172
  /** `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. */
12007
- metadata: z33.looseObject({ user_id: z33.string().optional() }).optional(),
12173
+ metadata: z34.looseObject({ user_id: z34.string().optional() }).optional(),
12008
12174
  /** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
12009
- output_config: z33.looseObject({ effort: z33.string().optional(), format: z33.object({ type: z33.literal("json_schema"), schema: z33.record(z33.string(), z33.unknown()) }).optional() }).optional()
12175
+ output_config: z34.looseObject({ effort: z34.string().optional(), format: z34.object({ type: z34.literal("json_schema"), schema: z34.record(z34.string(), z34.unknown()) }).optional() }).optional()
12010
12176
  });
12011
- CountTokensRequestSchema = z33.looseObject({
12012
- system: z33.unknown().optional(),
12013
- messages: z33.unknown().optional(),
12014
- tools: z33.unknown().optional()
12177
+ CountTokensRequestSchema = z34.looseObject({
12178
+ system: z34.unknown().optional(),
12179
+ messages: z34.unknown().optional(),
12180
+ tools: z34.unknown().optional()
12015
12181
  });
12016
12182
  }
12017
12183
  });
@@ -12423,10 +12589,9 @@ function checkedProxyBypass(entries, source) {
12423
12589
  }
12424
12590
  return kept;
12425
12591
  }
12426
- function withBypassHosts(existing, hosts) {
12427
- const listed = (existing ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
12428
- const have = new Set(listed.map((entry) => entry.toLowerCase()));
12429
- const added = hosts.filter((host) => {
12592
+ function appendedBypassHosts(existing, hosts) {
12593
+ const have = new Set((existing ?? "").split(",").map((entry) => entry.trim().toLowerCase()).filter((entry) => entry !== ""));
12594
+ return hosts.filter((host) => {
12430
12595
  const key = host.toLowerCase();
12431
12596
  if (have.has(key)) {
12432
12597
  return false;
@@ -12434,7 +12599,10 @@ function withBypassHosts(existing, hosts) {
12434
12599
  have.add(key);
12435
12600
  return true;
12436
12601
  });
12437
- return [...listed, ...added].join(",");
12602
+ }
12603
+ function withBypassHosts(existing, hosts) {
12604
+ const listed = (existing ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
12605
+ return [...listed, ...appendedBypassHosts(existing, hosts)].join(",");
12438
12606
  }
12439
12607
  var init_proxyBypass2 = __esm({
12440
12608
  "src/launcher/proxyBypass.ts"() {
@@ -13005,43 +13173,6 @@ var init_cliOverride = __esm({
13005
13173
  }
13006
13174
  });
13007
13175
 
13008
- // src/headroom/headers.ts
13009
- function mergeAnthropicCustomHeaders(existing, additions) {
13010
- const merged = /* @__PURE__ */ new Map();
13011
- for (const block of existing) {
13012
- if (block === void 0) {
13013
- continue;
13014
- }
13015
- for (const line of block.split("\n")) {
13016
- const entry = parseCustomHeaderLine(line);
13017
- if (entry === void 0) {
13018
- continue;
13019
- }
13020
- merged.set(entry.name, entry.value);
13021
- }
13022
- }
13023
- for (const entry of additions) {
13024
- merged.set(entry.name, entry.value);
13025
- }
13026
- return [...merged].map(([name, value]) => `${name}: ${value}`).join("\n");
13027
- }
13028
- function parseCustomHeaderLine(line) {
13029
- const trimmed = line.trim();
13030
- if (trimmed === "") {
13031
- return void 0;
13032
- }
13033
- const colon = trimmed.indexOf(":");
13034
- if (colon <= 0) {
13035
- return void 0;
13036
- }
13037
- return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
13038
- }
13039
- var init_headers = __esm({
13040
- "src/headroom/headers.ts"() {
13041
- "use strict";
13042
- }
13043
- });
13044
-
13045
13176
  // src/statusline/settings.ts
13046
13177
  function checkedStatusline(settings, source) {
13047
13178
  try {
@@ -13125,7 +13256,10 @@ function buildArgv(params) {
13125
13256
  return [...params.toolFlags, ...params.extraFlags, ...params.passthrough];
13126
13257
  }
13127
13258
  function buildEnv(params) {
13128
- const env = { ...params.baseEnv };
13259
+ const injections = recordInjections(params.baseEnv);
13260
+ const { env } = injections;
13261
+ const inject = injections.set;
13262
+ const injectedHeaderNames = [];
13129
13263
  const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
13130
13264
  let providerCustomHeaders;
13131
13265
  if (!params.configDirEscapeHatch && params.identityId !== void 0) {
@@ -13134,53 +13268,75 @@ function buildEnv(params) {
13134
13268
  if (params.provider !== void 0) {
13135
13269
  const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
13136
13270
  providerCustomHeaders = providerEnv.ANTHROPIC_CUSTOM_HEADERS;
13137
- env.ANTHROPIC_BASE_URL = void 0;
13138
- env.AGENT_SHIM_PROVIDER = params.provider.definition.displayName;
13271
+ injections.unset("ANTHROPIC_BASE_URL");
13272
+ inject("AGENT_SHIM_PROVIDER", params.provider.definition.displayName);
13139
13273
  for (const [key, value] of Object.entries(providerEnv)) {
13140
- env[key] = value;
13274
+ if (key === CUSTOM_HEADERS_ENV) {
13275
+ env[key] = value;
13276
+ injectedHeaderNames.push(...parseAnthropicCustomHeaders(value).map(({ name }) => name));
13277
+ } else if (key === "NO_PROXY" || key === "no_proxy") {
13278
+ env[key] = value;
13279
+ injections.recordBypassHosts(key, value.split(","));
13280
+ } else {
13281
+ inject(key, value);
13282
+ }
13141
13283
  }
13142
13284
  }
13143
13285
  for (const tier of CLAUDE_TIERS) {
13144
13286
  const ref = params.tierModels?.[tier];
13145
13287
  if (ref !== void 0) {
13146
- env[`ANTHROPIC_DEFAULT_${tier.toUpperCase()}_MODEL`] = ref;
13288
+ inject(`ANTHROPIC_DEFAULT_${tier.toUpperCase()}_MODEL`, ref);
13147
13289
  }
13148
13290
  }
13149
13291
  if (params.provider !== void 0) {
13150
- env.ANTHROPIC_AUTH_TOKEN = params.remoteControl ? void 0 : PROVIDER_SESSION_PLACEHOLDER;
13151
- env.ANTHROPIC_API_KEY = void 0;
13152
- env.CLAUDE_CODE_OAUTH_TOKEN = void 0;
13292
+ if (params.remoteControl) {
13293
+ injections.unset("ANTHROPIC_AUTH_TOKEN");
13294
+ } else {
13295
+ inject("ANTHROPIC_AUTH_TOKEN", PROVIDER_SESSION_PLACEHOLDER);
13296
+ }
13297
+ injections.unset("ANTHROPIC_API_KEY");
13298
+ injections.unset("CLAUDE_CODE_OAUTH_TOKEN");
13153
13299
  } else if (params.identityCredential !== void 0) {
13154
13300
  for (const [variable, value] of Object.entries(credentialVariables(params.identityCredential.target, params.identityCredential.token))) {
13155
- env[variable] = value;
13301
+ if (value === void 0) {
13302
+ injections.unset(variable);
13303
+ } else {
13304
+ inject(variable, value);
13305
+ }
13156
13306
  }
13157
13307
  }
13158
13308
  if (params.frontdoor !== void 0) {
13309
+ const launcherHeaders = [
13310
+ ...params.identityId === void 0 ? [] : [{ name: IDENTITY_HEADER, value: params.identityId }],
13311
+ { name: SESSION_HEADER, value: params.sessionId },
13312
+ { name: AUTH_HEADER, value: params.frontdoor.sessionToken },
13313
+ ...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
13314
+ ...params.headroom === void 0 ? [] : [
13315
+ { name: HEADROOM_FLAG_HEADER, value: "1" },
13316
+ { name: PROJECT_ID_HEADER, value: params.headroom.projectId }
13317
+ ]
13318
+ ];
13319
+ injectedHeaderNames.push(...launcherHeaders.map(({ name }) => name));
13159
13320
  env.ANTHROPIC_CUSTOM_HEADERS = mergeAnthropicCustomHeaders(
13160
13321
  [
13161
13322
  ...parentCustomHeaders === void 0 ? [] : [parentCustomHeaders],
13162
13323
  ...providerCustomHeaders === void 0 ? [] : [providerCustomHeaders]
13163
13324
  ],
13164
- [
13165
- ...params.identityId === void 0 ? [] : [{ name: IDENTITY_HEADER, value: params.identityId }],
13166
- { name: SESSION_HEADER, value: params.sessionId },
13167
- { name: AUTH_HEADER, value: params.frontdoor.sessionToken },
13168
- ...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
13169
- ...params.headroom === void 0 ? [] : [
13170
- { name: HEADROOM_FLAG_HEADER, value: "1" },
13171
- { name: PROJECT_ID_HEADER, value: params.headroom.projectId }
13172
- ]
13173
- ]
13325
+ launcherHeaders
13174
13326
  );
13175
- env.NODE_EXTRA_CA_CERTS = params.frontdoor.trustBundlePath;
13176
- env.HTTPS_PROXY = connectProxyUrl(params.frontdoor.connectPort, params.frontdoor.sessionToken);
13327
+ inject("NODE_EXTRA_CA_CERTS", params.frontdoor.trustBundlePath);
13328
+ inject("HTTPS_PROXY", connectProxyUrl(params.frontdoor.connectPort, params.frontdoor.sessionToken));
13177
13329
  const bypassed = [...LOOPBACK_HOSTS, ...params.proxyBypass ?? []];
13178
- env.NO_PROXY = withBypassHosts(env.NO_PROXY, bypassed);
13179
- env.no_proxy = withBypassHosts(env.no_proxy, bypassed);
13330
+ for (const list of ["NO_PROXY", "no_proxy"]) {
13331
+ injections.recordBypassHosts(list, appendedBypassHosts(env[list], bypassed));
13332
+ env[list] = withBypassHosts(env[list], bypassed);
13333
+ }
13180
13334
  }
13181
13335
  if (params.statusline !== void 0) {
13182
- env[STATUSLINE_ENV] = JSON.stringify(params.statusline);
13336
+ inject(STATUSLINE_ENV, JSON.stringify(params.statusline));
13183
13337
  }
13338
+ injections.recordHeaders(injectedHeaderNames);
13339
+ injections.finish();
13184
13340
  return env;
13185
13341
  }
13186
13342
  var LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
@@ -13193,6 +13349,7 @@ var init_flags = __esm({
13193
13349
  init_schema();
13194
13350
  init_credential();
13195
13351
  init_headers();
13352
+ init_injected();
13196
13353
  init_capability();
13197
13354
  init_route();
13198
13355
  init_statusline();
@@ -13954,19 +14111,18 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
13954
14111
  ...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
13955
14112
  };
13956
14113
  }
14114
+ function warnOfSupersededConfigDir(warn, fs17, superseded, identity, identityDir) {
14115
+ if (superseded === void 0 || superseded === identityDir || fs17.sameDirectory(superseded, identityDir)) {
14116
+ return;
14117
+ }
14118
+ warn(`agent-shim: the identity named on the command line outranks the inherited CLAUDE_CONFIG_DIR ${superseded}; running as ${identity} in ${identityDir}`);
14119
+ }
13957
14120
  function decideLaunch(params, readOnly, onRecorded) {
13958
14121
  const { paths, fs: fs17, proc, log } = params;
13959
- const { env, argv } = proc;
14122
+ const { argv } = proc;
13960
14123
  const parsedArgv = parseLauncherArgv(argv);
13961
- const cliOverride = buildCliOverride({
13962
- env,
13963
- categoryFlags: parsedArgv.categoryFlags,
13964
- shareFlags: parsedArgv.shareFlags,
13965
- hideFlags: parsedArgv.hideFlags
13966
- });
13967
- const configDirEscapeHatchApplies = env.CLAUDE_CONFIG_DIR !== void 0 && env.CLAUDE_CONFIG_DIR !== "";
13968
14124
  const decidedIdentity = decideIdentity({
13969
- env,
14125
+ env: proc.env,
13970
14126
  argv0Identity: params.pickedIdentity ?? parsedArgv.identity,
13971
14127
  directoryPinnedIdentity: params.directoryPinnedIdentity,
13972
14128
  readActiveIdentityFile: () => {
@@ -13978,6 +14134,14 @@ function decideLaunch(params, readOnly, onRecorded) {
13978
14134
  return trimmed === "" ? void 0 : trimmed;
13979
14135
  }
13980
14136
  });
14137
+ const configDirEscapeHatchApplies = decidedIdentity.configDirEscapeHatch;
14138
+ const env = launchEnvironment(proc.env, configDirEscapeHatchApplies);
14139
+ const cliOverride = buildCliOverride({
14140
+ env,
14141
+ categoryFlags: parsedArgv.categoryFlags,
14142
+ shareFlags: parsedArgv.shareFlags,
14143
+ hideFlags: parsedArgv.hideFlags
14144
+ });
13981
14145
  const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
13982
14146
  const lockFarm = !readOnly && !configDirEscapeHatchApplies && identityDecision.name !== void 0 ? params.farm : void 0;
13983
14147
  const lockPorts = params.namesLock ?? (lockFarm === void 0 ? realIdentityNamesLockPorts : { fs: lockFarm.fs, nowMs: lockFarm.now, ...lockFarm.lock });
@@ -13985,6 +14149,9 @@ function decideLaunch(params, readOnly, onRecorded) {
13985
14149
  try {
13986
14150
  const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
13987
14151
  const farm = farmIdentity === void 0 ? void 0 : params.farm;
14152
+ if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
14153
+ warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, path50.join(paths.identitiesDir, farmIdentity));
14154
+ }
13988
14155
  if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
13989
14156
  try {
13990
14157
  recoverFarmWarning(
@@ -14151,7 +14318,7 @@ function decideLaunch(params, readOnly, onRecorded) {
14151
14318
  const doorPid = supervisorPid ?? (recordedPid !== void 0 && proc.isProcessAlive(recordedPid) ? recordedPid : void 0);
14152
14319
  const doorRecord = doorPid === void 0 ? void 0 : readFrontDoorCodexRecord(params.fs, paths.frontdoorDir, doorPid);
14153
14320
  const doorHome = doorRecord?.codexHome;
14154
- const catalogueEnv = doorHome === void 0 ? proc.env : { ...proc.env, CODEX_HOME: doorHome };
14321
+ const catalogueEnv = doorHome === void 0 ? env : { ...env, CODEX_HOME: doorHome };
14155
14322
  const listedProviders = listProviderNames(fs17.readdir, paths.providersDir).flatMap((name) => {
14156
14323
  try {
14157
14324
  const definition = loadProvider(paths.providersDir, name, fs17);
@@ -14213,6 +14380,7 @@ function decideLaunch(params, readOnly, onRecorded) {
14213
14380
  billing,
14214
14381
  notes,
14215
14382
  configDirEscapeHatch: configDirEscapeHatchApplies,
14383
+ env,
14216
14384
  farmIdentity,
14217
14385
  farmContext,
14218
14386
  configProfileDecision,
@@ -14248,12 +14416,12 @@ function prepareLaunch(params) {
14248
14416
  }
14249
14417
  function prepareRegisteredLaunch(params, onRecorded) {
14250
14418
  const { paths, proc, log } = params;
14251
- const { env } = proc;
14252
14419
  let unregisterLaunch;
14253
14420
  const decided = decideLaunch(params, false, (remove) => {
14254
14421
  unregisterLaunch = remove;
14255
14422
  onRecorded(remove);
14256
14423
  });
14424
+ const { env } = decided;
14257
14425
  const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, lastRanAs, billing, notes, flags: resolvedFlags, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
14258
14426
  const rows = [
14259
14427
  ...decisionRows({
@@ -14389,7 +14557,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
14389
14557
  }
14390
14558
  function resolveLaunch(params) {
14391
14559
  const decided = decideLaunch(params, true);
14392
- const { env } = params.proc;
14560
+ const { env } = decided;
14393
14561
  const frontDoor = decided.provider !== void 0 || decided.flags.headroom || decided.flags.trackUsage;
14394
14562
  const built = buildEnv({
14395
14563
  baseEnv: env,
@@ -14405,7 +14573,7 @@ function resolveLaunch(params) {
14405
14573
  ...decided.flags.statusline === void 0 ? {} : { statusline: decided.flags.statusline }
14406
14574
  });
14407
14575
  const credentialNames = decided.identityCredentialBlock === void 0 ? [] : Object.keys(credentialVariables(decided.identityCredentialBlock.target ?? "bearer", ""));
14408
- const environment = [.../* @__PURE__ */ new Set([...Object.keys(built).filter((name) => built[name] !== env[name]), ...credentialNames])].sort();
14576
+ const environment = [.../* @__PURE__ */ new Set([...Object.keys(built).filter((name) => name !== INJECTED_ENV && built[name] !== env[name]), ...credentialNames])].sort();
14409
14577
  const credential = decided.provider !== void 0 ? isRouterProvider(decided.provider.definition) ? void 0 : { subject: "provider", name: decided.provider.name, summary: summariseCredential(decided.provider.definition.credential) } : decided.identityCredentialBlock !== void 0 && decided.farmIdentity !== void 0 && decided.identityDecision.name !== void 0 ? { subject: "identity", name: decided.identityDecision.name, summary: summariseCredential(decided.identityCredentialBlock) } : void 0;
14410
14578
  return {
14411
14579
  decision: decided.decision,
@@ -14481,6 +14649,7 @@ var init_launcher = __esm({
14481
14649
  init_launchHook();
14482
14650
  init_targets();
14483
14651
  init_names();
14652
+ init_injected();
14484
14653
  }
14485
14654
  });
14486
14655
 
@@ -14545,7 +14714,7 @@ var init_selfIdentity = __esm({
14545
14714
  });
14546
14715
 
14547
14716
  // src/frontdoor/trust.ts
14548
- import { createHash as createHash9 } from "node:crypto";
14717
+ import { createHash as createHash10 } from "node:crypto";
14549
14718
  import path52 from "node:path";
14550
14719
  function resolveTrustBundle(params) {
14551
14720
  const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
@@ -14567,7 +14736,7 @@ function resolveTrustBundle(params) {
14567
14736
  }
14568
14737
  const combined = `${inheritedPem.trimEnd()}
14569
14738
  ${caPem}`;
14570
- const bundle = path52.join(bundlesDir, `${createHash9("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
14739
+ const bundle = path52.join(bundlesDir, `${createHash10("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
14571
14740
  if (!fs17.exists(bundle)) {
14572
14741
  fs17.mkdirp(bundlesDir);
14573
14742
  fs17.writeFileAtomic(bundle, combined);
@@ -15003,7 +15172,7 @@ function identityLaunchArgv(identity, flags) {
15003
15172
  }
15004
15173
  async function withIdentityClaude(params, identity, flags, use) {
15005
15174
  const refusals = [];
15006
- const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => name !== CONFIG_DIR_VARIABLE));
15175
+ const env = { ...process.env };
15007
15176
  const argv = [...identityLaunchArgv(identity, flags)];
15008
15177
  const run = await recordRuns((replay) => resolveClaudeLaunch({ argv, cwd: params.cwd, env: definedEnvironment(env), paths: params.paths }, replay), params.runAsync ?? realRunAsync);
15009
15178
  const farm = buildFarmRuntime(params.paths, params.cwd, run);
@@ -15041,7 +15210,7 @@ async function withIdentityClaude(params, identity, flags, use) {
15041
15210
  plan.release();
15042
15211
  }
15043
15212
  }
15044
- var CONFIG_DIR_VARIABLE, IDENTITY_ONLY_FLAG;
15213
+ var IDENTITY_ONLY_FLAG;
15045
15214
  var init_identityClaude = __esm({
15046
15215
  "src/usage/identityClaude.ts"() {
15047
15216
  "use strict";
@@ -15050,13 +15219,12 @@ var init_identityClaude = __esm({
15050
15219
  init_realPorts();
15051
15220
  init_replayRun();
15052
15221
  init_identityNamesLock();
15053
- CONFIG_DIR_VARIABLE = "CLAUDE_CONFIG_DIR";
15054
15222
  IDENTITY_ONLY_FLAG = "--no-provider";
15055
15223
  }
15056
15224
  });
15057
15225
 
15058
15226
  // src/usage/providerQuota.ts
15059
- import { z as z41 } from "zod";
15227
+ import { z as z43 } from "zod";
15060
15228
  var MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
15061
15229
  var init_providerQuota = __esm({
15062
15230
  "src/usage/providerQuota.ts"() {
@@ -15075,35 +15243,35 @@ var init_providerQuota = __esm({
15075
15243
  [ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
15076
15244
  [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
15077
15245
  ]);
15078
- ZaiLimitSchema = z41.object({
15079
- type: z41.string(),
15080
- unit: z41.number().int(),
15081
- number: z41.number().int().positive(),
15082
- percentage: z41.number().nonnegative(),
15083
- nextResetTime: z41.number().positive().optional(),
15084
- usage: z41.number().nonnegative().optional(),
15085
- currentValue: z41.number().nonnegative().optional(),
15086
- remaining: z41.number().nonnegative().optional()
15246
+ ZaiLimitSchema = z43.object({
15247
+ type: z43.string(),
15248
+ unit: z43.number().int(),
15249
+ number: z43.number().int().positive(),
15250
+ percentage: z43.number().nonnegative(),
15251
+ nextResetTime: z43.number().positive().optional(),
15252
+ usage: z43.number().nonnegative().optional(),
15253
+ currentValue: z43.number().nonnegative().optional(),
15254
+ remaining: z43.number().nonnegative().optional()
15087
15255
  });
15088
- ZaiResponseSchema = z41.object({
15089
- success: z41.boolean(),
15090
- msg: z41.string().optional(),
15091
- data: z41.object({ level: z41.string().optional(), limits: z41.array(ZaiLimitSchema) })
15256
+ ZaiResponseSchema = z43.object({
15257
+ success: z43.boolean(),
15258
+ msg: z43.string().optional(),
15259
+ data: z43.object({ level: z43.string().optional(), limits: z43.array(ZaiLimitSchema) })
15092
15260
  });
15093
15261
  OPENROUTER_HOST = "openrouter.ai";
15094
15262
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
15095
15263
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
15096
15264
  MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15097
- OpenRouterKeySchema = z41.object({
15098
- data: z41.object({
15099
- limit: z41.number().nonnegative().nullable(),
15100
- limit_remaining: z41.number().nullable(),
15101
- limit_reset: z41.string().nullable(),
15102
- is_free_tier: z41.boolean().optional(),
15103
- free_model_daily_requests: z41.object({ used: z41.number().nonnegative(), limit: z41.number().nonnegative(), remaining: z41.number() }).optional()
15265
+ OpenRouterKeySchema = z43.object({
15266
+ data: z43.object({
15267
+ limit: z43.number().nonnegative().nullable(),
15268
+ limit_remaining: z43.number().nullable(),
15269
+ limit_reset: z43.string().nullable(),
15270
+ is_free_tier: z43.boolean().optional(),
15271
+ free_model_daily_requests: z43.object({ used: z43.number().nonnegative(), limit: z43.number().nonnegative(), remaining: z43.number() }).optional()
15104
15272
  })
15105
15273
  });
15106
- OpenRouterCreditsSchema = z41.object({ data: z41.object({ total_credits: z41.number().nonnegative(), total_usage: z41.number().nonnegative() }) });
15274
+ OpenRouterCreditsSchema = z43.object({ data: z43.object({ total_credits: z43.number().nonnegative(), total_usage: z43.number().nonnegative() }) });
15107
15275
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
15108
15276
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
15109
15277
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
@@ -15111,21 +15279,21 @@ var init_providerQuota = __esm({
15111
15279
  DAYS_PER_WEEK2 = 7;
15112
15280
  FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15113
15281
  WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
15114
- AntigravityBucketSchema = z41.object({
15115
- bucketId: z41.string(),
15116
- remainingFraction: z41.number().optional(),
15117
- resetTime: z41.string().optional()
15282
+ AntigravityBucketSchema = z43.object({
15283
+ bucketId: z43.string(),
15284
+ remainingFraction: z43.number().optional(),
15285
+ resetTime: z43.string().optional()
15118
15286
  });
15119
- AntigravitySummarySchema = z41.object({ groups: z41.array(z41.object({ buckets: z41.array(AntigravityBucketSchema) })) });
15120
- GoogleTokenInfoSchema = z41.object({
15121
- email: z41.string().optional(),
15122
- sub: z41.string().optional()
15287
+ AntigravitySummarySchema = z43.object({ groups: z43.array(z43.object({ buckets: z43.array(AntigravityBucketSchema) })) });
15288
+ GoogleTokenInfoSchema = z43.object({
15289
+ email: z43.string().optional(),
15290
+ sub: z43.string().optional()
15123
15291
  });
15124
- AntigravityUserSchema = z41.object({
15292
+ AntigravityUserSchema = z43.object({
15125
15293
  /** The code-assist tier context, which defaults to the free tier for every account. */
15126
- currentTier: z41.object({ name: z41.string().optional(), id: z41.string().optional() }).optional(),
15294
+ currentTier: z43.object({ name: z43.string().optional(), id: z43.string().optional() }).optional(),
15127
15295
  /** The account's paid subscription; absent when the account has none. */
15128
- paidTier: z41.object({ name: z41.string().optional(), id: z41.string().optional() }).optional()
15296
+ paidTier: z43.object({ name: z43.string().optional(), id: z43.string().optional() }).optional()
15129
15297
  });
15130
15298
  }
15131
15299
  });
@@ -15640,30 +15808,60 @@ function parseRcRequestBody(kind, body) {
15640
15808
  }
15641
15809
  function createRcSessionTracker(deps) {
15642
15810
  const entries = /* @__PURE__ */ new Map();
15643
- const expire = (id) => {
15811
+ const retirePending = (entry, requestId, reason) => {
15812
+ if (entry.pending.delete(requestId)) {
15813
+ entry.retired.set(requestId, deps.now());
15814
+ deps.onTransition?.({ kind: "pending-retired", session: entry.id, requestId, reason, at: deps.now() });
15815
+ }
15816
+ };
15817
+ const addPending = (entry, pending) => {
15818
+ if (entry.retired.has(pending.requestId)) {
15819
+ return;
15820
+ }
15821
+ const born = !entry.pending.has(pending.requestId);
15822
+ entry.pending.set(pending.requestId, pending);
15823
+ if (born) {
15824
+ deps.onTransition?.({ kind: "pending-born", session: entry.id, requestId: pending.requestId, type: pending.type, summary: pending.summary, at: pending.observedAt });
15825
+ }
15826
+ };
15827
+ const expire = (id, reason) => {
15828
+ const entry = entries.get(id);
15829
+ if (entry === void 0) {
15830
+ return;
15831
+ }
15832
+ for (const requestId of [...entry.pending.keys()]) {
15833
+ retirePending(entry, requestId, "session-ended");
15834
+ }
15644
15835
  entries.delete(id);
15836
+ deps.onTransition?.({ kind: "session-ended", session: id, reason, at: deps.now() });
15645
15837
  };
15646
15838
  const expirePendings = (entry, now) => {
15647
15839
  for (const [requestId, pending] of entry.pending) {
15648
15840
  if (now - pending.observedAt >= RC_PENDING_DEADLINE_MS) {
15649
- entry.pending.delete(requestId);
15841
+ retirePending(entry, requestId, "expired");
15842
+ }
15843
+ }
15844
+ for (const [requestId, retiredAt] of entry.retired) {
15845
+ if (now - retiredAt >= RC_PENDING_DEADLINE_MS) {
15846
+ entry.retired.delete(requestId);
15650
15847
  }
15651
15848
  }
15652
15849
  };
15653
15850
  const sweep = () => {
15654
15851
  for (const [id, entry] of entries) {
15655
15852
  if (deps.now() - entry.lastSeenAt >= deps.idleMs) {
15656
- expire(id);
15853
+ expire(id, "expired");
15657
15854
  continue;
15658
15855
  }
15659
15856
  expirePendings(entry, deps.now());
15660
15857
  }
15661
15858
  };
15662
- const timer = setInterval(sweep, deps.idleMs);
15859
+ const timer = setInterval(sweep, Math.min(deps.idleMs, RC_PENDING_DEADLINE_MS));
15663
15860
  timer.unref();
15664
15861
  const birth = (id, facts) => {
15665
- const record = { id, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), workerState: void 0, workerIdleSeconds: void 0, sequenceNum: void 0, liveTasks: /* @__PURE__ */ new Map() };
15862
+ const record = { id, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), retired: /* @__PURE__ */ new Map(), workerState: void 0, workerIdleSeconds: void 0, sequenceNum: void 0, liveTasks: /* @__PURE__ */ new Map() };
15666
15863
  entries.set(id, record);
15864
+ deps.onTransition?.({ kind: "session-appeared", session: id, at: record.createdAt });
15667
15865
  return record;
15668
15866
  };
15669
15867
  const persistCredential = (entry) => {
@@ -15671,6 +15869,13 @@ function createRcSessionTracker(deps) {
15671
15869
  deps.credentialStore?.write(entry.id, { authorization: entry.oauthAuthorization, anthropicVersion: entry.anthropicVersion, anthropicClientPlatform: entry.anthropicClientPlatform });
15672
15870
  }
15673
15871
  };
15872
+ const refresh = (entry, facts) => {
15873
+ entry.lastSeenAt = deps.now();
15874
+ entry.oauthAuthorization = facts.oauthAuthorization ?? entry.oauthAuthorization;
15875
+ entry.anthropicVersion = facts.anthropicVersion ?? entry.anthropicVersion;
15876
+ entry.anthropicClientPlatform = facts.anthropicClientPlatform ?? entry.anthropicClientPlatform;
15877
+ persistCredential(entry);
15878
+ };
15674
15879
  const observeExchange = (request4) => {
15675
15880
  const method = (request4.method ?? "").toUpperCase();
15676
15881
  if (!isRcSessionExchange(request4.url)) {
@@ -15709,7 +15914,12 @@ function createRcSessionTracker(deps) {
15709
15914
  if (id2 === void 0) {
15710
15915
  return;
15711
15916
  }
15712
- persistCredential(birth(id2, facts));
15917
+ const existing = entries.get(id2);
15918
+ if (existing === void 0) {
15919
+ persistCredential(birth(id2, facts));
15920
+ return;
15921
+ }
15922
+ refresh(existing, facts);
15713
15923
  }
15714
15924
  };
15715
15925
  }
@@ -15718,12 +15928,10 @@ function createRcSessionTracker(deps) {
15718
15928
  if (id?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
15719
15929
  return void 0;
15720
15930
  }
15721
- const entry = entries.get(id) ?? birth(id, facts);
15722
- entry.lastSeenAt = deps.now();
15723
- entry.oauthAuthorization = facts.oauthAuthorization ?? entry.oauthAuthorization;
15724
- entry.anthropicVersion = facts.anthropicVersion ?? entry.anthropicVersion;
15725
- entry.anthropicClientPlatform = facts.anthropicClientPlatform ?? entry.anthropicClientPlatform;
15726
- persistCredential(entry);
15931
+ const tracked = entries.get(id);
15932
+ if (tracked !== void 0) {
15933
+ refresh(tracked, facts);
15934
+ }
15727
15935
  const bodyKind = method === "POST" && rest === `${id}/worker/events` ? "worker-events" : method === "POST" && rest === `${id}/events` ? "client-events" : method === "POST" && rest === `${id}/worker/heartbeat` ? "heartbeat" : method === "PUT" && rest === `${id}/worker` ? "worker-registration" : void 0;
15728
15936
  let chunks = [];
15729
15937
  let buffered = 0;
@@ -15744,10 +15952,10 @@ function createRcSessionTracker(deps) {
15744
15952
  }
15745
15953
  const now = deps.now();
15746
15954
  for (const controlRequest of factsOfBody.controlRequests) {
15747
- entryNow.pending.set(controlRequest.requestId, { sessionId: id, ...controlRequest, observedAt: now });
15955
+ addPending(entryNow, { sessionId: id, ...controlRequest, observedAt: now });
15748
15956
  }
15749
15957
  for (const requestId of factsOfBody.answeredRequestIds) {
15750
- entryNow.pending.delete(requestId);
15958
+ retirePending(entryNow, requestId, "answered");
15751
15959
  }
15752
15960
  for (const payload of factsOfBody.payloads) {
15753
15961
  entryNow.liveTasks = applyAgentTaskEvent(entryNow.liveTasks, id, payload, now);
@@ -15756,7 +15964,11 @@ function createRcSessionTracker(deps) {
15756
15964
  entryNow.workerIdleSeconds = { value: factsOfBody.idleSeconds, observedAt: now };
15757
15965
  }
15758
15966
  if (factsOfBody.workerStatus !== void 0) {
15967
+ const previous = entryNow.workerState?.value;
15759
15968
  entryNow.workerState = { value: factsOfBody.workerStatus, observedAt: now };
15969
+ if (previous !== factsOfBody.workerStatus) {
15970
+ deps.onTransition?.({ kind: "worker-state", session: id, state: factsOfBody.workerStatus, ...previous === void 0 ? {} : { previous }, at: now });
15971
+ }
15760
15972
  }
15761
15973
  };
15762
15974
  const archiving = method === "POST" && rest === `${id}/archive`;
@@ -15781,10 +15993,13 @@ function createRcSessionTracker(deps) {
15781
15993
  onResponse: (status, headers) => {
15782
15994
  if (singleHeader(headers, CONFLICT_REASON_HEADER) !== void 0 || archiving && isSuccessful(status)) {
15783
15995
  deps.credentialStore?.remove(id);
15784
- expire(id);
15996
+ expire(id, singleHeader(headers, CONFLICT_REASON_HEADER) === void 0 ? "archived" : "conflict");
15785
15997
  return;
15786
15998
  }
15787
15999
  accepted = isSuccessful(status);
16000
+ if (accepted && !entries.has(id)) {
16001
+ persistCredential(birth(id, facts));
16002
+ }
15788
16003
  file();
15789
16004
  },
15790
16005
  onBodyChunk: () => {
@@ -15849,12 +16064,12 @@ function createRcSessionTracker(deps) {
15849
16064
  const pending = pendingOfControlRequestPayload(event.payload);
15850
16065
  if (pending !== void 0) {
15851
16066
  if (event.source === RC_STREAM_WORKER_SOURCE) {
15852
- entry.pending.set(pending.requestId, { sessionId, ...pending, observedAt: deps.now() });
16067
+ addPending(entry, { sessionId, ...pending, observedAt: deps.now() });
15853
16068
  }
15854
16069
  return;
15855
16070
  }
15856
16071
  for (const requestId of answeredRequestIdsOfControlResponsePayload(event.payload)) {
15857
- entry.pending.delete(requestId);
16072
+ retirePending(entry, requestId, "answered");
15858
16073
  }
15859
16074
  },
15860
16075
  liveTasksOf: (sessionId) => {
@@ -15862,10 +16077,14 @@ function createRcSessionTracker(deps) {
15862
16077
  return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).flatMap((entry) => [...entry.liveTasks.values()].sort((left, right) => left.observedAt - right.observedAt || (left.taskId < right.taskId ? -1 : 1)));
15863
16078
  },
15864
16079
  completePending: (sessionId, requestId) => {
15865
- entries.get(sessionId)?.pending.delete(requestId);
16080
+ const entry = entries.get(sessionId);
16081
+ if (entry !== void 0) {
16082
+ retirePending(entry, requestId, "answered");
16083
+ }
15866
16084
  },
15867
16085
  close: () => {
15868
16086
  clearInterval(timer);
16087
+ deps.onClose?.();
15869
16088
  }
15870
16089
  };
15871
16090
  }
@@ -17945,8 +18164,8 @@ init_cliError();
17945
18164
  init_realPorts();
17946
18165
 
17947
18166
  // src/frontdoor/controlApi.ts
17948
- import { createORPCClient as createORPCClient2, ORPCError as ORPCError7 } from "@orpc/client";
17949
- import { openapi as openapi8 } from "@orpc/openapi";
18167
+ import { createORPCClient as createORPCClient2, ORPCError as ORPCError8 } from "@orpc/client";
18168
+ import { openapi as openapi9 } from "@orpc/openapi";
17950
18169
 
17951
18170
  // src/checkReport.ts
17952
18171
  init_cliError();
@@ -18087,9 +18306,10 @@ init_farm();
18087
18306
  init_guard();
18088
18307
  init_providersStore();
18089
18308
  init_projects();
18309
+ init_injected();
18090
18310
  init_pipeline();
18091
18311
  import path36 from "node:path";
18092
- import { z as z24 } from "zod";
18312
+ import { z as z25 } from "zod";
18093
18313
  var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
18094
18314
  function projectFragmentOf(rawKey) {
18095
18315
  return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
@@ -18158,9 +18378,9 @@ function lookupKeychainService(run, farmRoot) {
18158
18378
  }
18159
18379
  return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
18160
18380
  }
18161
- var SettingsSecretsShapeSchema = z24.looseObject({
18162
- env: z24.record(z24.string(), z24.unknown()).optional(),
18163
- hooks: z24.record(z24.string(), z24.array(z24.unknown())).optional()
18381
+ var SettingsSecretsShapeSchema = z25.looseObject({
18382
+ env: z25.record(z25.string(), z25.unknown()).optional(),
18383
+ hooks: z25.record(z25.string(), z25.array(z25.unknown())).optional()
18164
18384
  });
18165
18385
  function hookCommandCountOf(group) {
18166
18386
  if (typeof group !== "object" || group === null) {
@@ -18261,10 +18481,11 @@ function runCheck(params) {
18261
18481
  const resolved = resolveDecisions({ facts, cascade: params.cascade, classification: params.classification });
18262
18482
  const decisionLines = [...resolved.decisions.values()].slice().sort((a, b) => a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0).map(formatDecision);
18263
18483
  const projectEncodingAmbiguities = flagAmbiguousEncodings(resolved.flattened, facts);
18484
+ const guardEnv = launchEnvironment(params.env, params.configDirEscapeHatch);
18264
18485
  const ambientCredential = isCodex ? codexCredentialGuard(params.env, params.identity?.allowAmbientCredential ?? false) : evaluateAmbientCredentialGuard({
18265
- env: params.env,
18486
+ env: guardEnv,
18266
18487
  allowAmbientCredential: params.identity?.allowAmbientCredential ?? false,
18267
- allowAmbientCredentialOverride: parseEnvBool("AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL", params.env.AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL) === true,
18488
+ allowAmbientCredentialOverride: parseEnvBool("AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL", guardEnv.AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL) === true,
18268
18489
  ...params.identityName === void 0 ? {} : { identityName: params.identityName }
18269
18490
  });
18270
18491
  const settingsShared = resolved.flattened.categories.get("settings") ?? SHIPPED_CATEGORY_DEFAULTS.settings;
@@ -18434,6 +18655,7 @@ function collectCheckReport(params) {
18434
18655
  home,
18435
18656
  claudeHome,
18436
18657
  env: params.env,
18658
+ configDirEscapeHatch: identityDecision.configDirEscapeHatch,
18437
18659
  ...git.branch === void 0 ? {} : { branch: git.branch },
18438
18660
  ...git.branchDetached === void 0 ? {} : { branchDetached: git.branchDetached },
18439
18661
  nowMs: Date.now(),
@@ -18463,7 +18685,7 @@ init_schema();
18463
18685
  init_claudeVersion();
18464
18686
  init_identity();
18465
18687
  init_projects();
18466
- import { z as z26 } from "zod";
18688
+ import { z as z27 } from "zod";
18467
18689
 
18468
18690
  // src/resolve/types.ts
18469
18691
  var LAYER_KINDS = [
@@ -18524,123 +18746,123 @@ var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
18524
18746
 
18525
18747
  // src/usage/pickReportSchema.ts
18526
18748
  init_plan2();
18527
- import { z as z25 } from "zod";
18528
- var PoolPickCandidateViewSchema = z25.strictObject({
18529
- identity: z25.string(),
18749
+ import { z as z26 } from "zod";
18750
+ var PoolPickCandidateViewSchema = z26.strictObject({
18751
+ identity: z26.string(),
18530
18752
  /** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
18531
- class: z25.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
18753
+ class: z26.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
18532
18754
  /** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
18533
- score: z25.number().optional(),
18755
+ score: z26.number().optional(),
18534
18756
  /** 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`. */
18535
- scoreWindow: z25.enum(["sevenDay", "fiveHour"]).optional(),
18757
+ scoreWindow: z26.enum(["sevenDay", "fiveHour"]).optional(),
18536
18758
  /** False when the five-hour window would run dry, at the observed pace, before it resets. */
18537
- feasible: z25.boolean(),
18759
+ feasible: z26.boolean(),
18538
18760
  /** When an `ineligible` member can be used again, as an ISO instant. */
18539
- blockedUntil: z25.iso.datetime().optional(),
18761
+ blockedUntil: z26.iso.datetime().optional(),
18540
18762
  plan: PlanClassSchema,
18541
18763
  /** The facts behind the class and score, in the order they matter. */
18542
- reasons: z25.array(z25.string())
18764
+ reasons: z26.array(z26.string())
18543
18765
  });
18544
- var PoolPickReportSchema = z25.strictObject({
18545
- pool: z25.string(),
18546
- directory: z25.string(),
18766
+ var PoolPickReportSchema = z26.strictObject({
18767
+ pool: z26.string(),
18768
+ directory: z26.string(),
18547
18769
  /** The member a launch would run as, absent when every member is refused. */
18548
- pick: z25.string().optional(),
18549
- candidates: z25.array(PoolPickCandidateViewSchema),
18770
+ pick: z26.string().optional(),
18771
+ candidates: z26.array(PoolPickCandidateViewSchema),
18550
18772
  /** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
18551
- missing: z25.array(z25.string()),
18773
+ missing: z26.array(z26.string()),
18552
18774
  /** When nothing can be picked, the soonest any member returns. */
18553
- earliestReturn: z25.strictObject({ identity: z25.string(), at: z25.iso.datetime() }).optional(),
18775
+ earliestReturn: z26.strictObject({ identity: z26.string(), at: z26.iso.datetime() }).optional(),
18554
18776
  /** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
18555
- movedOff: z25.strictObject({ identity: z25.string(), reason: z25.string() }).optional(),
18777
+ movedOff: z26.strictObject({ identity: z26.string(), reason: z26.string() }).optional(),
18556
18778
  /** Why the last-pick record could not be read, when that is the case. */
18557
- stickyProblem: z25.string().optional()
18779
+ stickyProblem: z26.string().optional()
18558
18780
  });
18559
18781
 
18560
18782
  // src/checkReportSchema.ts
18561
18783
  var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
18562
- var CheckLayerViewSchema = z26.strictObject({
18563
- id: z26.int(),
18564
- kind: z26.enum(LAYER_KINDS),
18565
- source: z26.string()
18784
+ var CheckLayerViewSchema = z27.strictObject({
18785
+ id: z27.int(),
18786
+ kind: z27.enum(LAYER_KINDS),
18787
+ source: z27.string()
18566
18788
  });
18567
- var CheckEntryViewSchema = z26.strictObject({
18568
- path: z26.string(),
18569
- shared: z26.boolean(),
18570
- via: z26.enum(DECISION_VIAS),
18789
+ var CheckEntryViewSchema = z27.strictObject({
18790
+ path: z27.string(),
18791
+ shared: z27.boolean(),
18792
+ via: z27.enum(DECISION_VIAS),
18571
18793
  /** The entry's real category, or null when nothing classifies it. */
18572
- category: z26.enum(CATEGORY_NAMES).nullable(),
18573
- rule: z26.strictObject({ key: z26.string(), layer: z26.int() }).optional(),
18794
+ category: z27.enum(CATEGORY_NAMES).nullable(),
18795
+ rule: z27.strictObject({ key: z27.string(), layer: z27.int() }).optional(),
18574
18796
  /** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
18575
- eliminated: z26.readonly(z26.array(z26.strictObject({ key: z26.string(), failed: z26.readonly(z26.array(z26.string())) }))).optional()
18797
+ eliminated: z27.readonly(z27.array(z27.strictObject({ key: z27.string(), failed: z27.readonly(z27.array(z27.string())) }))).optional()
18576
18798
  });
18577
- var CheckDiagnosticSchema = z26.strictObject({
18578
- code: z26.enum(DIAGNOSTIC_CODES),
18579
- severity: z26.enum(DIAGNOSTIC_SEVERITIES),
18580
- message: z26.string(),
18581
- subject: z26.string().optional(),
18582
- layer: z26.int().optional()
18799
+ var CheckDiagnosticSchema = z27.strictObject({
18800
+ code: z27.enum(DIAGNOSTIC_CODES),
18801
+ severity: z27.enum(DIAGNOSTIC_SEVERITIES),
18802
+ message: z27.string(),
18803
+ subject: z27.string().optional(),
18804
+ layer: z27.int().optional()
18583
18805
  });
18584
- var CheckAmbientCredentialSchema = z26.union([z26.strictObject({ ok: z26.literal(true) }), z26.strictObject({ ok: z26.literal(false), variable: z26.string(), message: z26.string() })]);
18585
- var CheckKeychainSchema = z26.strictObject({
18586
- checked: z26.literal(true),
18587
- found: z26.boolean(),
18588
- serviceName: z26.string().optional(),
18589
- note: z26.string()
18806
+ var CheckAmbientCredentialSchema = z27.union([z27.strictObject({ ok: z27.literal(true) }), z27.strictObject({ ok: z27.literal(false), variable: z27.string(), message: z27.string() })]);
18807
+ var CheckKeychainSchema = z27.strictObject({
18808
+ checked: z27.literal(true),
18809
+ found: z27.boolean(),
18810
+ serviceName: z27.string().optional(),
18811
+ note: z27.string()
18590
18812
  });
18591
- var CheckSettingsExposureSchema = z26.strictObject({
18592
- file: z26.string(),
18593
- envKeyNames: z26.readonly(z26.array(z26.string())),
18594
- hookEventNames: z26.readonly(z26.array(z26.string())),
18595
- hookCommandCount: z26.int().nonnegative()
18813
+ var CheckSettingsExposureSchema = z27.strictObject({
18814
+ file: z27.string(),
18815
+ envKeyNames: z27.readonly(z27.array(z27.string())),
18816
+ hookEventNames: z27.readonly(z27.array(z27.string())),
18817
+ hookCommandCount: z27.int().nonnegative()
18596
18818
  });
18597
- var CredentialSourceSummarySchema = z26.union([
18598
- z26.strictObject({ kind: z26.literal("env"), variable: z26.string() }),
18599
- z26.strictObject({ kind: z26.literal("file"), path: z26.string() }),
18600
- z26.strictObject({ kind: z26.literal("command"), program: z26.string() }),
18601
- z26.strictObject({ kind: z26.literal("op"), reference: z26.string() }),
18602
- z26.strictObject({ kind: z26.literal("keychain"), service: z26.string(), account: z26.string().optional() }),
18603
- z26.strictObject({ kind: z26.literal("literal") })
18819
+ var CredentialSourceSummarySchema = z27.union([
18820
+ z27.strictObject({ kind: z27.literal("env"), variable: z27.string() }),
18821
+ z27.strictObject({ kind: z27.literal("file"), path: z27.string() }),
18822
+ z27.strictObject({ kind: z27.literal("command"), program: z27.string() }),
18823
+ z27.strictObject({ kind: z27.literal("op"), reference: z27.string() }),
18824
+ z27.strictObject({ kind: z27.literal("keychain"), service: z27.string(), account: z27.string().optional() }),
18825
+ z27.strictObject({ kind: z27.literal("literal") })
18604
18826
  ]);
18605
- var CredentialSummarySchema = z26.strictObject({
18606
- target: z26.enum(CREDENTIAL_TARGETS),
18607
- sources: z26.readonly(z26.array(CredentialSourceSummarySchema)),
18827
+ var CredentialSummarySchema = z27.strictObject({
18828
+ target: z27.enum(CREDENTIAL_TARGETS),
18829
+ sources: z27.readonly(z27.array(CredentialSourceSummarySchema)),
18608
18830
  cache: CredentialCacheSchema.optional()
18609
18831
  });
18610
- var CachedCredentialStateSchema = z26.union([
18611
- z26.strictObject({ store: z26.enum(CREDENTIAL_CACHE_STORES), status: z26.literal("empty") }),
18612
- z26.strictObject({ store: z26.enum(CREDENTIAL_CACHE_STORES), status: z26.literal("unreadable"), reason: z26.string() }),
18613
- z26.strictObject({ store: z26.enum(CREDENTIAL_CACHE_STORES), status: z26.enum(["fresh", "expired"]), ageMs: z26.number(), expiresInMs: z26.number().optional() })
18832
+ var CachedCredentialStateSchema = z27.union([
18833
+ z27.strictObject({ store: z27.enum(CREDENTIAL_CACHE_STORES), status: z27.literal("empty") }),
18834
+ z27.strictObject({ store: z27.enum(CREDENTIAL_CACHE_STORES), status: z27.literal("unreadable"), reason: z27.string() }),
18835
+ z27.strictObject({ store: z27.enum(CREDENTIAL_CACHE_STORES), status: z27.enum(["fresh", "expired"]), ageMs: z27.number(), expiresInMs: z27.number().optional() })
18614
18836
  ]);
18615
- var CheckCredentialProviderSchema = z26.union([
18616
- z26.strictObject({ name: z26.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
18617
- z26.strictObject({ name: z26.string(), problem: z26.string() })
18837
+ var CheckCredentialProviderSchema = z27.union([
18838
+ z27.strictObject({ name: z27.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
18839
+ z27.strictObject({ name: z27.string(), problem: z27.string() })
18618
18840
  ]);
18619
- var CheckCredentialSchema = z26.strictObject({
18620
- applies: z26.enum(CHECK_CREDENTIAL_APPLIES),
18841
+ var CheckCredentialSchema = z27.strictObject({
18842
+ applies: z27.enum(CHECK_CREDENTIAL_APPLIES),
18621
18843
  provider: CheckCredentialProviderSchema.optional(),
18622
18844
  identity: CredentialSummarySchema.optional(),
18623
18845
  identityCached: CachedCredentialStateSchema.optional()
18624
18846
  });
18625
- var CheckClaudeVersionSchema = z26.strictObject({
18626
- pinned: z26.strictObject({ version: z26.string(), source: z26.enum(CLAUDE_VERSION_SOURCES), installed: z26.boolean() }).optional(),
18627
- highestInstalled: z26.string().optional(),
18628
- installed: z26.readonly(z26.array(z26.string()))
18847
+ var CheckClaudeVersionSchema = z27.strictObject({
18848
+ pinned: z27.strictObject({ version: z27.string(), source: z27.enum(CLAUDE_VERSION_SOURCES), installed: z27.boolean() }).optional(),
18849
+ highestInstalled: z27.string().optional(),
18850
+ installed: z27.readonly(z27.array(z27.string()))
18629
18851
  });
18630
- var CheckReportJsonSchema = z26.strictObject({
18631
- identity: z26.strictObject({ name: z26.string().nullable(), source: z26.enum(IDENTITY_DECISION_SOURCES) }),
18852
+ var CheckReportJsonSchema = z27.strictObject({
18853
+ identity: z27.strictObject({ name: z27.string().nullable(), source: z27.enum(IDENTITY_DECISION_SOURCES) }),
18632
18854
  /** The pool ranking, when the launch named a pool instead of an identity. */
18633
18855
  pool: PoolPickReportSchema.optional(),
18634
- configProfile: z26.strictObject({ name: z26.string().nullable(), source: z26.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
18635
- layers: z26.readonly(z26.array(CheckLayerViewSchema)),
18636
- entries: z26.readonly(z26.array(CheckEntryViewSchema)),
18637
- projectEncodingAmbiguities: z26.readonly(
18638
- z26.array(z26.strictObject({ fragment: z26.string(), encoded: z26.string(), reason: z26.enum(ENCODING_AMBIGUITY_REASONS), detail: z26.string() }))
18856
+ configProfile: z27.strictObject({ name: z27.string().nullable(), source: z27.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
18857
+ layers: z27.readonly(z27.array(CheckLayerViewSchema)),
18858
+ entries: z27.readonly(z27.array(CheckEntryViewSchema)),
18859
+ projectEncodingAmbiguities: z27.readonly(
18860
+ z27.array(z27.strictObject({ fragment: z27.string(), encoded: z27.string(), reason: z27.enum(ENCODING_AMBIGUITY_REASONS), detail: z27.string() }))
18639
18861
  ),
18640
- diagnostics: z26.readonly(z26.array(CheckDiagnosticSchema)),
18862
+ diagnostics: z27.readonly(z27.array(CheckDiagnosticSchema)),
18641
18863
  ambientCredential: CheckAmbientCredentialSchema,
18642
18864
  keychain: CheckKeychainSchema.optional(),
18643
- settingsExposure: z26.readonly(z26.array(CheckSettingsExposureSchema)),
18865
+ settingsExposure: z27.readonly(z27.array(CheckSettingsExposureSchema)),
18644
18866
  credential: CheckCredentialSchema,
18645
18867
  claudeVersion: CheckClaudeVersionSchema.optional()
18646
18868
  });
@@ -18651,28 +18873,28 @@ init_preflight();
18651
18873
  init_resets();
18652
18874
 
18653
18875
  // src/usage/resetsSchema.ts
18654
- import { z as z27 } from "zod";
18655
- var ResetRowSchema = z27.strictObject({
18656
- identity: z27.string(),
18657
- provider: z27.string(),
18876
+ import { z as z28 } from "zod";
18877
+ var ResetRowSchema = z28.strictObject({
18878
+ identity: z28.string(),
18879
+ provider: z28.string(),
18658
18880
  /** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
18659
- window: z27.string(),
18881
+ window: z28.string(),
18660
18882
  /** When the state the window comes from was observed, as an ISO instant. */
18661
- observedAt: z27.iso.datetime(),
18883
+ observedAt: z28.iso.datetime(),
18662
18884
  /** When the window resets, as an ISO instant; absent when the upstream reported none. */
18663
- resetsAt: z27.iso.datetime().optional(),
18885
+ resetsAt: z28.iso.datetime().optional(),
18664
18886
  /** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
18665
- reset: z27.boolean(),
18887
+ reset: z28.boolean(),
18666
18888
  /** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
18667
- utilization: z27.number().optional(),
18889
+ utilization: z28.number().optional(),
18668
18890
  /** The window's own status, for a window that has not reset yet. */
18669
- status: z27.string().optional()
18891
+ status: z28.string().optional()
18670
18892
  });
18671
- var ResetScheduleSchema = z27.strictObject({ resets: z27.readonly(z27.array(ResetRowSchema)) });
18893
+ var ResetScheduleSchema = z28.strictObject({ resets: z28.readonly(z28.array(ResetRowSchema)) });
18672
18894
 
18673
18895
  // src/frontdoor/controlSchemas.ts
18674
18896
  import path42 from "node:path";
18675
- import { z as z34 } from "zod";
18897
+ import { z as z35 } from "zod";
18676
18898
 
18677
18899
  // src/codex/doctor.ts
18678
18900
  function codexIdentityFindings(entry, identity) {
@@ -19346,12 +19568,8 @@ function runDoctor(params) {
19346
19568
  }
19347
19569
  push(section, "warn", `${where} pins Claude Code ${version}, which is not installed (installed: ${installed.length === 0 ? "none" : installed.join(", ")}); a launch that resolves to it fails.`, subject);
19348
19570
  };
19349
- const ambient = detectAmbientCredential(params.env);
19350
- if (ambient === void 0) {
19351
- push("ambient-credential", "pass", "No ambient-credential environment variable is set.");
19352
- } else {
19353
- push("ambient-credential", "warn", formatAmbientCredentialGuardMessage(ambient.variable));
19354
- }
19571
+ const ambient = ambientCredentialFinding(params.env);
19572
+ push("ambient-credential", ambient.severity, ambient.message);
19355
19573
  if (params.binaryDiscovery.ok) {
19356
19574
  const { binary } = params.binaryDiscovery;
19357
19575
  const versionNote = binary.version === void 0 ? "" : `, version ${binary.version}`;
@@ -19903,92 +20121,92 @@ function collectDoctorReport(params) {
19903
20121
  // src/frontdoor/controlSchemas.ts
19904
20122
  init_schema2();
19905
20123
  init_state();
19906
- var UsageListOutputSchema = z34.strictObject({ snapshots: z34.readonly(z34.array(UsageSnapshotSchema)) });
19907
- var UsageWindowsInputSchema = z34.strictObject({
19908
- identity: z34.string().min(1),
19909
- provider: z34.string().min(1).optional()
20124
+ var UsageListOutputSchema = z35.strictObject({ snapshots: z35.readonly(z35.array(UsageSnapshotSchema)) });
20125
+ var UsageWindowsInputSchema = z35.strictObject({
20126
+ identity: z35.string().min(1),
20127
+ provider: z35.string().min(1).optional()
19910
20128
  });
19911
- var EffectiveWindowSchema = z34.strictObject({
20129
+ var EffectiveWindowSchema = z35.strictObject({
19912
20130
  /** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
19913
- reset: z34.boolean(),
20131
+ reset: z35.boolean(),
19914
20132
  /** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
19915
- utilization: z34.number().optional(),
20133
+ utilization: z35.number().optional(),
19916
20134
  /** The reset instant, for a window that has not reset yet and reported one. */
19917
- resetsAtMs: z34.number().optional(),
20135
+ resetsAtMs: z35.number().optional(),
19918
20136
  /** The window's own status, for a window that has not reset yet. */
19919
- status: z34.string().optional()
20137
+ status: z35.string().optional()
19920
20138
  });
19921
- var UsageWindowsOutputSchema = z34.strictObject({
19922
- identity: z34.string(),
19923
- provider: z34.string(),
20139
+ var UsageWindowsOutputSchema = z35.strictObject({
20140
+ identity: z35.string(),
20141
+ provider: z35.string(),
19924
20142
  /** When the rate-limit state the windows come from was observed. */
19925
- observedAt: z34.iso.datetime().optional(),
20143
+ observedAt: z35.iso.datetime().optional(),
19926
20144
  fiveHour: EffectiveWindowSchema.optional(),
19927
20145
  sevenDay: EffectiveWindowSchema.optional()
19928
20146
  });
19929
- var UsageLiveOutputSchema = z34.strictObject({
20147
+ var UsageLiveOutputSchema = z35.strictObject({
19930
20148
  /** 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. */
19931
20149
  latest: RcLiveRateLimitSchema.optional(),
19932
20150
  /** One observation per session whose stream has filed a rate_limit_event this door generation. */
19933
- sessions: z34.readonly(z34.array(RcLiveRateLimitSchema))
20151
+ sessions: z35.readonly(z35.array(RcLiveRateLimitSchema))
19934
20152
  });
19935
- var FrontDoorSessionStatusSchema = z34.strictObject({
19936
- pid: z34.int().positive(),
19937
- startedAt: z34.number(),
19938
- alive: z34.boolean()
20153
+ var FrontDoorSessionStatusSchema = z35.strictObject({
20154
+ pid: z35.int().positive(),
20155
+ startedAt: z35.number(),
20156
+ alive: z35.boolean()
19939
20157
  });
19940
- var HeadroomSocketTargetSchema = z34.union([z34.strictObject({ socketPath: z34.string() }), z34.strictObject({ refused: z34.string() })]);
19941
- var FrontDoorStatusOutputSchema = z34.strictObject({
20158
+ var HeadroomSocketTargetSchema = z35.union([z35.strictObject({ socketPath: z35.string() }), z35.strictObject({ refused: z35.string() })]);
20159
+ var FrontDoorStatusOutputSchema = z35.strictObject({
19942
20160
  state: FrontDoorStateSchema,
19943
- supervisorAlive: z34.boolean(),
20161
+ supervisorAlive: z35.boolean(),
19944
20162
  /** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
19945
- draining: z34.readonly(z34.array(z34.number().int().positive())),
19946
- sessions: z34.readonly(z34.array(FrontDoorSessionStatusSchema)),
20163
+ draining: z35.readonly(z35.array(z35.number().int().positive())),
20164
+ sessions: z35.readonly(z35.array(FrontDoorSessionStatusSchema)),
19947
20165
  headroomSocket: HeadroomSocketTargetSchema.optional(),
19948
- logPath: z34.string(),
19949
- logExists: z34.boolean()
20166
+ logPath: z35.string(),
20167
+ logExists: z35.boolean()
19950
20168
  });
19951
- var FrontDoorSessionsOutputSchema = z34.strictObject({ sessions: z34.readonly(z34.array(FrontDoorSessionStatusSchema)) });
19952
- var CheckRunInputSchema = z34.strictObject({
19953
- path: z34.string().min(1),
19954
- identity: z34.string().min(1).optional()
20169
+ var FrontDoorSessionsOutputSchema = z35.strictObject({ sessions: z35.readonly(z35.array(FrontDoorSessionStatusSchema)) });
20170
+ var CheckRunInputSchema = z35.strictObject({
20171
+ path: z35.string().min(1),
20172
+ identity: z35.string().min(1).optional()
19955
20173
  }).refine((input) => path42.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
19956
- var PoolPickInputSchema = z34.strictObject({
19957
- pool: z34.string().min(1),
19958
- path: z34.string().min(1)
20174
+ var PoolPickInputSchema = z35.strictObject({
20175
+ pool: z35.string().min(1),
20176
+ path: z35.string().min(1)
19959
20177
  }).refine((input) => path42.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
19960
- var DoctorFindingSchema = z34.strictObject({
19961
- section: z34.enum(DOCTOR_SECTIONS),
19962
- subject: z34.string().optional(),
19963
- severity: z34.enum(DOCTOR_SEVERITIES),
19964
- message: z34.string()
20178
+ var DoctorFindingSchema = z35.strictObject({
20179
+ section: z35.enum(DOCTOR_SECTIONS),
20180
+ subject: z35.string().optional(),
20181
+ severity: z35.enum(DOCTOR_SEVERITIES),
20182
+ message: z35.string()
19965
20183
  });
19966
- var DoctorRunOutputSchema = z34.strictObject({
20184
+ var DoctorRunOutputSchema = z35.strictObject({
19967
20185
  /** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
19968
- ok: z34.boolean(),
19969
- findings: z34.readonly(z34.array(DoctorFindingSchema))
20186
+ ok: z35.boolean(),
20187
+ findings: z35.readonly(z35.array(DoctorFindingSchema))
19970
20188
  });
19971
- var FrontDoorRestartOutputSchema = z34.strictObject({
19972
- action: z34.literal("restarting"),
19973
- previousPid: z34.int().positive()
20189
+ var FrontDoorRestartOutputSchema = z35.strictObject({
20190
+ action: z35.literal("restarting"),
20191
+ previousPid: z35.int().positive()
19974
20192
  });
19975
- var UpdateCheckOutputSchema = z34.strictObject({
19976
- current: z34.string(),
19977
- latest: z34.string(),
19978
- action: z34.enum(["current", "available", "updated"])
20193
+ var UpdateCheckOutputSchema = z35.strictObject({
20194
+ current: z35.string(),
20195
+ latest: z35.string(),
20196
+ action: z35.enum(["current", "available", "updated"])
19979
20197
  });
19980
- var CodexSignInSchema = z34.discriminatedUnion("state", [
19981
- z34.strictObject({ state: z34.literal("none") }),
19982
- z34.strictObject({ state: z34.literal("signed-in"), email: z34.string().optional(), planScope: z34.boolean(), accessTokenExpiresAt: z34.number() }),
19983
- z34.strictObject({ state: z34.literal("unreadable"), message: z34.string() })
20198
+ var CodexSignInSchema = z35.discriminatedUnion("state", [
20199
+ z35.strictObject({ state: z35.literal("none") }),
20200
+ z35.strictObject({ state: z35.literal("signed-in"), email: z35.string().optional(), planScope: z35.boolean(), accessTokenExpiresAt: z35.number() }),
20201
+ z35.strictObject({ state: z35.literal("unreadable"), message: z35.string() })
19984
20202
  ]);
19985
- var CodexStatusOutputSchema = z34.strictObject({
20203
+ var CodexStatusOutputSchema = z35.strictObject({
19986
20204
  signIn: CodexSignInSchema,
19987
- codexProviders: z34.readonly(z34.array(z34.string()))
20205
+ codexProviders: z35.readonly(z35.array(z35.string()))
19988
20206
  });
19989
- var CodexLogoutOutputSchema = z34.strictObject({
19990
- hadGrant: z34.boolean(),
19991
- revoked: z34.boolean()
20207
+ var CodexLogoutOutputSchema = z35.strictObject({
20208
+ hadGrant: z35.boolean(),
20209
+ revoked: z35.boolean()
19992
20210
  });
19993
20211
 
19994
20212
  // src/frontdoor/codexApi.ts
@@ -20056,67 +20274,67 @@ init_schema();
20056
20274
  init_names();
20057
20275
  init_keychainLogin();
20058
20276
  init_statusline();
20059
- import { z as z35 } from "zod";
20060
- var RemovalConfirmationSchema = z35.boolean();
20061
- var CredentialWriteSchema = (targets) => z35.strictObject({
20062
- sources: z35.array(RemoteCredentialSourceSchema).min(1).optional(),
20063
- target: z35.enum(targets).optional(),
20064
- cache: z35.union([z35.literal(false), CredentialCacheSchema]).optional()
20277
+ import { z as z36 } from "zod";
20278
+ var RemovalConfirmationSchema = z36.boolean();
20279
+ var CredentialWriteSchema = (targets) => z36.strictObject({
20280
+ sources: z36.array(RemoteCredentialSourceSchema).min(1).optional(),
20281
+ target: z36.enum(targets).optional(),
20282
+ cache: z36.union([z36.literal(false), CredentialCacheSchema]).optional()
20065
20283
  });
20066
- var CredentialSummarySchema2 = z35.strictObject({
20067
- target: z35.enum(CREDENTIAL_TARGETS),
20068
- sources: z35.readonly(z35.array(
20069
- z35.discriminatedUnion("kind", [
20070
- z35.strictObject({ kind: z35.literal("env"), variable: z35.string() }),
20071
- z35.strictObject({ kind: z35.literal("file"), path: z35.string() }),
20072
- z35.strictObject({ kind: z35.literal("command"), program: z35.string() }),
20073
- z35.strictObject({ kind: z35.literal("op"), reference: z35.string() }),
20074
- z35.strictObject({ kind: z35.literal("keychain"), service: z35.string(), account: z35.string().optional() }),
20075
- z35.strictObject({ kind: z35.literal("literal") })
20284
+ var CredentialSummarySchema2 = z36.strictObject({
20285
+ target: z36.enum(CREDENTIAL_TARGETS),
20286
+ sources: z36.readonly(z36.array(
20287
+ z36.discriminatedUnion("kind", [
20288
+ z36.strictObject({ kind: z36.literal("env"), variable: z36.string() }),
20289
+ z36.strictObject({ kind: z36.literal("file"), path: z36.string() }),
20290
+ z36.strictObject({ kind: z36.literal("command"), program: z36.string() }),
20291
+ z36.strictObject({ kind: z36.literal("op"), reference: z36.string() }),
20292
+ z36.strictObject({ kind: z36.literal("keychain"), service: z36.string(), account: z36.string().optional() }),
20293
+ z36.strictObject({ kind: z36.literal("literal") })
20076
20294
  ])
20077
20295
  )),
20078
20296
  cache: CredentialCacheSchema.optional()
20079
20297
  });
20080
- var mutationOutput = (kind, action) => z35.strictObject({ action: z35.literal(action), kind: z35.literal(kind), name: z35.string() });
20081
- var storedMutationOutput = (kind, action, value) => z35.strictObject({ action: z35.literal(action), kind: z35.literal(kind), name: z35.string(), value });
20082
- var IdentityValueSchema = z35.strictObject({
20083
- name: z35.string(),
20084
- label: z35.string().optional(),
20085
- defaultConfigProfile: z35.string().optional(),
20086
- provider: z35.string().optional(),
20087
- allowAmbientCredential: z35.boolean(),
20298
+ var mutationOutput = (kind, action) => z36.strictObject({ action: z36.literal(action), kind: z36.literal(kind), name: z36.string() });
20299
+ var storedMutationOutput = (kind, action, value) => z36.strictObject({ action: z36.literal(action), kind: z36.literal(kind), name: z36.string(), value });
20300
+ var IdentityValueSchema = z36.strictObject({
20301
+ name: z36.string(),
20302
+ label: z36.string().optional(),
20303
+ defaultConfigProfile: z36.string().optional(),
20304
+ provider: z36.string().optional(),
20305
+ allowAmbientCredential: z36.boolean(),
20088
20306
  credential: CredentialSummarySchema2.optional(),
20089
- anchors: z35.array(AnchorSchema).optional()
20307
+ anchors: z36.array(AnchorSchema).optional()
20090
20308
  });
20091
20309
  var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
20092
- var ProviderValueSchema = z35.strictObject({
20093
- name: z35.string(),
20094
- kind: z35.enum(PROVIDER_KINDS),
20095
- displayName: z35.string(),
20096
- baseUrl: z35.string().optional(),
20310
+ var ProviderValueSchema = z36.strictObject({
20311
+ name: z36.string(),
20312
+ kind: z36.enum(PROVIDER_KINDS),
20313
+ displayName: z36.string(),
20314
+ baseUrl: z36.string().optional(),
20097
20315
  codex: CodexProviderConfigSchema.optional(),
20098
20316
  credential: CredentialSummarySchema2.optional(),
20099
- env: z35.record(z35.string(), z35.string()).optional()
20317
+ env: z36.record(z36.string(), z36.string()).optional()
20100
20318
  });
20101
- var ConfigNameInputSchema = z35.strictObject({ name: z35.string().min(1) });
20102
- var ConfigIdentityAddInputSchema = z35.strictObject({ name: z35.string().min(1), keepKeychainLogin: z35.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
20319
+ var ConfigNameInputSchema = z36.strictObject({ name: z36.string().min(1) });
20320
+ var ConfigIdentityAddInputSchema = z36.strictObject({ name: z36.string().min(1), keepKeychainLogin: z36.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
20103
20321
  var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
20104
- var ConfigIdentitySetInputSchema = z35.strictObject({
20105
- name: z35.string().min(1),
20322
+ var ConfigIdentitySetInputSchema = z36.strictObject({
20323
+ name: z36.string().min(1),
20106
20324
  /** The identity's display label; `false` clears it. */
20107
- label: z35.union([IdentityLabelSchema, z35.literal(false)]).optional(),
20108
- defaultConfigProfile: z35.union([z35.string().min(1), z35.literal(false)]).optional(),
20325
+ label: z36.union([IdentityLabelSchema, z36.literal(false)]).optional(),
20326
+ defaultConfigProfile: z36.union([z36.string().min(1), z36.literal(false)]).optional(),
20109
20327
  /** The provider the identity exists for; `false` clears it. */
20110
- provider: z35.union([z35.string().min(1), z35.literal(false)]).optional(),
20111
- allowAmbientCredential: z35.boolean().optional(),
20112
- credential: z35.union([z35.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
20328
+ provider: z36.union([z36.string().min(1), z36.literal(false)]).optional(),
20329
+ allowAmbientCredential: z36.boolean().optional(),
20330
+ credential: z36.union([z36.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
20113
20331
  /** `false` removes the anchors; a list replaces them. */
20114
- anchors: z35.union([z35.literal(false), z35.array(AnchorSchema).min(1)]).optional()
20332
+ anchors: z36.union([z36.literal(false), z36.array(AnchorSchema).min(1)]).optional()
20115
20333
  });
20116
20334
  var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
20117
- var ConfigIdentityRemoveInputSchema = z35.strictObject({ name: z35.string().min(1), confirm: RemovalConfirmationSchema });
20335
+ var ConfigIdentityRemoveInputSchema = z36.strictObject({ name: z36.string().min(1), confirm: RemovalConfirmationSchema });
20118
20336
  var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
20119
- var ConfigStatuslineSetSchema = z35.record(z35.string(), z35.unknown()).superRefine((settings, context) => {
20337
+ var ConfigStatuslineSetSchema = z36.record(z36.string(), z36.unknown()).superRefine((settings, context) => {
20120
20338
  for (const key of Object.keys(settings)) {
20121
20339
  if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
20122
20340
  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` });
@@ -20124,93 +20342,93 @@ var ConfigStatuslineSetSchema = z35.record(z35.string(), z35.unknown()).superRef
20124
20342
  }
20125
20343
  });
20126
20344
  var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
20127
- var ConfigProfileAddInputSchema = z35.strictObject({
20128
- name: z35.string().min(1),
20129
- extends: z35.array(z35.string().min(1)).optional(),
20130
- description: z35.string().optional()
20345
+ var ConfigProfileAddInputSchema = z36.strictObject({
20346
+ name: z36.string().min(1),
20347
+ extends: z36.array(z36.string().min(1)).optional(),
20348
+ description: z36.string().optional()
20131
20349
  });
20132
20350
  var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
20133
- var ConfigProfileSetInputSchema = z35.strictObject({
20134
- name: z35.string().min(1),
20135
- category: z35.record(z35.string(), z35.boolean()).optional(),
20136
- entry: z35.record(z35.string(), z35.boolean()).optional(),
20137
- extends: z35.union([z35.array(z35.string().min(1)), z35.literal(false)]).optional(),
20138
- description: z35.union([z35.string(), z35.literal(false)]).optional(),
20139
- launch: z35.strictObject({
20140
- skipPermissions: z35.boolean().optional(),
20141
- remoteControl: z35.boolean().optional(),
20142
- headroom: z35.boolean().optional(),
20143
- trackUsage: z35.boolean().optional(),
20144
- provider: z35.union([z35.string().min(1), z35.literal(false)]).optional(),
20145
- claudeVersion: z35.union([z35.string().min(1), z35.literal(false)]).optional(),
20146
- delay: z35.union([z35.string().regex(DURATION_RE), z35.literal(false)]).optional(),
20147
- pause: z35.boolean().optional(),
20148
- explain: z35.boolean().optional(),
20149
- proxyBypass: z35.union([z35.array(z35.string().min(1)), z35.literal(false)]).optional(),
20150
- statusline: z35.strictObject({
20351
+ var ConfigProfileSetInputSchema = z36.strictObject({
20352
+ name: z36.string().min(1),
20353
+ category: z36.record(z36.string(), z36.boolean()).optional(),
20354
+ entry: z36.record(z36.string(), z36.boolean()).optional(),
20355
+ extends: z36.union([z36.array(z36.string().min(1)), z36.literal(false)]).optional(),
20356
+ description: z36.union([z36.string(), z36.literal(false)]).optional(),
20357
+ launch: z36.strictObject({
20358
+ skipPermissions: z36.boolean().optional(),
20359
+ remoteControl: z36.boolean().optional(),
20360
+ headroom: z36.boolean().optional(),
20361
+ trackUsage: z36.boolean().optional(),
20362
+ provider: z36.union([z36.string().min(1), z36.literal(false)]).optional(),
20363
+ claudeVersion: z36.union([z36.string().min(1), z36.literal(false)]).optional(),
20364
+ delay: z36.union([z36.string().regex(DURATION_RE), z36.literal(false)]).optional(),
20365
+ pause: z36.boolean().optional(),
20366
+ explain: z36.boolean().optional(),
20367
+ proxyBypass: z36.union([z36.array(z36.string().min(1)), z36.literal(false)]).optional(),
20368
+ statusline: z36.strictObject({
20151
20369
  set: ConfigStatuslineSetSchema.optional(),
20152
- unset: z35.array(z35.string()).optional()
20370
+ unset: z36.array(z36.string()).optional()
20153
20371
  }).optional()
20154
20372
  }).optional()
20155
20373
  });
20156
20374
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
20157
- var ConfigProfileRemoveInputSchema = z35.strictObject({ name: z35.string().min(1), confirm: RemovalConfirmationSchema });
20375
+ var ConfigProfileRemoveInputSchema = z36.strictObject({ name: z36.string().min(1), confirm: RemovalConfirmationSchema });
20158
20376
  var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
20159
20377
  var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
20160
- var PoolMembersInputSchema = z35.array(z35.string().min(1)).min(1);
20161
- var ConfigPoolAddInputSchema = z35.strictObject({
20162
- name: z35.string().min(1),
20378
+ var PoolMembersInputSchema = z36.array(z36.string().min(1)).min(1);
20379
+ var ConfigPoolAddInputSchema = z36.strictObject({
20380
+ name: z36.string().min(1),
20163
20381
  identities: PoolMembersInputSchema,
20164
- preference: z35.enum(POOL_PREFERENCES).optional(),
20165
- resumeOnLimit: z35.boolean().optional(),
20166
- compactBeforeLimit: z35.boolean().optional(),
20382
+ preference: z36.enum(POOL_PREFERENCES).optional(),
20383
+ resumeOnLimit: z36.boolean().optional(),
20384
+ compactBeforeLimit: z36.boolean().optional(),
20167
20385
  compactAtUtilisation: CompactAtUtilisationSchema.optional()
20168
20386
  });
20169
20387
  var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
20170
- var ConfigPoolSetInputSchema = z35.strictObject({
20171
- name: z35.string().min(1),
20388
+ var ConfigPoolSetInputSchema = z36.strictObject({
20389
+ name: z36.string().min(1),
20172
20390
  identities: PoolMembersInputSchema.optional(),
20173
- preference: z35.union([z35.enum(POOL_PREFERENCES), z35.literal(false)]).optional(),
20174
- resumeOnLimit: z35.boolean().optional(),
20175
- compactBeforeLimit: z35.boolean().optional(),
20176
- compactAtUtilisation: z35.union([CompactAtUtilisationSchema, z35.literal(false)]).optional()
20391
+ preference: z36.union([z36.enum(POOL_PREFERENCES), z36.literal(false)]).optional(),
20392
+ resumeOnLimit: z36.boolean().optional(),
20393
+ compactBeforeLimit: z36.boolean().optional(),
20394
+ compactAtUtilisation: z36.union([CompactAtUtilisationSchema, z36.literal(false)]).optional()
20177
20395
  });
20178
20396
  var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
20179
- var ConfigPoolRemoveInputSchema = z35.strictObject({ name: z35.string().min(1), confirm: RemovalConfirmationSchema });
20397
+ var ConfigPoolRemoveInputSchema = z36.strictObject({ name: z36.string().min(1), confirm: RemovalConfirmationSchema });
20180
20398
  var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
20181
20399
  var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
20182
- var ConfigProviderAddInputSchema = z35.strictObject({
20183
- name: z35.string().min(1),
20184
- kind: z35.enum(PROVIDER_KINDS).optional(),
20185
- displayName: z35.string().min(1),
20186
- baseUrl: z35.string().min(1).optional(),
20400
+ var ConfigProviderAddInputSchema = z36.strictObject({
20401
+ name: z36.string().min(1),
20402
+ kind: z36.enum(PROVIDER_KINDS).optional(),
20403
+ displayName: z36.string().min(1),
20404
+ baseUrl: z36.string().min(1).optional(),
20187
20405
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
20188
20406
  codex: CodexProviderConfigSchema.optional()
20189
20407
  });
20190
20408
  var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
20191
- var ConfigProviderSetInputSchema = z35.strictObject({
20192
- name: z35.string().min(1),
20193
- displayName: z35.string().min(1).optional(),
20194
- baseUrl: z35.string().min(1).optional(),
20409
+ var ConfigProviderSetInputSchema = z36.strictObject({
20410
+ name: z36.string().min(1),
20411
+ displayName: z36.string().min(1).optional(),
20412
+ baseUrl: z36.string().min(1).optional(),
20195
20413
  credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
20196
20414
  codex: CodexProviderConfigSchema.optional()
20197
20415
  });
20198
20416
  var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
20199
- var ConfigProviderRemoveInputSchema = z35.strictObject({ name: z35.string().min(1), confirm: RemovalConfirmationSchema });
20417
+ var ConfigProviderRemoveInputSchema = z36.strictObject({ name: z36.string().min(1), confirm: RemovalConfirmationSchema });
20200
20418
  var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
20201
- var ConfigRuleAddInputSchema = z35.strictObject({
20202
- path: z35.string().min(1),
20203
- configProfile: z35.string().min(1).optional(),
20204
- identity: z35.string().min(1).optional()
20419
+ var ConfigRuleAddInputSchema = z36.strictObject({
20420
+ path: z36.string().min(1),
20421
+ configProfile: z36.string().min(1).optional(),
20422
+ identity: z36.string().min(1).optional()
20205
20423
  });
20206
20424
  var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
20207
- var ConfigRuleSetInputSchema = z35.strictObject({
20208
- path: z35.string().min(1),
20209
- configProfile: z35.union([z35.string().min(1), z35.literal(false)]).optional(),
20210
- identity: z35.union([z35.string().min(1), z35.literal(false)]).optional()
20425
+ var ConfigRuleSetInputSchema = z36.strictObject({
20426
+ path: z36.string().min(1),
20427
+ configProfile: z36.union([z36.string().min(1), z36.literal(false)]).optional(),
20428
+ identity: z36.union([z36.string().min(1), z36.literal(false)]).optional()
20211
20429
  });
20212
20430
  var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
20213
- var ConfigRuleRemoveInputSchema = z35.strictObject({ path: z35.string().min(1), confirm: RemovalConfirmationSchema });
20431
+ var ConfigRuleRemoveInputSchema = z36.strictObject({ path: z36.string().min(1), confirm: RemovalConfirmationSchema });
20214
20432
  var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
20215
20433
 
20216
20434
  // src/frontdoor/configApi.ts
@@ -20563,50 +20781,50 @@ import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from
20563
20781
 
20564
20782
  // src/frontdoor/eventSchemas.ts
20565
20783
  init_schema2();
20566
- import { z as z36 } from "zod";
20784
+ import { z as z37 } from "zod";
20567
20785
  var DOOR_EVENT_SOURCE_RC = "rc";
20568
20786
  var LAUNCH_EVENT_SOURCE = "launch";
20569
20787
  var USAGE_EVENT_SOURCE = "usage";
20570
20788
  var DOOR_HEALTH_EVENT_SOURCE = "door";
20571
20789
  var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
20572
- var DoorEventSchema = z36.strictObject({
20573
- source: z36.string().min(1),
20790
+ var DoorEventSchema = z37.strictObject({
20791
+ source: z37.string().min(1),
20574
20792
  /** A positive integer because the backbone's counters start at one and only ever increase. */
20575
- sequence: z36.number().int().positive(),
20576
- payload: z36.unknown()
20793
+ sequence: z37.number().int().positive(),
20794
+ payload: z37.unknown()
20577
20795
  });
20578
- var DoorEventSourceQuerySchema = z36.strictObject({
20579
- sources: z36.array(z36.string().min(1)).min(1).optional()
20796
+ var DoorEventSourceQuerySchema = z37.strictObject({
20797
+ sources: z37.array(z37.string().min(1)).min(1).optional()
20580
20798
  });
20581
- var LaunchLifecycleEventSchema = z36.strictObject({
20582
- kind: z36.enum(["registered", "pruned", "ended"]),
20583
- pid: z36.number().int().positive(),
20584
- startedAt: z36.number(),
20585
- observedAt: z36.number()
20799
+ var LaunchLifecycleEventSchema = z37.strictObject({
20800
+ kind: z37.enum(["registered", "pruned", "ended"]),
20801
+ pid: z37.number().int().positive(),
20802
+ startedAt: z37.number(),
20803
+ observedAt: z37.number()
20586
20804
  });
20587
- var DoorHealthEventSchema = z36.discriminatedUnion("kind", [
20588
- z36.strictObject({ kind: z36.literal("generation"), pid: z36.number().int().positive(), providerPort: z36.number().int().positive(), connectPort: z36.number().int().positive(), directPort: z36.number().int().positive(), observedAt: z36.number() }),
20589
- z36.strictObject({ kind: z36.literal("listenerFailed"), pid: z36.number().int().positive(), listener: z36.enum(["provider", "connect", "direct"]), message: z36.string(), observedAt: z36.number() }),
20590
- z36.strictObject({ kind: z36.literal("binaryTurnover"), pid: z36.number().int().positive(), observedAt: z36.number() }),
20591
- z36.strictObject({ kind: z36.literal("idleShutdown"), pid: z36.number().int().positive(), observedAt: z36.number() }),
20592
- z36.strictObject({ kind: z36.literal("superseded"), pid: z36.number().int().positive(), ownerPid: z36.number().int().positive(), observedAt: z36.number() }),
20593
- z36.strictObject({ kind: z36.literal("drained"), pid: z36.number().int().positive(), observedAt: z36.number() })
20805
+ var DoorHealthEventSchema = z37.discriminatedUnion("kind", [
20806
+ z37.strictObject({ kind: z37.literal("generation"), pid: z37.number().int().positive(), providerPort: z37.number().int().positive(), connectPort: z37.number().int().positive(), directPort: z37.number().int().positive(), observedAt: z37.number() }),
20807
+ z37.strictObject({ kind: z37.literal("listenerFailed"), pid: z37.number().int().positive(), listener: z37.enum(["provider", "connect", "direct"]), message: z37.string(), observedAt: z37.number() }),
20808
+ z37.strictObject({ kind: z37.literal("binaryTurnover"), pid: z37.number().int().positive(), observedAt: z37.number() }),
20809
+ z37.strictObject({ kind: z37.literal("idleShutdown"), pid: z37.number().int().positive(), observedAt: z37.number() }),
20810
+ z37.strictObject({ kind: z37.literal("superseded"), pid: z37.number().int().positive(), ownerPid: z37.number().int().positive(), observedAt: z37.number() }),
20811
+ z37.strictObject({ kind: z37.literal("drained"), pid: z37.number().int().positive(), observedAt: z37.number() })
20594
20812
  ]);
20595
- var QuotaExpiringEventSchema = z36.strictObject({
20813
+ var QuotaExpiringEventSchema = z37.strictObject({
20596
20814
  /** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
20597
- id: z36.string().min(1),
20815
+ id: z37.string().min(1),
20598
20816
  /** The identity's name when the event was published, absent for an identity no longer stored under the id. */
20599
- name: z36.string().min(1).optional(),
20600
- provider: z36.string().min(1),
20601
- window: z36.enum(["fiveHour", "sevenDay"]),
20817
+ name: z37.string().min(1).optional(),
20818
+ provider: z37.string().min(1),
20819
+ window: z37.enum(["fiveHour", "sevenDay"]),
20602
20820
  /** 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. */
20603
- utilization: z36.number().min(0).max(1),
20604
- resetsAt: z36.iso.datetime(),
20605
- observedAt: z36.number()
20821
+ utilization: z37.number().min(0).max(1),
20822
+ resetsAt: z37.iso.datetime(),
20823
+ observedAt: z37.number()
20606
20824
  });
20607
20825
  var UsageChangeEventSchema = UsageSnapshotSchema.extend({
20608
- id: z36.string().min(1),
20609
- name: z36.string().min(1).optional()
20826
+ id: z37.string().min(1),
20827
+ name: z37.string().min(1).optional()
20610
20828
  });
20611
20829
 
20612
20830
  // src/frontdoor/eventsApi.ts
@@ -20651,14 +20869,14 @@ function createEventsApiRouter(deps) {
20651
20869
  init_update();
20652
20870
  import { ORPCError as ORPCError4 } from "@orpc/client";
20653
20871
  import { openapi as openapi5 } from "@orpc/openapi";
20654
- import { z as z37 } from "zod";
20872
+ import { z as z38 } from "zod";
20655
20873
  var FRONTDOOR_API_TAG = "frontdoor";
20656
20874
  var UPDATE_API_TAG = "update";
20657
20875
  function createLifecycleApiRouter(deps) {
20658
20876
  const authed = doorApiAuth(deps.expectedToken);
20659
20877
  return {
20660
20878
  frontdoor: {
20661
- refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z37.strictObject({ requested: z37.literal(true) })).handler(() => {
20879
+ refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z38.strictObject({ requested: z38.literal(true) })).handler(() => {
20662
20880
  deps.refreshCatalogues();
20663
20881
  return { requested: true };
20664
20882
  }),
@@ -20695,61 +20913,62 @@ import { openapi as openapi6 } from "@orpc/openapi";
20695
20913
 
20696
20914
  // src/frontdoor/launchSchemas.ts
20697
20915
  import path43 from "node:path";
20698
- import { z as z38 } from "zod";
20916
+ import { z as z39 } from "zod";
20699
20917
  init_statusline();
20700
20918
  init_claudeVersion();
20701
20919
  init_identity();
20702
- var LaunchResolveInputSchema = z38.strictObject({
20703
- path: z38.string().min(1),
20920
+ var LaunchResolveInputSchema = z39.strictObject({
20921
+ path: z39.string().min(1),
20704
20922
  /** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
20705
- argv: z38.readonly(z38.array(z38.string())).optional(),
20923
+ argv: z39.readonly(z39.array(z39.string())).optional(),
20706
20924
  /** 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. */
20707
- env: z38.record(z38.string(), z38.string()).optional()
20925
+ env: z39.record(z39.string(), z39.string()).optional()
20708
20926
  }).refine((input) => path43.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20709
- var LaunchPoolDecisionSchema = z38.strictObject({
20710
- name: z38.string(),
20711
- reasons: z38.readonly(z38.array(z38.string())),
20712
- movedOff: z38.strictObject({ identity: z38.string(), reason: z38.string() }).optional()
20927
+ var LaunchPoolDecisionSchema = z39.strictObject({
20928
+ name: z39.string(),
20929
+ reasons: z39.readonly(z39.array(z39.string())),
20930
+ movedOff: z39.strictObject({ identity: z39.string(), reason: z39.string() }).optional()
20713
20931
  });
20714
- var LaunchDecisionSchema = z38.strictObject({
20715
- identity: z38.string().optional(),
20716
- identityId: z38.string().optional(),
20717
- identitySource: z38.enum(IDENTITY_DECISION_SOURCES),
20932
+ var LaunchDecisionSchema = z39.strictObject({
20933
+ identity: z39.string().optional(),
20934
+ identityId: z39.string().optional(),
20935
+ identitySource: z39.enum(IDENTITY_DECISION_SOURCES),
20718
20936
  pool: LaunchPoolDecisionSchema.optional(),
20719
- configDirEscapeHatch: z38.boolean(),
20720
- configDir: z38.string().optional(),
20721
- configProfile: z38.string().optional(),
20722
- configProfileSource: z38.enum(CONFIG_PROFILE_DECISION_SOURCES),
20723
- provider: z38.string().optional()
20937
+ /** 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. */
20938
+ configDirEscapeHatch: z39.boolean(),
20939
+ configDir: z39.string().optional(),
20940
+ configProfile: z39.string().optional(),
20941
+ configProfileSource: z39.enum(CONFIG_PROFILE_DECISION_SOURCES),
20942
+ provider: z39.string().optional()
20724
20943
  });
20725
- var LaunchFlagsSchema = z38.strictObject({
20726
- skipPermissions: z38.boolean(),
20727
- remoteControl: z38.boolean(),
20728
- headroom: z38.boolean(),
20729
- trackUsage: z38.boolean(),
20730
- pause: z38.boolean(),
20731
- explain: z38.boolean(),
20944
+ var LaunchFlagsSchema = z39.strictObject({
20945
+ skipPermissions: z39.boolean(),
20946
+ remoteControl: z39.boolean(),
20947
+ headroom: z39.boolean(),
20948
+ trackUsage: z39.boolean(),
20949
+ pause: z39.boolean(),
20950
+ explain: z39.boolean(),
20732
20951
  /** How long the launch waits after its own output before it starts claude, in milliseconds. */
20733
- delayMs: z38.number(),
20952
+ delayMs: z39.number(),
20734
20953
  /** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
20735
- proxyBypass: z38.array(z38.string()).readonly(),
20954
+ proxyBypass: z39.array(z39.string()).readonly(),
20736
20955
  /** How the session's built-in statusline looks, when the launch configures any of it. */
20737
20956
  statusline: StatuslineSchema.optional()
20738
20957
  });
20739
- var LaunchResolveOutputSchema = z38.strictObject({
20958
+ var LaunchResolveOutputSchema = z39.strictObject({
20740
20959
  decision: LaunchDecisionSchema,
20741
20960
  flags: LaunchFlagsSchema,
20742
- claudeVersion: z38.strictObject({ version: z38.string(), source: z38.enum(CLAUDE_VERSION_SOURCES) }).optional(),
20961
+ claudeVersion: z39.strictObject({ version: z39.string(), source: z39.enum(CLAUDE_VERSION_SOURCES) }).optional(),
20743
20962
  /** The real `claude` binary the launch would spawn, on the door's host. */
20744
- bin: z38.string(),
20963
+ bin: z39.string(),
20745
20964
  /** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
20746
- args: z38.readonly(z38.array(z38.string())),
20965
+ args: z39.readonly(z39.array(z39.string())),
20747
20966
  /** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
20748
- credential: z38.strictObject({ subject: z38.enum(["provider", "identity"]), name: z38.string(), summary: CredentialSummarySchema }).optional(),
20749
- routing: z38.strictObject({ frontDoor: z38.boolean(), headroom: z38.boolean() }),
20967
+ credential: z39.strictObject({ subject: z39.enum(["provider", "identity"]), name: z39.string(), summary: CredentialSummarySchema }).optional(),
20968
+ routing: z39.strictObject({ frontDoor: z39.boolean(), headroom: z39.boolean() }),
20750
20969
  /** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
20751
- environment: z38.readonly(z38.array(z38.string())),
20752
- warnings: z38.readonly(z38.array(z38.string()))
20970
+ environment: z39.readonly(z39.array(z39.string())),
20971
+ warnings: z39.readonly(z39.array(z39.string()))
20753
20972
  });
20754
20973
 
20755
20974
  // src/frontdoor/launchApi.ts
@@ -20785,22 +21004,22 @@ function createLaunchApiRouter(deps) {
20785
21004
  // src/frontdoor/agentTreesApi.ts
20786
21005
  import { ORPCError as ORPCError6 } from "@orpc/client";
20787
21006
  import { openapi as openapi7 } from "@orpc/openapi";
20788
- import { z as z39 } from "zod";
21007
+ import { z as z40 } from "zod";
20789
21008
  init_cliError();
20790
- var AgentTreesListInputSchema = z39.strictObject({
21009
+ var AgentTreesListInputSchema = z40.strictObject({
20791
21010
  /** Only this identity's sessions. */
20792
- identity: z39.string().optional(),
21011
+ identity: z40.string().optional(),
20793
21012
  /** Include sessions that spawned no agent and ran no workflow. */
20794
- all: z39.boolean().optional()
21013
+ all: z40.boolean().optional()
20795
21014
  });
20796
- var AgentTreesListOutputSchema = z39.array(SessionSummarySchema);
20797
- var AgentTreesShowInputSchema = z39.strictObject({
21015
+ var AgentTreesListOutputSchema = z40.array(SessionSummarySchema);
21016
+ var AgentTreesShowInputSchema = z40.strictObject({
20798
21017
  /** A session id, or an unambiguous prefix of one. */
20799
- session: z39.string().min(1),
21018
+ session: z40.string().min(1),
20800
21019
  /** Look only in this identity. */
20801
- identity: z39.string().optional()
21020
+ identity: z40.string().optional()
20802
21021
  });
20803
- var AgentTreesShowOutputSchema = z39.strictObject({ identities: z39.array(z39.string()), ...MergedAgentTreeSchema.shape });
21022
+ var AgentTreesShowOutputSchema = z40.strictObject({ identities: z40.array(z40.string()), ...MergedAgentTreeSchema.shape });
20804
21023
  function asBadRequest(error) {
20805
21024
  if (error instanceof CliError) {
20806
21025
  throw new ORPCError6("BAD_REQUEST", { message: error.message });
@@ -20847,22 +21066,397 @@ function createAgentTreesApiRouter(deps) {
20847
21066
  };
20848
21067
  }
20849
21068
 
20850
- // src/frontdoor/controlApi.ts
20851
- var USAGE_API_TAG = "usage";
20852
- var FRONTDOOR_API_TAG2 = "frontdoor";
20853
- var CHECK_API_TAG = "check";
20854
- var DOCTOR_API_TAG = "doctor";
20855
- var POOL_API_TAG = "pool";
20856
- function createControlApiRouter(deps) {
20857
- const authed = doorApiAuth(deps.expectedToken);
20858
- return {
20859
- usage: {
20860
- list: authed.meta(openapi8({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] })).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
20861
- resets: authed.meta(openapi8({ method: "GET", path: "/rest/usage/resets", summary: "List every recorded quota window with when it resets", tags: [USAGE_API_TAG] })).output(ResetScheduleSchema).handler(() => collectResets(deps.usageSnapshots(), deps.now())),
20862
- effectiveWindow: authed.meta(openapi8({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] })).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input }) => {
20863
- const snapshot = deps.usageSnapshotOf(input.identity);
20864
- if (snapshot === void 0) {
20865
- throw new ORPCError7("NOT_FOUND", { message: `identity ${input.identity} has no usage snapshot yet, so no quota window has been observed for it` });
21069
+ // src/frontdoor/rcEventLogApi.ts
21070
+ import { ORPCError as ORPCError7 } from "@orpc/client";
21071
+ import { openapi as openapi8 } from "@orpc/openapi";
21072
+ import { eventIterator as eventIterator3, withEventMeta as withEventMeta3 } from "@orpc/server";
21073
+
21074
+ // src/frontdoor/rcEventLog.ts
21075
+ import { z as z41 } from "zod";
21076
+
21077
+ // src/frontdoor/eventHub.ts
21078
+ var DOOR_EVENT_BUFFER_EVENTS = 100;
21079
+ function createDoorEventHub() {
21080
+ const sequences = /* @__PURE__ */ new Map();
21081
+ const registered = /* @__PURE__ */ new Set();
21082
+ const every = /* @__PURE__ */ new Set();
21083
+ const bySource = /* @__PURE__ */ new Map();
21084
+ const deliver = (event) => {
21085
+ for (const listener of every) {
21086
+ listener(event);
21087
+ }
21088
+ for (const listener of bySource.get(event.source) ?? []) {
21089
+ listener(event);
21090
+ }
21091
+ };
21092
+ const publish = (source, payload) => {
21093
+ const sequence2 = (sequences.get(source) ?? 0) + 1;
21094
+ sequences.set(source, sequence2);
21095
+ deliver({ source, sequence: sequence2, payload });
21096
+ };
21097
+ const addListener = (sources, listener) => {
21098
+ if (sources === void 0) {
21099
+ every.add(listener);
21100
+ return () => {
21101
+ every.delete(listener);
21102
+ };
21103
+ }
21104
+ const listenersFor = (source) => {
21105
+ const listeners = bySource.get(source) ?? /* @__PURE__ */ new Set();
21106
+ bySource.set(source, listeners);
21107
+ return listeners;
21108
+ };
21109
+ const detachers = sources.map((source) => {
21110
+ const listeners = listenersFor(source);
21111
+ listeners.add(listener);
21112
+ return () => {
21113
+ listeners.delete(listener);
21114
+ if (listeners.size === 0) {
21115
+ bySource.delete(source);
21116
+ }
21117
+ };
21118
+ });
21119
+ return () => {
21120
+ for (const detach of detachers) {
21121
+ detach();
21122
+ }
21123
+ };
21124
+ };
21125
+ return {
21126
+ publisher: (source) => {
21127
+ registered.add(source);
21128
+ return {
21129
+ source,
21130
+ publish: (payload) => {
21131
+ publish(source, payload);
21132
+ }
21133
+ };
21134
+ },
21135
+ subscribe: addListener,
21136
+ stream: (sources) => {
21137
+ const queue = [];
21138
+ let wake;
21139
+ let closed = false;
21140
+ const detach = addListener(sources, (event) => {
21141
+ if (queue.length >= DOOR_EVENT_BUFFER_EVENTS) {
21142
+ queue.shift();
21143
+ }
21144
+ queue.push(event);
21145
+ wake?.();
21146
+ });
21147
+ return {
21148
+ next: async () => {
21149
+ for (; ; ) {
21150
+ const event = queue.shift();
21151
+ if (event !== void 0) {
21152
+ return { value: event, done: false };
21153
+ }
21154
+ if (closed) {
21155
+ return { value: void 0, done: true };
21156
+ }
21157
+ await new Promise((resolve) => {
21158
+ wake = resolve;
21159
+ });
21160
+ }
21161
+ },
21162
+ close: () => {
21163
+ closed = true;
21164
+ detach();
21165
+ wake?.();
21166
+ }
21167
+ };
21168
+ },
21169
+ sources: () => [...registered].sort()
21170
+ };
21171
+ }
21172
+ function rcFanoutOnDoorHub(fanout, hub) {
21173
+ const publisher = hub.publisher(DOOR_EVENT_SOURCE_RC);
21174
+ return {
21175
+ publish: (event) => {
21176
+ fanout.publish(event);
21177
+ publisher.publish(event);
21178
+ },
21179
+ subscribe: (session, listener) => fanout.subscribe(session, listener)
21180
+ };
21181
+ }
21182
+
21183
+ // src/frontdoor/rcEventLog.ts
21184
+ var RC_SESSION_EVENT_TOKEN_MAX_CHARS = 255;
21185
+ var HIGH_SURROGATE_FIRST = 55296;
21186
+ var HIGH_SURROGATE_LAST = 56319;
21187
+ var LOW_SURROGATE_FIRST = 56320;
21188
+ var LOW_SURROGATE_LAST = 57343;
21189
+ var CUT_MARKER = "...";
21190
+ var RC_SESSION_EVENT_SUMMARY_MAX_CHARS = RC_SESSION_EVENT_TOKEN_MAX_CHARS + " ".length + RC_PENDING_SUMMARY_EXCERPT_CHARS + CUT_MARKER.length;
21191
+ var RC_SESSION_EVENT_GENERATION_MAX_CHARS = "00000000-0000-4000-8000-000000000000".length;
21192
+ var SEQUENCE_MAX_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
21193
+ var NUMBER_BYTES = Float64Array.BYTES_PER_ELEMENT;
21194
+ var NUMBER_FIELDS = ["at", "sequence"].length;
21195
+ var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
21196
+ var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
21197
+ var RC_PENDING_RETIRE_REASONS = ["answered", "expired", "session-ended"];
21198
+ var transitionBase = { session: z41.string(), at: z41.number() };
21199
+ var cursorFields = { cursor: z41.string(), sequence: z41.int().positive() };
21200
+ var sessionAppearedShape = { kind: z41.literal("session-appeared"), ...transitionBase };
21201
+ var sessionEndedShape = { kind: z41.literal("session-ended"), reason: z41.enum(RC_SESSION_END_REASONS), ...transitionBase };
21202
+ var workerStateShape = { kind: z41.literal("worker-state"), state: z41.string(), previous: z41.string().optional(), ...transitionBase };
21203
+ var pendingBornShape = { kind: z41.literal("pending-born"), requestId: z41.string(), type: z41.string(), summary: z41.string(), ...transitionBase };
21204
+ var pendingRetiredShape = { kind: z41.literal("pending-retired"), requestId: z41.string(), reason: z41.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
21205
+ var RcSessionTransitionSchema = z41.discriminatedUnion("kind", [
21206
+ z41.strictObject(sessionAppearedShape),
21207
+ z41.strictObject(sessionEndedShape),
21208
+ z41.strictObject(workerStateShape),
21209
+ z41.strictObject(pendingBornShape),
21210
+ z41.strictObject(pendingRetiredShape)
21211
+ ]);
21212
+ var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
21213
+ 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;
21214
+ var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
21215
+ var RcSessionEventSchema = z41.discriminatedUnion("kind", [
21216
+ z41.strictObject({ ...cursorFields, ...sessionAppearedShape }),
21217
+ z41.strictObject({ ...cursorFields, ...sessionEndedShape }),
21218
+ z41.strictObject({ ...cursorFields, ...workerStateShape }),
21219
+ z41.strictObject({ ...cursorFields, ...pendingBornShape }),
21220
+ z41.strictObject({ ...cursorFields, ...pendingRetiredShape })
21221
+ ]);
21222
+ var RcSessionEventsReadInputSchema = z41.strictObject({
21223
+ /** The cursor of the last event the caller saw; every retained event when omitted. */
21224
+ since: z41.string().min(1).optional(),
21225
+ /** One `cse_` session id; every session when omitted. */
21226
+ session: z41.string().min(1).optional(),
21227
+ /** The most events one answer carries; every event after `since` when omitted. */
21228
+ limit: z41.int().positive().optional()
21229
+ });
21230
+ var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
21231
+ /** 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. */
21232
+ limit: z41.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
21233
+ });
21234
+ var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
21235
+ var RcSessionEventsReadOutputSchema = z41.discriminatedUnion("status", [
21236
+ z41.strictObject({ status: z41.literal("ok"), events: z41.readonly(z41.array(RcSessionEventSchema)), cursor: z41.string(), more: z41.boolean(), head: z41.string() }),
21237
+ z41.strictObject({ status: z41.literal("expired"), message: z41.string(), head: z41.string() })
21238
+ ]);
21239
+ var CURSOR_SEPARATOR = ".";
21240
+ 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";
21241
+ function cursorOf(generation, sequence2) {
21242
+ return `${generation}${CURSOR_SEPARATOR}${String(sequence2)}`;
21243
+ }
21244
+ function parseCursor(cursor) {
21245
+ const at = cursor.lastIndexOf(CURSOR_SEPARATOR);
21246
+ if (at <= 0) {
21247
+ return void 0;
21248
+ }
21249
+ const digits = cursor.slice(at + 1);
21250
+ if (!/^[0-9]+$/.test(digits)) {
21251
+ return void 0;
21252
+ }
21253
+ return { generation: cursor.slice(0, at), sequence: Number(digits) };
21254
+ }
21255
+ function codePointBoundary(text, at) {
21256
+ const before = text.charCodeAt(at - 1);
21257
+ const after = text.charCodeAt(at);
21258
+ const isHigh = before >= HIGH_SURROGATE_FIRST && before <= HIGH_SURROGATE_LAST;
21259
+ const isLow = after >= LOW_SURROGATE_FIRST && after <= LOW_SURROGATE_LAST;
21260
+ return isHigh && isLow ? at - 1 : at;
21261
+ }
21262
+ function bounded2(text, maxChars) {
21263
+ const kept = text.length <= maxChars ? text : `${text.slice(0, codePointBoundary(text, maxChars - CUT_MARKER.length))}${CUT_MARKER}`;
21264
+ return Buffer.from(kept, "utf16le").toString("utf16le");
21265
+ }
21266
+ function boundedTransition(transition) {
21267
+ const session = bounded2(transition.session, RC_SESSION_EVENT_TOKEN_MAX_CHARS);
21268
+ if (transition.kind === "worker-state") {
21269
+ return { ...transition, session, state: bounded2(transition.state, RC_SESSION_EVENT_TOKEN_MAX_CHARS), ...transition.previous === void 0 ? {} : { previous: bounded2(transition.previous, RC_SESSION_EVENT_TOKEN_MAX_CHARS) } };
21270
+ }
21271
+ if (transition.kind === "pending-born") {
21272
+ return { ...transition, session, requestId: bounded2(transition.requestId, RC_SESSION_EVENT_TOKEN_MAX_CHARS), type: bounded2(transition.type, RC_SESSION_EVENT_TOKEN_MAX_CHARS), summary: bounded2(transition.summary, RC_SESSION_EVENT_SUMMARY_MAX_CHARS) };
21273
+ }
21274
+ if (transition.kind === "pending-retired") {
21275
+ return { ...transition, session, requestId: bounded2(transition.requestId, RC_SESSION_EVENT_TOKEN_MAX_CHARS) };
21276
+ }
21277
+ return { ...transition, session };
21278
+ }
21279
+ function createRcSessionEventLog(deps) {
21280
+ if (deps.generation.includes(CURSOR_SEPARATOR)) {
21281
+ throw new Error(`a door generation id must not contain "${CURSOR_SEPARATOR}", which separates a cursor's generation from its sequence`);
21282
+ }
21283
+ if (deps.generation.length > RC_SESSION_EVENT_GENERATION_MAX_CHARS) {
21284
+ throw new Error(`a door generation id must be at most ${String(RC_SESSION_EVENT_GENERATION_MAX_CHARS)} characters, a UUID's length`);
21285
+ }
21286
+ const events = [];
21287
+ let lastSequence = 0;
21288
+ const listeners = /* @__PURE__ */ new Set();
21289
+ let isClosed = false;
21290
+ const expired = (reason) => ({ status: "expired", message: `${reason}; ${RESYNC_ADVICE}`, head: cursorOf(deps.generation, lastSequence) });
21291
+ return {
21292
+ append: (transition) => {
21293
+ lastSequence += 1;
21294
+ events.push({ ...boundedTransition(transition), cursor: cursorOf(deps.generation, lastSequence), sequence: lastSequence });
21295
+ if (events.length > deps.capacity) {
21296
+ events.splice(0, events.length - deps.capacity);
21297
+ }
21298
+ for (const listener of listeners) {
21299
+ listener();
21300
+ }
21301
+ },
21302
+ head: () => cursorOf(deps.generation, lastSequence),
21303
+ read: ({ since, session, limit }) => {
21304
+ let after = 0;
21305
+ if (since !== void 0) {
21306
+ const parsed = parseCursor(since);
21307
+ if (parsed === void 0) {
21308
+ return expired(`"${since}" is not a cursor this door issues`);
21309
+ }
21310
+ if (parsed.generation !== deps.generation) {
21311
+ return expired(`the cursor "${since}" was issued by another generation of the front door, whose events this one never held`);
21312
+ }
21313
+ if (parsed.sequence > lastSequence) {
21314
+ return expired(`the cursor "${since}" names an event past this door's newest`);
21315
+ }
21316
+ const oldest = events[0]?.sequence ?? lastSequence + 1;
21317
+ if (parsed.sequence < oldest - 1) {
21318
+ return expired(`the events after "${since}" have been evicted (the log retains the newest ${String(deps.capacity)} and the oldest it still holds is "${cursorOf(deps.generation, oldest)}")`);
21319
+ }
21320
+ after = parsed.sequence;
21321
+ }
21322
+ const selected2 = [];
21323
+ let cursor = cursorOf(deps.generation, lastSequence);
21324
+ let more = false;
21325
+ for (const event of events) {
21326
+ if (event.sequence <= after || session !== void 0 && event.session !== session) {
21327
+ continue;
21328
+ }
21329
+ if (limit !== void 0 && selected2.length === limit) {
21330
+ more = true;
21331
+ cursor = selected2.at(-1)?.cursor ?? cursor;
21332
+ break;
21333
+ }
21334
+ selected2.push(event);
21335
+ }
21336
+ return { status: "ok", events: selected2, cursor, more, head: cursorOf(deps.generation, lastSequence) };
21337
+ },
21338
+ onAppend: (listener) => {
21339
+ listeners.add(listener);
21340
+ return () => {
21341
+ listeners.delete(listener);
21342
+ };
21343
+ },
21344
+ close: () => {
21345
+ if (isClosed) {
21346
+ return;
21347
+ }
21348
+ isClosed = true;
21349
+ for (const listener of listeners) {
21350
+ listener();
21351
+ }
21352
+ },
21353
+ closed: () => isClosed
21354
+ };
21355
+ }
21356
+ var RcSessionEventCursorExpiredError = class extends Error {
21357
+ /** The cursor naming the log's newest event at the moment of the refusal: where to resume after once the status read has restated the present. */
21358
+ head;
21359
+ constructor(message, head) {
21360
+ super(message);
21361
+ this.name = "RcSessionEventCursorExpiredError";
21362
+ this.head = head;
21363
+ }
21364
+ };
21365
+ function followRcSessionEvents(log, input, signal) {
21366
+ return followAfter(log, input.since ?? log.head(), input.session, signal);
21367
+ }
21368
+ async function* followAfter(log, since, session, signal) {
21369
+ let cursor = since;
21370
+ let onAbort = () => void 0;
21371
+ const aborted = new Promise((resolve) => {
21372
+ onAbort = resolve;
21373
+ });
21374
+ signal?.addEventListener("abort", onAbort, { once: true });
21375
+ try {
21376
+ for (; ; ) {
21377
+ signal?.throwIfAborted();
21378
+ const closedBeforeRead = log.closed();
21379
+ let detach = () => void 0;
21380
+ const woken = new Promise((resolve) => {
21381
+ detach = log.onAppend(resolve);
21382
+ });
21383
+ try {
21384
+ const read = log.read({ since: cursor, ...session === void 0 ? {} : { session } });
21385
+ if (read.status === "expired") {
21386
+ throw new RcSessionEventCursorExpiredError(read.message, read.head);
21387
+ }
21388
+ if (read.events.length === 0) {
21389
+ cursor = read.cursor;
21390
+ if (closedBeforeRead) {
21391
+ return;
21392
+ }
21393
+ await Promise.race([woken, aborted]);
21394
+ continue;
21395
+ }
21396
+ for (const event of read.events) {
21397
+ yield event;
21398
+ cursor = event.cursor;
21399
+ }
21400
+ cursor = read.cursor;
21401
+ } finally {
21402
+ detach();
21403
+ }
21404
+ }
21405
+ } finally {
21406
+ signal?.removeEventListener("abort", onAbort);
21407
+ }
21408
+ }
21409
+
21410
+ // src/frontdoor/rcEventLogApi.ts
21411
+ var RC_API_TAG2 = "remote-control";
21412
+ var CURSOR_EXPIRED_CODE = "GONE";
21413
+ async function* sseOf(follower) {
21414
+ try {
21415
+ for await (const event of follower) {
21416
+ yield withEventMeta3(event, { id: event.cursor });
21417
+ }
21418
+ } catch (error) {
21419
+ if (error instanceof RcSessionEventCursorExpiredError) {
21420
+ throw new ORPCError7(CURSOR_EXPIRED_CODE, { message: error.message, data: { head: error.head } });
21421
+ }
21422
+ throw error;
21423
+ }
21424
+ }
21425
+ function createRcSessionEventsApiRouter(deps) {
21426
+ const authed = doorApiAuth(deps.expectedToken);
21427
+ return {
21428
+ rcSessions: {
21429
+ events: authed.meta(openapi8({ method: "GET", path: "/rest/rc/session-events", summary: "Stream every observed session's state transitions, pending requests and endings (SSE), resumable by cursor", tags: [RC_API_TAG2] })).input(RcSessionEventsStreamInputSchema).output(eventIterator3(RcSessionEventSchema)).handler(({ input, signal, lastEventId }) => sseOf(followRcSessionEvents(deps.sessionEvents, { since: lastEventId ?? input.since, session: input.session }, signal))),
21430
+ eventsPage: authed.meta(
21431
+ openapi8({
21432
+ method: "POST",
21433
+ path: "/rest/rc/session-events/page",
21434
+ summary: "Read every observed session's state transitions, pending requests and endings after a cursor, one page at a time",
21435
+ tags: [RC_API_TAG2],
21436
+ // A POST because the page size is a number a query string cannot type, but the answer changes nothing.
21437
+ spec: (current) => ({ ...current, [READ_ONLY_OPERATION_EXTENSION]: true })
21438
+ })
21439
+ ).input(RcSessionEventsPageInputSchema).output(RcSessionEventsReadOutputSchema).handler(({ input }) => deps.sessionEvents.read(input))
21440
+ }
21441
+ };
21442
+ }
21443
+
21444
+ // src/frontdoor/controlApi.ts
21445
+ var USAGE_API_TAG = "usage";
21446
+ var FRONTDOOR_API_TAG2 = "frontdoor";
21447
+ var CHECK_API_TAG = "check";
21448
+ var DOCTOR_API_TAG = "doctor";
21449
+ var POOL_API_TAG = "pool";
21450
+ function createControlApiRouter(deps) {
21451
+ const authed = doorApiAuth(deps.expectedToken);
21452
+ return {
21453
+ usage: {
21454
+ list: authed.meta(openapi9({ method: "GET", path: "/rest/usage/snapshots", summary: "List every identity's usage snapshot", tags: [USAGE_API_TAG] })).output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
21455
+ resets: authed.meta(openapi9({ method: "GET", path: "/rest/usage/resets", summary: "List every recorded quota window with when it resets", tags: [USAGE_API_TAG] })).output(ResetScheduleSchema).handler(() => collectResets(deps.usageSnapshots(), deps.now())),
21456
+ effectiveWindow: authed.meta(openapi9({ method: "GET", path: "/rest/usage/windows", summary: "Read one identity's effective quota windows", tags: [USAGE_API_TAG] })).input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input }) => {
21457
+ const snapshot = deps.usageSnapshotOf(input.identity);
21458
+ if (snapshot === void 0) {
21459
+ throw new ORPCError8("NOT_FOUND", { message: `identity ${input.identity} has no usage snapshot yet, so no quota window has been observed for it` });
20866
21460
  }
20867
21461
  const provider = input.provider ?? ANTHROPIC_PROVIDER;
20868
21462
  const rateLimit = snapshot.providers[provider]?.rateLimit;
@@ -20876,34 +21470,34 @@ function createControlApiRouter(deps) {
20876
21470
  ...unified?.sevenDay === void 0 ? {} : { sevenDay: effectiveWindow(unified.sevenDay, now) }
20877
21471
  };
20878
21472
  }),
20879
- live: authed.meta(openapi8({ method: "GET", path: "/rest/usage/live", summary: "Read the live rate-limit observations the event backbone files", tags: [USAGE_API_TAG] })).input(RcSessionQuerySchema).output(UsageLiveOutputSchema).handler(({ input }) => {
21473
+ live: authed.meta(openapi9({ method: "GET", path: "/rest/usage/live", summary: "Read the live rate-limit observations the event backbone files", tags: [USAGE_API_TAG] })).input(RcSessionQuerySchema).output(UsageLiveOutputSchema).handler(({ input }) => {
20880
21474
  const sessions = deps.liveRateLimits(input.session);
20881
21475
  if (input.session !== void 0 && sessions.length === 0) {
20882
21476
  if (deps.list().some((session) => session.id === input.session)) {
20883
- throw new ORPCError7("NOT_FOUND", { message: `session ${input.session} has filed no rate_limit_event on its stream yet: the worker emits one only once a turn has completed, so retry after this session's next turn` });
21477
+ throw new ORPCError8("NOT_FOUND", { message: `session ${input.session} has filed no rate_limit_event on its stream yet: the worker emits one only once a turn has completed, so retry after this session's next turn` });
20884
21478
  }
20885
- throw new ORPCError7("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
21479
+ throw new ORPCError8("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
20886
21480
  }
20887
21481
  return { latest: deps.latestRateLimit(), sessions };
20888
21482
  })
20889
21483
  },
20890
21484
  frontdoor: {
20891
- status: authed.meta(openapi8({ method: "GET", path: "/rest/frontdoor/status", summary: "Read the front door's status", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
20892
- sessions: authed.meta(openapi8({ method: "GET", path: "/rest/frontdoor/sessions", summary: "Read the front door's session registry", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
21485
+ status: authed.meta(openapi9({ method: "GET", path: "/rest/frontdoor/status", summary: "Read the front door's status", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
21486
+ sessions: authed.meta(openapi9({ method: "GET", path: "/rest/frontdoor/sessions", summary: "Read the front door's session registry", tags: [FRONTDOOR_API_TAG2] })).output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
20893
21487
  },
20894
21488
  check: {
20895
21489
  // The report's own JSON shape is the contract (the same one `check --json` prints and `checkReportSchema.ts` defines), so the procedure returns exactly that conversion.
20896
- run: authed.meta(openapi8({ method: "GET", path: "/rest/check", summary: "Run the check report for one directory", tags: [CHECK_API_TAG] })).input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input }) => checkReportToJson(deps.checkReport(input.path, input.identity)))
21490
+ run: authed.meta(openapi9({ method: "GET", path: "/rest/check", summary: "Run the check report for one directory", tags: [CHECK_API_TAG] })).input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input }) => checkReportToJson(deps.checkReport(input.path, input.identity)))
20897
21491
  },
20898
21492
  doctor: {
20899
- run: authed.meta(openapi8({ method: "GET", path: "/rest/doctor", summary: "Run the doctor report", tags: [DOCTOR_API_TAG] })).output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
21493
+ run: authed.meta(openapi9({ method: "GET", path: "/rest/doctor", summary: "Run the doctor report", tags: [DOCTOR_API_TAG] })).output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
20900
21494
  },
20901
21495
  pool: {
20902
- pick: authed.meta(openapi8({ method: "GET", path: "/rest/pool/pick", summary: "Rank one pool exactly as a launch from a directory would right now", tags: [POOL_API_TAG] })).input(PoolPickInputSchema).output(PoolPickReportSchema).handler(({ input }) => {
21496
+ pick: authed.meta(openapi9({ method: "GET", path: "/rest/pool/pick", summary: "Rank one pool exactly as a launch from a directory would right now", tags: [POOL_API_TAG] })).input(PoolPickInputSchema).output(PoolPickReportSchema).handler(({ input }) => {
20903
21497
  const report = deps.poolPick(input.pool, input.path);
20904
21498
  if (report === void 0) {
20905
21499
  const live = deps.poolNames();
20906
- throw new ORPCError7("NOT_FOUND", {
21500
+ throw new ORPCError8("NOT_FOUND", {
20907
21501
  message: live.length === 0 ? `no pools are configured, so none is named ${input.pool}` : `no pool is named ${input.pool}; the live pools are ${live.map((name) => `"${name}"`).join(", ")}`
20908
21502
  });
20909
21503
  }
@@ -20915,7 +21509,7 @@ function createControlApiRouter(deps) {
20915
21509
  function createDoorApiRouter(deps) {
20916
21510
  const control = createControlApiRouter(deps);
20917
21511
  const lifecycle = createLifecycleApiRouter(deps);
20918
- return { ...createRcApiRouter(deps), ...control, ...lifecycle, ...createConfigApiRouter(deps), ...createCodexApiRouter(deps), ...createLaunchApiRouter(deps), ...createAgentTreesApiRouter(deps), ...createEventsApiRouter(deps), frontdoor: { ...control.frontdoor, ...lifecycle.frontdoor } };
21512
+ return { ...createRcApiRouter(deps), ...createRcSessionEventsApiRouter(deps), ...control, ...lifecycle, ...createConfigApiRouter(deps), ...createCodexApiRouter(deps), ...createLaunchApiRouter(deps), ...createAgentTreesApiRouter(deps), ...createEventsApiRouter(deps), frontdoor: { ...control.frontdoor, ...lifecycle.frontdoor } };
20919
21513
  }
20920
21514
  function createDoorApiNodeHandler(deps) {
20921
21515
  return doorApiNodeHandlerOf(createDoorApiRouter(deps), deps.expectedToken);
@@ -21021,112 +21615,6 @@ function formatFrontDoorStatus(status, caCertPath) {
21021
21615
  // src/index.ts
21022
21616
  init_state();
21023
21617
 
21024
- // src/frontdoor/eventHub.ts
21025
- var DOOR_EVENT_BUFFER_EVENTS = 100;
21026
- function createDoorEventHub() {
21027
- const sequences = /* @__PURE__ */ new Map();
21028
- const registered = /* @__PURE__ */ new Set();
21029
- const every = /* @__PURE__ */ new Set();
21030
- const bySource = /* @__PURE__ */ new Map();
21031
- const deliver = (event) => {
21032
- for (const listener of every) {
21033
- listener(event);
21034
- }
21035
- for (const listener of bySource.get(event.source) ?? []) {
21036
- listener(event);
21037
- }
21038
- };
21039
- const publish = (source, payload) => {
21040
- const sequence2 = (sequences.get(source) ?? 0) + 1;
21041
- sequences.set(source, sequence2);
21042
- deliver({ source, sequence: sequence2, payload });
21043
- };
21044
- const addListener = (sources, listener) => {
21045
- if (sources === void 0) {
21046
- every.add(listener);
21047
- return () => {
21048
- every.delete(listener);
21049
- };
21050
- }
21051
- const listenersFor = (source) => {
21052
- const listeners = bySource.get(source) ?? /* @__PURE__ */ new Set();
21053
- bySource.set(source, listeners);
21054
- return listeners;
21055
- };
21056
- const detachers = sources.map((source) => {
21057
- const listeners = listenersFor(source);
21058
- listeners.add(listener);
21059
- return () => {
21060
- listeners.delete(listener);
21061
- if (listeners.size === 0) {
21062
- bySource.delete(source);
21063
- }
21064
- };
21065
- });
21066
- return () => {
21067
- for (const detach of detachers) {
21068
- detach();
21069
- }
21070
- };
21071
- };
21072
- return {
21073
- publisher: (source) => {
21074
- registered.add(source);
21075
- return {
21076
- source,
21077
- publish: (payload) => {
21078
- publish(source, payload);
21079
- }
21080
- };
21081
- },
21082
- subscribe: addListener,
21083
- stream: (sources) => {
21084
- const queue = [];
21085
- let wake;
21086
- let closed = false;
21087
- const detach = addListener(sources, (event) => {
21088
- if (queue.length >= DOOR_EVENT_BUFFER_EVENTS) {
21089
- queue.shift();
21090
- }
21091
- queue.push(event);
21092
- wake?.();
21093
- });
21094
- return {
21095
- next: async () => {
21096
- for (; ; ) {
21097
- const event = queue.shift();
21098
- if (event !== void 0) {
21099
- return { value: event, done: false };
21100
- }
21101
- if (closed) {
21102
- return { value: void 0, done: true };
21103
- }
21104
- await new Promise((resolve) => {
21105
- wake = resolve;
21106
- });
21107
- }
21108
- },
21109
- close: () => {
21110
- closed = true;
21111
- detach();
21112
- wake?.();
21113
- }
21114
- };
21115
- },
21116
- sources: () => [...registered].sort()
21117
- };
21118
- }
21119
- function rcFanoutOnDoorHub(fanout, hub) {
21120
- const publisher = hub.publisher(DOOR_EVENT_SOURCE_RC);
21121
- return {
21122
- publish: (event) => {
21123
- fanout.publish(event);
21124
- publisher.publish(event);
21125
- },
21126
- subscribe: (session, listener) => fanout.subscribe(session, listener)
21127
- };
21128
- }
21129
-
21130
21618
  // src/frontdoor/launchEvents.ts
21131
21619
  function createLaunchEventPublisher(hub, now) {
21132
21620
  const publisher = hub.publisher(LAUNCH_EVENT_SOURCE);
@@ -23074,7 +23562,7 @@ init_poolPick();
23074
23562
 
23075
23563
  // src/agents/read.ts
23076
23564
  import path46 from "node:path";
23077
- import { z as z40 } from "zod";
23565
+ import { z as z42 } from "zod";
23078
23566
  var PROJECTS_DIR = "projects";
23079
23567
  var TASKS_DIR = "tasks";
23080
23568
  var SUBAGENTS_DIR = "subagents";
@@ -23193,14 +23681,14 @@ function parseJson2(text) {
23193
23681
  return void 0;
23194
23682
  }
23195
23683
  }
23196
- var TaskFileSchema = z40.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z40.array(z40.string()).default([]), blockedBy: z40.array(z40.string()).default([]) });
23197
- var WorkflowRunFileSchema = z40.object({
23198
- runId: z40.string(),
23199
- workflowName: z40.string().optional(),
23200
- status: z40.string().optional(),
23201
- startTime: z40.number().optional(),
23202
- phases: z40.array(z40.object({ title: z40.string() })).default([]),
23203
- summary: z40.string().optional()
23684
+ var TaskFileSchema = z42.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z42.array(z42.string()).default([]), blockedBy: z42.array(z42.string()).default([]) });
23685
+ var WorkflowRunFileSchema = z42.object({
23686
+ runId: z42.string(),
23687
+ workflowName: z42.string().optional(),
23688
+ status: z42.string().optional(),
23689
+ startTime: z42.number().optional(),
23690
+ phases: z42.array(z42.object({ title: z42.string() })).default([]),
23691
+ summary: z42.string().optional()
23204
23692
  });
23205
23693
  function summariseSession(fs17, configDir, ref) {
23206
23694
  const sessionRelative = path46.join(PROJECTS_DIR, ref.project, ref.entry);
@@ -23707,6 +24195,7 @@ export {
23707
24195
  RC_IDLE_EXPIRY_MS,
23708
24196
  RC_ORPC_PATH_PREFIX,
23709
24197
  RC_PENDING_DEADLINE_MS,
24198
+ RC_PENDING_RETIRE_REASONS,
23710
24199
  RC_PERMISSION_MODES,
23711
24200
  RC_READ_FILE_ENCODINGS,
23712
24201
  RC_REQUEST_PARSE_CAP_BYTES,
@@ -23718,6 +24207,8 @@ export {
23718
24207
  RC_SELF_HOST_SCOPE_LIST,
23719
24208
  RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
23720
24209
  RC_SESSIONS_PATH_PREFIX,
24210
+ RC_SESSION_END_REASONS,
24211
+ RC_SESSION_EVENT_LOG_CAPACITY,
23721
24212
  RC_STREAM_BACKOFF_MS,
23722
24213
  RC_WEB_FETCH_ALLOW_PRIVATE_ENV,
23723
24214
  RC_WEB_FETCH_DEADLINE_MS,
@@ -23728,6 +24219,13 @@ export {
23728
24219
  RcPermissionModeSchema,
23729
24220
  RcRateLimitInfoSchema,
23730
24221
  RcRateLimitWindowSchema,
24222
+ RcSessionEventCursorExpiredError,
24223
+ RcSessionEventSchema,
24224
+ RcSessionEventsPageInputSchema,
24225
+ RcSessionEventsReadInputSchema,
24226
+ RcSessionEventsReadOutputSchema,
24227
+ RcSessionEventsStreamInputSchema,
24228
+ RcSessionTransitionSchema,
23731
24229
  RcStreamEnvelopeSchema,
23732
24230
  RcStreamEventSchema,
23733
24231
  ResetRowSchema,
@@ -23809,6 +24307,8 @@ export {
23809
24307
  createRcEventFanout,
23810
24308
  createRcLiveUsage,
23811
24309
  createRcSelfHostSurface,
24310
+ createRcSessionEventLog,
24311
+ createRcSessionEventsApiRouter,
23812
24312
  createRcSessionTracker,
23813
24313
  createRcStreamHub,
23814
24314
  createSseParser,
@@ -23824,6 +24324,7 @@ export {
23824
24324
  evaluateAmbientCredentialGuard,
23825
24325
  evaluateWhen,
23826
24326
  fetchThroughWebProxy,
24327
+ followRcSessionEvents,
23827
24328
  formatAmbientCredentialGuardMessage,
23828
24329
  formatCheckReport,
23829
24330
  formatDoctorReport,