coxpit 3.2.1 → 3.2.2
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/package.json +4 -4
- package/src/index.ts +5 -0
- package/src/orchestrator.ts +26 -1
- package/src/server.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coxpit",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Self-hosted cockpit for running a fleet of AI coding agents across your own machines — parallel worktree runs, live board, compare & merge, web terminal, design capture.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@fastify/websocket": "^11",
|
|
46
46
|
"@libsql/client": "^0.14",
|
|
47
|
-
"@xterm/addon-fit": "^0.
|
|
48
|
-
"@xterm/addon-unicode11": "^0.
|
|
49
|
-
"@xterm/xterm": "^
|
|
47
|
+
"@xterm/addon-fit": "^0.10.0",
|
|
48
|
+
"@xterm/addon-unicode11": "^0.8.0",
|
|
49
|
+
"@xterm/xterm": "^5.5.0",
|
|
50
50
|
"dotenv": "^16",
|
|
51
51
|
"drizzle-orm": "^0.38",
|
|
52
52
|
"fastify": "^5",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { config } from './config';
|
|
2
2
|
import { db, ensureSchema } from './db';
|
|
3
3
|
import { machines } from './db/schema';
|
|
4
|
+
import { reconcileOrphanRuns } from './orchestrator';
|
|
4
5
|
import { buildServer } from './server';
|
|
5
6
|
|
|
6
7
|
await ensureSchema();
|
|
@@ -10,5 +11,9 @@ if ((await db.select().from(machines)).length === 0) {
|
|
|
10
11
|
await db.insert(machines).values({ slug: 'local', name: 'This machine', kind: 'local', online: true });
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
// 재시작으로 고아가 된 running run 정산(카드가 영원히 '진행 중'으로 남는 것 방지).
|
|
15
|
+
const orphans = await reconcileOrphanRuns();
|
|
16
|
+
if (orphans > 0) console.log(`[coxpit] settled ${orphans} orphaned run(s) from a previous daemon instance`);
|
|
17
|
+
|
|
13
18
|
const app = await buildServer();
|
|
14
19
|
await app.listen({ host: config.host, port: config.port });
|
package/src/orchestrator.ts
CHANGED
|
@@ -295,7 +295,17 @@ export async function getRunTermInfo(runId: number): Promise<{ machine: MachineT
|
|
|
295
295
|
*/
|
|
296
296
|
export async function stopRun(runId: number): Promise<{ ok: boolean; detail: string }> {
|
|
297
297
|
const child = liveChildren.get(runId);
|
|
298
|
-
if (!child)
|
|
298
|
+
if (!child) {
|
|
299
|
+
// 데몬 재시작 등으로 고아가 된 좀비 run — 프로세스는 없는데 DB 만 running.
|
|
300
|
+
// stop 요청을 정산으로 처리해 카드가 영원히 '진행 중'으로 남지 않게 한다.
|
|
301
|
+
const zr = (await db.select().from(agentRuns).where(eq(agentRuns.id, runId)).limit(1))[0];
|
|
302
|
+
if (zr && (zr.status === 'running' || zr.status === 'starting')) {
|
|
303
|
+
await setRun(runId, { status: 'stopped', endedAt: new Date(), exitSummary: 'orphaned (daemon restarted) — settled by stop' });
|
|
304
|
+
await recordEvent(runId, 'meta', JSON.stringify({ orphanSettled: true }));
|
|
305
|
+
return { ok: true, detail: 'no live process — settled as stopped' };
|
|
306
|
+
}
|
|
307
|
+
return { ok: false, detail: 'not running' };
|
|
308
|
+
}
|
|
299
309
|
stoppedRuns.add(runId);
|
|
300
310
|
|
|
301
311
|
// 원격이면 먼저 원격 프로세스를 pid 파일로 죽인다(ssh 채널만 끊으면 잔존 가능).
|
|
@@ -719,6 +729,21 @@ export async function prRun(runId: number): Promise<{ ok: boolean; detail: strin
|
|
|
719
729
|
/**
|
|
720
730
|
* worktree/브랜치/tmux 정리(태스크 종료·run 폐기 시).
|
|
721
731
|
*/
|
|
732
|
+
/**
|
|
733
|
+
* 부팅 정산 — 데몬 재시작 후 살아있는 자식이 있을 수 없는데 DB 가 running/starting 인
|
|
734
|
+
* run(고아)을 failed 로 정리한다. workbench('open')는 에이전트가 없으므로 대상 아님.
|
|
735
|
+
*/
|
|
736
|
+
export async function reconcileOrphanRuns(): Promise<number> {
|
|
737
|
+
const stale = (await db.select().from(agentRuns)).filter(
|
|
738
|
+
(r) => r.status === 'running' || r.status === 'starting',
|
|
739
|
+
);
|
|
740
|
+
for (const r of stale) {
|
|
741
|
+
await setRun(r.id, { status: 'failed', endedAt: new Date(), exitSummary: 'orphaned by daemon restart' });
|
|
742
|
+
await recordEvent(r.id, 'error', 'daemon restarted while this run was live — settled as failed (worktree/branch preserved; diff still reviewable)');
|
|
743
|
+
}
|
|
744
|
+
return stale.length;
|
|
745
|
+
}
|
|
746
|
+
|
|
722
747
|
export async function cleanupRun(runId: number): Promise<{ ok: boolean; detail: string }> {
|
|
723
748
|
const ctx = await loadContext(runId);
|
|
724
749
|
const rr = await db.select().from(agentRuns).where(eq(agentRuns.id, runId)).limit(1);
|
package/src/server.ts
CHANGED
|
@@ -33,7 +33,7 @@ export async function buildServer(): Promise<FastifyInstance> {
|
|
|
33
33
|
app.addHook('onRequest', authGate);
|
|
34
34
|
|
|
35
35
|
// 무인증 헬스(외부 감시용)
|
|
36
|
-
app.get('/api/health', async () => ({ ok: true, name: 'coxpit', version: '3.2.
|
|
36
|
+
app.get('/api/health', async () => ({ ok: true, name: 'coxpit', version: '3.2.2' }));
|
|
37
37
|
|
|
38
38
|
// 플릿 보드(단일 페이지). 인증 게이트 적용됨.
|
|
39
39
|
app.get('/', async (_req, reply) => reply.type('text/html').send(BOARD_HTML));
|
|
@@ -502,7 +502,7 @@ export async function buildServer(): Promise<FastifyInstance> {
|
|
|
502
502
|
// 라이브 스트림 좌석 — 오케스트레이터가 run/event 를 여기로 broadcast.
|
|
503
503
|
app.get('/ws', { websocket: true }, (socket) => {
|
|
504
504
|
addSink(socket);
|
|
505
|
-
socket.send(JSON.stringify({ type: 'hello', name: 'coxpit-fleet', version: '3.2.
|
|
505
|
+
socket.send(JSON.stringify({ type: 'hello', name: 'coxpit-fleet', version: '3.2.2' }));
|
|
506
506
|
socket.on('close', () => removeSink(socket));
|
|
507
507
|
});
|
|
508
508
|
|