replicas-engine 0.1.466 → 0.1.468

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 +25 -3
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // src/index.ts
4
4
  import { serve } from "@hono/node-server";
5
5
  import { Hono as Hono2 } from "hono";
6
+ import { existsSync as existsSync11 } from "fs";
6
7
 
7
8
  // ../shared/src/type-guards.ts
8
9
  function isRecord(value) {
@@ -569,11 +570,19 @@ var SANDBOX_LIFECYCLE = {
569
570
  AUTO_DELETE_MINUTES: -1,
570
571
  SSH_TOKEN_EXPIRATION_MINUTES: 3 * 60
571
572
  };
573
+ var SANDBOX_PATHS = {
574
+ HOME_DIR: "/home/user",
575
+ WORKSPACES_DIR: "/home/user/workspaces",
576
+ REPLICAS_DIR: "/home/user/.replicas",
577
+ ENGINE_INIT_GATE: "/home/user/.replicas/engine-init-gate",
578
+ REPLICAS_CANVAS_DIR: "/home/user/.replicas/canvas",
579
+ REPLICAS_RUNTIME_ENV_FILE: "/home/user/.replicas/runtime-env.sh"
580
+ };
572
581
  var WORKSPACE_SIZES = ["small", "large"];
573
582
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
574
583
 
575
584
  // ../shared/src/e2b.ts
576
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-19-v18";
585
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-19-v20";
577
586
 
578
587
  // ../shared/src/runtime-env.ts
579
588
  function shellQuotePosix(value) {
@@ -4635,7 +4644,8 @@ function loadEngineEnv() {
4635
4644
  REPLICAS_DISABLE_GH_PR_MERGE: readEnv("REPLICAS_DISABLE_GH_PR_MERGE")?.toLowerCase() === "true",
4636
4645
  REPLICAS_ENV_SYSTEM_PROMPT: readEnv("REPLICAS_ENV_SYSTEM_PROMPT"),
4637
4646
  REPLICAS_ENV_START_HOOK: readEnv("REPLICAS_ENV_START_HOOK"),
4638
- REPLICAS_DISABLE_AUTO_START_HOOKS: readEnv("REPLICAS_DISABLE_AUTO_START_HOOKS")?.toLowerCase() === "true"
4647
+ REPLICAS_DISABLE_AUTO_START_HOOKS: readEnv("REPLICAS_DISABLE_AUTO_START_HOOKS")?.toLowerCase() === "true",
4648
+ REPLICAS_ENGINE_DEFER_INITIALIZATION: readEnv("REPLICAS_ENGINE_DEFER_INITIALIZATION")?.toLowerCase() === "true"
4639
4649
  };
4640
4650
  if (!IS_WARMING_MODE && !env.WORKSPACE_ID) {
4641
4651
  console.error("WORKSPACE_ID is not set \u2014 this is required in normal (non-warming) mode");
@@ -9775,7 +9785,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
9775
9785
  var MIN_CODEX_CLI_VERSION = "0.144.6";
9776
9786
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
9777
9787
  var codexCliVersionEnsured = null;
9778
- var ENGINE_PACKAGE_VERSION = "0.1.466";
9788
+ var ENGINE_PACKAGE_VERSION = "0.1.468";
9779
9789
  var INITIALIZE_METHOD = "initialize";
9780
9790
  var INITIALIZED_NOTIFICATION = "initialized";
9781
9791
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -16746,6 +16756,7 @@ var heartbeatService = new HeartbeatService();
16746
16756
  // src/index.ts
16747
16757
  var startupStartedAt = performance.now();
16748
16758
  var startupTimings = {};
16759
+ var ENGINE_INIT_GATE_TIMEOUT_MS = 35 * 60 * 1e3;
16749
16760
  var resolveEngineReady = () => {
16750
16761
  };
16751
16762
  var engineReadyPromise = new Promise((resolve4) => {
@@ -16762,6 +16773,16 @@ async function timeStartupStep(name, fn) {
16762
16773
  };
16763
16774
  }
16764
16775
  }
16776
+ async function waitForInitializationGate() {
16777
+ if (!ENGINE_ENV.REPLICAS_ENGINE_DEFER_INITIALIZATION) return;
16778
+ const deadline = Date.now() + ENGINE_INIT_GATE_TIMEOUT_MS;
16779
+ while (!existsSync11(SANDBOX_PATHS.ENGINE_INIT_GATE)) {
16780
+ if (Date.now() >= deadline) {
16781
+ throw new Error("Timed out waiting for deferred engine initialization gate");
16782
+ }
16783
+ await new Promise((resolve4) => setTimeout(resolve4, 25));
16784
+ }
16785
+ }
16765
16786
  await timeStartupStep("engine_logger_initialize", () => engineLogger.initialize());
16766
16787
  process.on("uncaughtException", (error) => {
16767
16788
  console.error("[FATAL] Uncaught exception:", error);
@@ -17005,6 +17026,7 @@ serve(
17005
17026
  } else {
17006
17027
  console.log(`Replicas Engine running on port ${info.port}`);
17007
17028
  }
17029
+ await timeStartupStep("wait_for_initialization_gate", waitForInitializationGate);
17008
17030
  const gitResult = await timeStartupStep("git_initialize", () => gitService.initializeGitRepository());
17009
17031
  if (!gitResult.success && gitResult.error) {
17010
17032
  console.warn(`Git initialization warning: ${gitResult.error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.466",
3
+ "version": "0.1.468",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",