replicas-engine 0.1.40 → 0.1.41
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/src/index.js +8 -0
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -3198,6 +3198,7 @@ function checkActiveSSHSessions() {
|
|
|
3198
3198
|
}
|
|
3199
3199
|
var app = new Hono2();
|
|
3200
3200
|
var bootTimeMs = Date.now();
|
|
3201
|
+
var engineReady = false;
|
|
3201
3202
|
var authMiddleware = async (c, next) => {
|
|
3202
3203
|
const secret = c.req.header("X-Replicas-Engine-Secret");
|
|
3203
3204
|
const expectedSecret = process.env.REPLICAS_ENGINE_SECRET;
|
|
@@ -3210,10 +3211,16 @@ var authMiddleware = async (c, next) => {
|
|
|
3210
3211
|
if (secret !== expectedSecret) {
|
|
3211
3212
|
return c.json({ error: "Unauthorized: Invalid secret" }, 401);
|
|
3212
3213
|
}
|
|
3214
|
+
if (!engineReady) {
|
|
3215
|
+
return c.json({ error: "Engine is initializing" }, 503);
|
|
3216
|
+
}
|
|
3213
3217
|
await next();
|
|
3214
3218
|
};
|
|
3215
3219
|
var chatService = new ChatService(repoService.getWorkspaceRoot());
|
|
3216
3220
|
app.get("/health", async (c) => {
|
|
3221
|
+
if (!engineReady) {
|
|
3222
|
+
return c.json({ status: "initializing", timestamp: (/* @__PURE__ */ new Date()).toISOString() }, 503);
|
|
3223
|
+
}
|
|
3217
3224
|
try {
|
|
3218
3225
|
const logContent = await readFile8("/var/log/cloud-init-output.log", "utf-8");
|
|
3219
3226
|
let status;
|
|
@@ -3374,6 +3381,7 @@ serve(
|
|
|
3374
3381
|
}
|
|
3375
3382
|
await replicasConfigService.initialize();
|
|
3376
3383
|
await chatService.initialize();
|
|
3384
|
+
engineReady = true;
|
|
3377
3385
|
await githubTokenManager.start();
|
|
3378
3386
|
await claudeTokenManager.start();
|
|
3379
3387
|
await codexTokenManager.start();
|