Files
novalon-website/.agents/skills/impeccable/scripts/live-status.mjs
T
张翔 cf99e7556c chore(infra): 更新 Nginx 部署配置与项目上下文文档
- 更新 CI/CD 子域名反向代理配置
- 调整 Nginx 静态文件服务器配置
- 更新 CONTEXT.md 领域共享语言文档
- 添加 CLAUDE.md 代理工作指南
- 更新 Playwright E2E 测试配置
2026-07-07 06:52:07 +08:00

62 lines
2.1 KiB
JavaScript

#!/usr/bin/env node
/**
* Print durable recovery status for Impeccable live sessions.
*/
import { createLiveSessionStore } from './live/session-store.mjs';
import { readLiveServerInfo } from './lib/impeccable-paths.mjs';
import { manualApplyResumeHint } from './live-resume.mjs';
function readServerInfo() {
return readLiveServerInfo(process.cwd())?.info || null;
}
async function fetchServerStatus(info) {
if (!info) return null;
try {
const res = await fetch(`http://localhost:${info.port}/status?token=${info.token}`);
if (!res.ok) return null;
return await res.json();
} catch {
return null;
}
}
export async function statusCli() {
const info = readServerInfo();
const server = await fetchServerStatus(info);
const store = createLiveSessionStore({ cwd: process.cwd() });
const activeSessions = store.listActiveSessions();
const manualApply = findPendingManualApply(server, activeSessions);
const payload = {
liveServer: server ? {
status: server.status,
port: server.port,
connectedClients: server.connectedClients,
agentPolling: server.agentPolling,
pendingEvents: server.pendingEvents,
} : null,
activeSessions: server?.activeSessions || activeSessions,
recoveryHint: manualApply
? manualApplyResumeHint(manualApply)
: server
? 'Run live-poll.mjs to continue pending work, or live-complete.mjs --id <session> after manual cleanup.'
: 'Start live-server.mjs to requeue pending durable events, then run live-poll.mjs.',
};
console.log(JSON.stringify(payload, null, 2));
}
function findPendingManualApply(server, activeSessions) {
const fromServer = server?.pendingEvents?.find((event) => event?.type === 'manual_edit_apply');
if (fromServer) return fromServer;
const fromSession = activeSessions
?.map((session) => session.pendingEvent)
.find((event) => event?.type === 'manual_edit_apply');
return fromSession || null;
}
const _running = process.argv[1];
if (_running?.endsWith('live-status.mjs') || _running?.endsWith('live-status.mjs/')) {
statusCli();
}