Files
mcn-short-video/project/短视频脚本创作/V1.0/mcn-workshop/cdp-verify-r64-acc.mjs
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

45 lines
3.3 KiB
JavaScript

// 09-04 R64.2 验证:账号列表「刷新」(更新)按钮去文字留图标
const CDP = 9223;
const list = await fetch(`http://localhost:${CDP}/json`).then((r) => r.json());
const page = list.find((t) => t.type === 'page' && (t.url || '').includes('8900')) || list.find((t) => t.type === 'page');
if (!page) { console.log('ERR: no page'); process.exit(1); }
const ws = new WebSocket(page.webSocketDebuggerUrl);
let id = 0; const pending = new Map();
const send = (method, params = {}) => new Promise((res, rej) => { const i = ++id; pending.set(i, { res, rej }); ws.send(JSON.stringify({ id: i, method, params })); });
ws.onmessage = (e) => { const m = JSON.parse(e.data); if (m.id && pending.has(m.id)) { const p = pending.get(m.id); pending.delete(m.id); m.error ? p.rej(new Error(m.error.message)) : p.res(m.result); } };
await new Promise((r) => (ws.onopen = r));
const ev = async (expr) => { const r = await send('Runtime.evaluate', { expression: expr, returnByValue: true, awaitPromise: true }); if (r.exceptionDetails) return { __err: (r.exceptionDetails.exception?.description || r.exceptionDetails.text).slice(0, 300) }; return r.result.value; };
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
await send('Page.enable'); await send('Runtime.enable'); await send('Network.enable');
await send('Network.setCacheDisabled', { cacheDisabled: true });
await send('Emulation.setDeviceMetricsOverride', { width: 860, height: 1000, deviceScaleFactor: 1, mobile: false });
const waitFor = async (expr, ms = 15000) => { const t0 = Date.now(); while (Date.now() - t0 < ms) { if (await ev(expr)) return true; await sleep(300); } return false; };
const fail = (m) => { console.log('FAIL@' + m); process.exit(1); };
const fs = await import('node:fs');
await send('Page.navigate', { url: `http://127.0.0.1:8900/?t=${Date.now()}#/accounts` });
if (!(await waitFor(`location.hash === '#/accounts' && !!document.querySelector('#accUpdate') && [...document.scripts].some((s) => (s.src || '').includes('data-pages.js?v=20260904n'))`, 15000))) fail('accounts route');
await sleep(500);
const r = await ev(`(() => {
const b = document.querySelector('#accUpdate');
if (!b) return { err: 'no #accUpdate' };
const text = (b.textContent || '').trim();
const svg = b.querySelector('svg');
const rect = b.getBoundingClientRect();
return { text, hasSvg: !!svg, svgViewBox: svg ? svg.getAttribute('viewBox') : null, w: Math.round(rect.width), h: Math.round(rect.height), title: b.getAttribute('title') };
})()`);
console.log(JSON.stringify(r, null, 2));
await ev(`document.querySelector('#accUpdate').scrollIntoView({ block: 'center' })`); await sleep(200);
// 截图按钮所在 toolbar
const rect = await ev(`(() => { const el = document.querySelector('.acc-toolbar'); const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, w: r.width, h: r.height }; })()`);
if (rect && !rect.__err) {
const shot = await send('Page.captureScreenshot', { format: 'png', clip: { x: Math.max(0, rect.x - 4), y: Math.max(0, rect.y - 4), width: Math.min(rect.w + 8, 1200), height: Math.min(rect.h + 8, 800), scale: 1 } });
fs.writeFileSync(`tmp/r64_acc_toolbar.png`, Buffer.from(shot.data, 'base64'));
}
const ok = r && !r.__err && r.text === '' && r.hasSvg;
console.log(ok ? '\n=== PASS ===' : '\n=== CHECK ===');
ws.close();
process.exit(ok ? 0 : 1);