dsh-mineru 0.1.17 → 0.1.19

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
@@ -2,12 +2,26 @@
2
2
 
3
3
  All notable changes to **dsh-mineru** are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/), and versioning follows [Semantic Versioning](https://semver.org/lang/zh-CN/). 版本号唯一来源是 `package.json`。
4
4
 
5
- ## [0.1.17] - 2026-11-11
6
-
7
- ### Fixed
8
-
9
- - The MinerU settings panel could be unreachable: the client only registered a `settings.plugins.tab` contribution, and a deployment whose composition ships no Plugins settings section never renders that slot, so the tab was dropped silently and Settings showed no MinerU entry at all. The panel now also registers a standalone `settings.section` (with a `settings.section.icon`), which every settings dialog renders; the tab registration stays for deployments that do have the Plugins section.
10
-
5
+ ## [0.1.19] - 2026-11-29
6
+
7
+ ### Fixed
8
+
9
+ - Dropping or pasting a file always reported "please open a session first" even with a chat open. `currentSession()` read a `current` field that does not exist on the host's `SessionListState` (which only carries `ids`, `byId`, `phase`), so the intake path never resolved a session. It now derives the viewed session from the `retainedBy.mainView` retention count, matching how the host's own packages identify the active session.
10
+ - Image drops were hijacked in the capture phase and never reached the native image-attachment channel. The drop filter now excludes `IMAGE_DROP_EXT`, consistent with the existing paste handler, so images keep their native channel while documents still route through the plugin.
11
+
12
+ ## [0.1.18] - 2026-11-11
13
+
14
+ ### Fixed
15
+
16
+ - The Settings card's **Test token** button failed for perfectly healthy tokens. It submitted the vendor's own demo PDF (`cdn-mineru.openxlab.org.cn/demo/example.pdf`) through URL mode with `vlm`, and MinerU now rejects exactly that combination at submit time with `-60017 retry limit reached (5 attempts), please replace the file`, so the card reported a token problem that did not exist. The probe is now a 1-page PDF embedded in the package (`lib/token-probe.js`): it is written to a temp file, uploaded through the precision API and polled to `done`, which exercises the credential plus the signed upload/poll/download chain in one call. The test costs about one page of quota, uses the configured `modelVersion` instead of a hard-coded `vlm`, and no longer depends on any third-party file staying online.
17
+ - MinerU error messages now keep the vendor's own words. `parsePayloadError` appends `(MinerU 原文:…)` to the mapped Chinese summary for both top-level `msg` and per-file `err_msg`, and the `-60017` text no longer claims the user must wait for a model upgrade — it names the retry limit and suggests switching the model version to `pipeline`.
18
+
19
+ ## [0.1.17] - 2026-11-11
20
+
21
+ ### Fixed
22
+
23
+ - The MinerU settings panel could be unreachable: the client only registered a `settings.plugins.tab` contribution, and a deployment whose composition ships no Plugins settings section never renders that slot, so the tab was dropped silently and Settings showed no MinerU entry at all. The panel now also registers a standalone `settings.section` (with a `settings.section.icon`), which every settings dialog renders; the tab registration stays for deployments that do have the Plugins section.
24
+
11
25
  ## [0.1.16] - 2026-11-11
12
26
 
13
27
  ### Fixed
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # dsh-mineru
2
2
 
3
3
  [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
- [![version](https://img.shields.io/badge/version-0.1.17-blue)](https://github.com/Lee-Hilex/dsh-mineru/releases)
4
+ [![version](https://img.shields.io/badge/version-0.1.19-blue)](https://github.com/Lee-Hilex/dsh-mineru/releases)
5
5
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-0.2.0--rc.2-4d6bfe)](https://github.com/deepseek-ai/deepseek-harness)
6
6
  [![MinerU](https://img.shields.io/badge/MinerU-API-4d6bfe)](https://mineru.net/apiManage/docs)
7
7
 
package/README.zh.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # dsh-mineru
2
2
 
3
3
  [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
- [![version](https://img.shields.io/badge/version-0.1.17-blue)](https://github.com/Lee-Hilex/dsh-mineru/releases)
4
+ [![version](https://img.shields.io/badge/version-0.1.19-blue)](https://github.com/Lee-Hilex/dsh-mineru/releases)
5
5
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-0.2.0--rc.2-4d6bfe)](https://github.com/deepseek-ai/deepseek-harness)
6
6
  [![MinerU](https://img.shields.io/badge/MinerU-API-4d6bfe)](https://mineru.net/apiManage/docs)
7
7
 
package/lib/client.js CHANGED
@@ -653,10 +653,24 @@ window.__ModuleLoader__.load({
653
653
  }
654
654
 
655
655
  function installFileDropBridge(ctx) {
656
- var currentSession = function () { return ctx.sessions.list.getSnapshot().current; };
656
+ // The host exposes no sessions.current: the viewed Session is derived
657
+ // from its mainView retention count (see client session references).
658
+ var currentSession = function () {
659
+ var rows = ctx.sessions.list.getSnapshot().byId;
660
+ for (var id in rows) {
661
+ if (!Object.prototype.hasOwnProperty.call(rows, id)) continue;
662
+ var retained = rows[id] && rows[id].retainedBy;
663
+ if (retained && (retained.mainView || 0) > 0) return id;
664
+ }
665
+ return undefined;
666
+ };
657
667
  var hasFiles = function (event) { return event.dataTransfer ? event.dataTransfer.types.includes("Files") : false; };
658
668
  var supportedOf = function (list) {
659
- return Array.from(list ?? []).filter(function (f) { return f && SUPPORTED_DROP_EXT.includes(dropExtOf(f.name)); });
669
+ return Array.from(list ?? []).filter(function (f) {
670
+ // Exclude images so native image-attachment drops keep their
671
+ // own channel; only documents route through this bridge.
672
+ return f && SUPPORTED_DROP_EXT.includes(dropExtOf(f.name)) && !IMAGE_DROP_EXT[dropExtOf(f.name)];
673
+ });
660
674
  };
661
675
  // The native composer drag overlay can get stuck on for OS-originated
662
676
  // drags (dragend never fires inside the browser). Dispatching a
@@ -1,135 +1,135 @@
1
- /**
2
- * DNS resolution with a public-resolver fallback.
3
- *
4
- * Campus and ISP DNS servers sometimes answer public CDN hostnames with a
5
- * loopback address (captive-DNS / filtering behaviour). When that happens the
6
- * MinerU API is reachable but the result CDN is not, and the download step
7
- * fails with a bare `fetch failed`. This module builds a `lookup` callback for
8
- * `node:http(s)` that keeps trusting the system resolver unless it returns no
9
- * usable address, and only then asks ordinary public resolvers over UDP 53 —
10
- * no DNS-over-HTTPS dependency, no proxy, no hosts-file edit.
11
- *
12
- * The callback follows the `net.connect` contract: it answers
13
- * `(err, address, family)` by default and `(err, [{ address, family }])` when
14
- * `options.all` is set (undici and Node's autoSelectFamily ask that way).
15
- * @module dsh-mineru/dns-resolve
16
- */
17
- import { lookup as systemLookup } from 'node:dns';
18
- import { Resolver } from 'node:dns/promises';
19
-
20
- /** Public resolvers used only when the system resolver yields nothing usable. */
21
- const DEFAULT_SERVERS = ['223.5.5.5', '119.29.29.29'];
22
- const DEFAULT_TTL_MS = 10 * 60 * 1000;
23
- const DEFAULT_TIMEOUT_MS = 5000;
24
-
25
- /**
26
- * Whether an address is unusable for reaching a public host.
27
- * Loopback and unspecified addresses mean a filtered or captive resolver,
28
- * never a real destination for a remote CDN.
29
- * @param {unknown} address
30
- * @returns {boolean}
31
- */
32
- export function isLoopbackAddress(address) {
33
- const value = String(address ?? '').toLowerCase();
34
- if (value === '::1' || value === '::' || value === '0.0.0.0') return true;
35
- if (value.startsWith('127.')) return true;
36
- const mapped = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(value);
37
- if (mapped) return isLoopbackAddress(mapped[1]);
38
- return false;
39
- }
40
-
41
- /**
42
- * Resolve a hostname through explicit public resolvers.
43
- * @param {string[]} servers
44
- * @param {number} timeoutMs
45
- * @returns {(hostname: string) => Promise<{address: string, family: number}[]>}
46
- */
47
- export function createPublicResolve(servers = DEFAULT_SERVERS, timeoutMs = DEFAULT_TIMEOUT_MS) {
48
- const resolver = new Resolver({ timeout: timeoutMs, tries: 2 });
49
- resolver.setServers(servers);
50
- return async function resolve(hostname) {
51
- const [v4, v6] = await Promise.all([
52
- resolver.resolve4(hostname).catch(() => []),
53
- resolver.resolve6(hostname).catch(() => []),
54
- ]);
55
- const addresses = [
56
- ...v4.map((address) => ({ address, family: 4 })),
57
- ...v6.map((address) => ({ address, family: 6 })),
58
- ].filter((entry) => !isLoopbackAddress(entry.address));
59
- if (addresses.length === 0) {
60
- throw new Error('public resolvers returned no usable address for ' + hostname);
61
- }
62
- return addresses;
63
- };
64
- }
65
-
66
- /**
67
- * Build a `lookup` callback that falls back to public resolvers.
68
- *
69
- * Results are cached per hostname for `ttlMs`, so a download loop resolves
70
- * once. Every injectable seam exists for tests: `systemLookup` and `resolve`.
71
- * @param {object} [options]
72
- * @param {string[]} [options.servers] public resolvers to ask on fallback
73
- * @param {number} [options.ttlMs] fallback-answer cache lifetime
74
- * @param {number} [options.timeoutMs] per-query timeout for the public resolvers
75
- * @param {Function} [options.systemLookup] `node:dns` lookup replacement
76
- * @param {(hostname: string) => Promise<{address: string, family: number}[]>} [options.resolve]
77
- * @returns {(hostname: string, options: object|Function, callback?: Function) => void}
78
- */
79
- export function createFallbackLookup(options = {}) {
80
- const ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
81
- const system = options.systemLookup ?? systemLookup;
82
- const resolve = options.resolve ?? createPublicResolve(
83
- options.servers ?? DEFAULT_SERVERS,
84
- options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
85
- );
86
- /** @type {Map<string, {addresses: {address: string, family: number}[], expires: number}>} */
87
- const cache = new Map();
88
-
89
- return function lookup(hostname, opts, callback) {
90
- const query = typeof opts === 'function' ? {} : (opts ?? {});
91
- const done = typeof opts === 'function' ? opts : callback;
92
-
93
- /** @param {{address: string, family: number}[]} addresses @param {Error|null} [fallbackError] */
94
- const deliver = (addresses, fallbackError) => {
95
- if (addresses.length === 0) {
96
- done(fallbackError ?? new Error('no usable address for ' + hostname));
97
- return;
98
- }
99
- const wanted = query.family === 6 ? 6 : query.family === 4 ? 4 : 0;
100
- const matching = wanted ? addresses.filter((entry) => entry.family === wanted) : addresses;
101
- const list = matching.length > 0 ? matching : addresses;
102
- if (query.all) {
103
- done(null, list);
104
- return;
105
- }
106
- done(null, list[0].address, list[0].family);
107
- };
108
-
109
- const cached = cache.get(hostname);
110
- if (cached && cached.expires > Date.now()) {
111
- deliver(cached.addresses);
112
- return;
113
- }
114
- if (cached) cache.delete(hostname);
115
-
116
- system(hostname, { ...query, all: true }, (error, list) => {
117
- const usable = (list ?? []).filter((entry) => !isLoopbackAddress(entry.address));
118
- if (usable.length > 0) {
119
- deliver(usable);
120
- return;
121
- }
122
- resolve(hostname).then(
123
- (addresses) => {
124
- if (addresses.length === 0) {
125
- deliver([], error);
126
- return;
127
- }
128
- cache.set(hostname, { addresses, expires: Date.now() + ttlMs });
129
- deliver(addresses);
130
- },
131
- (resolveError) => deliver([], error ?? resolveError),
132
- );
133
- });
134
- };
135
- }
1
+ /**
2
+ * DNS resolution with a public-resolver fallback.
3
+ *
4
+ * Campus and ISP DNS servers sometimes answer public CDN hostnames with a
5
+ * loopback address (captive-DNS / filtering behaviour). When that happens the
6
+ * MinerU API is reachable but the result CDN is not, and the download step
7
+ * fails with a bare `fetch failed`. This module builds a `lookup` callback for
8
+ * `node:http(s)` that keeps trusting the system resolver unless it returns no
9
+ * usable address, and only then asks ordinary public resolvers over UDP 53 —
10
+ * no DNS-over-HTTPS dependency, no proxy, no hosts-file edit.
11
+ *
12
+ * The callback follows the `net.connect` contract: it answers
13
+ * `(err, address, family)` by default and `(err, [{ address, family }])` when
14
+ * `options.all` is set (undici and Node's autoSelectFamily ask that way).
15
+ * @module dsh-mineru/dns-resolve
16
+ */
17
+ import { lookup as systemLookup } from 'node:dns';
18
+ import { Resolver } from 'node:dns/promises';
19
+
20
+ /** Public resolvers used only when the system resolver yields nothing usable. */
21
+ const DEFAULT_SERVERS = ['223.5.5.5', '119.29.29.29'];
22
+ const DEFAULT_TTL_MS = 10 * 60 * 1000;
23
+ const DEFAULT_TIMEOUT_MS = 5000;
24
+
25
+ /**
26
+ * Whether an address is unusable for reaching a public host.
27
+ * Loopback and unspecified addresses mean a filtered or captive resolver,
28
+ * never a real destination for a remote CDN.
29
+ * @param {unknown} address
30
+ * @returns {boolean}
31
+ */
32
+ export function isLoopbackAddress(address) {
33
+ const value = String(address ?? '').toLowerCase();
34
+ if (value === '::1' || value === '::' || value === '0.0.0.0') return true;
35
+ if (value.startsWith('127.')) return true;
36
+ const mapped = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(value);
37
+ if (mapped) return isLoopbackAddress(mapped[1]);
38
+ return false;
39
+ }
40
+
41
+ /**
42
+ * Resolve a hostname through explicit public resolvers.
43
+ * @param {string[]} servers
44
+ * @param {number} timeoutMs
45
+ * @returns {(hostname: string) => Promise<{address: string, family: number}[]>}
46
+ */
47
+ export function createPublicResolve(servers = DEFAULT_SERVERS, timeoutMs = DEFAULT_TIMEOUT_MS) {
48
+ const resolver = new Resolver({ timeout: timeoutMs, tries: 2 });
49
+ resolver.setServers(servers);
50
+ return async function resolve(hostname) {
51
+ const [v4, v6] = await Promise.all([
52
+ resolver.resolve4(hostname).catch(() => []),
53
+ resolver.resolve6(hostname).catch(() => []),
54
+ ]);
55
+ const addresses = [
56
+ ...v4.map((address) => ({ address, family: 4 })),
57
+ ...v6.map((address) => ({ address, family: 6 })),
58
+ ].filter((entry) => !isLoopbackAddress(entry.address));
59
+ if (addresses.length === 0) {
60
+ throw new Error('public resolvers returned no usable address for ' + hostname);
61
+ }
62
+ return addresses;
63
+ };
64
+ }
65
+
66
+ /**
67
+ * Build a `lookup` callback that falls back to public resolvers.
68
+ *
69
+ * Results are cached per hostname for `ttlMs`, so a download loop resolves
70
+ * once. Every injectable seam exists for tests: `systemLookup` and `resolve`.
71
+ * @param {object} [options]
72
+ * @param {string[]} [options.servers] public resolvers to ask on fallback
73
+ * @param {number} [options.ttlMs] fallback-answer cache lifetime
74
+ * @param {number} [options.timeoutMs] per-query timeout for the public resolvers
75
+ * @param {Function} [options.systemLookup] `node:dns` lookup replacement
76
+ * @param {(hostname: string) => Promise<{address: string, family: number}[]>} [options.resolve]
77
+ * @returns {(hostname: string, options: object|Function, callback?: Function) => void}
78
+ */
79
+ export function createFallbackLookup(options = {}) {
80
+ const ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
81
+ const system = options.systemLookup ?? systemLookup;
82
+ const resolve = options.resolve ?? createPublicResolve(
83
+ options.servers ?? DEFAULT_SERVERS,
84
+ options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
85
+ );
86
+ /** @type {Map<string, {addresses: {address: string, family: number}[], expires: number}>} */
87
+ const cache = new Map();
88
+
89
+ return function lookup(hostname, opts, callback) {
90
+ const query = typeof opts === 'function' ? {} : (opts ?? {});
91
+ const done = typeof opts === 'function' ? opts : callback;
92
+
93
+ /** @param {{address: string, family: number}[]} addresses @param {Error|null} [fallbackError] */
94
+ const deliver = (addresses, fallbackError) => {
95
+ if (addresses.length === 0) {
96
+ done(fallbackError ?? new Error('no usable address for ' + hostname));
97
+ return;
98
+ }
99
+ const wanted = query.family === 6 ? 6 : query.family === 4 ? 4 : 0;
100
+ const matching = wanted ? addresses.filter((entry) => entry.family === wanted) : addresses;
101
+ const list = matching.length > 0 ? matching : addresses;
102
+ if (query.all) {
103
+ done(null, list);
104
+ return;
105
+ }
106
+ done(null, list[0].address, list[0].family);
107
+ };
108
+
109
+ const cached = cache.get(hostname);
110
+ if (cached && cached.expires > Date.now()) {
111
+ deliver(cached.addresses);
112
+ return;
113
+ }
114
+ if (cached) cache.delete(hostname);
115
+
116
+ system(hostname, { ...query, all: true }, (error, list) => {
117
+ const usable = (list ?? []).filter((entry) => !isLoopbackAddress(entry.address));
118
+ if (usable.length > 0) {
119
+ deliver(usable);
120
+ return;
121
+ }
122
+ resolve(hostname).then(
123
+ (addresses) => {
124
+ if (addresses.length === 0) {
125
+ deliver([], error);
126
+ return;
127
+ }
128
+ cache.set(hostname, { addresses, expires: Date.now() + ttlMs });
129
+ deliver(addresses);
130
+ },
131
+ (resolveError) => deliver([], error ?? resolveError),
132
+ );
133
+ });
134
+ };
135
+ }
package/lib/http.js CHANGED
@@ -10,13 +10,15 @@
10
10
  */
11
11
  import { createReadStream, createWriteStream } from 'node:fs';
12
12
  import { randomBytes } from 'node:crypto';
13
- import { mkdir, rm, stat } from 'node:fs/promises';
13
+ import { mkdir, mkdtemp, rm, stat, writeFile } from 'node:fs/promises';
14
+ import { tmpdir } from 'node:os';
14
15
  import { join } from 'node:path';
15
16
  import { SettingsConflictError } from '@deepseek-ai/dsh-settings';
16
17
  import { credentialRef } from '@deepseek-ai/dsh-credentials';
17
18
  import { MineruError } from './mineru-client.js';
18
19
  import { ArtifactError, inlineable, sanitizeFileName } from './artifacts.js';
19
20
  import { DEFAULTS, SUPPORTED_EXTENSIONS, validateConfig } from './config.js';
21
+ import { TOKEN_PROBE_FILE_NAME, tokenProbePdf } from './token-probe.js';
20
22
 
21
23
  const JSON_BODY_LIMIT = 1 << 20;
22
24
 
@@ -251,10 +253,15 @@ async function handle(req, res, deps) {
251
253
  sendJson(res, 404, { ok: false, error: 'unknown route: ' + route });
252
254
  }
253
255
  /**
254
- * Token connection test: submits the official one-page demo PDF through the
255
- * precision API and polls briefly. Success proves the token works; this is an
256
- * explicit user action and consumes at most one page of the 1000-page daily
257
- * priority quota.
256
+ * Token connection test: uploads the embedded one-page probe PDF through the
257
+ * precision API and polls until done. Success proves the token works — and,
258
+ * because the probe travels the real upload path, also the signed-PUT upload
259
+ * and the batch poll. This is an explicit user action and consumes at most one
260
+ * page of the daily quota.
261
+ *
262
+ * The probe is embedded rather than fetched from a vendor demo URL: URL mode
263
+ * made the test fail with `-60017 retry limit reached (5 attempts)` whenever
264
+ * the remote fixture was unavailable, which read as "your token is broken".
258
265
  */
259
266
  async function testToken(deps) {
260
267
  const cfg = deps.config();
@@ -262,13 +269,12 @@ async function testToken(deps) {
262
269
  if (!client.precisionEnabled()) {
263
270
  return { status: 400, body: { ok: false, error: '未配置 MinerU Token: 请先在上方填写并保存 Token.' } };
264
271
  }
265
- const demo = 'https://cdn-mineru.openxlab.org.cn/demo/example.pdf';
266
272
  const opts = {
267
273
  language: cfg.language,
268
274
  enableTable: true,
269
275
  enableFormula: true,
270
276
  isOcr: false,
271
- modelVersion: 'vlm',
277
+ modelVersion: cfg.modelVersion,
272
278
  pageRanges: undefined,
273
279
  pageRange: undefined,
274
280
  extraFormats: [],
@@ -279,19 +285,24 @@ async function testToken(deps) {
279
285
  };
280
286
  const controller = new AbortController();
281
287
  const timer = setTimeout(() => controller.abort(), 185000);
288
+ let probeDir;
282
289
  try {
283
- const outcome = await client.submitAndWaitUrl({
284
- url: demo,
285
- fileName: 'example.pdf',
290
+ probeDir = await mkdtemp(join(tmpdir(), 'dsh-mineru-token-test-'));
291
+ const filePath = join(probeDir, TOKEN_PROBE_FILE_NAME);
292
+ await writeFile(filePath, tokenProbePdf());
293
+ const outcome = await client.submitAndWaitFile({
294
+ filePath,
295
+ fileName: TOKEN_PROBE_FILE_NAME,
286
296
  opts,
287
297
  api: 'precision',
288
298
  signal: controller.signal,
289
299
  });
300
+ const ref = outcome.taskId ? 'taskId=' + outcome.taskId : 'batchId=' + outcome.batchId;
290
301
  return {
291
302
  status: 200,
292
303
  body: {
293
304
  ok: true,
294
- message: 'Token 有效: 示例 PDF 解析成功 (taskId=' + outcome.taskId + '). 本次测试消耗约 1 页精准解析额度.',
305
+ message: 'Token 有效:测试 PDF 上传并解析成功(' + ref + ')。本次测试消耗约 1 页精准解析额度。',
295
306
  },
296
307
  };
297
308
  } catch (err) {
@@ -299,6 +310,7 @@ async function testToken(deps) {
299
310
  return { status: 400, body: { ok: false, error: message } };
300
311
  } finally {
301
312
  clearTimeout(timer);
313
+ if (probeDir !== undefined) await rm(probeDir, { recursive: true, force: true }).catch(() => {});
302
314
  }
303
315
  }
304
316
 
@@ -67,7 +67,7 @@ const ERROR_MESSAGES = Object.freeze({
67
67
  '-60013': 'MinerU 没有权限访问该任务:只能访问自己提交的任务。',
68
68
  '-60014': 'MinerU 任务正在运行中,暂不支持删除。',
69
69
  '-60015': 'MinerU 文件转换失败:可以手动转为 PDF 再上传。',
70
- '-60017': 'MinerU 重试次数达到上限:请等后续模型升级后重试。',
70
+ '-60017': 'MinerU 对这份文件连续重试 5 次仍失败(-60017):请换一份文件或稍后重试;若换文件依旧报错,多为 MinerU 服务端模型临时故障,可把「精准解析模型版本」改成 pipeline 再试。',
71
71
  '-60021': 'MinerU 读取文件页数失败,请稍后重试。',
72
72
  '-60016': 'MinerU 文件转换失败:可以尝试其他导出格式或重试。',
73
73
  '-60018': 'MinerU 每日解析任务数量已达上限,请明日再试。',
@@ -599,13 +599,23 @@ export class MineruClient {
599
599
  if (payload && typeof payload === 'object') {
600
600
  const code = payload.code;
601
601
  const data = payload.data;
602
+ // Keep the vendor's own words: the mapped Chinese line is a summary, and
603
+ // `msg` often carries the actionable half ("please replace the file",
604
+ // "quota exhausted", ...) that the summary drops.
605
+ const vendor = typeof payload.msg === 'string' ? payload.msg.trim() : '';
602
606
  if (code !== undefined && code !== 0 && code !== '0') {
603
607
  const mapped = messageForCode(code) ?? (data?.err_code !== undefined ? messageForCode(data.err_code) : undefined);
604
- return new MineruError(mapped ?? ('MinerU 接口错误:' + (payload.msg || String(code))), 'MINERU_API', { rawCode: String(code), api });
608
+ const base = mapped ?? ('MinerU 接口错误:' + (vendor || String(code)));
609
+ const message = mapped !== undefined && vendor !== '' && !mapped.includes(vendor) ? base + '(MinerU 原文:' + vendor + ')' : base;
610
+ return new MineruError(message, 'MINERU_API', { rawCode: String(code), api });
605
611
  }
606
612
  if (data && typeof data === 'object' && data.err_code !== undefined) {
607
613
  const mapped = messageForCode(data.err_code);
608
- if (mapped) return new MineruError(mapped, 'MINERU_API', { rawCode: String(data.err_code), api });
614
+ const rawErr = typeof data.err_msg === 'string' ? data.err_msg.trim() : '';
615
+ if (mapped) {
616
+ const message = rawErr !== '' && !mapped.includes(rawErr) ? mapped + '(MinerU 原文:' + rawErr + ')' : mapped;
617
+ return new MineruError(message, 'MINERU_API', { rawCode: String(data.err_code), api });
618
+ }
609
619
  }
610
620
  }
611
621
  return new MineruError('MinerU 返回异常:' + String(payload ?? '').slice(0, 400), 'MINERU_API', { api });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Embedded one-page probe PDF for the Settings card "test token" action.
3
+ *
4
+ * Historically the test submitted the vendor demo URL
5
+ * (`cdn-mineru.openxlab.org.cn/demo/example.pdf`) through URL mode. That
6
+ * fixture now answers `-60017 retry limit reached (5 attempts), please replace
7
+ * the file`, so a perfectly healthy token reported a failed test, and the test
8
+ * depended on a third-party file staying online.
9
+ *
10
+ * Shipping the bytes keeps the probe hermetic: write it to a temp file, upload
11
+ * it through the precision API, poll to `done`. That exercises token validity,
12
+ * the signed-PUT upload, the batch poll and the zip download in one call, and
13
+ * costs one page of quota instead of depending on any remote fixture.
14
+ *
15
+ * @module dsh-mineru/token-probe
16
+ */
17
+
18
+ /** Base64 of a single-page PDF with four lines of Helvetica text. */
19
+ const PROBE_PDF_BASE64 = [
20
+ 'JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj',
21
+ '4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEg',
22
+ 'Pj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3',
23
+ 'ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA0IDAgUiA+PiA+PiAv',
24
+ 'Q29udGVudHMgNSAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cG',
25
+ 'UgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhID4+CmVuZG9iago1IDAgb2JqCjw8IC9MZW5n',
26
+ 'dGggMjc5ID4+CnN0cmVhbQpCVAovRjEgMTggVGYKNzIgNzIwIFRkCihkc2gtbWluZXJ1IHRva2',
27
+ 'VuIHRlc3QpIFRqCjAgLTI4IFRkCi9GMSAxMSBUZgooVGhpcyBvbmUtcGFnZSBQREYgaXMgZ2Vu',
28
+ 'ZXJhdGVkIGJ5IHRoZSBwbHVnaW4gYW5kIHBhcnNlZCB0aHJvdWdoIHRoZSkgVGoKMCAtMTYgVG',
29
+ 'QKKE1pbmVyVSBwcmVjaXNpb24gQVBJLiBBIHN1Y2Nlc3NmdWwgcGFyc2UgcHJvdmVzIHRoZSB0',
30
+ 'b2tlbiwgdGhlIHVwbG9hZCkgVGoKMCAtMTYgVGQKKHBhdGggYW5kIHRoZSBwb2xsaW5nIGxvb3',
31
+ 'AgYWxsIHdvcmsuKSBUagpFVAplbmRzdHJlYW0KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAg',
32
+ 'NjU1MzUgZiAKMDAwMDAwMDAxNSAwMDAwMCBuIAowMDAwMDAwMDY0IDAwMDAwIG4gCjAwMDAwMD',
33
+ 'AxMjEgMDAwMDAgbiAKMDAwMDAwMDI0NyAwMDAwMCBuIAowMDAwMDAwMzE3IDAwMDAwIG4gCnRy',
34
+ 'YWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNjQ2CiUlRU9GCg==',
35
+ ].join('');
36
+
37
+ /** File name used for the uploaded probe; also the artifact stem MinerU reports. */
38
+ export const TOKEN_PROBE_FILE_NAME = 'dsh-mineru-token-test.pdf';
39
+
40
+ /**
41
+ * A fresh copy of the probe bytes. A Buffer (not a string) so the upload path
42
+ * can stream it unchanged and callers cannot mutate the shared constant.
43
+ * @returns {Buffer}
44
+ */
45
+ export function tokenProbePdf() {
46
+ return Buffer.from(PROBE_PDF_BASE64, 'base64');
47
+ }
package/package.json CHANGED
@@ -1,101 +1,101 @@
1
- {
2
- "name": "dsh-mineru",
3
- "version": "0.1.17",
4
- "description": "dsh-mineru: MinerU 文档解析插件 for DeepSeek Harness — 多模态全格式 (PDF/Word/PPT/Excel/HTML/图片) → 结构化 Markdown. 填 Token 走精准解析 API, 留空走 Agent 轻量解析 API. 注意: 解析需把文件上传至 MinerU 远端(内容出网), 无完全离线模式, 涉密/不得出网材料请勿使用.",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "types": "lib/types/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./lib/types/index.d.ts",
11
- "default": "./lib/index.js"
12
- },
13
- "./client": {
14
- "types": "./lib/types/client.d.ts",
15
- "default": "./lib/client.js"
16
- },
17
- "./package.json": "./package.json"
18
- },
19
- "files": [
20
- "lib/",
21
- "cordis.patch.yml",
22
- "README.md",
23
- "README.zh.md",
24
- "CHANGELOG.md",
25
- "RELEASE.md",
26
- "CONTRIBUTING.md",
27
- "LICENSE"
28
- ],
29
- "dsh": {
30
- "bundle": {
31
- "patch": "./cordis.patch.yml"
32
- },
33
- "client": {
34
- "inject": [
35
- "slots",
36
- "connection",
37
- "sessions",
38
- "conversation",
39
- "locale"
40
- ],
41
- "platform": "web"
42
- }
43
- },
44
- "scripts": {
45
- "test": "vitest run",
46
- "test:compat": "vitest run tests/dsh-compat.spec.js"
47
- },
48
- "dependencies": {
49
- "@deepseek-ai/schemastery": "^3.18.0"
50
- },
51
- "devDependencies": {
52
- "@deepseek-ai/cordis": "4.0.5",
53
- "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
54
- "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
55
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
56
- "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
57
- "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
58
- "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
59
- "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
60
- "@deepseek-ai/dsh-skill": "0.2.0-rc.2",
61
- "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
62
- "vitest": "^4.1.11"
63
- },
64
- "engines": {
65
- "node": ">=18.0.0"
66
- },
67
- "peerDependencies": {
68
- "@deepseek-ai/cordis": "^4.0.1",
69
- "@deepseek-ai/schemastery": "^3.18.0",
70
- "@deepseek-ai/dsh-tools": "^0.1.5-rc.1 || ^0.2.0-rc.1",
71
- "@deepseek-ai/dsh-settings": "^0.1.5-rc.1 || ^0.2.0-rc.1",
72
- "@deepseek-ai/dsh-credentials": "^0.1.5-rc.1 || ^0.2.0-rc.1",
73
- "@deepseek-ai/dsh-skill": "^0.1.5-rc.1 || ^0.2.0-rc.1",
74
- "@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.1 || ^0.2.0-rc.1",
75
- "@deepseek-ai/dsh-llm": "^0.1.5-rc.1 || ^0.2.0-rc.1"
76
- },
77
- "license": "MIT",
78
- "keywords": [
79
- "deepseek-harness",
80
- "dsh",
81
- "dsh-plugin",
82
- "mineru",
83
- "document-parsing",
84
- "pdf",
85
- "ocr",
86
- "markdown",
87
- "multimodal"
88
- ],
89
- "repository": {
90
- "type": "git",
91
- "url": "git+https://github.com/Lee-Hilex/dsh-mineru.git"
92
- },
93
- "homepage": "https://github.com/Lee-Hilex/dsh-mineru#readme",
94
- "bugs": {
95
- "url": "https://github.com/Lee-Hilex/dsh-mineru/issues"
96
- },
97
- "author": {
98
- "name": "Lee-Hilex",
99
- "email": "niuniu910417@163.com"
100
- }
101
- }
1
+ {
2
+ "name": "dsh-mineru",
3
+ "version": "0.1.19",
4
+ "description": "dsh-mineru: MinerU 文档解析插件 for DeepSeek Harness — 多模态全格式 (PDF/Word/PPT/Excel/HTML/图片) → 结构化 Markdown. 填 Token 走精准解析 API, 留空走 Agent 轻量解析 API. 注意: 解析需把文件上传至 MinerU 远端(内容出网), 无完全离线模式, 涉密/不得出网材料请勿使用.",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./lib/types/client.d.ts",
15
+ "default": "./lib/client.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "lib/",
21
+ "cordis.patch.yml",
22
+ "README.md",
23
+ "README.zh.md",
24
+ "CHANGELOG.md",
25
+ "RELEASE.md",
26
+ "CONTRIBUTING.md",
27
+ "LICENSE"
28
+ ],
29
+ "dsh": {
30
+ "bundle": {
31
+ "patch": "./cordis.patch.yml"
32
+ },
33
+ "client": {
34
+ "inject": [
35
+ "slots",
36
+ "connection",
37
+ "sessions",
38
+ "conversation",
39
+ "locale"
40
+ ],
41
+ "platform": "web"
42
+ }
43
+ },
44
+ "scripts": {
45
+ "test": "vitest run",
46
+ "test:compat": "vitest run tests/dsh-compat.spec.js"
47
+ },
48
+ "dependencies": {
49
+ "@deepseek-ai/schemastery": "^3.18.0"
50
+ },
51
+ "devDependencies": {
52
+ "@deepseek-ai/cordis": "4.0.5",
53
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
54
+ "@deepseek-ai/dsh-app-boot": "0.2.0-rc.2",
55
+ "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
56
+ "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
57
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
58
+ "@deepseek-ai/dsh-scope": "0.2.0-rc.2",
59
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
60
+ "@deepseek-ai/dsh-skill": "0.2.0-rc.2",
61
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
62
+ "vitest": "^4.1.11"
63
+ },
64
+ "engines": {
65
+ "node": ">=18.0.0"
66
+ },
67
+ "peerDependencies": {
68
+ "@deepseek-ai/cordis": "^4.0.1",
69
+ "@deepseek-ai/schemastery": "^3.18.0",
70
+ "@deepseek-ai/dsh-tools": "^0.1.5-rc.1 || ^0.2.0-rc.1",
71
+ "@deepseek-ai/dsh-settings": "^0.1.5-rc.1 || ^0.2.0-rc.1",
72
+ "@deepseek-ai/dsh-credentials": "^0.1.5-rc.1 || ^0.2.0-rc.1",
73
+ "@deepseek-ai/dsh-skill": "^0.1.5-rc.1 || ^0.2.0-rc.1",
74
+ "@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.1 || ^0.2.0-rc.1",
75
+ "@deepseek-ai/dsh-llm": "^0.1.5-rc.1 || ^0.2.0-rc.1"
76
+ },
77
+ "license": "MIT",
78
+ "keywords": [
79
+ "deepseek-harness",
80
+ "dsh",
81
+ "dsh-plugin",
82
+ "mineru",
83
+ "document-parsing",
84
+ "pdf",
85
+ "ocr",
86
+ "markdown",
87
+ "multimodal"
88
+ ],
89
+ "repository": {
90
+ "type": "git",
91
+ "url": "git+https://github.com/Lee-Hilex/dsh-mineru.git"
92
+ },
93
+ "homepage": "https://github.com/Lee-Hilex/dsh-mineru#readme",
94
+ "bugs": {
95
+ "url": "https://github.com/Lee-Hilex/dsh-mineru/issues"
96
+ },
97
+ "author": {
98
+ "name": "Lee-Hilex",
99
+ "email": "niuniu910417@163.com"
100
+ }
101
+ }