dsh-pdf-mineru 0.0.10 → 0.0.12
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 +55 -0
- package/README.md +35 -15
- package/cordis.patch.yml +1 -3
- package/lib/client.js +1148 -805
- package/lib/client.js.map +1 -1
- package/lib/index.js +1956 -733
- 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 +25 -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 +15 -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/index.d.ts +1 -1
- package/lib/types/loopback-rpc.d.ts +8 -0
- 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 +8 -12
- 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 +17 -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 +5 -6
- package/lib/types/utils/crypto.d.ts +1 -4
- package/package.json +28 -23
- package/lib/types/storage/batch-artifact-router.d.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.12
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Pruned default configuration values on save via `pruneConfigToDiff` so that unchanged defaults are not written to `settings.yaml`, preventing user configuration bloat.
|
|
8
|
+
- Added automatic startup slimming via `detectBloatedSettingsOps` and `settings.mutate` to clean up legacy bloated default entries from existing `settings.yaml` files.
|
|
9
|
+
- Added page-level "Reset to Defaults" and section-level "Reset" controls in the Web settings UI to easily restore default values.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Raised the minimum supported DSH version to `0.1.5-rc.2` and aligned DSH runtime peers, development dependencies, and the lockfile with that release. Node.js requirements, Provider configuration, cache formats, and tool arguments are unchanged.
|
|
14
|
+
- Use typed live Agent/session route access for image-capability detection, retaining request-header precedence, Agent-option fallback, and conservative handling of unavailable model metadata.
|
|
15
|
+
- Replace obsolete Host, Tool, and Connection ambient declarations with published types; align client RPC calls and tool schema inference with the rc.2 contracts.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Explicitly inject both `connection` and `webServer` for RPC registration now that Connection no longer requires WebServer. Headless hosts retain both model tools without attempting HTTP route registration.
|
|
20
|
+
- Use a caller-local guarded route registrar to handle Cordis service-getter dependency scoping and enforce loopback-only RPC access independently of the unsupported `authority` argument, while retaining native Connection authentication and response handling.
|
|
21
|
+
- Include required empty `details` in RPC error envelopes so rc.2 clients retain actionable MinerU errors instead of rejecting the wire response.
|
|
22
|
+
|
|
23
|
+
## 0.0.11
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Added the live `output.maxInlineImages` setting for configuring the per-`read_pdf` inline image budget, defaulting to 6.
|
|
28
|
+
- 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.
|
|
29
|
+
- Added automatic legal document boundary clamping (`narrowPageSelection`) for page range selections in `read_pdf`.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **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.
|
|
34
|
+
- **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.
|
|
35
|
+
- **Continuation cursor contract (Breaking Change):** Replaced numeric line offsets (`read_offset_line`) with an opaque Unicode-safe `cursor` token for partial reading continuations.
|
|
36
|
+
- 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")`).
|
|
37
|
+
- Unified configuration parsing, snapshotted execution settings, and made startup-bound storage/payload limits explicit. Split settings sections and preserved numeric input drafts.
|
|
38
|
+
- Separated parse synopsis from body projection and aligned required tool schemas, English guidance, and actionable RPC failures.
|
|
39
|
+
- Consolidated current usage, architecture, deployment limits, and upgrade guidance; removed obsolete lock instructions and temporary audit/work logs.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- Ensured all tool outputs strictly conform to lossless JSON by omitting undefined optional properties instead of serializing `undefined`.
|
|
44
|
+
- Removed the obsolete `defaults.artifacts` field from the shipped Cordis configuration, restoring Host startup under strict configuration validation.
|
|
45
|
+
- 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.
|
|
46
|
+
- Charged consumed image bytes on partial-read, final-stat, and close failures; required actual normalized attachment sizes and propagated cancellation after the final image.
|
|
47
|
+
- Replaced instance-held lock bypass and unsafe stale-file reclamation with scoped, cancellable local-filesystem bakery coordination and explicit mutation authority.
|
|
48
|
+
- Protected readers, image processing, producers, staging cleanup, and destructive maintenance across processes sharing a storage root; rejected symlinked traversal and publication ancestors.
|
|
49
|
+
- Added exact, Unicode-safe `read_pdf` continuation cursors and honest out-of-range/unsupported-selection errors; Native output includes the actual continuation token.
|
|
50
|
+
- Restricted image reads to manifest-declared artifacts, bounded attachments, and separated stable Figure identifiers from successful attachment order.
|
|
51
|
+
- 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.
|
|
52
|
+
- Bounded maintenance traversal and exposed incomplete statistics as lower bounds in the settings UI.
|
|
53
|
+
|
|
54
|
+
### Removed
|
|
55
|
+
|
|
56
|
+
- Removed unused HTTP/transient-reference wrappers, batch router/coordinator code, migration naming, and transitional cache-key/presentation aliases.
|
|
57
|
+
|
|
3
58
|
## 0.0.10
|
|
4
59
|
|
|
5
60
|
### Fixed
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="Awesome DSH Plugin"></a>
|
|
13
13
|
<a href="https://www.npmjs.com/package/dsh-pdf-mineru"><img src="https://img.shields.io/npm/v/dsh-pdf-mineru?style=flat-square&label=npm&color=CB3837" alt="npm version"></a>
|
|
14
14
|
<a href="./package.json"><img src="https://img.shields.io/badge/Node.js-%3E%3D22.19.0-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 22.19.0 or newer"></a>
|
|
15
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.1.
|
|
15
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.1.5--rc.2%20(RC%20only)-111827?style=flat-square" alt="DSH >=0.1.5-rc.2 (RC only)">
|
|
16
16
|
<img src="https://img.shields.io/badge/MinerU-Official%20v4%20%7C%20Self--hosted%20v2-2563EB?style=flat-square" alt="MinerU v2 and v4">
|
|
17
17
|
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-2EA44F?style=flat-square" alt="MIT License"></a>
|
|
18
18
|
</p>
|
|
@@ -38,10 +38,12 @@
|
|
|
38
38
|
### 0. 环境要求与版本兼容说明
|
|
39
39
|
|
|
40
40
|
> ⚠️ **重要版本声明与环境要求**:
|
|
41
|
-
> - **最低支持的 DSH 版本**:`>= 0.1.
|
|
41
|
+
> - **最低支持的 DSH 版本**:`>= 0.1.5-rc.2`。
|
|
42
42
|
> - **仅支持 RC 版本**:本插件**只会对 DeepSeek Harness 的 RC(Release Candidate)版本及后续正式发布版本进行官方支持**。由于早期 `alpha` 测试版本包含较多实验性且剧烈变动的内部 API,本插件不再对 `alpha` 等非稳定测试版本提供兼容与维护支持。
|
|
43
43
|
> - **运行环境要求**:Node.js `^22.19.0 || >=24.0.0`,包管理器推荐 `pnpm@11+`。
|
|
44
44
|
|
|
45
|
+
本次适配从插件 `0.0.12` 起以 DSH `v0.1.5-rc.2` 为基线。升级前请先升级宿主;现有 Provider 配置、缓存格式与工具参数无需因本次 DSH 适配而迁移。Web 设置与维护 RPC 仅在 `connection` 和 `webServer` 同时可用时注册;无 WebServer 的宿主仍可使用两个模型工具,但不提供这些 HTTP RPC。
|
|
46
|
+
|
|
45
47
|
### 1. 安装插件
|
|
46
48
|
|
|
47
49
|
在 DeepSeek Harness 环境中一键安装:
|
|
@@ -106,14 +108,22 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
|
|
|
106
108
|
|
|
107
109
|
### 核心交付字段与正文状态说明
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
`read_pdf` 直接返回阅读结果。`async_parse_pdf` 立即返回原生 `job_id`,完成后通过 `job_output` 提供英文摘要文本,不返回相同的正文结构。阅读结果字段如下:
|
|
110
112
|
|
|
111
113
|
- `markdown_content`:提取的正文 Markdown 文本。
|
|
112
114
|
- `content_status`:正文交付状态:
|
|
113
|
-
- `complete
|
|
114
|
-
- `partial
|
|
115
|
-
- `not_requested
|
|
116
|
-
- `
|
|
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 表示全局禁用);图片仍受单图与总字节安全上限约束。
|
|
121
|
+
|
|
122
|
+
Cursor 是无签名、无服务端状态的读取定位 token,不是授权凭证。源文件仍须存在并保持不变;解析配置、结果身份或选择不匹配时需要重新开始。完全越界页码会明确报错,部分越界给出警告;没有可靠页码/类型映射时,不会假装完成不支持的筛选。
|
|
123
|
+
|
|
124
|
+
后台摘要使用独立路径,不再为生成摘要加载/拼接完整 Markdown,也不受阅读正文的字符预算影响。可选 content-list 最多读取 2 MiB;缺失、为空、格式不可用或超限时返回已完成的解析结果与必要提示,不猜测页数或图表数量。摘要大纲最多 20 项,每项标题最多 160 个 UTF-16 code units。存储层必要的流式完整性校验仍然保留。
|
|
125
|
+
|
|
126
|
+
图片的读取预算与规范化后附件预算分别核算。部分读取后失败、读取后 stat 失败、close 失败均不能退还已消耗的读取字节;附件实际字节未知或无效时不回退使用源文件大小。
|
|
117
127
|
|
|
118
128
|
### 常用解析参数(均可通过自然语言告知 Agent)
|
|
119
129
|
|
|
@@ -121,7 +131,8 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
|
|
|
121
131
|
| --- | --- | --- | --- |
|
|
122
132
|
| `file_path` | `string` | 全部 | 待解析/读取的本地文件路径(必填) |
|
|
123
133
|
| `pages` | `number` / `string` / `number[]` | `read_pdf` | 1-based 页码选择,支持单页(如 `3`)、数组(如 `[1, 2, 5]`)或范围字符串(如 `"1-3, 5"`) |
|
|
124
|
-
| `focus` | `string` / `string[]` | `read_pdf` |
|
|
134
|
+
| `focus` | `string` / `string[]` | `read_pdf` | `all`(默认)、`text`、`table`、`image`、`toc` 或 `artifacts` |
|
|
135
|
+
| `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus` 互斥,仍须传同一 `file_path` |
|
|
125
136
|
| `inline_images` | `boolean` | `read_pdf` | 是否直接内联多模态图表(模型路由支持图片时默认开启) |
|
|
126
137
|
| `poll_timeout_ms` | `number` | `read_pdf` | 最大同步等待超时毫秒数 |
|
|
127
138
|
|
|
@@ -151,7 +162,7 @@ flowchart LR
|
|
|
151
162
|
```
|
|
152
163
|
|
|
153
164
|
- **统一工具分发**:Agent 发起的同步请求(`read_pdf`)直接返回结果,异步长任务(`async_parse_pdf`)交由 DSH 原生 JobRegistry 调度。
|
|
154
|
-
-
|
|
165
|
+
- **缓存复用**:按文件 SHA-256 与解析语义寻址;命中时无需重新提交上游解析,但仍校验本地源文件及产物。
|
|
155
166
|
- **并发请求合并**:同进程内的并发重复请求由 `SharedOperationRegistry` 合并,避免重复向上游提交。
|
|
156
167
|
- **双 Provider 适配**:上游适配自建 FastAPI v2 或官方云 v4,解析产物经校验后原子发布。
|
|
157
168
|
|
|
@@ -161,7 +172,7 @@ flowchart LR
|
|
|
161
172
|
| --- | --- | --- |
|
|
162
173
|
| **部署难度** | ⭐ **零门槛**(仅需配置 API Key) | 需自行部署 MinerU FastAPI 服务及模型环境 |
|
|
163
174
|
| **硬件要求** | 无需本地 GPU,云端集群算力支持 | 推荐配备 NVIDIA GPU 显卡 |
|
|
164
|
-
| **数据安全性** | 数据上传至 MinerU 官方云端解析 |
|
|
175
|
+
| **数据安全性** | 数据上传至 MinerU 官方云端解析 | 由自建服务的部署位置、网络与安全配置决定 |
|
|
165
176
|
| **支持模型** | 原生支持 `pipeline` 与 `vlm` | 支持 `pipeline`,亦可通过 `modelMap` 映射自建 VLM 引擎 |
|
|
166
177
|
| **单文件限制** | 单文件最大 200 MB,最多 200 页 | 取决于自建服务端硬件与配置 |
|
|
167
178
|
| **网络协议** | 强制 HTTPS,安全传输 | 支持 HTTP / HTTPS,本地可配置 `allowInsecureHttp` |
|
|
@@ -177,7 +188,7 @@ flowchart LR
|
|
|
177
188
|
|
|
178
189
|
### 1. 官方云 (Official v4) 推荐配置
|
|
179
190
|
```yaml
|
|
180
|
-
schemaVersion:
|
|
191
|
+
schemaVersion: 2
|
|
181
192
|
activeProvider: mp_official
|
|
182
193
|
providers:
|
|
183
194
|
- id: mp_official
|
|
@@ -194,7 +205,7 @@ defaults:
|
|
|
194
205
|
|
|
195
206
|
### 2. 本地私有化 (Self-hosted v2) 推荐配置
|
|
196
207
|
```yaml
|
|
197
|
-
schemaVersion:
|
|
208
|
+
schemaVersion: 2
|
|
198
209
|
activeProvider: mp_self_hosted
|
|
199
210
|
providers:
|
|
200
211
|
- id: mp_self_hosted
|
|
@@ -218,12 +229,21 @@ storage:
|
|
|
218
229
|
cacheEnabled: true
|
|
219
230
|
output:
|
|
220
231
|
maxInlineChars: 200000 # 单次响应最大内联字符预算(UTF-16 字符)
|
|
232
|
+
maxInlineImages: 6 # 单次 read_pdf 响应最多内联图片数(0–100)
|
|
221
233
|
limits:
|
|
222
234
|
maxFileBytes: 209715200 # 200 MB
|
|
223
235
|
```
|
|
224
236
|
|
|
225
237
|
</details>
|
|
226
238
|
|
|
239
|
+
### 多进程共享存储与升级
|
|
240
|
+
|
|
241
|
+
多个进程可以共享同一 `storageRoot`,前提是同一主机、同一 PID 可见命名空间及支持 hard link 的一致本地文件系统。不支持 NFS、跨主机或互不可见 PID 的容器共享这一锁协议。
|
|
242
|
+
|
|
243
|
+
升级时请先停止所有使用该目录的 MinerU 进程,再统一更新并重启。新协议的 `.process.lock` 是持久版本隔离标记,实际互斥与使用记录位于 `.lock/`;它不是应当在退出时删除的“残留锁”。遇到旧锁或损坏记录,请先确认所有相关进程已停止,再按错误提示人工恢复,切勿在活跃进程运行时删除协调文件。
|
|
244
|
+
|
|
245
|
+
`storageRoot` 与 `limits.*` 在启动时固定。运行中的配置保存会拒绝这些值的变更;应修改宿主配置并重启插件,不能依赖一次被拒绝的保存自动生效。
|
|
246
|
+
|
|
227
247
|
---
|
|
228
248
|
|
|
229
249
|
## ❓ 常见问题 (FAQ)
|
|
@@ -239,7 +259,7 @@ limits:
|
|
|
239
259
|
<details>
|
|
240
260
|
<summary><strong>Q: 扫描版 PDF 或图片文档识别不准怎么办?</strong></summary>
|
|
241
261
|
|
|
242
|
-
普通纯文本 PDF
|
|
262
|
+
普通纯文本 PDF 通常可以使用默认设置。对于扫描件或识别效果不佳的文档,在 MinerU 设置中将 **Default Parse Method** 改为 `ocr`;`ocr` 布尔值由该选择保持一致。模型工具不接受 `ocr`、`model` 等技术参数,不能通过向 `read_pdf` 添加这些参数切换解析方式。
|
|
243
263
|
</details>
|
|
244
264
|
|
|
245
265
|
<details>
|
|
@@ -252,10 +272,10 @@ limits:
|
|
|
252
272
|
<details>
|
|
253
273
|
<summary><strong>Q: 解析结果保存在哪里?如何清理缓存?</strong></summary>
|
|
254
274
|
|
|
255
|
-
|
|
275
|
+
解析结果按源文件内容、解析语义及 Provider 兼容标识寻址,默认存放在 `$DSH_HOME/cache/pdf-mineru/results/`。启用缓存复用时,后续阅读可复用已发布结果;同进程并发请求合并,但不同进程仍可能分别提交上游解析,不保证跨进程只计费一次。`storage.cacheEnabled=false` 仅禁用解析前的缓存复用,结果仍会不可变发布,不等同于清空缓存或强制覆盖已有结果。
|
|
256
276
|
您可以在 **Settings → Plugins → MinerU** 的运维区域中:
|
|
257
277
|
- 点击 **Verify Cache** 检查缓存完整性;
|
|
258
|
-
- 点击 **Clear Cache**
|
|
278
|
+
- 点击 **Clear Cache** 预览,再显式确认清除。破坏性维护在存在活跃读取或解析时拒绝执行,不会为了清理而取消它们。
|
|
259
279
|
</details>
|
|
260
280
|
|
|
261
281
|
<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
|