chatroom-cli 1.91.2 → 1.91.4

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
@@ -29879,6 +29879,71 @@ function resolveCodexSdkPackageJson(chatroomCliRoot) {
29879
29879
  throw new CodexSdkPackageError(`Could not locate @openai/codex-sdk package.json from ${chatroomCliRoot}. ${REINSTALL_HINT2}`);
29880
29880
  }
29881
29881
  }
29882
+ function resolveTargetTriple() {
29883
+ const { platform, arch } = process;
29884
+ if (platform === "linux" && arch === "x64")
29885
+ return "x86_64-unknown-linux-musl";
29886
+ if (platform === "linux" && arch === "arm64")
29887
+ return "aarch64-unknown-linux-musl";
29888
+ if (platform === "darwin" && arch === "x64")
29889
+ return "x86_64-apple-darwin";
29890
+ if (platform === "darwin" && arch === "arm64")
29891
+ return "aarch64-apple-darwin";
29892
+ if (platform === "win32" && arch === "x64")
29893
+ return "x86_64-pc-windows-msvc";
29894
+ if (platform === "win32" && arch === "arm64")
29895
+ return "aarch64-pc-windows-msvc";
29896
+ throw new CodexSdkPackageError(`Unsupported platform for ${CODEX_NPM_NAME}: ${platform}-${arch}. ${REINSTALL_HINT2}`);
29897
+ }
29898
+ function resolvePlatformPackageName2(targetTriple) {
29899
+ const pkg = PLATFORM_PACKAGE_BY_TARGET[targetTriple];
29900
+ if (!pkg) {
29901
+ throw new CodexSdkPackageError(`Unsupported platform for ${CODEX_NPM_NAME}: ${targetTriple}. ${REINSTALL_HINT2}`);
29902
+ }
29903
+ return pkg;
29904
+ }
29905
+ function resolveCodexExecutablePath(moduleRef = import.meta.url) {
29906
+ if (cachedExecutablePath2)
29907
+ return cachedExecutablePath2;
29908
+ const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
29909
+ const require3 = createRequire4(join8(chatroomCliRoot, "package.json"));
29910
+ let codexPackageDir;
29911
+ try {
29912
+ codexPackageDir = dirname3(require3.resolve(`${CODEX_NPM_NAME}/package.json`, { paths: [chatroomCliRoot] }));
29913
+ } catch {
29914
+ throw new CodexSdkPackageError(`${CODEX_NPM_NAME} is not installed. Ensure chatroom-cli was installed with optional dependencies. ${REINSTALL_HINT2}`);
29915
+ }
29916
+ const targetTriple = resolveTargetTriple();
29917
+ const platformPkg = resolvePlatformPackageName2(targetTriple);
29918
+ const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
29919
+ let platformPkgDir;
29920
+ try {
29921
+ const platformPackageJson = [codexPackageDir, chatroomCliRoot].map((resolveFrom) => {
29922
+ try {
29923
+ return require3.resolve(`${platformPkg}/package.json`, { paths: [resolveFrom] });
29924
+ } catch {
29925
+ return;
29926
+ }
29927
+ }).find((resolved) => resolved !== undefined);
29928
+ if (!platformPackageJson) {
29929
+ throw new Error(`Unable to resolve ${platformPkg}`);
29930
+ }
29931
+ platformPkgDir = dirname3(platformPackageJson);
29932
+ } catch {
29933
+ throw new CodexSdkPackageError(`Native Codex CLI package ${platformPkg} is not installed. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies. ${REINSTALL_HINT2}`);
29934
+ }
29935
+ const packageBinaryPath = join8(platformPkgDir, "vendor", targetTriple, "bin", codexBinaryName);
29936
+ const legacyBinaryPath = join8(platformPkgDir, "vendor", targetTriple, "codex", codexBinaryName);
29937
+ if (existsSync2(packageBinaryPath)) {
29938
+ cachedExecutablePath2 = packageBinaryPath;
29939
+ return cachedExecutablePath2;
29940
+ }
29941
+ if (existsSync2(legacyBinaryPath)) {
29942
+ cachedExecutablePath2 = legacyBinaryPath;
29943
+ return cachedExecutablePath2;
29944
+ }
29945
+ throw new CodexSdkPackageError(`Unable to locate Codex CLI binaries for ${targetTriple}. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies. ${REINSTALL_HINT2}`);
29946
+ }
29882
29947
  async function importBundledCodexSdk(moduleRef = import.meta.url) {
29883
29948
  const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
29884
29949
  const pinnedVersion = readPinnedSdkVersion2(chatroomCliRoot);
@@ -29887,11 +29952,11 @@ async function importBundledCodexSdk(moduleRef = import.meta.url) {
29887
29952
  if (installedVersion !== pinnedVersion) {
29888
29953
  throw new CodexSdkPackageError(`@openai/codex-sdk@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT2}`);
29889
29954
  }
29890
- const entryPath = join8(dirname3(packageJsonPath), "dist", "index.js");
29891
- if (!existsSync2(entryPath)) {
29892
- throw new CodexSdkPackageError(`@openai/codex-sdk entry file is missing: ${entryPath}. ${REINSTALL_HINT2}`);
29955
+ const distEntryPath = join8(dirname3(packageJsonPath), "dist", "index.js");
29956
+ if (!existsSync2(distEntryPath)) {
29957
+ throw new CodexSdkPackageError(`@openai/codex-sdk entry file is missing: ${distEntryPath}. ${REINSTALL_HINT2}`);
29893
29958
  }
29894
- return import(pathToFileURL2(entryPath).href);
29959
+ return import(pathToFileURL2(distEntryPath).href);
29895
29960
  }
29896
29961
  function getBundledCodexSdkVersion(moduleRef = import.meta.url) {
29897
29962
  const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
@@ -29908,12 +29973,28 @@ function formatCodexSdkError(err) {
29908
29973
  }
29909
29974
  function formatCodexSdkLoadError(err) {
29910
29975
  if (err instanceof CodexSdkPackageError) {
29911
- return err.message;
29976
+ const message2 = err.message;
29977
+ if ((message2.includes("Codex CLI") || message2.includes("optional dependencies")) && !message2.includes(REINSTALL_HINT2)) {
29978
+ return `${message2} ${REINSTALL_HINT2}`;
29979
+ }
29980
+ return message2;
29981
+ }
29982
+ const message = err instanceof Error ? err.message : String(err);
29983
+ if (message.includes("Codex CLI") || message.includes("optional dependencies")) {
29984
+ return `${message} ${REINSTALL_HINT2}`;
29912
29985
  }
29913
29986
  return formatCodexSdkError(err);
29914
29987
  }
29915
- var REINSTALL_HINT2 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", CodexSdkPackageError;
29988
+ var REINSTALL_HINT2 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", CODEX_NPM_NAME = "@openai/codex", PLATFORM_PACKAGE_BY_TARGET, CodexSdkPackageError, cachedExecutablePath2;
29916
29989
  var init_codex_sdk_package = __esm(() => {
29990
+ PLATFORM_PACKAGE_BY_TARGET = {
29991
+ "x86_64-unknown-linux-musl": "@openai/codex-linux-x64",
29992
+ "aarch64-unknown-linux-musl": "@openai/codex-linux-arm64",
29993
+ "x86_64-apple-darwin": "@openai/codex-darwin-x64",
29994
+ "aarch64-apple-darwin": "@openai/codex-darwin-arm64",
29995
+ "x86_64-pc-windows-msvc": "@openai/codex-win32-x64",
29996
+ "aarch64-pc-windows-msvc": "@openai/codex-win32-arm64"
29997
+ };
29917
29998
  CodexSdkPackageError = class CodexSdkPackageError extends Error {
29918
29999
  code = "CODEX_SDK_PACKAGE_INCOMPLETE";
29919
30000
  constructor(message) {
@@ -30354,6 +30435,7 @@ var init_codex_sdk_agent_service = __esm(() => {
30354
30435
  async isInstalled() {
30355
30436
  try {
30356
30437
  await loadSdk2();
30438
+ resolveCodexExecutablePath();
30357
30439
  return true;
30358
30440
  } catch (err) {
30359
30441
  console.warn(`[codex-sdk] unavailable: ${formatCodexSdkLoadError(err)}`);
@@ -30697,7 +30779,11 @@ ${options.prompt}`;
30697
30779
  let thread;
30698
30780
  try {
30699
30781
  const { Codex } = await loadSdk2();
30700
- codex = new Codex({ env: buildCodexEnv(options.resolvedConvexUrl) });
30782
+ const codexPath = resolveCodexExecutablePath();
30783
+ codex = new Codex({
30784
+ codexPathOverride: codexPath,
30785
+ env: buildCodexEnv(options.resolvedConvexUrl)
30786
+ });
30701
30787
  thread = codex.startThread(buildThreadOptions(options.workingDir, variant));
30702
30788
  } catch (err) {
30703
30789
  writeSpawnError2(buildAgentLogPrefix("codex-sdk", context5), err);
@@ -30724,7 +30810,11 @@ ${options.prompt}`;
30724
30810
  const pid = keeper.pid;
30725
30811
  const variant = decodeCodexVariant(options.model ?? stored.model);
30726
30812
  const { Codex } = await loadSdk2();
30727
- const codex = new Codex({ env: buildCodexEnv(options.resolvedConvexUrl) });
30813
+ const codexPath = resolveCodexExecutablePath();
30814
+ const codex = new Codex({
30815
+ codexPathOverride: codexPath,
30816
+ env: buildCodexEnv(options.resolvedConvexUrl)
30817
+ });
30728
30818
  const thread = codex.resumeThread(stored.harnessSessionId, buildThreadOptions(stored.workingDir, variant));
30729
30819
  return this.startRunningSession({
30730
30820
  pid,
@@ -117714,4 +117804,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
117714
117804
  });
117715
117805
  program2.parse();
117716
117806
 
117717
- //# debugId=E1D1B59D5776760164756E2164756E21
117807
+ //# debugId=E74FDA2AD007D39564756E2164756E21