codexuse-cli 6.2.12 → 6.3.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.js CHANGED
@@ -2046,7 +2046,7 @@ var require_toml = __commonJS({
2046
2046
 
2047
2047
  // src/commands/accountPool.ts
2048
2048
  var import_node_crypto16 = require("crypto");
2049
- var import_node_path15 = __toESM(require("path"));
2049
+ var import_node_path16 = __toESM(require("path"));
2050
2050
 
2051
2051
  // ../../packages/contracts/src/settings/types.ts
2052
2052
  var DEFAULT_ACCOUNT_POOL_EXPOSED_MODELS = [
@@ -3483,11 +3483,23 @@ function resolveDefaultUserDataDir() {
3483
3483
  if (configured && import_node_path4.default.isAbsolute(configured)) {
3484
3484
  return import_node_path4.default.resolve(configured);
3485
3485
  }
3486
- const home = process.env.HOME || import_node_os.default.homedir();
3486
+ const home = process.env.HOME || process.env.USERPROFILE || import_node_os.default.homedir();
3487
3487
  if (!home) {
3488
3488
  throw new Error("Unable to resolve home directory for app state.");
3489
3489
  }
3490
- return import_node_path4.default.join(home, "Library", "Application Support", APP_NAME);
3490
+ if (process.platform === "darwin") {
3491
+ return import_node_path4.default.join(home, "Library", "Application Support", APP_NAME);
3492
+ }
3493
+ if (process.platform === "win32") {
3494
+ return import_node_path4.default.join(
3495
+ process.env.APPDATA || import_node_path4.default.join(home, "AppData", "Roaming"),
3496
+ APP_NAME
3497
+ );
3498
+ }
3499
+ return import_node_path4.default.join(
3500
+ process.env.XDG_CONFIG_HOME || import_node_path4.default.join(home, ".config"),
3501
+ APP_NAME
3502
+ );
3491
3503
  }
3492
3504
  function getUserDataDir() {
3493
3505
  return configuredUserDataDir ?? resolveDefaultUserDataDir();
@@ -5662,6 +5674,30 @@ async function readLinuxMachineId() {
5662
5674
  }
5663
5675
  return null;
5664
5676
  }
5677
+ function parseWindowsMachineGuid(output) {
5678
+ const match7 = output.match(/^\s*MachineGuid\s+REG_\w+\s+(.+?)\s*$/im);
5679
+ return normalize(match7?.[1]) || null;
5680
+ }
5681
+ async function readWindowsMachineGuid() {
5682
+ if (process.platform !== "win32") {
5683
+ return null;
5684
+ }
5685
+ try {
5686
+ const { stdout } = await execFileAsync(
5687
+ "reg.exe",
5688
+ [
5689
+ "query",
5690
+ "HKLM\\SOFTWARE\\Microsoft\\Cryptography",
5691
+ "/v",
5692
+ "MachineGuid"
5693
+ ],
5694
+ { timeout: 4e3, windowsHide: true }
5695
+ );
5696
+ return parseWindowsMachineGuid(stdout);
5697
+ } catch {
5698
+ return null;
5699
+ }
5700
+ }
5665
5701
  function hashDeviceComponent(value3) {
5666
5702
  return import_node_crypto4.default.createHash("sha256").update(`codexuse-device:${value3}`).digest("hex");
5667
5703
  }
@@ -5671,7 +5707,7 @@ async function getDeviceId() {
5671
5707
  }
5672
5708
  const dbPath = resolveAppStorageDbPath(getUserDataDir());
5673
5709
  const cached2 = normalize(await readDocument(dbPath, DEVICE_ID_DOCUMENT, normalize));
5674
- const stableDeviceSource = await readHardwareUuid() ?? await readLinuxMachineId();
5710
+ const stableDeviceSource = await readHardwareUuid() ?? await readLinuxMachineId() ?? await readWindowsMachineGuid();
5675
5711
  if (stableDeviceSource) {
5676
5712
  const deviceId2 = hashDeviceComponent(stableDeviceSource);
5677
5713
  if (cached2 !== deviceId2) {
@@ -6631,7 +6667,7 @@ function shouldEnforceProfileLimit(status) {
6631
6667
  // ../../packages/runtime-profiles/src/profiles/profile-manager.ts
6632
6668
  var import_node_crypto15 = require("crypto");
6633
6669
  var import_fs = require("fs");
6634
- var import_node_os5 = __toESM(require("os"), 1);
6670
+ var import_node_os8 = __toESM(require("os"), 1);
6635
6671
  var import_path = __toESM(require("path"), 1);
6636
6672
  var import_path2 = require("path");
6637
6673
  var import_toml2 = __toESM(require_toml(), 1);
@@ -6690,29 +6726,68 @@ function resolveProfileIdentityKeyFromProfile(profile) {
6690
6726
  var import_node_child_process5 = require("child_process");
6691
6727
  var import_node_crypto11 = require("crypto");
6692
6728
  var import_node_readline = __toESM(require("readline"), 1);
6693
- var import_node_fs6 = require("fs");
6694
- var import_node_os3 = __toESM(require("os"), 1);
6695
- var import_node_path10 = __toESM(require("path"), 1);
6729
+ var import_node_fs7 = require("fs");
6730
+ var import_node_os6 = __toESM(require("os"), 1);
6731
+ var import_node_path11 = __toESM(require("path"), 1);
6696
6732
 
6697
6733
  // ../../packages/runtime-codex/src/codex/cli.ts
6698
6734
  var import_node_child_process2 = require("child_process");
6735
+ var import_node_fs5 = require("fs");
6736
+ var import_node_os2 = __toESM(require("os"), 1);
6737
+ var import_node_path6 = __toESM(require("path"), 1);
6738
+
6739
+ // ../../packages/runtime-codex/src/codex/pathCommand.ts
6699
6740
  var import_node_fs4 = require("fs");
6700
6741
  var import_node_path5 = __toESM(require("path"), 1);
6742
+ function isRunnableFile(candidate, platform) {
6743
+ try {
6744
+ if (!(0, import_node_fs4.statSync)(candidate).isFile()) return false;
6745
+ (0, import_node_fs4.accessSync)(candidate, platform === "win32" ? import_node_fs4.constants.F_OK : import_node_fs4.constants.X_OK);
6746
+ return true;
6747
+ } catch {
6748
+ return false;
6749
+ }
6750
+ }
6751
+ function resolveNpmShimEntrypoint(command, shimPath) {
6752
+ if (!/\.(?:cmd|bat)$/i.test(shimPath)) return null;
6753
+ const root = import_node_path5.default.dirname(shimPath);
6754
+ const candidates = command.toLowerCase() === "codex" ? [import_node_path5.default.join(root, "node_modules", "@openai", "codex", "bin", "codex.js")] : command.toLowerCase() === "codexuse" ? [
6755
+ import_node_path5.default.join(root, "node_modules", "codexuse-cli", "dist", "index.js"),
6756
+ import_node_path5.default.join(root, "node_modules", "@codexuse", "cli", "dist", "index.js")
6757
+ ] : [];
6758
+ return candidates.find((candidate) => isRunnableFile(candidate, "win32")) ?? null;
6759
+ }
6760
+ function resolveCommandOnPath(command, env = process.env, platform = process.platform) {
6761
+ const direct = import_node_path5.default.isAbsolute(command) || command.includes("/") || command.includes("\\");
6762
+ const extensions = platform === "win32" && import_node_path5.default.extname(command) === "" ? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
6763
+ const directories = direct ? [""] : (env.PATH ?? "").split(platform === "win32" ? ";" : ":").map((entry) => entry.trim().replace(/^"+|"+$/g, "")).filter(Boolean);
6764
+ for (const directory of directories) {
6765
+ for (const extension of extensions) {
6766
+ const candidate = direct ? `${command}${extension}` : import_node_path5.default.join(directory, `${command}${extension}`);
6767
+ if (isRunnableFile(candidate, platform)) {
6768
+ return resolveNpmShimEntrypoint(command, candidate) ?? import_node_path5.default.resolve(candidate);
6769
+ }
6770
+ }
6771
+ }
6772
+ return null;
6773
+ }
6774
+
6775
+ // ../../packages/runtime-codex/src/codex/cli.ts
6701
6776
  var STABLE_CHANNEL = "stable";
6702
6777
  var ENV_HINTS = ["CODEX_BINARY", "CODEX_CLI_PATH", "CODEX_PATH"];
6703
6778
  var cachedStatus = null;
6704
6779
  var cachedVersion = null;
6705
6780
  function getPathHintEntries() {
6706
- const homeDir = process.env.HOME ?? "";
6781
+ const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? import_node_os2.default.homedir();
6707
6782
  const homeEntries = homeDir ? [
6708
- import_node_path5.default.join(homeDir, ".local", "bin"),
6709
- import_node_path5.default.join(homeDir, ".fnm", "aliases", "default", "bin"),
6710
- import_node_path5.default.join(homeDir, ".fnm", "current", "bin"),
6711
- import_node_path5.default.join(homeDir, ".volta", "bin"),
6712
- import_node_path5.default.join(homeDir, ".asdf", "shims"),
6713
- import_node_path5.default.join(homeDir, ".bun", "bin")
6783
+ import_node_path6.default.join(homeDir, ".local", "bin"),
6784
+ import_node_path6.default.join(homeDir, ".fnm", "aliases", "default", "bin"),
6785
+ import_node_path6.default.join(homeDir, ".fnm", "current", "bin"),
6786
+ import_node_path6.default.join(homeDir, ".volta", "bin"),
6787
+ import_node_path6.default.join(homeDir, ".asdf", "shims"),
6788
+ import_node_path6.default.join(homeDir, ".bun", "bin")
6714
6789
  ] : [];
6715
- const configuredHints = (process.env.CODEX_PATH_HINTS ?? "").split(import_node_path5.default.delimiter).map((entry) => entry.trim()).filter(Boolean);
6790
+ const configuredHints = (process.env.CODEX_PATH_HINTS ?? "").split(import_node_path6.default.delimiter).map((entry) => entry.trim()).filter(Boolean);
6716
6791
  return [
6717
6792
  "/opt/homebrew/bin",
6718
6793
  "/usr/local/bin",
@@ -6724,9 +6799,9 @@ function fileExists(candidate) {
6724
6799
  if (!candidate) {
6725
6800
  return null;
6726
6801
  }
6727
- const normalized = import_node_path5.default.resolve(candidate);
6802
+ const normalized = import_node_path6.default.resolve(candidate);
6728
6803
  try {
6729
- const stats = (0, import_node_fs4.statSync)(normalized);
6804
+ const stats = (0, import_node_fs5.statSync)(normalized);
6730
6805
  if (stats.isFile()) {
6731
6806
  return normalized;
6732
6807
  }
@@ -6753,17 +6828,14 @@ function resolveCodexFromPath() {
6753
6828
  new Set(
6754
6829
  [
6755
6830
  ...getPathHintEntries(),
6756
- ...pathValue.split(import_node_path5.default.delimiter).map((entry) => entry.trim()).filter(Boolean)
6831
+ ...pathValue.split(import_node_path6.default.delimiter).map((entry) => entry.trim()).filter(Boolean)
6757
6832
  ].filter(Boolean)
6758
6833
  )
6759
6834
  );
6760
- for (const entry of entries3) {
6761
- const candidate = fileExists(import_node_path5.default.join(entry, "codex"));
6762
- if (candidate) {
6763
- return candidate;
6764
- }
6765
- }
6766
- return null;
6835
+ return resolveCommandOnPath("codex", {
6836
+ ...process.env,
6837
+ PATH: entries3.join(import_node_path6.default.delimiter)
6838
+ });
6767
6839
  }
6768
6840
  function buildUnavailableStatus(reason) {
6769
6841
  return {
@@ -6873,7 +6945,8 @@ async function requireCodexCli() {
6873
6945
 
6874
6946
  // ../../packages/runtime-codex/src/codex/command.ts
6875
6947
  var import_node_child_process3 = require("child_process");
6876
- var import_node_path6 = __toESM(require("path"), 1);
6948
+ var import_node_os3 = __toESM(require("os"), 1);
6949
+ var import_node_path7 = __toESM(require("path"), 1);
6877
6950
  var cachedNodeRuntime = null;
6878
6951
  function isJavaScriptEntrypoint(binaryPath) {
6879
6952
  const normalized = binaryPath.trim().toLowerCase();
@@ -6888,20 +6961,21 @@ function resolveNodeRuntime(env) {
6888
6961
  return cachedNodeRuntime;
6889
6962
  }
6890
6963
  const runtimeEnv = { ...process.env, ...env };
6891
- const homeDir = runtimeEnv.HOME ?? "";
6892
- const pathHints = (runtimeEnv.CODEX_PATH_HINTS ?? process.env.CODEX_PATH_HINTS ?? "").split(import_node_path6.default.delimiter).map((entry) => entry.trim()).filter(Boolean);
6964
+ const homeDir = runtimeEnv.HOME ?? runtimeEnv.USERPROFILE ?? import_node_os3.default.homedir();
6965
+ const pathHints = (runtimeEnv.CODEX_PATH_HINTS ?? process.env.CODEX_PATH_HINTS ?? "").split(import_node_path7.default.delimiter).map((entry) => entry.trim()).filter(Boolean);
6893
6966
  const extraPathEntries = [
6894
6967
  "/usr/local/bin",
6895
6968
  "/opt/homebrew/bin",
6896
- import_node_path6.default.join(homeDir, ".local", "bin"),
6897
- import_node_path6.default.join(homeDir, ".fnm", "aliases", "default", "bin"),
6898
- import_node_path6.default.join(homeDir, ".fnm", "current", "bin"),
6969
+ import_node_path7.default.join(homeDir, ".local", "bin"),
6970
+ import_node_path7.default.join(homeDir, ".fnm", "aliases", "default", "bin"),
6971
+ import_node_path7.default.join(homeDir, ".fnm", "current", "bin"),
6972
+ import_node_path7.default.join(homeDir, ".bun", "bin"),
6899
6973
  ...pathHints
6900
6974
  ].filter(Boolean);
6901
6975
  const currentPath = runtimeEnv.PATH ?? "";
6902
6976
  runtimeEnv.PATH = Array.from(
6903
- /* @__PURE__ */ new Set([...extraPathEntries, ...currentPath.split(import_node_path6.default.delimiter).filter(Boolean)])
6904
- ).join(import_node_path6.default.delimiter);
6977
+ /* @__PURE__ */ new Set([...extraPathEntries, ...currentPath.split(import_node_path7.default.delimiter).filter(Boolean)])
6978
+ ).join(import_node_path7.default.delimiter);
6905
6979
  const candidates = Array.from(
6906
6980
  new Set(
6907
6981
  [
@@ -6941,19 +7015,19 @@ function buildCodexCommand(binaryPath, args2, env) {
6941
7015
 
6942
7016
  // ../../packages/runtime-codex/src/codex/home.ts
6943
7017
  var import_node_crypto9 = require("crypto");
6944
- var import_node_fs5 = require("fs");
7018
+ var import_node_fs6 = require("fs");
6945
7019
  var import_promises2 = require("fs/promises");
6946
- var import_node_os2 = __toESM(require("os"), 1);
6947
- var import_node_path7 = __toESM(require("path"), 1);
7020
+ var import_node_os4 = __toESM(require("os"), 1);
7021
+ var import_node_path8 = __toESM(require("path"), 1);
6948
7022
  function resolveHomeDir() {
6949
- return process.env.HOME || import_node_os2.default.homedir();
7023
+ return process.env.HOME || import_node_os4.default.homedir();
6950
7024
  }
6951
7025
  function expandHomePrefix(input, homeDir) {
6952
7026
  if (input === "~") {
6953
7027
  return homeDir;
6954
7028
  }
6955
7029
  if (input.startsWith("~/") || input.startsWith("~\\")) {
6956
- return import_node_path7.default.join(homeDir, input.slice(2));
7030
+ return import_node_path8.default.join(homeDir, input.slice(2));
6957
7031
  }
6958
7032
  return input;
6959
7033
  }
@@ -6969,25 +7043,25 @@ function normalizeCodexHomePath(input) {
6969
7043
  if (!configured) {
6970
7044
  return null;
6971
7045
  }
6972
- return import_node_path7.default.resolve(expandHomePrefix(configured, resolveHomeDir()));
7046
+ return import_node_path8.default.resolve(expandHomePrefix(configured, resolveHomeDir()));
6973
7047
  }
6974
7048
  function resolveDefaultCodexHomeDir() {
6975
- return normalizeCodexHomePath(process.env.CODEX_HOME) ?? import_node_path7.default.join(resolveHomeDir(), ".codex");
7049
+ return normalizeCodexHomePath(process.env.CODEX_HOME) ?? import_node_path8.default.join(resolveHomeDir(), ".codex");
6976
7050
  }
6977
7051
  function resolveCodexSqliteHomeDir(codexHomePath) {
6978
7052
  return normalizeCodexHomePath(process.env.CODEX_SQLITE_HOME) ?? resolveCodexHomeDir({ codexHomePath });
6979
7053
  }
6980
7054
  function resolveCurrentProfileCodexHomeDir(profileHomeId) {
6981
- return import_node_path7.default.join(
7055
+ return import_node_path8.default.join(
6982
7056
  resolveProfileCodexHomesRoot(),
6983
7057
  (0, import_node_crypto9.createHash)("sha256").update(profileHomeId).digest("hex").slice(0, 20)
6984
7058
  );
6985
7059
  }
6986
7060
  function resolveProfileCodexHomeDir(profileHomeId) {
6987
7061
  const current = resolveCurrentProfileCodexHomeDir(profileHomeId);
6988
- const legacy = import_node_path7.default.join(resolveLegacyProfileCodexHomesRoot(), profileHomeId);
6989
- const currentExists = (0, import_node_fs5.existsSync)(current);
6990
- const legacyExists = (0, import_node_fs5.existsSync)(legacy);
7062
+ const legacy = import_node_path8.default.join(resolveLegacyProfileCodexHomesRoot(), profileHomeId);
7063
+ const currentExists = (0, import_node_fs6.existsSync)(current);
7064
+ const legacyExists = (0, import_node_fs6.existsSync)(legacy);
6991
7065
  if (currentExists && legacyExists) {
6992
7066
  return current;
6993
7067
  }
@@ -6995,15 +7069,15 @@ function resolveProfileCodexHomeDir(profileHomeId) {
6995
7069
  }
6996
7070
  function findProfileCodexHomeLocationConflict(profileHomeId) {
6997
7071
  const current = resolveCurrentProfileCodexHomeDir(profileHomeId);
6998
- const legacy = import_node_path7.default.join(resolveLegacyProfileCodexHomesRoot(), profileHomeId);
6999
- return (0, import_node_fs5.existsSync)(current) && (0, import_node_fs5.existsSync)(legacy) ? { current, legacy } : null;
7072
+ const legacy = import_node_path8.default.join(resolveLegacyProfileCodexHomesRoot(), profileHomeId);
7073
+ return (0, import_node_fs6.existsSync)(current) && (0, import_node_fs6.existsSync)(legacy) ? { current, legacy } : null;
7000
7074
  }
7001
7075
  function resolveProfileCodexHomesRoot() {
7002
- return import_node_path7.default.join(resolveHomeDir(), ".codexuse", "p");
7076
+ return import_node_path8.default.join(resolveHomeDir(), ".codexuse", "p");
7003
7077
  }
7004
7078
  async function ensureProfileCodexHomesRoot() {
7005
7079
  const root = resolveProfileCodexHomesRoot();
7006
- const parent = import_node_path7.default.dirname(root);
7080
+ const parent = import_node_path8.default.dirname(root);
7007
7081
  await (0, import_promises2.mkdir)(parent, { recursive: true, mode: 448 });
7008
7082
  await (0, import_promises2.mkdir)(root, { recursive: true, mode: 448 });
7009
7083
  if (process.platform !== "win32") {
@@ -7013,13 +7087,13 @@ async function ensureProfileCodexHomesRoot() {
7013
7087
  return root;
7014
7088
  }
7015
7089
  function resolveLegacyProfileCodexHomesRoot() {
7016
- return import_node_path7.default.join(getUserDataDir(), "profile-homes");
7090
+ return import_node_path8.default.join(getUserDataDir(), "profile-homes");
7017
7091
  }
7018
7092
  async function migrateProfileCodexHomeDir(profileHomeId) {
7019
- const legacy = import_node_path7.default.join(resolveLegacyProfileCodexHomesRoot(), profileHomeId);
7093
+ const legacy = import_node_path8.default.join(resolveLegacyProfileCodexHomesRoot(), profileHomeId);
7020
7094
  const current = resolveCurrentProfileCodexHomeDir(profileHomeId);
7021
- const currentExists = (0, import_node_fs5.existsSync)(current);
7022
- const legacyExists = (0, import_node_fs5.existsSync)(legacy);
7095
+ const currentExists = (0, import_node_fs6.existsSync)(current);
7096
+ const legacyExists = (0, import_node_fs6.existsSync)(legacy);
7023
7097
  if (currentExists && legacyExists) {
7024
7098
  return current;
7025
7099
  }
@@ -7070,6 +7144,7 @@ async function resolveCodexRuntimeContext(options) {
7070
7144
  }
7071
7145
 
7072
7146
  // ../../packages/runtime-codex/src/cli/env.ts
7147
+ var import_node_os5 = __toESM(require("os"), 1);
7073
7148
  function buildCodexChildEnv(overrides = {}) {
7074
7149
  const env = { ...process.env };
7075
7150
  for (const key of Object.keys(env)) {
@@ -7095,7 +7170,7 @@ var import_toml = __toESM(require_toml(), 1);
7095
7170
  // ../../packages/runtime-codex/src/codex/config-metadata.ts
7096
7171
  var import_node_child_process4 = require("child_process");
7097
7172
  var import_promises3 = require("fs/promises");
7098
- var import_node_path8 = __toESM(require("path"), 1);
7173
+ var import_node_path9 = __toESM(require("path"), 1);
7099
7174
  var CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/openai/codex/main/codex-rs/core/config.schema.json";
7100
7175
  var METADATA_CACHE_TTL_MS = 6e4;
7101
7176
  var FALLBACK_SCHEMA_TOP_LEVEL_KEYS = [
@@ -7281,8 +7356,8 @@ function parseSchemaKeys(schemaRaw) {
7281
7356
  async function readSchemaFromLocal() {
7282
7357
  const candidates = [
7283
7358
  process.env.CODEX_CONFIG_SCHEMA_PATH,
7284
- import_node_path8.default.join(process.cwd(), "codex-rs", "core", "config.schema.json"),
7285
- import_node_path8.default.join(process.cwd(), "node_modules", "@openai", "codex", "codex-rs", "core", "config.schema.json")
7359
+ import_node_path9.default.join(process.cwd(), "codex-rs", "core", "config.schema.json"),
7360
+ import_node_path9.default.join(process.cwd(), "node_modules", "@openai", "codex", "codex-rs", "core", "config.schema.json")
7286
7361
  ].filter((candidate) => Boolean(candidate));
7287
7362
  for (const candidate of candidates) {
7288
7363
  try {
@@ -7388,7 +7463,7 @@ async function getCodexConfigMetadata(forceRefresh = false) {
7388
7463
  // ../../packages/runtime-codex/src/codex/config-io.ts
7389
7464
  var import_node_crypto10 = require("crypto");
7390
7465
  var import_promises4 = require("fs/promises");
7391
- var import_node_path9 = __toESM(require("path"), 1);
7466
+ var import_node_path10 = __toESM(require("path"), 1);
7392
7467
 
7393
7468
  // ../../packages/runtime-codex/src/codex/config-presets.ts
7394
7469
  var DEFAULT_CONFIG_TEMPLATE = [
@@ -7431,10 +7506,10 @@ var YOLO_PRESET = {
7431
7506
 
7432
7507
  // ../../packages/runtime-codex/src/codex/config-io.ts
7433
7508
  function getConfigPath(options) {
7434
- return import_node_path9.default.join(resolveCodexHomeDir(options), "config.toml");
7509
+ return import_node_path10.default.join(resolveCodexHomeDir(options), "config.toml");
7435
7510
  }
7436
7511
  async function ensureConfigDirExists(filePath) {
7437
- const dir = import_node_path9.default.dirname(filePath);
7512
+ const dir = import_node_path10.default.dirname(filePath);
7438
7513
  await (0, import_promises4.mkdir)(dir, { recursive: true });
7439
7514
  }
7440
7515
  async function resolveConfigWriteTarget(configPath) {
@@ -7448,7 +7523,7 @@ async function resolveConfigWriteTarget(configPath) {
7448
7523
  if (error.code !== "ENOENT") {
7449
7524
  throw error;
7450
7525
  }
7451
- return import_node_path9.default.resolve(import_node_path9.default.dirname(configPath), await (0, import_promises4.readlink)(configPath));
7526
+ return import_node_path10.default.resolve(import_node_path10.default.dirname(configPath), await (0, import_promises4.readlink)(configPath));
7452
7527
  }
7453
7528
  } catch (error) {
7454
7529
  if (error.code === "ENOENT") {
@@ -7458,8 +7533,8 @@ async function resolveConfigWriteTarget(configPath) {
7458
7533
  }
7459
7534
  }
7460
7535
  async function removeStaleConfigStagingFiles(targetPath) {
7461
- const directory = import_node_path9.default.dirname(targetPath);
7462
- const prefix = `${import_node_path9.default.basename(targetPath)}.tmp-`;
7536
+ const directory = import_node_path10.default.dirname(targetPath);
7537
+ const prefix = `${import_node_path10.default.basename(targetPath)}.tmp-`;
7463
7538
  const entries3 = await (0, import_promises4.readdir)(directory).catch((error) => {
7464
7539
  if (error.code === "ENOENT") {
7465
7540
  return [];
@@ -7467,7 +7542,7 @@ async function removeStaleConfigStagingFiles(targetPath) {
7467
7542
  throw error;
7468
7543
  });
7469
7544
  await Promise.all(
7470
- entries3.filter((entry) => entry.startsWith(prefix)).map((entry) => (0, import_promises4.rm)(import_node_path9.default.join(directory, entry), { force: true }))
7545
+ entries3.filter((entry) => entry.startsWith(prefix)).map((entry) => (0, import_promises4.rm)(import_node_path10.default.join(directory, entry), { force: true }))
7471
7546
  );
7472
7547
  }
7473
7548
  async function resolveConfigWriteMode(targetPath) {
@@ -7528,7 +7603,7 @@ async function writeConfigContent(content, options) {
7528
7603
  await (0, import_promises4.rename)(stagingPath, targetPath);
7529
7604
  if (process.platform !== "win32") {
7530
7605
  await (0, import_promises4.chmod)(targetPath, mode);
7531
- const directory = await (0, import_promises4.open)(import_node_path9.default.dirname(targetPath), "r");
7606
+ const directory = await (0, import_promises4.open)(import_node_path10.default.dirname(targetPath), "r");
7532
7607
  try {
7533
7608
  await directory.sync();
7534
7609
  } finally {
@@ -7551,7 +7626,7 @@ async function removeConfigContent(options) {
7551
7626
  }
7552
7627
  throw error;
7553
7628
  }
7554
- const directory = await (0, import_promises4.open)(import_node_path9.default.dirname(configPath), "r");
7629
+ const directory = await (0, import_promises4.open)(import_node_path10.default.dirname(configPath), "r");
7555
7630
  try {
7556
7631
  await directory.sync();
7557
7632
  } finally {
@@ -8585,8 +8660,8 @@ var CIRCULAR = "[Circular]";
8585
8660
  function formatPropertyKey(name) {
8586
8661
  return typeof name === "string" ? JSON.stringify(name) : String(name);
8587
8662
  }
8588
- function formatPath(path22) {
8589
- return path22.map((key) => `[${formatPropertyKey(key)}]`).join("");
8663
+ function formatPath(path23) {
8664
+ return path23.map((key) => `[${formatPropertyKey(key)}]`).join("");
8590
8665
  }
8591
8666
  function formatDate(date) {
8592
8667
  try {
@@ -12107,9 +12182,9 @@ var Pointer = class extends IssueNodeImpl {
12107
12182
  * The issue that occurred.
12108
12183
  */
12109
12184
  issue;
12110
- constructor(path22, issue) {
12185
+ constructor(path23, issue) {
12111
12186
  super();
12112
- this.path = path22;
12187
+ this.path = path23;
12113
12188
  this.issue = issue;
12114
12189
  }
12115
12190
  };
@@ -12294,43 +12369,43 @@ function getExpectedMessage(expected, issue) {
12294
12369
  const input = formatInput(issue);
12295
12370
  return input === void 0 ? `Expected ${expected}` : `Expected ${expected}, got ${input}`;
12296
12371
  }
12297
- function toDefaultIssues(issue, path22, leafHook, checkHook) {
12372
+ function toDefaultIssues(issue, path23, leafHook, checkHook) {
12298
12373
  switch (issue._tag) {
12299
12374
  case "Filter": {
12300
12375
  const message = checkHook(issue);
12301
12376
  if (message !== void 0) {
12302
12377
  return [{
12303
- path: path22,
12378
+ path: path23,
12304
12379
  message
12305
12380
  }];
12306
12381
  }
12307
12382
  if (issue.issue._tag !== "InvalidValue") {
12308
- return toDefaultIssues(issue.issue, path22, leafHook, checkHook);
12383
+ return toDefaultIssues(issue.issue, path23, leafHook, checkHook);
12309
12384
  }
12310
12385
  const expected = findExpected(issue.issue);
12311
12386
  return [{
12312
- path: path22,
12387
+ path: path23,
12313
12388
  message: expected === void 0 ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue)
12314
12389
  }];
12315
12390
  }
12316
12391
  case "Encoding":
12317
- return toDefaultIssues(issue.issue, path22, leafHook, checkHook);
12392
+ return toDefaultIssues(issue.issue, path23, leafHook, checkHook);
12318
12393
  case "Pointer":
12319
- return toDefaultIssues(issue.issue, [...path22, ...issue.path], leafHook, checkHook);
12394
+ return toDefaultIssues(issue.issue, [...path23, ...issue.path], leafHook, checkHook);
12320
12395
  case "Composite":
12321
- return issue.issues.flatMap((issue2) => toDefaultIssues(issue2, path22, leafHook, checkHook));
12396
+ return issue.issues.flatMap((issue2) => toDefaultIssues(issue2, path23, leafHook, checkHook));
12322
12397
  case "AnyOf": {
12323
12398
  if (issue.issues.length === 0) {
12324
12399
  return [{
12325
- path: path22,
12400
+ path: path23,
12326
12401
  message: findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue)
12327
12402
  }];
12328
12403
  }
12329
- return issue.issues.flatMap((issue2) => toDefaultIssues(issue2, path22, leafHook, checkHook));
12404
+ return issue.issues.flatMap((issue2) => toDefaultIssues(issue2, path23, leafHook, checkHook));
12330
12405
  }
12331
12406
  default:
12332
12407
  return [{
12333
- path: path22,
12408
+ path: path23,
12334
12409
  message: leafHook(issue)
12335
12410
  }];
12336
12411
  }
@@ -12349,7 +12424,7 @@ function makeFormatterDefault() {
12349
12424
  return (issue) => formatIssue(issue, "");
12350
12425
  }
12351
12426
  var defaultFormatter = /* @__PURE__ */ makeFormatterDefault();
12352
- function formatIssue(issue, path22) {
12427
+ function formatIssue(issue, path23) {
12353
12428
  let message;
12354
12429
  switch (issue._tag) {
12355
12430
  case "Filter": {
@@ -12358,7 +12433,7 @@ function formatIssue(issue, path22) {
12358
12433
  message = annotated;
12359
12434
  } else {
12360
12435
  if (issue.issue._tag !== "InvalidValue") {
12361
- return formatIssue(issue.issue, path22);
12436
+ return formatIssue(issue.issue, path23);
12362
12437
  }
12363
12438
  const expected = findExpected(issue.issue);
12364
12439
  message = expected === void 0 ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue);
@@ -12366,13 +12441,13 @@ function formatIssue(issue, path22) {
12366
12441
  break;
12367
12442
  }
12368
12443
  case "Encoding":
12369
- return formatIssue(issue.issue, path22);
12444
+ return formatIssue(issue.issue, path23);
12370
12445
  case "Pointer":
12371
- return formatIssue(issue.issue, path22 + formatPath(issue.path));
12446
+ return formatIssue(issue.issue, path23 + formatPath(issue.path));
12372
12447
  case "Composite":
12373
12448
  case "AnyOf": {
12374
12449
  if (issue._tag === "Composite" || issue.issues.length > 0) {
12375
- return issue.issues.map((issue2) => formatIssue(issue2, path22)).join("\n");
12450
+ return issue.issues.map((issue2) => formatIssue(issue2, path23)).join("\n");
12376
12451
  }
12377
12452
  message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue);
12378
12453
  break;
@@ -12381,8 +12456,8 @@ function formatIssue(issue, path22) {
12381
12456
  message = defaultLeafHook(issue);
12382
12457
  break;
12383
12458
  }
12384
- return path22 ? `${message}
12385
- at ${path22}` : message;
12459
+ return path23 ? `${message}
12460
+ at ${path23}` : message;
12386
12461
  }
12387
12462
  function findMessage(issue) {
12388
12463
  if (issue._tag === "Pointer") return;
@@ -13255,13 +13330,13 @@ var Enum = class extends ASTNodeImpl {
13255
13330
  return this.enums.map(([_, value3]) => JSON.stringify(value3)).join(" | ");
13256
13331
  }
13257
13332
  };
13258
- function formatTemplateLiteralPath(path22) {
13259
- return typeof path22 === "number" ? `parts[${path22}]` : path22;
13333
+ function formatTemplateLiteralPath(path23) {
13334
+ return typeof path23 === "number" ? `parts[${path23}]` : path23;
13260
13335
  }
13261
- function isTemplateLiteralPart(ast, path22, validated) {
13336
+ function isTemplateLiteralPart(ast, path23, validated) {
13262
13337
  if (validated.has(ast)) return true;
13263
13338
  if (ast.encoding) {
13264
- throw new Error(`TemplateLiteral parts cannot have an encoding at ${formatTemplateLiteralPath(path22)}`);
13339
+ throw new Error(`TemplateLiteral parts cannot have an encoding at ${formatTemplateLiteralPath(path23)}`);
13265
13340
  }
13266
13341
  let valid;
13267
13342
  switch (ast._tag) {
@@ -13274,12 +13349,12 @@ function isTemplateLiteralPart(ast, path22, validated) {
13274
13349
  valid = !ast.checks;
13275
13350
  break;
13276
13351
  case "TemplateLiteral": {
13277
- const currentPath = formatTemplateLiteralPath(path22);
13352
+ const currentPath = formatTemplateLiteralPath(path23);
13278
13353
  valid = !ast.checks && ast.parts.every((part, index2) => isTemplateLiteralPart(part, `${currentPath}.parts[${index2}]`, validated));
13279
13354
  break;
13280
13355
  }
13281
13356
  case "Union": {
13282
- const currentPath = formatTemplateLiteralPath(path22);
13357
+ const currentPath = formatTemplateLiteralPath(path23);
13283
13358
  valid = !ast.checks && ast.types.every((part, index2) => isTemplateLiteralPart(part, `${currentPath}.types[${index2}]`, validated));
13284
13359
  break;
13285
13360
  }
@@ -16817,8 +16892,8 @@ function parseUriFragment(fragment) {
16817
16892
  const pointer = decodeUriFragment(fragment);
16818
16893
  return pointer === void 0 ? void 0 : pointer.length === 0 ? [] : pointer.slice(1).split("/").map(unescapeToken);
16819
16894
  }
16820
- function formatUriFragment(path22) {
16821
- return path22.reduce((fragment, token) => `${fragment}/${formatUriFragmentToken(token)}`, "#");
16895
+ function formatUriFragment(path23) {
16896
+ return path23.reduce((fragment, token) => `${fragment}/${formatUriFragmentToken(token)}`, "#");
16822
16897
  }
16823
16898
 
16824
16899
  // ../../node_modules/.bun/effect@4.0.0-rc.115/node_modules/effect/dist/JsonSchema.js
@@ -17405,10 +17480,10 @@ var RegExp2 = globalThis.RegExp;
17405
17480
  var escape = (string3) => string3.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
17406
17481
 
17407
17482
  // ../../node_modules/.bun/effect@4.0.0-rc.115/node_modules/effect/dist/internal/errors.js
17408
- function errorWithPath(message, path22) {
17409
- if (path22.length > 0) {
17483
+ function errorWithPath(message, path23) {
17484
+ if (path23.length > 0) {
17410
17485
  message += `
17411
- at ${formatPath(path22)}`;
17486
+ at ${formatPath(path23)}`;
17412
17487
  }
17413
17488
  return new Error(message);
17414
17489
  }
@@ -17570,11 +17645,11 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17570
17645
  schemas,
17571
17646
  definitions
17572
17647
  };
17573
- function compileDefinition(key, path22) {
17648
+ function compileDefinition(key, path23) {
17574
17649
  const compiled = definitionStates.get(key);
17575
17650
  if (compiled !== void 0) return typeof compiled === "string" ? compiled : key;
17576
17651
  if (!Object.hasOwn(references, key)) {
17577
- throw errorWithPath(`Invalid reference ${key}`, [...path22, "$ref"]);
17652
+ throw errorWithPath(`Invalid reference ${key}`, [...path23, "$ref"]);
17578
17653
  }
17579
17654
  definitionStates.set(key, null);
17580
17655
  const representation = references[key];
@@ -17615,14 +17690,14 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17615
17690
  const annotations = representation.checks.length === 0 ? representation.annotations : representation.checks[representation.checks.length - 1].annotations;
17616
17691
  return typeof annotations?.identifier !== "string" && typeof annotations?.[IDENTIFIER_FALLBACK_KEY] === "string" ? annotations[IDENTIFIER_FALLBACK_KEY] : void 0;
17617
17692
  }
17618
- function annotationSchemas(representation, path22) {
17619
- return representation?.schemas?.map((schema, index2) => recur2(schema, [...path22, "schemas", index2])) ?? [];
17693
+ function annotationSchemas(representation, path23) {
17694
+ return representation?.schemas?.map((schema, index2) => recur2(schema, [...path23, "schemas", index2])) ?? [];
17620
17695
  }
17621
- function compileCheck(check2, type, path22) {
17696
+ function compileCheck(check2, type, path23) {
17622
17697
  const annotations = check2.annotations;
17623
17698
  const callback2 = annotations?.toJsonSchema;
17624
17699
  if (callback2 !== void 0) {
17625
- const schemas2 = annotationSchemas(check2.representation, [...path22, "representation"]);
17700
+ const schemas2 = annotationSchemas(check2.representation, [...path23, "representation"]);
17626
17701
  const fragment = callback2({
17627
17702
  type,
17628
17703
  schemas: schemas2
@@ -17636,7 +17711,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17636
17711
  return check2._tag === "Filter" && hasOnlyKeywords(schema, allowed) && (ordinary2 === void 0 || hasOnlyKeywords(ordinary2, promotableAnnotationKeywords)) ? [schema, true] : [schema];
17637
17712
  }
17638
17713
  if (check2._tag === "Filter") return void 0;
17639
- const children = check2.checks.map((child, index2) => compileCheck(child, type, [...path22, "checks", index2])).filter((child) => child !== void 0);
17714
+ const children = check2.checks.map((child, index2) => compileCheck(child, type, [...path23, "checks", index2])).filter((child) => child !== void 0);
17640
17715
  if (children.length === 0) return void 0;
17641
17716
  const ordinary = collectJsonSchemaAnnotations(annotations, options);
17642
17717
  const allOf = children.map(([schema]) => schema);
@@ -17647,16 +17722,16 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17647
17722
  ...ordinary
17648
17723
  }];
17649
17724
  }
17650
- function recur2(representation, path22) {
17725
+ function recur2(representation, path23) {
17651
17726
  if (representation._tag === "Reference") {
17652
- const canonical = compileDefinition(representation.$ref, path22);
17727
+ const canonical = compileDefinition(representation.$ref, path23);
17653
17728
  return {
17654
17729
  $ref: formatDefinitionReference(canonical)
17655
17730
  };
17656
17731
  }
17657
17732
  const cached2 = compiledRepresentations.get(representation);
17658
17733
  if (cached2 !== void 0) return cached2;
17659
- let output = on(representation, path22);
17734
+ let output = on(representation, path23);
17660
17735
  const ordinary = collectJsonSchemaAnnotations(representation.annotations, options);
17661
17736
  if (ordinary !== void 0) {
17662
17737
  output = {
@@ -17666,7 +17741,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17666
17741
  }
17667
17742
  for (let index2 = 0; index2 < representation.checks.length; index2++) {
17668
17743
  const type = typeof output.type === "string" && isJsonSchemaType(output.type) ? output.type : void 0;
17669
- const check2 = compileCheck(representation.checks[index2], type, [...path22, "checks", index2]);
17744
+ const check2 = compileCheck(representation.checks[index2], type, [...path23, "checks", index2]);
17670
17745
  if (check2 !== void 0) {
17671
17746
  output = appendJsonSchema(output, ...check2);
17672
17747
  }
@@ -17674,7 +17749,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17674
17749
  compiledRepresentations.set(representation, output);
17675
17750
  return output;
17676
17751
  }
17677
- function on(representation, path22) {
17752
+ function on(representation, path23) {
17678
17753
  switch (representation._tag) {
17679
17754
  case "Any":
17680
17755
  case "Unknown":
@@ -17718,7 +17793,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17718
17793
  return {};
17719
17794
  }
17720
17795
  case "Suspend":
17721
- return recur2(representation.thunk, [...path22, "thunk"]);
17796
+ return recur2(representation.thunk, [...path23, "thunk"]);
17722
17797
  case "Never":
17723
17798
  return {
17724
17799
  not: {}
@@ -17753,7 +17828,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17753
17828
  case "Enum": {
17754
17829
  const types = representation.enums.map(([title, literal], index2) => {
17755
17830
  if (typeof literal === "number" && !globalThis.Number.isFinite(literal)) {
17756
- throw errorWithPath(`Invalid numeric enum value ${globalThis.String(literal)}`, [...path22, "enums", index2, 1]);
17831
+ throw errorWithPath(`Invalid numeric enum value ${globalThis.String(literal)}`, [...path23, "enums", index2, 1]);
17757
17832
  }
17758
17833
  return {
17759
17834
  type: typeof literal,
@@ -17774,7 +17849,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17774
17849
  };
17775
17850
  case "Arrays": {
17776
17851
  if (representation.rest.length > 1) {
17777
- throw errorWithPath("Invalid schema representation document", [...path22, "rest"]);
17852
+ throw errorWithPath("Invalid schema representation document", [...path23, "rest"]);
17778
17853
  }
17779
17854
  const out = {
17780
17855
  type: "array"
@@ -17782,7 +17857,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17782
17857
  let minItems = representation.elements.length;
17783
17858
  const prefixItems = representation.elements.map((element, index2) => {
17784
17859
  if (element.isOptional) minItems--;
17785
- const compiled = recur2(element.type, [...path22, "elements", index2, "type"]);
17860
+ const compiled = recur2(element.type, [...path23, "elements", index2, "type"]);
17786
17861
  const annotations = collectJsonSchemaAnnotations(element.annotations, options);
17787
17862
  return annotations === void 0 ? compiled : appendJsonSchema(compiled, annotations);
17788
17863
  });
@@ -17795,7 +17870,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17795
17870
  }
17796
17871
  if (representation.rest.length === 1) {
17797
17872
  delete out.maxItems;
17798
- const rest = recur2(representation.rest[0], [...path22, "rest", 0]);
17873
+ const rest = recur2(representation.rest[0], [...path23, "rest", 0]);
17799
17874
  if (Object.keys(rest).length > 0) out.items = rest;
17800
17875
  else delete out.items;
17801
17876
  }
@@ -17817,10 +17892,10 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17817
17892
  for (let index2 = 0; index2 < representation.propertySignatures.length; index2++) {
17818
17893
  const property = representation.propertySignatures[index2];
17819
17894
  if (typeof property.name !== "string") {
17820
- throw errorWithPath("Invalid schema representation document", [...path22, "propertySignatures", index2, "name"]);
17895
+ throw errorWithPath("Invalid schema representation document", [...path23, "propertySignatures", index2, "name"]);
17821
17896
  }
17822
17897
  const name = property.name;
17823
- const compiled = recur2(property.type, [...path22, "propertySignatures", index2, "type"]);
17898
+ const compiled = recur2(property.type, [...path23, "propertySignatures", index2, "type"]);
17824
17899
  const annotations = collectJsonSchemaAnnotations(property.annotations, options);
17825
17900
  assignProperty(properties, name, annotations === void 0 ? compiled : appendJsonSchema(compiled, annotations));
17826
17901
  if (!property.isOptional) required2.push(name);
@@ -17833,12 +17908,12 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17833
17908
  let hasUnrepresentableIndexPattern = false;
17834
17909
  for (let index2 = 0; index2 < representation.indexSignatures.length; index2++) {
17835
17910
  const signature = representation.indexSignatures[index2];
17836
- let type = recur2(signature.type, [...path22, "indexSignatures", index2, "type"]);
17911
+ let type = recur2(signature.type, [...path23, "indexSignatures", index2, "type"]);
17837
17912
  if (equals(type, {
17838
17913
  not: {}
17839
17914
  })) type = false;
17840
17915
  indexValueSchemas.push(type);
17841
- const patterns = getParameterPatterns(signature.parameter, [...path22, "indexSignatures", index2, "parameter"], /* @__PURE__ */ new Set());
17916
+ const patterns = getParameterPatterns(signature.parameter, [...path23, "indexSignatures", index2, "parameter"], /* @__PURE__ */ new Set());
17842
17917
  if (patterns === void 0) {
17843
17918
  hasUnrepresentableIndexPattern = true;
17844
17919
  continue;
@@ -17864,7 +17939,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17864
17939
  });
17865
17940
  }
17866
17941
  for (let index2 = 0; index2 < representation.indexSignatures.length; index2++) {
17867
- propertyNames.push(recur2(representation.indexSignatures[index2].parameter, [...path22, "indexSignatures", index2, "parameter"]));
17942
+ propertyNames.push(recur2(representation.indexSignatures[index2].parameter, [...path23, "indexSignatures", index2, "parameter"]));
17868
17943
  }
17869
17944
  out.propertyNames = propertyNames.length === 1 ? propertyNames[0] : {
17870
17945
  anyOf: propertyNames
@@ -17894,7 +17969,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17894
17969
  return out;
17895
17970
  }
17896
17971
  case "Union": {
17897
- const types = representation.types.map((type, index2) => recur2(type, [...path22, "types", index2]));
17972
+ const types = representation.types.map((type, index2) => recur2(type, [...path23, "types", index2]));
17898
17973
  if (types.length === 0) return {
17899
17974
  not: {}
17900
17975
  };
@@ -17911,13 +17986,13 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17911
17986
  }
17912
17987
  }
17913
17988
  }
17914
- function getParameterPatterns(parameter, path22, seenReferences) {
17989
+ function getParameterPatterns(parameter, path23, seenReferences) {
17915
17990
  switch (parameter._tag) {
17916
17991
  case "Reference": {
17917
17992
  if (!Object.hasOwn(references, parameter.$ref)) {
17918
- throw errorWithPath(`Invalid reference ${parameter.$ref}`, [...path22, "$ref"]);
17993
+ throw errorWithPath(`Invalid reference ${parameter.$ref}`, [...path23, "$ref"]);
17919
17994
  }
17920
- compileDefinition(parameter.$ref, path22);
17995
+ compileDefinition(parameter.$ref, path23);
17921
17996
  if (seenReferences.has(parameter.$ref)) return void 0;
17922
17997
  const next = new Set(seenReferences).add(parameter.$ref);
17923
17998
  return getParameterPatterns(references[parameter.$ref], ["references", parameter.$ref], next);
@@ -17927,7 +18002,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17927
18002
  if (parameter.checks.length !== 1 || parameter.checks[0]._tag !== "Filter" || parameter.checks[0].annotations?.toJsonSchema === void 0) {
17928
18003
  return void 0;
17929
18004
  }
17930
- const schema = recur2(parameter, path22);
18005
+ const schema = recur2(parameter, path23);
17931
18006
  return schema.type === "string" && typeof schema.pattern === "string" && hasOnlyKeywords(schema, "|type|pattern|title|description|default|examples|readOnly|writeOnly|") ? [schema.pattern] : void 0;
17932
18007
  }
17933
18008
  case "TemplateLiteral":
@@ -17938,7 +18013,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17938
18013
  }
17939
18014
  const patterns = [];
17940
18015
  for (let index2 = 0; index2 < parameter.types.length; index2++) {
17941
- const memberPatterns = getParameterPatterns(parameter.types[index2], [...path22, "types", index2], seenReferences);
18016
+ const memberPatterns = getParameterPatterns(parameter.types[index2], [...path23, "types", index2], seenReferences);
17942
18017
  if (memberPatterns === void 0) return void 0;
17943
18018
  if (memberPatterns.length === 0) return [];
17944
18019
  patterns.push(...memberPatterns);
@@ -17946,7 +18021,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17946
18021
  return patterns;
17947
18022
  }
17948
18023
  default:
17949
- throw errorWithPath("Invalid schema representation document", path22);
18024
+ throw errorWithPath("Invalid schema representation document", path23);
17950
18025
  }
17951
18026
  }
17952
18027
  }
@@ -18421,25 +18496,25 @@ function get3(oldValue, newValue) {
18421
18496
  getLoop(oldValue, newValue, "", patches);
18422
18497
  return patches;
18423
18498
  }
18424
- function getLoop(oldValue, newValue, path22, patches) {
18499
+ function getLoop(oldValue, newValue, path23, patches) {
18425
18500
  if (Object.is(oldValue, newValue)) return;
18426
18501
  if (Array.isArray(oldValue) && Array.isArray(newValue)) {
18427
18502
  const len1 = oldValue.length;
18428
18503
  const len2 = newValue.length;
18429
18504
  const shared = Math.min(len1, len2);
18430
18505
  for (let i = 0; i < shared; i++) {
18431
- getLoop(oldValue[i], newValue[i], `${path22}/${i}`, patches);
18506
+ getLoop(oldValue[i], newValue[i], `${path23}/${i}`, patches);
18432
18507
  }
18433
18508
  for (let i = len1 - 1; i >= len2; i--) {
18434
18509
  patches.push({
18435
18510
  op: "remove",
18436
- path: `${path22}/${i}`
18511
+ path: `${path23}/${i}`
18437
18512
  });
18438
18513
  }
18439
18514
  for (let i = len1; i < len2; i++) {
18440
18515
  patches.push({
18441
18516
  op: "add",
18442
- path: `${path22}/${i}`,
18517
+ path: `${path23}/${i}`,
18443
18518
  value: newValue[i]
18444
18519
  });
18445
18520
  }
@@ -18450,7 +18525,7 @@ function getLoop(oldValue, newValue, path22, patches) {
18450
18525
  const keys22 = Object.keys(newValue);
18451
18526
  const allKeys = Array.from(/* @__PURE__ */ new Set([...keys1, ...keys22])).sort();
18452
18527
  for (const key of allKeys) {
18453
- const keyPath = `${path22}/${escapeToken(key)}`;
18528
+ const keyPath = `${path23}/${escapeToken(key)}`;
18454
18529
  const hasKey1 = Object.hasOwn(oldValue, key);
18455
18530
  const hasKey2 = Object.hasOwn(newValue, key);
18456
18531
  if (hasKey1 && hasKey2) {
@@ -18472,7 +18547,7 @@ function getLoop(oldValue, newValue, path22, patches) {
18472
18547
  }
18473
18548
  patches.push({
18474
18549
  op: "replace",
18475
- path: path22,
18550
+ path: path23,
18476
18551
  value: newValue
18477
18552
  });
18478
18553
  }
@@ -18716,16 +18791,16 @@ var xml = {
18716
18791
  var toEquivalence = /* @__PURE__ */ memoize((ast) => {
18717
18792
  return recur(ast, []);
18718
18793
  });
18719
- function recur(ast, path22) {
18794
+ function recur(ast, path23) {
18720
18795
  const annotation = resolve(ast)?.["toEquivalence"];
18721
18796
  if (annotation) {
18722
- return annotation(isDeclaration(ast) ? ast.typeParameters.map((tp) => recur(tp, path22)) : []);
18797
+ return annotation(isDeclaration(ast) ? ast.typeParameters.map((tp) => recur(tp, path23)) : []);
18723
18798
  }
18724
18799
  switch (ast._tag) {
18725
18800
  case "Never":
18726
18801
  return strictEqual();
18727
18802
  case "Declaration":
18728
- return declarationEquivalence(ast, path22);
18803
+ return declarationEquivalence(ast, path23);
18729
18804
  case "Null":
18730
18805
  case "Undefined":
18731
18806
  case "Void":
@@ -18743,9 +18818,9 @@ function recur(ast, path22) {
18743
18818
  case "TemplateLiteral":
18744
18819
  return equals;
18745
18820
  case "Arrays": {
18746
- const elements = ast.elements.map((e, i) => recur(e, [...path22, i]));
18821
+ const elements = ast.elements.map((e, i) => recur(e, [...path23, i]));
18747
18822
  const len = ast.elements.length;
18748
- const rest = ast.rest.map((r, i) => recur(r, [...path22, len + i]));
18823
+ const rest = ast.rest.map((r, i) => recur(r, [...path23, len + i]));
18749
18824
  return make2((a, b) => {
18750
18825
  if (!Array.isArray(a) || !Array.isArray(b)) {
18751
18826
  return false;
@@ -18780,8 +18855,8 @@ function recur(ast, path22) {
18780
18855
  if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) {
18781
18856
  return equals;
18782
18857
  }
18783
- const propertySignatures = ast.propertySignatures.map((ps) => recur(ps.type, [...path22, ps.name]));
18784
- const indexSignatures = ast.indexSignatures.map((is3) => recur(is3.type, path22));
18858
+ const propertySignatures = ast.propertySignatures.map((ps) => recur(ps.type, [...path23, ps.name]));
18859
+ const indexSignatures = ast.indexSignatures.map((is3) => recur(is3.type, path23));
18785
18860
  return make2((a, b) => {
18786
18861
  if (!isObject(a) || !isObject(b)) {
18787
18862
  return false;
@@ -18817,7 +18892,7 @@ function recur(ast, path22) {
18817
18892
  }
18818
18893
  case "Union": {
18819
18894
  const types = toType(ast).types;
18820
- const compiled = new Map(types.map((candidate, i) => [candidate, [_is(candidate), recur(ast.types[i], path22)]]));
18895
+ const compiled = new Map(types.map((candidate, i) => [candidate, [_is(candidate), recur(ast.types[i], path23)]]));
18821
18896
  return make2((a, b) => {
18822
18897
  const candidates = getCandidates(a, types);
18823
18898
  for (let i = 0; i < candidates.length; i++) {
@@ -18831,41 +18906,41 @@ function recur(ast, path22) {
18831
18906
  }
18832
18907
  case "Suspend": {
18833
18908
  let equivalence;
18834
- return make2((a, b) => (equivalence ??= recur(ast.thunk(), path22))(a, b));
18909
+ return make2((a, b) => (equivalence ??= recur(ast.thunk(), path23))(a, b));
18835
18910
  }
18836
18911
  }
18837
18912
  }
18838
- function declarationEquivalence(ast, path22) {
18913
+ function declarationEquivalence(ast, path23) {
18839
18914
  const representation = ast.annotations?.representation;
18840
18915
  if (representation === void 0) return equals;
18841
18916
  switch (representation.id) {
18842
18917
  case "effect/schema/Option": {
18843
- const [value3] = declarationTypeParameters(ast, path22);
18918
+ const [value3] = declarationTypeParameters(ast, path23);
18844
18919
  return (a, b) => a._tag === b._tag && (a._tag === "None" || value3(a.value, b.value));
18845
18920
  }
18846
18921
  case "effect/schema/Result": {
18847
- const [success, failure] = declarationTypeParameters(ast, path22);
18922
+ const [success, failure] = declarationTypeParameters(ast, path23);
18848
18923
  return (a, b) => a._tag === b._tag && (a._tag === "Success" ? success(a.success, b.success) : failure(a.failure, b.failure));
18849
18924
  }
18850
18925
  case "effect/schema/CauseReason": {
18851
- const [error, defect] = declarationTypeParameters(ast, path22);
18926
+ const [error, defect] = declarationTypeParameters(ast, path23);
18852
18927
  return causeReasonEquivalence(error, defect);
18853
18928
  }
18854
18929
  case "effect/schema/Cause": {
18855
- const [error, defect] = declarationTypeParameters(ast, path22);
18930
+ const [error, defect] = declarationTypeParameters(ast, path23);
18856
18931
  return causeEquivalence(error, defect);
18857
18932
  }
18858
18933
  case "effect/schema/Exit": {
18859
- const [value3, error, defect] = declarationTypeParameters(ast, path22);
18934
+ const [value3, error, defect] = declarationTypeParameters(ast, path23);
18860
18935
  const cause = causeEquivalence(error, defect);
18861
18936
  return (a, b) => a._tag === b._tag && (a._tag === "Success" ? value3(a.value, b.value) : cause(a.cause, b.cause));
18862
18937
  }
18863
18938
  case "effect/schema/ReadonlyMap": {
18864
- const [key, value3] = declarationTypeParameters(ast, path22);
18939
+ const [key, value3] = declarationTypeParameters(ast, path23);
18865
18940
  return makeCompareMap(key, value3);
18866
18941
  }
18867
18942
  case "effect/schema/ReadonlySet":
18868
- return makeCompareSet(declarationTypeParameters(ast, path22)[0]);
18943
+ return makeCompareSet(declarationTypeParameters(ast, path23)[0]);
18869
18944
  case "effect/schema/RegExp":
18870
18945
  return (a, b) => a.source === b.source && a.flags === b.flags;
18871
18946
  case "effect/schema/URL":
@@ -18874,8 +18949,8 @@ function declarationEquivalence(ast, path22) {
18874
18949
  return equals;
18875
18950
  }
18876
18951
  }
18877
- function declarationTypeParameters(ast, path22) {
18878
- return ast.typeParameters.map((parameter) => recur(parameter, path22));
18952
+ function declarationTypeParameters(ast, path23) {
18953
+ return ast.typeParameters.map((parameter) => recur(parameter, path23));
18879
18954
  }
18880
18955
  function causeReasonEquivalence(error, defect) {
18881
18956
  return (a, b) => {
@@ -19232,12 +19307,12 @@ var PathNode = class {
19232
19307
  path;
19233
19308
  get;
19234
19309
  set;
19235
- constructor(path22) {
19236
- this.path = path22;
19310
+ constructor(path23) {
19311
+ this.path = path23;
19237
19312
  this.get = (s) => {
19238
19313
  let out = s;
19239
- for (let i = 0; i < path22.length; i++) {
19240
- out = out[path22[i]];
19314
+ for (let i = 0; i < path23.length; i++) {
19315
+ out = out[path23[i]];
19241
19316
  }
19242
19317
  return out;
19243
19318
  };
@@ -19245,12 +19320,12 @@ var PathNode = class {
19245
19320
  const out = cloneShallow(s);
19246
19321
  let current = out;
19247
19322
  let i = 0;
19248
- for (; i < path22.length - 1; i++) {
19249
- const key = path22[i];
19323
+ for (; i < path23.length - 1; i++) {
19324
+ const key = path23[i];
19250
19325
  assignProperty(current, key, cloneShallow(current[key]));
19251
19326
  current = current[key];
19252
19327
  }
19253
- assignProperty(current, path22[i], a);
19328
+ assignProperty(current, path23[i], a);
19254
19329
  return out;
19255
19330
  };
19256
19331
  }
@@ -20472,9 +20547,9 @@ var UnixPathProto = {
20472
20547
  return this.toJSON();
20473
20548
  }
20474
20549
  };
20475
- var unixPathAddress = (path22) => {
20550
+ var unixPathAddress = (path23) => {
20476
20551
  const self = Object.create(UnixPathProto);
20477
- self.path = path22;
20552
+ self.path = path23;
20478
20553
  return Object.freeze(self);
20479
20554
  };
20480
20555
 
@@ -25545,7 +25620,7 @@ function fingerprintAuth(content) {
25545
25620
  }
25546
25621
  async function readOptionalFile(filePath) {
25547
25622
  try {
25548
- return await import_node_fs6.promises.readFile(filePath, "utf8");
25623
+ return await import_node_fs7.promises.readFile(filePath, "utf8");
25549
25624
  } catch (error) {
25550
25625
  const code = error && typeof error === "object" && "code" in error ? error.code : null;
25551
25626
  if (code === "ENOENT") return null;
@@ -25553,12 +25628,12 @@ async function readOptionalFile(filePath) {
25553
25628
  }
25554
25629
  }
25555
25630
  async function writeAtomicPath(filePath, content) {
25556
- const dir = import_node_path10.default.dirname(filePath);
25557
- const tempPath = import_node_path10.default.join(
25631
+ const dir = import_node_path11.default.dirname(filePath);
25632
+ const tempPath = import_node_path11.default.join(
25558
25633
  dir,
25559
- `.${import_node_path10.default.basename(filePath)}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.tmp`
25634
+ `.${import_node_path11.default.basename(filePath)}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.tmp`
25560
25635
  );
25561
- const handle = await import_node_fs6.promises.open(tempPath, "wx", 384);
25636
+ const handle = await import_node_fs7.promises.open(tempPath, "wx", 384);
25562
25637
  try {
25563
25638
  await handle.writeFile(content, "utf8");
25564
25639
  await handle.sync();
@@ -25566,9 +25641,9 @@ async function writeAtomicPath(filePath, content) {
25566
25641
  await handle.close();
25567
25642
  }
25568
25643
  try {
25569
- await import_node_fs6.promises.rename(tempPath, filePath);
25644
+ await import_node_fs7.promises.rename(tempPath, filePath);
25570
25645
  if (process.platform !== "win32") {
25571
- const dirHandle = await import_node_fs6.promises.open(dir, "r");
25646
+ const dirHandle = await import_node_fs7.promises.open(dir, "r");
25572
25647
  try {
25573
25648
  await dirHandle.sync();
25574
25649
  } finally {
@@ -25576,16 +25651,16 @@ async function writeAtomicPath(filePath, content) {
25576
25651
  }
25577
25652
  }
25578
25653
  } finally {
25579
- await import_node_fs6.promises.rm(tempPath, { force: true }).catch(() => void 0);
25654
+ await import_node_fs7.promises.rm(tempPath, { force: true }).catch(() => void 0);
25580
25655
  }
25581
25656
  }
25582
25657
  async function installAuthFileIfAbsent(filePath, content) {
25583
- const dir = import_node_path10.default.dirname(filePath);
25584
- const tempPath = import_node_path10.default.join(
25658
+ const dir = import_node_path11.default.dirname(filePath);
25659
+ const tempPath = import_node_path11.default.join(
25585
25660
  dir,
25586
- `.${import_node_path10.default.basename(filePath)}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.install`
25661
+ `.${import_node_path11.default.basename(filePath)}.${process.pid}.${(0, import_node_crypto11.randomUUID)()}.install`
25587
25662
  );
25588
- const handle = await import_node_fs6.promises.open(tempPath, "wx", 384);
25663
+ const handle = await import_node_fs7.promises.open(tempPath, "wx", 384);
25589
25664
  try {
25590
25665
  await handle.writeFile(content, "utf8");
25591
25666
  await handle.sync();
@@ -25593,25 +25668,25 @@ async function installAuthFileIfAbsent(filePath, content) {
25593
25668
  await handle.close();
25594
25669
  }
25595
25670
  try {
25596
- await import_node_fs6.promises.link(tempPath, filePath);
25671
+ await import_node_fs7.promises.link(tempPath, filePath);
25597
25672
  } finally {
25598
- await import_node_fs6.promises.rm(tempPath, { force: true }).catch(() => void 0);
25673
+ await import_node_fs7.promises.rm(tempPath, { force: true }).catch(() => void 0);
25599
25674
  }
25600
25675
  }
25601
25676
  async function linkAuthFileIfAbsent(sourcePath, targetPath) {
25602
- await import_node_fs6.promises.link(sourcePath, targetPath);
25677
+ await import_node_fs7.promises.link(sourcePath, targetPath);
25603
25678
  }
25604
25679
  async function hasExternalOpenFileHandle(filePath) {
25605
25680
  if (process.platform === "linux") {
25606
25681
  let target;
25607
25682
  try {
25608
- target = await import_node_fs6.promises.stat(filePath);
25683
+ target = await import_node_fs7.promises.stat(filePath);
25609
25684
  } catch {
25610
25685
  return true;
25611
25686
  }
25612
25687
  let processes;
25613
25688
  try {
25614
- processes = await import_node_fs6.promises.readdir("/proc", { withFileTypes: true });
25689
+ processes = await import_node_fs7.promises.readdir("/proc", { withFileTypes: true });
25615
25690
  } catch {
25616
25691
  return true;
25617
25692
  }
@@ -25622,7 +25697,7 @@ async function hasExternalOpenFileHandle(filePath) {
25622
25697
  }
25623
25698
  const processPath = `/proc/${entry.name}`;
25624
25699
  try {
25625
- const processStats = await import_node_fs6.promises.stat(processPath);
25700
+ const processStats = await import_node_fs7.promises.stat(processPath);
25626
25701
  if (currentUid !== void 0 && processStats.uid !== currentUid) {
25627
25702
  continue;
25628
25703
  }
@@ -25631,7 +25706,7 @@ async function hasExternalOpenFileHandle(filePath) {
25631
25706
  }
25632
25707
  let descriptors;
25633
25708
  try {
25634
- descriptors = await import_node_fs6.promises.readdir(`${processPath}/fd`);
25709
+ descriptors = await import_node_fs7.promises.readdir(`${processPath}/fd`);
25635
25710
  } catch (error) {
25636
25711
  const code = error && typeof error === "object" && "code" in error ? error.code : null;
25637
25712
  if (code === "ENOENT" || code === "ESRCH") continue;
@@ -25639,7 +25714,7 @@ async function hasExternalOpenFileHandle(filePath) {
25639
25714
  }
25640
25715
  for (const descriptor2 of descriptors) {
25641
25716
  try {
25642
- const descriptorStats = await import_node_fs6.promises.stat(`${processPath}/fd/${descriptor2}`);
25717
+ const descriptorStats = await import_node_fs7.promises.stat(`${processPath}/fd/${descriptor2}`);
25643
25718
  if (descriptorStats.dev === target.dev && descriptorStats.ino === target.ino) {
25644
25719
  return true;
25645
25720
  }
@@ -25686,9 +25761,9 @@ async function hasExternalOpenFileHandle(filePath) {
25686
25761
  async function cleanupAuthWriteback(filePath) {
25687
25762
  const paths = authWritebackPaths(filePath);
25688
25763
  await Promise.all([
25689
- import_node_fs6.promises.rm(paths.manifest, { force: true }),
25690
- import_node_fs6.promises.rm(paths.backup, { force: true }),
25691
- import_node_fs6.promises.rm(paths.replaced, { force: true })
25764
+ import_node_fs7.promises.rm(paths.manifest, { force: true }),
25765
+ import_node_fs7.promises.rm(paths.backup, { force: true }),
25766
+ import_node_fs7.promises.rm(paths.replaced, { force: true })
25692
25767
  ]);
25693
25768
  }
25694
25769
  async function rollbackAuthWriteback(filePath, manifest) {
@@ -25709,8 +25784,8 @@ async function rollbackAuthWriteback(filePath, manifest) {
25709
25784
  "Codex auth changed outside CodexUse during writeback rollback; recovery files were preserved."
25710
25785
  );
25711
25786
  }
25712
- await import_node_fs6.promises.rename(filePath, paths.replaced);
25713
- if (fingerprintAuth(await import_node_fs6.promises.readFile(paths.replaced, "utf8")) !== manifest.targetFingerprint) {
25787
+ await import_node_fs7.promises.rename(filePath, paths.replaced);
25788
+ if (fingerprintAuth(await import_node_fs7.promises.readFile(paths.replaced, "utf8")) !== manifest.targetFingerprint) {
25714
25789
  const replaced = await readOptionalFile(paths.replaced);
25715
25790
  if (await readOptionalFile(filePath) === null && replaced !== null) {
25716
25791
  await installAuthFileIfAbsent(filePath, replaced);
@@ -25747,7 +25822,7 @@ async function replaceAuthFileIfCurrent(filePath, expectedCurrent, replacement)
25747
25822
  await writeAtomicPath(paths.manifest, JSON.stringify(manifest));
25748
25823
  let committed = false;
25749
25824
  try {
25750
- await import_node_fs6.promises.rename(filePath, paths.backup);
25825
+ await import_node_fs7.promises.rename(filePath, paths.backup);
25751
25826
  if (await readOptionalFile(paths.backup) !== expectedCurrent) {
25752
25827
  throw new Error("Codex auth changed while writeback began.");
25753
25828
  }
@@ -25797,7 +25872,7 @@ async function acquireCodexAuthFileSystemLock(filePath) {
25797
25872
  }
25798
25873
  }
25799
25874
  async function acquireCodexAuthFileLock(filePath) {
25800
- const queueKey = import_node_path10.default.resolve(filePath);
25875
+ const queueKey = import_node_path11.default.resolve(filePath);
25801
25876
  const predecessor = authFileLockQueues.get(queueKey) ?? Promise.resolve();
25802
25877
  let finishTurn;
25803
25878
  const turn = new Promise((resolve2) => {
@@ -25830,7 +25905,7 @@ async function acquireCodexAuthFileLock(filePath) {
25830
25905
  }
25831
25906
  }
25832
25907
  async function acquireCodexAuthFileReadLock(filePath) {
25833
- const queueKey = import_node_path10.default.resolve(filePath);
25908
+ const queueKey = import_node_path11.default.resolve(filePath);
25834
25909
  await (authFileLockQueues.get(queueKey) ?? Promise.resolve());
25835
25910
  const releaseReadLock = await acquireCrossProcessFileReadLock(filePath);
25836
25911
  if (!releaseReadLock) {
@@ -25847,7 +25922,7 @@ async function acquireCodexAuthFileReadLock(filePath) {
25847
25922
  async function readAuthFileCached(filePath) {
25848
25923
  let stats;
25849
25924
  try {
25850
- stats = await import_node_fs6.promises.stat(filePath);
25925
+ stats = await import_node_fs7.promises.stat(filePath);
25851
25926
  } catch {
25852
25927
  authFileCache.delete(filePath);
25853
25928
  return null;
@@ -25856,7 +25931,7 @@ async function readAuthFileCached(filePath) {
25856
25931
  if (cached2 && cached2.mtimeMs === stats.mtimeMs && cached2.size === stats.size) {
25857
25932
  return cached2.content;
25858
25933
  }
25859
- const content = await import_node_fs6.promises.readFile(filePath, "utf8");
25934
+ const content = await import_node_fs7.promises.readFile(filePath, "utf8");
25860
25935
  authFileCache.set(filePath, {
25861
25936
  mtimeMs: stats.mtimeMs,
25862
25937
  size: stats.size,
@@ -25875,7 +25950,7 @@ async function writeAuthFileCached(filePath, content, expectedCurrent, options =
25875
25950
  );
25876
25951
  if (!written) return false;
25877
25952
  try {
25878
- const stats = await import_node_fs6.promises.stat(filePath);
25953
+ const stats = await import_node_fs7.promises.stat(filePath);
25879
25954
  authFileCache.set(filePath, {
25880
25955
  mtimeMs: stats.mtimeMs,
25881
25956
  size: stats.size,
@@ -26004,9 +26079,9 @@ function parseRateLimitSnapshotFromRpcMessage(message) {
26004
26079
  return snapshot2;
26005
26080
  }
26006
26081
  function resolveRpcAuthPath(envOverride, authPath) {
26007
- return authPath ?? import_node_path10.default.join(
26082
+ return authPath ?? import_node_path11.default.join(
26008
26083
  resolveCodexHomeDir({
26009
- codexHomePath: envOverride?.CODEX_HOME ?? (envOverride?.HOME ? import_node_path10.default.join(envOverride.HOME, ".codex") : void 0)
26084
+ codexHomePath: envOverride?.CODEX_HOME ?? (envOverride?.HOME ? import_node_path11.default.join(envOverride.HOME, ".codex") : void 0)
26010
26085
  }),
26011
26086
  "auth.json"
26012
26087
  );
@@ -26014,13 +26089,13 @@ function resolveRpcAuthPath(envOverride, authPath) {
26014
26089
  async function fetchRateLimitsViaRpc(envOverride, options = {}) {
26015
26090
  const binaryPath = options.codexPath ?? await requireCodexCli();
26016
26091
  const sourceAuthPath = resolveRpcAuthPath(envOverride, options.authPath);
26017
- const tempHome = await import_node_fs6.promises.mkdtemp(import_node_path10.default.join(import_node_os3.default.tmpdir(), "codex-rpc-"));
26018
- const tempAuthPath = import_node_path10.default.join(tempHome, "auth.json");
26092
+ const tempHome = await import_node_fs7.promises.mkdtemp(import_node_path11.default.join(import_node_os6.default.tmpdir(), "codex-rpc-"));
26093
+ const tempAuthPath = import_node_path11.default.join(tempHome, "auth.json");
26019
26094
  let initialSourceAuth;
26020
26095
  try {
26021
26096
  const authLock = await acquireCodexAuthFileReadLock(sourceAuthPath);
26022
26097
  if (!authLock) {
26023
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true });
26098
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true });
26024
26099
  return null;
26025
26100
  }
26026
26101
  try {
@@ -26029,21 +26104,22 @@ async function fetchRateLimitsViaRpc(envOverride, options = {}) {
26029
26104
  await authLock.release();
26030
26105
  }
26031
26106
  if (!initialSourceAuth) {
26032
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true });
26107
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true });
26033
26108
  return null;
26034
26109
  }
26035
- await import_node_fs6.promises.writeFile(tempAuthPath, initialSourceAuth, {
26110
+ await import_node_fs7.promises.writeFile(tempAuthPath, initialSourceAuth, {
26036
26111
  encoding: "utf8",
26037
26112
  mode: 384
26038
26113
  });
26039
26114
  } catch {
26040
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26115
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26041
26116
  });
26042
26117
  return null;
26043
26118
  }
26044
26119
  const childEnv = buildCodexChildEnv({
26045
26120
  ...envOverride ?? {},
26046
26121
  HOME: tempHome,
26122
+ USERPROFILE: tempHome,
26047
26123
  CODEX_HOME: tempHome,
26048
26124
  CODEX_SQLITE_HOME: tempHome,
26049
26125
  CODEX_TELEMETRY_LABEL: "codex-rpc",
@@ -26104,7 +26180,7 @@ async function fetchRateLimitsViaRpc(envOverride, options = {}) {
26104
26180
  rl.close();
26105
26181
  await stopChildAndWait(child);
26106
26182
  try {
26107
- const updatedAuth = await import_node_fs6.promises.readFile(tempAuthPath, "utf8");
26183
+ const updatedAuth = await import_node_fs7.promises.readFile(tempAuthPath, "utf8");
26108
26184
  if (updatedAuth.trim().length > 0) {
26109
26185
  const currentSourceAuth = await readAuthFileCached(sourceAuthPath);
26110
26186
  if (shouldWriteBackAuth(initialSourceAuth, currentSourceAuth, updatedAuth)) {
@@ -26133,7 +26209,7 @@ async function fetchRateLimitsViaRpc(envOverride, options = {}) {
26133
26209
  } catch (error) {
26134
26210
  logWarn("Failed to sync refreshed auth after rate-limit probe:", error);
26135
26211
  }
26136
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26212
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26137
26213
  });
26138
26214
  }
26139
26215
  }
@@ -26147,15 +26223,15 @@ async function activateResetWindowViaRpc(envOverride, options = {}) {
26147
26223
  }
26148
26224
  async function activateResetWindowViaRpcIsolated(envOverride, options, sourceAuthPath) {
26149
26225
  const binaryPath = options.codexPath ?? await requireCodexCli();
26150
- const tempHome = await import_node_fs6.promises.mkdtemp(
26151
- import_node_path10.default.join(import_node_os3.default.tmpdir(), "codex-activation-")
26226
+ const tempHome = await import_node_fs7.promises.mkdtemp(
26227
+ import_node_path11.default.join(import_node_os6.default.tmpdir(), "codex-activation-")
26152
26228
  );
26153
- const tempAuthPath = import_node_path10.default.join(tempHome, "auth.json");
26229
+ const tempAuthPath = import_node_path11.default.join(tempHome, "auth.json");
26154
26230
  let initialSourceAuth;
26155
26231
  try {
26156
26232
  const authLock = await acquireCodexAuthFileReadLock(sourceAuthPath);
26157
26233
  if (!authLock) {
26158
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true });
26234
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true });
26159
26235
  return { status: "skipped", reason: "auth-busy" };
26160
26236
  }
26161
26237
  try {
@@ -26164,30 +26240,30 @@ async function activateResetWindowViaRpcIsolated(envOverride, options, sourceAut
26164
26240
  await authLock.release();
26165
26241
  }
26166
26242
  if (!initialSourceAuth) {
26167
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26243
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26168
26244
  });
26169
26245
  return { status: "skipped", reason: "auth-missing" };
26170
26246
  }
26171
- await import_node_fs6.promises.writeFile(tempAuthPath, initialSourceAuth, {
26247
+ await import_node_fs7.promises.writeFile(tempAuthPath, initialSourceAuth, {
26172
26248
  encoding: "utf8",
26173
26249
  mode: 384
26174
26250
  });
26175
26251
  } catch {
26176
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26252
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26177
26253
  });
26178
26254
  return { status: "skipped", reason: "auth-missing" };
26179
26255
  }
26180
26256
  let configuredModel = null;
26181
26257
  try {
26182
26258
  const snapshot2 = await getCodexConfigSnapshot({
26183
- codexHomePath: import_node_path10.default.dirname(sourceAuthPath)
26259
+ codexHomePath: import_node_path11.default.dirname(sourceAuthPath)
26184
26260
  });
26185
26261
  configuredModel = snapshot2.settings.model;
26186
26262
  } catch {
26187
26263
  }
26188
26264
  const activationModel = resolveActivationModel(configuredModel);
26189
- await import_node_fs6.promises.writeFile(
26190
- import_node_path10.default.join(tempHome, "config.toml"),
26265
+ await import_node_fs7.promises.writeFile(
26266
+ import_node_path11.default.join(tempHome, "config.toml"),
26191
26267
  `model = ${JSON.stringify(activationModel)}
26192
26268
  `,
26193
26269
  "utf8"
@@ -26196,6 +26272,7 @@ async function activateResetWindowViaRpcIsolated(envOverride, options, sourceAut
26196
26272
  const childEnv = buildCodexChildEnv({
26197
26273
  ...envOverride ?? {},
26198
26274
  HOME: tempHome,
26275
+ USERPROFILE: tempHome,
26199
26276
  CODEX_HOME: tempHome,
26200
26277
  CODEX_SQLITE_HOME: tempHome,
26201
26278
  CODEX_TELEMETRY_LABEL: "codex-reset-activation",
@@ -26324,7 +26401,7 @@ async function activateResetWindowViaRpcIsolated(envOverride, options, sourceAut
26324
26401
  rl.close();
26325
26402
  await stopChildAndWait(child);
26326
26403
  try {
26327
- const updatedAuth = await import_node_fs6.promises.readFile(tempAuthPath, "utf8");
26404
+ const updatedAuth = await import_node_fs7.promises.readFile(tempAuthPath, "utf8");
26328
26405
  if (updatedAuth.trim().length > 0) {
26329
26406
  const currentSourceAuth = await readAuthFileCached(sourceAuthPath);
26330
26407
  if (shouldWriteBackAuth(initialSourceAuth, currentSourceAuth, updatedAuth)) {
@@ -26359,7 +26436,7 @@ async function activateResetWindowViaRpcIsolated(envOverride, options, sourceAut
26359
26436
  } catch (error) {
26360
26437
  writebackError = error instanceof Error ? error : new Error(String(error));
26361
26438
  }
26362
- await import_node_fs6.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26439
+ await import_node_fs7.promises.rm(tempHome, { recursive: true, force: true }).catch(() => {
26363
26440
  });
26364
26441
  }
26365
26442
  if (activationError && writebackError) {
@@ -26383,13 +26460,13 @@ async function activateResetWindowViaRpcIsolated(envOverride, options, sourceAut
26383
26460
  // ../../packages/runtime-codex/src/codex/officialAppRestart.ts
26384
26461
  var import_node_child_process6 = require("child_process");
26385
26462
  var import_node_crypto13 = require("crypto");
26386
- var import_node_fs9 = require("fs");
26387
- var import_node_os4 = require("os");
26388
- var import_node_path13 = __toESM(require("path"), 1);
26463
+ var import_node_fs10 = require("fs");
26464
+ var import_node_os7 = require("os");
26465
+ var import_node_path14 = __toESM(require("path"), 1);
26389
26466
 
26390
26467
  // ../../packages/runtime-codex/src/codex/threadUsage.ts
26391
- var import_node_fs7 = require("fs");
26392
- var import_node_path11 = __toESM(require("path"), 1);
26468
+ var import_node_fs8 = require("fs");
26469
+ var import_node_path12 = __toESM(require("path"), 1);
26393
26470
  var ROLLOUT_DIRS = ["sessions", "archived_sessions"];
26394
26471
  var SQLITE_EXTENSIONS = /* @__PURE__ */ new Set([".db", ".sqlite", ".sqlite3"]);
26395
26472
  var SILENT_TAKEOVER_HOT_WINDOW_MS = 6e4;
@@ -26401,7 +26478,7 @@ async function collectRolloutFiles(root) {
26401
26478
  async function visit(dir) {
26402
26479
  let entries3;
26403
26480
  try {
26404
- entries3 = await import_node_fs7.promises.readdir(dir, {
26481
+ entries3 = await import_node_fs8.promises.readdir(dir, {
26405
26482
  withFileTypes: true,
26406
26483
  encoding: "utf8"
26407
26484
  });
@@ -26411,7 +26488,7 @@ async function collectRolloutFiles(root) {
26411
26488
  const childVisits = [];
26412
26489
  for (const entry of entries3) {
26413
26490
  const entryName = String(entry.name);
26414
- const entryPath = import_node_path11.default.join(dir, entryName);
26491
+ const entryPath = import_node_path12.default.join(dir, entryName);
26415
26492
  if (entry.isDirectory()) {
26416
26493
  childVisits.push(visit(entryPath));
26417
26494
  continue;
@@ -26429,14 +26506,14 @@ async function collectRolloutFiles(root) {
26429
26506
  async function collectRolloutFilesStrict(root) {
26430
26507
  const files = [];
26431
26508
  async function visit(dir) {
26432
- const entries3 = await import_node_fs7.promises.readdir(dir, {
26509
+ const entries3 = await import_node_fs8.promises.readdir(dir, {
26433
26510
  withFileTypes: true,
26434
26511
  encoding: "utf8"
26435
26512
  });
26436
26513
  await Promise.all(
26437
26514
  entries3.map(async (entry) => {
26438
26515
  const entryName = String(entry.name);
26439
- const entryPath = import_node_path11.default.join(dir, entryName);
26516
+ const entryPath = import_node_path12.default.join(dir, entryName);
26440
26517
  if (entry.isDirectory()) {
26441
26518
  await visit(entryPath);
26442
26519
  } else if (entry.isFile() && entryName.startsWith("rollout-") && entryName.endsWith(".jsonl")) {
@@ -26452,9 +26529,9 @@ async function readOfficialCodexRolloutActivityHeat(profileHome) {
26452
26529
  let latestUpdatedAtMs = null;
26453
26530
  try {
26454
26531
  for (const dirname of ROLLOUT_DIRS) {
26455
- const root = import_node_path11.default.join(profileHome, dirname);
26532
+ const root = import_node_path12.default.join(profileHome, dirname);
26456
26533
  try {
26457
- await import_node_fs7.promises.access(root);
26534
+ await import_node_fs8.promises.access(root);
26458
26535
  } catch (error) {
26459
26536
  if (error.code === "ENOENT") {
26460
26537
  continue;
@@ -26463,7 +26540,7 @@ async function readOfficialCodexRolloutActivityHeat(profileHome) {
26463
26540
  }
26464
26541
  const files = await collectRolloutFilesStrict(root);
26465
26542
  for (const file of files) {
26466
- const stat3 = await import_node_fs7.promises.stat(file);
26543
+ const stat3 = await import_node_fs8.promises.stat(file);
26467
26544
  if (Number.isFinite(stat3.mtimeMs)) {
26468
26545
  latestUpdatedAtMs = Math.max(latestUpdatedAtMs ?? 0, stat3.mtimeMs);
26469
26546
  }
@@ -26484,14 +26561,14 @@ async function findRolloutFileByScan(profileHome, threadId) {
26484
26561
  let best = null;
26485
26562
  const variants = threadIdVariants(threadId);
26486
26563
  for (const dirname of ROLLOUT_DIRS) {
26487
- const root = import_node_path11.default.join(profileHome, dirname);
26564
+ const root = import_node_path12.default.join(profileHome, dirname);
26488
26565
  const files = await collectRolloutFiles(root);
26489
26566
  for (const file of files) {
26490
- const basename = import_node_path11.default.basename(file);
26567
+ const basename = import_node_path12.default.basename(file);
26491
26568
  if (!variants.some((variant) => basename.includes(variant))) {
26492
26569
  continue;
26493
26570
  }
26494
- const stat3 = await import_node_fs7.promises.stat(file).catch(() => null);
26571
+ const stat3 = await import_node_fs8.promises.stat(file).catch(() => null);
26495
26572
  const updatedAtMs = stat3 && Number.isFinite(stat3.mtimeMs) ? stat3.mtimeMs : null;
26496
26573
  if (!best || (updatedAtMs ?? 0) > (best.updatedAtMs ?? 0) || (updatedAtMs ?? 0) === (best.updatedAtMs ?? 0) && file > best.path) {
26497
26574
  best = { path: file, updatedAtMs };
@@ -26563,13 +26640,13 @@ function resolveRolloutPath(profileHome, rolloutPath) {
26563
26640
  if (!rolloutPath) {
26564
26641
  return null;
26565
26642
  }
26566
- return import_node_path11.default.isAbsolute(rolloutPath) ? rolloutPath : import_node_path11.default.join(profileHome, rolloutPath);
26643
+ return import_node_path12.default.isAbsolute(rolloutPath) ? rolloutPath : import_node_path12.default.join(profileHome, rolloutPath);
26567
26644
  }
26568
26645
  async function collectSessionDatabasePaths(profileHome, sqliteHome = profileHome) {
26569
26646
  const paths = [];
26570
- const sqliteDir = import_node_path11.default.join(sqliteHome, "sqlite");
26647
+ const sqliteDir = import_node_path12.default.join(sqliteHome, "sqlite");
26571
26648
  try {
26572
- const entries3 = await import_node_fs7.promises.readdir(sqliteDir, {
26649
+ const entries3 = await import_node_fs8.promises.readdir(sqliteDir, {
26573
26650
  withFileTypes: true,
26574
26651
  encoding: "utf8"
26575
26652
  });
@@ -26578,20 +26655,20 @@ async function collectSessionDatabasePaths(profileHome, sqliteHome = profileHome
26578
26655
  continue;
26579
26656
  }
26580
26657
  const entryName = String(entry.name);
26581
- if (SQLITE_EXTENSIONS.has(import_node_path11.default.extname(entryName))) {
26582
- paths.push(import_node_path11.default.join(sqliteDir, entryName));
26658
+ if (SQLITE_EXTENSIONS.has(import_node_path12.default.extname(entryName))) {
26659
+ paths.push(import_node_path12.default.join(sqliteDir, entryName));
26583
26660
  }
26584
26661
  }
26585
26662
  } catch {
26586
26663
  }
26587
26664
  paths.sort((left, right) => {
26588
- const leftName = import_node_path11.default.basename(left);
26589
- const rightName = import_node_path11.default.basename(right);
26665
+ const leftName = import_node_path12.default.basename(left);
26666
+ const rightName = import_node_path12.default.basename(right);
26590
26667
  if (leftName === "codex-dev.db" && rightName !== "codex-dev.db") return -1;
26591
26668
  if (rightName === "codex-dev.db" && leftName !== "codex-dev.db") return 1;
26592
26669
  return leftName.localeCompare(rightName);
26593
26670
  });
26594
- const legacy = import_node_path11.default.join(sqliteHome, "state_5.sqlite");
26671
+ const legacy = import_node_path12.default.join(sqliteHome, "state_5.sqlite");
26595
26672
  if (!paths.includes(legacy)) {
26596
26673
  paths.push(legacy);
26597
26674
  }
@@ -26651,7 +26728,7 @@ function queryThreadRecordFromTable(db, profileHome, threadId, config) {
26651
26728
  }
26652
26729
  async function readThreadRecordFromDb(profileHome, dbPath, threadId) {
26653
26730
  try {
26654
- await import_node_fs7.promises.access(dbPath);
26731
+ await import_node_fs8.promises.access(dbPath);
26655
26732
  } catch {
26656
26733
  return null;
26657
26734
  }
@@ -26717,9 +26794,9 @@ async function findOfficialCodexThreadRecord(profileHome, threadId, options = {}
26717
26794
 
26718
26795
  // ../../packages/runtime-codex/src/codex/sharedHistory.ts
26719
26796
  var import_node_crypto12 = require("crypto");
26720
- var import_node_fs8 = require("fs");
26797
+ var import_node_fs9 = require("fs");
26721
26798
  var import_promises5 = require("fs/promises");
26722
- var import_node_path12 = __toESM(require("path"), 1);
26799
+ var import_node_path13 = __toESM(require("path"), 1);
26723
26800
  var HISTORY_MARKER = ".codexuse-shared-history-v1.json";
26724
26801
  var HISTORY_INDEX = "session_index.jsonl";
26725
26802
  var HISTORY_DIRECTORIES = [
@@ -26728,13 +26805,13 @@ var HISTORY_DIRECTORIES = [
26728
26805
  "thread-writer-locks"
26729
26806
  ];
26730
26807
  function markerPath(profileHome) {
26731
- return import_node_path12.default.join(profileHome, HISTORY_MARKER);
26808
+ return import_node_path13.default.join(profileHome, HISTORY_MARKER);
26732
26809
  }
26733
26810
  function linkPointsTo(linkPath, targetPath) {
26734
26811
  try {
26735
- const metadata = (0, import_node_fs8.lstatSync)(linkPath);
26812
+ const metadata = (0, import_node_fs9.lstatSync)(linkPath);
26736
26813
  if (!metadata.isSymbolicLink()) return false;
26737
- return import_node_path12.default.resolve(import_node_path12.default.dirname(linkPath), (0, import_node_fs8.readlinkSync)(linkPath)) === import_node_path12.default.resolve(targetPath);
26814
+ return import_node_path13.default.resolve(import_node_path13.default.dirname(linkPath), (0, import_node_fs9.readlinkSync)(linkPath)) === import_node_path13.default.resolve(targetPath);
26738
26815
  } catch {
26739
26816
  return false;
26740
26817
  }
@@ -26742,9 +26819,9 @@ function linkPointsTo(linkPath, targetPath) {
26742
26819
  function parseMarker(profileHome) {
26743
26820
  try {
26744
26821
  const value3 = JSON.parse(
26745
- (0, import_node_fs8.readFileSync)(markerPath(profileHome), "utf8")
26822
+ (0, import_node_fs9.readFileSync)(markerPath(profileHome), "utf8")
26746
26823
  );
26747
- if (value3.version !== 1 || typeof value3.sharedHome !== "string" || !import_node_path12.default.isAbsolute(value3.sharedHome) || typeof value3.sqliteHome !== "string" || !import_node_path12.default.isAbsolute(value3.sqliteHome)) {
26824
+ if (value3.version !== 1 || typeof value3.sharedHome !== "string" || !import_node_path13.default.isAbsolute(value3.sharedHome) || typeof value3.sqliteHome !== "string" || !import_node_path13.default.isAbsolute(value3.sqliteHome)) {
26748
26825
  return null;
26749
26826
  }
26750
26827
  return value3;
@@ -26753,25 +26830,25 @@ function parseMarker(profileHome) {
26753
26830
  }
26754
26831
  }
26755
26832
  function readSharedCodexHistoryConfiguration(profileHome) {
26756
- const normalizedProfileHome = import_node_path12.default.resolve(profileHome);
26833
+ const normalizedProfileHome = import_node_path13.default.resolve(profileHome);
26757
26834
  const marker = parseMarker(normalizedProfileHome);
26758
- if (!marker || import_node_path12.default.resolve(marker.sharedHome) === normalizedProfileHome) {
26835
+ if (!marker || import_node_path13.default.resolve(marker.sharedHome) === normalizedProfileHome) {
26759
26836
  return null;
26760
26837
  }
26761
26838
  if (!HISTORY_DIRECTORIES.every(
26762
26839
  (name) => linkPointsTo(
26763
- import_node_path12.default.join(normalizedProfileHome, name),
26764
- import_node_path12.default.join(marker.sharedHome, name)
26840
+ import_node_path13.default.join(normalizedProfileHome, name),
26841
+ import_node_path13.default.join(marker.sharedHome, name)
26765
26842
  )
26766
26843
  ) || !linkPointsTo(
26767
- import_node_path12.default.join(normalizedProfileHome, HISTORY_INDEX),
26768
- import_node_path12.default.join(marker.sharedHome, HISTORY_INDEX)
26844
+ import_node_path13.default.join(normalizedProfileHome, HISTORY_INDEX),
26845
+ import_node_path13.default.join(marker.sharedHome, HISTORY_INDEX)
26769
26846
  )) {
26770
26847
  return null;
26771
26848
  }
26772
26849
  return {
26773
- sharedHome: import_node_path12.default.resolve(marker.sharedHome),
26774
- sqliteHome: import_node_path12.default.resolve(marker.sqliteHome)
26850
+ sharedHome: import_node_path13.default.resolve(marker.sharedHome),
26851
+ sqliteHome: import_node_path13.default.resolve(marker.sqliteHome)
26775
26852
  };
26776
26853
  }
26777
26854
 
@@ -31099,18 +31176,18 @@ async function startOfficialCodexBridgeActionListenerOnce(args2) {
31099
31176
  if (!requestId || !rememberBridgeActionId(requestId)) {
31100
31177
  return;
31101
31178
  }
31102
- const path22 = typeof payload.path === "string" ? payload.path.trim().slice(0, 64) : "";
31179
+ const path23 = typeof payload.path === "string" ? payload.path.trim().slice(0, 64) : "";
31103
31180
  const requestHandler = officialCodexBridgeRequestHandler;
31104
31181
  void (async () => {
31105
31182
  let result2;
31106
- if (!path22) {
31183
+ if (!path23) {
31107
31184
  result2 = { status: "failed", reason: "missing-path" };
31108
31185
  } else if (!requestHandler) {
31109
31186
  result2 = { status: "failed", reason: "no-request-handler" };
31110
31187
  } else {
31111
31188
  try {
31112
31189
  result2 = await requestHandler({
31113
- path: path22,
31190
+ path: path23,
31114
31191
  payload: payload.payload ?? null,
31115
31192
  sourceProfileName: bridgeActionListenerProfiles.get(args2.debuggerUrl) ?? profileName
31116
31193
  });
@@ -31665,7 +31742,7 @@ var LAUNCH_LOCK_NAME = ".codexuse-launch.lock";
31665
31742
  var LAUNCH_LOCK_WAIT_MS = 6e4;
31666
31743
  async function withProfileLaunchFileLock(profileHome, work, options) {
31667
31744
  const accountKey = options.profileKey?.trim();
31668
- const lockPath = accountKey ? import_node_path13.default.join(resolveProfileCodexHomesRoot(), ".launch-locks", (0, import_node_crypto13.createHash)("sha256").update(accountKey).digest("hex")) : import_node_path13.default.join(profileHome, LAUNCH_LOCK_NAME);
31745
+ const lockPath = accountKey ? import_node_path14.default.join(resolveProfileCodexHomesRoot(), ".launch-locks", (0, import_node_crypto13.createHash)("sha256").update(accountKey).digest("hex")) : import_node_path14.default.join(profileHome, LAUNCH_LOCK_NAME);
31669
31746
  const deadline = Date.now() + (options.waitMs ?? LAUNCH_LOCK_WAIT_MS);
31670
31747
  for (; ; ) {
31671
31748
  const release = await acquireCrossProcessFileLock(lockPath, { busyTimeoutMs: 0 });
@@ -31712,7 +31789,7 @@ async function readProcessRows() {
31712
31789
  return rows;
31713
31790
  }
31714
31791
  function getMainExecutablePath(candidate) {
31715
- return import_node_path13.default.join(candidate.appPath, "Contents", "MacOS", candidate.executableName);
31792
+ return import_node_path14.default.join(candidate.appPath, "Contents", "MacOS", candidate.executableName);
31716
31793
  }
31717
31794
  function isMainProcessRow(row, candidate) {
31718
31795
  return row.args.includes(getMainExecutablePath(candidate));
@@ -32442,16 +32519,16 @@ async function verifyCurrentManagedProfileProof(instance, runtime, candidate, op
32442
32519
  }
32443
32520
  var devToolsActivePortPaths = (appUserDataDir) => {
32444
32521
  const roots = appUserDataDir ? [appUserDataDir] : [
32445
- import_node_path13.default.join((0, import_node_os4.homedir)(), "Library", "Application Support", "OpenAI", "Codex"),
32446
- import_node_path13.default.join((0, import_node_os4.homedir)(), "Library", "Application Support", "Codex"),
32447
- import_node_path13.default.join((0, import_node_os4.homedir)(), "Library", "Application Support", "com.openai.codex"),
32448
- import_node_path13.default.join((0, import_node_os4.homedir)(), "Library", "Application Support", "com.openai.chat")
32522
+ import_node_path14.default.join((0, import_node_os7.homedir)(), "Library", "Application Support", "OpenAI", "Codex"),
32523
+ import_node_path14.default.join((0, import_node_os7.homedir)(), "Library", "Application Support", "Codex"),
32524
+ import_node_path14.default.join((0, import_node_os7.homedir)(), "Library", "Application Support", "com.openai.codex"),
32525
+ import_node_path14.default.join((0, import_node_os7.homedir)(), "Library", "Application Support", "com.openai.chat")
32449
32526
  ];
32450
- return roots.map((root) => import_node_path13.default.join(root, "DevToolsActivePort"));
32527
+ return roots.map((root) => import_node_path14.default.join(root, "DevToolsActivePort"));
32451
32528
  };
32452
32529
  var readDevToolsActivePort = async (filePath) => {
32453
32530
  try {
32454
- const text = await import_node_fs9.promises.readFile(filePath, "utf8");
32531
+ const text = await import_node_fs10.promises.readFile(filePath, "utf8");
32455
32532
  const port = Number(text.split(/\r?\n/, 1)[0]);
32456
32533
  if (!Number.isInteger(port) || port <= 0 || port >= 65536) {
32457
32534
  return null;
@@ -32488,7 +32565,7 @@ function classifyOpenCodexLaunchFailure(error) {
32488
32565
  }
32489
32566
  async function openCodexWithProfileHome(candidate, profileHome, profileName, previousPids, options = {}) {
32490
32567
  const executablePath = getMainExecutablePath(candidate);
32491
- if (!(0, import_node_fs9.existsSync)(executablePath)) {
32568
+ if (!(0, import_node_fs10.existsSync)(executablePath)) {
32492
32569
  return {
32493
32570
  opened: false,
32494
32571
  pid: null,
@@ -32512,7 +32589,7 @@ async function openCodexWithProfileHome(candidate, profileHome, profileName, pre
32512
32589
  let child;
32513
32590
  try {
32514
32591
  if (appUserDataDir) {
32515
- (0, import_node_fs9.mkdirSync)(appUserDataDir, { recursive: true });
32592
+ (0, import_node_fs10.mkdirSync)(appUserDataDir, { recursive: true });
32516
32593
  }
32517
32594
  child = (0, import_node_child_process6.spawn)(
32518
32595
  "/usr/bin/open",
@@ -32664,14 +32741,14 @@ async function openCodexWithProfileHome(candidate, profileHome, profileName, pre
32664
32741
  };
32665
32742
  }
32666
32743
  function resolveCodexLaunchHome(profileHome) {
32667
- if (Buffer.byteLength(import_node_path13.default.join(profileHome, "ipc", "ipc.sock")) >= 100) {
32744
+ if (Buffer.byteLength(import_node_path14.default.join(profileHome, "ipc", "ipc.sock")) >= 100) {
32668
32745
  throw new Error("codex-home-path-too-long");
32669
32746
  }
32670
32747
  return profileHome;
32671
32748
  }
32672
32749
  async function readBundleString(appPath, key) {
32673
- const plistPath = import_node_path13.default.join(appPath, "Contents", "Info.plist");
32674
- if (!(0, import_node_fs9.existsSync)(plistPath)) {
32750
+ const plistPath = import_node_path14.default.join(appPath, "Contents", "Info.plist");
32751
+ if (!(0, import_node_fs10.existsSync)(plistPath)) {
32675
32752
  return null;
32676
32753
  }
32677
32754
  const result2 = await runCommand2("/usr/bin/plutil", [
@@ -32690,18 +32767,18 @@ async function readBundleString(appPath, key) {
32690
32767
  }
32691
32768
  function addStandardOfficialCodexAppPaths(rawPaths) {
32692
32769
  for (const appName of OFFICIAL_CODEX_APP_NAMES) {
32693
- rawPaths.add(import_node_path13.default.join("/Applications", appName));
32694
- rawPaths.add(import_node_path13.default.join((0, import_node_os4.homedir)(), "Applications", appName));
32770
+ rawPaths.add(import_node_path14.default.join("/Applications", appName));
32771
+ rawPaths.add(import_node_path14.default.join((0, import_node_os7.homedir)(), "Applications", appName));
32695
32772
  }
32696
32773
  }
32697
32774
  function officialCodexAppPriority(appPath) {
32698
- const priority = OFFICIAL_CODEX_APP_NAMES.indexOf(import_node_path13.default.basename(appPath));
32775
+ const priority = OFFICIAL_CODEX_APP_NAMES.indexOf(import_node_path14.default.basename(appPath));
32699
32776
  return priority >= 0 ? priority : OFFICIAL_CODEX_APP_NAMES.length;
32700
32777
  }
32701
32778
  async function collectCodexAppCandidates(rawPaths) {
32702
32779
  const candidates = [];
32703
32780
  for (const appPath of rawPaths) {
32704
- if (!(0, import_node_fs9.existsSync)(appPath) || !OFFICIAL_CODEX_APP_NAMES.includes(import_node_path13.default.basename(appPath)) || !(0, import_node_fs9.existsSync)(import_node_path13.default.join(appPath, "Contents", "Resources", "codex"))) {
32781
+ if (!(0, import_node_fs10.existsSync)(appPath) || !OFFICIAL_CODEX_APP_NAMES.includes(import_node_path14.default.basename(appPath)) || !(0, import_node_fs10.existsSync)(import_node_path14.default.join(appPath, "Contents", "Resources", "codex"))) {
32705
32782
  continue;
32706
32783
  }
32707
32784
  const bundleId = await readBundleString(appPath, "CFBundleIdentifier");
@@ -32712,7 +32789,7 @@ async function collectCodexAppCandidates(rawPaths) {
32712
32789
  appPath,
32713
32790
  bundleId,
32714
32791
  version: await readBundleString(appPath, "CFBundleShortVersionString"),
32715
- executableName: await readBundleString(appPath, "CFBundleExecutable") ?? import_node_path13.default.basename(appPath, ".app")
32792
+ executableName: await readBundleString(appPath, "CFBundleExecutable") ?? import_node_path14.default.basename(appPath, ".app")
32716
32793
  });
32717
32794
  }
32718
32795
  return candidates.sort(
@@ -32721,7 +32798,7 @@ async function collectCodexAppCandidates(rawPaths) {
32721
32798
  }
32722
32799
  function getRunningCodexPidsFromRows(candidate, rows) {
32723
32800
  const pids = /* @__PURE__ */ new Set();
32724
- const appContentsRoot = `${import_node_path13.default.join(candidate.appPath, "Contents")}${import_node_path13.default.sep}`;
32801
+ const appContentsRoot = `${import_node_path14.default.join(candidate.appPath, "Contents")}${import_node_path14.default.sep}`;
32725
32802
  for (const row of rows) {
32726
32803
  if (row.args.includes(appContentsRoot)) {
32727
32804
  pids.add(row.pid);
@@ -32731,7 +32808,7 @@ function getRunningCodexPidsFromRows(candidate, rows) {
32731
32808
  }
32732
32809
  function getRunningCodexMainPidsFromRows(candidate, rows) {
32733
32810
  const pids = /* @__PURE__ */ new Set();
32734
- const executablePath = import_node_path13.default.join(
32811
+ const executablePath = import_node_path14.default.join(
32735
32812
  candidate.appPath,
32736
32813
  "Contents",
32737
32814
  "MacOS",
@@ -32769,7 +32846,7 @@ async function resolveCodexAppTarget() {
32769
32846
  mainPids: getRunningCodexMainPidsFromRows(candidate, rows)
32770
32847
  })).filter((entry) => entry.mainPids.length > 0);
32771
32848
  const explicit = explicitPath ? runningCandidates.find(
32772
- (entry) => import_node_path13.default.resolve(entry.candidate.appPath) === import_node_path13.default.resolve(explicitPath)
32849
+ (entry) => import_node_path14.default.resolve(entry.candidate.appPath) === import_node_path14.default.resolve(explicitPath)
32773
32850
  ) : null;
32774
32851
  if (runningCandidates.length > 1) {
32775
32852
  return {
@@ -32812,14 +32889,14 @@ function resolveOfficialCodexLaunchConfiguration(profileHome, options = {}) {
32812
32889
  sqliteHome: options.sqliteHome ?? readSharedCodexHistoryConfiguration(profileHome)?.sqliteHome ?? profileHome,
32813
32890
  // Managed profile windows keep Electron state separate as well as CODEX_HOME.
32814
32891
  // Callers can supply another isolated directory or explicitly use stock state.
32815
- userDataDir: options.useDefaultUserData === true ? null : options.userDataDir ?? import_node_path13.default.join(profileHome, "codex-app-user-data")
32892
+ userDataDir: options.useDefaultUserData === true ? null : options.userDataDir ?? import_node_path14.default.join(profileHome, "codex-app-user-data")
32816
32893
  };
32817
32894
  }
32818
32895
  function resolveOfficialCodexThreadSqliteHome(profileHome) {
32819
32896
  return readSharedCodexHistoryConfiguration(profileHome)?.sqliteHome ?? profileHome;
32820
32897
  }
32821
32898
  function sharedCodexLaunchOptions(useDefaultUserData, profileIdentity) {
32822
- const userDataDir = !useDefaultUserData && profileIdentity ? import_node_path13.default.join(
32899
+ const userDataDir = !useDefaultUserData && profileIdentity ? import_node_path14.default.join(
32823
32900
  SHARED_CODEX_HOME,
32824
32901
  "codex-app-user-data",
32825
32902
  (0, import_node_crypto13.createHash)("sha256").update(profileIdentity).digest("hex").slice(0, 16)
@@ -32986,7 +33063,7 @@ function isSharedHomeMainProcessRow(row, candidate) {
32986
33063
  resolveProfileCodexHomesRoot(),
32987
33064
  resolveLegacyProfileCodexHomesRoot()
32988
33065
  ];
32989
- return isMainProcessRow(row, candidate) && managedRoots.every((root) => !row.args.includes(`${root}${import_node_path13.default.sep}`));
33066
+ return isMainProcessRow(row, candidate) && managedRoots.every((root) => !row.args.includes(`${root}${import_node_path14.default.sep}`));
32990
33067
  }
32991
33068
  async function hydrateSharedHomeCdpWindow(rows, candidate) {
32992
33069
  const isRunningCandidate = async (value3) => {
@@ -37060,8 +37137,8 @@ async function releaseProfileHomeMutationIntent(homeId, operationId) {
37060
37137
  }
37061
37138
 
37062
37139
  // ../../packages/runtime-profiles/src/profiles/rate-limit-cache.ts
37063
- var import_node_fs10 = require("fs");
37064
- var import_node_path14 = __toESM(require("path"), 1);
37140
+ var import_node_fs11 = require("fs");
37141
+ var import_node_path15 = __toESM(require("path"), 1);
37065
37142
  var memorySnapshots = /* @__PURE__ */ new Map();
37066
37143
  var persistedSnapshotWriteLock = Promise.resolve();
37067
37144
  var RATE_LIMIT_SNAPSHOT_CACHE_FILE = "rate-limit-snapshots.json";
@@ -37069,12 +37146,12 @@ function cloneSnapshot(snapshot2) {
37069
37146
  return JSON.parse(JSON.stringify(snapshot2));
37070
37147
  }
37071
37148
  function snapshotCachePath() {
37072
- return import_node_path14.default.join(getUserDataDir(), RATE_LIMIT_SNAPSHOT_CACHE_FILE);
37149
+ return import_node_path15.default.join(getUserDataDir(), RATE_LIMIT_SNAPSHOT_CACHE_FILE);
37073
37150
  }
37074
37151
  async function loadPersistedSnapshots() {
37075
37152
  let raw;
37076
37153
  try {
37077
- raw = (await import_node_fs10.promises.readFile(snapshotCachePath(), "utf8")).trim();
37154
+ raw = (await import_node_fs11.promises.readFile(snapshotCachePath(), "utf8")).trim();
37078
37155
  } catch {
37079
37156
  return /* @__PURE__ */ new Map();
37080
37157
  }
@@ -37118,13 +37195,13 @@ async function writePersistedSnapshots(snapshots) {
37118
37195
  2
37119
37196
  );
37120
37197
  try {
37121
- await import_node_fs10.promises.mkdir(import_node_path14.default.dirname(filePath), { recursive: true });
37122
- await import_node_fs10.promises.writeFile(tmpPath, `${payload}
37198
+ await import_node_fs11.promises.mkdir(import_node_path15.default.dirname(filePath), { recursive: true });
37199
+ await import_node_fs11.promises.writeFile(tmpPath, `${payload}
37123
37200
  `, "utf8");
37124
- await import_node_fs10.promises.rename(tmpPath, filePath);
37201
+ await import_node_fs11.promises.rename(tmpPath, filePath);
37125
37202
  } catch {
37126
37203
  try {
37127
- await import_node_fs10.promises.rm(tmpPath, { force: true });
37204
+ await import_node_fs11.promises.rm(tmpPath, { force: true });
37128
37205
  } catch {
37129
37206
  }
37130
37207
  }
@@ -39570,7 +39647,7 @@ var ProfileManager = class {
39570
39647
  }
39571
39648
  throw error;
39572
39649
  }
39573
- const trashRoot = process.platform === "darwin" ? import_path.default.join(process.env.HOME || import_node_os5.default.homedir(), ".Trash") : import_path.default.join(getUserDataDir(), "deleted-profile-homes");
39650
+ const trashRoot = process.platform === "darwin" ? import_path.default.join(process.env.HOME || import_node_os8.default.homedir(), ".Trash") : import_path.default.join(getUserDataDir(), "deleted-profile-homes");
39574
39651
  await import_fs.promises.mkdir(trashRoot, { recursive: true, mode: 448 });
39575
39652
  const safeName = record2.name.replace(/[^A-Za-z0-9._-]+/g, "-").slice(0, 48) || "profile";
39576
39653
  const destination = import_path.default.join(
@@ -40559,6 +40636,7 @@ var ProfileManager = class {
40559
40636
  const leaseId = await this.acquireProfileRuntimeLease(record2);
40560
40637
  const envOverrides = buildCodexChildEnv({
40561
40638
  HOME: profileHome,
40639
+ USERPROFILE: profileHome,
40562
40640
  CODEX_HOME: profileHome,
40563
40641
  CODEX_SQLITE_HOME: profileHome
40564
40642
  });
@@ -40679,6 +40757,7 @@ var ProfileManager = class {
40679
40757
  leaseId,
40680
40758
  env: buildCodexChildEnv({
40681
40759
  HOME: profileHome,
40760
+ USERPROFILE: profileHome,
40682
40761
  CODEX_HOME: profileHome,
40683
40762
  CODEX_SQLITE_HOME: profileHome
40684
40763
  })
@@ -42010,6 +42089,7 @@ async function prepareManagedProfileRuntime(profileManager, profileName, options
42010
42089
  leaseId: null,
42011
42090
  env: buildCodexChildEnv({
42012
42091
  HOME: profileHome,
42092
+ USERPROFILE: profileHome,
42013
42093
  CODEX_HOME: profileHome,
42014
42094
  CODEX_SQLITE_HOME: profileHome
42015
42095
  })
@@ -42519,7 +42599,7 @@ function pruneStore(store) {
42519
42599
  return store;
42520
42600
  }
42521
42601
  function resolveAccountPoolDbPath(stateDir) {
42522
- return import_node_path15.default.join(stateDir, "state.sqlite");
42602
+ return import_node_path16.default.join(stateDir, "state.sqlite");
42523
42603
  }
42524
42604
  async function readStore(stateDir) {
42525
42605
  const dbPath = resolveAccountPoolDbPath(stateDir);
@@ -42620,9 +42700,9 @@ async function listSessions(stateDir) {
42620
42700
  }
42621
42701
  function resolveRuntimeStateDir(runtime, explicitStateDir) {
42622
42702
  if (explicitStateDir) {
42623
- return import_node_path15.default.resolve(explicitStateDir);
42703
+ return import_node_path16.default.resolve(explicitStateDir);
42624
42704
  }
42625
- return import_node_path15.default.join(getUserDataDir(), DESKTOP_RPC_STATE_DIR);
42705
+ return import_node_path16.default.join(getUserDataDir(), DESKTOP_RPC_STATE_DIR);
42626
42706
  }
42627
42707
  function resolveStateDir(flags) {
42628
42708
  const runtimeFlag = parseStringFlag(flags, "--runtime")?.trim().toLowerCase();
@@ -43071,7 +43151,7 @@ async function handleAccountPoolCommand(args2, version) {
43071
43151
 
43072
43152
  // src/commands/codex.ts
43073
43153
  var import_node_child_process9 = require("child_process");
43074
- var import_node_os6 = __toESM(require("os"));
43154
+ var import_node_os9 = __toESM(require("os"));
43075
43155
 
43076
43156
  // ../../packages/runtime-profiles/src/profiles/rate-limit-notifier.ts
43077
43157
  function maxUsedPercent(snapshot2) {
@@ -43190,22 +43270,22 @@ async function assertProfileAccessAllowed(profileManager, profileName) {
43190
43270
  }
43191
43271
 
43192
43272
  // ../../packages/runtime-app-state/src/app/workspaceBindings.ts
43193
- var import_node_fs11 = require("fs");
43194
- var import_node_path16 = __toESM(require("path"), 1);
43273
+ var import_node_fs12 = require("fs");
43274
+ var import_node_path17 = __toESM(require("path"), 1);
43195
43275
  async function canonicalizeWorkspacePath(input, options = {}) {
43196
- const resolved = import_node_path16.default.resolve(input || process.cwd());
43276
+ const resolved = import_node_path17.default.resolve(input || process.cwd());
43197
43277
  try {
43198
- const canonical = await import_node_fs11.promises.realpath(resolved);
43278
+ const canonical = await import_node_fs12.promises.realpath(resolved);
43199
43279
  if (options.requireDirectory !== false) {
43200
- const stats = await import_node_fs11.promises.stat(canonical);
43280
+ const stats = await import_node_fs12.promises.stat(canonical);
43201
43281
  if (!stats.isDirectory()) {
43202
43282
  throw new Error(`Workspace path is not a directory: ${resolved}`);
43203
43283
  }
43204
43284
  }
43205
- return import_node_path16.default.normalize(canonical);
43285
+ return import_node_path17.default.normalize(canonical);
43206
43286
  } catch (error) {
43207
43287
  if (options.requireDirectory === false) {
43208
- return import_node_path16.default.normalize(resolved);
43288
+ return import_node_path17.default.normalize(resolved);
43209
43289
  }
43210
43290
  const message = error instanceof Error ? error.message : String(error);
43211
43291
  const symptom = new Error(
@@ -43272,7 +43352,7 @@ async function resolveWorkspaceProfileBinding(requestedPath) {
43272
43352
  inherited: candidate !== canonical
43273
43353
  };
43274
43354
  }
43275
- const parent = import_node_path16.default.dirname(candidate);
43355
+ const parent = import_node_path17.default.dirname(candidate);
43276
43356
  if (parent === candidate) {
43277
43357
  return null;
43278
43358
  }
@@ -43282,14 +43362,14 @@ async function resolveWorkspaceProfileBinding(requestedPath) {
43282
43362
 
43283
43363
  // src/platform/codexCli.ts
43284
43364
  var import_node_child_process8 = require("child_process");
43285
- var import_node_fs12 = require("fs");
43286
- var import_node_path17 = __toESM(require("path"));
43365
+ var import_node_fs13 = require("fs");
43366
+ var import_node_path18 = __toESM(require("path"));
43287
43367
  var ENV_HINTS2 = ["CODEX_BINARY", "CODEX_CLI_PATH", "CODEX_PATH"];
43288
43368
  function fileExists2(candidate) {
43289
43369
  if (!candidate) return null;
43290
- const resolved = import_node_path17.default.resolve(candidate);
43370
+ const resolved = import_node_path18.default.resolve(candidate);
43291
43371
  try {
43292
- const stat3 = (0, import_node_fs12.statSync)(resolved);
43372
+ const stat3 = (0, import_node_fs13.statSync)(resolved);
43293
43373
  if (stat3.isFile()) return resolved;
43294
43374
  } catch {
43295
43375
  return null;
@@ -43307,9 +43387,9 @@ function resolveFromEnv() {
43307
43387
  }
43308
43388
  function resolveFromPath() {
43309
43389
  const pathValue = process.env.PATH ?? "";
43310
- const entries3 = pathValue.split(import_node_path17.default.delimiter).filter(Boolean);
43390
+ const entries3 = pathValue.split(import_node_path18.default.delimiter).filter(Boolean);
43311
43391
  for (const entry of entries3) {
43312
- const candidate = fileExists2(import_node_path17.default.join(entry, "codex"));
43392
+ const candidate = fileExists2(import_node_path18.default.join(entry, "codex"));
43313
43393
  if (candidate) return candidate;
43314
43394
  }
43315
43395
  return null;
@@ -43490,7 +43570,7 @@ function exitCodeForSignal(signal) {
43490
43570
  if (!signal) return 1;
43491
43571
  if (signal === "SIGINT") return 130;
43492
43572
  if (signal === "SIGTERM") return 143;
43493
- const number3 = import_node_os6.default.constants.signals[signal];
43573
+ const number3 = import_node_os9.default.constants.signals[signal];
43494
43574
  return typeof number3 === "number" ? 128 + number3 : 1;
43495
43575
  }
43496
43576
  async function runCodexWithProfile(manager, profileName, codexArgs) {
@@ -43757,14 +43837,14 @@ async function handleLicense(args2, version) {
43757
43837
  }
43758
43838
 
43759
43839
  // src/commands/profile.ts
43760
- var import_node_fs14 = require("fs");
43761
- var import_node_os7 = __toESM(require("os"));
43762
- var import_node_path19 = __toESM(require("path"));
43840
+ var import_node_fs15 = require("fs");
43841
+ var import_node_os10 = __toESM(require("os"));
43842
+ var import_node_path20 = __toESM(require("path"));
43763
43843
 
43764
43844
  // ../../packages/runtime-app-state/src/app/officialCodexSwitchCoordinator.ts
43765
43845
  var import_node_crypto17 = require("crypto");
43766
- var import_node_fs13 = require("fs");
43767
- var import_node_path18 = __toESM(require("path"), 1);
43846
+ var import_node_fs14 = require("fs");
43847
+ var import_node_path19 = __toESM(require("path"), 1);
43768
43848
  var DEFAULT_SWITCH_INTENT_TTL_MS = 10 * 60 * 1e3;
43769
43849
  var SWITCH_INTENT_RENEW_MS = 30 * 1e3;
43770
43850
  var PROCESS_OWNER_ID3 = (0, import_node_crypto17.randomUUID)();
@@ -44584,7 +44664,7 @@ function formatProfileLabel(name, displayName) {
44584
44664
  }
44585
44665
  var AUTO_ROLL_ACCESS_REQUIRED_MESSAGE = "Auto-roll requires a Pro license or an active trial.";
44586
44666
  async function withIsolatedCodexLogin(mode, action) {
44587
- const home = await import_node_fs14.promises.mkdtemp(import_node_path19.default.join(import_node_os7.default.tmpdir(), "codexuse-cli-login-"));
44667
+ const home = await import_node_fs15.promises.mkdtemp(import_node_path20.default.join(import_node_os10.default.tmpdir(), "codexuse-cli-login-"));
44588
44668
  try {
44589
44669
  await runCodexLogin(mode, {
44590
44670
  HOME: home,
@@ -44592,9 +44672,9 @@ async function withIsolatedCodexLogin(mode, action) {
44592
44672
  CODEX_SQLITE_HOME: home,
44593
44673
  ELECTRON_RUN_AS_NODE: "1"
44594
44674
  });
44595
- return await action(import_node_path19.default.join(home, "auth.json"));
44675
+ return await action(import_node_path20.default.join(home, "auth.json"));
44596
44676
  } finally {
44597
- await import_node_fs14.promises.rm(home, { recursive: true, force: true }).catch(() => void 0);
44677
+ await import_node_fs15.promises.rm(home, { recursive: true, force: true }).catch(() => void 0);
44598
44678
  }
44599
44679
  }
44600
44680
  async function assertOfficialCodexProfileStopped(profileName) {
@@ -46095,15 +46175,15 @@ async function pushRemoteSnapshot(access, snapshot2, options) {
46095
46175
  }
46096
46176
 
46097
46177
  // ../../packages/runtime-profiles/src/cloud-sync/journal.ts
46098
- var import_node_fs15 = require("fs");
46178
+ var import_node_fs16 = require("fs");
46099
46179
  var import_node_crypto18 = require("crypto");
46100
- var import_node_path20 = __toESM(require("path"), 1);
46180
+ var import_node_path21 = __toESM(require("path"), 1);
46101
46181
  var JOURNAL_FILENAME = "cloud-sync-pull.journal.json";
46102
46182
  function getCloudSyncJournalPath() {
46103
- return import_node_path20.default.join(getUserDataDir(), JOURNAL_FILENAME);
46183
+ return import_node_path21.default.join(getUserDataDir(), JOURNAL_FILENAME);
46104
46184
  }
46105
46185
  async function syncDirectory(dir) {
46106
- const directory = await import_node_fs15.promises.open(dir, "r");
46186
+ const directory = await import_node_fs16.promises.open(dir, "r");
46107
46187
  try {
46108
46188
  await directory.sync();
46109
46189
  } finally {
@@ -46112,30 +46192,30 @@ async function syncDirectory(dir) {
46112
46192
  }
46113
46193
  async function writeCloudSyncJournal(journal) {
46114
46194
  const target = getCloudSyncJournalPath();
46115
- const dir = import_node_path20.default.dirname(target);
46116
- await import_node_fs15.promises.mkdir(dir, { recursive: true, mode: 448 });
46117
- await import_node_fs15.promises.chmod(dir, 448);
46195
+ const dir = import_node_path21.default.dirname(target);
46196
+ await import_node_fs16.promises.mkdir(dir, { recursive: true, mode: 448 });
46197
+ await import_node_fs16.promises.chmod(dir, 448);
46118
46198
  const staging = `${target}.tmp-${process.pid}-${(0, import_node_crypto18.randomUUID)()}`;
46119
- await import_node_fs15.promises.writeFile(staging, JSON.stringify(journal), {
46199
+ await import_node_fs16.promises.writeFile(staging, JSON.stringify(journal), {
46120
46200
  encoding: "utf8",
46121
46201
  flag: "wx",
46122
46202
  mode: 384,
46123
46203
  flush: true
46124
46204
  });
46125
- await import_node_fs15.promises.rename(staging, target);
46205
+ await import_node_fs16.promises.rename(staging, target);
46126
46206
  await syncDirectory(dir);
46127
46207
  }
46128
46208
  async function clearCloudSyncJournal() {
46129
46209
  const target = getCloudSyncJournalPath();
46130
46210
  try {
46131
- await import_node_fs15.promises.unlink(target);
46211
+ await import_node_fs16.promises.unlink(target);
46132
46212
  } catch (error) {
46133
46213
  if (error?.code === "ENOENT") {
46134
46214
  return;
46135
46215
  }
46136
46216
  throw error;
46137
46217
  }
46138
- await syncDirectory(import_node_path20.default.dirname(target));
46218
+ await syncDirectory(import_node_path21.default.dirname(target));
46139
46219
  }
46140
46220
 
46141
46221
  // ../../packages/runtime-profiles/src/cloud-sync/encryption.ts
@@ -46932,7 +47012,7 @@ async function handleSync(args2, version) {
46932
47012
  }
46933
47013
 
46934
47014
  // src/commands/workspace.ts
46935
- var import_node_fs16 = require("fs");
47015
+ var import_node_fs17 = require("fs");
46936
47016
  function printWorkspaceHelp() {
46937
47017
  console.log(`Usage:
46938
47018
  codexuse workspace bind <path> <profile>
@@ -46962,7 +47042,7 @@ async function handleWorkspaceCommand(args2) {
46962
47042
  return;
46963
47043
  }
46964
47044
  for (const binding of bindings) {
46965
- const pathState = await import_node_fs16.promises.stat(binding.rootPath).then(() => "").catch(() => " (path missing)");
47045
+ const pathState = await import_node_fs17.promises.stat(binding.rootPath).then(() => "").catch(() => " (path missing)");
46966
47046
  const profileState = profiles.has(binding.profileName) ? "" : " (profile missing)";
46967
47047
  console.log(`${binding.rootPath} -> ${binding.profileName}${pathState}${profileState}`);
46968
47048
  }
@@ -47026,7 +47106,7 @@ async function ensureCliStorageReady() {
47026
47106
  }
47027
47107
 
47028
47108
  // src/app/main.ts
47029
- var VERSION = true ? "6.2.12" : "0.0.0";
47109
+ var VERSION = true ? "6.3.0" : "0.0.0";
47030
47110
  async function runCli() {
47031
47111
  const args2 = process.argv.slice(2);
47032
47112
  if (args2.length === 0) {