dsh-mineru 0.1.18 → 0.1.20
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 +13 -0
- package/README.md +6 -6
- package/README.zh.md +6 -6
- package/lib/client.js +16 -2
- package/lib/dns-resolve.js +135 -135
- package/package.json +30 -18
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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.20] - 2026-11-29
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- The six `@deepseek-ai/dsh-*` peer ranges silently rejected every 0.2 prerelease after `0.2.0-rc.x` (`0.2.1-rc.*`, `0.2.2-rc.*`, `0.2.3-alpha.*`) even though the plugin runs on them unchanged. node-semver only admits a prerelease when the range contains a comparator with the exact same `[major, minor, patch]` tuple, so the single `^0.2.0-rc.1` term could never reach later tuples. The peers now enumerate each shipped tuple (`^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0`), covering every published 0.2 prerelease and the whole 0.2 stable line while keeping 0.3 excluded.
|
|
10
|
+
|
|
11
|
+
## [0.1.19] - 2026-11-29
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- 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.
|
|
16
|
+
- 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.
|
|
17
|
+
|
|
5
18
|
## [0.1.18] - 2026-11-11
|
|
6
19
|
|
|
7
20
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# dsh-mineru
|
|
2
2
|
|
|
3
3
|
[](LICENSE)
|
|
4
|
-
[](https://github.com/Lee-Hilex/dsh-mineru/releases)
|
|
5
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
6
6
|
[](https://mineru.net/apiManage/docs)
|
|
7
7
|
|
|
8
8
|
> Repository: <https://github.com/Lee-Hilex/dsh-mineru> · npm: [`dsh-mineru`](https://www.npmjs.com/package/dsh-mineru) · [Changelog](CHANGELOG.md)
|
|
@@ -45,7 +45,7 @@ Typical use cases:
|
|
|
45
45
|
|
|
46
46
|
### Highlights
|
|
47
47
|
|
|
48
|
-
- **DSH 0.2.
|
|
48
|
+
- **DSH 0.2.2-rc.5 compatibility** — tested with the real Loader, settings service and tool runtime; the peer ranges cover every 0.2 prerelease from `0.2.0-rc.x` through `0.2.3-alpha.x` and the whole 0.2 stable line, while the `0.1.5-rc.x` range and legacy settings path are retained;
|
|
49
49
|
- **Dual API modes, auto-selected** — chooses Precision or Agent parsing based on whether a token is configured; can be overridden per call;
|
|
50
50
|
- **Progressive tool exposure** — only the tiny `mineru_activate` bootstrap is visible until the agent activates the full toolset, saving context;
|
|
51
51
|
- **Drag-and-drop uploads** — drop a file into the chat; its path lands in the composer draft so text-only models can process documents;
|
|
@@ -57,7 +57,7 @@ Typical use cases:
|
|
|
57
57
|
|
|
58
58
|
### Step 1: Install
|
|
59
59
|
|
|
60
|
-
> **Note**: Requires DeepSeek Harness `0.2.0-rc.1` or newer on the `0.2.0`
|
|
60
|
+
> **Note**: Requires DeepSeek Harness `0.2.0-rc.1` or newer on the `0.2` line (prereleases through `0.2.3-alpha.x` and every `0.2.x` stable release are covered), or a compatible `0.1.5-rc.x` installation, with the `dsh` CLI available. Use plugin `0.1.20` for hosts beyond `0.2.0-rc.2`: older plugin builds only declare the `0.2.0` prerelease tuple, so `0.2.1-rc` and later need `0.1.20` or later to pass the runtime gate. If npm still serves an older build, install a source-built tarball below.
|
|
61
61
|
|
|
62
62
|
**From npm (recommended)**
|
|
63
63
|
|
|
@@ -72,14 +72,14 @@ dsh plugin --profile headless add dsh-mineru # Headless profile
|
|
|
72
72
|
git clone git@github.com:Lee-Hilex/dsh-mineru.git
|
|
73
73
|
cd dsh-mineru
|
|
74
74
|
npm ci # development: Node.js 24 recommended; no build step
|
|
75
|
-
npm test # includes real DSH 0.2.
|
|
75
|
+
npm test # includes real DSH 0.2.2-rc.5 integration tests
|
|
76
76
|
npm pack # produces dsh-mineru-<version>.tgz
|
|
77
77
|
dsh plugin --profile web add ./dsh-mineru-<version>.tgz
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
Run `npm pack` again and re-install after changing the source. Local installs must use the tarball (`pnpm link:` installs resolve `@deepseek-ai` peers outside the profile).
|
|
81
81
|
|
|
82
|
-
For the desktop profile, use `dsh plugin --profile desktop add ./dsh-mineru-0.1.
|
|
82
|
+
For the desktop profile, use `dsh plugin --profile desktop add ./dsh-mineru-0.1.20.tgz`. Compatible package metadata passes the runtime gate without an `allow-version` exemption. `npm run test:compat` runs only the real-runtime compatibility checks; MinerU responses are simulated, so the tests upload no documents and consume no API quota.
|
|
83
83
|
|
|
84
84
|
### Step 2: Verify the install
|
|
85
85
|
|
package/README.zh.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# dsh-mineru
|
|
2
2
|
|
|
3
3
|
[](LICENSE)
|
|
4
|
-
[](https://github.com/Lee-Hilex/dsh-mineru/releases)
|
|
5
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
6
6
|
[](https://mineru.net/apiManage/docs)
|
|
7
7
|
|
|
8
8
|
> 仓库: <https://github.com/Lee-Hilex/dsh-mineru> · npm: [`dsh-mineru`](https://www.npmjs.com/package/dsh-mineru) · [更新日志](CHANGELOG.md)
|
|
@@ -45,7 +45,7 @@ dsh-mineru 把 [MinerU](https://mineru.net)(OpenDataLab 出品的高精度文
|
|
|
45
45
|
|
|
46
46
|
### 核心能力
|
|
47
47
|
|
|
48
|
-
- **适配 DSH 0.2.
|
|
48
|
+
- **适配 DSH 0.2.2-rc.5** — 使用真实 Loader、设置服务和工具运行时验证,peer 范围覆盖 `0.2.0-rc.x` 至 `0.2.3-alpha.x` 全部预发布及整个 0.2 稳定线,同时保留 `0.1.5-rc.x` 范围与旧设置接口;
|
|
49
49
|
- **双 API 自动切换** — 按是否配置 Token 自动选择精准解析或轻量解析,也可手动指定;
|
|
50
50
|
- **渐进式工具曝光** — 平时只挂一个极小的 `mineru_activate` 引导工具,激活后才挂载完整工具集,省上下文;
|
|
51
51
|
- **拖拽上传** — 文件直接拖进聊天窗口,路径自动填入输入框,纯文本模型也能处理文档;
|
|
@@ -57,7 +57,7 @@ dsh-mineru 把 [MinerU](https://mineru.net)(OpenDataLab 出品的高精度文
|
|
|
57
57
|
|
|
58
58
|
### 第 1 步:安装
|
|
59
59
|
|
|
60
|
-
> **Note**: 需要已安装 DeepSeek Harness `0.2.0-rc.1` 或更新(`0.2.0`
|
|
60
|
+
> **Note**: 需要已安装 DeepSeek Harness `0.2.0-rc.1` 或更新(`0.2` 线,已覆盖至 `0.2.3-alpha.x` 及全部 `0.2.x` 稳定版),或兼容的 `0.1.5-rc.x`,且 `dsh` 命令可用。`0.2.0-rc.2` 之后的宿主请使用插件 `0.1.20` 或更高版本:旧版插件只声明了 `0.2.0` 这一个预发布元组,`0.2.1-rc` 起需 `0.1.20+` 才能通过宿主版本检查。若 npm 仍提供旧版本,请按下文从源码打包安装。
|
|
61
61
|
|
|
62
62
|
**从 npm 安装(推荐)**
|
|
63
63
|
|
|
@@ -72,14 +72,14 @@ dsh plugin --profile headless add dsh-mineru # 无头(Headless)模式使
|
|
|
72
72
|
git clone git@github.com:Lee-Hilex/dsh-mineru.git
|
|
73
73
|
cd dsh-mineru
|
|
74
74
|
npm ci # 开发测试推荐 Node.js 24;本包无需 build
|
|
75
|
-
npm test # 包含真实 DSH 0.2.
|
|
75
|
+
npm test # 包含真实 DSH 0.2.2-rc.5 集成测试
|
|
76
76
|
npm pack # 产出 dsh-mineru-<version>.tgz
|
|
77
77
|
dsh plugin --profile web add ./dsh-mineru-<version>.tgz
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
修改源码后重新 `npm pack` 并重装即可。注意本地安装请用 tgz(`pnpm link:` 安装会使 `@deepseek-ai` 依赖解析脱离 profile)。
|
|
81
81
|
|
|
82
|
-
桌面端 profile 使用 `dsh plugin --profile desktop add ./dsh-mineru-0.1.
|
|
82
|
+
桌面端 profile 使用 `dsh plugin --profile desktop add ./dsh-mineru-0.1.20.tgz`。兼容声明可直接通过宿主版本检查,无需 `allow-version` 豁免。`npm run test:compat` 仅运行真实宿主兼容测试;MinerU 响应采用模拟服务,测试不会上传文档或消耗 API 额度。
|
|
83
83
|
|
|
84
84
|
### 第 2 步:验证安装
|
|
85
85
|
|
package/lib/client.js
CHANGED
|
@@ -653,10 +653,24 @@ window.__ModuleLoader__.load({
|
|
|
653
653
|
}
|
|
654
654
|
|
|
655
655
|
function installFileDropBridge(ctx) {
|
|
656
|
-
|
|
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) {
|
|
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
|
package/lib/dns-resolve.js
CHANGED
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mineru",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "dsh-mineru: MinerU 文档解析插件 for DeepSeek Harness — 多模态全格式 (PDF/Word/PPT/Excel/HTML/图片) → 结构化 Markdown. 填 Token 走精准解析 API, 留空走 Agent 轻量解析 API. 注意: 解析需把文件上传至 MinerU 远端(内容出网), 无完全离线模式, 涉密/不得出网材料请勿使用.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -49,16 +49,28 @@
|
|
|
49
49
|
"@deepseek-ai/schemastery": "^3.18.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@deepseek-ai/cordis": "4.0
|
|
53
|
-
"@deepseek-ai/
|
|
54
|
-
"@deepseek-ai/
|
|
55
|
-
"@deepseek-ai/
|
|
56
|
-
"@deepseek-ai/
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
"@deepseek-ai/dsh-
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
52
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
53
|
+
"@deepseek-ai/cordis-plugin-group": "~1.1.0",
|
|
54
|
+
"@deepseek-ai/cordis-plugin-include": "~1.1.0",
|
|
55
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.1.0",
|
|
56
|
+
"@deepseek-ai/cordis-plugin-timer": "~1.2.0",
|
|
57
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.5",
|
|
58
|
+
"@deepseek-ai/dsh-app-boot": "0.2.2-rc.5",
|
|
59
|
+
"@deepseek-ai/dsh-credentials": "0.2.2-rc.5",
|
|
60
|
+
"@deepseek-ai/dsh-error": "0.2.2-rc.5",
|
|
61
|
+
"@deepseek-ai/dsh-home-paths": "0.2.2-rc.5",
|
|
62
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.5",
|
|
63
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.2-rc.5",
|
|
64
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.5",
|
|
65
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.5",
|
|
66
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.5",
|
|
67
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.5",
|
|
68
|
+
"@deepseek-ai/dsh-settings": "0.2.2-rc.5",
|
|
69
|
+
"@deepseek-ai/dsh-skill": "0.2.2-rc.5",
|
|
70
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.5",
|
|
71
|
+
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.5",
|
|
72
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.5",
|
|
73
|
+
"@deepseek-ai/dsh-workspace": "0.2.2-rc.5",
|
|
62
74
|
"vitest": "^4.1.11"
|
|
63
75
|
},
|
|
64
76
|
"engines": {
|
|
@@ -66,13 +78,13 @@
|
|
|
66
78
|
},
|
|
67
79
|
"peerDependencies": {
|
|
68
80
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
69
|
-
"@deepseek-ai/
|
|
70
|
-
"@deepseek-ai/dsh-
|
|
71
|
-
"@deepseek-ai/dsh-
|
|
72
|
-
"@deepseek-ai/dsh-
|
|
73
|
-
"@deepseek-ai/dsh-skill": "^0.1.5-rc.1 || ^0.2.0-rc.1",
|
|
74
|
-
"@deepseek-ai/dsh-
|
|
75
|
-
"@deepseek-ai/
|
|
81
|
+
"@deepseek-ai/dsh-credentials": "^0.1.5-rc.1 || ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0",
|
|
82
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.1 || ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0",
|
|
83
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-rc.1 || ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0",
|
|
84
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-rc.1 || ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0",
|
|
85
|
+
"@deepseek-ai/dsh-skill": "^0.1.5-rc.1 || ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0",
|
|
86
|
+
"@deepseek-ai/dsh-tools": "^0.1.5-rc.1 || ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-rc.1 || ^0.2.3-alpha.0",
|
|
87
|
+
"@deepseek-ai/schemastery": "^3.18.0"
|
|
76
88
|
},
|
|
77
89
|
"license": "MIT",
|
|
78
90
|
"keywords": [
|