Files
mcn-short-video/project/短视频脚本创作/V1.0/mcn-workshop/poll-review-tasks.cjs
T
maogeigei f77735b206 工作台:目录改名 mcn-workshop + 任务进度可见 + 会话归属配置化
1. 目录 mcn-work-shop -> mcn-workshop(空间分组名取会话 cwd 的目录名,只改字符串无效,必须真改名)
2. 全仓替换 mcn-work-shop -> mcn-workshop:37 文件 121 处;历史日志按沿革句规矩保留当时目录名
3. 任务进度可见:/api/run/status 产出 已运行时长/工具调用/最近动作/停滞判定(读会话日志尾部),前端新增右下角常驻面板,四处任务入口接入
4. 会话归属目录配置化:新增 config.sessionCwd(留空=工作台自身目录),现指向 D://AI技能//mcn-workshop,使任务显示为命名分组而非「未分组任务」
5. 修前端轮询静默缺陷:连续 3 次查询失败即提示服务断开(原逻辑静默空转到 15 分钟超时,用户零感知)
2026-10-08 13:09:06 +08:00

44 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* poll-review-tasks.cjs — 轮询 6 条复盘任务(/api/run/status,ACCEPTED 已归 done)*/
const TASKS = [
{ rw: 31, id: 'automation-1788251452496' },
{ rw: 30, id: 'automation-1788251455526' },
{ rw: 29, id: 'automation-1788251458549' },
{ rw: 28, id: 'automation-1788251461578' },
{ rw: 27, id: 'automation-1788251464600' },
{ rw: 26, id: 'automation-1788251467630' },
];
const { loadConfig } = require('./load-config');
const CFG = loadConfig();
const API = `http://localhost:${CFG.port}/api/run/status?id=`;
const state = {};
TASKS.forEach((t) => (state[t.rw] = 'pending'));
const status = async (id) => {
try {
const r = await fetch(API + encodeURIComponent(id));
const d = await r.json();
return d.state || 'unknown';
} catch { return 'unknown'; }
};
console.log('START polling 6 review tasks:', new Date().toLocaleTimeString('zh-CN'));
(async () => {
const started = Date.now();
while (Date.now() - started < 60 * 60 * 1000) {
let allDone = true;
for (const t of TASKS) {
const s = await status(t.id);
state[t.rw] = s;
if (s !== 'done' && s !== 'error') allDone = false;
}
console.log(new Date().toLocaleTimeString('zh-CN'), '|',
TASKS.map((t) => 'rw' + t.rw + ':' + state[t.rw]).join(' '));
if (allDone) {
const errs = TASKS.filter((t) => state[t.rw] === 'error');
console.log(errs.length ? 'ALL DONE (with errors): ' + errs.map((t) => 'rw' + t.rw).join(',') : 'ALL DONE ✓');
process.exit(0);
}
await new Promise((r) => setTimeout(r, 30000));
}
console.log('TIMEOUT after 60min, last states:', JSON.stringify(state));
process.exit(1);
})();