dsh-pdf-mineru 0.0.12 → 0.0.15
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 +68 -0
- package/README.md +36 -19
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/index.js +1845 -338
- package/lib/pdfjs-worker.mjs +457 -0
- package/lib/types/domain/request.d.ts +4 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/service/document-index.d.ts +36 -0
- package/lib/types/service/mineru-service.d.ts +20 -0
- package/lib/types/service/page-renderer.d.ts +64 -0
- package/lib/types/service/pdfjs-backend.d.ts +5 -0
- package/lib/types/service/read-cursor.d.ts +15 -3
- package/lib/types/service/read-delivery.d.ts +28 -0
- package/lib/types/service/result-presenter.d.ts +68 -6
- package/lib/types/tools.d.ts +3 -0
- package/package.json +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.15
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added a local PDF.js 6.3.289 + @napi-rs/canvas 1.0.9 subprocess fallback for original-page rendering. Normal installation includes renderer dependencies and package-local font/CMap/WASM resources; no system Poppler installation is required on supported native platforms.
|
|
8
|
+
- Added explicit original-page renderer identity to result types, strict tool output schemas, Native text and presentation metadata; physical page-count provenance distinguishes pdfinfo from pdfjs.
|
|
9
|
+
- Added deterministic backend-selection regressions, isolated PDF.js worker tests, full-tool offline auto/fallback smoke modes and an installed-package smoke from an unrelated working directory.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Keep Poppler preferred; fall back only when an executable is missing or explicitly unavailable in the execution environment, never for PDF failures, page/hash validation, cancellation, timeout or resource limits.
|
|
14
|
+
- Both backends share one checked snapshot, concurrency slot and total deadline. PDF.js parsing and Canvas allocation run only in a fixed child process with bounded output and local package resources; cancellation waits for process reaping before cleanup.
|
|
15
|
+
- Ship the unbundled PDF.js subprocess entry explicitly and keep native/PDF runtime dependencies external to host/client bundles. Document native-platform installation conditions, resource controls and fidelity differences without claiming OS sandbox isolation or pixel equivalence.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Preserve cancellation and the shared deadline when temporary cleanup completes late; cleanup failures cannot replace an already determined primary error.
|
|
20
|
+
- Distinguish Poppler output I/O failures and abnormal process termination from invalid PDFs without retrying another backend.
|
|
21
|
+
- Reject truncated/corrupt PNG containers with bounded chunk, checksum and end-marker validation before attachment delivery.
|
|
22
|
+
|
|
23
|
+
Reader cursor v3, index v2, Provider contracts and parsed cache formats remain unchanged.
|
|
24
|
+
|
|
25
|
+
## 0.0.14
|
|
26
|
+
|
|
27
|
+
This release includes the bounded-reader work recorded under 0.0.13; the previous published release is 0.0.12.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Kept the continuation cursor explicitly nullable in every read response, including completed selections.
|
|
32
|
+
- Cursor continuations now inherit the caller's image presentation intent; explicit `inline_images` overrides update the next cursor without bypassing current model capabilities or image budgets.
|
|
33
|
+
- Restored reference lists and other supported `list_items` content from cached MinerU results without reparsing, renumbering or fabricating text.
|
|
34
|
+
- Scoped block quality diagnostics to the actual delivered text, including TOC, table, search and continuation selections; document/selection notices are not replayed on every chunk.
|
|
35
|
+
- Recognized known header/footer/page-number/footnote and flat reference blocks instead of emitting misleading unknown-type warnings for them.
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- Added stable structured `diagnostics`, advisory formula `verification_hints`, and `provenance` separating upstream parsing configuration from index/reader versions. Unknown upstream engine versions are explicitly null.
|
|
40
|
+
- Added bounded inline-gap diagnostics and dual-provider offline review-paper regressions; suspect formulas remain unchanged and are never silently repaired.
|
|
41
|
+
- Added explicit `metadata_shortened` markers when quality/provenance metadata cannot fit a small output budget.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- Consolidated interim implementation reports into the maintained PDF reading guide and refreshed README/architecture documentation.
|
|
46
|
+
- Reader cursor v3 persists image intent and rejects v1/v2 tokens with a restart instruction. Index v2 reprojects existing immutable artifacts; it does not invalidate parse caches or automatically upload documents.
|
|
47
|
+
|
|
48
|
+
## 0.0.13
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- Added stable result-bound block IDs, original figure/table labels, literal document search (`query`), and exact block reading (`block_id`).
|
|
53
|
+
- Added local original-page verification (`view: "page"`) using bounded Poppler processes, private streaming snapshots, source SHA-256 checks, cancellation, and cleanup, without Provider upload.
|
|
54
|
+
- Added nested MinerU span normalization preserving inline mathematics, value-free bounded fidelity diagnostics, and explicit per-chunk visual coverage.
|
|
55
|
+
- Added an opt-in offline built-plugin smoke test (`smoke:reader-local`) and model-workflow regression fixtures.
|
|
56
|
+
|
|
57
|
+
### Changed
|
|
58
|
+
|
|
59
|
+
- Default read response budget is now 12,000 UTF-16 units; body chunks are capped at 8,000 units, with an additional 48,000-byte JSON/prose ceiling. Explicit larger response configurations no longer expand individual body chunks.
|
|
60
|
+
- Default reading omits exported cache paths and duplicate TOC metadata. Use `focus: "artifacts"` for exports and `focus: "toc"` for a complete resumable outline.
|
|
61
|
+
- **Reading cursor v2:** projection changes invalidate v1 cursors explicitly; restart without a cursor. Continuations are cache-only and bind selected text plus manifest artifact identity; cache eviction never silently triggers a new upload. Parsed cache manifests and Provider cache semantics are unchanged.
|
|
62
|
+
- Distinguished authoritative page metadata from a content-list lower bound and rejected page filtering that would silently discard unlocated evidence.
|
|
63
|
+
- Clarified that text completion does not guarantee OCR fidelity or image attachment coverage.
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
|
|
67
|
+
- Stopped renumbering original figure labels after page selection, and stopped replaying preceding indexed figures on text continuation.
|
|
68
|
+
- Kept complete outlines available instead of silently truncating Markdown fallback headings.
|
|
69
|
+
- Prevented the native renderer from preserving a misleading complete footer after emergency output truncation.
|
|
70
|
+
|
|
3
71
|
## 0.0.12
|
|
4
72
|
|
|
5
73
|
### Added
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
## ✨ 核心亮点
|
|
27
27
|
|
|
28
|
-
- 📑
|
|
28
|
+
- 📑 **结构化提取与证据定位**:支持双栏正文、目录、LaTeX公式、表格、参考文献与插图;通过搜索、稳定块ID和原页核对检查解析证据,而非假设OCR无损。
|
|
29
29
|
- ☁️ **云端 / 本地自由切换**:支持开箱即用的 **MinerU 官方云 API**(无需本地显卡)与 **私有化自建服务**(数据不出内网),统一工具接口无缝切换。
|
|
30
30
|
- ⚡ **无感后台异步解析**:几十页至数百页的长篇论文或研报,Agent 会自动提交为 DSH 原生后台任务(Native Job),解析期间不阻塞聊天,解析完成后自动提醒。
|
|
31
31
|
- 💾 **智能内容寻址缓存**:基于文件指纹与解析配置自动去重,同一份文档无需重复解析,极大节省 Token、官方 API 额度与计算资源,二次调用秒级响应。
|
|
@@ -54,6 +54,16 @@ dsh plugin --profile web add dsh-pdf-mineru
|
|
|
54
54
|
|
|
55
55
|
> 本地开发或测试源码时,可使用:`dsh plugin --profile web add link:/absolute/path/to/dsh-pdf-mineru`
|
|
56
56
|
|
|
57
|
+
### 本地原页渲染的安装条件
|
|
58
|
+
|
|
59
|
+
正常安装插件会安装固定版本的 [pdfjs-dist 6.3.289](https://www.npmjs.com/package/pdfjs-dist/v/6.3.289)(Apache-2.0)和 [@napi-rs/canvas 1.0.9](https://www.npmjs.com/package/@napi-rs/canvas/v/1.0.9)(MIT)。在支持的平台且未禁用平台可选依赖时,**无需系统安装 Poppler 即可使用原有原页接口**;字体、CMap、WASM 都从安装包本地加载,无 CDN。
|
|
60
|
+
|
|
61
|
+
这并非“纯 JavaScript、无原生依赖”:Canvas 使用预编译 Skia/N-API 平台二进制,包管理器通过 optionalDependencies 选择平台包,无安装期编译脚本。上游提供 Linux x64/arm64(glibc、musl)、Linux armv7(glibc)、Linux riscv64(glibc)、macOS x64/arm64、Windows x64/arm64 和 Android arm64 包;仍要求匹配的系统 ABI/运行库和本插件 Node 版本;Canvas上游文档要求glibc ≥2.18、Linux arm64为Cortex-A57或更新、armv7为Cortex-A7或更新,Node自身的系统要求仍须同时满足。实际验收平台为 Linux x64 glibc(Node 22.19.0 与26.8.2的独立生产安装包),其它平台有上游二进制不等于本仓库逐一验收。不要使用会删掉平台包的 --no-optional 安装选项。两后端均不可用时会提示安装 Poppler,或在支持平台重新安装插件及其平台可选依赖;不会使普通文本阅读失效。
|
|
62
|
+
|
|
63
|
+
PDF.js 包解压约34.8 MB,Canvas JS 约0.13 MB,Linux x64 glibc 二进制约34.8 MB(十进制,其他平台不同),这是安装依赖体积,不是插件 tarball 体积。PDF.js 的 Node 要求覆盖本插件现有 Node.js `^22.19.0 || >=24.0.0` 范围。
|
|
64
|
+
|
|
65
|
+
只对依赖/执行环境不可用自动切换:损坏、加密、解析失败、页码越界、源摘要不匹配、取消、资源超限或超时不会通过换后端重试。后端间可能存在字体、抗锯齿、透明度和裁切保真差异,不承诺像素相同;详见[阅读指南](docs/model-reading.md)。
|
|
66
|
+
|
|
57
67
|
### 2. 配置与连接
|
|
58
68
|
|
|
59
69
|
打开 DSH 界面中的 **Settings → Plugins → MinerU**,根据您的使用场景选择 Provider:
|
|
@@ -106,24 +116,21 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
|
|
|
106
116
|
| `read_pdf` | 同步读取 / 按需切片 | 同步读取 PDF,支持指定页码(`pages`)与内容类型(`focus`)切片提取,返回 Markdown 文本与按自然顺序排列的内联多模态图表 |
|
|
107
117
|
| `async_parse_pdf` | 长篇文档 / 后台解析 | 注册为 DSH 原生后台任务(`mineru-N`),全量解析 PDF 至本地缓存,完成后交付文档结构化摘要与后续阅读指引,不阻塞当前对话 |
|
|
108
118
|
|
|
109
|
-
###
|
|
110
|
-
|
|
111
|
-
`read_pdf` 直接返回阅读结果。`async_parse_pdf` 立即返回原生 `job_id`,完成后通过 `job_output` 提供英文摘要文本,不返回相同的正文结构。阅读结果字段如下:
|
|
119
|
+
### 证据阅读:定位 → 精读 → 续读 → 原页核对
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- `not_requested`:只请求了产物列表等不包含正文的结果。
|
|
118
|
-
- `markdown_path` 是完整原始 Markdown 产物,`manifest_path` 是结果清单。筛选重建的文本不与原始文件行号对应,故不再返回误导性的 `read_offset_line`。
|
|
119
|
-
- `output.maxInlineChars`:单次阅读响应的字符预算(默认 200,000 个 UTF-16 code units),约束 JSON 和 Native 英文文本各自的大小,包括元信息、续读 token 与状态说明。
|
|
120
|
-
- `output.maxInlineImages`:单次 `read_pdf` 响应的内联图片数量预算(默认 6,可配置为 0–100;0 表示全局禁用);图片仍受单图与总字节安全上限约束。
|
|
121
|
+
1. 用 `focus: "toc"` 看目录,或用 `query: "图 7"` 字面检索。空格有意义,“图7”与“图 7”不同。
|
|
122
|
+
2. 用返回的 `block_id` 精读完整块,或用物理页码与focus选择内容。标题块不代表整节。
|
|
123
|
+
3. `content_status: "partial"` 时,以同一file_path和原样cursor继续,不重复pages/focus/block_id/query;结束时cursor为null。
|
|
124
|
+
4. 对关键公式、数值和图表,用 `view: "page"` 回看原页;可传source_sha256作为expected_sha256。
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
**complete只表示所选解析文本交付完成,不保证OCR正确或图像全部展示。** 检查当前块的diagnostics、公式verification_hints及visuals;metadata_shortened表示元数据因预算未完整列出。
|
|
123
127
|
|
|
124
|
-
|
|
128
|
+
- 默认响应预算12,000个UTF-16单元、正文每块最多8,000;JSON和Native文本各最多48,000字节。默认不重复返回缓存路径;导出用focus: artifacts。
|
|
129
|
+
- `inline_images` 首次省略默认true,续读省略继承,显式布尔值覆盖;模型能力和图像预算始终构成上限。
|
|
130
|
+
- **0.0.14起使用v3游标,0.0.15保持该协议及索引v2;旧v1/v2游标需重新开始,解析缓存无需迁移。** 续读不会在缓存丢失时偷偷重新上传。
|
|
131
|
+
- 原页模式优先使用 PATH 中的 Poppler(pdfinfo/pdftoppm),命令缺失或明确不可执行时自动回退到 PDF.js + Node Canvas 子进程;仍需图像模型、附件服务及大于0的图像预算。结果以 `renderer: "poppler" | "pdfjs"` 标明后端,不会上传PDF或要求模型重新调用。它是本地有界执行,不是OS级隔离沙箱。
|
|
125
132
|
|
|
126
|
-
|
|
133
|
+
字段语义、完整示例、来源/索引版本、预算、安全边界、错误恢复和离线验收见 **[PDF阅读指南](docs/model-reading.md)**。更新插件后需要让宿主重新加载工具定义;只构建源码或刷新Web页面不等于后端已重载。
|
|
127
134
|
|
|
128
135
|
### 常用解析参数(均可通过自然语言告知 Agent)
|
|
129
136
|
|
|
@@ -132,8 +139,12 @@ Cursor 是无签名、无服务端状态的读取定位 token,不是授权凭
|
|
|
132
139
|
| `file_path` | `string` | 全部 | 待解析/读取的本地文件路径(必填) |
|
|
133
140
|
| `pages` | `number` / `string` / `number[]` | `read_pdf` | 1-based 页码选择,支持单页(如 `3`)、数组(如 `[1, 2, 5]`)或范围字符串(如 `"1-3, 5"`) |
|
|
134
141
|
| `focus` | `string` / `string[]` | `read_pdf` | `all`(默认)、`text`、`table`、`image`、`toc` 或 `artifacts` |
|
|
135
|
-
| `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus` 互斥,仍须传同一 `file_path` |
|
|
136
|
-
| `
|
|
142
|
+
| `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus`/`block_id`/`query` 互斥,仍须传同一 `file_path` |
|
|
143
|
+
| `block_id` | `string` | `read_pdf` | 原样使用此前返回的稳定块 ID;与 `query`、`cursor` 互斥 |
|
|
144
|
+
| `query` | `string` | `read_pdf` | 1–256 字符、不区分大小写的字面检索;返回上下文摘要与块 ID,再用 `block_id` 读全文 |
|
|
145
|
+
| `view` | `"content"` / `"page"` | `read_pdf` | 默认解析文本;page 模式只接受一页 `pages`,本地渲染原页,不调用 Provider |
|
|
146
|
+
| `expected_sha256` | `string` | `read_pdf` | 仅 page 模式;可选的源文件 SHA-256,通常来自此前结果的 `source_sha256` |
|
|
147
|
+
| `inline_images` | `boolean` | `read_pdf` | 首次省略默认true;续读省略继承,显式值覆盖,仍受模型能力和图像预算约束 |
|
|
137
148
|
| `poll_timeout_ms` | `number` | `read_pdf` | 最大同步等待超时毫秒数 |
|
|
138
149
|
|
|
139
150
|
---
|
|
@@ -228,7 +239,7 @@ storage:
|
|
|
228
239
|
storageRoot: /absolute/path/to/dsh/cache/pdf-mineru # 默认在 $DSH_HOME/cache/pdf-mineru
|
|
229
240
|
cacheEnabled: true
|
|
230
241
|
output:
|
|
231
|
-
maxInlineChars:
|
|
242
|
+
maxInlineChars: 12000 # 单次响应预算;正文每块另限 8000 UTF-16 单元
|
|
232
243
|
maxInlineImages: 6 # 单次 read_pdf 响应最多内联图片数(0–100)
|
|
233
244
|
limits:
|
|
234
245
|
maxFileBytes: 209715200 # 200 MB
|
|
@@ -304,10 +315,16 @@ pnpm run build
|
|
|
304
315
|
# 4. 在运行中的 DSH Web 中验证前端设置组件
|
|
305
316
|
pnpm run verify:gui
|
|
306
317
|
|
|
307
|
-
# 5.
|
|
318
|
+
# 5. (可选)本地原页验证,无上传;第二条用空PATH验证PDF.js自动回退
|
|
319
|
+
pnpm run smoke:reader-local -- /path/to/sample.pdf 1 --backend=auto
|
|
320
|
+
pnpm run smoke:reader-local -- /path/to/sample.pdf 1 .vitest-cache/pdfjs --backend=pdfjs
|
|
321
|
+
|
|
322
|
+
# 6. (显式选择)使用真实 Token 运行在线解析,会上传文档
|
|
308
323
|
MINERU_API_KEY=<token> pnpm run smoke:official-v4 -- /path/to/sample.pdf
|
|
309
324
|
```
|
|
310
325
|
|
|
326
|
+
> 文档入口:[PDF阅读指南](docs/model-reading.md) · [版本记录](CHANGELOG.md)。已完成的阶段性开发报告不作为当前使用契约维护,历史信息可从Git记录查阅。
|
|
327
|
+
|
|
311
328
|
> 想要深入了解插件的架构设计、数据模型、并发请求合并、安全解包与存储隔离机制?请查阅 **[ARCHITECTURE.md](./ARCHITECTURE.md)**。
|
|
312
329
|
|
|
313
330
|
---
|