dsh-pdf-mineru 0.0.12 → 0.0.14

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 CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.14
4
+
5
+ This release includes the bounded-reader work recorded under 0.0.13; the previous published release is 0.0.12.
6
+
7
+ ### Fixed
8
+
9
+ - Kept the continuation cursor explicitly nullable in every read response, including completed selections.
10
+ - 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.
11
+ - Restored reference lists and other supported `list_items` content from cached MinerU results without reparsing, renumbering or fabricating text.
12
+ - 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.
13
+ - Recognized known header/footer/page-number/footnote and flat reference blocks instead of emitting misleading unknown-type warnings for them.
14
+
15
+ ### Added
16
+
17
+ - 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.
18
+ - Added bounded inline-gap diagnostics and dual-provider offline review-paper regressions; suspect formulas remain unchanged and are never silently repaired.
19
+ - Added explicit `metadata_shortened` markers when quality/provenance metadata cannot fit a small output budget.
20
+
21
+ ### Changed
22
+
23
+ - Consolidated interim implementation reports into the maintained PDF reading guide and refreshed README/architecture documentation.
24
+ - 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.
25
+
26
+ ## 0.0.13
27
+
28
+ ### Added
29
+
30
+ - Added stable result-bound block IDs, original figure/table labels, literal document search (`query`), and exact block reading (`block_id`).
31
+ - Added local original-page verification (`view: "page"`) using bounded Poppler processes, private streaming snapshots, source SHA-256 checks, cancellation, and cleanup, without Provider upload.
32
+ - Added nested MinerU span normalization preserving inline mathematics, value-free bounded fidelity diagnostics, and explicit per-chunk visual coverage.
33
+ - Added an opt-in offline built-plugin smoke test (`smoke:reader-local`) and model-workflow regression fixtures.
34
+
35
+ ### Changed
36
+
37
+ - 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.
38
+ - Default reading omits exported cache paths and duplicate TOC metadata. Use `focus: "artifacts"` for exports and `focus: "toc"` for a complete resumable outline.
39
+ - **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.
40
+ - Distinguished authoritative page metadata from a content-list lower bound and rejected page filtering that would silently discard unlocated evidence.
41
+ - Clarified that text completion does not guarantee OCR fidelity or image attachment coverage.
42
+
43
+ ### Fixed
44
+
45
+ - Stopped renumbering original figure labels after page selection, and stopped replaying preceding indexed figures on text continuation.
46
+ - Kept complete outlines available instead of silently truncating Markdown fallback headings.
47
+ - Prevented the native renderer from preserving a misleading complete footer after emergency output truncation.
48
+
3
49
  ## 0.0.12
4
50
 
5
51
  ### Added
package/README.md CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  ## ✨ 核心亮点
27
27
 
28
- - 📑 **高质量结构化提取**:精准识别双栏排版、复杂多级标题、LaTeX 数学公式、表格与插图,输出排版优雅的 Markdown。
28
+ - 📑 **结构化提取与证据定位**:支持双栏正文、目录、LaTeX公式、表格、参考文献与插图;通过搜索、稳定块ID和原页核对检查解析证据,而非假设OCR无损。
29
29
  - ☁️ **云端 / 本地自由切换**:支持开箱即用的 **MinerU 官方云 API**(无需本地显卡)与 **私有化自建服务**(数据不出内网),统一工具接口无缝切换。
30
30
  - ⚡ **无感后台异步解析**:几十页至数百页的长篇论文或研报,Agent 会自动提交为 DSH 原生后台任务(Native Job),解析期间不阻塞聊天,解析完成后自动提醒。
31
31
  - 💾 **智能内容寻址缓存**:基于文件指纹与解析配置自动去重,同一份文档无需重复解析,极大节省 Token、官方 API 额度与计算资源,二次调用秒级响应。
@@ -106,24 +106,21 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
106
106
  | `read_pdf` | 同步读取 / 按需切片 | 同步读取 PDF,支持指定页码(`pages`)与内容类型(`focus`)切片提取,返回 Markdown 文本与按自然顺序排列的内联多模态图表 |
107
107
  | `async_parse_pdf` | 长篇文档 / 后台解析 | 注册为 DSH 原生后台任务(`mineru-N`),全量解析 PDF 至本地缓存,完成后交付文档结构化摘要与后续阅读指引,不阻塞当前对话 |
108
108
 
109
- ### 核心交付字段与正文状态说明
109
+ ### 证据阅读:定位 → 精读 → 续读 → 原页核对
110
110
 
111
- `read_pdf` 直接返回阅读结果。`async_parse_pdf` 立即返回原生 `job_id`,完成后通过 `job_output` 提供英文摘要文本,不返回相同的正文结构。阅读结果字段如下:
111
+ 1. 用 `focus: "toc"` 看目录,或用 `query: "图 7"` 字面检索。空格有意义,“图7”与“图 7”不同。
112
+ 2. 用返回的 `block_id` 精读完整块,或用物理页码与focus选择内容。标题块不代表整节。
113
+ 3. `content_status: "partial"` 时,以同一file_path和原样cursor继续,不重复pages/focus/block_id/query;结束时cursor为null。
114
+ 4. 对关键公式、数值和图表,用 `view: "page"` 回看原页;可传source_sha256作为expected_sha256。
112
115
 
113
- - `markdown_content`:提取的正文 Markdown 文本。
114
- - `content_status`:正文交付状态:
115
- - `complete`:本次选择已读完;若本次是续读,表示剩余正文已全部提供。
116
- - `partial`:因输出预算分段,返回 `cursor`。下一次使用相同 `file_path` 与原样 `cursor`,不要再次传 `pages`/`focus`;逐次拼接 `markdown_content` 即为同一选择的完整正文。
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 表示全局禁用);图片仍受单图与总字节安全上限约束。
116
+ **complete只表示所选解析文本交付完成,不保证OCR正确或图像全部展示。** 检查当前块的diagnostics、公式verification_hints及visuals;metadata_shortened表示元数据因预算未完整列出。
121
117
 
122
- Cursor 是无签名、无服务端状态的读取定位 token,不是授权凭证。源文件仍须存在并保持不变;解析配置、结果身份或选择不匹配时需要重新开始。完全越界页码会明确报错,部分越界给出警告;没有可靠页码/类型映射时,不会假装完成不支持的筛选。
118
+ - 默认响应预算12,000个UTF-16单元、正文每块最多8,000;JSON和Native文本各最多48,000字节。默认不重复返回缓存路径;导出用focus: artifacts。
119
+ - `inline_images` 首次省略默认true,续读省略继承,显式布尔值覆盖;模型能力和图像预算始终构成上限。
120
+ - **0.0.14使用v3游标,旧v1/v2游标需重新开始;解析缓存无需迁移。** 续读不会在缓存丢失时偷偷重新上传。
121
+ - 原页模式需要Poppler(pdfinfo/pdftoppm)、图像模型、附件服务及大于0的图像预算。它是本地有界执行,不是OS级隔离沙箱。
123
122
 
124
- 后台摘要使用独立路径,不再为生成摘要加载/拼接完整 Markdown,也不受阅读正文的字符预算影响。可选 content-list 最多读取 2 MiB;缺失、为空、格式不可用或超限时返回已完成的解析结果与必要提示,不猜测页数或图表数量。摘要大纲最多 20 项,每项标题最多 160 个 UTF-16 code units。存储层必要的流式完整性校验仍然保留。
125
-
126
- 图片的读取预算与规范化后附件预算分别核算。部分读取后失败、读取后 stat 失败、close 失败均不能退还已消耗的读取字节;附件实际字节未知或无效时不回退使用源文件大小。
123
+ 字段语义、完整示例、来源/索引版本、预算、安全边界、错误恢复和离线验收见 **[PDF阅读指南](docs/model-reading.md)**。更新插件后需要让宿主重新加载工具定义;只构建源码或刷新Web页面不等于后端已重载。
127
124
 
128
125
  ### 常用解析参数(均可通过自然语言告知 Agent)
129
126
 
@@ -132,8 +129,12 @@ Cursor 是无签名、无服务端状态的读取定位 token,不是授权凭
132
129
  | `file_path` | `string` | 全部 | 待解析/读取的本地文件路径(必填) |
133
130
  | `pages` | `number` / `string` / `number[]` | `read_pdf` | 1-based 页码选择,支持单页(如 `3`)、数组(如 `[1, 2, 5]`)或范围字符串(如 `"1-3, 5"`) |
134
131
  | `focus` | `string` / `string[]` | `read_pdf` | `all`(默认)、`text`、`table`、`image`、`toc` 或 `artifacts` |
135
- | `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus` 互斥,仍须传同一 `file_path` |
136
- | `inline_images` | `boolean` | `read_pdf` | 是否直接内联多模态图表(模型路由支持图片时默认开启) |
132
+ | `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus`/`block_id`/`query` 互斥,仍须传同一 `file_path` |
133
+ | `block_id` | `string` | `read_pdf` | 原样使用此前返回的稳定块 ID;与 `query`、`cursor` 互斥 |
134
+ | `query` | `string` | `read_pdf` | 1–256 字符、不区分大小写的字面检索;返回上下文摘要与块 ID,再用 `block_id` 读全文 |
135
+ | `view` | `"content"` / `"page"` | `read_pdf` | 默认解析文本;page 模式只接受一页 `pages`,本地渲染原页,不调用 Provider |
136
+ | `expected_sha256` | `string` | `read_pdf` | 仅 page 模式;可选的源文件 SHA-256,通常来自此前结果的 `source_sha256` |
137
+ | `inline_images` | `boolean` | `read_pdf` | 首次省略默认true;续读省略继承,显式值覆盖,仍受模型能力和图像预算约束 |
137
138
  | `poll_timeout_ms` | `number` | `read_pdf` | 最大同步等待超时毫秒数 |
138
139
 
139
140
  ---
@@ -228,7 +229,7 @@ storage:
228
229
  storageRoot: /absolute/path/to/dsh/cache/pdf-mineru # 默认在 $DSH_HOME/cache/pdf-mineru
229
230
  cacheEnabled: true
230
231
  output:
231
- maxInlineChars: 200000 # 单次响应最大内联字符预算(UTF-16 字符)
232
+ maxInlineChars: 12000 # 单次响应预算;正文每块另限 8000 UTF-16 单元
232
233
  maxInlineImages: 6 # 单次 read_pdf 响应最多内联图片数(0–100)
233
234
  limits:
234
235
  maxFileBytes: 209715200 # 200 MB
@@ -304,10 +305,15 @@ pnpm run build
304
305
  # 4. 在运行中的 DSH Web 中验证前端设置组件
305
306
  pnpm run verify:gui
306
307
 
307
- # 5. (可选)使用真实 Token 运行端到端 Smoke 测试
308
+ # 5. (可选)本地原页验证,无上传,需要Poppler
309
+ pnpm run smoke:reader-local -- /path/to/sample.pdf 1
310
+
311
+ # 6. (显式选择)使用真实 Token 运行在线解析,会上传文档
308
312
  MINERU_API_KEY=<token> pnpm run smoke:official-v4 -- /path/to/sample.pdf
309
313
  ```
310
314
 
315
+ > 文档入口:[PDF阅读指南](docs/model-reading.md) · [版本记录](CHANGELOG.md)。已完成的阶段性开发报告不作为当前使用契约维护,历史信息可从Git记录查阅。
316
+
311
317
  > 想要深入了解插件的架构设计、数据模型、并发请求合并、安全解包与存储隔离机制?请查阅 **[ARCHITECTURE.md](./ARCHITECTURE.md)**。
312
318
 
313
319
  ---
package/lib/client.js CHANGED
@@ -56,7 +56,7 @@ window.__ModuleLoader__.load({
56
56
  maxDelayMs: 1e4
57
57
  };
58
58
  const DEFAULT_OUTPUT_CONFIG = {
59
- maxInlineChars: 2e5,
59
+ maxInlineChars: 12e3,
60
60
  maxInlineImages: 6
61
61
  };
62
62
  const DEFAULT_STORAGE_OPTIONS = {