replicas-engine 0.1.417 → 0.1.418

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.
Files changed (2) hide show
  1. package/dist/src/index.js +43 -2
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -490,7 +490,7 @@ var WORKSPACE_SIZES = ["small", "large"];
490
490
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
491
491
 
492
492
  // ../shared/src/e2b.ts
493
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-09-v6";
493
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-09-v7";
494
494
 
495
495
  // ../shared/src/runtime-env.ts
496
496
  function parsePosixEnvFile(content) {
@@ -2523,6 +2523,22 @@ function isCodexAuthError(error) {
2523
2523
  return lower.includes("unauthorized") || lower.includes("authentication") || lower.includes("invalid api key") || lower.includes("incorrect api key") || lower.includes("api key") && lower.includes("invalid") || lower.includes("401") || lower.includes('codexerrorinfo="unauthorized"') || lower.includes("codexerrorinfo=unauthorized") || lower.includes("failed to refresh token") || lower.includes("your session has ended");
2524
2524
  }
2525
2525
 
2526
+ // ../shared/src/version.ts
2527
+ function compareVersions(v1, v2) {
2528
+ const parts1 = v1.split(".").map(Number);
2529
+ const parts2 = v2.split(".").map(Number);
2530
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
2531
+ const num1 = parts1[i] || 0;
2532
+ const num2 = parts2[i] || 0;
2533
+ if (num1 > num2) return 1;
2534
+ if (num1 < num2) return -1;
2535
+ }
2536
+ return 0;
2537
+ }
2538
+ function isVersionBelow(version, minimum) {
2539
+ return compareVersions(version, minimum) < 0;
2540
+ }
2541
+
2526
2542
  // ../shared/src/engine/environment.ts
2527
2543
  var DESKTOP_NOVNC_PORT = 6080;
2528
2544
 
@@ -8253,7 +8269,10 @@ var AspClient = class {
8253
8269
  // src/managers/codex-asp/app-server-process.ts
8254
8270
  var DEFAULT_CODEX_BINARY = "codex";
8255
8271
  var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
8256
- var ENGINE_PACKAGE_VERSION = "0.1.417";
8272
+ var MIN_CODEX_CLI_VERSION = "0.144.0";
8273
+ var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
8274
+ var codexCliVersionEnsured = null;
8275
+ var ENGINE_PACKAGE_VERSION = "0.1.418";
8257
8276
  var INITIALIZE_METHOD = "initialize";
8258
8277
  var INITIALIZED_NOTIFICATION = "initialized";
8259
8278
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -8280,6 +8299,7 @@ var AppServerProcess = class {
8280
8299
  return { client: this.client };
8281
8300
  }
8282
8301
  this.shuttingDown = false;
8302
+ await this.ensureMinCodexCliVersion();
8283
8303
  const child = spawn3(this.binary, this.args, {
8284
8304
  cwd: this.cwd,
8285
8305
  env: this.env,
@@ -8369,6 +8389,27 @@ var AppServerProcess = class {
8369
8389
  child.kill("SIGTERM");
8370
8390
  });
8371
8391
  }
8392
+ ensureMinCodexCliVersion() {
8393
+ codexCliVersionEnsured ??= this.runEnsureMinCodexCliVersion().catch((error) => {
8394
+ codexCliVersionEnsured = null;
8395
+ console.warn("[AppServerProcess] Failed to ensure minimum codex CLI version, continuing with installed binary:", error);
8396
+ });
8397
+ return codexCliVersionEnsured;
8398
+ }
8399
+ async runEnsureMinCodexCliVersion() {
8400
+ const { stdout } = await execFileAsync(this.binary, ["--version"], { env: this.env });
8401
+ const version = stdout.match(/(\d+\.\d+\.\d+)/)?.[1];
8402
+ if (version && !isVersionBelow(version, MIN_CODEX_CLI_VERSION)) {
8403
+ return;
8404
+ }
8405
+ console.warn(`[AppServerProcess] codex CLI ${version ?? "unknown"} is below ${MIN_CODEX_CLI_VERSION}; upgrading @openai/codex`);
8406
+ await execFileAsync(
8407
+ "npm",
8408
+ ["install", "-g", "--no-audit", "--no-fund", `@openai/codex@${MIN_CODEX_CLI_VERSION}`],
8409
+ { env: this.env, timeout: CODEX_UPGRADE_TIMEOUT_MS }
8410
+ );
8411
+ console.warn(`[AppServerProcess] upgraded codex CLI to ${MIN_CODEX_CLI_VERSION}`);
8412
+ }
8372
8413
  async loginWithConfiguredApiKey(client) {
8373
8414
  if (ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD !== "api_key" || !ENGINE_ENV.OPENAI_API_KEY) {
8374
8415
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.417",
3
+ "version": "0.1.418",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",