Show persistent operations queue

This commit is contained in:
wuyang
2026-11-04 10:11:04 +08:00
parent 830d5b722a
commit 713c3cd0a2
3 changed files with 33 additions and 1 deletions
+9
View File
@@ -154,6 +154,15 @@ export function createApp(options = process.env) {
}
if (route.startsWith('/api/')) {
if (!session(req)) return json(res, 401, { error: '请先登录' });
if (req.method === 'GET' && route === '/api/workqueue') {
const value = await jsonFile('workqueue.json', { schema: 1, tasks: [] });
if (value?.schema !== 1 || !Array.isArray(value.tasks)) return json(res, 500, { error: '工作队列格式无效' });
const valid = new Set(['pending', 'running', 'done', 'blocked']);
const tasks = value.tasks.filter(t => t && typeof t.id === 'string' && typeof t.title === 'string' && valid.has(t.status))
.map(t => ({ title: t.id.startsWith('interaction-') ? '核查新互动' : t.title.slice(0, 100), status: t.status,
attempts: Number.isInteger(t.attempts) ? t.attempts : 0, updated_at: typeof t.updated_at === 'string' ? t.updated_at : null }));
return json(res, 200, { tasks });
}
if (req.method === 'GET' && route === '/api/evolution') return json(res, 200, await jsonFile('evolution.json', { schema_version: 1, events: [] }));
if (req.method === 'GET' && route === '/api/daily') return json(res, 200, await dailyRecords());
if (req.method === 'GET' && route === '/api/dashboard') {