replicas-engine 0.1.39 → 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.
Files changed (2) hide show
  1. package/dist/src/index.js +14 -6
  2. package/package.json +4 -4
package/dist/src/index.js CHANGED
@@ -732,6 +732,7 @@ var DEFAULT_CHAT_TITLES = {
732
732
  claude: "Claude Code",
733
733
  codex: "Codex"
734
734
  };
735
+ var IMAGE_MEDIA_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
735
736
 
736
737
  // src/services/replicas-config.ts
737
738
  var execAsync = promisify(exec);
@@ -1087,7 +1088,7 @@ function isJsonlEvent(value) {
1087
1088
  if (!isRecord3(value)) {
1088
1089
  return false;
1089
1090
  }
1090
- return typeof value.timestamp === "string" && typeof value.type === "string" && "payload" in value;
1091
+ return typeof value.timestamp === "string" && typeof value.type === "string" && isRecord3(value.payload);
1091
1092
  }
1092
1093
  function parseJsonlEvents(lines) {
1093
1094
  const events = [];
@@ -1488,9 +1489,9 @@ function convertCodexEvent(event, linearSessionId) {
1488
1489
  }
1489
1490
 
1490
1491
  // src/utils/image-utils.ts
1491
- var IMAGE_MEDIA_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
1492
+ var IMAGE_MEDIA_TYPES2 = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
1492
1493
  function isImageMediaType(value) {
1493
- return IMAGE_MEDIA_TYPES.has(value);
1494
+ return IMAGE_MEDIA_TYPES2.has(value);
1494
1495
  }
1495
1496
  function inferMediaType(url, contentType) {
1496
1497
  if (contentType) {
@@ -2113,7 +2114,7 @@ function isJsonlEvent2(value) {
2113
2114
  if (!isRecord4(value)) {
2114
2115
  return false;
2115
2116
  }
2116
- return typeof value.timestamp === "string" && typeof value.type === "string" && "payload" in value;
2117
+ return typeof value.timestamp === "string" && typeof value.type === "string" && isRecord4(value.payload);
2117
2118
  }
2118
2119
  function sleep(ms) {
2119
2120
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -2939,8 +2940,7 @@ var createChatSchema = z.object({
2939
2940
  title: z.string().min(1).optional(),
2940
2941
  repoScope: z.union([z.literal("all"), z.array(z.string().min(1))]).optional()
2941
2942
  });
2942
- var imageMediaTypes = ["image/png", "image/jpeg", "image/gif", "image/webp"];
2943
- var imageMediaTypeSchema = z.enum(imageMediaTypes);
2943
+ var imageMediaTypeSchema = z.enum(IMAGE_MEDIA_TYPES);
2944
2944
  var sendMessageSchema = z.object({
2945
2945
  message: z.string().min(1),
2946
2946
  model: z.string().optional(),
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -27,13 +27,13 @@
27
27
  "author": "Replicas",
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@anthropic-ai/claude-agent-sdk": "^0.1.30",
30
+ "@anthropic-ai/claude-agent-sdk": "^0.2.41",
31
31
  "@hono/node-server": "^1.19.5",
32
- "@openai/codex-sdk": "^0.88.0",
32
+ "@openai/codex-sdk": "^0.101.0",
33
33
  "dotenv": "^17.2.3",
34
34
  "hono": "^4.10.3",
35
35
  "smol-toml": "^1.6.0",
36
- "zod": "^3.25.0"
36
+ "zod": "^4.0.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^20.11.17",