dsh-pdf-mineru 0.0.10 → 0.0.11
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 +35 -0
- package/README.md +31 -13
- package/cordis.patch.yml +1 -3
- package/lib/client.js +941 -754
- package/lib/client.js.map +1 -1
- package/lib/index.js +1774 -715
- package/lib/types/client/NumericInput.d.ts +21 -0
- package/lib/types/client/SettingsPage.d.ts +3 -23
- package/lib/types/client/helpers.d.ts +23 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/sections/AdvancedSections.d.ts +9 -0
- package/lib/types/client/sections/DefaultsSection.d.ts +12 -0
- package/lib/types/client/sections/ProviderSection.d.ts +24 -0
- package/lib/types/config/pure.d.ts +78 -0
- package/lib/types/config.d.ts +10 -64
- package/lib/types/{service → domain}/cache-key.d.ts +2 -2
- package/lib/types/domain/request.d.ts +17 -3
- package/lib/types/domain/schemas.d.ts +0 -3
- package/lib/types/providers/http-client.d.ts +1 -17
- package/lib/types/providers/provider.d.ts +1 -1
- package/lib/types/rpc.d.ts +5 -1
- package/lib/types/service/image-policy.d.ts +11 -0
- package/lib/types/service/mineru-service.d.ts +10 -2
- package/lib/types/service/read-cursor.d.ts +32 -0
- package/lib/types/service/result-presenter.d.ts +12 -8
- package/lib/types/service/shared-operations.d.ts +0 -2
- package/lib/types/storage/access-gate.d.ts +34 -1
- package/lib/types/storage/index.d.ts +0 -1
- package/lib/types/storage/maintenance-service.d.ts +3 -5
- package/lib/types/storage/paths.d.ts +7 -1
- package/lib/types/storage/process-lock.d.ts +30 -15
- package/lib/types/storage/result-repository.d.ts +6 -6
- package/lib/types/tools.d.ts +3 -4
- package/lib/types/utils/crypto.d.ts +1 -4
- package/package.json +2 -1
- package/lib/types/storage/batch-artifact-router.d.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.11
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added the live `output.maxInlineImages` setting for configuring the per-`read_pdf` inline image budget, defaulting to 6.
|
|
8
|
+
- Added `artifacts` focus option to `read_pdf`, gating secondary artifact file paths (such as `layout.json` and `model.json`) so they are omitted by default unless explicitly requested.
|
|
9
|
+
- Added automatic legal document boundary clamping (`narrowPageSelection`) for page range selections in `read_pdf`.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Storage protocol upgrade (Breaking Change):** Stop every MinerU process sharing the root before upgrading. `.process.lock` is now a persistent version fence, not a lock to delete at normal shutdown. Local hard-link support and shared PID visibility are required; NFS/cross-host locking is not supported.
|
|
14
|
+
- **Configuration schema v2 (Breaking Change):** Versioned the current plugin configuration as schema v2 and added a bounded v1 migration that validates and removes obsolete `defaults.artifacts` and `limits.maxFilesPerRequest` fields before persisting the canonical v2 settings.
|
|
15
|
+
- **Continuation cursor contract (Breaking Change):** Replaced numeric line offsets (`read_offset_line`) with an opaque Unicode-safe `cursor` token for partial reading continuations.
|
|
16
|
+
- Cleaned up output prose presentation: removed verbose result headers and redundant manifest paths, displaying clear page range, total page count, and standardized figure labeling (`Figure N (Page X, "Title")`).
|
|
17
|
+
- Unified configuration parsing, snapshotted execution settings, and made startup-bound storage/payload limits explicit. Split settings sections and preserved numeric input drafts.
|
|
18
|
+
- Separated parse synopsis from body projection and aligned required tool schemas, English guidance, and actionable RPC failures.
|
|
19
|
+
- Consolidated current usage, architecture, deployment limits, and upgrade guidance; removed obsolete lock instructions and temporary audit/work logs.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Ensured all tool outputs strictly conform to lossless JSON by omitting undefined optional properties instead of serializing `undefined`.
|
|
24
|
+
- Removed the obsolete `defaults.artifacts` field from the shipped Cordis configuration, restoring Host startup under strict configuration validation.
|
|
25
|
+
- Routed async completion through a separate bounded synopsis API instead of Markdown projection flags; oversized/invalid optional summary indexes now degrade explicitly without masking cache-integrity failures.
|
|
26
|
+
- Charged consumed image bytes on partial-read, final-stat, and close failures; required actual normalized attachment sizes and propagated cancellation after the final image.
|
|
27
|
+
- Replaced instance-held lock bypass and unsafe stale-file reclamation with scoped, cancellable local-filesystem bakery coordination and explicit mutation authority.
|
|
28
|
+
- Protected readers, image processing, producers, staging cleanup, and destructive maintenance across processes sharing a storage root; rejected symlinked traversal and publication ancestors.
|
|
29
|
+
- Added exact, Unicode-safe `read_pdf` continuation cursors and honest out-of-range/unsupported-selection errors; Native output includes the actual continuation token.
|
|
30
|
+
- Restricted image reads to manifest-declared artifacts, bounded attachments, and separated stable Figure identifiers from successful attachment order.
|
|
31
|
+
- Made cache reads non-mutating and published-result isolation explicitly guarded; the first valid publication wins for equivalent content even when filenames or nondeterministic provider bytes differ.
|
|
32
|
+
- Bounded maintenance traversal and exposed incomplete statistics as lower bounds in the settings UI.
|
|
33
|
+
|
|
34
|
+
### Removed
|
|
35
|
+
|
|
36
|
+
- Removed unused HTTP/transient-reference wrappers, batch router/coordinator code, migration naming, and transitional cache-key/presentation aliases.
|
|
37
|
+
|
|
3
38
|
## 0.0.10
|
|
4
39
|
|
|
5
40
|
### Fixed
|
package/README.md
CHANGED
|
@@ -106,14 +106,22 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
|
|
|
106
106
|
|
|
107
107
|
### 核心交付字段与正文状态说明
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
`read_pdf` 直接返回阅读结果。`async_parse_pdf` 立即返回原生 `job_id`,完成后通过 `job_output` 提供英文摘要文本,不返回相同的正文结构。阅读结果字段如下:
|
|
110
110
|
|
|
111
111
|
- `markdown_content`:提取的正文 Markdown 文本。
|
|
112
112
|
- `content_status`:正文交付状态:
|
|
113
|
-
- `complete
|
|
114
|
-
- `partial
|
|
115
|
-
- `not_requested
|
|
116
|
-
- `
|
|
113
|
+
- `complete`:本次选择已读完;若本次是续读,表示剩余正文已全部提供。
|
|
114
|
+
- `partial`:因输出预算分段,返回 `cursor`。下一次使用相同 `file_path` 与原样 `cursor`,不要再次传 `pages`/`focus`;逐次拼接 `markdown_content` 即为同一选择的完整正文。
|
|
115
|
+
- `not_requested`:只请求了产物列表等不包含正文的结果。
|
|
116
|
+
- `markdown_path` 是完整原始 Markdown 产物,`manifest_path` 是结果清单。筛选重建的文本不与原始文件行号对应,故不再返回误导性的 `read_offset_line`。
|
|
117
|
+
- `output.maxInlineChars`:单次阅读响应的字符预算(默认 200,000 个 UTF-16 code units),约束 JSON 和 Native 英文文本各自的大小,包括元信息、续读 token 与状态说明。
|
|
118
|
+
- `output.maxInlineImages`:单次 `read_pdf` 响应的内联图片数量预算(默认 6,可配置为 0–100;0 表示全局禁用);图片仍受单图与总字节安全上限约束。
|
|
119
|
+
|
|
120
|
+
Cursor 是无签名、无服务端状态的读取定位 token,不是授权凭证。源文件仍须存在并保持不变;解析配置、结果身份或选择不匹配时需要重新开始。完全越界页码会明确报错,部分越界给出警告;没有可靠页码/类型映射时,不会假装完成不支持的筛选。
|
|
121
|
+
|
|
122
|
+
后台摘要使用独立路径,不再为生成摘要加载/拼接完整 Markdown,也不受阅读正文的字符预算影响。可选 content-list 最多读取 2 MiB;缺失、为空、格式不可用或超限时返回已完成的解析结果与必要提示,不猜测页数或图表数量。摘要大纲最多 20 项,每项标题最多 160 个 UTF-16 code units。存储层必要的流式完整性校验仍然保留。
|
|
123
|
+
|
|
124
|
+
图片的读取预算与规范化后附件预算分别核算。部分读取后失败、读取后 stat 失败、close 失败均不能退还已消耗的读取字节;附件实际字节未知或无效时不回退使用源文件大小。
|
|
117
125
|
|
|
118
126
|
### 常用解析参数(均可通过自然语言告知 Agent)
|
|
119
127
|
|
|
@@ -121,7 +129,8 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
|
|
|
121
129
|
| --- | --- | --- | --- |
|
|
122
130
|
| `file_path` | `string` | 全部 | 待解析/读取的本地文件路径(必填) |
|
|
123
131
|
| `pages` | `number` / `string` / `number[]` | `read_pdf` | 1-based 页码选择,支持单页(如 `3`)、数组(如 `[1, 2, 5]`)或范围字符串(如 `"1-3, 5"`) |
|
|
124
|
-
| `focus` | `string` / `string[]` | `read_pdf` |
|
|
132
|
+
| `focus` | `string` / `string[]` | `read_pdf` | `all`(默认)、`text`、`table`、`image`、`toc` 或 `artifacts` |
|
|
133
|
+
| `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus` 互斥,仍须传同一 `file_path` |
|
|
125
134
|
| `inline_images` | `boolean` | `read_pdf` | 是否直接内联多模态图表(模型路由支持图片时默认开启) |
|
|
126
135
|
| `poll_timeout_ms` | `number` | `read_pdf` | 最大同步等待超时毫秒数 |
|
|
127
136
|
|
|
@@ -151,7 +160,7 @@ flowchart LR
|
|
|
151
160
|
```
|
|
152
161
|
|
|
153
162
|
- **统一工具分发**:Agent 发起的同步请求(`read_pdf`)直接返回结果,异步长任务(`async_parse_pdf`)交由 DSH 原生 JobRegistry 调度。
|
|
154
|
-
-
|
|
163
|
+
- **缓存复用**:按文件 SHA-256 与解析语义寻址;命中时无需重新提交上游解析,但仍校验本地源文件及产物。
|
|
155
164
|
- **并发请求合并**:同进程内的并发重复请求由 `SharedOperationRegistry` 合并,避免重复向上游提交。
|
|
156
165
|
- **双 Provider 适配**:上游适配自建 FastAPI v2 或官方云 v4,解析产物经校验后原子发布。
|
|
157
166
|
|
|
@@ -161,7 +170,7 @@ flowchart LR
|
|
|
161
170
|
| --- | --- | --- |
|
|
162
171
|
| **部署难度** | ⭐ **零门槛**(仅需配置 API Key) | 需自行部署 MinerU FastAPI 服务及模型环境 |
|
|
163
172
|
| **硬件要求** | 无需本地 GPU,云端集群算力支持 | 推荐配备 NVIDIA GPU 显卡 |
|
|
164
|
-
| **数据安全性** | 数据上传至 MinerU 官方云端解析 |
|
|
173
|
+
| **数据安全性** | 数据上传至 MinerU 官方云端解析 | 由自建服务的部署位置、网络与安全配置决定 |
|
|
165
174
|
| **支持模型** | 原生支持 `pipeline` 与 `vlm` | 支持 `pipeline`,亦可通过 `modelMap` 映射自建 VLM 引擎 |
|
|
166
175
|
| **单文件限制** | 单文件最大 200 MB,最多 200 页 | 取决于自建服务端硬件与配置 |
|
|
167
176
|
| **网络协议** | 强制 HTTPS,安全传输 | 支持 HTTP / HTTPS,本地可配置 `allowInsecureHttp` |
|
|
@@ -177,7 +186,7 @@ flowchart LR
|
|
|
177
186
|
|
|
178
187
|
### 1. 官方云 (Official v4) 推荐配置
|
|
179
188
|
```yaml
|
|
180
|
-
schemaVersion:
|
|
189
|
+
schemaVersion: 2
|
|
181
190
|
activeProvider: mp_official
|
|
182
191
|
providers:
|
|
183
192
|
- id: mp_official
|
|
@@ -194,7 +203,7 @@ defaults:
|
|
|
194
203
|
|
|
195
204
|
### 2. 本地私有化 (Self-hosted v2) 推荐配置
|
|
196
205
|
```yaml
|
|
197
|
-
schemaVersion:
|
|
206
|
+
schemaVersion: 2
|
|
198
207
|
activeProvider: mp_self_hosted
|
|
199
208
|
providers:
|
|
200
209
|
- id: mp_self_hosted
|
|
@@ -218,12 +227,21 @@ storage:
|
|
|
218
227
|
cacheEnabled: true
|
|
219
228
|
output:
|
|
220
229
|
maxInlineChars: 200000 # 单次响应最大内联字符预算(UTF-16 字符)
|
|
230
|
+
maxInlineImages: 6 # 单次 read_pdf 响应最多内联图片数(0–100)
|
|
221
231
|
limits:
|
|
222
232
|
maxFileBytes: 209715200 # 200 MB
|
|
223
233
|
```
|
|
224
234
|
|
|
225
235
|
</details>
|
|
226
236
|
|
|
237
|
+
### 多进程共享存储与升级
|
|
238
|
+
|
|
239
|
+
多个进程可以共享同一 `storageRoot`,前提是同一主机、同一 PID 可见命名空间及支持 hard link 的一致本地文件系统。不支持 NFS、跨主机或互不可见 PID 的容器共享这一锁协议。
|
|
240
|
+
|
|
241
|
+
升级时请先停止所有使用该目录的 MinerU 进程,再统一更新并重启。新协议的 `.process.lock` 是持久版本隔离标记,实际互斥与使用记录位于 `.lock/`;它不是应当在退出时删除的“残留锁”。遇到旧锁或损坏记录,请先确认所有相关进程已停止,再按错误提示人工恢复,切勿在活跃进程运行时删除协调文件。
|
|
242
|
+
|
|
243
|
+
`storageRoot` 与 `limits.*` 在启动时固定。运行中的配置保存会拒绝这些值的变更;应修改宿主配置并重启插件,不能依赖一次被拒绝的保存自动生效。
|
|
244
|
+
|
|
227
245
|
---
|
|
228
246
|
|
|
229
247
|
## ❓ 常见问题 (FAQ)
|
|
@@ -239,7 +257,7 @@ limits:
|
|
|
239
257
|
<details>
|
|
240
258
|
<summary><strong>Q: 扫描版 PDF 或图片文档识别不准怎么办?</strong></summary>
|
|
241
259
|
|
|
242
|
-
普通纯文本 PDF
|
|
260
|
+
普通纯文本 PDF 通常可以使用默认设置。对于扫描件或识别效果不佳的文档,在 MinerU 设置中将 **Default Parse Method** 改为 `ocr`;`ocr` 布尔值由该选择保持一致。模型工具不接受 `ocr`、`model` 等技术参数,不能通过向 `read_pdf` 添加这些参数切换解析方式。
|
|
243
261
|
</details>
|
|
244
262
|
|
|
245
263
|
<details>
|
|
@@ -252,10 +270,10 @@ limits:
|
|
|
252
270
|
<details>
|
|
253
271
|
<summary><strong>Q: 解析结果保存在哪里?如何清理缓存?</strong></summary>
|
|
254
272
|
|
|
255
|
-
|
|
273
|
+
解析结果按源文件内容、解析语义及 Provider 兼容标识寻址,默认存放在 `$DSH_HOME/cache/pdf-mineru/results/`。启用缓存复用时,后续阅读可复用已发布结果;同进程并发请求合并,但不同进程仍可能分别提交上游解析,不保证跨进程只计费一次。`storage.cacheEnabled=false` 仅禁用解析前的缓存复用,结果仍会不可变发布,不等同于清空缓存或强制覆盖已有结果。
|
|
256
274
|
您可以在 **Settings → Plugins → MinerU** 的运维区域中:
|
|
257
275
|
- 点击 **Verify Cache** 检查缓存完整性;
|
|
258
|
-
- 点击 **Clear Cache**
|
|
276
|
+
- 点击 **Clear Cache** 预览,再显式确认清除。破坏性维护在存在活跃读取或解析时拒绝执行,不会为了清理而取消它们。
|
|
259
277
|
</details>
|
|
260
278
|
|
|
261
279
|
<details>
|
package/cordis.patch.yml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
- id: dsh-pdf-mineru
|
|
5
5
|
name: 'dsh-pdf-mineru'
|
|
6
6
|
config:
|
|
7
|
-
schemaVersion:
|
|
7
|
+
schemaVersion: 2
|
|
8
8
|
activeProvider: mp_self_hosted
|
|
9
9
|
providers:
|
|
10
10
|
- id: mp_self_hosted
|
|
@@ -30,8 +30,6 @@
|
|
|
30
30
|
language: ch
|
|
31
31
|
formula: true
|
|
32
32
|
table: true
|
|
33
|
-
artifacts:
|
|
34
|
-
- markdown
|
|
35
33
|
retry:
|
|
36
34
|
maxAttempts: 3
|
|
37
35
|
baseDelayMs: 500
|