chatroom-cli 1.91.2 → 1.91.3

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,60 @@ 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
+ try {
29911
+ require3.resolve(`${CODEX_NPM_NAME}/package.json`, { paths: [chatroomCliRoot] });
29912
+ } catch {
29913
+ throw new CodexSdkPackageError(`${CODEX_NPM_NAME} is not installed. Ensure chatroom-cli was installed with optional dependencies. ${REINSTALL_HINT2}`);
29914
+ }
29915
+ const targetTriple = resolveTargetTriple();
29916
+ const platformPkg = resolvePlatformPackageName2(targetTriple);
29917
+ const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
29918
+ let platformPkgDir;
29919
+ try {
29920
+ platformPkgDir = dirname3(require3.resolve(`${platformPkg}/package.json`, { paths: [chatroomCliRoot] }));
29921
+ } catch {
29922
+ throw new CodexSdkPackageError(`Native Codex CLI package ${platformPkg} is not installed. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies. ${REINSTALL_HINT2}`);
29923
+ }
29924
+ const packageBinaryPath = join8(platformPkgDir, "vendor", targetTriple, "bin", codexBinaryName);
29925
+ const legacyBinaryPath = join8(platformPkgDir, "vendor", targetTriple, "codex", codexBinaryName);
29926
+ if (existsSync2(packageBinaryPath)) {
29927
+ cachedExecutablePath2 = packageBinaryPath;
29928
+ return cachedExecutablePath2;
29929
+ }
29930
+ if (existsSync2(legacyBinaryPath)) {
29931
+ cachedExecutablePath2 = legacyBinaryPath;
29932
+ return cachedExecutablePath2;
29933
+ }
29934
+ throw new CodexSdkPackageError(`Unable to locate Codex CLI binaries for ${targetTriple}. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies. ${REINSTALL_HINT2}`);
29935
+ }
29882
29936
  async function importBundledCodexSdk(moduleRef = import.meta.url) {
29883
29937
  const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
29884
29938
  const pinnedVersion = readPinnedSdkVersion2(chatroomCliRoot);
@@ -29887,11 +29941,11 @@ async function importBundledCodexSdk(moduleRef = import.meta.url) {
29887
29941
  if (installedVersion !== pinnedVersion) {
29888
29942
  throw new CodexSdkPackageError(`@openai/codex-sdk@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT2}`);
29889
29943
  }
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}`);
29944
+ const distEntryPath = join8(dirname3(packageJsonPath), "dist", "index.js");
29945
+ if (!existsSync2(distEntryPath)) {
29946
+ throw new CodexSdkPackageError(`@openai/codex-sdk entry file is missing: ${distEntryPath}. ${REINSTALL_HINT2}`);
29893
29947
  }
29894
- return import(pathToFileURL2(entryPath).href);
29948
+ return import(pathToFileURL2(distEntryPath).href);
29895
29949
  }
29896
29950
  function getBundledCodexSdkVersion(moduleRef = import.meta.url) {
29897
29951
  const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
@@ -29908,12 +29962,28 @@ function formatCodexSdkError(err) {
29908
29962
  }
29909
29963
  function formatCodexSdkLoadError(err) {
29910
29964
  if (err instanceof CodexSdkPackageError) {
29911
- return err.message;
29965
+ const message2 = err.message;
29966
+ if ((message2.includes("Codex CLI") || message2.includes("optional dependencies")) && !message2.includes(REINSTALL_HINT2)) {
29967
+ return `${message2} ${REINSTALL_HINT2}`;
29968
+ }
29969
+ return message2;
29970
+ }
29971
+ const message = err instanceof Error ? err.message : String(err);
29972
+ if (message.includes("Codex CLI") || message.includes("optional dependencies")) {
29973
+ return `${message} ${REINSTALL_HINT2}`;
29912
29974
  }
29913
29975
  return formatCodexSdkError(err);
29914
29976
  }
29915
- var REINSTALL_HINT2 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", CodexSdkPackageError;
29977
+ var REINSTALL_HINT2 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", CODEX_NPM_NAME = "@openai/codex", PLATFORM_PACKAGE_BY_TARGET, CodexSdkPackageError, cachedExecutablePath2;
29916
29978
  var init_codex_sdk_package = __esm(() => {
29979
+ PLATFORM_PACKAGE_BY_TARGET = {
29980
+ "x86_64-unknown-linux-musl": "@openai/codex-linux-x64",
29981
+ "aarch64-unknown-linux-musl": "@openai/codex-linux-arm64",
29982
+ "x86_64-apple-darwin": "@openai/codex-darwin-x64",
29983
+ "aarch64-apple-darwin": "@openai/codex-darwin-arm64",
29984
+ "x86_64-pc-windows-msvc": "@openai/codex-win32-x64",
29985
+ "aarch64-pc-windows-msvc": "@openai/codex-win32-arm64"
29986
+ };
29917
29987
  CodexSdkPackageError = class CodexSdkPackageError extends Error {
29918
29988
  code = "CODEX_SDK_PACKAGE_INCOMPLETE";
29919
29989
  constructor(message) {
@@ -30354,6 +30424,7 @@ var init_codex_sdk_agent_service = __esm(() => {
30354
30424
  async isInstalled() {
30355
30425
  try {
30356
30426
  await loadSdk2();
30427
+ resolveCodexExecutablePath();
30357
30428
  return true;
30358
30429
  } catch (err) {
30359
30430
  console.warn(`[codex-sdk] unavailable: ${formatCodexSdkLoadError(err)}`);
@@ -30697,7 +30768,11 @@ ${options.prompt}`;
30697
30768
  let thread;
30698
30769
  try {
30699
30770
  const { Codex } = await loadSdk2();
30700
- codex = new Codex({ env: buildCodexEnv(options.resolvedConvexUrl) });
30771
+ const codexPath = resolveCodexExecutablePath();
30772
+ codex = new Codex({
30773
+ codexPathOverride: codexPath,
30774
+ env: buildCodexEnv(options.resolvedConvexUrl)
30775
+ });
30701
30776
  thread = codex.startThread(buildThreadOptions(options.workingDir, variant));
30702
30777
  } catch (err) {
30703
30778
  writeSpawnError2(buildAgentLogPrefix("codex-sdk", context5), err);
@@ -30724,7 +30799,11 @@ ${options.prompt}`;
30724
30799
  const pid = keeper.pid;
30725
30800
  const variant = decodeCodexVariant(options.model ?? stored.model);
30726
30801
  const { Codex } = await loadSdk2();
30727
- const codex = new Codex({ env: buildCodexEnv(options.resolvedConvexUrl) });
30802
+ const codexPath = resolveCodexExecutablePath();
30803
+ const codex = new Codex({
30804
+ codexPathOverride: codexPath,
30805
+ env: buildCodexEnv(options.resolvedConvexUrl)
30806
+ });
30728
30807
  const thread = codex.resumeThread(stored.harnessSessionId, buildThreadOptions(stored.workingDir, variant));
30729
30808
  return this.startRunningSession({
30730
30809
  pid,
@@ -117714,4 +117793,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
117714
117793
  });
117715
117794
  program2.parse();
117716
117795
 
117717
- //# debugId=E1D1B59D5776760164756E2164756E21
117796
+ //# debugId=7232F20998B29AC964756E2164756E21