From 3f5bffba8edffcd64c4b52aef051bf5f15b73503 Mon Sep 17 00:00:00 2001 From: wangfar Date: Mon, 23 Nov 2026 10:48:13 +0800 Subject: [PATCH] =?UTF-8?q?seewo-kit:=20=E4=BA=91=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E6=8E=A2=E6=B4=BB=20+=20shell=20=E7=9B=B4=E8=BF=9E?= =?UTF-8?q?=E5=9B=9E=E9=80=80=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=86=99=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=B0=B8=E4=B9=85=E6=8C=82=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 云端 MCP(7916) 对单个 shell 的转发会永久阻塞且不报超时:实测 130s 无响应, 期间云端没有向 shell 端口发起 TCP,shell 日志也没有请求记录;而该 shell 自己的 MCP 端口(从 Log\<时间>,\last_info.txt 读取)读写/截图均 10-130ms 正常。 - 新增 callShellTool/routeFor:每个 shell 首次调用做 4s 探活,云端超时即自动 改走直连端口;单次调用中途超时也立刻降级,不再让调用方干等 - 路由按 shell 缓存,失败 15s 后重试;shell 重启导致端口变化时自动重新发现 - diagnose_courseware 输出 live.shells[].transport(cloud/direct/端口), 新增 proxy-dead 警告;写操作与 export_slides 结果附带 transport - 修正“渲染线程卡死”的误判文案 - README 增补坑 16 --- kit/README.md | 36 +++++- kit/core.mjs | 329 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 333 insertions(+), 32 deletions(-) diff --git a/kit/README.md b/kit/README.md index 378182a..9570689 100644 --- a/kit/README.md +++ b/kit/README.md @@ -228,9 +228,11 @@ kit/ - `live.open`:同一个课件开了几个窗口;>1 时 `safeToWrite=false`,因为每个窗口各存一份,写谁都会被另一个覆盖; - `live.shells[].workingMode`:每个窗口停在 `Edit` 还是 `Display`。停在授课界面时切换会丢该界面的改动; +- `live.shells[].transport`:每个窗口的 MCP 链路状态。`cloud` 是云端(7916)转发,`direct` 是该窗口自己的端口。 + 云端代理坏掉时 `cloud=dead` + `direct=ok`,kit 会自动改走直连,写入不受影响,同时报 `proxy-dead`; - `pages` / `live.shells[].pages`:磁盘页数 vs 内存页数,不一致说明有没落盘的改动或还在加载; - `revision` / `syncedRevision`:本地改了没上传; -- `checkRender=true`:顺手截一张图,验证渲染线程没卡死(卡死时会明确报「重启希沃」而不是干等); +- `checkRender=true`:顺手截一张图,验证截图链路(云端代理和直连都走不通时才报错,并明确要求重启希沃); - `latestBackups`:最近 3 份快照,出问题可以直接 `restore_courseware`。 返回 `{ ok, safeToWrite, issues[], tips[] }`。`safeToWrite=false` 时不要写课件。 @@ -256,8 +258,8 @@ kit/ - 默认导出全部页,或 `page` / `pages` 指定;输出到 `%TEMP%\opencode\seewo-kit-export\-<时间>`,也可传 `outDir`(绝对路径或相对目录名)。 - `fileNamePattern` 支持 `{page}`(原页码)和 `{index}`(补零),默认 `slide-01.png`。 -- 直接调用希沃原生 `get_slide_screenshot({ slideNumber, expectedPngImageFilePath })`,不额外调用 - `goto_slide`(少一次渲染等待,也少一个卡死点)。 +- 直接调用希沃原生 `get_slide_screenshot({ slideNumber, expectedPngImageFilePath })`。 + 每页截图前先 `goto_slide` 到目标页(否则偶尔会拿到上一页的旧帧),失败也不中断。 - 每页截图前会删掉 0 字节残留;成功标准是文件 ≥ `minBytes`(默认 2048)。 - `timeoutSec` 默认 180 秒。超时会**停止后续页面**并返回 `ok: false`,同时提示确认希沃窗口在前台、 课件已完整加载,必要时重启希沃;不会像以前那样反复重试把界面越拖越死。 @@ -503,7 +505,33 @@ MCP 加的元素在 Display 模式下不会被保存;写操作前后尽量让 确认这些改动不要了,才传 `force=true`。 3. **截图拿到旧帧。** `get_slide_screenshot` 偶尔返回上一页/上一次的渲染结果,文件大小看起来完全正常。 `export_slides` 现在每次先删目标文件、先 `goto_slide` 到目标页、再校验文件修改时间是否落在本次调用之后; - 连续两页超时就判定渲染线程卡死并中止,提示重启希沃,而不是继续等。 + 连续两页超时就中止并提示重启希沃,而不是继续等。 + +### 16. 云端 MCP 的 shell 转发会永久挂起(已加直连回退) + +希沃有两层 MCP:云端(7916)只有 11 个 `en_*` / 云课件工具,其余 52 个工具是**转发**给课件窗口进程(shell)执行的。 +每个 shell 进程自己也有完整 MCP 服务,端口随机,启动时写进日志。 + +2026-11-23 实测到,云端到某个 shell 的转发会**永久卡死**: + +- `get_slide_info(shellId=7568)` 130 秒仍无返回,也没有任何超时错误; +- 卡住期间云端进程**没有**向该 shell 的端口发起 TCP 连接,shell 日志里也**收不到**任何请求; +- 同一个 shell 自己的端口(50100)用 HTTP 直接调,全部 10–130 ms 返回,截图也正常; +- 另一个 shell(5628)走云端转发 11–86 ms 正常。 + +也就是说「希沃卡死 / 截图接口坏了」是误判,真正坏的是云端那条转发链,而且它不报错、不超时。 + +现在 `core.mjs` 的做法: + +1. 每个 shell 第一次被用到时,用 `get_current_courseware_info` 做一次 4 秒探活; +2. 云端代理超时 → 从 `%APPDATA%\Seewo\EasiNote5\Log\<时间>,\last_info.txt` 里读出 + `Shell MCP server started on port: N`,自动改走 `http://127.0.0.1:N/mcp`(直连时脱掉 `shellId`; + 端口变了会自动重新发现); +3. 探活通过的调用仍走云端;单次调用中途超时也会立刻降级,不会让调用方干等; +4. 路由按 shell 缓存,`diagnose_courseware` 的 `live.shells[].transport` 会直接显示 `cloud` / `direct` 状态。 + +所以云端代理坏掉时,读写照常,只是 `diagnose_courseware` 会报一条 `proxy-dead`。 +真正恢复云端代理需要重启希沃(只有重启才会重建转发客户端)。 ## 排错 diff --git a/kit/core.mjs b/kit/core.mjs index b30ea2e..6bd618e 100644 --- a/kit/core.mjs +++ b/kit/core.mjs @@ -47,19 +47,55 @@ const stamp = () => { const isSlidePath = p => SLIDE_RE.test(String(p || '').replace(/\//g, '\\')); // ---------------------------------------------------------------- 希沃 MCP 客户端 -let sessionId = null; -let rpcId = 100; -let initialized = false; +// +// 希沃有两层 MCP: +// · 云端(7916,Cloud MCP,宿主是主窗口进程)只有 11 个 en_* / 云课件工具, +// 其余 52 个「shell 工具」是它转发给某个课件窗口进程(shell)去执行的; +// · 每个 shell 进程自己也有一个完整的 MCP 服务,端口随机,启动时会写进日志。 +// +// 云端那条转发链【没有超时】:某个 shell 的代理一旦失效,所有带 shellId 的调用都会永久挂住 +// (实测 130 秒无响应,且 shell 侧收不到任何请求,连 TCP 都没连)。这会让写操作既写不进去, +// 又长时间不报错。所以这里对每个 shell 做一次探活:代理不通就自动改走该 shell 的直连端口。 +// 直连端口从 %APPDATA%\Seewo\EasiNote5\Log\<时间>,\last_info.txt 里读取。 +const LOG_ROOT = path.join(os.homedir(), 'AppData', 'Roaming', 'Seewo', 'EasiNote5', 'Log'); +const PORT_RE = /Shell MCP server started on port:\s*(\d+)/g; +const LISTEN_RE = /Listening on http:\/\/(?:127\.0\.0\.1|\[::1\]):(\d+)\//; -async function post(body, timeoutMs = 30000) { +/** 只有云端才有的工具;其余工具在 shell 直连端口上也有,可以走直连 */ +const CLOUD_ONLY = new Set([ + 'en_find_shells', 'en_bind_shell', 'en_goto_app_ui', + 'new_cloud_courseware', 'new_cloud_courseware_from_pptx', 'open_cloud_courseware', + 'search_cloud_courseware', 'generate_video_from_pptx', + 'ensys_open_file', 'switch_to_display_board_mode', 'recognition_document_and_goto_page', +]); + +const PROBE_TIMEOUT_MS = 4000; +const DEFAULT_TIMEOUT_MS = 30000; + +let rpcId = 100; +const sessions = new Map(); // port -> { sid, initialized, rpcId } +const routes = new Map(); // shellId -> { kind: 'cloud'|'direct'|'dead', port, reason, at } +const shellPorts = new Map(); // shellId -> { port, dir } + +function sessionOf(port) { + let st = sessions.get(port); + if (!st) { + st = { sid: null, initialized: false }; + sessions.set(port, st); + } + return st; +} + +async function postTo(port, body, timeoutMs = DEFAULT_TIMEOUT_MS) { + const st = sessionOf(port); const headers = { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' }; - if (sessionId) headers['Mcp-Session-Id'] = sessionId; - const res = await fetch(`http://127.0.0.1:${MCP_PORT}/mcp`, { + if (st.sid) headers['Mcp-Session-Id'] = st.sid; + const res = await fetch(`http://127.0.0.1:${port}/mcp`, { method: 'POST', headers, body: JSON.stringify(body), signal: AbortSignal.timeout(timeoutMs), }); const sid = res.headers.get('mcp-session-id'); - if (sid) sessionId = sid; + if (sid) st.sid = sid; const text = await res.text(); if (text.includes('data:')) { const data = text.split('\n').filter(l => l.startsWith('data:')).map(l => l.slice(5).trim()).join(''); @@ -68,33 +104,214 @@ async function post(body, timeoutMs = 30000) { try { return JSON.parse(text); } catch { return { raw: text }; } } -async function rpc(name, args = {}, { timeoutMs } = {}) { - const r = await post({ jsonrpc: '2.0', id: rpcId++, method: 'tools/call', params: { name, arguments: args } }, timeoutMs); +async function ensureInitOn(port, timeoutMs = DEFAULT_TIMEOUT_MS) { + const st = sessionOf(port); + if (st.initialized) return; + await postTo(port, { + jsonrpc: '2.0', id: 1, method: 'initialize', + params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'seewo-kit', version: '1.1' } }, + }, timeoutMs); + await postTo(port, { jsonrpc: '2.0', method: 'notifications/initialized' }, timeoutMs); + st.initialized = true; +} + +async function rpcOn(port, name, args = {}, timeoutMs = DEFAULT_TIMEOUT_MS) { + await ensureInitOn(port, timeoutMs); + const r = await postTo(port, { + jsonrpc: '2.0', id: rpcId++, method: 'tools/call', params: { name, arguments: args }, + }, timeoutMs); if (r.error) throw new Error(`${name}: ${JSON.stringify(r.error)}`); const txt = (r.result?.content ?? []).filter(c => c.type === 'text').map(c => c.text).join('\n'); if (r.result?.isError) throw new Error(`${name}: ${txt}`); return { text: txt, data: r.result?.structuredContent }; } -async function ensureInit() { - if (initialized) return; - await post({ - jsonrpc: '2.0', id: 1, method: 'initialize', - params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'seewo-kit', version: '1.0' } }, - }); - await post({ jsonrpc: '2.0', method: 'notifications/initialized' }); - initialized = true; +const ensureInit = () => ensureInitOn(MCP_PORT); +const rpc = (name, args, { timeoutMs } = {}) => rpcOn(MCP_PORT, name, args, timeoutMs); + +/** 超时 / 连不上,才算「这条链路坏了」;业务报错说明对面是通的 */ +function isTransportError(e) { + const n = String(e?.name || ''); + const m = String(e?.message || ''); + return n === 'TimeoutError' || n === 'AbortError' + || /aborted due to timeout|fetch failed|ECONNREFUSED|ECONNRESET|other side closed|socket/i.test(m); } -async function mcp(name, args = {}, { timeoutMs } = {}) { +/** 找 shell 进程的日志目录(目录名形如 20261123_102339,7568) */ +function shellLogDirs(shellId) { + if (!existsSync(LOG_ROOT)) return []; + const want = String(shellId); + const out = []; + for (const name of readdirSync(LOG_ROOT)) { + const m = name.match(/(?:,|_)(\d+)$/); + if (!m || m[1] !== want) continue; + const dir = path.join(LOG_ROOT, name); + try { if (!statSync(dir).isDirectory()) continue; } catch { continue; } + out.push({ name, dir }); + } + // 目录名自带时间戳,倒序即最新在前 + out.sort((a, b) => b.name.localeCompare(a.name)); + return out; +} + +/** 从日志里取这个 shell 的直连 MCP 端口 */ +function discoverShellPort(shellId, { fresh = false } = {}) { + const id = String(shellId); + if (!fresh) { + const cached = shellPorts.get(id); + if (cached) return cached.port; + } + for (const { dir } of shellLogDirs(id)) { + for (const file of ['last_info.txt', 'all_info.txt']) { + const f = path.join(dir, file); + if (!existsSync(f)) continue; + const txt = readFileSync(f, 'utf8'); + const hits = [...txt.matchAll(PORT_RE)]; + const port = hits.length ? hits[hits.length - 1][1] : txt.match(LISTEN_RE)?.[1]; + if (port) { + shellPorts.set(id, { port, dir }); + return port; + } + } + } + shellPorts.delete(id); + return null; +} + +/** + * 直连调用:shell 服务本来就是「当前课件」作用域,shellId 要脱掉 + * (带上反而可能被判成 shellId 与绑定窗口不一致)。 + */ +async function directRpc(port, name, args = {}, timeoutMs = DEFAULT_TIMEOUT_MS) { + const once = async (a) => { + try { + return await rpcOn(port, name, a, timeoutMs); + } catch (e) { + // 端口被复用时旧会话会失效,重握手一次 + if (/session|会话/i.test(String(e.message))) { + const st = sessionOf(port); + st.sid = null; + st.initialized = false; + return await rpcOn(port, name, a, timeoutMs); + } + throw e; + } + }; + const clean = { ...args }; + const hadShell = Object.prototype.hasOwnProperty.call(clean, 'shellId'); + delete clean.shellId; + try { + return await once(clean); + } catch (e) { + if (hadShell && /shellId|绑定|绑定的|Usage error|请先调用/i.test(String(e.message))) { + return await once(args); + } + throw e; + } +} + +/** 判断这个 shell 该走云端还是直连;结果按 shell 缓存,避免每次都等超时 */ +async function routeFor(shellId) { + const id = String(shellId); + const cached = routes.get(id); + if (cached && cached.kind !== 'dead') return cached; + // 已知彻底不通时不要每次调用都重等两轮探测,15 秒后再试 + if (cached && cached.kind === 'dead' && Date.now() - (cached.at ?? 0) < 15000) return cached; + + let cloudError = null; + try { + await rpcOn(MCP_PORT, 'get_current_courseware_info', { shellId: id }, PROBE_TIMEOUT_MS); + const r = { kind: 'cloud', port: discoverShellPort(id), at: Date.now() }; + routes.set(id, r); + return r; + } catch (e) { + if (!isTransportError(e)) { + // 有业务返回,说明云端代理是通的 + const r = { kind: 'cloud', port: discoverShellPort(id), at: Date.now() }; + routes.set(id, r); + return r; + } + cloudError = e; + } + + const port = discoverShellPort(id, { fresh: true }); + if (port) { + try { + await rpcOn(port, 'get_current_courseware_info', {}, PROBE_TIMEOUT_MS); + const r = { kind: 'direct', port, reason: `云端代理无响应(${cloudError.message}),改走直连 ${port}`, at: Date.now() }; + routes.set(id, r); + return r; + } catch (e) { + cloudError = new Error(`${cloudError.message};直连 ${port} 也失败:${e.message}`); + } + } + const r = { kind: 'dead', port, reason: String(cloudError?.message || '未知'), at: Date.now() }; + routes.set(id, r); + return r; +} + +/** 带 shellId 的工具调用:云端代理坏了就自动改直连 */ +async function callShellTool(name, args = {}, { timeoutMs = DEFAULT_TIMEOUT_MS, shellId } = {}) { + const id = String(shellId); + const route = await routeFor(id); + + if (route.kind === 'dead') { + throw new Error( + `云端 MCP 到 shell ${id} 的代理没有响应,也找不到可用的直连端口。` + + `原因:${route.reason}。请重启希沃白板后重试。`, + ); + } + + if (route.kind === 'cloud') { + try { + return await rpcOn(MCP_PORT, name, args, timeoutMs); + } catch (e) { + if (!isTransportError(e)) throw e; + // 探活通过但这次仍超时:立即降级,别让调用方干等 + const port = discoverShellPort(id, { fresh: true }); + if (port) { + try { + const r = await directRpc(port, name, args, timeoutMs); + routes.set(id, { kind: 'direct', port, reason: `云端代理超时(${e.message}),改走直连 ${port}`, at: Date.now() }); + return r; + } catch (e2) { + routes.set(id, { kind: 'dead', port, reason: `${e.message};直连失败:${e2.message}`, at: Date.now() }); + throw e2; + } + } + routes.set(id, { kind: 'dead', port: null, reason: e.message, at: Date.now() }); + throw e; + } + } + + try { + return await directRpc(route.port, name, args, timeoutMs); + } catch (e) { + // shell 重启后端口会变,重新发现一次 + const port = discoverShellPort(id, { fresh: true }); + if (port && port !== route.port) { + const r = await directRpc(port, name, args, timeoutMs); + routes.set(id, { kind: 'direct', port, at: Date.now() }); + return r; + } + throw e; + } +} + +async function mcp(name, args = {}, { timeoutMs, direct = false } = {}) { + const shellId = args && args.shellId != null ? String(args.shellId) : null; + if (!direct && shellId && !CLOUD_ONLY.has(name)) { + return callShellTool(name, args, { timeoutMs: timeoutMs ?? DEFAULT_TIMEOUT_MS, shellId }); + } await ensureInit(); try { return await rpc(name, args, { timeoutMs }); } catch (e) { // 会话过期时重新握手一次 - if (/session|会话|ShellId/i.test(String(e.message))) { - sessionId = null; - initialized = false; + if (/session|会话/i.test(String(e.message))) { + const st = sessionOf(MCP_PORT); + st.sid = null; + st.initialized = false; await ensureInit(); return await rpc(name, args, { timeoutMs }); } @@ -102,6 +319,40 @@ async function mcp(name, args = {}, { timeoutMs } = {}) { } } +/** 给结果用:这个 shell 当前实际走的链路(cloud / direct) */ +export function shellRouteOf(shellId) { + const r = routes.get(String(shellId)); + if (!r) return null; + return { kind: r.kind, port: r.port ?? null, ...(r.reason ? { reason: r.reason } : {}) }; +} + +/** 给 diagnose 用:这个 shell 的云端代理 / 直连端口各自是否可用 */ +export async function shellTransportOf(shellId) { + const id = String(shellId); + let cloud; + try { + const info = await rpcOn(MCP_PORT, 'get_current_courseware_info', { shellId: id }, PROBE_TIMEOUT_MS); + cloud = { ok: true, info }; + } catch (e) { + cloud = { ok: false, error: e.message }; + } + const port = discoverShellPort(id, { fresh: true }); + let direct = { ok: false, port: port ?? null, ...(port ? {} : { error: '日志里没有找到该 shell 的 MCP 端口' }) }; + if (port) { + try { + const info = await rpcOn(port, 'get_current_courseware_info', {}, PROBE_TIMEOUT_MS); + direct = { ok: true, port, info }; + } catch (e) { + direct = { ok: false, port, error: e.message }; + } + } + // 顺便把探活结果写进路由缓存,diagnose 之后的调用不用再等一次超时 + if (cloud.ok) routes.set(id, { kind: 'cloud', port: direct.port ?? null, at: Date.now() }); + else if (direct.ok) routes.set(id, { kind: 'direct', port, reason: `云端代理无响应(${cloud.error}),改走直连 ${port}`, at: Date.now() }); + else routes.set(id, { kind: 'dead', port: direct.port ?? null, reason: String(cloud.error || direct.error || '未知'), at: Date.now() }); + return { cloud, direct, route: routes.get(id) ?? null }; +} + const shells = () => mcp('en_find_shells', { searchingMode: 'All' }) .then(r => r.data?.shells ?? []) .catch(() => []); @@ -1102,6 +1353,10 @@ async function ensureEditMode(shellId, { timeoutMs = 20000 } = {}) { let mode = null; let tries = 0; while (Date.now() < deadline) { + // 首选云端窗口列表里的 workingMode(直连端口的 get_current_courseware_info 不带 shellContext) + const cur = (await shells()).find(s => String(s.id) === String(shellId)); + mode = cur?.workingMode ?? mode; + if (mode === 'Edit') return true; const info = await mcp('get_current_courseware_info', { shellId }, { timeoutMs: 12000 }).catch(() => null); mode = infoOf(info)?.shellContext?.workingMode ?? mode; if (mode === 'Edit') return true; @@ -1197,6 +1452,7 @@ async function runEdit(cw, opts, action) { ...(warnings.length ? { warnings } : {}), reopened: !!shellId, shellId, + ...(shellId ? { transport: shellRouteOf(shellId) } : {}), sync: syncText, }; }); @@ -2485,9 +2741,17 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend const list = (await shells()).filter(s => sameCourseware(s, cw)); const details = []; for (const s of list) { - const info = await mcp('get_current_courseware_info', { shellId: s.id }, { timeoutMs: 12000 }).catch(() => null); + const tr = await shellTransportOf(s.id); + const info = tr.cloud.ok ? tr.cloud.info : (tr.direct.ok ? tr.direct.info : null); const d = infoOf(info) ?? {}; - if (!info) { + if (!tr.cloud.ok && tr.direct.ok) { + push('warn', 'proxy-dead', + `shell ${s.id} 的云端 MCP 代理无响应(${tr.cloud.error}),kit 已自动改走直连端口 ${tr.direct.port};` + + '写操作仍可用,但云端代理要重启希沃才会恢复'); + } else if (!tr.cloud.ok && !tr.direct.ok) { + push('error', 'shell-unreachable', + `shell ${s.id} 的云端代理和直连端口都不可用(云端:${tr.cloud.error};直连:${tr.direct.error ?? '无端口'});此时不要写课件`); + } else if (!info) { push('warn', 'shell-unresponsive', `shell ${s.id} 12 秒内没有响应(可能正在渲染、切换界面或关闭),此时不要写课件`); } details.push({ @@ -2496,6 +2760,13 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend pages: typeof d.slideCount === 'number' ? d.slideCount : null, size: typeof d.size === 'number' ? d.size : null, remoteId: d.remoteId ?? null, + transport: { + cloud: tr.cloud.ok ? 'ok' : 'dead', + ...(tr.cloud.ok ? {} : { cloudError: tr.cloud.error }), + direct: tr.direct.ok ? 'ok' : 'dead', + directPort: tr.direct.port ?? null, + ...(tr.direct.ok ? {} : (tr.direct.error ? { directError: tr.direct.error } : {})), + }, }); } live = { open: details.length, shells: details }; @@ -2538,7 +2809,7 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend if (!render.ok) push('warn', 'render', `截图只拿到 ${bytes} 字节,渲染可能没起来`); } catch (e) { render = { ok: false, page: renderPage, ms: Date.now() - startedAt, error: e.message }; - push('error', 'render', `截图接口 ${timeoutSec} 秒没返回,渲染线程很可能已卡死;重启希沃后再继续`); + push('error', 'render', `截图 ${timeoutSec} 秒没返回(云端代理和 shell 直连都没成功);重启希沃后再继续`); } } } @@ -2566,6 +2837,7 @@ export async function diagnoseCourseware({ courseware, checkRender = false, rend issues, tips: issues.length ? [ 'multi-instance/display-mode 两种报错都不是让你忽略的:它们说明希沃里有多份内容,任何一方保存都会覆盖另一方。', + 'proxy-dead 表示云端 MCP 到该窗口的转发链路坏了:kit 会自动走直连端口,写入不受影响,但重启希沃才会修好云端代理。', 'render 报错时不要反复重试截图,重启希沃最快。', ] : [], }; @@ -3063,7 +3335,7 @@ export async function exportSlides({ page: n, path: file, bytes, attempts, ...(ok ? {} : { error: timedOut - ? `截图超时(${timeoutSec} 秒)。请确认希沃窗口在前台、课件已完整加载;必要时重启希沃后重试,或调大 timeoutSec。` + ? `截图超时(${timeoutSec} 秒):云端代理和 shell 直连都没有返回。请确认希沃窗口已完整加载,必要时重启希沃,或调大 timeoutSec。` : (lastError ?? '没有生成截图文件'), timedOut, ...(stale ? { stale: true } : {}), }), @@ -3072,10 +3344,10 @@ export async function exportSlides({ aborted = true; break; } - // 连续两页超时基本可以断定渲染线程已死,继续只会更慢 + // 连续两页超时基本可以断定链路已死,继续只会更慢 if (consecutiveTimeouts >= 2) { aborted = true; - abortedReason = `连续 ${consecutiveTimeouts} 页截图超时,希沃渲染线程很可能已卡死,请重启希沃后再导出`; + abortedReason = `连续 ${consecutiveTimeouts} 页截图超时(云端代理与直连都不可用),请重启希沃后再导出`; break; } } @@ -3086,13 +3358,14 @@ export async function exportSlides({ courseware: cw.name, localId: cw.localId, shellId: shell.id, opened, outDir: dir, workingMode: modeNow, + ...(shellRouteOf(shell.id) ? { transport: shellRouteOf(shell.id) } : {}), ...(keptDisplayMode ? { note: '课件停在授课界面:为免丢内容没有切回备课,截图即当前授课画面。' } : {}), count: files.length, requested: nums.length, succeeded, failed, skipped: nums.length - files.length, aborted, ...(aborted ? { hint: abortedReason - ?? '已中止剩余页面:希沃截图接口卡住了。重启希沃、让课件完整加载后再导出,比继续等更快。', + ?? '已中止剩余页面:截图一直超时(云端代理与直连都不可用)。重启希沃、让课件完整加载后再导出,比继续等更快。', } : {}), timeoutSec, files, };