dsh-pdf-mineru 0.1.0 → 0.1.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 +9 -0
- package/README.md +12 -5
- package/lib/index.js +72 -25
- package/lib/types/adapters/dsh-document-source.d.ts +15 -0
- package/lib/types/tools.d.ts +7 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Accept `attachment_id` as an alternative to `file_path` in `read_pdf` content, cursor and page requests and in `async_parse_pdf`. Both source fields are optional in schemas; exactly one is required at runtime, and callers should retain the same source selector on continuation; existing cursor identity validation is unchanged.
|
|
8
|
+
- Resolve full SHA-256 content IDs or unique 8–64 hexadecimal digest prefixes (optionally `sha256:`-prefixed) from current-session visible file and nested tool-result refs. Reject ambiguous matches and pass the exact matched ref to DSH `fileHostPath`; compacted-out refs are not searched.
|
|
9
|
+
|
|
10
|
+
DSH retains ownership of stored files. Hosts without local-path capability return `UNSUPPORTED_OPTION`; no stream materialization, new integrity checks, storage migration or Provider changes are introduced.
|
|
11
|
+
|
|
3
12
|
## 0.1.0
|
|
4
13
|
|
|
5
14
|
### Added
|
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ PDF.js 包解压约34.8 MB,Canvas JS 约0.13 MB,Linux x64 glibc 二进制约
|
|
|
68
68
|
|
|
69
69
|
打开 DSH 界面中的 **Settings → MinerU**,根据您的使用场景选择 Provider。设置页按卡片分组,高级配置按需展开;修改后点击 **Save Configuration / 保存配置** 生效。连接测试使用当前草稿,缓存清理仍需先预览再确认。
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
设置页包含 Provider、解析默认值、存储与缓存、轮询、重试、输出限制、安全上限和存储维护八张卡片。支持全部展开/折叠,折叠不会丢失表单草稿;启动时固定的安全上限只读展示,需修改宿主配置并重启。界面沿用 DSH 深浅色主题,并支持键盘导航和紧凑布局。
|
|
72
72
|
|
|
73
73
|
<p align="center">
|
|
74
74
|
<img src="./docs/assets/mineru-settings-preview.webp" width="780" alt="dsh-pdf-mineru 在 DSH Settings 中的设置界面">
|
|
@@ -122,26 +122,33 @@ Agent 会自动根据文档长度和指令意图,智能选择同步返回或
|
|
|
122
122
|
|
|
123
123
|
1. 用 `focus: "toc"` 看目录,或用 `query: "图 7"` 字面检索。空格有意义,“图7”与“图 7”不同。
|
|
124
124
|
2. 用返回的 `block_id` 精读完整块,或用物理页码与focus选择内容。标题块不代表整节。
|
|
125
|
-
3. `content_status: "partial"`
|
|
125
|
+
3. `content_status: "partial"` 时,以同一来源选择器(`file_path` 或 `attachment_id`)和原样cursor继续,不重复pages/focus/block_id/query;结束时cursor为null。
|
|
126
126
|
4. 对关键公式、数值和图表,用 `view: "page"` 回看原页;可传source_sha256作为expected_sha256。
|
|
127
127
|
|
|
128
128
|
**complete只表示所选解析文本交付完成,不保证OCR正确或图像全部展示。** 检查当前块的diagnostics、公式verification_hints及visuals;metadata_shortened表示元数据因预算未完整列出。
|
|
129
129
|
|
|
130
130
|
- 默认响应预算12,000个UTF-16单元、正文每块最多8,000;JSON和Native文本各最多48,000字节。默认不重复返回缓存路径;导出用focus: artifacts。
|
|
131
131
|
- `inline_images` 首次省略默认true,续读省略继承,显式布尔值覆盖;模型能力和图像预算始终构成上限。
|
|
132
|
-
- **0.0.14起使用v3游标,0.1.
|
|
132
|
+
- **0.0.14起使用v3游标,0.1.1保持该协议及索引v2;旧v1/v2游标需重新开始,解析缓存无需迁移。** 续读不会在缓存丢失时偷偷重新上传。
|
|
133
133
|
- 原页模式优先使用 PATH 中的 Poppler(pdfinfo/pdftoppm),命令缺失或明确不可执行时自动回退到 PDF.js + Node Canvas 子进程;仍需图像模型、附件服务及大于0的图像预算。结果以 `renderer: "poppler" | "pdfjs"` 标明后端,不会上传PDF或要求模型重新调用。它是本地有界执行,不是OS级隔离沙箱。
|
|
134
134
|
|
|
135
135
|
字段语义、完整示例、来源/索引版本、预算、安全边界、错误恢复和离线验收见 **[PDF阅读指南](docs/model-reading.md)**。更新插件后需要让宿主重新加载工具定义;只构建源码或刷新Web页面不等于后端已重载。
|
|
136
136
|
|
|
137
|
+
### 文件来源
|
|
138
|
+
|
|
139
|
+
`read_pdf` 的正文、续读、原页模式及 `async_parse_pdf` 都保留 `file_path`,也可改用互斥的 `attachment_id`,例如 `{"attachment_id":"<当前附件的完整内容ID>","focus":"toc"}`。两个来源字段在 schema 中均可选,但每次调用运行时必须且只能提供一个;调用方续读应保留同一选择器;游标仍按既有结果/投影身份校验,不新增选择器字符串绑定。
|
|
140
|
+
|
|
141
|
+
附件 ID 可为完整 `sha256:` 加 64 位十六进制摘要,或 8–64 位摘要前缀(可带 `sha256:`)。只匹配当前会话可见消息中的文件及嵌套工具结果引用;已压缩移出的引用不可见。多个不同内容 ID 匹配时拒绝,需提供更长前缀或完整 ID;不会猜测路径或搜索全局附件库。附件仍由 DSH 管理;宿主不提供本地路径能力时返回 `UNSUPPORTED_OPTION`,插件不会将附件流落盘。Provider、缓存和既有完整性校验不变。
|
|
142
|
+
|
|
137
143
|
### 常用解析参数(均可通过自然语言告知 Agent)
|
|
138
144
|
|
|
139
145
|
| 参数 | 类型 | 适用工具 | 作用说明 |
|
|
140
146
|
| --- | --- | --- | --- |
|
|
141
|
-
| `file_path` | `string` | 全部 |
|
|
147
|
+
| `file_path` | `string` | 全部 | 本地文件路径;与 `attachment_id` 必须且只能选一个 |
|
|
148
|
+
| `attachment_id` | `string` | 全部 | 当前会话可见文件附件的完整内容 ID 或唯一摘要前缀(8–64 位十六进制,可带 `sha256:`) |
|
|
142
149
|
| `pages` | `number` / `string` / `number[]` | `read_pdf` | 1-based 页码选择,支持单页(如 `3`)、数组(如 `[1, 2, 5]`)或范围字符串(如 `"1-3, 5"`) |
|
|
143
150
|
| `focus` | `string` / `string[]` | `read_pdf` | `all`(默认)、`text`、`table`、`image`、`toc` 或 `artifacts` |
|
|
144
|
-
| `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus`/`block_id`/`query`
|
|
151
|
+
| `cursor` | `string` | `read_pdf` | 原样传回上一条部分阅读响应的 token;与 `pages`/`focus`/`block_id`/`query` 互斥,仍须传同一来源选择器(`file_path` 或 `attachment_id`) |
|
|
145
152
|
| `block_id` | `string` | `read_pdf` | 原样使用此前返回的稳定块 ID;与 `query`、`cursor` 互斥 |
|
|
146
153
|
| `query` | `string` | `read_pdf` | 1–256 字符、不区分大小写的字面检索;返回上下文摘要与块 ID,再用 `block_id` 读全文 |
|
|
147
154
|
| `view` | `"content"` / `"page"` | `read_pdf` | 默认解析文本;page 模式只接受一页 `pages`,本地渲染原页,不调用 Provider |
|
package/lib/index.js
CHANGED
|
@@ -8437,6 +8437,38 @@ function mediaTypeForExtension(ext) {
|
|
|
8437
8437
|
}
|
|
8438
8438
|
}
|
|
8439
8439
|
//#endregion
|
|
8440
|
+
//#region src/adapters/dsh-document-source.ts
|
|
8441
|
+
function parseDocumentSource(args) {
|
|
8442
|
+
if (args.file_path !== void 0 === (args.attachment_id !== void 0)) throw new MinerUError(failure("INVALID_REQUEST", "Exactly one of file_path or attachment_id is required"));
|
|
8443
|
+
if (args.file_path !== void 0) {
|
|
8444
|
+
if (typeof args.file_path !== "string" || args.file_path.trim() === "") throw new MinerUError(failure("INVALID_REQUEST", "file_path must be a non-empty string"));
|
|
8445
|
+
return { file_path: args.file_path.trim() };
|
|
8446
|
+
}
|
|
8447
|
+
if (typeof args.attachment_id !== "string" || !/^(?:sha256:)?[a-fA-F0-9]{8,64}$/.test(args.attachment_id.trim())) throw new MinerUError(failure("INVALID_REQUEST", "attachment_id must be a SHA-256 digest or an unambiguous prefix of 8–64 hexadecimal characters, optionally prefixed with sha256:"));
|
|
8448
|
+
return { attachment_id: args.attachment_id.trim().toLowerCase() };
|
|
8449
|
+
}
|
|
8450
|
+
function* fileReferences(blocks) {
|
|
8451
|
+
for (const block of blocks) if (block.type === "file") yield block.attachment;
|
|
8452
|
+
else if (block.type === "tool-result") yield* fileReferences(block.content);
|
|
8453
|
+
}
|
|
8454
|
+
/** Resolve only references on the current DSH surface; never scan raw history or storage. */
|
|
8455
|
+
function resolveDocumentPath(source, session, attachments) {
|
|
8456
|
+
if (source.file_path !== void 0) return source.file_path;
|
|
8457
|
+
if (attachments === void 0) throw new MinerUError(failure("UNSUPPORTED_OPTION", "Attachment input requires the DSH attachment service; use file_path instead"));
|
|
8458
|
+
const prefix = source.attachment_id.replace(/^sha256:/, "");
|
|
8459
|
+
const matches = /* @__PURE__ */ new Map();
|
|
8460
|
+
for (const message of session.deriveMessages()) for (const ref of fileReferences(message.content)) {
|
|
8461
|
+
const id = String(ref.attachmentId);
|
|
8462
|
+
if (id.slice(7).startsWith(prefix) && !matches.has(id)) matches.set(id, ref);
|
|
8463
|
+
}
|
|
8464
|
+
if (matches.size === 0) throw new MinerUError(failure("INVALID_REQUEST", "No file attachment matches attachment_id on the current session surface"));
|
|
8465
|
+
if (matches.size > 1) throw new MinerUError(failure("INVALID_REQUEST", "attachment_id is ambiguous; use a longer prefix or the full SHA-256 ID"));
|
|
8466
|
+
const ref = matches.values().next().value;
|
|
8467
|
+
const path = attachments.fileHostPath(ref);
|
|
8468
|
+
if (path === void 0) throw new MinerUError(failure("UNSUPPORTED_OPTION", "The DSH attachment backend does not provide a host file path; use file_path instead"));
|
|
8469
|
+
return path;
|
|
8470
|
+
}
|
|
8471
|
+
//#endregion
|
|
8440
8472
|
//#region src/tools.ts
|
|
8441
8473
|
/** Model-facing MinerU tools: native background submit and direct parse. */
|
|
8442
8474
|
const artifactViewSchema = {
|
|
@@ -8803,17 +8835,19 @@ const parseOutputSchema = {
|
|
|
8803
8835
|
},
|
|
8804
8836
|
additionalProperties: false
|
|
8805
8837
|
};
|
|
8806
|
-
const
|
|
8807
|
-
type: "string",
|
|
8808
|
-
description: "Path of the local PDF document to parse.",
|
|
8809
|
-
required: true
|
|
8810
|
-
} };
|
|
8811
|
-
const readPdfParameters = {
|
|
8838
|
+
const documentSourceParameters = {
|
|
8812
8839
|
file_path: {
|
|
8813
8840
|
type: "string",
|
|
8814
|
-
description: "Path of the local PDF document
|
|
8815
|
-
required: true
|
|
8841
|
+
description: "Path of the local PDF document. Provide exactly one of file_path or attachment_id."
|
|
8816
8842
|
},
|
|
8843
|
+
attachment_id: {
|
|
8844
|
+
type: "string",
|
|
8845
|
+
description: "File attachment on the current session surface: full SHA-256 ID or unique 8–64 hex-character digest prefix, with optional sha256: prefix. Uses the DSH host file path; not a URL or filesystem path. Mutually exclusive with file_path."
|
|
8846
|
+
}
|
|
8847
|
+
};
|
|
8848
|
+
const asyncParseParameters = documentSourceParameters;
|
|
8849
|
+
const readPdfParameters = {
|
|
8850
|
+
...documentSourceParameters,
|
|
8817
8851
|
view: {
|
|
8818
8852
|
type: "string",
|
|
8819
8853
|
enum: ["content", "page"],
|
|
@@ -8888,7 +8922,7 @@ const readPdfParameters = {
|
|
|
8888
8922
|
},
|
|
8889
8923
|
cursor: {
|
|
8890
8924
|
type: "string",
|
|
8891
|
-
description: "Opaque continuation cursor returned by a previous partial read. Pass only a non-empty returned token, unchanged; null means stop, not restart. When provided, file_path is required and pages/focus must be omitted."
|
|
8925
|
+
description: "Opaque continuation cursor returned by a previous partial read. Pass only a non-empty returned token, unchanged; null means stop, not restart. When provided, the same source (file_path or attachment_id) is required and pages/focus must be omitted."
|
|
8892
8926
|
}
|
|
8893
8927
|
};
|
|
8894
8928
|
const DEFAULT_RENDER_LIMIT = 2e5;
|
|
@@ -8959,6 +8993,7 @@ function requireAgent(exec) {
|
|
|
8959
8993
|
}
|
|
8960
8994
|
const READ_PARAMETER_FIELDS = /* @__PURE__ */ new Set([
|
|
8961
8995
|
"file_path",
|
|
8996
|
+
"attachment_id",
|
|
8962
8997
|
"pages",
|
|
8963
8998
|
"focus",
|
|
8964
8999
|
"inline_images",
|
|
@@ -8969,25 +9004,28 @@ const READ_PARAMETER_FIELDS = /* @__PURE__ */ new Set([
|
|
|
8969
9004
|
"view",
|
|
8970
9005
|
"expected_sha256"
|
|
8971
9006
|
]);
|
|
8972
|
-
const ASYNC_PARAMETER_FIELDS = /* @__PURE__ */ new Set(["file_path"]);
|
|
9007
|
+
const ASYNC_PARAMETER_FIELDS = /* @__PURE__ */ new Set(["file_path", "attachment_id"]);
|
|
9008
|
+
function resolveToolInput(input, agent, attachments) {
|
|
9009
|
+
const { file_path: _path, attachment_id: _id, ...options } = input;
|
|
9010
|
+
return {
|
|
9011
|
+
...options,
|
|
9012
|
+
file_path: resolveDocumentPath(input, agent.session, attachments)
|
|
9013
|
+
};
|
|
9014
|
+
}
|
|
8973
9015
|
function assertAllowedParameters(args, allowed) {
|
|
8974
9016
|
for (const key of Object.keys(args)) if (!allowed.has(key)) throw new MinerUError(failure("INVALID_REQUEST", `Unsupported parameter: ${key}. Valid parameters: ${[...allowed].join(", ")}`));
|
|
8975
9017
|
}
|
|
8976
|
-
function extractFilePath(args) {
|
|
8977
|
-
if (typeof args.file_path !== "string" || args.file_path.trim() === "") throw new MinerUError(failure("INVALID_REQUEST", "Local document path (file_path) is required"));
|
|
8978
|
-
return args.file_path.trim();
|
|
8979
|
-
}
|
|
8980
9018
|
function parseAsyncInput(args) {
|
|
8981
9019
|
if (typeof args !== "object" || args === null || Array.isArray(args)) throw new MinerUError(failure("INVALID_REQUEST", "Tool arguments must be an object"));
|
|
8982
9020
|
const obj = args;
|
|
8983
9021
|
assertAllowedParameters(obj, ASYNC_PARAMETER_FIELDS);
|
|
8984
|
-
return { input:
|
|
9022
|
+
return { input: parseDocumentSource(obj) };
|
|
8985
9023
|
}
|
|
8986
9024
|
function parseReadInput(args) {
|
|
8987
9025
|
if (typeof args !== "object" || args === null || Array.isArray(args)) throw new MinerUError(failure("INVALID_REQUEST", "Tool arguments must be an object"));
|
|
8988
9026
|
const obj = args;
|
|
8989
9027
|
assertAllowedParameters(obj, READ_PARAMETER_FIELDS);
|
|
8990
|
-
const
|
|
9028
|
+
const source = parseDocumentSource(obj);
|
|
8991
9029
|
const pollTimeoutMs = parsePollTimeout(obj.poll_timeout_ms);
|
|
8992
9030
|
if (obj.view !== void 0 && obj.view !== "content" && obj.view !== "page") throw new MinerUError(failure("INVALID_REQUEST", "view must be content or page"));
|
|
8993
9031
|
if (obj.view === "page") {
|
|
@@ -8998,7 +9036,7 @@ function parseReadInput(args) {
|
|
|
8998
9036
|
"block_id",
|
|
8999
9037
|
"inline_images",
|
|
9000
9038
|
"poll_timeout_ms"
|
|
9001
|
-
]) if (obj[key] !== void 0) throw new MinerUError(failure("INVALID_REQUEST", "page view accepts only file_path, pages, and optional expected_sha256"));
|
|
9039
|
+
]) if (obj[key] !== void 0) throw new MinerUError(failure("INVALID_REQUEST", "page view accepts only one source (file_path or attachment_id), pages, and optional expected_sha256"));
|
|
9002
9040
|
let selected;
|
|
9003
9041
|
try {
|
|
9004
9042
|
selected = normalizePageSelection(obj.pages);
|
|
@@ -9008,7 +9046,7 @@ function parseReadInput(args) {
|
|
|
9008
9046
|
if (selected === void 0 || selected.size !== 1) throw new MinerUError(failure("INVALID_REQUEST", "page view requires exactly one physical page in pages"));
|
|
9009
9047
|
if (obj.expected_sha256 !== void 0 && (typeof obj.expected_sha256 !== "string" || !/^[a-f0-9]{64}$/.test(obj.expected_sha256))) throw new MinerUError(failure("INVALID_REQUEST", "expected_sha256 must be a lowercase SHA-256 digest"));
|
|
9010
9048
|
return {
|
|
9011
|
-
input:
|
|
9049
|
+
input: source,
|
|
9012
9050
|
view: "page",
|
|
9013
9051
|
page: [...selected][0],
|
|
9014
9052
|
...typeof obj.expected_sha256 === "string" ? { expected_sha256: obj.expected_sha256 } : {}
|
|
@@ -9053,7 +9091,7 @@ function parseReadInput(args) {
|
|
|
9053
9091
|
const resolvedInlineImages = inline_images ?? cursorInlineImages ?? true;
|
|
9054
9092
|
return {
|
|
9055
9093
|
input: {
|
|
9056
|
-
|
|
9094
|
+
...source,
|
|
9057
9095
|
...pages !== void 0 ? { pages } : {},
|
|
9058
9096
|
...focus !== void 0 ? { focus } : {},
|
|
9059
9097
|
inline_images: resolvedInlineImages,
|
|
@@ -9252,7 +9290,7 @@ async function checkCallingModelSupportsImage(exec, ctx) {
|
|
|
9252
9290
|
}
|
|
9253
9291
|
return false;
|
|
9254
9292
|
}
|
|
9255
|
-
function registerTools(ctx, getService, accessGate, getOutputConfig = () => DEFAULT_OUTPUT_CONFIG) {
|
|
9293
|
+
function registerTools(ctx, getService, accessGate, getOutputConfig = () => DEFAULT_OUTPUT_CONFIG, getAttachments = () => ctx.get("attachments")) {
|
|
9256
9294
|
const disposers = [];
|
|
9257
9295
|
const backgroundInvocations = /* @__PURE__ */ new Set();
|
|
9258
9296
|
const withStorageAccess = async (operation, signal) => {
|
|
@@ -9296,7 +9334,7 @@ function registerTools(ctx, getService, accessGate, getOutputConfig = () => DEFA
|
|
|
9296
9334
|
execute: async (args, exec) => {
|
|
9297
9335
|
const agent = requireAgent(exec);
|
|
9298
9336
|
exec.signal.throwIfAborted();
|
|
9299
|
-
const
|
|
9337
|
+
const input = resolveToolInput(parseAsyncInput(args).input, agent, getAttachments());
|
|
9300
9338
|
const jobs = ctx.get("jobs");
|
|
9301
9339
|
if (jobs === void 0) throw new MinerUError(failure("PROVIDER_UNAVAILABLE", "Native DSH background jobs are unavailable; load the jobs registry and job tools"));
|
|
9302
9340
|
const controller = new AbortController();
|
|
@@ -9338,7 +9376,7 @@ function registerTools(ctx, getService, accessGate, getOutputConfig = () => DEFA
|
|
|
9338
9376
|
})));
|
|
9339
9377
|
disposers.push(ctx.tools.register(defineTool({
|
|
9340
9378
|
name: "read_pdf",
|
|
9341
|
-
description: "Read PDF evidence in bounded chunks with physical pages and stable block IDs. Start with focus: toc or a short query; use block_id to read a search hit. markdown_content contains selected parsed text; partial requires continuing with the unchanged cursor and same file_path only (no pages/focus/block_id/query). The cursor is null when complete or not_requested. Continue only when partial; stop rather than passing null back. Complete ends that text selection, not a guarantee of OCR fidelity or visual coverage; check diagnostics and visuals. Diagnostics are scoped to delivered blocks; document/selection notices appear initially. verification_hints recommend original-page checks for formulas, not automatic corrections. provenance separates parsing configuration from index/reader versions; upstream_version null means unknown. Omitted inline_images inherits the cursor intent; an explicit boolean overrides it. metadata_shortened identifies budget-limited metadata. Use view: page with one page number to inspect the original PDF locally without Provider upload, optionally checking source_sha256 via expected_sha256. Use focus: artifacts only for exported cache paths. Output in run_code should preserve markdown_content and cursor, rather than dumping large/debug objects.",
|
|
9379
|
+
description: "Read PDF evidence in bounded chunks with physical pages and stable block IDs. Start with focus: toc or a short query; use block_id to read a search hit. markdown_content contains selected parsed text; partial requires continuing with the unchanged cursor and same source (file_path or attachment_id) only (no pages/focus/block_id/query). The cursor is null when complete or not_requested. Continue only when partial; stop rather than passing null back. Complete ends that text selection, not a guarantee of OCR fidelity or visual coverage; check diagnostics and visuals. Diagnostics are scoped to delivered blocks; document/selection notices appear initially. verification_hints recommend original-page checks for formulas, not automatic corrections. provenance separates parsing configuration from index/reader versions; upstream_version null means unknown. Omitted inline_images inherits the cursor intent; an explicit boolean overrides it. metadata_shortened identifies budget-limited metadata. Use view: page with one page number to inspect the original PDF locally without Provider upload, optionally checking source_sha256 via expected_sha256. Use focus: artifacts only for exported cache paths. Output in run_code should preserve markdown_content and cursor, rather than dumping large/debug objects.",
|
|
9342
9380
|
parameters: readPdfParameters,
|
|
9343
9381
|
output: {
|
|
9344
9382
|
schema: parseOutputSchema,
|
|
@@ -9411,10 +9449,12 @@ function registerTools(ctx, getService, accessGate, getOutputConfig = () => DEFA
|
|
|
9411
9449
|
execute: async (args, exec) => {
|
|
9412
9450
|
const agent = requireAgent(exec);
|
|
9413
9451
|
const parsed = parseReadInput(args);
|
|
9414
|
-
|
|
9452
|
+
exec.signal.throwIfAborted();
|
|
9453
|
+
const attachments = getAttachments();
|
|
9454
|
+
const input = resolveToolInput(parsed.input, agent, attachments);
|
|
9455
|
+
const { pollTimeoutMs, inline_images } = parsed;
|
|
9415
9456
|
const { maxInlineImages } = getOutputConfig();
|
|
9416
9457
|
const supportsImage = await checkCallingModelSupportsImage(exec, ctx);
|
|
9417
|
-
const attachments = ctx.get("attachments");
|
|
9418
9458
|
if (parsed.view === "page") {
|
|
9419
9459
|
if (maxInlineImages === 0) throw new MinerUError(failure("UNSUPPORTED_OPTION", "Original page view requires output.maxInlineImages greater than zero"));
|
|
9420
9460
|
if (!supportsImage || attachments === void 0) throw new MinerUError(failure("UNSUPPORTED_OPTION", "Original page view requires an image-capable model and attachment support"));
|
|
@@ -9932,7 +9972,14 @@ async function apply(ctx, entryConfig = {}) {
|
|
|
9932
9972
|
return environment && environment.length > 0 ? environment : void 0;
|
|
9933
9973
|
}
|
|
9934
9974
|
});
|
|
9935
|
-
|
|
9975
|
+
let attachments;
|
|
9976
|
+
ctx.inject(["attachments"], (attachmentCtx) => {
|
|
9977
|
+
attachments = attachmentCtx.attachments;
|
|
9978
|
+
return () => {
|
|
9979
|
+
attachments = void 0;
|
|
9980
|
+
};
|
|
9981
|
+
});
|
|
9982
|
+
toolDisposer = registerTools(ctx, () => service, accessGate, () => runtimeConfig().output, () => attachments);
|
|
9936
9983
|
ctx.inject(["connection", "webServer"], (connectionCtx) => {
|
|
9937
9984
|
return registerRpc(connectionCtx, {
|
|
9938
9985
|
getConfig: () => persistedConfig,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
2
|
+
import type { Message } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
/** Tool-only selectors. Attachment identities never enter the MinerU domain. */
|
|
4
|
+
export type DocumentSource = {
|
|
5
|
+
readonly file_path: string;
|
|
6
|
+
readonly attachment_id?: never;
|
|
7
|
+
} | {
|
|
8
|
+
readonly attachment_id: string;
|
|
9
|
+
readonly file_path?: never;
|
|
10
|
+
};
|
|
11
|
+
export declare function parseDocumentSource(args: Readonly<Record<string, unknown>>): DocumentSource;
|
|
12
|
+
/** Resolve only references on the current DSH surface; never scan raw history or storage. */
|
|
13
|
+
export declare function resolveDocumentPath(source: DocumentSource, session: {
|
|
14
|
+
deriveMessages(): readonly Message[];
|
|
15
|
+
}, attachments: Pick<AttachmentStore, 'fileHostPath'> | undefined): string;
|
package/lib/types/tools.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
2
3
|
import type { ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
3
4
|
import type { ParseRequestInput } from './domain/request.js';
|
|
4
5
|
import { type OutputConfig } from './config/pure.js';
|
|
5
6
|
import type { StorageAccessGate } from './storage/access-gate.js';
|
|
6
7
|
import type { MinerUService, ResultView } from './service/mineru-service.js';
|
|
8
|
+
import { type DocumentSource } from './adapters/dsh-document-source.js';
|
|
7
9
|
declare module '@deepseek-ai/dsh-jobs' {
|
|
8
10
|
interface JobKindMap {
|
|
9
11
|
mineru: 'mineru';
|
|
10
12
|
}
|
|
11
13
|
}
|
|
14
|
+
type ToolParseRequestInput = Omit<ParseRequestInput, 'file_path'> & DocumentSource;
|
|
12
15
|
export declare function parseAsyncInput(args: unknown): {
|
|
13
|
-
readonly input:
|
|
16
|
+
readonly input: ToolParseRequestInput;
|
|
14
17
|
};
|
|
15
18
|
export interface ParsedToolInput {
|
|
16
|
-
readonly input:
|
|
19
|
+
readonly input: ToolParseRequestInput;
|
|
17
20
|
readonly pollTimeoutMs?: number;
|
|
18
21
|
readonly inline_images?: boolean;
|
|
19
22
|
readonly view?: 'page';
|
|
@@ -22,4 +25,5 @@ export interface ParsedToolInput {
|
|
|
22
25
|
}
|
|
23
26
|
export declare function parseReadInput(args: unknown): ParsedToolInput;
|
|
24
27
|
export declare function renderResult(value: ResultView): ContentBlock[];
|
|
25
|
-
export declare function registerTools(ctx: Context, getService: () => MinerUService, accessGate?: StorageAccessGate, getOutputConfig?: () => OutputConfig): () => Promise<void>;
|
|
28
|
+
export declare function registerTools(ctx: Context, getService: () => MinerUService, accessGate?: StorageAccessGate, getOutputConfig?: () => OutputConfig, getAttachments?: () => AttachmentStore | undefined): () => Promise<void>;
|
|
29
|
+
export {};
|
package/package.json
CHANGED