agent-shim 11.86.4 → 11.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1234,6 +1234,8 @@ var init_schema = __esm({
1234
1234
  jobs: import_zod3.z.record(PoolNameSchema, JobSchema).optional()
1235
1235
  });
1236
1236
  IdentitySchema = import_zod3.z.strictObject({
1237
+ /** The CLI this login belongs to; absent means Claude Code for backwards compatibility. */
1238
+ agent: import_zod3.z.enum(["claude", "codex"]).optional(),
1237
1239
  $schema: import_zod3.z.string().optional(),
1238
1240
  name: FileNameSchema,
1239
1241
  /** What the identity is for, in the person's words, drawn beside its name in `identity list` and `show`, the launch banner and the statusline. Display only: the name stays the key for lookup and for the references to the identity (pools, rules, jobs, model refs), and the id for paths and Keychain service names. */
@@ -1305,7 +1307,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
1305
1307
  return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
1306
1308
  }
1307
1309
  function describeIgnoredKeys(filePath, ignored) {
1308
- const places = ignored.map(({ path: path53, keys }) => `${path53.length === 0 ? "" : `${path53.map(String).join(".")}.`}${keys.join(", ")}`);
1310
+ const places = ignored.map(({ path: path54, keys }) => `${path54.length === 0 ? "" : `${path54.map(String).join(".")}.`}${keys.join(", ")}`);
1309
1311
  return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
1310
1312
  }
1311
1313
  function noteIgnoredKeys(filePath, ignored) {
@@ -1327,9 +1329,9 @@ function restoreIgnoredKeys(filePath, value) {
1327
1329
  return value;
1328
1330
  }
1329
1331
  const restored = structuredClone(value);
1330
- for (const { path: path53, values } of ignored) {
1332
+ for (const { path: path54, values } of ignored) {
1331
1333
  let holder = restored;
1332
- for (const step of path53) {
1334
+ for (const step of path54) {
1333
1335
  holder = isRecord(holder) ? holder[step] : void 0;
1334
1336
  }
1335
1337
  if (isRecord(holder)) {
@@ -4724,8 +4726,8 @@ function parseConnectTarget(authority) {
4724
4726
  function isInterceptedHost(host, interceptHosts) {
4725
4727
  return interceptHosts.includes(host);
4726
4728
  }
4727
- function servedByPipeline(path53) {
4728
- return path53?.startsWith(ROUTED_PATH_PREFIX) === true;
4729
+ function servedByPipeline(path54) {
4730
+ return path54?.startsWith(ROUTED_PATH_PREFIX) === true;
4729
4731
  }
4730
4732
  function forwardableHeaders(headers) {
4731
4733
  const connectionTokens = new Set(
@@ -5171,7 +5173,7 @@ var init_package = __esm({
5171
5173
  "package.json"() {
5172
5174
  package_default = {
5173
5175
  name: "agent-shim",
5174
- version: "11.86.4",
5176
+ version: "11.87.0",
5175
5177
  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.",
5176
5178
  license: "MIT",
5177
5179
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -6997,24 +6999,73 @@ var init_realPorts = __esm({
6997
6999
  }
6998
7000
  });
6999
7001
 
7002
+ // src/cli/bool.ts
7003
+ function parseBoolWord(input) {
7004
+ switch (input) {
7005
+ case "true":
7006
+ case "1":
7007
+ return true;
7008
+ case "false":
7009
+ case "0":
7010
+ return false;
7011
+ default:
7012
+ return void 0;
7013
+ }
7014
+ }
7015
+ var init_bool = __esm({
7016
+ "src/cli/bool.ts"() {
7017
+ "use strict";
7018
+ }
7019
+ });
7020
+
7021
+ // src/cli/envBool.ts
7022
+ function parseEnvBool(variable, value) {
7023
+ if (value === void 0 || value === "") {
7024
+ return void 0;
7025
+ }
7026
+ const parsed = parseBoolWord(value);
7027
+ if (parsed === void 0) {
7028
+ throw new InvalidEnvBoolError(variable, value);
7029
+ }
7030
+ return parsed;
7031
+ }
7032
+ var InvalidEnvBoolError;
7033
+ var init_envBool = __esm({
7034
+ "src/cli/envBool.ts"() {
7035
+ "use strict";
7036
+ init_cliError();
7037
+ init_bool();
7038
+ InvalidEnvBoolError = class extends UsageError {
7039
+ constructor(variable, value) {
7040
+ super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
7041
+ this.variable = variable;
7042
+ this.value = value;
7043
+ this.name = "InvalidEnvBoolError";
7044
+ }
7045
+ variable;
7046
+ value;
7047
+ };
7048
+ }
7049
+ });
7050
+
7000
7051
  // src/pathNorm.ts
7001
7052
  function expandTilde(value, home) {
7002
7053
  if (value === "~") {
7003
7054
  return home;
7004
7055
  }
7005
7056
  if (value.startsWith("~/")) {
7006
- return import_node_path20.default.join(home, value.slice(2));
7057
+ return import_node_path21.default.join(home, value.slice(2));
7007
7058
  }
7008
7059
  return value;
7009
7060
  }
7010
7061
  function normaliseRulePath(rulePath, home) {
7011
- return import_node_path20.default.resolve(expandTilde(rulePath, home));
7062
+ return import_node_path21.default.resolve(expandTilde(rulePath, home));
7012
7063
  }
7013
- var import_node_path20;
7064
+ var import_node_path21;
7014
7065
  var init_pathNorm = __esm({
7015
7066
  "src/pathNorm.ts"() {
7016
7067
  "use strict";
7017
- import_node_path20 = __toESM(require("node:path"), 1);
7068
+ import_node_path21 = __toESM(require("node:path"), 1);
7018
7069
  }
7019
7070
  });
7020
7071
 
@@ -7038,8 +7089,8 @@ function loadCascadeInput(params) {
7038
7089
  });
7039
7090
  const levels = [];
7040
7091
  for (const dir of dirs) {
7041
- const portable = loadConfigFile(import_node_path21.default.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path21.default.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
7042
- const portableLocal = loadConfigFile(import_node_path21.default.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path21.default.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
7092
+ const portable = loadConfigFile(import_node_path22.default.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path22.default.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
7093
+ const portableLocal = loadConfigFile(import_node_path22.default.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path22.default.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
7043
7094
  const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
7044
7095
  const entryOrder = directoryRules?.ruleEntryOrders[index];
7045
7096
  return {
@@ -7086,11 +7137,11 @@ function readDirectorySelections(loaded) {
7086
7137
  }
7087
7138
  return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
7088
7139
  }
7089
- var import_node_path21, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
7140
+ var import_node_path22, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
7090
7141
  var init_cascade = __esm({
7091
7142
  "src/launcher/cascade.ts"() {
7092
7143
  "use strict";
7093
- import_node_path21 = __toESM(require("node:path"), 1);
7144
+ import_node_path22 = __toESM(require("node:path"), 1);
7094
7145
  init_load();
7095
7146
  init_schema();
7096
7147
  init_pathNorm();
@@ -7191,13 +7242,13 @@ function loadIdentity(identitiesDir, name, fs17) {
7191
7242
  throw new UnsafeNameError(name, "identity", FILE_NAME_RULE);
7192
7243
  }
7193
7244
  const id = resolveIdentityId(identitiesDir, name, fs17);
7194
- return id === void 0 ? void 0 : loadConfigFile(import_node_path22.default.join(identitiesDir, id, "identity.json"), IdentitySchema, fs17.readConfigFile);
7245
+ return id === void 0 ? void 0 : loadConfigFile(import_node_path23.default.join(identitiesDir, id, "identity.json"), IdentitySchema, fs17.readConfigFile);
7195
7246
  }
7196
- var import_node_path22, IDENTITY_DECISION_SOURCES, IDENTITY_SOURCE_LABELS, CONFIG_PROFILE_DECISION_SOURCES;
7247
+ var import_node_path23, IDENTITY_DECISION_SOURCES, IDENTITY_SOURCE_LABELS, CONFIG_PROFILE_DECISION_SOURCES;
7197
7248
  var init_identity = __esm({
7198
7249
  "src/launcher/identity.ts"() {
7199
7250
  "use strict";
7200
- import_node_path22 = __toESM(require("node:path"), 1);
7251
+ import_node_path23 = __toESM(require("node:path"), 1);
7201
7252
  init_load();
7202
7253
  init_names();
7203
7254
  init_schema();
@@ -7456,7 +7507,7 @@ function requireIdentityDirectoryId(id) {
7456
7507
  }
7457
7508
  }
7458
7509
  function claudeJsonPath(identitiesDir, identity) {
7459
- return import_node_path23.default.join(identitiesDir, identity, CLAUDE_JSON);
7510
+ return import_node_path24.default.join(identitiesDir, identity, CLAUDE_JSON);
7460
7511
  }
7461
7512
  function readAccountMetadata(fs17, identitiesDir, identity) {
7462
7513
  requireIdentityDirectoryId(identity);
@@ -7508,11 +7559,11 @@ function createAccountReader(fs17, identitiesDir) {
7508
7559
  return account;
7509
7560
  };
7510
7561
  }
7511
- var import_node_path23, CLAUDE_JSON, AccountMetadataError, InvalidIdentityIdError;
7562
+ var import_node_path24, CLAUDE_JSON, AccountMetadataError, InvalidIdentityIdError;
7512
7563
  var init_account = __esm({
7513
7564
  "src/usage/account.ts"() {
7514
7565
  "use strict";
7515
- import_node_path23 = __toESM(require("node:path"), 1);
7566
+ import_node_path24 = __toESM(require("node:path"), 1);
7516
7567
  init_cliError();
7517
7568
  init_names();
7518
7569
  init_schema();
@@ -8222,7 +8273,7 @@ function readUsageLog(fs17, logDir, options = {}) {
8222
8273
  return { records, invalidLines };
8223
8274
  }
8224
8275
  function readSegment(fs17, logDir, segment) {
8225
- const contents = fs17.readFileUtf8(import_node_path24.default.join(logDir, segment.name));
8276
+ const contents = fs17.readFileUtf8(import_node_path25.default.join(logDir, segment.name));
8226
8277
  if (contents === void 0) {
8227
8278
  return void 0;
8228
8279
  }
@@ -8252,7 +8303,7 @@ function readSegment(fs17, logDir, segment) {
8252
8303
  }
8253
8304
  function snapshotPath(snapshotsDir, identity) {
8254
8305
  requireIdentityDirectoryId(identity);
8255
- return import_node_path24.default.join(snapshotsDir, `${identity}.json`);
8306
+ return import_node_path25.default.join(snapshotsDir, `${identity}.json`);
8256
8307
  }
8257
8308
  function readUsageSnapshot(fs17, snapshotsDir, identity) {
8258
8309
  const file = snapshotPath(snapshotsDir, identity);
@@ -8285,11 +8336,11 @@ function listUsageSnapshots(fs17, snapshotsDir) {
8285
8336
  return snapshot === void 0 ? [] : [snapshot];
8286
8337
  }).sort((left, right) => left.identity.localeCompare(right.identity));
8287
8338
  }
8288
- var import_node_path24, SEGMENT_RE, DAY_MS, UsageSnapshotError;
8339
+ var import_node_path25, SEGMENT_RE, DAY_MS, UsageSnapshotError;
8289
8340
  var init_read = __esm({
8290
8341
  "src/usage/read.ts"() {
8291
8342
  "use strict";
8292
- import_node_path24 = __toESM(require("node:path"), 1);
8343
+ import_node_path25 = __toESM(require("node:path"), 1);
8293
8344
  init_account();
8294
8345
  init_schema2();
8295
8346
  SEGMENT_RE = /^(\d{4}-\d{2}-\d{2})\.(\d+)\.jsonl$/;
@@ -8310,7 +8361,7 @@ function pruneUsageLog(fs17, logDir, nowMs) {
8310
8361
  const cutoff = nowMs - USAGE_RETENTION_MS;
8311
8362
  for (const segment of listLogSegments(fs17, logDir)) {
8312
8363
  if (segment.endsAt <= cutoff) {
8313
- fs17.removeRecursive(import_node_path25.default.join(logDir, segment.name));
8364
+ fs17.removeRecursive(import_node_path26.default.join(logDir, segment.name));
8314
8365
  }
8315
8366
  }
8316
8367
  }
@@ -8392,7 +8443,7 @@ function createUsageStore(deps) {
8392
8443
  pruneUsageLog(fs17, paths.usageLogDir, nowMs);
8393
8444
  prunedDay = day;
8394
8445
  }
8395
- fs17.appendFilePrivate(import_node_path25.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record)}
8446
+ fs17.appendFilePrivate(import_node_path26.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record)}
8396
8447
  `);
8397
8448
  deps.onRecord?.(record);
8398
8449
  if (record.identity !== void 0) {
@@ -8416,11 +8467,11 @@ function createUsageStore(deps) {
8416
8467
  })
8417
8468
  };
8418
8469
  }
8419
- var import_node_path25, DAY_MS2, DAYS_IN_WEEK, USAGE_RETENTION_MS;
8470
+ var import_node_path26, DAY_MS2, DAYS_IN_WEEK, USAGE_RETENTION_MS;
8420
8471
  var init_store2 = __esm({
8421
8472
  "src/usage/store.ts"() {
8422
8473
  "use strict";
8423
- import_node_path25 = __toESM(require("node:path"), 1);
8474
+ import_node_path26 = __toESM(require("node:path"), 1);
8424
8475
  init_account();
8425
8476
  init_rateLimit();
8426
8477
  init_read();
@@ -8609,15 +8660,15 @@ function recordStickyPick(fs17, picksFile, directory, identity, nowMs) {
8609
8660
  const current = readPicksFile(fs17, picksFile).file.picks;
8610
8661
  const kept = Object.entries(current).filter(([, entry]) => nowMs - Date.parse(entry.at) <= USAGE_RETENTION_MS);
8611
8662
  const next = { schemaVersion: SCHEMA_VERSION, picks: { ...Object.fromEntries(kept), [directory]: { identity, at: new Date(nowMs).toISOString() } } };
8612
- fs17.mkdirPrivate(import_node_path26.default.dirname(picksFile));
8663
+ fs17.mkdirPrivate(import_node_path27.default.dirname(picksFile));
8613
8664
  fs17.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
8614
8665
  `);
8615
8666
  }
8616
- var import_node_path26, import_zod17, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
8667
+ var import_node_path27, import_zod17, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
8617
8668
  var init_poolPick = __esm({
8618
8669
  "src/usage/poolPick.ts"() {
8619
8670
  "use strict";
8620
- import_node_path26 = __toESM(require("node:path"), 1);
8671
+ import_node_path27 = __toESM(require("node:path"), 1);
8621
8672
  import_zod17 = require("zod");
8622
8673
  init_cliError();
8623
8674
  init_identity();
@@ -8644,9 +8695,9 @@ var init_poolPick = __esm({
8644
8695
  });
8645
8696
 
8646
8697
  // src/statusline/keys.ts
8647
- function valueAt(source, path53) {
8698
+ function valueAt(source, path54) {
8648
8699
  let current = source;
8649
- for (const part of path53) {
8700
+ for (const part of path54) {
8650
8701
  if (!isPlainObject(current)) {
8651
8702
  return void 0;
8652
8703
  }
@@ -8654,14 +8705,14 @@ function valueAt(source, path53) {
8654
8705
  }
8655
8706
  return current;
8656
8707
  }
8657
- function acceptsNull(path53) {
8658
- const layer = path53.reduceRight((inner, part) => ({ [part]: inner }), null);
8708
+ function acceptsNull(path54) {
8709
+ const layer = path54.reduceRight((inner, part) => ({ [part]: inner }), null);
8659
8710
  return StatuslineSchema.safeParse(layer).success;
8660
8711
  }
8661
- function keyOf(path53, declared) {
8712
+ function keyOf(path54, declared) {
8662
8713
  const optional = declared instanceof import_zod18.z.ZodOptional;
8663
8714
  const leaf = optional ? declared.unwrap() : declared;
8664
- const common = { path: path53.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path53), optional, unsettable: acceptsNull(path53) };
8715
+ const common = { path: path54.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path54), optional, unsettable: acceptsNull(path54) };
8665
8716
  if (leaf instanceof import_zod18.z.ZodNumber) {
8666
8717
  return { ...common, kind: "integer", choices: [] };
8667
8718
  }
@@ -8686,7 +8737,7 @@ function keyOf(path53, declared) {
8686
8737
  if (leaf instanceof import_zod18.z.ZodArray && leaf.element instanceof import_zod18.z.ZodString) {
8687
8738
  return { ...common, kind: "textList", choices: [] };
8688
8739
  }
8689
- throw new TypeError(`statusline setting ${path53.join(".")} has a kind the key listing does not describe`);
8740
+ throw new TypeError(`statusline setting ${path54.join(".")} has a kind the key listing does not describe`);
8690
8741
  }
8691
8742
  function walk(shape, prefix) {
8692
8743
  return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod18.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
@@ -8704,15 +8755,15 @@ var init_keys = __esm({
8704
8755
  });
8705
8756
 
8706
8757
  // src/statusline/change.ts
8707
- function keyNamed(path53) {
8708
- const found = statuslineKeys().find((key) => key.path === path53);
8758
+ function keyNamed(path54) {
8759
+ const found = statuslineKeys().find((key) => key.path === path54);
8709
8760
  if (found === void 0) {
8710
- throw new UsageError(`"${path53}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
8761
+ throw new UsageError(`"${path54}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
8711
8762
  }
8712
8763
  return found;
8713
8764
  }
8714
- function setAt(target, path53, value) {
8715
- const [head, ...rest] = path53;
8765
+ function setAt(target, path54, value) {
8766
+ const [head, ...rest] = path54;
8716
8767
  if (head === void 0) {
8717
8768
  return;
8718
8769
  }
@@ -8725,8 +8776,8 @@ function setAt(target, path53, value) {
8725
8776
  target[head] = next;
8726
8777
  setAt(next, rest, value);
8727
8778
  }
8728
- function removeAt(target, path53) {
8729
- const [head, ...rest] = path53;
8779
+ function removeAt(target, path54) {
8780
+ const [head, ...rest] = path54;
8730
8781
  if (head === void 0) {
8731
8782
  return;
8732
8783
  }
@@ -8744,13 +8795,13 @@ function removeAt(target, path53) {
8744
8795
  }
8745
8796
  function applyStatuslineChange(existing, change) {
8746
8797
  const draft = structuredClone(existing ?? {});
8747
- for (const [path53, value] of Object.entries(change.set ?? {})) {
8748
- keyNamed(path53);
8749
- setAt(draft, path53.split("."), value);
8798
+ for (const [path54, value] of Object.entries(change.set ?? {})) {
8799
+ keyNamed(path54);
8800
+ setAt(draft, path54.split("."), value);
8750
8801
  }
8751
- for (const path53 of change.unset ?? []) {
8752
- keyNamed(path53);
8753
- removeAt(draft, path53.split("."));
8802
+ for (const path54 of change.unset ?? []) {
8803
+ keyNamed(path54);
8804
+ removeAt(draft, path54.split("."));
8754
8805
  }
8755
8806
  const result = StatuslineSchema.safeParse(draft);
8756
8807
  if (!result.success) {
@@ -8986,19 +9037,19 @@ function writePools(paths, pools) {
8986
9037
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
8987
9038
  }
8988
9039
  function poolCycleOf(pools, name) {
8989
- const walk2 = (current, path53) => {
9040
+ const walk2 = (current, path54) => {
8990
9041
  for (const entry of pools[current]?.identities ?? []) {
8991
9042
  const nested = poolNameOf(poolMemberIdentity(entry));
8992
9043
  if (nested === void 0) {
8993
9044
  continue;
8994
9045
  }
8995
9046
  if (nested === name) {
8996
- return [...path53, nested];
9047
+ return [...path54, nested];
8997
9048
  }
8998
- if (path53.includes(nested)) {
9049
+ if (path54.includes(nested)) {
8999
9050
  continue;
9000
9051
  }
9001
- const found = walk2(nested, [...path53, nested]);
9052
+ const found = walk2(nested, [...path54, nested]);
9002
9053
  if (found !== void 0) {
9003
9054
  return found;
9004
9055
  }
@@ -9111,8 +9162,8 @@ function resolveAgentShimHome(env = process.env, home = import_node_os4.default.
9111
9162
  if (fromEnv !== void 0 && fromEnv !== "") {
9112
9163
  return fromEnv;
9113
9164
  }
9114
- const current = import_node_path27.default.join(home, HOME_DIRNAME);
9115
- const legacy = import_node_path27.default.join(home, LEGACY_HOME_DIRNAME);
9165
+ const current = import_node_path28.default.join(home, HOME_DIRNAME);
9166
+ const legacy = import_node_path28.default.join(home, LEGACY_HOME_DIRNAME);
9116
9167
  return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
9117
9168
  }
9118
9169
  function isExistingDirectory(candidate) {
@@ -9123,71 +9174,71 @@ function resolveClaudeHome() {
9123
9174
  if (fromEnv !== void 0 && fromEnv !== "") {
9124
9175
  return fromEnv;
9125
9176
  }
9126
- return import_node_path27.default.join(import_node_os4.default.homedir(), ".claude");
9177
+ return import_node_path28.default.join(import_node_os4.default.homedir(), ".claude");
9127
9178
  }
9128
9179
  function buildLayoutPaths(root) {
9129
9180
  return {
9130
9181
  root,
9131
- identitiesDir: import_node_path27.default.join(root, "identities"),
9132
- configProfilesDir: import_node_path27.default.join(root, "config-profiles"),
9133
- providersDir: import_node_path27.default.join(root, "providers"),
9134
- providerAliasesFile: import_node_path27.default.join(root, "provider-aliases.json"),
9135
- directoryRulesFile: import_node_path27.default.join(root, "directory-rules.json"),
9136
- activeIdentityFile: import_node_path27.default.join(root, "active-identity"),
9137
- globalConfigFile: import_node_path27.default.join(root, "config.json"),
9138
- categoriesLocalFile: import_node_path27.default.join(root, "categories.local.json"),
9139
- claudeShimFile: import_node_path27.default.join(root, "claude-shim.json"),
9140
- headroomDir: import_node_path27.default.join(root, "headroom"),
9141
- headroomStateFile: import_node_path27.default.join(root, "headroom", "state.json"),
9142
- headroomRoutingFile: import_node_path27.default.join(root, "headroom", "routing.json"),
9143
- headroomLegacyStateFile: import_node_path27.default.join(root, "headroom", "state.v2.json"),
9144
- headroomAllowlistFile: import_node_path27.default.join(root, "headroom", "run", "allowlist.txt"),
9145
- headroomSocketDir: import_node_path27.default.join(root, "headroom", "run"),
9146
- headroomLockFile: import_node_path27.default.join(root, "headroom", "start.lock"),
9147
- headroomSessionsDir: import_node_path27.default.join(root, "headroom", "sessions"),
9148
- logsDir: import_node_path27.default.join(root, "logs"),
9149
- headroomLogPath: import_node_path27.default.join(root, "logs", "headroom.log"),
9150
- frontdoorDir: import_node_path27.default.join(root, "frontdoor"),
9151
- frontdoorCaDir: import_node_path27.default.join(root, "frontdoor", "ca"),
9152
- frontdoorCaCertFile: import_node_path27.default.join(root, "frontdoor", "ca", "ca.pem"),
9153
- frontdoorCaKeyFile: import_node_path27.default.join(root, "frontdoor", "ca", "ca.key"),
9154
- frontdoorCaBundlesDir: import_node_path27.default.join(root, "frontdoor", "ca", "bundles"),
9155
- chatgptSignInFile: import_node_path27.default.join(root, "codex", "chatgpt-sign-in.json"),
9156
- frontdoorStateFile: import_node_path27.default.join(root, "frontdoor", "state.json"),
9157
- frontdoorLockFile: import_node_path27.default.join(root, "frontdoor", "start.lock"),
9158
- frontdoorControlTokenFile: import_node_path27.default.join(root, "frontdoor", "control-token"),
9159
- frontdoorSessionsDir: import_node_path27.default.join(root, "frontdoor", "sessions"),
9160
- frontdoorDirectRecordsDir: import_node_path27.default.join(root, "frontdoor", "direct"),
9161
- frontdoorDrainingDir: import_node_path27.default.join(root, "frontdoor", "draining"),
9162
- frontdoorRcCredentialsDir: import_node_path27.default.join(root, "frontdoor", "rc-credentials"),
9163
- frontdoorLogPath: import_node_path27.default.join(root, "logs", "frontdoor.log"),
9164
- usageDir: import_node_path27.default.join(root, "usage"),
9165
- usageLogDir: import_node_path27.default.join(root, "usage", "log"),
9166
- usageSnapshotsDir: import_node_path27.default.join(root, "usage", "snapshots"),
9167
- statuslineDir: import_node_path27.default.join(root, "statusline"),
9168
- catalogueDir: import_node_path27.default.join(root, "catalogues"),
9169
- usagePicksFile: import_node_path27.default.join(root, "usage", "picks.json"),
9170
- usageAnchorsFile: import_node_path27.default.join(root, "usage", "anchors.json"),
9171
- usageJobsFile: import_node_path27.default.join(root, "usage", "jobs.json"),
9172
- jobLogsDir: import_node_path27.default.join(root, "logs", "jobs"),
9173
- identityRenamesDir: import_node_path27.default.join(root, "identity-renames"),
9174
- identityNameRenamesDir: import_node_path27.default.join(root, "identity-name-renames"),
9175
- launchesDir: import_node_path27.default.join(root, "launches"),
9176
- superviseDir: import_node_path27.default.join(root, "supervise"),
9177
- modelMovesDir: import_node_path27.default.join(root, "model-moves"),
9178
- mcpPermissionsFile: import_node_path27.default.join(root, "mcp", "permissions.json")
9182
+ identitiesDir: import_node_path28.default.join(root, "identities"),
9183
+ configProfilesDir: import_node_path28.default.join(root, "config-profiles"),
9184
+ providersDir: import_node_path28.default.join(root, "providers"),
9185
+ providerAliasesFile: import_node_path28.default.join(root, "provider-aliases.json"),
9186
+ directoryRulesFile: import_node_path28.default.join(root, "directory-rules.json"),
9187
+ activeIdentityFile: import_node_path28.default.join(root, "active-identity"),
9188
+ globalConfigFile: import_node_path28.default.join(root, "config.json"),
9189
+ categoriesLocalFile: import_node_path28.default.join(root, "categories.local.json"),
9190
+ claudeShimFile: import_node_path28.default.join(root, "claude-shim.json"),
9191
+ headroomDir: import_node_path28.default.join(root, "headroom"),
9192
+ headroomStateFile: import_node_path28.default.join(root, "headroom", "state.json"),
9193
+ headroomRoutingFile: import_node_path28.default.join(root, "headroom", "routing.json"),
9194
+ headroomLegacyStateFile: import_node_path28.default.join(root, "headroom", "state.v2.json"),
9195
+ headroomAllowlistFile: import_node_path28.default.join(root, "headroom", "run", "allowlist.txt"),
9196
+ headroomSocketDir: import_node_path28.default.join(root, "headroom", "run"),
9197
+ headroomLockFile: import_node_path28.default.join(root, "headroom", "start.lock"),
9198
+ headroomSessionsDir: import_node_path28.default.join(root, "headroom", "sessions"),
9199
+ logsDir: import_node_path28.default.join(root, "logs"),
9200
+ headroomLogPath: import_node_path28.default.join(root, "logs", "headroom.log"),
9201
+ frontdoorDir: import_node_path28.default.join(root, "frontdoor"),
9202
+ frontdoorCaDir: import_node_path28.default.join(root, "frontdoor", "ca"),
9203
+ frontdoorCaCertFile: import_node_path28.default.join(root, "frontdoor", "ca", "ca.pem"),
9204
+ frontdoorCaKeyFile: import_node_path28.default.join(root, "frontdoor", "ca", "ca.key"),
9205
+ frontdoorCaBundlesDir: import_node_path28.default.join(root, "frontdoor", "ca", "bundles"),
9206
+ chatgptSignInFile: import_node_path28.default.join(root, "codex", "chatgpt-sign-in.json"),
9207
+ frontdoorStateFile: import_node_path28.default.join(root, "frontdoor", "state.json"),
9208
+ frontdoorLockFile: import_node_path28.default.join(root, "frontdoor", "start.lock"),
9209
+ frontdoorControlTokenFile: import_node_path28.default.join(root, "frontdoor", "control-token"),
9210
+ frontdoorSessionsDir: import_node_path28.default.join(root, "frontdoor", "sessions"),
9211
+ frontdoorDirectRecordsDir: import_node_path28.default.join(root, "frontdoor", "direct"),
9212
+ frontdoorDrainingDir: import_node_path28.default.join(root, "frontdoor", "draining"),
9213
+ frontdoorRcCredentialsDir: import_node_path28.default.join(root, "frontdoor", "rc-credentials"),
9214
+ frontdoorLogPath: import_node_path28.default.join(root, "logs", "frontdoor.log"),
9215
+ usageDir: import_node_path28.default.join(root, "usage"),
9216
+ usageLogDir: import_node_path28.default.join(root, "usage", "log"),
9217
+ usageSnapshotsDir: import_node_path28.default.join(root, "usage", "snapshots"),
9218
+ statuslineDir: import_node_path28.default.join(root, "statusline"),
9219
+ catalogueDir: import_node_path28.default.join(root, "catalogues"),
9220
+ usagePicksFile: import_node_path28.default.join(root, "usage", "picks.json"),
9221
+ usageAnchorsFile: import_node_path28.default.join(root, "usage", "anchors.json"),
9222
+ usageJobsFile: import_node_path28.default.join(root, "usage", "jobs.json"),
9223
+ jobLogsDir: import_node_path28.default.join(root, "logs", "jobs"),
9224
+ identityRenamesDir: import_node_path28.default.join(root, "identity-renames"),
9225
+ identityNameRenamesDir: import_node_path28.default.join(root, "identity-name-renames"),
9226
+ launchesDir: import_node_path28.default.join(root, "launches"),
9227
+ superviseDir: import_node_path28.default.join(root, "supervise"),
9228
+ modelMovesDir: import_node_path28.default.join(root, "model-moves"),
9229
+ mcpPermissionsFile: import_node_path28.default.join(root, "mcp", "permissions.json")
9179
9230
  };
9180
9231
  }
9181
9232
  function resolveLayoutPaths() {
9182
9233
  return buildLayoutPaths(resolveAgentShimHome());
9183
9234
  }
9184
- var import_node_fs6, import_node_os4, import_node_path27;
9235
+ var import_node_fs6, import_node_os4, import_node_path28;
9185
9236
  var init_paths = __esm({
9186
9237
  "src/paths.ts"() {
9187
9238
  "use strict";
9188
9239
  import_node_fs6 = __toESM(require("node:fs"), 1);
9189
9240
  import_node_os4 = __toESM(require("node:os"), 1);
9190
- import_node_path27 = __toESM(require("node:path"), 1);
9241
+ import_node_path28 = __toESM(require("node:path"), 1);
9191
9242
  init_legacy();
9192
9243
  }
9193
9244
  });
@@ -9215,7 +9266,7 @@ function decideSignIn(facts) {
9215
9266
  return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
9216
9267
  }
9217
9268
  function credentialsFilePath(farmRoot) {
9218
- return import_node_path28.default.join(farmRoot, CREDENTIALS_FILE);
9269
+ return import_node_path29.default.join(farmRoot, CREDENTIALS_FILE);
9219
9270
  }
9220
9271
  function identitySignIn(fs17, probe, identity) {
9221
9272
  const probing = !identity.hasCredentialBlock && identity.provider === void 0;
@@ -9227,12 +9278,12 @@ function identitySignIn(fs17, probe, identity) {
9227
9278
  platform: probe.platform
9228
9279
  });
9229
9280
  }
9230
- var import_node_crypto9, import_node_path28, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS;
9281
+ var import_node_crypto9, import_node_path29, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS;
9231
9282
  var init_signIn = __esm({
9232
9283
  "src/usage/signIn.ts"() {
9233
9284
  "use strict";
9234
9285
  import_node_crypto9 = require("node:crypto");
9235
- import_node_path28 = __toESM(require("node:path"), 1);
9286
+ import_node_path29 = __toESM(require("node:path"), 1);
9236
9287
  CREDENTIALS_FILE = ".credentials.json";
9237
9288
  KEYCHAIN_SERVICE_PREFIX = "Claude Code-credentials";
9238
9289
  KEYCHAIN_SERVICE_HASH_DIGITS = 8;
@@ -9445,7 +9496,7 @@ function serialisedFor(entry, owner) {
9445
9496
  return JSON.stringify({ owner, ...withoutOwner(entry) });
9446
9497
  }
9447
9498
  function tempPathFor(target) {
9448
- return import_node_path29.default.join(import_node_path29.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0, import_node_crypto10.randomUUID)()}`);
9499
+ return import_node_path30.default.join(import_node_path30.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0, import_node_crypto10.randomUUID)()}`);
9449
9500
  }
9450
9501
  function processRuns(pid) {
9451
9502
  try {
@@ -9463,7 +9514,7 @@ function abandonedTempFiles(entries) {
9463
9514
  }
9464
9515
  function sweepAbandonedTempFiles(dir) {
9465
9516
  for (const entry of abandonedTempFiles(import_node_fs7.default.existsSync(dir) ? import_node_fs7.default.readdirSync(dir) : [])) {
9466
- import_node_fs7.default.rmSync(import_node_path29.default.join(dir, entry), { force: true });
9517
+ import_node_fs7.default.rmSync(import_node_path30.default.join(dir, entry), { force: true });
9467
9518
  }
9468
9519
  }
9469
9520
  function storedEntry(store, entry, owner) {
@@ -9502,8 +9553,8 @@ function security(args, stdin) {
9502
9553
  return { status: result.status, stdout: result.stdout };
9503
9554
  }
9504
9555
  function createRealCredentialCache(root, keychain = { run: security, platform: process.platform }) {
9505
- const dir = import_node_path29.default.join(root, "credential-cache");
9506
- const filePath = (owner) => import_node_path29.default.join(dir, cacheFileNameFor(owner));
9556
+ const dir = import_node_path30.default.join(root, "credential-cache");
9557
+ const filePath = (owner) => import_node_path30.default.join(dir, cacheFileNameFor(owner));
9507
9558
  return {
9508
9559
  read(store, owner) {
9509
9560
  if (store === "file") {
@@ -9564,13 +9615,13 @@ function createRealCredentialCache(root, keychain = { run: security, platform: p
9564
9615
  function realCredentialCacheEnv(paths) {
9565
9616
  return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
9566
9617
  }
9567
- var import_node_crypto10, import_node_fs7, import_node_path29, CACHE_DIR_MODE, CACHE_FILE_MODE, TEMP_PREFIX, TEMP_NAME, RELEASED_TEMP_NAME;
9618
+ var import_node_crypto10, import_node_fs7, import_node_path30, CACHE_DIR_MODE, CACHE_FILE_MODE, TEMP_PREFIX, TEMP_NAME, RELEASED_TEMP_NAME;
9568
9619
  var init_realCredentialCache = __esm({
9569
9620
  "src/realCredentialCache.ts"() {
9570
9621
  "use strict";
9571
9622
  import_node_crypto10 = require("node:crypto");
9572
9623
  import_node_fs7 = __toESM(require("node:fs"), 1);
9573
- import_node_path29 = __toESM(require("node:path"), 1);
9624
+ import_node_path30 = __toESM(require("node:path"), 1);
9574
9625
  init_blockingSpawn();
9575
9626
  init_names();
9576
9627
  init_keychainLogin();
@@ -10477,67 +10528,18 @@ var init_providersStore = __esm({
10477
10528
  }
10478
10529
  });
10479
10530
 
10480
- // src/cli/bool.ts
10481
- function parseBoolWord(input) {
10482
- switch (input) {
10483
- case "true":
10484
- case "1":
10485
- return true;
10486
- case "false":
10487
- case "0":
10488
- return false;
10489
- default:
10490
- return void 0;
10491
- }
10492
- }
10493
- var init_bool = __esm({
10494
- "src/cli/bool.ts"() {
10495
- "use strict";
10496
- }
10497
- });
10498
-
10499
- // src/cli/envBool.ts
10500
- function parseEnvBool(variable, value) {
10501
- if (value === void 0 || value === "") {
10502
- return void 0;
10503
- }
10504
- const parsed = parseBoolWord(value);
10505
- if (parsed === void 0) {
10506
- throw new InvalidEnvBoolError(variable, value);
10507
- }
10508
- return parsed;
10509
- }
10510
- var InvalidEnvBoolError;
10511
- var init_envBool = __esm({
10512
- "src/cli/envBool.ts"() {
10513
- "use strict";
10514
- init_cliError();
10515
- init_bool();
10516
- InvalidEnvBoolError = class extends UsageError {
10517
- constructor(variable, value) {
10518
- super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
10519
- this.variable = variable;
10520
- this.value = value;
10521
- this.name = "InvalidEnvBoolError";
10522
- }
10523
- variable;
10524
- value;
10525
- };
10526
- }
10527
- });
10528
-
10529
10531
  // src/identityToken.ts
10530
10532
  function identityTokenDir(paths) {
10531
- return import_node_path30.default.join(paths.root, "credentials");
10533
+ return import_node_path31.default.join(paths.root, "credentials");
10532
10534
  }
10533
10535
  function identityTokenPath(paths, identityId) {
10534
- return import_node_path30.default.join(identityTokenDir(paths), `${identityId}.token`);
10536
+ return import_node_path31.default.join(identityTokenDir(paths), `${identityId}.token`);
10535
10537
  }
10536
- var import_node_path30;
10538
+ var import_node_path31;
10537
10539
  var init_identityToken = __esm({
10538
10540
  "src/identityToken.ts"() {
10539
10541
  "use strict";
10540
- import_node_path30 = __toESM(require("node:path"), 1);
10542
+ import_node_path31 = __toESM(require("node:path"), 1);
10541
10543
  init_cliError();
10542
10544
  }
10543
10545
  });
@@ -10783,7 +10785,7 @@ function listRenameJournals(fs17, directory) {
10783
10785
  if (!name.endsWith(JOURNAL_SUFFIX)) {
10784
10786
  continue;
10785
10787
  }
10786
- const file = import_node_path31.default.join(directory, name);
10788
+ const file = import_node_path32.default.join(directory, name);
10787
10789
  try {
10788
10790
  const journal = readRenameJournal(fs17, file);
10789
10791
  if (journal !== void 0) {
@@ -10828,12 +10830,12 @@ function requireNameFreeOfUnfinishedRename(fs17, directory, name, action, sameNa
10828
10830
  throw new NameHeldByUnfinishedRenameError(action, name, held, finishabilityOf(held, exists));
10829
10831
  }
10830
10832
  }
10831
- var import_node_crypto11, import_node_path31, import_zod21, RenameJournalSchema, FILE_NAME_HASH_DIGITS, JOURNAL_SUFFIX, RenameJournalUnreadableError, NameHeldByUnfinishedRenameError;
10833
+ var import_node_crypto11, import_node_path32, import_zod21, RenameJournalSchema, FILE_NAME_HASH_DIGITS, JOURNAL_SUFFIX, RenameJournalUnreadableError, NameHeldByUnfinishedRenameError;
10832
10834
  var init_identityRenameJournal = __esm({
10833
10835
  "src/identityRenameJournal.ts"() {
10834
10836
  "use strict";
10835
10837
  import_node_crypto11 = require("node:crypto");
10836
- import_node_path31 = __toESM(require("node:path"), 1);
10838
+ import_node_path32 = __toESM(require("node:path"), 1);
10837
10839
  import_zod21 = require("zod");
10838
10840
  init_cliError();
10839
10841
  RenameJournalSchema = import_zod21.z.strictObject({
@@ -10881,7 +10883,7 @@ function readRecordFiles(paths) {
10881
10883
  if (!entry.endsWith(RECORD_SUFFIX)) {
10882
10884
  return [];
10883
10885
  }
10884
- const file = import_node_path32.default.join(paths.identityNameRenamesDir, entry);
10886
+ const file = import_node_path33.default.join(paths.identityNameRenamesDir, entry);
10885
10887
  let parsed;
10886
10888
  try {
10887
10889
  parsed = JSON.parse(import_node_fs9.default.readFileSync(file, "utf8"));
@@ -10893,7 +10895,7 @@ function readRecordFiles(paths) {
10893
10895
  });
10894
10896
  }
10895
10897
  function isFiledForItsPair(entry) {
10896
- return import_node_path32.default.basename(entry.file) === renamePairFileName(entry.record.from, entry.record.to, RECORD_SUFFIX);
10898
+ return import_node_path33.default.basename(entry.file) === renamePairFileName(entry.record.from, entry.record.to, RECORD_SUFFIX);
10897
10899
  }
10898
10900
  function readNameRenameRecords(paths) {
10899
10901
  return readRecordFiles(paths).filter(isFiledForItsPair).map((entry) => entry.record);
@@ -10954,12 +10956,12 @@ function requireNoInterruptedNameRename(paths, name, action, except) {
10954
10956
  throw new InterruptedNameRenameError(action, describeInterruptedNameRename(paths, held));
10955
10957
  }
10956
10958
  }
10957
- var import_node_fs9, import_node_path32, import_zod22, NameRenameRecordSchema, RECORD_SUFFIX, InterruptedNameRenameError;
10959
+ var import_node_fs9, import_node_path33, import_zod22, NameRenameRecordSchema, RECORD_SUFFIX, InterruptedNameRenameError;
10958
10960
  var init_identityNameRenameRecord = __esm({
10959
10961
  "src/identityNameRenameRecord.ts"() {
10960
10962
  "use strict";
10961
10963
  import_node_fs9 = __toESM(require("node:fs"), 1);
10962
- import_node_path32 = __toESM(require("node:path"), 1);
10964
+ import_node_path33 = __toESM(require("node:path"), 1);
10963
10965
  import_zod22 = require("zod");
10964
10966
  init_cliError();
10965
10967
  init_configProfilesStore();
@@ -10989,13 +10991,13 @@ var init_identityNameRenameRecord = __esm({
10989
10991
 
10990
10992
  // src/launcher/launchRecords.ts
10991
10993
  function recordFile(directory, pid) {
10992
- return import_node_path33.default.join(directory, `${String(pid)}.${(0, import_node_crypto12.randomUUID)()}${RECORD_SUFFIX2}`);
10994
+ return import_node_path34.default.join(directory, `${String(pid)}.${(0, import_node_crypto12.randomUUID)()}${RECORD_SUFFIX2}`);
10993
10995
  }
10994
10996
  function readRecord(fs17, directory, name) {
10995
10997
  if (!name.endsWith(RECORD_SUFFIX2)) {
10996
10998
  return void 0;
10997
10999
  }
10998
- const raw = fs17.readFileUtf8(import_node_path33.default.join(directory, name));
11000
+ const raw = fs17.readFileUtf8(import_node_path34.default.join(directory, name));
10999
11001
  if (raw === void 0) {
11000
11002
  return void 0;
11001
11003
  }
@@ -11013,7 +11015,7 @@ function registerLaunch(fs17, directory, owner, isRunning) {
11013
11015
  for (const name of fs17.readdir(directory)) {
11014
11016
  const record2 = readRecord(fs17, directory, name);
11015
11017
  if (record2 !== void 0 && !isRunning(record2.pid)) {
11016
- fs17.removeRecursive(import_node_path33.default.join(directory, name));
11018
+ fs17.removeRecursive(import_node_path34.default.join(directory, name));
11017
11019
  }
11018
11020
  }
11019
11021
  const file = recordFile(directory, owner.pid);
@@ -11030,11 +11032,11 @@ function liveLaunchesOn(fs17, directory, identity, isRunning) {
11030
11032
  return record?.identity === identity && isRunning(record.pid) ? [record.pid] : [];
11031
11033
  }).sort((left, right) => left - right);
11032
11034
  }
11033
- var import_node_path33, import_node_crypto12, import_zod23, LaunchRecordSchema, RECORD_SUFFIX2;
11035
+ var import_node_path34, import_node_crypto12, import_zod23, LaunchRecordSchema, RECORD_SUFFIX2;
11034
11036
  var init_launchRecords = __esm({
11035
11037
  "src/launcher/launchRecords.ts"() {
11036
11038
  "use strict";
11037
- import_node_path33 = __toESM(require("node:path"), 1);
11039
+ import_node_path34 = __toESM(require("node:path"), 1);
11038
11040
  import_node_crypto12 = require("node:crypto");
11039
11041
  import_zod23 = require("zod");
11040
11042
  LaunchRecordSchema = import_zod23.z.strictObject({
@@ -11078,13 +11080,13 @@ function identityNameOf(paths, id) {
11078
11080
  return identityNameIn(identityRecords(paths), id);
11079
11081
  }
11080
11082
  function identityDirectory(paths, id) {
11081
- return import_node_path34.default.join(paths.identitiesDir, id);
11083
+ return import_node_path35.default.join(paths.identitiesDir, id);
11082
11084
  }
11083
11085
  function identityJsonPath(paths, id) {
11084
11086
  if (!isStoredName(id)) {
11085
11087
  throw new UnsafeNameError(id, "identity");
11086
11088
  }
11087
- return import_node_path34.default.join(identityDirectory(paths, id), IDENTITY_FILE);
11089
+ return import_node_path35.default.join(identityDirectory(paths, id), IDENTITY_FILE);
11088
11090
  }
11089
11091
  function requireIdentityNames(paths, names) {
11090
11092
  const existing = new Set(listIdentities(paths).map((entry) => entry.name));
@@ -11108,7 +11110,7 @@ function readIdentityById(paths, id) {
11108
11110
  return readJson(identityJsonPath(paths, id), IdentitySchema);
11109
11111
  }
11110
11112
  function idKeyedFiles(paths, id) {
11111
- return [identityTokenPath(paths, id), import_node_path34.default.join(paths.root, "credential-cache", cacheFileNameFor(identityCacheKey(id))), snapshotPath(paths.usageSnapshotsDir, id)];
11113
+ return [identityTokenPath(paths, id), import_node_path35.default.join(paths.root, "credential-cache", cacheFileNameFor(identityCacheKey(id))), snapshotPath(paths.usageSnapshotsDir, id)];
11112
11114
  }
11113
11115
  function loggedIdentityIds(paths) {
11114
11116
  let logged;
@@ -11138,7 +11140,7 @@ function stateFiledUnder(paths, id, allocation, moving) {
11138
11140
  const folded = id.toLowerCase();
11139
11141
  const entry = (import_node_fs10.default.existsSync(paths.identitiesDir) ? import_node_fs10.default.readdirSync(paths.identitiesDir) : []).find((candidate) => candidate !== moving?.lockEntry && belongsToIdentity(candidate.toLowerCase(), folded));
11140
11142
  if (entry !== void 0) {
11141
- return `${import_node_path34.default.join(paths.identitiesDir, entry)} exists${entry.toLowerCase() === folded && entry !== id ? `, and an id that differs from "${id}" only in case is the same directory on a filesystem that ignores case` : ""}`;
11143
+ return `${import_node_path35.default.join(paths.identitiesDir, entry)} exists${entry.toLowerCase() === folded && entry !== id ? `, and an id that differs from "${id}" only in case is the same directory on a filesystem that ignores case` : ""}`;
11142
11144
  }
11143
11145
  const sharing = allocation.recordIds().find((other) => other.toLowerCase() !== folded && other !== moving?.id && foldedCacheFile(other) === foldedCacheFile(id));
11144
11146
  if (sharing !== void 0) {
@@ -11146,12 +11148,12 @@ function stateFiledUnder(paths, id, allocation, moving) {
11146
11148
  const sharingFile = cacheFileNameFor(identityCacheKey(sharing));
11147
11149
  return `the credential cache would file it in ${file}, ${file === sharingFile ? `the file of identities/${sharing}` : `which differs only in case from the file of identities/${sharing}, ${sharingFile}`}`;
11148
11150
  }
11149
- const cacheDir = import_node_path34.default.join(paths.root, "credential-cache");
11151
+ const cacheDir = import_node_path35.default.join(paths.root, "credential-cache");
11150
11152
  const ownCacheFile = moving !== void 0 && createRealCredentialCache(paths.root).read("file", identityCacheKey(moving.id)) !== void 0 ? cacheFileNameFor(identityCacheKey(moving.id)) : void 0;
11151
11153
  for (const candidate of idKeyedFiles(paths, id)) {
11152
- const onDisk = entriesOf(import_node_path34.default.dirname(candidate)).find((spelled) => spelled.toLowerCase() === import_node_path34.default.basename(candidate).toLowerCase() && !(import_node_path34.default.dirname(candidate) === cacheDir && spelled === ownCacheFile));
11154
+ const onDisk = entriesOf(import_node_path35.default.dirname(candidate)).find((spelled) => spelled.toLowerCase() === import_node_path35.default.basename(candidate).toLowerCase() && !(import_node_path35.default.dirname(candidate) === cacheDir && spelled === ownCacheFile));
11153
11155
  if (onDisk !== void 0) {
11154
- return `${import_node_path34.default.join(import_node_path34.default.dirname(candidate), onDisk)} exists${onDisk === import_node_path34.default.basename(candidate) ? "" : `, and a file name that differs from ${import_node_path34.default.basename(candidate)} only in case is the same file on a filesystem that ignores case`}`;
11156
+ return `${import_node_path35.default.join(import_node_path35.default.dirname(candidate), onDisk)} exists${onDisk === import_node_path35.default.basename(candidate) ? "" : `, and a file name that differs from ${import_node_path35.default.basename(candidate)} only in case is the same file on a filesystem that ignores case`}`;
11155
11157
  }
11156
11158
  }
11157
11159
  if (allocation.keychain !== void 0 && keychainCacheEntryExists(allocation.keychain, identityCacheKey(id))) {
@@ -11195,7 +11197,7 @@ function addIdentity(paths, name, options = {}) {
11195
11197
  if (checkedId !== void 0 && idTaken(paths, checkedId, allocation)) {
11196
11198
  throw new CheckedIdTakenError(name, checkedId);
11197
11199
  }
11198
- const identity = IdentitySchema.parse({ name, allowAmbientCredential: false });
11200
+ const identity = IdentitySchema.parse({ name, allowAmbientCredential: false, ...options.agent === void 0 ? {} : { agent: options.agent } });
11199
11201
  writeJsonAtomic(identityJsonPath(paths, id()), identity);
11200
11202
  return identity;
11201
11203
  });
@@ -11256,7 +11258,7 @@ function listIdentityDirectories(paths) {
11256
11258
  if (!isIdentityDirectoryName(entry.name)) {
11257
11259
  continue;
11258
11260
  }
11259
- const entryPath = import_node_path34.default.join(paths.identitiesDir, entry.name);
11261
+ const entryPath = import_node_path35.default.join(paths.identitiesDir, entry.name);
11260
11262
  const followed = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? followedLink(entryPath) : "other";
11261
11263
  if (followed === "other") {
11262
11264
  continue;
@@ -11366,7 +11368,7 @@ function isFarmEntry(entry, name) {
11366
11368
  return entry === name || new RegExp(`^\\.${escapedForPattern(name)}${FARM_SUFFIX_PATTERN}$`, "u").test(entry);
11367
11369
  }
11368
11370
  function belongsToIdentity(entry, name) {
11369
- return isFarmEntry(entry, name) || entry === import_node_path34.default.basename(identityLockPath("", name));
11371
+ return isFarmEntry(entry, name) || entry === import_node_path35.default.basename(identityLockPath("", name));
11370
11372
  }
11371
11373
  function requireNewIdentityName(name) {
11372
11374
  if (!FileNameSchema.safeParse(name).success) {
@@ -11374,7 +11376,7 @@ function requireNewIdentityName(name) {
11374
11376
  }
11375
11377
  }
11376
11378
  function sameIdentityName(paths, first, second) {
11377
- return sameDirectory(import_node_path34.default.join(paths.identitiesDir, first), import_node_path34.default.join(paths.identitiesDir, second)) || first.toLowerCase() === second.toLowerCase() && ignoresCase(paths.identitiesDir);
11379
+ return sameDirectory(import_node_path35.default.join(paths.identitiesDir, first), import_node_path35.default.join(paths.identitiesDir, second)) || first.toLowerCase() === second.toLowerCase() && ignoresCase(paths.identitiesDir);
11378
11380
  }
11379
11381
  function requireNoUnfinishedRenameNaming(paths, name, action) {
11380
11382
  requireNameFreeOfUnfinishedRename({ readFileUtf8: nodeStoreFs.readFileUtf8, readdir: (directory) => import_node_fs10.default.existsSync(directory) ? import_node_fs10.default.readdirSync(directory) : [] }, paths.identityRenamesDir, name, action, (first, second) => sameIdentityName(paths, first, second), (identity) => identityIdExists(paths, identity));
@@ -11404,17 +11406,17 @@ function removeIdentityWithLockHeld(paths, name, namesLock) {
11404
11406
  }
11405
11407
  const resync = acquireRemovalLock(paths, name, id, namesLock);
11406
11408
  try {
11407
- const lockFile = import_node_path34.default.basename(resync.path);
11409
+ const lockFile = import_node_path35.default.basename(resync.path);
11408
11410
  for (const file of idKeyedFiles(paths, id).filter((candidate) => import_node_fs10.default.existsSync(candidate))) {
11409
- import_node_fs10.default.accessSync(import_node_path34.default.dirname(file), import_node_fs10.default.constants.W_OK | import_node_fs10.default.constants.X_OK);
11411
+ import_node_fs10.default.accessSync(import_node_path35.default.dirname(file), import_node_fs10.default.constants.W_OK | import_node_fs10.default.constants.X_OK);
11410
11412
  }
11411
- const links = import_node_fs10.default.readdirSync(paths.identitiesDir).filter((entry) => !entry.startsWith(".") && entry !== id && sameDirectory(import_node_path34.default.join(paths.identitiesDir, entry), import_node_path34.default.join(paths.identitiesDir, id)));
11413
+ const links = import_node_fs10.default.readdirSync(paths.identitiesDir).filter((entry) => !entry.startsWith(".") && entry !== id && sameDirectory(import_node_path35.default.join(paths.identitiesDir, entry), import_node_path35.default.join(paths.identitiesDir, id)));
11412
11414
  for (const entry of import_node_fs10.default.readdirSync(paths.identitiesDir)) {
11413
11415
  if (links.includes(entry) || entry !== lockFile && belongsToIdentity(entry, id)) {
11414
- import_node_fs10.default.rmSync(import_node_path34.default.join(paths.identitiesDir, entry), { recursive: true, force: true });
11416
+ import_node_fs10.default.rmSync(import_node_path35.default.join(paths.identitiesDir, entry), { recursive: true, force: true });
11415
11417
  }
11416
11418
  }
11417
- const cacheFile = import_node_path34.default.join(paths.root, "credential-cache", cacheFileNameFor(identityCacheKey(id)));
11419
+ const cacheFile = import_node_path35.default.join(paths.root, "credential-cache", cacheFileNameFor(identityCacheKey(id)));
11418
11420
  for (const file of idKeyedFiles(paths, id).filter((candidate) => candidate !== cacheFile)) {
11419
11421
  import_node_fs10.default.rmSync(file, { force: true });
11420
11422
  }
@@ -11427,12 +11429,12 @@ function removeIdentityWithLockHeld(paths, name, namesLock) {
11427
11429
  resync.release();
11428
11430
  }
11429
11431
  }
11430
- var import_node_fs10, import_node_path34, IdentityNotFoundError, DisplacedIdentityError, IdentityAlreadyExistsError, InvalidIdentityNameError, realUsageReadFs, realRecordsPort, CheckedIdTakenError, DISPLACED_PROBLEM, NOT_JSON_PROBLEM, IdentityRemovalBusyError, REMOVED_STATE;
11432
+ var import_node_fs10, import_node_path35, IdentityNotFoundError, DisplacedIdentityError, IdentityAlreadyExistsError, InvalidIdentityNameError, realUsageReadFs, realRecordsPort, CheckedIdTakenError, DISPLACED_PROBLEM, NOT_JSON_PROBLEM, IdentityRemovalBusyError, REMOVED_STATE;
11431
11433
  var init_identityStore = __esm({
11432
11434
  "src/identityStore.ts"() {
11433
11435
  "use strict";
11434
11436
  import_node_fs10 = __toESM(require("node:fs"), 1);
11435
- import_node_path34 = __toESM(require("node:path"), 1);
11437
+ import_node_path35 = __toESM(require("node:path"), 1);
11436
11438
  init_load();
11437
11439
  init_names();
11438
11440
  init_store();
@@ -11666,10 +11668,10 @@ function commandFilename(ownExecutablePath, commandName) {
11666
11668
  }
11667
11669
  function resolveOwnBinaryCheck(paths, contentSourcePath) {
11668
11670
  const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
11669
- const recordedTarget = state === void 0 ? void 0 : import_node_path36.default.resolve(state.targetPath);
11671
+ const recordedTarget = state === void 0 ? void 0 : import_node_path37.default.resolve(state.targetPath);
11670
11672
  let ownStat;
11671
11673
  return (candidate) => {
11672
- if (recordedTarget !== void 0 && import_node_path36.default.resolve(candidate) === recordedTarget) {
11674
+ if (recordedTarget !== void 0 && import_node_path37.default.resolve(candidate) === recordedTarget) {
11673
11675
  return true;
11674
11676
  }
11675
11677
  ownStat ??= statOrUndefined(contentSourcePath);
@@ -11692,22 +11694,22 @@ function statOrUndefined(target) {
11692
11694
  }
11693
11695
  }
11694
11696
  function findPathShadow(params) {
11695
- const resolvedTargetDir = import_node_path36.default.resolve(params.targetDir);
11697
+ const resolvedTargetDir = import_node_path37.default.resolve(params.targetDir);
11696
11698
  for (const dir of params.pathDirs) {
11697
11699
  const found = params.findExecutableInDir(dir, params.targetFilename);
11698
11700
  if (found === void 0) {
11699
11701
  continue;
11700
11702
  }
11701
- return import_node_path36.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
11703
+ return import_node_path37.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
11702
11704
  }
11703
- return params.pathDirs.some((dir) => import_node_path36.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
11705
+ return params.pathDirs.some((dir) => import_node_path37.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
11704
11706
  }
11705
- var import_node_fs11, import_node_path36, import_zod28, ClaudeShimStateSchema, nodeLinkFs;
11707
+ var import_node_fs11, import_node_path37, import_zod28, ClaudeShimStateSchema, nodeLinkFs;
11706
11708
  var init_claudeShim = __esm({
11707
11709
  "src/claudeShim.ts"() {
11708
11710
  "use strict";
11709
11711
  import_node_fs11 = __toESM(require("node:fs"), 1);
11710
- import_node_path36 = __toESM(require("node:path"), 1);
11712
+ import_node_path37 = __toESM(require("node:path"), 1);
11711
11713
  import_zod28 = require("zod");
11712
11714
  init_commandDeps();
11713
11715
  init_store();
@@ -11903,15 +11905,15 @@ function signInCatalogueFingerprint(raw, filePath) {
11903
11905
  function savedCatalogueFingerprint(provider, paths, env, home, read) {
11904
11906
  if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(read(paths.chatgptSignInFile), paths.chatgptSignInFile);
11905
11907
  const configuredHome = env.CODEX_HOME;
11906
- const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path39.default.join(home, ".codex") : configuredHome;
11907
- return cliCatalogueFingerprint(read(import_node_path39.default.join(codexHome, "auth.json")));
11908
+ const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path40.default.join(home, ".codex") : configuredHome;
11909
+ return cliCatalogueFingerprint(read(import_node_path40.default.join(codexHome, "auth.json")));
11908
11910
  }
11909
- var import_node_crypto13, import_node_path39, import_zod32, CatalogueBindingSchema;
11911
+ var import_node_crypto13, import_node_path40, import_zod32, CatalogueBindingSchema;
11910
11912
  var init_catalogueCredential = __esm({
11911
11913
  "src/codex/catalogueCredential.ts"() {
11912
11914
  "use strict";
11913
11915
  import_node_crypto13 = require("node:crypto");
11914
- import_node_path39 = __toESM(require("node:path"), 1);
11916
+ import_node_path40 = __toESM(require("node:path"), 1);
11915
11917
  import_zod32 = require("zod");
11916
11918
  init_siwcStore();
11917
11919
  CatalogueBindingSchema = import_zod32.z.strictObject({ fingerprint: import_zod32.z.string().min(1), source: import_zod32.z.string().min(1), revision: import_zod32.z.string().min(1) });
@@ -13140,7 +13142,7 @@ function buildEnv(params) {
13140
13142
  const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
13141
13143
  let providerCustomHeaders;
13142
13144
  if (!params.configDirEscapeHatch && params.identityId !== void 0) {
13143
- env.CLAUDE_CONFIG_DIR = import_node_path47.default.join(params.identitiesDir, params.identityId);
13145
+ env.CLAUDE_CONFIG_DIR = import_node_path48.default.join(params.identitiesDir, params.identityId);
13144
13146
  }
13145
13147
  if (params.provider !== void 0) {
13146
13148
  const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
@@ -13194,11 +13196,11 @@ function buildEnv(params) {
13194
13196
  }
13195
13197
  return env;
13196
13198
  }
13197
- var import_node_path47, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
13199
+ var import_node_path48, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
13198
13200
  var init_flags = __esm({
13199
13201
  "src/launcher/flags.ts"() {
13200
13202
  "use strict";
13201
- import_node_path47 = __toESM(require("node:path"), 1);
13203
+ import_node_path48 = __toESM(require("node:path"), 1);
13202
13204
  init_envBool();
13203
13205
  init_cliError();
13204
13206
  init_conditions();
@@ -13290,7 +13292,7 @@ function newestTranscript(fs17, projectDir) {
13290
13292
  if (!name.endsWith(".jsonl")) {
13291
13293
  continue;
13292
13294
  }
13293
- const candidate = import_node_path48.default.join(projectDir, name);
13295
+ const candidate = import_node_path49.default.join(projectDir, name);
13294
13296
  const stat = fs17.lstat(candidate);
13295
13297
  if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
13296
13298
  newestMs = stat.mtimeMs;
@@ -13304,16 +13306,16 @@ function resumedContextTokens(fs17, params) {
13304
13306
  if (target === void 0) {
13305
13307
  return void 0;
13306
13308
  }
13307
- const projectDir = import_node_path48.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
13308
- const file = target.kind === "id" ? import_node_path48.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
13309
+ const projectDir = import_node_path49.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
13310
+ const file = target.kind === "id" ? import_node_path49.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
13309
13311
  const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
13310
13312
  return text === void 0 ? void 0 : contextTokensOfTranscript(text);
13311
13313
  }
13312
- var import_node_path48;
13314
+ var import_node_path49;
13313
13315
  var init_resumeContext = __esm({
13314
13316
  "src/usage/resumeContext.ts"() {
13315
13317
  "use strict";
13316
- import_node_path48 = __toESM(require("node:path"), 1);
13318
+ import_node_path49 = __toESM(require("node:path"), 1);
13317
13319
  }
13318
13320
  });
13319
13321
 
@@ -14007,6 +14009,10 @@ function decideLaunch(params, readOnly, onRecorded) {
14007
14009
  proc.exit(1);
14008
14010
  }
14009
14011
  }
14012
+ if (loadedIdentity?.config.agent === "codex") {
14013
+ log.error(`Identity "${identityDecision.name ?? ""}" belongs to Codex. Use agent-shim run --agent codex @${identityDecision.name ?? ""}.`);
14014
+ proc.exit(1);
14015
+ }
14010
14016
  const configProfileDecision = decideConfigProfile({
14011
14017
  env,
14012
14018
  cliFlagConfigProfile: params.cliFlagConfigProfile ?? parsedArgv.configProfile,
@@ -14157,8 +14163,8 @@ function decideLaunch(params, readOnly, onRecorded) {
14157
14163
  if (definition.kind === "codex" && readOnly && cache !== void 0) {
14158
14164
  const binding = parseCatalogueBinding(params.fs.readFileUtf8(catalogueBindingPath(paths, name, catalogueOwner, generation)));
14159
14165
  const configuredHome = catalogueEnv.CODEX_HOME;
14160
- const home = configuredHome === void 0 || configuredHome === "" ? import_node_path49.default.join(import_node_os8.default.homedir(), ".codex") : configuredHome;
14161
- const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path49.default.resolve(home, "auth.json");
14166
+ const home = configuredHome === void 0 || configuredHome === "" ? import_node_path50.default.join(import_node_os8.default.homedir(), ".codex") : configuredHome;
14167
+ const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path50.default.resolve(home, "auth.json");
14162
14168
  const revision = params.fs.fileRevision?.(source);
14163
14169
  if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
14164
14170
  }
@@ -14179,7 +14185,7 @@ function decideLaunch(params, readOnly, onRecorded) {
14179
14185
  return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
14180
14186
  };
14181
14187
  const args = argsForSupervisor().args;
14182
- const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path49.default.join(paths.identitiesDir, farmIdentity);
14188
+ const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path50.default.join(paths.identitiesDir, farmIdentity);
14183
14189
  const decision = {
14184
14190
  identitySource: identityDecision.source,
14185
14191
  configDirEscapeHatch: identityDecision.configDirEscapeHatch,
@@ -14266,7 +14272,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
14266
14272
  let warnings = [];
14267
14273
  const updateCheck = runLaunchUpdateCheck({
14268
14274
  mode: params.updateMode ?? "off",
14269
- checkPath: import_node_path49.default.join(paths.root, "update.check"),
14275
+ checkPath: import_node_path50.default.join(paths.root, "update.check"),
14270
14276
  currentVersion: package_default.version,
14271
14277
  port: params.update
14272
14278
  });
@@ -14289,7 +14295,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
14289
14295
  classification: resyncFarmRuntime.classification,
14290
14296
  now: resyncFarmRuntime.now,
14291
14297
  uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
14292
- identityExists: () => params.fs.readConfigFile(import_node_path49.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
14298
+ identityExists: () => params.fs.readConfigFile(import_node_path50.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
14293
14299
  lock: resyncFarmRuntime.lock
14294
14300
  });
14295
14301
  } catch (error) {
@@ -14429,7 +14435,7 @@ function runLaunchPlan(plan, spawn3) {
14429
14435
  function runLauncher(params) {
14430
14436
  params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
14431
14437
  }
14432
- var import_node_crypto15, import_node_os8, import_node_util2, import_node_path49;
14438
+ var import_node_crypto15, import_node_os8, import_node_util2, import_node_path50;
14433
14439
  var init_launcher = __esm({
14434
14440
  "src/launcher.ts"() {
14435
14441
  "use strict";
@@ -14437,7 +14443,7 @@ var init_launcher = __esm({
14437
14443
  import_node_os8 = __toESM(require("node:os"), 1);
14438
14444
  init_catalogueCredential();
14439
14445
  import_node_util2 = require("node:util");
14440
- import_node_path49 = __toESM(require("node:path"), 1);
14446
+ import_node_path50 = __toESM(require("node:path"), 1);
14441
14447
  init_package();
14442
14448
  init_envBool();
14443
14449
  init_argv();
@@ -14487,13 +14493,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
14487
14493
  if (distDir === void 0) {
14488
14494
  throw new OwnCliPathUnknownError();
14489
14495
  }
14490
- return import_node_path50.default.join(distDir, OWN_CLI_FILE_NAME);
14496
+ return import_node_path51.default.join(distDir, OWN_CLI_FILE_NAME);
14491
14497
  }
14492
- var import_node_path50, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
14498
+ var import_node_path51, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
14493
14499
  var init_ownCli = __esm({
14494
14500
  "src/ownCli.ts"() {
14495
14501
  "use strict";
14496
- import_node_path50 = __toESM(require("node:path"), 1);
14502
+ import_node_path51 = __toESM(require("node:path"), 1);
14497
14503
  init_cliError();
14498
14504
  OWN_CLI_FILE_NAME = "cli.cjs";
14499
14505
  OwnCliPathUnknownError = class extends CliError {
@@ -14546,7 +14552,7 @@ var init_selfIdentity = __esm({
14546
14552
  // src/frontdoor/trust.ts
14547
14553
  function resolveTrustBundle(params) {
14548
14554
  const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
14549
- if (inherited === void 0 || inherited === "" || import_node_path51.default.resolve(inherited) === import_node_path51.default.resolve(caCertFile)) {
14555
+ if (inherited === void 0 || inherited === "" || import_node_path52.default.resolve(inherited) === import_node_path52.default.resolve(caCertFile)) {
14550
14556
  return { path: caCertFile };
14551
14557
  }
14552
14558
  const caPem = fs17.readFileUtf8(caCertFile);
@@ -14564,19 +14570,19 @@ function resolveTrustBundle(params) {
14564
14570
  }
14565
14571
  const combined = `${inheritedPem.trimEnd()}
14566
14572
  ${caPem}`;
14567
- const bundle = import_node_path51.default.join(bundlesDir, `${(0, import_node_crypto16.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
14573
+ const bundle = import_node_path52.default.join(bundlesDir, `${(0, import_node_crypto16.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
14568
14574
  if (!fs17.exists(bundle)) {
14569
14575
  fs17.mkdirp(bundlesDir);
14570
14576
  fs17.writeFileAtomic(bundle, combined);
14571
14577
  }
14572
14578
  return { path: bundle };
14573
14579
  }
14574
- var import_node_crypto16, import_node_path51, BUNDLE_NAME_HEX_DIGITS;
14580
+ var import_node_crypto16, import_node_path52, BUNDLE_NAME_HEX_DIGITS;
14575
14581
  var init_trust = __esm({
14576
14582
  "src/frontdoor/trust.ts"() {
14577
14583
  "use strict";
14578
14584
  import_node_crypto16 = require("node:crypto");
14579
- import_node_path51 = __toESM(require("node:path"), 1);
14585
+ import_node_path52 = __toESM(require("node:path"), 1);
14580
14586
  BUNDLE_NAME_HEX_DIGITS = 16;
14581
14587
  }
14582
14588
  });
@@ -14762,7 +14768,7 @@ function realPrepareLaunchParams(paths, options) {
14762
14768
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
14763
14769
  credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
14764
14770
  hold: realHoldPort,
14765
- hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path52.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
14771
+ hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path53.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
14766
14772
  ...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
14767
14773
  ...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
14768
14774
  ...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
@@ -14823,12 +14829,12 @@ function resolveClaudeLaunch(options, run = realRunPort) {
14823
14829
  };
14824
14830
  return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
14825
14831
  }
14826
- var import_node_os10, import_node_path52, import_node_crypto17, LaunchRefusedError;
14832
+ var import_node_os10, import_node_path53, import_node_crypto17, LaunchRefusedError;
14827
14833
  var init_launchWiring = __esm({
14828
14834
  "src/launchWiring.ts"() {
14829
14835
  "use strict";
14830
14836
  import_node_os10 = __toESM(require("node:os"), 1);
14831
- import_node_path52 = __toESM(require("node:path"), 1);
14837
+ import_node_path53 = __toESM(require("node:path"), 1);
14832
14838
  import_node_crypto17 = require("node:crypto");
14833
14839
  init_cliError();
14834
14840
  init_claudeShim();
@@ -15898,8 +15904,8 @@ function pathnameOf(url) {
15898
15904
  return new URL(url ?? "/", "http://127.0.0.1").pathname;
15899
15905
  }
15900
15906
  function isRcSessionExchange(url) {
15901
- const path53 = pathnameOf(url);
15902
- return path53 === RC_SESSIONS_PATH_PREFIX || path53.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
15907
+ const path54 = pathnameOf(url);
15908
+ return path54 === RC_SESSIONS_PATH_PREFIX || path54.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
15903
15909
  }
15904
15910
  var RC_SESSION_ID_PREFIX = "cse_";
15905
15911
  var RC_IDLE_EXPIRY_MS = 45e3;
@@ -16458,8 +16464,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
16458
16464
  function isRcReadFileEncoding(value) {
16459
16465
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
16460
16466
  }
16461
- function buildRcReadFilePayload(requestId, path53, options) {
16462
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path53, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
16467
+ function buildRcReadFilePayload(requestId, path54, options) {
16468
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path54, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
16463
16469
  }
16464
16470
  function buildRcFileSuggestionsPayload(requestId, query) {
16465
16471
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -16561,15 +16567,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
16561
16567
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
16562
16568
  return result.ok ? { ...result, requestId } : result;
16563
16569
  }
16564
- async function readRcSessionFile(deps, sessionId, path53, options) {
16565
- if (path53 === "") {
16570
+ async function readRcSessionFile(deps, sessionId, path54, options) {
16571
+ if (path54 === "") {
16566
16572
  return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
16567
16573
  }
16568
16574
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
16569
16575
  return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
16570
16576
  }
16571
16577
  const requestId = deps.newUuid();
16572
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path53, options), `read ${path53} from session ${sessionId}`);
16578
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path54, options), `read ${path54} from session ${sessionId}`);
16573
16579
  return result.ok ? { ...result, requestId } : result;
16574
16580
  }
16575
16581
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -16738,11 +16744,11 @@ function createRcControlHandler(deps) {
16738
16744
  path: "read-file",
16739
16745
  read: (body) => {
16740
16746
  const session = bodyString(body, "session");
16741
- const path53 = bodyString(body, "path");
16747
+ const path54 = bodyString(body, "path");
16742
16748
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
16743
16749
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
16744
- const refused2 = session === void 0 || path53 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
16745
- return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path53, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
16750
+ const refused2 = session === void 0 || path54 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
16751
+ return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path54, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
16746
16752
  }
16747
16753
  },
16748
16754
  {
@@ -17052,9 +17058,9 @@ function requestIdOfBody(body) {
17052
17058
  }
17053
17059
  function frontDoorRcControl(transport, token) {
17054
17060
  const headers = { authorization: `Bearer ${token}` };
17055
- const listAnswerOf = async (path53, what) => {
17061
+ const listAnswerOf = async (path54, what) => {
17056
17062
  try {
17057
- return await transport.request({ method: "GET", path: path53, headers });
17063
+ return await transport.request({ method: "GET", path: path54, headers });
17058
17064
  } catch (error) {
17059
17065
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
17060
17066
  }
@@ -17126,10 +17132,10 @@ function frontDoorRcControl(transport, token) {
17126
17132
  }
17127
17133
  return pending;
17128
17134
  };
17129
- const writeOf = async (path53, body, describeFailure2) => {
17135
+ const writeOf = async (path54, body, describeFailure2) => {
17130
17136
  let answer;
17131
17137
  try {
17132
- answer = await transport.request({ method: "POST", path: path53, headers: { ...headers, "content-type": "application/json" }, body });
17138
+ answer = await transport.request({ method: "POST", path: path54, headers: { ...headers, "content-type": "application/json" }, body });
17133
17139
  } catch (error) {
17134
17140
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
17135
17141
  }
@@ -17160,10 +17166,10 @@ function frontDoorRcControl(transport, token) {
17160
17166
  endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
17161
17167
  getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
17162
17168
  getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
17163
- readFile: async (sessionId, path53, options) => await writeOf(
17169
+ readFile: async (sessionId, path54, options) => await writeOf(
17164
17170
  `${CONTROL_PATH_PREFIX}/read-file`,
17165
- JSON.stringify({ session: sessionId, path: path53, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
17166
- (status, message) => `reading ${path53} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
17171
+ JSON.stringify({ session: sessionId, path: path54, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
17172
+ (status, message) => `reading ${path54} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
17167
17173
  ),
17168
17174
  fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
17169
17175
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -17322,12 +17328,12 @@ function tlsFacts(options) {
17322
17328
  }
17323
17329
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
17324
17330
  const agent = new ExemptTlsAgent();
17325
- const post = async (path53, headers, body) => await new Promise((resolve, reject) => {
17331
+ const post = async (path54, headers, body) => await new Promise((resolve, reject) => {
17326
17332
  const options = {
17327
17333
  host: target.host,
17328
17334
  port: target.port,
17329
17335
  method: "POST",
17330
- path: path53,
17336
+ path: path54,
17331
17337
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
17332
17338
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
17333
17339
  agent
@@ -17392,12 +17398,12 @@ function lateRcStreamDial(resolve) {
17392
17398
  }
17393
17399
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
17394
17400
  const agent = new ExemptTlsAgent();
17395
- const request4 = async (method, path53, headers, body, signal) => await new Promise((resolve, reject) => {
17401
+ const request4 = async (method, path54, headers, body, signal) => await new Promise((resolve, reject) => {
17396
17402
  const options = {
17397
17403
  host: target.host,
17398
17404
  port: target.port,
17399
17405
  method,
17400
- path: path53,
17406
+ path: path54,
17401
17407
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
17402
17408
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
17403
17409
  agent,
@@ -17439,9 +17445,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
17439
17445
  return { status, body: await readAll(response) };
17440
17446
  },
17441
17447
  openStream: async (sessionId, headers, resume, signal) => {
17442
- const path53 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
17448
+ const path54 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
17443
17449
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
17444
- const { status, response } = await request4("GET", path53, streamHeaders, void 0, signal);
17450
+ const { status, response } = await request4("GET", path54, streamHeaders, void 0, signal);
17445
17451
  if (!isSuccessful2(status)) {
17446
17452
  await readAll(response);
17447
17453
  return { status, chunks: NO_CHUNKS };
@@ -18342,6 +18348,31 @@ var import_openapi8 = require("@orpc/openapi");
18342
18348
 
18343
18349
  // src/checkReport.ts
18344
18350
  var import_node_os5 = __toESM(require("node:os"), 1);
18351
+ init_cliError();
18352
+
18353
+ // src/codex/categories.ts
18354
+ var CODEX_CATEGORIES = {
18355
+ secret: ["auth.json", "auth.json.*", "*.sqlite*", "*.db*", "identity.json", "cap_sid", "credentials*", "secrets*"],
18356
+ runtime: [".git*", ".DS_Store", "log", "logs", "tmp", "cache", "shell_snapshots", "models_cache.json", "version.json", "packages", "bin", "state", "otel"],
18357
+ history: ["sessions", "archived_sessions", "history.jsonl", "session_index.jsonl", "memories"],
18358
+ knowledge: ["AGENTS.md", "AGENTS.override.md", "skills", "rules", "agents", "prompts"],
18359
+ settings: ["config.toml", "*.config.toml"]
18360
+ };
18361
+
18362
+ // src/codex/identity.ts
18363
+ var import_node_path20 = __toESM(require("node:path"), 1);
18364
+ init_envBool();
18365
+ var CODEX_AMBIENT_CREDENTIALS = ["OPENAI_API_KEY", "CODEX_API_KEY", "CODEX_ACCESS_TOKEN", "OPENAI_IDENTITY_TOKEN_FILE", "OPENAI_FEDERATION_RULE_ID"];
18366
+ function canonicalCodexHome(env, home) {
18367
+ return import_node_path20.default.resolve(env.AGENT_SHIM_CODEX_HOME === void 0 || env.AGENT_SHIM_CODEX_HOME === "" ? import_node_path20.default.join(home, ".codex") : env.AGENT_SHIM_CODEX_HOME);
18368
+ }
18369
+ function codexCredentialGuard(env, allowAmbientCredential) {
18370
+ const variable = CODEX_AMBIENT_CREDENTIALS.find((key) => (env[key] ?? "") !== "");
18371
+ if (variable === void 0 || allowAmbientCredential || parseEnvBool("AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL", env.AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL) === true) return { ok: true };
18372
+ return { ok: false, variable, message: `Ambient Codex credential variable ${variable} overrides the selected login. Unset it or explicitly allow ambient credentials with AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1 or identity set <name> --allow-ambient-credential.` };
18373
+ }
18374
+
18375
+ // src/checkReport.ts
18345
18376
  init_classify();
18346
18377
  init_load();
18347
18378
 
@@ -18443,7 +18474,7 @@ init_realCredentialCache();
18443
18474
  init_providersStore();
18444
18475
  init_signIn();
18445
18476
  init_realPorts();
18446
- var import_node_path35 = __toESM(require("node:path"), 1);
18477
+ var import_node_path36 = __toESM(require("node:path"), 1);
18447
18478
  var import_zod24 = require("zod");
18448
18479
  init_envBool();
18449
18480
  init_load();
@@ -18613,6 +18644,7 @@ function buildClaudeVersionReport(params, cascadePin) {
18613
18644
  };
18614
18645
  }
18615
18646
  function runCheck(params) {
18647
+ const isCodex = params.agent === "codex" || params.identity?.agent === "codex";
18616
18648
  const facts = buildEntryFacts({
18617
18649
  fs: params.farmFs,
18618
18650
  claudeHome: params.claudeHome,
@@ -18627,7 +18659,7 @@ function runCheck(params) {
18627
18659
  const resolved = resolveDecisions({ facts, cascade: params.cascade, classification: params.classification });
18628
18660
  const decisionLines = [...resolved.decisions.values()].slice().sort((a, b) => a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0).map(formatDecision);
18629
18661
  const projectEncodingAmbiguities = flagAmbiguousEncodings(resolved.flattened, facts);
18630
- const ambientCredential = evaluateAmbientCredentialGuard({
18662
+ const ambientCredential = isCodex ? codexCredentialGuard(params.env, params.identity?.allowAmbientCredential ?? false) : evaluateAmbientCredentialGuard({
18631
18663
  env: params.env,
18632
18664
  allowAmbientCredential: params.identity?.allowAmbientCredential ?? false,
18633
18665
  allowAmbientCredentialOverride: parseEnvBool("AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL", params.env.AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL) === true,
@@ -18635,8 +18667,8 @@ function runCheck(params) {
18635
18667
  });
18636
18668
  const settingsShared = resolved.flattened.categories.get("settings") ?? SHIPPED_CATEGORY_DEFAULTS.settings;
18637
18669
  const settingsExposure = inspectSettingsExposure({ settingsShared, files: params.settingsFiles });
18638
- const keychain = params.platform === "darwin" && params.run !== void 0 && params.farmRoot !== void 0 ? lookupKeychainService(params.run, params.farmRoot) : void 0;
18639
- const claudeVersion = buildClaudeVersionReport(params, resolved.flattened.launch.claudeVersion);
18670
+ const keychain = !isCodex && params.platform === "darwin" && params.run !== void 0 && params.farmRoot !== void 0 ? lookupKeychainService(params.run, params.farmRoot) : void 0;
18671
+ const claudeVersion = isCodex ? void 0 : buildClaudeVersionReport(params, resolved.flattened.launch.claudeVersion);
18640
18672
  return {
18641
18673
  ...params.identityName === void 0 ? {} : { identityName: params.identityName },
18642
18674
  identitySource: params.identitySource,
@@ -18667,7 +18699,7 @@ function formatCheckReport(report) {
18667
18699
  }
18668
18700
  lines.push("", "Resolved entries:");
18669
18701
  if (report.decisionLines.length === 0) {
18670
- lines.push(" (nothing under ~/.claude to report)");
18702
+ lines.push(" (nothing in the canonical home to report)");
18671
18703
  }
18672
18704
  for (const line of report.decisionLines) {
18673
18705
  lines.push(` ${line}`);
@@ -18770,13 +18802,15 @@ function loadCheckProvider(paths, name) {
18770
18802
  function collectCheckReport(params) {
18771
18803
  const { paths, cwd } = params;
18772
18804
  const home = import_node_os5.default.homedir();
18773
- const claudeHome = resolveClaudeHome();
18774
18805
  const read = cosmiconfigReader();
18775
- const classification = loadClassification(paths);
18776
18806
  const loaded = loadCascadeInput({ paths, home, cwd, read });
18777
18807
  const git = resolveGitBranch(realRunPort, cwd);
18778
- const { selection, identityConfig } = selectLaunch({ paths, cwd, env: params.env, ...params.identity === void 0 ? {} : { identity: params.identity } }, loaded);
18808
+ const { selection, identityConfig } = selectLaunch({ paths, cwd, env: params.agent === "codex" ? { ...params.env, CLAUDE_CONFIG_DIR: void 0 } : params.env, ...params.identity === void 0 ? {} : { identity: params.identity } }, loaded);
18779
18809
  const { identity: identityDecision, poolPick, configProfile: configProfileDecision } = selection;
18810
+ const isCodex = identityConfig?.agent === "codex" || params.agent === "codex";
18811
+ if (identityConfig !== void 0 && params.agent !== void 0 && (identityConfig.agent ?? "claude") !== params.agent) throw new UsageError("The selected identity belongs to a different agent.");
18812
+ const claudeHome = isCodex ? canonicalCodexHome(params.env, home) : resolveClaudeHome();
18813
+ const classification = isCodex ? { defaults: CODEX_CATEGORIES } : loadClassification(paths);
18780
18814
  const cascade = loadCascadeInput({
18781
18815
  paths,
18782
18816
  home,
@@ -18787,12 +18821,13 @@ function collectCheckReport(params) {
18787
18821
  const providerName = cascadeProviderName(cascade, identityConfig?.provider);
18788
18822
  const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
18789
18823
  const identityId = identityDecision.name === void 0 ? void 0 : identityIdOf(paths, identityDecision.name);
18790
- const farmRoot = identityId === void 0 ? void 0 : import_node_path35.default.join(paths.identitiesDir, identityId);
18791
- const settingsFiles = {
18792
- "settings.json": realFsPort.readFileUtf8(import_node_path35.default.join(claudeHome, "settings.json")),
18793
- "settings.local.json": realFsPort.readFileUtf8(import_node_path35.default.join(claudeHome, "settings.local.json"))
18824
+ const farmRoot = identityId === void 0 ? void 0 : import_node_path36.default.join(paths.identitiesDir, identityId);
18825
+ const settingsFiles = isCodex ? {} : {
18826
+ "settings.json": realFsPort.readFileUtf8(import_node_path36.default.join(claudeHome, "settings.json")),
18827
+ "settings.local.json": realFsPort.readFileUtf8(import_node_path36.default.join(claudeHome, "settings.local.json"))
18794
18828
  };
18795
18829
  const report = runCheck({
18830
+ ...isCodex ? { agent: "codex" } : {},
18796
18831
  cwd,
18797
18832
  home,
18798
18833
  claudeHome,
@@ -18813,7 +18848,7 @@ function collectCheckReport(params) {
18813
18848
  settingsFiles,
18814
18849
  run: realRunPort,
18815
18850
  credentialCache: realCredentialCacheEnv(paths),
18816
- installedClaudeVersions: realInstalledClaudeVersions(),
18851
+ ...isCodex ? {} : { installedClaudeVersions: realInstalledClaudeVersions() },
18817
18852
  ...farmRoot === void 0 ? {} : { farmRoot },
18818
18853
  platform: process.platform,
18819
18854
  ...provider === void 0 ? {} : { provider }
@@ -19034,9 +19069,18 @@ var ResetRowSchema = import_zod27.z.strictObject({
19034
19069
  var ResetScheduleSchema = import_zod27.z.strictObject({ resets: import_zod27.z.readonly(import_zod27.z.array(ResetRowSchema)) });
19035
19070
 
19036
19071
  // src/frontdoor/controlSchemas.ts
19037
- var import_node_path41 = __toESM(require("node:path"), 1);
19072
+ var import_node_path42 = __toESM(require("node:path"), 1);
19038
19073
  var import_zod34 = require("zod");
19039
19074
 
19075
+ // src/codex/doctor.ts
19076
+ function codexIdentityFindings(entry, identity) {
19077
+ const incompatible = identity.provider !== void 0 || identity.credential !== void 0 || identity.anchors !== void 0;
19078
+ return [
19079
+ { section: "identity", severity: incompatible ? "fail" : "pass", subject: entry.name, message: incompatible ? `${entry.name} is a Codex identity with Claude-only provider, credential or anchor settings.` : `${entry.name} is a valid Codex identity; its home is ${entry.farmRoot}.` },
19080
+ { section: "sign-in", severity: "warn", subject: entry.name, message: `Codex login not queried. Run agent-shim run --agent codex @${entry.name} login status to validate its isolated login.` }
19081
+ ];
19082
+ }
19083
+
19040
19084
  // src/doctorReport.ts
19041
19085
  init_claudeShim();
19042
19086
  init_readableConfig();
@@ -19046,14 +19090,14 @@ init_identityStore();
19046
19090
  init_identityRecords();
19047
19091
 
19048
19092
  // src/doctorIdentityRecords.ts
19049
- var import_node_path37 = __toESM(require("node:path"), 1);
19093
+ var import_node_path38 = __toESM(require("node:path"), 1);
19050
19094
  init_identityRecords();
19051
19095
  function identityRecordFindings(records, displaced, nameRenames, strayNameRenameFiles) {
19052
19096
  return [
19053
19097
  ...strayNameRenameFiles.map((file) => ({
19054
19098
  severity: "warn",
19055
19099
  message: `${file} holds the record of a rename of an identity's name, but not under the file name that rename keeps it in, so nothing reads it or removes it. Remove it.`,
19056
- subject: import_node_path37.default.basename(file)
19100
+ subject: import_node_path38.default.basename(file)
19057
19101
  })),
19058
19102
  ...nameRenames.map(({ from, description }) => ({ severity: "fail", message: description, subject: from })),
19059
19103
  ...duplicateIdentityNames(records).map(({ name, ids }) => ({
@@ -19076,7 +19120,7 @@ var import_node_fs14 = __toESM(require("node:fs"), 1);
19076
19120
 
19077
19121
  // src/doctorPath.ts
19078
19122
  var import_node_fs12 = __toESM(require("node:fs"), 1);
19079
- var import_node_path38 = __toESM(require("node:path"), 1);
19123
+ var import_node_path39 = __toESM(require("node:path"), 1);
19080
19124
  init_blockingSpawn();
19081
19125
  init_realPorts();
19082
19126
  function realpathOrSelf(target) {
@@ -19089,14 +19133,14 @@ function realpathOrSelf(target) {
19089
19133
  var MAX_FORWARDING_SCRIPT_BYTES = 8192;
19090
19134
  function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
19091
19135
  const executable = realpathOrSelf(target);
19092
- const trustedMise = import_node_path38.default.join(import_node_path38.default.dirname(trustedExecutable), "mise");
19093
- if (import_node_path38.default.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
19094
- const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", import_node_path38.default.basename(target)], { encoding: "utf8", env });
19136
+ const trustedMise = import_node_path39.default.join(import_node_path39.default.dirname(trustedExecutable), "mise");
19137
+ if (import_node_path39.default.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
19138
+ const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", import_node_path39.default.basename(target)], { encoding: "utf8", env });
19095
19139
  if (result.error !== void 0) return void 0;
19096
19140
  if (result.status === 0 && result.stdout.trim() !== "") return result.stdout.trim();
19097
19141
  if (!result.stderr.includes("not currently active")) return void 0;
19098
19142
  for (const dir of pathDirs) {
19099
- const candidate = findExecutableInDir(dir, import_node_path38.default.basename(target));
19143
+ const candidate = findExecutableInDir(dir, import_node_path39.default.basename(target));
19100
19144
  if (candidate !== void 0 && realpathOrSelf(candidate) !== executable) {
19101
19145
  try {
19102
19146
  const script = import_node_fs12.default.statSync(candidate).size <= MAX_FORWARDING_SCRIPT_BYTES ? realFsPort.readFileUtf8(candidate) : void 0;
@@ -19111,7 +19155,7 @@ function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
19111
19155
  }
19112
19156
 
19113
19157
  // src/doctorReport.ts
19114
- var import_node_path40 = __toESM(require("node:path"), 1);
19158
+ var import_node_path41 = __toESM(require("node:path"), 1);
19115
19159
  init_signIn();
19116
19160
  init_identityAccounts();
19117
19161
  init_read();
@@ -19546,7 +19590,7 @@ function tcpPortEraRecord(raw) {
19546
19590
  return (has("port") || has("lastPort")) && !has("socketPath");
19547
19591
  }
19548
19592
  function pushPathResolution(push, resolution) {
19549
- const ownDir = import_node_path40.default.dirname(resolution.ownExecutablePath);
19593
+ const ownDir = import_node_path41.default.dirname(resolution.ownExecutablePath);
19550
19594
  switch (resolution.agentShim.status) {
19551
19595
  case "ok":
19552
19596
  push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
@@ -19666,14 +19710,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
19666
19710
  }
19667
19711
  function pushLegacyName(push, params) {
19668
19712
  const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
19669
- if (legacyVariables.length === 0 && import_node_path40.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
19713
+ if (legacyVariables.length === 0 && import_node_path41.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
19670
19714
  push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
19671
19715
  return;
19672
19716
  }
19673
19717
  for (const name of legacyVariables) {
19674
19718
  push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
19675
19719
  }
19676
- if (import_node_path40.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
19720
+ if (import_node_path41.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
19677
19721
  push(
19678
19722
  "legacy-name",
19679
19723
  "warn",
@@ -19767,9 +19811,9 @@ function runDoctor(params) {
19767
19811
  push("identity", "warn", `identities/${name} cannot be reached (${code}), so it is not counted as an identity. Repair the permissions of the directory or of what a symlink points through, or remove the entry.`, name);
19768
19812
  }
19769
19813
  for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
19770
- push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, import_node_path40.default.basename(file));
19814
+ push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, import_node_path41.default.basename(file));
19771
19815
  }
19772
- const validIdentityNames = /* @__PURE__ */ new Set();
19816
+ const validIdentityAgents = /* @__PURE__ */ new Map();
19773
19817
  const signedInAccounts = [];
19774
19818
  for (const entry of params.identities) {
19775
19819
  const validated3 = validate(IdentitySchema, entry, "identity", entry.name);
@@ -19777,7 +19821,7 @@ function runDoctor(params) {
19777
19821
  push("identity", "fail", validated3.message, entry.name);
19778
19822
  continue;
19779
19823
  }
19780
- validIdentityNames.add(entry.name);
19824
+ validIdentityAgents.set(entry.name, validated3.data.agent ?? "claude");
19781
19825
  const defaultProfile = validated3.data.defaultConfigProfile;
19782
19826
  let consistent = true;
19783
19827
  if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
@@ -19797,6 +19841,10 @@ function runDoctor(params) {
19797
19841
  if (!consistent) {
19798
19842
  continue;
19799
19843
  }
19844
+ if (validated3.data.agent === "codex") {
19845
+ findings.push(...codexIdentityFindings(entry, validated3.data));
19846
+ continue;
19847
+ }
19800
19848
  const credential = validated3.data.credential;
19801
19849
  const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, identityCacheKey(entry.id), credential);
19802
19850
  const authenticatesWith = credential !== void 0 ? `credential ${describeCredential(credential)}` : identityProvider !== void 0 ? `the credential of provider "${identityProvider}"` : "its stored login";
@@ -19835,9 +19883,9 @@ function runDoctor(params) {
19835
19883
  }
19836
19884
  const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
19837
19885
  const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
19838
- const accountByIdentity = new Map(params.identities.flatMap((entry) => validIdentityNames.has(entry.name) && entry.account !== void 0 ? [[entry.name, entry.account]] : []));
19886
+ const accountByIdentity = new Map(params.identities.flatMap((entry) => validIdentityAgents.has(entry.name) && entry.account !== void 0 ? [[entry.name, entry.account]] : []));
19839
19887
  for (const [poolName, pool] of Object.entries(pools)) {
19840
- const missing = pool.identities.filter((member) => poolNameOf(poolMemberIdentity(member)) === void 0 && !validIdentityNames.has(poolMemberIdentity(member)));
19888
+ const missing = pool.identities.filter((member) => poolNameOf(poolMemberIdentity(member)) === void 0 && !validIdentityAgents.has(poolMemberIdentity(member)));
19841
19889
  const undefinedPools = pool.identities.flatMap((member) => {
19842
19890
  const nested = poolNameOf(poolMemberIdentity(member));
19843
19891
  return nested === void 0 || nested in pools ? [] : [nested];
@@ -19881,7 +19929,7 @@ function runDoctor(params) {
19881
19929
  }
19882
19930
  const selectionExists = (selector) => {
19883
19931
  const poolName = poolNameOf(selector);
19884
- return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
19932
+ return poolName === void 0 ? validIdentityAgents.has(selector) : poolName in pools;
19885
19933
  };
19886
19934
  for (const entry of params.providers) {
19887
19935
  if (!pushNameFinding(push, "provider", "provider", entry)) {
@@ -19897,6 +19945,7 @@ function runDoctor(params) {
19897
19945
  push("keychain", "pass", "Skipped (not macOS).");
19898
19946
  } else {
19899
19947
  for (const entry of params.identities) {
19948
+ if (validIdentityAgents.get(entry.name) === "codex") continue;
19900
19949
  const result = lookupKeychainService(params.run, entry.farmRoot);
19901
19950
  push("keychain", "pass", result.found ? result.note : `${result.note} The sign-in section reports whether a login is stored elsewhere.`, entry.name);
19902
19951
  }
@@ -20127,9 +20176,9 @@ function collectDoctorReport(params) {
20127
20176
  const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
20128
20177
  const records = identityRecords(paths);
20129
20178
  const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
20130
- const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(import_node_path40.default.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
20131
- const farmRoot = import_node_path40.default.join(paths.identitiesDir, id);
20132
- const identityPath = import_node_path40.default.join(farmRoot, "identity.json");
20179
+ const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(import_node_path41.default.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
20180
+ const farmRoot = import_node_path41.default.join(paths.identitiesDir, id);
20181
+ const identityPath = import_node_path41.default.join(farmRoot, "identity.json");
20133
20182
  return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs14.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
20134
20183
  });
20135
20184
  const usageSnapshots = {};
@@ -20147,12 +20196,12 @@ function collectDoctorReport(params) {
20147
20196
  }
20148
20197
  const profileNames = import_node_fs14.default.existsSync(paths.configProfilesDir) ? import_node_fs14.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
20149
20198
  const configProfiles = profileNames.map((name) => {
20150
- const profilePath = import_node_path40.default.join(paths.configProfilesDir, `${name}.json`);
20199
+ const profilePath = import_node_path41.default.join(paths.configProfilesDir, `${name}.json`);
20151
20200
  return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
20152
20201
  });
20153
20202
  const providerNames = import_node_fs14.default.existsSync(paths.providersDir) ? import_node_fs14.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
20154
20203
  const providers = providerNames.map((name) => {
20155
- const providerPath = import_node_path40.default.join(paths.providersDir, `${name}.json`);
20204
+ const providerPath = import_node_path41.default.join(paths.providersDir, `${name}.json`);
20156
20205
  return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
20157
20206
  });
20158
20207
  const ownExecutablePath = realOwnExecutablePath();
@@ -20164,12 +20213,12 @@ function collectDoctorReport(params) {
20164
20213
  binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
20165
20214
  }
20166
20215
  const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
20167
- const pathDirs = (params.env.PATH ?? "").split(import_node_path40.default.delimiter).filter((dir) => dir !== "");
20216
+ const pathDirs = (params.env.PATH ?? "").split(import_node_path41.default.delimiter).filter((dir) => dir !== "");
20168
20217
  const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
20169
20218
  findPathShadow({
20170
20219
  pathDirs,
20171
- targetDir: import_node_path40.default.dirname(shimState.targetPath),
20172
- targetFilename: import_node_path40.default.basename(shimState.targetPath),
20220
+ targetDir: import_node_path41.default.dirname(shimState.targetPath),
20221
+ targetFilename: import_node_path41.default.basename(shimState.targetPath),
20173
20222
  findExecutableInDir
20174
20223
  }),
20175
20224
  shimState.targetPath,
@@ -20195,7 +20244,7 @@ function collectDoctorReport(params) {
20195
20244
  providerAliases: readProviderAliases(paths),
20196
20245
  renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
20197
20246
  unreachableIdentities,
20198
- identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path40.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
20247
+ identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path41.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
20199
20248
  directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
20200
20249
  globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
20201
20250
  models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
@@ -20210,7 +20259,7 @@ function collectDoctorReport(params) {
20210
20259
  agentShim: refinePathShadow(
20211
20260
  findPathShadow({
20212
20261
  pathDirs,
20213
- targetDir: import_node_path40.default.dirname(ownExecutablePath),
20262
+ targetDir: import_node_path41.default.dirname(ownExecutablePath),
20214
20263
  targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
20215
20264
  findExecutableInDir
20216
20265
  }),
@@ -20301,11 +20350,11 @@ var FrontDoorSessionsOutputSchema = import_zod34.z.strictObject({ sessions: impo
20301
20350
  var CheckRunInputSchema = import_zod34.z.strictObject({
20302
20351
  path: import_zod34.z.string().min(1),
20303
20352
  identity: import_zod34.z.string().min(1).optional()
20304
- }).refine((input) => import_node_path41.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20353
+ }).refine((input) => import_node_path42.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20305
20354
  var PoolPickInputSchema = import_zod34.z.strictObject({
20306
20355
  pool: import_zod34.z.string().min(1),
20307
20356
  path: import_zod34.z.string().min(1)
20308
- }).refine((input) => import_node_path41.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20357
+ }).refine((input) => import_node_path42.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
20309
20358
  var DoctorFindingSchema = import_zod34.z.strictObject({
20310
20359
  section: import_zod34.z.enum(DOCTOR_SECTIONS),
20311
20360
  subject: import_zod34.z.string().optional(),
@@ -20641,7 +20690,7 @@ function profileValue(name, paths) {
20641
20690
  function createConfigApiRouter(deps) {
20642
20691
  const authed = doorApiAuth(deps.expectedToken);
20643
20692
  const { paths } = deps;
20644
- const route = (path53, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path53, summary, tags: [CONFIG_API_TAG] }));
20693
+ const route = (path54, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path54, summary, tags: [CONFIG_API_TAG] }));
20645
20694
  return {
20646
20695
  config: {
20647
20696
  identity: {
@@ -21043,7 +21092,7 @@ var import_openapi6 = require("@orpc/openapi");
21043
21092
  init_cliError();
21044
21093
 
21045
21094
  // src/frontdoor/launchSchemas.ts
21046
- var import_node_path42 = __toESM(require("node:path"), 1);
21095
+ var import_node_path43 = __toESM(require("node:path"), 1);
21047
21096
  var import_zod38 = require("zod");
21048
21097
  init_statusline();
21049
21098
  init_claudeVersion();
@@ -21054,7 +21103,7 @@ var LaunchResolveInputSchema = import_zod38.z.strictObject({
21054
21103
  argv: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.string())).optional(),
21055
21104
  /** 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. */
21056
21105
  env: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.string()).optional()
21057
- }).refine((input) => import_node_path42.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
21106
+ }).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
21058
21107
  var LaunchPoolDecisionSchema = import_zod38.z.strictObject({
21059
21108
  name: import_zod38.z.string(),
21060
21109
  reasons: import_zod38.z.readonly(import_zod38.z.array(import_zod38.z.string())),
@@ -23235,7 +23284,7 @@ data: ${JSON.stringify(envelope)}
23235
23284
  }
23236
23285
 
23237
23286
  // src/frontdoor/rcSelfHostMint.ts
23238
- var import_node_path43 = __toESM(require("node:path"), 1);
23287
+ var import_node_path44 = __toESM(require("node:path"), 1);
23239
23288
  init_identityRecords();
23240
23289
  init_account();
23241
23290
  var CREDENTIALS_FILE2 = ".credentials.json";
@@ -23261,7 +23310,7 @@ function readJsonObject(fs17, file) {
23261
23310
  return isRecord14(parsed) ? parsed : void 0;
23262
23311
  }
23263
23312
  function readRcSelfHostRecord(fs17, frontdoorDir) {
23264
- const parsed = readJsonObject(fs17, import_node_path43.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
23313
+ const parsed = readJsonObject(fs17, import_node_path44.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
23265
23314
  if (parsed === void 0) {
23266
23315
  return void 0;
23267
23316
  }
@@ -23279,11 +23328,11 @@ function mintRcSelfHostCredential(deps) {
23279
23328
  if (id === void 0) {
23280
23329
  throw new Error(`No identity named "${deps.identity}".`);
23281
23330
  }
23282
- const identityDir = import_node_path43.default.join(deps.identitiesDir, id);
23283
- const credentialsFile = import_node_path43.default.join(identityDir, CREDENTIALS_FILE2);
23284
- const claudeJsonFile = import_node_path43.default.join(identityDir, CLAUDE_JSON2);
23285
- const recordDir = import_node_path43.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
23286
- const recordFile2 = import_node_path43.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
23331
+ const identityDir = import_node_path44.default.join(deps.identitiesDir, id);
23332
+ const credentialsFile = import_node_path44.default.join(identityDir, CREDENTIALS_FILE2);
23333
+ const claudeJsonFile = import_node_path44.default.join(identityDir, CLAUDE_JSON2);
23334
+ const recordDir = import_node_path44.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
23335
+ const recordFile2 = import_node_path44.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
23287
23336
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
23288
23337
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
23289
23338
  const existingOauth = isRecord14(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
@@ -23299,7 +23348,7 @@ function mintRcSelfHostCredential(deps) {
23299
23348
  const organizationUuid = deps.newUuid();
23300
23349
  const accountUuid = deps.newUuid();
23301
23350
  const mintedAt = new Date(deps.now()).toISOString();
23302
- deps.fs.mkdirPrivate(import_node_path43.default.dirname(credentialsFile));
23351
+ deps.fs.mkdirPrivate(import_node_path44.default.dirname(credentialsFile));
23303
23352
  deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
23304
23353
  `);
23305
23354
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
@@ -23335,7 +23384,7 @@ function mintRcSelfHostCredential(deps) {
23335
23384
  init_ensure2();
23336
23385
 
23337
23386
  // src/frontdoor/liveSessionRegistry.ts
23338
- var import_node_path44 = __toESM(require("node:path"), 1);
23387
+ var import_node_path45 = __toESM(require("node:path"), 1);
23339
23388
  init_capability();
23340
23389
  init_state();
23341
23390
  function sameStat(recorded, current) {
@@ -23355,7 +23404,7 @@ function createLiveSessionRegistry(ports) {
23355
23404
  const load = (name, stat) => {
23356
23405
  known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
23357
23406
  };
23358
- const statOf = (name) => fs17.lstat(import_node_path44.default.join(sessionsDir, name));
23407
+ const statOf = (name) => fs17.lstat(import_node_path45.default.join(sessionsDir, name));
23359
23408
  const reconcile = () => {
23360
23409
  const names = new Set(recordNames());
23361
23410
  let changed = false;
@@ -23422,7 +23471,7 @@ init_plan2();
23422
23471
  init_poolPick();
23423
23472
 
23424
23473
  // src/agents/read.ts
23425
- var import_node_path45 = __toESM(require("node:path"), 1);
23474
+ var import_node_path46 = __toESM(require("node:path"), 1);
23426
23475
  var import_zod40 = require("zod");
23427
23476
  var PROJECTS_DIR = "projects";
23428
23477
  var TASKS_DIR = "tasks";
@@ -23448,15 +23497,15 @@ function parseEntry2(project, entry) {
23448
23497
  }
23449
23498
  function listSessions2(fs17, configDir) {
23450
23499
  const found = [];
23451
- for (const project of fs17.readdir(import_node_path45.default.join(configDir, PROJECTS_DIR))) {
23452
- const projectDir = import_node_path45.default.join(configDir, PROJECTS_DIR, project);
23500
+ for (const project of fs17.readdir(import_node_path46.default.join(configDir, PROJECTS_DIR))) {
23501
+ const projectDir = import_node_path46.default.join(configDir, PROJECTS_DIR, project);
23453
23502
  const entries = /* @__PURE__ */ new Set();
23454
23503
  for (const name of fs17.readdir(projectDir)) {
23455
23504
  if (name.endsWith(TRANSCRIPT_SUFFIX)) {
23456
23505
  entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
23457
23506
  continue;
23458
23507
  }
23459
- const children = fs17.readdir(import_node_path45.default.join(projectDir, name));
23508
+ const children = fs17.readdir(import_node_path46.default.join(projectDir, name));
23460
23509
  if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
23461
23510
  entries.add(name);
23462
23511
  }
@@ -23476,8 +23525,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
23476
23525
  const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
23477
23526
  located.push({
23478
23527
  id,
23479
- metaPath: import_node_path45.default.join(relativeDir, name),
23480
- transcriptPath: import_node_path45.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
23528
+ metaPath: import_node_path46.default.join(relativeDir, name),
23529
+ transcriptPath: import_node_path46.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
23481
23530
  workflowRunId
23482
23531
  });
23483
23532
  }
@@ -23520,7 +23569,7 @@ function describeFailure(error) {
23520
23569
  }
23521
23570
  function readFileOrReport(fs17, configDir, relative, report) {
23522
23571
  try {
23523
- return fs17.readFileUtf8(import_node_path45.default.join(configDir, relative));
23572
+ return fs17.readFileUtf8(import_node_path46.default.join(configDir, relative));
23524
23573
  } catch (error) {
23525
23574
  report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
23526
23575
  return void 0;
@@ -23528,7 +23577,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
23528
23577
  }
23529
23578
  function listDirOrReport(fs17, configDir, relative, report) {
23530
23579
  try {
23531
- return fs17.readdir(import_node_path45.default.join(configDir, relative));
23580
+ return fs17.readdir(import_node_path46.default.join(configDir, relative));
23532
23581
  } catch (error) {
23533
23582
  report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
23534
23583
  return [];
@@ -23552,18 +23601,18 @@ var WorkflowRunFileSchema = import_zod40.z.object({
23552
23601
  summary: import_zod40.z.string().optional()
23553
23602
  });
23554
23603
  function summariseSession(fs17, configDir, ref) {
23555
- const sessionRelative = import_node_path45.default.join(PROJECTS_DIR, ref.project, ref.entry);
23556
- const subagentsRelative = import_node_path45.default.join(sessionRelative, SUBAGENTS_DIR);
23557
- const workflowsUnderSubagents = import_node_path45.default.join(subagentsRelative, WORKFLOWS_DIR);
23604
+ const sessionRelative = import_node_path46.default.join(PROJECTS_DIR, ref.project, ref.entry);
23605
+ const subagentsRelative = import_node_path46.default.join(sessionRelative, SUBAGENTS_DIR);
23606
+ const workflowsUnderSubagents = import_node_path46.default.join(subagentsRelative, WORKFLOWS_DIR);
23558
23607
  const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
23559
- let agentCount = fs17.readdir(import_node_path45.default.join(configDir, subagentsRelative)).filter(isMeta).length;
23560
- for (const runDir of fs17.readdir(import_node_path45.default.join(configDir, workflowsUnderSubagents))) {
23608
+ let agentCount = fs17.readdir(import_node_path46.default.join(configDir, subagentsRelative)).filter(isMeta).length;
23609
+ for (const runDir of fs17.readdir(import_node_path46.default.join(configDir, workflowsUnderSubagents))) {
23561
23610
  if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
23562
- agentCount += fs17.readdir(import_node_path45.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
23611
+ agentCount += fs17.readdir(import_node_path46.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
23563
23612
  }
23564
23613
  }
23565
- const workflowRunCount = fs17.readdir(import_node_path45.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
23566
- const transcript = fs17.lstat(import_node_path45.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
23614
+ const workflowRunCount = fs17.readdir(import_node_path46.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
23615
+ const transcript = fs17.lstat(import_node_path46.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
23567
23616
  return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
23568
23617
  }
23569
23618
  function readSessionAgentTree(fs17, configDir, ref, options = {}) {
@@ -23571,13 +23620,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
23571
23620
  const report = (problem) => {
23572
23621
  problems.push(problem);
23573
23622
  };
23574
- const sessionRelative = import_node_path45.default.join(PROJECTS_DIR, ref.project, ref.entry);
23575
- const subagentsRelative = import_node_path45.default.join(sessionRelative, SUBAGENTS_DIR);
23576
- const workflowsUnderSubagents = import_node_path45.default.join(subagentsRelative, WORKFLOWS_DIR);
23623
+ const sessionRelative = import_node_path46.default.join(PROJECTS_DIR, ref.project, ref.entry);
23624
+ const subagentsRelative = import_node_path46.default.join(sessionRelative, SUBAGENTS_DIR);
23625
+ const workflowsUnderSubagents = import_node_path46.default.join(subagentsRelative, WORKFLOWS_DIR);
23577
23626
  const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
23578
23627
  for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
23579
23628
  if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
23580
- located.push(...locateAgents(fs17, configDir, import_node_path45.default.join(workflowsUnderSubagents, runDir), runDir, report));
23629
+ located.push(...locateAgents(fs17, configDir, import_node_path46.default.join(workflowsUnderSubagents, runDir), runDir, report));
23581
23630
  }
23582
23631
  }
23583
23632
  const agents = /* @__PURE__ */ new Map();
@@ -23618,7 +23667,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
23618
23667
  superseded: ref.superseded,
23619
23668
  agents: roots.sort().map(build),
23620
23669
  tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
23621
- workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path45.default.join(sessionRelative, WORKFLOWS_DIR), report),
23670
+ workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path46.default.join(sessionRelative, WORKFLOWS_DIR), report),
23622
23671
  problems
23623
23672
  };
23624
23673
  }
@@ -23683,12 +23732,12 @@ function ownTaskLists(sessionId) {
23683
23732
  function readTasks(fs17, configDir, ownLists, sharedLists, report) {
23684
23733
  const tasks = [];
23685
23734
  [...ownLists, ...sharedLists].forEach((scope, index) => {
23686
- const relativeDir = import_node_path45.default.join(TASKS_DIR, scope);
23735
+ const relativeDir = import_node_path46.default.join(TASKS_DIR, scope);
23687
23736
  for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
23688
23737
  if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
23689
23738
  continue;
23690
23739
  }
23691
- const relative = import_node_path45.default.join(relativeDir, name);
23740
+ const relative = import_node_path46.default.join(relativeDir, name);
23692
23741
  const text = readFileOrReport(fs17, configDir, relative, report);
23693
23742
  const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
23694
23743
  if (parsed.success) {
@@ -23706,7 +23755,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
23706
23755
  if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
23707
23756
  continue;
23708
23757
  }
23709
- const relative = import_node_path45.default.join(relativeDir, name);
23758
+ const relative = import_node_path46.default.join(relativeDir, name);
23710
23759
  const text = readFileOrReport(fs17, configDir, relative, report);
23711
23760
  const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
23712
23761
  if (!parsed.success) {
@@ -23722,7 +23771,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
23722
23771
  }
23723
23772
 
23724
23773
  // src/agents/sessions.ts
23725
- var import_node_path46 = __toESM(require("node:path"), 1);
23774
+ var import_node_path47 = __toESM(require("node:path"), 1);
23726
23775
  init_cliError();
23727
23776
  var SessionLookupError = class extends CliError {
23728
23777
  constructor(message) {
@@ -23734,7 +23783,7 @@ function historyStores(fs17, configDirOf, identities) {
23734
23783
  const byRealPath = /* @__PURE__ */ new Map();
23735
23784
  for (const identity of identities) {
23736
23785
  const configDir = configDirOf(identity);
23737
- const real = fs17.realpath(import_node_path46.default.join(configDir, "projects"));
23786
+ const real = fs17.realpath(import_node_path47.default.join(configDir, "projects"));
23738
23787
  if (real === void 0) {
23739
23788
  continue;
23740
23789
  }