dsh-ppt 0.15.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.en.md +2 -0
- package/README.md +1 -0
- package/docs/COACHING.md +4 -0
- package/docs/USAGE.md +1 -0
- package/docs/VALIDATION.md +2 -0
- package/docs/VISUAL.md +58 -0
- package/docs/validation-0.16.0.md +30 -0
- package/docs/validation-0.16.1.md +29 -0
- package/lib/client.js +106 -7
- package/lib/index.js +6 -1
- package/lib/types.d.ts +8 -0
- package/lib/visual-model.d.ts +13 -0
- package/lib/visual-model.js +104 -0
- package/lib/visual.d.ts +197 -0
- package/lib/visual.js +382 -0
- package/lib/workbench.d.ts +4 -0
- package/lib/workbench.js +37 -4
- package/package.json +2 -2
- package/skills/dsh-ppt/SKILL.md +1 -0
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +19 -2
- package/skills/dsh-ppt/scripts/deck-core.mjs +10 -3
- package/skills/dsh-ppt/scripts/deck-visual.mjs +79 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
[历史英文记录](docs/CHANGELOG.en.md)
|
|
6
6
|
|
|
7
|
+
## 0.16.1(2026-10-24)
|
|
8
|
+
|
|
9
|
+
- 适配 DSH 0.2.1-rc.3 的动态模型目录:视觉检查、AI 预审与模拟答辩按提供方和模型 ID 保留选择,刷新或重排目录不会悄悄更换模型。
|
|
10
|
+
- 已选模型下线时清空选择并禁用开始按钮,等待重新选择。首次仅沿用仍然可用的工程模型,不自动选择目录里的第一个模型。
|
|
11
|
+
- Windows 测试、官方 RC.3 发布包安装和实际浏览器范围见 [0.16.1 验证记录](docs/validation-0.16.1.md)。
|
|
12
|
+
|
|
13
|
+
## 0.16.0(2026-10-23)
|
|
14
|
+
|
|
15
|
+
- 新增可选 AI 看图检查与排版修复:通过官方 DSH 图片附件和预备模型接口检查最终 PPTX 渲染图片,记录页面与问题区域。
|
|
16
|
+
- 修复仅使用字号、要点 / 表格拆页、柱图转横向条形图、图片完整显示等受限操作;不让模型重写原文、数值或公式。每轮另存可撤销副本,并重新渲染后复查新增页面。
|
|
17
|
+
- 工作台提供调用上限、停止、前后实际画面对比、未解决问题、历史与 Markdown 记录。旧工程、变化的 PPTX、渲染图片或副本不能误用。
|
|
18
|
+
- 普通成品生成不启动视觉模型;需自行配置支持图片输入的 DSH 模型和可选官方渲染引擎。范围与边界见[看图修复](docs/VISUAL.md)。
|
|
19
|
+
- Windows 测试、真实 DSH Web、真实模型样例、原生 PPTX 渲染和全新安装范围见 [0.16.0 验证记录](docs/validation-0.16.0.md)。
|
|
20
|
+
|
|
7
21
|
## 0.15.0(2026-10-23)
|
|
8
22
|
|
|
9
23
|
- 新增可选数据模型:数字绑定原始材料行、CSV / TSV 单元格或受限算术公式;点击 HTML 数字逐层追问来源,未绑定数字明确提示。
|
package/README.en.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# dsh-ppt
|
|
2
2
|
|
|
3
|
+
Optional **visual review and repair** inspects images rendered from the actual PPTX, highlights problem regions, creates a formatting-only copy and renders it again for rechecking. The original stays intact. See [visual review](docs/VISUAL.md#english).
|
|
4
|
+
|
|
3
5
|
[中文](README.md)
|
|
4
6
|
|
|
5
7
|

|
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- 可选数字溯源与现场推演:点击数字追到原始材料、CSV 单元格或公式;调整假设、预览影响并确认保存。HTML 保留交互,PPTX 保存静态结果及公式 / 假设,见[数据说明](docs/DATA.md)。
|
|
17
17
|
- 在设置页编辑文字和图片、调整顺序、复制或删除页面,并支持撤销。
|
|
18
18
|
- 提供质量检查与可选的最终 PPTX 图片 / PDF 渲染。
|
|
19
|
+
- 可选 AI 视觉检查:看实际 PPTX 图片,标记问题区域,调整排版并另存副本,重新渲染复查;支持前后对比、停止、撤销与检查记录。见[看图修复](docs/VISUAL.md)。
|
|
19
20
|
- 下载按页整理的 Markdown 讲稿,保留当前版本的标题与演讲备注。
|
|
20
21
|
- 可选 AI 预审与模拟答辩:复用 DSH 已配置模型,按需提问、比较改稿、另存可撤销副本,并导出问答与待补充材料清单。默认关闭,直接下载成品无需预审。
|
|
21
22
|
- 键盘操作:Ctrl/⌘+S 保存、Esc 取消或返回、Alt+←/→ 切换页面;有未保存修改时离开会提示。
|
package/docs/COACHING.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
先选择 DSH 已配置的文字模型、听众、温和 / 普通 / 严格的提问强度,以及整个工程或当前页。需要时粘贴补充材料,或导入 TXT / Markdown(最多 20,000 字符,文件最多 100 KB)。开始按钮说明将发送哪些内容和最多调用几次;点击后才发起生成。可用时优先选中生成工程时的模型;旧工程需要自行核对模型。
|
|
13
13
|
|
|
14
|
+
刷新目录或切换预审 / 答辩时会保留仍然可用的已选模型。原提供方或模型下线后,必须重新选择才能开始,不会自动换用目录中的其他模型。
|
|
15
|
+
|
|
14
16
|
只发送所选页面的文字、表格 / 图表数据、备注及主动提供的补充材料,不发送图片文件、密钥或工作区文件。模型调用不附带文件、终端等工具。请在开始前检查输入是否适合交给所选模型服务。供应商自身的重试和计费规则仍然适用,次数上限指插件主动发起的调用。
|
|
15
17
|
|
|
16
18
|
## 如何使用结果
|
|
@@ -37,6 +39,8 @@ Finished files remain the primary output. AI review and rehearsal are optional a
|
|
|
37
39
|
|
|
38
40
|
Choose a configured DSH text model, audience, difficulty, scope and optional supporting material. Click Start to send selected slide text, table/chart data, notes and the supplied material; image files are excluded. No file or shell tools are offered to the model. No additional account is needed beyond the chosen DSH provider.
|
|
39
41
|
|
|
42
|
+
Catalog refresh and mode changes preserve an available selection by provider and model ID. If the selected route disappears, choose again before starting; another model is never substituted automatically.
|
|
43
|
+
|
|
40
44
|
Review makes up to three plugin calls. Practice asks one question at a time and accepts human answers: one initial question plus feedback for up to five questions, at most six plugin calls. Provider retries and billing rules still apply. You can stop a call or finish early; stopping may still incur a charge, and failed attempts use the current budget. There is no automatic retry.
|
|
41
45
|
|
|
42
46
|
Compare source quotes and proposed edits before adopting them. Only eligible expression suggestions can directly change wording; logic and evidence gaps remain preparation tasks. Exact quote and numeric checks are limited safeguards, not factual certification. Save selected edits and Q&A backup slides to a new copy; the original artifacts remain intact and Undo restores the copy to its pre-adoption content. Copies are generated from JSON and do not import Office edits.
|
package/docs/USAGE.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
| `ppt_check` | 只读质量检查,定位具体页的问题;可复核当前渲染收据 |
|
|
21
21
|
| `ppt_render` | 可选官方引擎生成 PNG / PDF,保留源 PPTX,报告缺失字体 |
|
|
22
22
|
| `ppt_data` | 可选来源更新与假设推演,先预览差异再确认保存;见[数据说明](DATA.md) |
|
|
23
|
+
| AI 看图修复 | 可选实际 PPTX 图片检查、排版副本和重新渲染复查;在设置页开启,见[看图修复](VISUAL.md) |
|
|
23
24
|
| 品牌 | 共享颜色、字体、Logo、页脚,同步到 HTML 与 PPTX |
|
|
24
25
|
| 演讲者备注 | `<!-- 备注: ... -->` 或 `notes` 字段:HTML 按 `S` 呼出,PPTX 原生备注页(演示者视图) |
|
|
25
26
|
| 动效(motion) | 默认开:HTML 页间淡入 + 要点逐条入场;PPTX 原生转场 + 要点逐条点击显现;`motion: 'off'` / `--motion off` 产出纯静态 |
|
package/docs/VALIDATION.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
## 最新记录
|
|
8
8
|
|
|
9
|
+
[0.16.0 看图检查与排版修复验收](validation-0.16.0.md):200 项测试、真实 DSH 图片与模型接口、实际模型样例、修复副本复查、中文操作与英文深色窄屏、官方 CLI 全新安装。AI 检查结果与人工 / 桌面原生验收分开记录。
|
|
10
|
+
|
|
9
11
|
[0.15.0 数字溯源与推演验收](validation-0.15.0.md):自动测试、真实 DSH Web / 离线 HTML 操作、来源更新、参数回存、复制撤销、四页最终 PPTX 原生渲染及画面核对。桌面原生窗口内逐项操作另行验收。
|
|
10
12
|
|
|
11
13
|
[0.14.0 可选 AI 预审与答辩验收](validation-0.14.0.md):151 项测试、真实 DSH Web 及原生模拟模型、复制 / 撤销 / 下载 / 取消 / 旧修订保护、中文与英文深色窄屏。真实模型效果、桌面原生窗口和完整 Office 视觉比对本次未测。
|
package/docs/VISUAL.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# AI 视觉检查与排版修复
|
|
2
|
+
|
|
3
|
+
[返回简介](../README.md) · [English](#english)
|
|
4
|
+
|
|
5
|
+
普通生成仍直接提供 PPTX、HTML 和工程文件。需要进一步检查时,在 **设置 → 演示文稿 → 打开工程 → 视觉检查与修复** 主动开启。
|
|
6
|
+
|
|
7
|
+
模型目录可随 DSH 更新。点击“刷新视觉模型”会保留仍然可用的原选择;原模型下线时清空选择,重新选定后才能开始,不会自动换成另一个模型。
|
|
8
|
+
|
|
9
|
+
## 怎么用
|
|
10
|
+
|
|
11
|
+
1. 选择 DSH 已配置、明确声明支持图片输入的视觉模型。选当前页,或一次检查最多 12 页。
|
|
12
|
+
2. 选择“仅看图检查”,或最多自动修复 1 / 2 轮。开始前会显示发送范围与调用上限。
|
|
13
|
+
3. 插件读取当前实际 PPTX,用官方 LibreOffice Kit 渲染,然后把所选页的图片和页面文字交给模型。
|
|
14
|
+
4. 模型发现可处理的排版问题后,插件保留原稿,生成可撤销副本,再读取副本的 PPTX 重新渲染、复查。拆出的新页也会检查。
|
|
15
|
+
5. 查看前后画面,橙框表示模型定位的区域。“采用修复副本”打开复查后的工程;仍有问题时会明确标注。可以撤销、下载最新成品或导出检查记录。
|
|
16
|
+
|
|
17
|
+
**一轮修复包括“检查 → 修改 → 再渲染检查”,不是一次模型调用。** 每次调用最多两张图片,每张渲染图最多 4 MiB;若所有选定页面都拆分,最多两轮修复会检查原来的四倍页数。12 个原始页面、两轮修复的最坏调用上限为 42 次,开始前会展示。服务商自身的重试、计费规则仍然适用。
|
|
18
|
+
|
|
19
|
+
## 能自动改什么
|
|
20
|
+
|
|
21
|
+
| 操作 | 保留的内容 |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| 标题字号 24–60 pt、正文字号 16–28 pt | 原文不改写,PPTX 与 HTML 同步 |
|
|
24
|
+
| 图表标签字号 14–24 pt | 分类、系列、数值、单位和公式不改 |
|
|
25
|
+
| 柱状图改为横向条形图 | 保留全部数据与数字绑定 |
|
|
26
|
+
| 过密要点或表格拆页 | 保留顺序、原文、表头、备注和数字绑定 |
|
|
27
|
+
| 图片改为完整显示 | 使用已有嵌入图片,不新增图片或读取文件 |
|
|
28
|
+
|
|
29
|
+
不能用这些操作解决的问题会留下说明。不会根据模型意见捏造内容、重写结论、替换数字、安装字体或下载图片,也不会把“未发现明显问题”当作人工验收通过。缺失字体会单独报告。
|
|
30
|
+
|
|
31
|
+
## 模型与渲染条件
|
|
32
|
+
|
|
33
|
+
- 模型必须通过 DSH 的原生模型服务声明 `text` 和 `image` 输入;不会根据模型名字猜测视觉能力。对于自定义 pi-ai 模型,需要在宿主模型配置中明确相应的 `input: [text, image]` 能力,且实际服务必须支持。
|
|
34
|
+
- 使用 DSH 原生图片附件与绑定模型版本的 `prepareCall`,不给模型文件、终端或其他工具。插件不保存单独的 API Key。
|
|
35
|
+
- 可选渲染器为 `@deepseek-ai/libreoffice-kit@0.1.5`,普通成品生成不依赖它。安装与字体说明见[使用说明](USAGE.md#可选-png--pdf-渲染)。
|
|
36
|
+
- 不满足条件、调用失败或输出截断时会停止,保留已有结果,不自动重新发起插件调用。可修正条件后主动新建检查。
|
|
37
|
+
|
|
38
|
+
## 停止、版本和本地记录
|
|
39
|
+
|
|
40
|
+
运行时可随时停止。已完成的副本会保留,尚未复查的页面不会被标成完成;已发起的服务请求仍可能计费。中断记录不会自动续跑。
|
|
41
|
+
|
|
42
|
+
检查绑定原工程、JSON 内容、实际 PPTX 与逐页渲染校验值。检查中或检查后文件变化,会保留旧报告并拒绝继续或误采纳。Office 手工修改过的 PPTX 不能套用旧 JSON 的自动修改;需先保留 Office 原件,再决定是否从 JSON 另存工程副本。
|
|
43
|
+
|
|
44
|
+
每个工程最多 20 次、本机最多 200 次记录。删除检查记录会删除该次插件预览图片,保留原稿和已生成的 PPT 副本。DSH 附件服务本身的存储与清理由宿主管理,不在插件删除范围内。检查图片会发送至所选模型服务;完整源材料和历史不会作为额外材料发送,但图片及所选页面文字中出现的内容会发送。
|
|
45
|
+
|
|
46
|
+
## English
|
|
47
|
+
|
|
48
|
+
Open **Settings → Presentations → a project → Visual review and repair**. Choose a configured image-capable model, the current slide or up to 12 original slides, and inspection only or up to two repair rounds.
|
|
49
|
+
|
|
50
|
+
Refreshing the catalog preserves an available selection by provider and model ID. If that route disappears, selection is cleared and Start stays disabled until you choose again; another model is never substituted automatically.
|
|
51
|
+
|
|
52
|
+
The plugin renders the actual PPTX using the optional official LibreOffice Kit, sends the selected images and visible slide content through native DSH model and attachment services, and records image-based findings. A small formatting vocabulary may create an undoable copy: font sizes, bullet/table splits, horizontal bars or uncropped images. Original wording, values, formulas and source bindings remain intact.
|
|
53
|
+
|
|
54
|
+
Each repaired PPTX is rendered and inspected again, including newly split pages. Compare actual before/after images before adopting the copy. AI findings are not human verification. Unsupported issues and missing fonts remain explicit; errors, truncated output or cancellation stop the run without automatic plugin retries. The source presentation is preserved.
|
|
55
|
+
|
|
56
|
+
Each request carries at most two images. Splitting can increase the scope; the maximum number of requests is shown before starting (at most 42 for 12 original slides and two repair rounds). Providers may have separate retries or billing. Ordinary generation never starts this optional flow.
|
|
57
|
+
|
|
58
|
+
Records are local and tied to exact project/render hashes. A changed project, PPTX, image or copy cannot be reused as a current review. Deleting a record removes its plugin preview images, not presentation files or the host-managed DSH attachment store.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# 0.16.0 验证范围
|
|
2
|
+
|
|
3
|
+
日期:2026-10-23。自动检查、真实宿主、模型服务、渲染和桌面原生窗口分别记录。
|
|
4
|
+
|
|
5
|
+
## 自动检查
|
|
6
|
+
|
|
7
|
+
- Windows / Node 24:200 项测试通过,其中 20 项看图修复回归。覆盖默认不调用模型、检查 / 修复上限、逐页返回、受限操作、完整原文与数据绑定、表格表头、原生图表方向与字号、图片完整显示、副本撤销、原稿字节保留。
|
|
8
|
+
- 覆盖停止调用、两步之间停止、保留未复查副本且禁止采纳、重复请求、旧工程与 Office 改动、渲染图片校验、错误 JSON、输出截断、无有效视觉模型 / 无渲染器、外部服务错误脱敏、历史与删除边界。
|
|
9
|
+
- TypeScript、浏览器脚本语法与 diff 空白检查通过。渲染 / 模型契约测试中的固定图片和模拟适配器不当作真实视觉质量证据。
|
|
10
|
+
|
|
11
|
+
## 真实官方宿主与浏览器
|
|
12
|
+
|
|
13
|
+
- 官方 DSH 0.2.1-rc.2 隔离 Web profile,8 个 PPT 工具注册;未登录 401、正常启动令牌交换 303、已认证首页 200。
|
|
14
|
+
- Browser plugin not available;使用已安装的无头 Chrome / Playwright,不切换用户前台窗口。
|
|
15
|
+
- 1440×1000 中文界面:选择模型与范围、实际 PPTX 渲染、检查、拆分 8 条过密要点、重新渲染复查、橙框和前后画面对比、采纳副本、下载 PPTX、撤销、停止与空模型选择均操作验收。下载文件与确认副本字节一致,原稿三件套保持完整。
|
|
16
|
+
- 390×844 英文深色界面:PPT 面板可用宽度和 scrollWidth 均为 366px,无横向溢出;错误 JSON 停止且提示为英文,用户撰写的中文标题保留。页面未捕获异常为 0。
|
|
17
|
+
- 官方 LibreOffice Kit 0.1.5 Windows 原生引擎:原稿 3 页、副本 4 页逐页渲染,实际查看封面、两页要点与原生图表。过密内容拆为 4 条 / 页,完整文本和图表数据保留。
|
|
18
|
+
|
|
19
|
+
## 模型调用
|
|
20
|
+
|
|
21
|
+
- 模拟模型通过真实 DSH 图片附件、模型注册、精确路由准备及流式接口,验证发送的是实际渲染图片和正确页码,模型没有工具权限;3→4 页完整链路使用 4 次调用,低于预先显示的 5 次上限。
|
|
22
|
+
- 另用本地已配置的 `gpt-6.1-sol` 服务路由验收当前过密页。该模型在原图指出 8 条长要点拥挤,提出保留 4 条并拆页;生成副本后发送两页实际图片复查,共 2 次调用,复查未再列出问题。随后查看了这两页真实渲染结果。这只证明该路由与样例,不代表所有模型或所有演示稿的判断质量。
|
|
23
|
+
- 验收中外部适配器曾返回 `PI_AI_ERROR`;相应运行停止、保留失败状态且没有自动再次调用。后来主动新建的运行成功完成。服务可用性和插件状态处理分开记录。
|
|
24
|
+
- 仅在隔离 profile 为已验证的自定义模型声明图片输入。用户的全局模型配置与凭据未改写。
|
|
25
|
+
|
|
26
|
+
## 安装与边界
|
|
27
|
+
|
|
28
|
+
- 本地发布包通过官方 `dsh plugin --profile web add <tarball>` 全新安装:8 工具、真实宿主启动、3→4 页看图修复 / 采纳、副本渲染和原稿保留通过,启动认证 303 / 401 / 200。
|
|
29
|
+
- 普通生成仍不要求视觉模型或可选渲染器。
|
|
30
|
+
- 新功能未逐项进行桌面原生窗口、真实 PowerPoint / WPS、macOS / Linux 的视觉验收。AI 的“未发现问题”和成功渲染都不等于人工验收通过。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 0.16.1 / DSH RC.3 验证范围
|
|
2
|
+
|
|
3
|
+
日期:2026-10-24。目标为官方 DSH `0.2.1-rc.3`(tag `dsh-v0.2.1-rc.3`),使用公开 npm 运行时和 Windows / Node 24。
|
|
4
|
+
|
|
5
|
+
## 问题与修复
|
|
6
|
+
|
|
7
|
+
在公开 PPT 0.16.0 的真实 Web 面板中复现:选择目录中的模型后,更新目录再点击“刷新视觉模型”,序号被重新解释为另一个模型,开始按钮仍可用。RC.3 让官方 API Key 路由跟随动态模型列表,使目录变动成为正常使用场景。
|
|
8
|
+
|
|
9
|
+
0.16.1 的视觉检查、AI 预审和模拟答辩统一按提供方及模型 ID 保存选择。重排、改显示名称不会改路由;原路由消失就清空选择并禁用开始按钮。没有可用的工程模型时,首次打开也要求明确选择,不自动采用列表首项。
|
|
10
|
+
|
|
11
|
+
## 自动检查
|
|
12
|
+
|
|
13
|
+
- Windows 完整测试通过,新增 6 项模型选择回归,覆盖目录重排、路由删除、空选择、精确初始偏好、提供方与分隔符碰撞、显示名称变化。
|
|
14
|
+
- TypeScript 构建、浏览器脚本语法和 diff 空白检查通过。
|
|
15
|
+
|
|
16
|
+
## 发布包与真实浏览器
|
|
17
|
+
|
|
18
|
+
- 候选 npm tarball 通过官方 CLI 安装到全新隔离 Web profile;普通生成器生成四页 PPTX、HTML 和 JSON 作为界面夹具。
|
|
19
|
+
- Browser plugin not available;使用已安装的无头 Chrome / Playwright,不切换用户前台窗口。
|
|
20
|
+
- 1440×1000 中文界面实际操作三处选择器:模型消失后选择清空且开始按钮禁用;视觉检查和 AI 预审的目录重排保留原路由,切换到模拟答辩也保留选择。仅文字模型不进入视觉模型列表。
|
|
21
|
+
- 390×844 英文深色界面:占位选项、刷新和禁用状态正常;PPT 面板 clientWidth / scrollWidth 均为 366px,无横向溢出。页面未捕获异常为 0。
|
|
22
|
+
- 模型目录变化由注册进官方 LLM 服务的隔离适配器控制。它没有 API Key、外网请求或模型生成能力;目录切换验收期间生成调用数为 0。这是接口与交互验收,不是实际 DeepSeek 模型效果验收。
|
|
23
|
+
|
|
24
|
+
## 其他插件与边界
|
|
25
|
+
|
|
26
|
+
- 既有 Suite 0.2.35 的 18 组件在官方 RC.3 上通过契约与公开 npm 全新安装,19 个包的完整性匹配;实际共同启动为 112 个工具、36 项技能,PTC、完整 SDK 及四个官方调度工具可用,认证检查为 303 / 401 / 200。
|
|
27
|
+
- 加载独立 Review 0.3.0 与 Computer Use 0.1.2 的隔离宿主共同启动为 138 个工具、37 项技能,随后关闭。该检查不代表两者所有业务动作都已测试。
|
|
28
|
+
- 打开九个已有设置工作台检查入口与渲染。未配置账号的邮件工作台明确返回配置提示;这不是实际收发邮件验收。
|
|
29
|
+
- 本轮未逐项操作桌面原生窗口、PowerPoint / WPS,也未重复真实模型和原生渲染质量验收。Docker、Slack、钉钉的真实外部服务验收继续按用户要求搁置。既有 issue 不因兼容启动通过而视为解决。
|
package/lib/client.js
CHANGED
|
@@ -281,6 +281,13 @@ function useLanguage(locale) {
|
|
|
281
281
|
},
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
+
function modelRouteKey(model) { return JSON.stringify([model.provider, model.model]); }
|
|
285
|
+
function findModelRoute(models, key) { return key ? models.find(model => modelRouteKey(model) === key) : undefined; }
|
|
286
|
+
function reconcileModelRoute(models, selected, preferred) {
|
|
287
|
+
if (selected) return findModelRoute(models, selected) ? selected : '';
|
|
288
|
+
const key = preferred ? modelRouteKey(preferred) : '';
|
|
289
|
+
return findModelRoute(models, key) ? key : '';
|
|
290
|
+
}
|
|
284
291
|
function CoachingPanel({ project, selected, blocked, onAdopt, onChoose }) {
|
|
285
292
|
const L = (zh, en) => languageOf() === 'en' ? en : zh;
|
|
286
293
|
const [mode, setMode] = useState(''), [routes, setRoutes] = useState([]), [route, setRoute] = useState('');
|
|
@@ -288,7 +295,7 @@ function useLanguage(locale) {
|
|
|
288
295
|
const [scope, setScope] = useState('all'), [material, setMaterial] = useState(''), [run, setRun] = useState(null), [history, setHistory] = useState([]);
|
|
289
296
|
const [answer, setAnswer] = useState(''), [patches, setPatches] = useState([]), [backups, setBackups] = useState([]);
|
|
290
297
|
const [busy, setBusy] = useState(false), [error, setError] = useState(''), [notice, setNotice] = useState('');
|
|
291
|
-
const active = useRef(null), alive = useRef(true), current = useRef(null), runRef = useRef(null), reading = useRef(0);
|
|
298
|
+
const active = useRef(null), alive = useRef(true), current = useRef(null), runRef = useRef(null), reading = useRef(0), routeInitialized = useRef(false);
|
|
292
299
|
current.current = { project, selected, blocked }; runRef.current = run;
|
|
293
300
|
const stale = !!run && (run.stale || run.revision !== project.revision);
|
|
294
301
|
const maxCalls = mode === 'review' ? limit : limit + 1;
|
|
@@ -340,8 +347,9 @@ function useLanguage(locale) {
|
|
|
340
347
|
if (available.status === 'rejected') throw available.reason;
|
|
341
348
|
const models = available.value.routes;
|
|
342
349
|
setRoutes(models);
|
|
343
|
-
const preferred =
|
|
344
|
-
|
|
350
|
+
const preferred = routeInitialized.current ? undefined : project.modelRoute;
|
|
351
|
+
routeInitialized.current = true;
|
|
352
|
+
setRoute(value => reconcileModelRoute(models, value, preferred));
|
|
345
353
|
if (!models.length) setNotice(L('先在 DSH 的模型设置中配置可用模型,再点“刷新模型”。成品仍可直接下载。', 'Configure a model in DSH, then refresh models. Your finished files remain available.'));
|
|
346
354
|
if (results[1].status === 'rejected') throw results[1].reason;
|
|
347
355
|
});
|
|
@@ -363,7 +371,7 @@ function useLanguage(locale) {
|
|
|
363
371
|
function start() {
|
|
364
372
|
if (current.current.blocked) return;
|
|
365
373
|
return task(async signal => {
|
|
366
|
-
const model = routes
|
|
374
|
+
const model = findModelRoute(routes, route); if (!model) throw new Error(L('请选择模型', 'Choose a model'));
|
|
367
375
|
reading.current++;
|
|
368
376
|
const item = (await request('create', { confirmed: true, mode, ...model, difficulty, audience, limit, material,
|
|
369
377
|
language: languageOf(), ...(scope === 'current' ? { slideId: current.current.selected } : {}) }, signal)).run;
|
|
@@ -428,7 +436,7 @@ function useLanguage(locale) {
|
|
|
428
436
|
!run && h(React.Fragment, null,
|
|
429
437
|
h('p', null, mode === 'review' ? L('AI 根据材料模拟质疑与回答,最多保留 5 个值得改进的问题。', 'AI simulates questions and answers based on your material, keeping up to five useful findings.') : L('AI 一次问一题,你来回答;可随时结束并整理已完成的问答。', 'AI asks one question at a time. You answer and can finish at any point.')),
|
|
430
438
|
h('div', { className: 'coaching-grid' },
|
|
431
|
-
h('label', null, L('模型', 'Model'), h('select', { 'aria-label': L('演练模型', 'Rehearsal model'), value: route, disabled: busy, onChange: e => setRoute(e.target.value) },
|
|
439
|
+
h('label', null, L('模型', 'Model'), h('select', { 'aria-label': L('演练模型', 'Rehearsal model'), value: route, disabled: busy, onChange: e => setRoute(e.target.value) }, h('option', { value: '' }, routes.length ? L('请选择模型', 'Choose a model') : L('暂无可用模型', 'No configured model')), routes.map(r => h('option', { key: modelRouteKey(r), value: modelRouteKey(r) }, r.label)))),
|
|
432
440
|
h('label', null, L('听众', 'Audience'), h('select', { 'aria-label': L('听众', 'Audience'), value: audience, disabled: busy, onChange: e => setAudience(e.target.value) }, [['general', L('一般听众', 'General audience')], ['management', L('管理层 / 客户', 'Management / clients')], ['academic', L('答辩评委', 'Academic panel')]].map(([v, label]) => h('option', { key: v, value: v }, label)))),
|
|
433
441
|
h('label', null, L('提问强度', 'Difficulty'), h('select', { 'aria-label': L('提问强度', 'Difficulty'), value: difficulty, disabled: busy, onChange: e => setDifficulty(e.target.value) }, [['gentle', L('温和', 'Gentle')], ['normal', L('普通', 'Normal')], ['strict', L('严格', 'Strict')]].map(([v, label]) => h('option', { key: v, value: v }, label)))),
|
|
434
442
|
h('label', null, mode === 'review' ? L('预审轮数', 'Review rounds') : L('答辩题数', 'Questions'), h('select', { 'aria-label': mode === 'review' ? L('预审轮数', 'Review rounds') : L('答辩题数', 'Questions'), value: limit, disabled: busy, onChange: e => setLimit(Number(e.target.value)) }, Array.from({ length: mode === 'review' ? 3 : 5 }, (_, i) => h('option', { key: i, value: i + 1 }, String(i + 1))))),
|
|
@@ -437,7 +445,7 @@ function useLanguage(locale) {
|
|
|
437
445
|
h('textarea', { id: 'ppt-coach-material', rows: 3, maxLength: 20000, value: material, disabled: busy, onChange: e => { reading.current++; setMaterial(e.target.value); } }),
|
|
438
446
|
h('label', null, L('或导入 TXT / Markdown', 'Or import TXT / Markdown'), h('input', { type: 'file', accept: '.txt,.md,text/plain,text/markdown', disabled: busy, onChange: uploadMaterial })),
|
|
439
447
|
h('p', { className: 'muted' }, L('将所选页面的文字、图表数据、备注及补充材料发送给所选 DSH 模型,不发送图片文件。最多 ' + maxCalls + ' 次插件调用;模型服务自身的重试与计费规则仍适用。', 'Sends selected slide text, chart data, notes and supporting material to the chosen DSH model. Image files are excluded. Up to ' + maxCalls + ' plugin calls; provider retry and billing rules still apply.')),
|
|
440
|
-
h('div', { className: 'tools' }, h('button', { disabled: busy || blocked || !routes
|
|
448
|
+
h('div', { className: 'tools' }, h('button', { disabled: busy || blocked || !findModelRoute(routes, route), onClick: start }, mode === 'review' ? L('开始 AI 预审', 'Start AI review') : L('开始模拟答辩', 'Start rehearsal')), h('button', { disabled: busy, onClick: () => configure(mode) }, L('刷新模型', 'Refresh models'))),
|
|
441
449
|
blocked && h('p', { className: 'muted' }, L('请先保存或取消幻灯片修改。', 'Save or cancel slide edits first.'))),
|
|
442
450
|
run && h(React.Fragment, null,
|
|
443
451
|
h('h3', null, modeName(run.mode) + ' · ' + statusName(run.status)),
|
|
@@ -468,6 +476,94 @@ function useLanguage(locale) {
|
|
|
468
476
|
history.length > 0 && h('details', null, h('summary', null, L('本机历史记录(', 'Local history (') + history.length + L(')', ')')), h('div', { className: 'project-list' }, history.map(item => h('button', { key: item.id, disabled: busy, onClick: () => openReport(item.id) }, modeName(item.mode) + ' · ' + L('修订 ', 'Revision ') + item.revision + ' · ' + new Date(item.createdAt).toLocaleString(languageOf() === 'en' ? 'en-US' : 'zh-CN')))))));
|
|
469
477
|
}
|
|
470
478
|
const dataCss=`.pptw .data-workbench{margin-top:18px}.pptw .data-workbench details{margin:12px 0}.pptw .data-workbench summary{cursor:pointer;font-weight:600}.pptw .data-workbench pre,.pptw .data-workbench code{white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;max-height:220px;overflow:auto}.pptw .data-input-row{margin:15px 0}.pptw .data-input-controls{display:grid;grid-template-columns:minmax(0,1fr) 115px;gap:12px;align-items:center}.pptw .data-input-controls input[type=range]{accent-color:var(--dsw-alias-brand-primary,#2563eb)}.pptw .data-before-after{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.pptw .data-before-after pre{padding:10px;border:1px solid var(--dsw-alias-divider-default,#b8c0cc);border-radius:8px}.pptw .data-copy{display:flex;gap:8px;align-items:center}.pptw .data-copy input{width:auto}@media(max-width:640px){.pptw .data-before-after{grid-template-columns:minmax(0,1fr)}.pptw .data-input-controls{grid-template-columns:minmax(0,1fr) 100px}}`;
|
|
479
|
+
function VisualPanel({ project, selected, blocked, onBusy, onAdopt }) {
|
|
480
|
+
const L = (zh,en) => languageOf() === 'en' ? en : zh;
|
|
481
|
+
const [expanded,setExpanded] = useState(false), [routes,setRoutes] = useState([]), [route,setRoute] = useState('');
|
|
482
|
+
const [scope,setScope] = useState(project.slides.length > 12 ? 'current' : 'all'), [repairs,setRepairs] = useState(1);
|
|
483
|
+
const [run,setRun] = useState(null), [history,setHistory] = useState([]), [busy,setBusy] = useState(false), [error,setError] = useState('');
|
|
484
|
+
const [compare,setCompare] = useState(''), [pictures,setPictures] = useState({}), [loading,setLoading] = useState(false);
|
|
485
|
+
const active=useRef(null), alive=useRef(true), current=useRef(null), runRef=useRef(null), progressVersion=useRef(0), routeInitialized=useRef(false);
|
|
486
|
+
current.current={project,selected,blocked};runRef.current=run;
|
|
487
|
+
const request=(op,data={},signal) => action({operation:'visual-'+op,id:current.current.project.id,expectedRevision:current.current.project.revision,...data},signal);
|
|
488
|
+
const accept=value => {if(alive.current){progressVersion.current++;runRef.current=value;setRun(value);}};
|
|
489
|
+
const phaseName=value => ({render:L('正在渲染实际 PPTX','Rendering the actual PPTX'),inspect:L('正在看图检查','Inspecting rendered slides'),repair:L('正在生成排版副本','Creating a formatting copy'),done:L('检查已结束','Review finished')})[value]||value;
|
|
490
|
+
const failureText=value=>{const split=value.lastIndexOf(' / ');return split<0?value:L(value.slice(0,split),value.slice(split+3));};
|
|
491
|
+
const actionName=a => ({'title-size':L('标题字号','Title size'),'body-size':L('正文字号','Body size'),'chart-label-size':L('图表字号','Chart label size'),'chart-horizontal':L('改为横向条形图','Use horizontal bars'),'image-contain':L('完整显示图片','Show the complete image'),'split-bullets':L('拆分要点页','Split bullet slide'),'split-table':L('拆分表格页','Split table slide')})[a.type]+(a.value!==undefined?' · '+a.value:'');
|
|
492
|
+
useEffect(()=>{alive.current=true;return()=>{alive.current=false;active.current?.abort();if(runRef.current&&active.current)void request('stop',{runId:runRef.current.id}).catch(()=>{});};},[]);
|
|
493
|
+
useEffect(()=>{if(!run||['complete','paused'].includes(run.status)||!busy&&run.status!=='busy')return;const abort=new AbortController(),timer=setInterval(()=>{const version=progressVersion.current;void request('get',{runId:run.id},abort.signal).then(v=>{if(!abort.signal.aborted&&version===progressVersion.current)accept(v.run);}).catch(()=>{});},1000);return()=>{clearInterval(timer);abort.abort();};},[run?.id,run?.status,busy]);
|
|
494
|
+
async function refresh(signal){const value=await request('list',{},signal);if(alive.current)setHistory(value.runs);}
|
|
495
|
+
async function task(work,lock=false){
|
|
496
|
+
if(active.current)return;
|
|
497
|
+
const controller=new AbortController();active.current=controller;setBusy(true);setError('');if(lock)onBusy(true);
|
|
498
|
+
try{await work(controller.signal);}
|
|
499
|
+
catch(e){if(alive.current){if(!controller.signal.aborted)setError(e.message||L('视觉检查失败','Visual review failed'));if(runRef.current)try{accept((await request('get',{runId:runRef.current.id})).run);}catch{/* Keep the last checkpoint. */}}}
|
|
500
|
+
finally{if(active.current===controller)active.current=null;if(alive.current)setBusy(false);if(lock)onBusy(false);}
|
|
501
|
+
}
|
|
502
|
+
function configure(){setExpanded(true);return task(async signal=>{
|
|
503
|
+
const results=await Promise.allSettled([request('options',{},signal),refresh(signal)]);
|
|
504
|
+
if(results[0].status==='rejected')throw results[0].reason;
|
|
505
|
+
if(signal.aborted||!alive.current)return;
|
|
506
|
+
const models=results[0].value.routes;setRoutes(models);
|
|
507
|
+
const preferred=routeInitialized.current?undefined:project.modelRoute;routeInitialized.current=true;
|
|
508
|
+
setRoute(value=>reconcileModelRoute(models,value,preferred));
|
|
509
|
+
if(results[1].status==='rejected')throw results[1].reason;
|
|
510
|
+
});}
|
|
511
|
+
function start(){if(current.current.blocked)return;return task(async signal=>{
|
|
512
|
+
const model=findModelRoute(routes,route);if(!model)throw new Error(L('请选择支持图片输入的模型','Choose an image-capable model'));
|
|
513
|
+
let value=(await request('create',{confirmed:true,...model,repairs,language:languageOf(),...(scope==='current'?{slideId:current.current.selected}:{})},signal)).run;
|
|
514
|
+
accept(value);setPictures({});setCompare('');
|
|
515
|
+
while(value.status==='ready'&&!signal.aborted){value=(await request('step',{runId:value.id,confirmed:true},signal)).run;accept(value);}
|
|
516
|
+
await refresh(signal);
|
|
517
|
+
const last=value.rounds.at(-1);if(alive.current&&last?.rendered)setCompare(last.ids[0]);
|
|
518
|
+
},true);}
|
|
519
|
+
function stop(){active.current?.abort();if(runRef.current)void request('stop',{runId:runRef.current.id}).then(value=>accept(value.run)).catch(e=>{if(alive.current)setError(e.message);});}
|
|
520
|
+
function open(id){return task(async signal=>{const value=(await request('get',{runId:id},signal)).run;accept(value);setCompare(value.rounds.at(-1)?.rendered?value.rounds.at(-1).ids[0]:'');});}
|
|
521
|
+
function adopt(){if(blocked||!run?.canAdopt)return;return task(async signal=>{const value=await request('adopt',{runId:run.id,confirmed:true},signal);if(alive.current)onAdopt(value.project);},true);}
|
|
522
|
+
function remove(){if(!window.confirm(L('删除这次检查记录和预览图片?生成的 PPT 副本会保留。','Delete this review and its preview images? Presentation copies are kept.')))return;return task(async signal=>{await request('delete',{runId:run.id},signal);accept(null);setPictures({});setCompare('');await refresh(signal);});}
|
|
523
|
+
function download(){const url=new URL('api/dsh-ppt/download',document.baseURI);for(const[k,v]of Object.entries({id:project.id,kind:'visual',revision:project.revision,run:run.id}))url.searchParams.set(k,String(v));const a=document.createElement('a');a.href=url.href;a.download='';document.body.append(a);a.click();a.remove();}
|
|
524
|
+
useEffect(()=>{
|
|
525
|
+
if(!compare||!run)return;
|
|
526
|
+
const abort=new AbortController(),last=run.rounds.length-1;setPictures({});setLoading(true);
|
|
527
|
+
const initial=run.rounds[0].ids.includes(compare);
|
|
528
|
+
Promise.allSettled([initial?request('page',{runId:run.id,round:0,slideId:compare},abort.signal):Promise.resolve(null),request('page',{runId:run.id,round:last,slideId:compare},abort.signal)]).then(values=>{
|
|
529
|
+
if(abort.signal.aborted||!alive.current)return;
|
|
530
|
+
setPictures({before:values[0].status==='fulfilled'?values[0].value?.data:null,after:values[1].status==='fulfilled'?values[1].value?.data:null});
|
|
531
|
+
const failed=values.find(v=>v.status==='rejected');if(failed)setError(failed.reason.message);setLoading(false);
|
|
532
|
+
});return()=>abort.abort();
|
|
533
|
+
},[run?.id,run?.rounds.length,compare]);
|
|
534
|
+
useEffect(()=>{const last=run?.rounds.at(-1);if(!busy&&!compare&&last?.rendered)setCompare(last.ids[0]);},[run?.id,run?.rounds.length,run?.rounds.at(-1)?.rendered,busy,compare]);
|
|
535
|
+
const first=run?.rounds[0],last=run?.rounds.at(-1),stale=run&&(run.stale||run.revision!==project.revision),count=scope==='all'?project.slides.length:1;
|
|
536
|
+
const callCap=Array.from({length:repairs+1},(_,i)=>Math.ceil(count*2**i/2)).reduce((a,b)=>a+b,0);
|
|
537
|
+
function image(src,round,label){return h('figure',{style:{margin:0,minWidth:0}},h('figcaption',null,label),src?h('div',{style:{position:'relative',lineHeight:0}},h('img',{src,alt:label,style:{width:'100%',height:'auto',display:'block'}}),(round?.findings||[]).filter(f=>f.slideId===compare).map((f,i)=>h('span',{key:i,title:f.issue,style:{position:'absolute',pointerEvents:'none',border:'2px solid #f97316',boxSizing:'border-box',left:f.box[0]*100+'%',top:f.box[1]*100+'%',width:f.box[2]*100+'%',height:f.box[3]*100+'%'}}))):h('p',{className:'muted'},round===first&&!first.ids.includes(compare)?L('此页由拆分生成,没有对应的原页画面。','This page was created by a split and has no original counterpart.'):L('画面尚未载入,请重新选择页面。','Image not loaded; select the slide again.')));}
|
|
538
|
+
return h('section',{className:'card coaching','aria-label':L('视觉检查与修复','Visual review and repair')},
|
|
539
|
+
h('h3',null,L('让 AI 看完成品,再修排版','Let AI inspect the finished slides and repair formatting')),
|
|
540
|
+
h('p',{className:'muted'},L('可选功能。检查实际 PPTX 画面,另存修复副本,再渲染复查。原稿保留。','Optional. Inspect actual PPTX images, save a repaired copy, and render it again for rechecking. The original is kept.')),
|
|
541
|
+
!expanded?h('button',{disabled:busy||blocked,onClick:configure},L('视觉检查与修复','Visual review and repair')):h(React.Fragment,null,
|
|
542
|
+
error&&h('div',{role:'alert',className:'notice error'},error),
|
|
543
|
+
!run&&h(React.Fragment,null,
|
|
544
|
+
h('div',{className:'coaching-grid'},
|
|
545
|
+
h('label',null,L('视觉模型','Vision model'),h('select',{'aria-label':L('视觉模型','Vision model'),value:route,disabled:busy,onChange:e=>setRoute(e.target.value)},h('option',{value:''},L('请选择','Choose a model')),routes.map(m=>h('option',{key:modelRouteKey(m),value:modelRouteKey(m)},m.label)))),
|
|
546
|
+
h('label',null,L('检查范围','Review scope'),h('select',{'aria-label':L('视觉检查范围','Visual review scope'),value:scope,disabled:busy,onChange:e=>setScope(e.target.value)},h('option',{value:'all',disabled:project.slides.length>12},L('全部页面(最多 12 页)','All slides (up to 12)')),h('option',{value:'current'},L('当前页','Current slide')))),
|
|
547
|
+
h('label',null,L('自动修复上限','Repair limit'),h('select',{'aria-label':L('自动修复上限','Repair limit'),value:repairs,disabled:busy,onChange:e=>setRepairs(Number(e.target.value))},h('option',{value:0},L('仅看图检查','Inspect only')),h('option',{value:1},L('最多修复 1 轮(推荐)','Up to 1 repair round (recommended)')),h('option',{value:2},L('最多修复 2 轮','Up to 2 repair rounds'))))),
|
|
548
|
+
!routes.length&&h('p',{className:'notice'},L('未找到声明支持图片输入的模型。请在 DSH 模型设置中检查图片输入配置;普通生成和下载仍可使用。','No model declares image input. Check the image-input configuration in DSH model settings; normal creation and downloads remain available.')),
|
|
549
|
+
h('p',null,L('会向所选模型发送 '+count+' 页的渲染图片和页面文字;拆页后会重新检查新增页面,最多 '+callCap+' 次模型调用。','Sends rendered images and text from '+count+' slides to the selected model. New split pages are rechecked, with up to '+callCap+' model calls.')),
|
|
550
|
+
h('p',{className:'muted'},L('只调整字号、拆页、图表方向和图片裁切,不改写原文、数字或公式。可随时停止;服务商仍可能收取已发起调用的费用。','Changes font sizes, pagination, chart orientation and image cropping. Original text, numbers and formulas are preserved. You can stop at any time; calls already sent may still be billed.')),
|
|
551
|
+
h('div',{className:'tools'},h('button',{className:'primary',disabled:busy||blocked||!findModelRoute(routes,route)||count>12,onClick:start},L('开始看图检查','Start visual review')),h('button',{disabled:busy,onClick:configure},L('刷新视觉模型','Refresh vision models')))),
|
|
552
|
+
run&&h(React.Fragment,null,
|
|
553
|
+
h('p',{role:'status'},(run.status==='paused'?L('检查已停止','Review stopped'):run.status==='ready'&&!busy?L('等待检查','Review ready'):phaseName(run.phase))+' · '+L('已调用 ','Calls ')+run.usedCalls+'/'+run.maxCalls+' · '+L('本轮已检查 ','Slides checked this pass ')+(last?.cursor||0)+'/'+(last?.ids.length||0)),
|
|
554
|
+
busy&&h('button',{onClick:stop},L('停止视觉检查','Stop visual review')),
|
|
555
|
+
run.error&&h('p',{role:'alert',className:'notice error'},failureText(run.error)),
|
|
556
|
+
stale&&h('p',{className:'notice'},L('工程或成品已变化,旧记录可查看,但不能继续或采纳。','The project or output changed. This old record is readable, but cannot be continued or adopted.')),
|
|
557
|
+
run.status==='complete'&&h('p',{className:'notice'},last.findings.length?L('复查仍有 '+last.findings.length+' 个问题,请查看标记和说明。','Recheck still found '+last.findings.length+' issues. Review the highlighted regions and notes.'):L('AI 在本次范围内未发现明显视觉问题;这是一份模型检查记录。','AI found no obvious visual issues in this scope. This is a model review record.')),
|
|
558
|
+
(last?.missingFonts||[]).length>0&&h('p',{className:'notice error'},L('渲染引擎报告缺失字体:','Renderer reported missing fonts: ')+last.missingFonts.join(', ')),
|
|
559
|
+
run.rounds.map((r,i)=>h('details',{key:i,open:i===run.rounds.length-1},h('summary',null,L('检查轮次 ','Inspection pass ')+i+' · '+r.cursor+'/'+r.ids.length),r.findings.map((f,j)=>h('p',{key:j},h('strong',null,(project.slides.findIndex(s=>s.id===f.slideId)>=0?L('原第 '+(project.slides.findIndex(s=>s.id===f.slideId)+1)+' 页','Original slide '+(project.slides.findIndex(s=>s.id===f.slideId)+1)):L('拆分页','Split page'))+' · '),f.issue,h('br'),h('small',{className:'muted'},f.action?actionName(f.action):L('需要人工判断','Needs manual review')))),r.applied.length>0&&h('ul',null,r.applied.map((a,j)=>h('li',{key:j},L('已应用:','Applied: ')+actionName(a)))))),
|
|
560
|
+
!busy&&last?.rendered&&h(React.Fragment,null,
|
|
561
|
+
h('label',null,L('查看前后画面(橙框为 AI 定位区域)','Compare images (orange boxes mark AI findings)'),h('select',{'aria-label':L('对比页面','Comparison slide'),value:compare,onChange:e=>setCompare(e.target.value)},last.ids.map((id,i)=>h('option',{value:id,key:id},String(i+1)+'. '+(project.slides.find(s=>s.id===id)?.title||L('拆分页','Split page')))))),
|
|
562
|
+
loading?h('p',{role:'status'},L('正在载入画面…','Loading images…')):h('div',{className:'before-after'},image(pictures.before,first,L('原稿 · 实际 PPTX','Original · actual PPTX')),image(pictures.after,last,run.rounds.length>1?L('修复后 · 实际 PPTX','Repaired · actual PPTX'):L('本次检查画面','Reviewed image')))),
|
|
563
|
+
h('div',{className:'tools'},h('button',{className:'primary',disabled:busy||blocked||!run.canAdopt||stale,onClick:adopt},last?.findings.length?L('打开修复副本(仍有待处理问题)','Open repaired copy (issues remain)'):L('采用修复副本','Use repaired copy')),h('button',{disabled:busy,onClick:download},L('下载视觉检查记录','Download visual review')),h('button',{disabled:busy||run.status==='busy',onClick:remove},L('删除检查记录','Delete review')),h('button',{disabled:busy,onClick:()=>{accept(null);setCompare('');setPictures({});configure();}},L('新建视觉检查','New visual review')))),
|
|
564
|
+
!busy&&history.length>0&&h('details',null,h('summary',null,L('本机视觉检查历史','Local visual review history')),h('div',{className:'project-list'},history.map(item=>h('button',{key:item.id,onClick:()=>open(item.id)},L('修订 ','Revision ')+item.revision+' · '+new Date(item.createdAt).toLocaleString(languageOf()==='en'?'en-US':'zh-CN'))))),
|
|
565
|
+
h('button',{disabled:busy,onClick:()=>setExpanded(false)},L('收起视觉检查','Collapse visual review'))));
|
|
566
|
+
}
|
|
471
567
|
function DataPanel({project,blocked,incoming,onParameters,onDirty,onBusy,onAdopt,onChoose,onDownload}) {
|
|
472
568
|
const L=(zh,en)=>languageOf()==='en'?en:zh,model=project.dataModel;
|
|
473
569
|
const baseline=Object.fromEntries(model.metrics.filter(m=>m.kind==='input').map(m=>[m.id,String(m.value)]));
|
|
@@ -767,6 +863,9 @@ function useLanguage(locale) {
|
|
|
767
863
|
project.dataModel&&h(DataPanel,{key:project.id+':'+project.revision,project,blocked:busy||dirty||imagePending||mode!=='html',incoming:incomingData,
|
|
768
864
|
onParameters:parameters=>frame.current?.contentWindow?.postMessage({type:'dsh-ppt-data-set',nonce:nonce.current,parameters,command:++dataCommand.current},'*'),onDirty:setDataDirty,onBusy:value=>{setBusy(value);setJob(languageOf()==='en'?'Updating presentation data…':'正在核对并更新数据…');},
|
|
769
865
|
onAdopt:next=>{adopt(next,selected);setMessage(languageOf()==='en'?'Saved confirmed data. HTML, PPTX and project are synchronized; undo is available.':'已保存确认后的数据,HTML、PPTX 和工程已同步,可撤销。');},onChoose:id=>choose(project.slides.find(s=>s.id===id)),onDownload:download}),
|
|
866
|
+
h(VisualPanel,{key:'visual:'+project.id,project,selected,blocked:busy||dirty||imagePending||dataDirty,
|
|
867
|
+
onBusy:value=>{setBusy(value);setJob(languageOf()==='en'?'Reviewing rendered slides…':'正在检查和复查实际 PPTX 画面…');},
|
|
868
|
+
onAdopt:next=>{adopt(next,selected);setMode(next.render?'pptx':'html');setMessage(languageOf()==='en'?'Opened the repaired copy. The original is kept, and formatting changes can be undone.':'已打开修复副本,原稿保留,可撤销排版修改。');}}),
|
|
770
869
|
h(CoachingPanel, { key: project.id, project, selected, blocked: busy || dirty || imagePending || dataDirty,
|
|
771
870
|
onChoose: id => { choose(project.slides.find(s => s.id === id)); previewBox.current?.scrollIntoView({ behavior: 'smooth', block: 'center' }); },
|
|
772
871
|
onAdopt: next => { adopt(next, selected); setMessage(languageOf() === 'en' ? 'Saved to a new copy. The original is kept; you can undo the adopted changes in this copy.' : '已保存为新副本,原稿保留;可在当前副本中撤销采纳的修改。'); } })
|
|
@@ -779,5 +878,5 @@ function useLanguage(locale) {
|
|
|
779
878
|
try { localeService = ctx.get?.('locale') || ctx.locale; } catch { localeService = ctx.locale; }
|
|
780
879
|
ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'dsh-ppt', order: 58, label: () => t("演示文稿"), inject: () => ({ locale: localeService }) }, __withFirstRun(Workbench)));
|
|
781
880
|
}
|
|
782
|
-
return { inject: ['slots', 'locale'], apply, __internals: { draftFor, editorHtml, createImageLoader } };
|
|
881
|
+
return { inject: ['slots', 'locale'], apply, __internals: { draftFor, editorHtml, createImageLoader, modelRouteKey, findModelRoute, reconcileModelRoute } };
|
|
783
882
|
} });
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { registerPptSkill } from './skill.js';
|
|
|
20
20
|
import { buildPptTools } from './tools.js';
|
|
21
21
|
import { PptWorkbench, installPptWorkbench } from './workbench.js';
|
|
22
22
|
import { nativeCoachingModel } from './coaching-model.js';
|
|
23
|
+
import { nativeVisualModel } from './visual-model.js';
|
|
23
24
|
/** cordis 服务注入:apply 里要使用 ctx.tools 与 ctx.skills。 */
|
|
24
25
|
export const inject = ['tools', 'skills'];
|
|
25
26
|
export const name = 'dsh-ppt';
|
|
@@ -34,7 +35,11 @@ export function apply(ctx, config = {}) {
|
|
|
34
35
|
workbench.coaching.setModel(nativeCoachingModel(host.llm));
|
|
35
36
|
host.effect?.(() => () => workbench.coaching.setModel());
|
|
36
37
|
});
|
|
37
|
-
|
|
38
|
+
ctx.inject?.(['llm', 'attachments'], host => {
|
|
39
|
+
workbench.visual.setModel(nativeVisualModel(host.llm, host.attachments));
|
|
40
|
+
host.effect?.(() => () => workbench.visual.setModel());
|
|
41
|
+
});
|
|
42
|
+
disposers.push(() => { workbench.coaching.dispose(); workbench.visual.dispose(); });
|
|
38
43
|
}
|
|
39
44
|
// 技能注册:单个技能文件缺失只告警,不弄崩宿主启动。
|
|
40
45
|
try {
|
package/lib/types.d.ts
CHANGED
|
@@ -145,6 +145,12 @@ export interface PptSlideSpec {
|
|
|
145
145
|
notes?: string;
|
|
146
146
|
image?: PptImageSpec | string | null;
|
|
147
147
|
chart?: PptChartSpec | null;
|
|
148
|
+
/** Optional bounded native font sizes, in points. */
|
|
149
|
+
visual?: {
|
|
150
|
+
titleSize?: number;
|
|
151
|
+
bodySize?: number;
|
|
152
|
+
chartLabelSize?: number;
|
|
153
|
+
};
|
|
148
154
|
}
|
|
149
155
|
export interface PptConfig {
|
|
150
156
|
/** 默认输出目录;调用 ppt_create 时可用 outputDir 覆盖。相对路径按会话工作目录解析。 */
|
|
@@ -225,6 +231,8 @@ export interface PptCreateResult {
|
|
|
225
231
|
}
|
|
226
232
|
/** Shared generator and optional renderer exposed to the plugin. */
|
|
227
233
|
export interface DeckEngine {
|
|
234
|
+
repairDeckVisual(options: Record<string, unknown>): Promise<PptCreateResult>;
|
|
235
|
+
readRenderReceipt(pptxPath: string, receiptPath: string): PptRenderResult;
|
|
228
236
|
previewDeckData(options: Record<string, unknown>): Record<string, any>;
|
|
229
237
|
updateDeckData(options: Record<string, unknown>): Promise<PptCreateResult>;
|
|
230
238
|
dataReport(manifest: any): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Native image calls use durable DSH attachments and the exact prepared route. */
|
|
2
|
+
import type { ModelRoute } from './coaching-model.js';
|
|
3
|
+
export interface VisualImage {
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VisualModel {
|
|
8
|
+
routes(signal?: AbortSignal): Promise<Array<ModelRoute & {
|
|
9
|
+
label: string;
|
|
10
|
+
}>>;
|
|
11
|
+
inspect(route: ModelRoute, system: string, input: string, images: VisualImage[], signal: AbortSignal): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
export declare function nativeVisualModel(llm: any, attachments: any): VisualModel;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
class VisualCallError extends Error {
|
|
2
|
+
}
|
|
3
|
+
async function abortable(work, signal) {
|
|
4
|
+
signal.throwIfAborted();
|
|
5
|
+
let stop;
|
|
6
|
+
const aborted = new Promise((_, reject) => { stop = () => reject(new Error('视觉模型调用已停止 / Visual model call stopped')); signal.addEventListener('abort', stop, { once: true }); });
|
|
7
|
+
try {
|
|
8
|
+
return await Promise.race([work, aborted]);
|
|
9
|
+
}
|
|
10
|
+
finally {
|
|
11
|
+
signal.removeEventListener('abort', stop);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function nativeVisualModel(llm, attachments) {
|
|
15
|
+
return {
|
|
16
|
+
async routes(signal) {
|
|
17
|
+
const active = AbortSignal.any([...(signal ? [signal] : []), AbortSignal.timeout(15_000)]);
|
|
18
|
+
const groups = await Promise.all(llm.listProviders().slice(0, 20).map(async (provider) => {
|
|
19
|
+
try {
|
|
20
|
+
const models = await abortable(llm.listModels(provider.id), active);
|
|
21
|
+
return models.slice(0, 100).filter(m => m.inputModalities?.includes('image') && m.inputModalities?.includes('text'))
|
|
22
|
+
.map(m => ({ provider: provider.id, model: m.id, label: (provider.name || provider.id) + ' / ' + (m.name || m.id) }));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
active.throwIfAborted();
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
return groups.flat();
|
|
30
|
+
},
|
|
31
|
+
async inspect(route, system, input, images, signal) {
|
|
32
|
+
if (!images.length || images.length > 2 || images.some(i => i.data.byteLength > 4 * 1024 * 1024))
|
|
33
|
+
throw new Error('每次视觉检查需 1–2 张、每张不超过 4 MiB / Image request limit');
|
|
34
|
+
if (!llm.listProviders().some((p) => p.id === route.provider))
|
|
35
|
+
throw new Error('模型服务已停用 / Model provider is unavailable');
|
|
36
|
+
const active = AbortSignal.any([signal, AbortSignal.timeout(120_000)]);
|
|
37
|
+
let stream;
|
|
38
|
+
try {
|
|
39
|
+
const info = await abortable(llm.resolveModelInfo(route.provider, route.model, active), active);
|
|
40
|
+
const prepared = await abortable(llm.prepareCall({ ...route, maxTokens: 6000,
|
|
41
|
+
...(info?.reasoning?.efforts?.some((v) => v.id === 'off') ? { reasoningEffort: 'off' } : {}) }, active), active);
|
|
42
|
+
if (!prepared.inputModalities?.includes('image') || !prepared.inputModalities?.includes('text'))
|
|
43
|
+
throw new VisualCallError('所选模型不能读取图片,请选择视觉模型 / Choose a model with image input');
|
|
44
|
+
const refs = await abortable(attachments.saveImages(images.map(i => ({ data: i.data, mediaType: 'image/png', name: i.name }))), active);
|
|
45
|
+
if (!Array.isArray(refs) || refs.length !== images.length)
|
|
46
|
+
throw new VisualCallError('图片存储未完成 / Image admission failed');
|
|
47
|
+
active.throwIfAborted();
|
|
48
|
+
stream = prepared.stream({ ...prepared.config, system, tools: [], signal: active,
|
|
49
|
+
messages: [{ role: 'user', content: [{ type: 'text', text: input }, ...refs.map(attachment => ({ type: 'image', attachment }))] }],
|
|
50
|
+
})[Symbol.asyncIterator]();
|
|
51
|
+
const blocks = new Map();
|
|
52
|
+
let complete = false;
|
|
53
|
+
for (;;) {
|
|
54
|
+
const part = await abortable(stream.next(), active);
|
|
55
|
+
if (part.done)
|
|
56
|
+
break;
|
|
57
|
+
const chunk = part.value;
|
|
58
|
+
if (chunk.type === 'tool-call-delta' || chunk.type === 'block-end' && chunk.block?.type === 'tool-call')
|
|
59
|
+
throw new VisualCallError('视觉检查不允许工具调用 / Unexpected tool call');
|
|
60
|
+
if (chunk.type === 'text-delta')
|
|
61
|
+
blocks.set(chunk.index, (blocks.get(chunk.index) || '') + String(chunk.text || ''));
|
|
62
|
+
if (chunk.type === 'block-end' && chunk.block?.type === 'text')
|
|
63
|
+
blocks.set(chunk.index, String(chunk.block.text || ''));
|
|
64
|
+
if ([...blocks.values()].reduce((n, t) => n + t.length, 0) > 30_000)
|
|
65
|
+
throw new VisualCallError('视觉结果过长 / Visual output limit');
|
|
66
|
+
if (chunk.type === 'finish') {
|
|
67
|
+
if (chunk.reason?.kind === 'max-tokens')
|
|
68
|
+
throw new VisualCallError('视觉模型达到输出上限,未采纳截断结果;请缩小检查范围或选择更快的模型 / Vision output limit reached; truncated results were not adopted. Review fewer slides or choose a faster model');
|
|
69
|
+
if (chunk.reason?.failure?.code === 'AUTH')
|
|
70
|
+
throw new VisualCallError('视觉模型认证失败,请检查 DSH 中的凭据 / Vision model authentication failed; check the DSH credential');
|
|
71
|
+
if (chunk.reason?.failure?.code === 'RATE_LIMIT')
|
|
72
|
+
throw new VisualCallError('视觉模型服务限流,未自动重试 / Vision model rate limited; no automatic retry');
|
|
73
|
+
if (chunk.reason?.kind !== 'stop')
|
|
74
|
+
throw new VisualCallError('视觉模型未完整返回结果,未自动重试;请检查模型服务 / Vision model did not complete; no automatic retry. Check the model service');
|
|
75
|
+
complete = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const output = [...blocks].sort(([a], [b]) => a - b).map(([, t]) => t).join('');
|
|
80
|
+
if (!complete || !output.trim())
|
|
81
|
+
throw new VisualCallError('未收到完整视觉结果 / No complete visual result');
|
|
82
|
+
return output;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (active.aborted)
|
|
86
|
+
throw new VisualCallError('视觉模型调用已停止 / Visual model call stopped');
|
|
87
|
+
if (error instanceof VisualCallError)
|
|
88
|
+
throw error;
|
|
89
|
+
// Provider error bodies can echo credentials or request payloads. Keep
|
|
90
|
+
// only stable failure categories in UI and persistent review records.
|
|
91
|
+
const code = error?.failure?.code || error?.code;
|
|
92
|
+
if (code === 'AUTH')
|
|
93
|
+
throw new VisualCallError('视觉模型认证失败,请检查 DSH 中的凭据 / Vision model authentication failed; check the DSH credential');
|
|
94
|
+
if (code === 'RATE_LIMIT')
|
|
95
|
+
throw new VisualCallError('视觉模型服务限流,未自动重试 / Vision model rate limited; no automatic retry');
|
|
96
|
+
throw new VisualCallError('视觉模型请求失败,请检查模型、凭据与图片输入配置;未自动重试 / Vision model request failed; check model, credential and image input settings; no automatic retry');
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (stream?.return)
|
|
100
|
+
void Promise.resolve(stream.return()).catch(() => { });
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|