dsh-mineru 0.1.18 → 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,6 +2,13 @@
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.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
+
5
12
  ## [0.1.18] - 2026-11-11
6
13
 
7
14
  ### 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.18-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.18-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mineru",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
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",