// R67 冒烟:新版本资源加载 + MYAI_CONNECTORS 可达 + 无 console error 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, 200) }; 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 errors = []; const onExc = (e) => { try { const m = JSON.parse(e.data); if (m.method === 'Runtime.exceptionThrown') errors.push((m.params.exceptionDetails?.exception?.description || m.params.exceptionDetails?.text || '').slice(0, 200)); } catch (x) {} }; ws.onmessage = ((orig) => (e) => { onExc(e); orig(e); })(ws.onmessage); 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('app.js?v=20260904i')) && [...document.scripts].some((s) => (s.src || '').includes('data-pages.js?v=20260904r'))`, 15000))) { console.log('FAIL: version resources not loaded'); process.exit(1); } await sleep(600); const r = await ev(`(() => { // 常量经全局词法环境可达(跨 script);模拟一次 executeTask 入参构造不抛错 let connOk = false, fnOk = false; try { connOk = (typeof MYAI_CONNECTORS !== 'undefined') && Array.isArray(MYAI_CONNECTORS) && MYAI_CONNECTORS[0] === 'custom-mcp:myai-mcp-production'; } catch (e) {} try { fnOk = typeof executeTask === 'function' && typeof confirmVideoParse === 'function'; } catch (e) {} return { connOk, fnOk, title: document.title, hasUpdate: !!document.querySelector('#accUpdate') }; })()`); console.log(JSON.stringify(r, null, 2)); console.log('console/page errors:', errors.length ? JSON.stringify(errors.slice(0, 3)) : 'none'); const ok = r && !r.__err && r.connOk && r.fnOk && errors.length === 0; console.log(ok ? '\n=== PASS ===' : '\n=== CHECK ==='); ws.close(); process.exit(ok ? 0 : 1);