replicas-engine 0.1.3 → 0.1.5

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
@@ -2,11 +2,29 @@
2
2
  import 'dotenv/config';
3
3
  import { serve } from '@hono/node-server';
4
4
  import { Hono } from 'hono';
5
+ import { readFile } from 'fs/promises';
6
+ import { READY_MESSAGE, COMPLETION_MESSAGE } from '@replicas/shared';
5
7
  import { authMiddleware } from './middleware/auth.js';
6
8
  import codex from './routes/codex.js';
7
9
  const app = new Hono();
8
- app.get('/health', (c) => {
9
- return c.json({ status: 'ok', timestamp: new Date().toISOString() });
10
+ app.get('/health', async (c) => {
11
+ try {
12
+ const logContent = await readFile('/var/log/cloud-init-output.log', 'utf-8');
13
+ let status;
14
+ if (logContent.includes(COMPLETION_MESSAGE)) {
15
+ status = 'active';
16
+ }
17
+ else if (logContent.includes(READY_MESSAGE)) {
18
+ status = 'ready';
19
+ }
20
+ else {
21
+ status = 'initializing';
22
+ }
23
+ return c.json({ status, timestamp: new Date().toISOString() });
24
+ }
25
+ catch (error) {
26
+ return c.json({ status: 'initializing', timestamp: new Date().toISOString() });
27
+ }
10
28
  });
11
29
  app.use('*', authMiddleware);
12
30
  app.route('/codex', codex);
@@ -7,7 +7,20 @@ export class CodexManager {
7
7
  workingDirectory;
8
8
  constructor(workingDirectory) {
9
9
  this.codex = new Codex();
10
- this.workingDirectory = workingDirectory || process.env.WORKSPACE_HOME || process.env.HOME || '/home/ubuntu';
10
+ if (workingDirectory) {
11
+ this.workingDirectory = workingDirectory;
12
+ }
13
+ else {
14
+ const repoName = process.env.REPLICAS_REPO_NAME;
15
+ const workspaceHome = process.env.WORKSPACE_HOME || process.env.HOME || '/home/ubuntu';
16
+ if (repoName) {
17
+ this.workingDirectory = `${workspaceHome}/workspaces/${repoName}`;
18
+ console.log(`Using repository working directory: ${this.workingDirectory}`);
19
+ }
20
+ else {
21
+ this.workingDirectory = workspaceHome;
22
+ }
23
+ }
11
24
  }
12
25
  async *sendMessage(message) {
13
26
  if (!this.currentThread) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,6 +25,7 @@
25
25
  "author": "Replicas",
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
+ "@replicas/shared": "0.0.1",
28
29
  "@hono/node-server": "^1.19.5",
29
30
  "@openai/codex-sdk": "^0.50.0",
30
31
  "dotenv": "^17.2.3",