codexuse-cli 5.2.6 → 5.2.8

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
@@ -10629,6 +10629,11 @@ var COMMAND_TIMEOUT_MS = 3e3;
10629
10629
  var EXIT_WAIT_MS = 1e4;
10630
10630
  var POLL_INTERVAL_MS = 250;
10631
10631
  var PROCESS_EXIT_GRACE_MS = 15e3;
10632
+ var LIVE_SWITCH_RETRY_DELAY_MS = 3e3;
10633
+ var LAUNCH_VERIFY_RETRIES = (() => {
10634
+ const raw = Number(process.env.CODEXUSE_LAUNCH_RETRIES);
10635
+ return Number.isInteger(raw) && raw > 0 ? raw : 3;
10636
+ })();
10632
10637
  var APP_DISCOVERY_CACHE_TTL_MS = 6e4;
10633
10638
  var APP_DISCOVERY_MISS_CACHE_TTL_MS = 5e3;
10634
10639
  var OFFICIAL_CODEX_ACTIVITY_LIMIT = 50;
@@ -10640,6 +10645,9 @@ var CODEXUSE_BRIDGE_BINDING_NAME = "__codexuseBridgeBinding";
10640
10645
  var CODEXUSE_BRIDGE_INSTALL_TTL_MS = 5e3;
10641
10646
  var CODEXUSE_BRIDGE_VERSION = "0.2.0";
10642
10647
  var CODEXUSE_STALE_LAUNCH_GRACE_MS = 45e3;
10648
+ function sleep2(ms) {
10649
+ return new Promise((resolve) => setTimeout(resolve, ms));
10650
+ }
10643
10651
  var officialCodexBridgeActionHandler = null;
10644
10652
  var bridgeActionListeners = /* @__PURE__ */ new Map();
10645
10653
  var handledBridgeActionIds = [];
@@ -15450,7 +15458,7 @@ async function resolveInstanceRuntimeState(args) {
15450
15458
  args.rows
15451
15459
  );
15452
15460
  return {
15453
- running: appServerPid2 !== null,
15461
+ running: false,
15454
15462
  appServerPid: appServerPid2,
15455
15463
  startedAt: null
15456
15464
  };
@@ -15462,7 +15470,7 @@ async function resolveInstanceRuntimeState(args) {
15462
15470
  args.rows
15463
15471
  );
15464
15472
  return {
15465
- running: appServerPid2 !== null,
15473
+ running: false,
15466
15474
  appServerPid: appServerPid2,
15467
15475
  startedAt: null
15468
15476
  };
@@ -15594,35 +15602,6 @@ async function collectCodexAppCandidates(rawPaths) {
15594
15602
  }
15595
15603
  return candidates.sort((a, b) => a.appPath.localeCompare(b.appPath));
15596
15604
  }
15597
- function addCodexAppPathsFromDirectory(rawPaths, rootPath, maxDepth = 2) {
15598
- if (!(0, import_node_fs7.existsSync)(rootPath)) {
15599
- return;
15600
- }
15601
- const pending = [{ directory: rootPath, depth: 0 }];
15602
- while (pending.length > 0) {
15603
- const current = pending.shift();
15604
- let entries;
15605
- try {
15606
- entries = (0, import_node_fs7.readdirSync)(current.directory, { withFileTypes: true });
15607
- } catch {
15608
- continue;
15609
- }
15610
- for (const entry of entries) {
15611
- if (!entry.isDirectory()) {
15612
- continue;
15613
- }
15614
- const childPath = import_node_path13.default.join(current.directory, entry.name);
15615
- if (entry.name === "Codex.app") {
15616
- rawPaths.add(childPath);
15617
- continue;
15618
- }
15619
- if (entry.name.endsWith(".app") || current.depth >= maxDepth) {
15620
- continue;
15621
- }
15622
- pending.push({ directory: childPath, depth: current.depth + 1 });
15623
- }
15624
- }
15625
- }
15626
15605
  async function discoverCodexAppCandidates() {
15627
15606
  const now = Date.now();
15628
15607
  const envPath = process.env.CODEXUSE_OFFICIAL_CODEX_APP_PATH?.trim() || null;
@@ -15635,8 +15614,6 @@ async function discoverCodexAppCandidates() {
15635
15614
  }
15636
15615
  rawPaths.add("/Applications/Codex.app");
15637
15616
  rawPaths.add(import_node_path13.default.join((0, import_node_os4.homedir)(), "Applications", "Codex.app"));
15638
- addCodexAppPathsFromDirectory(rawPaths, "/Applications");
15639
- addCodexAppPathsFromDirectory(rawPaths, import_node_path13.default.join((0, import_node_os4.homedir)(), "Applications"));
15640
15617
  const sorted = await collectCodexAppCandidates(rawPaths);
15641
15618
  appDiscoveryCache = {
15642
15619
  envPath,
@@ -15908,7 +15885,20 @@ async function getOfficialCodexProfileInstances(options = {}) {
15908
15885
  };
15909
15886
  }
15910
15887
  function launchOfficialCodexProfileInstance(options) {
15911
- return enqueueProfileAction(() => launchOfficialCodexProfileInstanceOnce(options));
15888
+ return enqueueProfileAction(
15889
+ () => launchOfficialCodexProfileInstanceWithRetries(options)
15890
+ );
15891
+ }
15892
+ async function launchOfficialCodexProfileInstanceWithRetries(options) {
15893
+ let launched = await launchOfficialCodexProfileInstanceOnce(options);
15894
+ for (let attempt = 1; attempt < LAUNCH_VERIFY_RETRIES; attempt += 1) {
15895
+ if (launched.status !== "failed" || launched.reason !== "app-server-not-verified") {
15896
+ break;
15897
+ }
15898
+ await sleep2(LIVE_SWITCH_RETRY_DELAY_MS);
15899
+ launched = await launchOfficialCodexProfileInstanceOnce(options);
15900
+ }
15901
+ return launched;
15912
15902
  }
15913
15903
  async function launchOfficialCodexProfileInstanceOnce(options) {
15914
15904
  if (process.platform !== "darwin") {
@@ -15986,6 +15976,10 @@ async function launchOfficialCodexProfileInstanceOnce(options) {
15986
15976
  reason: null
15987
15977
  };
15988
15978
  }
15979
+ if (runtime.appServerPid !== null) {
15980
+ await stopProcessTree(runtime.appServerPid, rows);
15981
+ launchBaselineMainPids = (await readProcessRows()).filter((row) => isMainProcessRow(row, candidate)).map((row) => row.pid);
15982
+ }
15989
15983
  }
15990
15984
  let cdpPort;
15991
15985
  try {
@@ -17345,9 +17339,11 @@ function formatErrorResponse(raw, status) {
17345
17339
  }
17346
17340
  }
17347
17341
  } catch {
17348
- return trimmed;
17349
17342
  }
17350
- return trimmed;
17343
+ if (trimmed.startsWith("<")) {
17344
+ return `Cloud sync request failed (${status}).`;
17345
+ }
17346
+ return trimmed.length > 500 ? `${trimmed.slice(0, 500)}...` : trimmed;
17351
17347
  }
17352
17348
  return `Cloud sync request failed (${status}).`;
17353
17349
  }
@@ -18227,7 +18223,7 @@ async function ensureCliStorageReady() {
18227
18223
  }
18228
18224
 
18229
18225
  // src/app/main.ts
18230
- var VERSION = true ? "5.2.6" : "0.0.0";
18226
+ var VERSION = true ? "5.2.8" : "0.0.0";
18231
18227
  async function runCli() {
18232
18228
  const args = process.argv.slice(2);
18233
18229
  if (args.length === 0) {