codexuse-cli 5.0.8 → 5.0.9

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
@@ -2023,7 +2023,7 @@ var require_toml = __commonJS({
2023
2023
 
2024
2024
  // src/commands/accountPool.ts
2025
2025
  var import_node_crypto4 = require("crypto");
2026
- var import_node_path6 = __toESM(require("path"));
2026
+ var import_node_path7 = __toESM(require("path"));
2027
2027
 
2028
2028
  // ../../packages/contracts/src/settings/types.ts
2029
2029
  var DEFAULT_ACCOUNT_POOL_EXPOSED_MODELS = [
@@ -5291,6 +5291,120 @@ async function activateResetWindowViaRpc(envOverride, options = {}) {
5291
5291
  }
5292
5292
  }
5293
5293
 
5294
+ // ../../packages/runtime-profiles/src/profiles/rate-limit-cache.ts
5295
+ var import_node_fs4 = require("fs");
5296
+ var import_node_path6 = __toESM(require("path"), 1);
5297
+ var memorySnapshots = /* @__PURE__ */ new Map();
5298
+ var persistedSnapshotWriteLock = Promise.resolve();
5299
+ var RATE_LIMIT_SNAPSHOT_CACHE_FILE = "rate-limit-snapshots.json";
5300
+ function cloneSnapshot(snapshot) {
5301
+ return JSON.parse(JSON.stringify(snapshot));
5302
+ }
5303
+ function snapshotCachePath() {
5304
+ return import_node_path6.default.join(getUserDataDir(), RATE_LIMIT_SNAPSHOT_CACHE_FILE);
5305
+ }
5306
+ async function loadPersistedSnapshots() {
5307
+ let raw;
5308
+ try {
5309
+ raw = (await import_node_fs4.promises.readFile(snapshotCachePath(), "utf8")).trim();
5310
+ } catch {
5311
+ return /* @__PURE__ */ new Map();
5312
+ }
5313
+ if (!raw) {
5314
+ return /* @__PURE__ */ new Map();
5315
+ }
5316
+ try {
5317
+ const parsed = JSON.parse(raw);
5318
+ if (!parsed || typeof parsed !== "object") {
5319
+ return /* @__PURE__ */ new Map();
5320
+ }
5321
+ return new Map(
5322
+ Object.entries(parsed).flatMap(
5323
+ ([key, value]) => {
5324
+ if (!key || !value || typeof value !== "object") {
5325
+ return [];
5326
+ }
5327
+ const snapshot = value;
5328
+ if (typeof snapshot.lastUpdated !== "string") {
5329
+ return [];
5330
+ }
5331
+ return [[key, cloneSnapshot(snapshot)]];
5332
+ }
5333
+ )
5334
+ );
5335
+ } catch {
5336
+ return /* @__PURE__ */ new Map();
5337
+ }
5338
+ }
5339
+ async function writePersistedSnapshots(snapshots) {
5340
+ const filePath = snapshotCachePath();
5341
+ const tmpPath = `${filePath}.tmp`;
5342
+ const payload = JSON.stringify(
5343
+ Object.fromEntries(
5344
+ Array.from(snapshots.entries()).map(([key, snapshot]) => [
5345
+ key,
5346
+ cloneSnapshot(snapshot)
5347
+ ])
5348
+ ),
5349
+ null,
5350
+ 2
5351
+ );
5352
+ try {
5353
+ await import_node_fs4.promises.mkdir(import_node_path6.default.dirname(filePath), { recursive: true });
5354
+ await import_node_fs4.promises.writeFile(tmpPath, `${payload}
5355
+ `, "utf8");
5356
+ await import_node_fs4.promises.rename(tmpPath, filePath);
5357
+ } catch {
5358
+ try {
5359
+ await import_node_fs4.promises.rm(tmpPath, { force: true });
5360
+ } catch {
5361
+ }
5362
+ }
5363
+ }
5364
+ async function mutatePersistedSnapshots(mutate) {
5365
+ persistedSnapshotWriteLock = persistedSnapshotWriteLock.then(async () => {
5366
+ const persistedSnapshots = await loadPersistedSnapshots();
5367
+ if (!mutate(persistedSnapshots)) {
5368
+ return;
5369
+ }
5370
+ await writePersistedSnapshots(persistedSnapshots);
5371
+ });
5372
+ await persistedSnapshotWriteLock;
5373
+ }
5374
+ async function deleteRateLimitSnapshots(keys) {
5375
+ const snapshotKeys = Array.from(new Set(keys.map((key) => key.trim()).filter(Boolean)));
5376
+ if (snapshotKeys.length === 0) {
5377
+ return;
5378
+ }
5379
+ for (const key of snapshotKeys) {
5380
+ memorySnapshots.delete(key);
5381
+ }
5382
+ await mutatePersistedSnapshots((persistedSnapshots) => {
5383
+ let changed = false;
5384
+ for (const key of snapshotKeys) {
5385
+ changed = persistedSnapshots.delete(key) || changed;
5386
+ }
5387
+ return changed;
5388
+ });
5389
+ }
5390
+ async function pruneRateLimitSnapshots(allowedKeys) {
5391
+ const allowed = new Set(allowedKeys.map((key) => key.trim()).filter(Boolean));
5392
+ for (const key of Array.from(memorySnapshots.keys())) {
5393
+ if (!allowed.has(key)) {
5394
+ memorySnapshots.delete(key);
5395
+ }
5396
+ }
5397
+ await mutatePersistedSnapshots((persistedSnapshots) => {
5398
+ let changed = false;
5399
+ for (const key of Array.from(persistedSnapshots.keys())) {
5400
+ if (!allowed.has(key)) {
5401
+ changed = persistedSnapshots.delete(key) || changed;
5402
+ }
5403
+ }
5404
+ return changed;
5405
+ });
5406
+ }
5407
+
5294
5408
  // ../../packages/runtime-profiles/src/profiles/profile-manager.ts
5295
5409
  var TOKEN_EXPIRING_SOON_WINDOW_MS = 15 * 60 * 1e3;
5296
5410
  var REFRESH_TOKEN_REDEEMED_SNIPPET2 = "refresh token was already used";
@@ -5449,6 +5563,20 @@ var ProfileManager = class {
5449
5563
  delete map[name];
5450
5564
  await this.writeProfilesStateMap(map);
5451
5565
  }
5566
+ rateLimitSnapshotKeysForRecord(record) {
5567
+ return Array.from(
5568
+ /* @__PURE__ */ new Set([
5569
+ this.resolveProfileIdentityFromRecord(record),
5570
+ resolveFallbackAccountKey(record.name)
5571
+ ])
5572
+ );
5573
+ }
5574
+ rateLimitSnapshotKeysForStateMap(map) {
5575
+ return Object.entries(map).flatMap(([name, raw]) => {
5576
+ const record = this.fromStateRecord(name, raw);
5577
+ return record ? this.rateLimitSnapshotKeysForRecord(record) : [];
5578
+ });
5579
+ }
5452
5580
  resolveAuthMethod(data) {
5453
5581
  const raw = typeof data?.auth_method === "string" ? data.auth_method.trim().toLowerCase() : "";
5454
5582
  return raw || "codex-cli";
@@ -6179,6 +6307,7 @@ var ProfileManager = class {
6179
6307
  }
6180
6308
  async deleteProfileRecordAndHome(record) {
6181
6309
  const profileName = this.normalizeProfileName(record.name);
6310
+ const snapshotKeys = this.rateLimitSnapshotKeysForRecord(record);
6182
6311
  if (!record.accountId) {
6183
6312
  const dashboardState = await this.readProfileDashboardState();
6184
6313
  delete dashboardState.customGroupsByAccountKey[resolveFallbackAccountKey(profileName)];
@@ -6192,6 +6321,7 @@ var ProfileManager = class {
6192
6321
  }
6193
6322
  }
6194
6323
  await this.deleteProfileRecord(profileName);
6324
+ await deleteRateLimitSnapshots(snapshotKeys);
6195
6325
  }
6196
6326
  buildProfileFromData(name, data, fallback) {
6197
6327
  const metadata = fallback?.metadata ?? this.extractProfileMetadata(data);
@@ -7105,6 +7235,7 @@ var ProfileManager = class {
7105
7235
  }
7106
7236
  if (removed.length > 0) {
7107
7237
  await this.writeProfilesStateMap(nextMap);
7238
+ await pruneRateLimitSnapshots(this.rateLimitSnapshotKeysForStateMap(nextMap));
7108
7239
  }
7109
7240
  return removed;
7110
7241
  }
@@ -7247,6 +7378,7 @@ var ProfileManager = class {
7247
7378
  nextMap[record.name] = this.toStateRecord(record);
7248
7379
  }
7249
7380
  await this.writeProfilesStateMap(nextMap);
7381
+ await pruneRateLimitSnapshots(this.rateLimitSnapshotKeysForStateMap(nextMap));
7250
7382
  let removed = 0;
7251
7383
  for (const name of existingNames) {
7252
7384
  if (normalized.has(name)) {
@@ -7720,7 +7852,7 @@ function pruneStore(store) {
7720
7852
  return store;
7721
7853
  }
7722
7854
  function resolveAccountPoolDbPath(stateDir) {
7723
- return import_node_path6.default.join(stateDir, "state.sqlite");
7855
+ return import_node_path7.default.join(stateDir, "state.sqlite");
7724
7856
  }
7725
7857
  async function readStore(stateDir) {
7726
7858
  const dbPath = resolveAccountPoolDbPath(stateDir);
@@ -7823,9 +7955,9 @@ async function listSessions(stateDir) {
7823
7955
  }
7824
7956
  function resolveRuntimeStateDir(runtime, explicitStateDir) {
7825
7957
  if (explicitStateDir) {
7826
- return import_node_path6.default.resolve(explicitStateDir);
7958
+ return import_node_path7.default.resolve(explicitStateDir);
7827
7959
  }
7828
- return import_node_path6.default.join(getUserDataDir(), DESKTOP_RPC_STATE_DIR);
7960
+ return import_node_path7.default.join(getUserDataDir(), DESKTOP_RPC_STATE_DIR);
7829
7961
  }
7830
7962
  function resolveStateDir(flags) {
7831
7963
  const runtimeFlag = parseStringFlag(flags, "--runtime")?.trim().toLowerCase();
@@ -8293,14 +8425,14 @@ function maxUsedPercent(snapshot) {
8293
8425
 
8294
8426
  // src/platform/codexCli.ts
8295
8427
  var import_node_child_process3 = require("child_process");
8296
- var import_node_fs4 = require("fs");
8297
- var import_node_path7 = __toESM(require("path"));
8428
+ var import_node_fs5 = require("fs");
8429
+ var import_node_path8 = __toESM(require("path"));
8298
8430
  var ENV_HINTS2 = ["CODEX_BINARY", "CODEX_CLI_PATH", "CODEX_PATH"];
8299
8431
  function fileExists2(candidate) {
8300
8432
  if (!candidate) return null;
8301
- const resolved = import_node_path7.default.resolve(candidate);
8433
+ const resolved = import_node_path8.default.resolve(candidate);
8302
8434
  try {
8303
- const stat2 = (0, import_node_fs4.statSync)(resolved);
8435
+ const stat2 = (0, import_node_fs5.statSync)(resolved);
8304
8436
  if (stat2.isFile()) return resolved;
8305
8437
  } catch {
8306
8438
  return null;
@@ -8318,9 +8450,9 @@ function resolveFromEnv() {
8318
8450
  }
8319
8451
  function resolveFromPath() {
8320
8452
  const pathValue = process.env.PATH ?? "";
8321
- const entries = pathValue.split(import_node_path7.default.delimiter).filter(Boolean);
8453
+ const entries = pathValue.split(import_node_path8.default.delimiter).filter(Boolean);
8322
8454
  for (const entry of entries) {
8323
- const candidate = fileExists2(import_node_path7.default.join(entry, "codex"));
8455
+ const candidate = fileExists2(import_node_path8.default.join(entry, "codex"));
8324
8456
  if (candidate) return candidate;
8325
8457
  }
8326
8458
  return null;
@@ -8698,14 +8830,14 @@ async function assertProfileCreationAllowed(profileManager) {
8698
8830
  // ../../packages/runtime-codex/src/codex/officialAppRestart.ts
8699
8831
  var import_node_child_process5 = require("child_process");
8700
8832
  var import_node_crypto5 = require("crypto");
8701
- var import_node_fs6 = require("fs");
8833
+ var import_node_fs7 = require("fs");
8702
8834
  var import_node_os3 = require("os");
8703
8835
  var import_node_net = __toESM(require("net"), 1);
8704
- var import_node_path9 = __toESM(require("path"), 1);
8836
+ var import_node_path10 = __toESM(require("path"), 1);
8705
8837
 
8706
8838
  // ../../packages/runtime-codex/src/codex/threadUsage.ts
8707
- var import_node_fs5 = require("fs");
8708
- var import_node_path8 = __toESM(require("path"), 1);
8839
+ var import_node_fs6 = require("fs");
8840
+ var import_node_path9 = __toESM(require("path"), 1);
8709
8841
  var ROLLOUT_DIRS = ["sessions", "archived_sessions"];
8710
8842
  function isRecord5(value) {
8711
8843
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -8715,7 +8847,7 @@ async function collectRolloutFiles(root) {
8715
8847
  async function visit(dir) {
8716
8848
  let entries;
8717
8849
  try {
8718
- entries = await import_node_fs5.promises.readdir(dir, {
8850
+ entries = await import_node_fs6.promises.readdir(dir, {
8719
8851
  withFileTypes: true,
8720
8852
  encoding: "utf8"
8721
8853
  });
@@ -8725,7 +8857,7 @@ async function collectRolloutFiles(root) {
8725
8857
  const childVisits = [];
8726
8858
  for (const entry of entries) {
8727
8859
  const entryName = String(entry.name);
8728
- const entryPath = import_node_path8.default.join(dir, entryName);
8860
+ const entryPath = import_node_path9.default.join(dir, entryName);
8729
8861
  if (entry.isDirectory()) {
8730
8862
  childVisits.push(visit(entryPath));
8731
8863
  continue;
@@ -8744,14 +8876,14 @@ async function findRolloutFileByScan(profileHome, threadId) {
8744
8876
  let best = null;
8745
8877
  const variants = threadIdVariants(threadId);
8746
8878
  for (const dirname of ROLLOUT_DIRS) {
8747
- const root = import_node_path8.default.join(profileHome, dirname);
8879
+ const root = import_node_path9.default.join(profileHome, dirname);
8748
8880
  const files = await collectRolloutFiles(root);
8749
8881
  for (const file of files) {
8750
- const basename = import_node_path8.default.basename(file);
8882
+ const basename = import_node_path9.default.basename(file);
8751
8883
  if (!variants.some((variant) => basename.includes(variant))) {
8752
8884
  continue;
8753
8885
  }
8754
- const stat2 = await import_node_fs5.promises.stat(file).catch(() => null);
8886
+ const stat2 = await import_node_fs6.promises.stat(file).catch(() => null);
8755
8887
  const updatedAtMs = stat2 && Number.isFinite(stat2.mtimeMs) ? stat2.mtimeMs : null;
8756
8888
  if (!best || (updatedAtMs ?? 0) > (best.updatedAtMs ?? 0) || (updatedAtMs ?? 0) === (best.updatedAtMs ?? 0) && file > best.path) {
8757
8889
  best = { path: file, updatedAtMs };
@@ -8823,12 +8955,12 @@ function resolveRolloutPath(profileHome, rolloutPath) {
8823
8955
  if (!rolloutPath) {
8824
8956
  return null;
8825
8957
  }
8826
- return import_node_path8.default.isAbsolute(rolloutPath) ? rolloutPath : import_node_path8.default.join(profileHome, rolloutPath);
8958
+ return import_node_path9.default.isAbsolute(rolloutPath) ? rolloutPath : import_node_path9.default.join(profileHome, rolloutPath);
8827
8959
  }
8828
8960
  async function readThreadRecordFromStateDb(profileHome, threadId) {
8829
- const dbPath = import_node_path8.default.join(profileHome, "state_5.sqlite");
8961
+ const dbPath = import_node_path9.default.join(profileHome, "state_5.sqlite");
8830
8962
  try {
8831
- await import_node_fs5.promises.access(dbPath);
8963
+ await import_node_fs6.promises.access(dbPath);
8832
8964
  } catch {
8833
8965
  return null;
8834
8966
  }
@@ -12935,18 +13067,18 @@ function startOfficialCodexBridgeActionListener(args) {
12935
13067
  if (!requestId || !rememberBridgeActionId(requestId)) {
12936
13068
  return;
12937
13069
  }
12938
- const path14 = typeof payload.path === "string" ? payload.path.trim().slice(0, 64) : "";
13070
+ const path15 = typeof payload.path === "string" ? payload.path.trim().slice(0, 64) : "";
12939
13071
  const requestHandler = officialCodexBridgeRequestHandler;
12940
13072
  void (async () => {
12941
13073
  let result;
12942
- if (!path14) {
13074
+ if (!path15) {
12943
13075
  result = { status: "failed", reason: "missing-path" };
12944
13076
  } else if (!requestHandler) {
12945
13077
  result = { status: "failed", reason: "no-request-handler" };
12946
13078
  } else {
12947
13079
  try {
12948
13080
  result = await requestHandler({
12949
- path: path14,
13081
+ path: path15,
12950
13082
  payload: payload.payload ?? null,
12951
13083
  sourceProfileName: profileName
12952
13084
  });
@@ -13364,7 +13496,7 @@ async function readProcessRows() {
13364
13496
  });
13365
13497
  }
13366
13498
  function getMainExecutablePath(candidate) {
13367
- return import_node_path9.default.join(candidate.appPath, "Contents", "MacOS", candidate.executableName);
13499
+ return import_node_path10.default.join(candidate.appPath, "Contents", "MacOS", candidate.executableName);
13368
13500
  }
13369
13501
  function isMainProcessRow(row, candidate) {
13370
13502
  return row.args.includes(getMainExecutablePath(candidate));
@@ -13586,15 +13718,15 @@ function classifyOpenCodexLaunchFailure(error) {
13586
13718
  }
13587
13719
  async function openCodexWithProfileHome(candidate, profileHome, profileName, cdpPort, previousPids, options = {}) {
13588
13720
  const executablePath = getMainExecutablePath(candidate);
13589
- if (!(0, import_node_fs6.existsSync)(executablePath)) {
13721
+ if (!(0, import_node_fs7.existsSync)(executablePath)) {
13590
13722
  return { opened: false, pid: null, reason: "app-executable-missing" };
13591
13723
  }
13592
13724
  const telemetryLabel = `codexuse-profile-${encodeURIComponent(profileName)}`;
13593
- const appUserDataDir = options.useDefaultUserData === false ? import_node_path9.default.join(profileHome, "codex-app-user-data") : null;
13725
+ const appUserDataDir = options.useDefaultUserData === false ? import_node_path10.default.join(profileHome, "codex-app-user-data") : null;
13594
13726
  let child;
13595
13727
  try {
13596
13728
  if (appUserDataDir) {
13597
- (0, import_node_fs6.mkdirSync)(appUserDataDir, { recursive: true });
13729
+ (0, import_node_fs7.mkdirSync)(appUserDataDir, { recursive: true });
13598
13730
  }
13599
13731
  child = (0, import_node_child_process5.spawn)(
13600
13732
  "/usr/bin/open",
@@ -13652,8 +13784,8 @@ async function openCodexWithProfileHome(candidate, profileHome, profileName, cdp
13652
13784
  };
13653
13785
  }
13654
13786
  async function readBundleString(appPath, key) {
13655
- const plistPath = import_node_path9.default.join(appPath, "Contents", "Info.plist");
13656
- if (!(0, import_node_fs6.existsSync)(plistPath)) {
13787
+ const plistPath = import_node_path10.default.join(appPath, "Contents", "Info.plist");
13788
+ if (!(0, import_node_fs7.existsSync)(plistPath)) {
13657
13789
  return null;
13658
13790
  }
13659
13791
  const result = await runCommand2("/usr/bin/plutil", [
@@ -13673,7 +13805,7 @@ async function readBundleString(appPath, key) {
13673
13805
  async function collectCodexAppCandidates(rawPaths) {
13674
13806
  const candidates = [];
13675
13807
  for (const appPath of rawPaths) {
13676
- if (!(0, import_node_fs6.existsSync)(appPath) || import_node_path9.default.basename(appPath) !== "Codex.app") {
13808
+ if (!(0, import_node_fs7.existsSync)(appPath) || import_node_path10.default.basename(appPath) !== "Codex.app") {
13677
13809
  continue;
13678
13810
  }
13679
13811
  const bundleId = await readBundleString(appPath, "CFBundleIdentifier");
@@ -13690,7 +13822,7 @@ async function collectCodexAppCandidates(rawPaths) {
13690
13822
  return candidates.sort((a, b) => a.appPath.localeCompare(b.appPath));
13691
13823
  }
13692
13824
  function addCodexAppPathsFromDirectory(rawPaths, rootPath, maxDepth = 2) {
13693
- if (!(0, import_node_fs6.existsSync)(rootPath)) {
13825
+ if (!(0, import_node_fs7.existsSync)(rootPath)) {
13694
13826
  return;
13695
13827
  }
13696
13828
  const pending = [{ directory: rootPath, depth: 0 }];
@@ -13698,7 +13830,7 @@ function addCodexAppPathsFromDirectory(rawPaths, rootPath, maxDepth = 2) {
13698
13830
  const current = pending.shift();
13699
13831
  let entries;
13700
13832
  try {
13701
- entries = (0, import_node_fs6.readdirSync)(current.directory, { withFileTypes: true });
13833
+ entries = (0, import_node_fs7.readdirSync)(current.directory, { withFileTypes: true });
13702
13834
  } catch {
13703
13835
  continue;
13704
13836
  }
@@ -13706,7 +13838,7 @@ function addCodexAppPathsFromDirectory(rawPaths, rootPath, maxDepth = 2) {
13706
13838
  if (!entry.isDirectory()) {
13707
13839
  continue;
13708
13840
  }
13709
- const childPath = import_node_path9.default.join(current.directory, entry.name);
13841
+ const childPath = import_node_path10.default.join(current.directory, entry.name);
13710
13842
  if (entry.name === "Codex.app") {
13711
13843
  rawPaths.add(childPath);
13712
13844
  continue;
@@ -13729,9 +13861,9 @@ async function discoverCodexAppCandidates() {
13729
13861
  rawPaths.add(envPath);
13730
13862
  }
13731
13863
  rawPaths.add("/Applications/Codex.app");
13732
- rawPaths.add(import_node_path9.default.join((0, import_node_os3.homedir)(), "Applications", "Codex.app"));
13864
+ rawPaths.add(import_node_path10.default.join((0, import_node_os3.homedir)(), "Applications", "Codex.app"));
13733
13865
  addCodexAppPathsFromDirectory(rawPaths, "/Applications");
13734
- addCodexAppPathsFromDirectory(rawPaths, import_node_path9.default.join((0, import_node_os3.homedir)(), "Applications"));
13866
+ addCodexAppPathsFromDirectory(rawPaths, import_node_path10.default.join((0, import_node_os3.homedir)(), "Applications"));
13735
13867
  const sorted = await collectCodexAppCandidates(rawPaths);
13736
13868
  appDiscoveryCache = {
13737
13869
  envPath,
@@ -13742,7 +13874,7 @@ async function discoverCodexAppCandidates() {
13742
13874
  }
13743
13875
  function getRunningCodexPidsFromRows(candidate, rows) {
13744
13876
  const pids = /* @__PURE__ */ new Set();
13745
- const appContentsRoot = `${import_node_path9.default.join(candidate.appPath, "Contents")}${import_node_path9.default.sep}`;
13877
+ const appContentsRoot = `${import_node_path10.default.join(candidate.appPath, "Contents")}${import_node_path10.default.sep}`;
13746
13878
  for (const row of rows) {
13747
13879
  if (row.args.includes(appContentsRoot)) {
13748
13880
  pids.add(row.pid);
@@ -13752,7 +13884,7 @@ function getRunningCodexPidsFromRows(candidate, rows) {
13752
13884
  }
13753
13885
  function getRunningCodexMainPidsFromRows(candidate, rows) {
13754
13886
  const pids = /* @__PURE__ */ new Set();
13755
- const executablePath = import_node_path9.default.join(
13887
+ const executablePath = import_node_path10.default.join(
13756
13888
  candidate.appPath,
13757
13889
  "Contents",
13758
13890
  "MacOS",
@@ -13783,7 +13915,7 @@ async function resolveCodexAppTarget() {
13783
13915
  const mainPids = getRunningCodexMainPidsFromRows(fallback, rows);
13784
13916
  return { candidate: fallback, runningPids, mainPids };
13785
13917
  }
13786
- var SHARED_CODEX_HOME = import_node_path9.default.join((0, import_node_os3.homedir)(), ".codex");
13918
+ var SHARED_CODEX_HOME = import_node_path10.default.join((0, import_node_os3.homedir)(), ".codex");
13787
13919
  function toIso(value) {
13788
13920
  return typeof value === "number" && Number.isFinite(value) ? new Date(value).toISOString() : null;
13789
13921
  }
@@ -15544,7 +15676,7 @@ var import_toml3 = __toESM(require_toml(), 1);
15544
15676
  // ../../packages/runtime-codex/src/codex/config-metadata.ts
15545
15677
  var import_node_child_process6 = require("child_process");
15546
15678
  var import_promises = require("fs/promises");
15547
- var import_node_path10 = __toESM(require("path"), 1);
15679
+ var import_node_path11 = __toESM(require("path"), 1);
15548
15680
  var CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/openai/codex/main/codex-rs/core/config.schema.json";
15549
15681
  var METADATA_CACHE_TTL_MS = 6e4;
15550
15682
  var FALLBACK_SCHEMA_TOP_LEVEL_KEYS = [
@@ -15730,8 +15862,8 @@ function parseSchemaKeys(schemaRaw) {
15730
15862
  async function readSchemaFromLocal() {
15731
15863
  const candidates = [
15732
15864
  process.env.CODEX_CONFIG_SCHEMA_PATH,
15733
- import_node_path10.default.join(process.cwd(), "codex-rs", "core", "config.schema.json"),
15734
- import_node_path10.default.join(process.cwd(), "node_modules", "@openai", "codex", "codex-rs", "core", "config.schema.json")
15865
+ import_node_path11.default.join(process.cwd(), "codex-rs", "core", "config.schema.json"),
15866
+ import_node_path11.default.join(process.cwd(), "node_modules", "@openai", "codex", "codex-rs", "core", "config.schema.json")
15735
15867
  ].filter((candidate) => Boolean(candidate));
15736
15868
  for (const candidate of candidates) {
15737
15869
  try {
@@ -15836,11 +15968,11 @@ async function getCodexConfigMetadata(forceRefresh = false) {
15836
15968
 
15837
15969
  // ../../packages/runtime-codex/src/codex/config-io.ts
15838
15970
  var import_promises2 = require("fs/promises");
15839
- var import_node_path12 = __toESM(require("path"), 1);
15971
+ var import_node_path13 = __toESM(require("path"), 1);
15840
15972
 
15841
15973
  // ../../packages/runtime-codex/src/codex/home.ts
15842
15974
  var import_node_os4 = __toESM(require("os"), 1);
15843
- var import_node_path11 = __toESM(require("path"), 1);
15975
+ var import_node_path12 = __toESM(require("path"), 1);
15844
15976
  function resolveHomeDir() {
15845
15977
  return process.env.HOME || import_node_os4.default.homedir();
15846
15978
  }
@@ -15849,7 +15981,7 @@ function expandHomePrefix(input, homeDir) {
15849
15981
  return homeDir;
15850
15982
  }
15851
15983
  if (input.startsWith("~/") || input.startsWith("~\\")) {
15852
- return import_node_path11.default.join(homeDir, input.slice(2));
15984
+ return import_node_path12.default.join(homeDir, input.slice(2));
15853
15985
  }
15854
15986
  return input;
15855
15987
  }
@@ -15865,10 +15997,10 @@ function normalizeCodexHomePath(input) {
15865
15997
  if (!configured) {
15866
15998
  return null;
15867
15999
  }
15868
- return import_node_path11.default.resolve(expandHomePrefix(configured, resolveHomeDir()));
16000
+ return import_node_path12.default.resolve(expandHomePrefix(configured, resolveHomeDir()));
15869
16001
  }
15870
16002
  function resolveDefaultCodexHomeDir() {
15871
- return import_node_path11.default.join(resolveHomeDir(), ".codex");
16003
+ return import_node_path12.default.join(resolveHomeDir(), ".codex");
15872
16004
  }
15873
16005
  function resolveCodexHomeDir(options) {
15874
16006
  return normalizeCodexHomePath(options?.codexHomePath) ?? resolveDefaultCodexHomeDir();
@@ -15941,10 +16073,10 @@ var YOLO_PRESET = {
15941
16073
 
15942
16074
  // ../../packages/runtime-codex/src/codex/config-io.ts
15943
16075
  function getConfigPath(options) {
15944
- return import_node_path12.default.join(resolveCodexHomeDir(options), "config.toml");
16076
+ return import_node_path13.default.join(resolveCodexHomeDir(options), "config.toml");
15945
16077
  }
15946
16078
  async function ensureConfigDirExists(filePath) {
15947
- const dir = import_node_path12.default.dirname(filePath);
16079
+ const dir = import_node_path13.default.dirname(filePath);
15948
16080
  await (0, import_promises2.mkdir)(dir, { recursive: true });
15949
16081
  }
15950
16082
  function normalizeLineEndings(content) {
@@ -17103,7 +17235,7 @@ async function ensureCliStorageReady() {
17103
17235
  }
17104
17236
 
17105
17237
  // src/app/main.ts
17106
- var VERSION = true ? "5.0.8" : "0.0.0";
17238
+ var VERSION = true ? "5.0.9" : "0.0.0";
17107
17239
  async function runCli() {
17108
17240
  const args = process.argv.slice(2);
17109
17241
  if (args.length === 0) {