dsh-union-search 0.12.0 → 0.13.0-rc.2
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/README.md +6 -0
- package/lib/client.js +57 -0
- package/lib/index.js +97 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -276,6 +276,8 @@ provider: bing # ddg / ddg-lite / bing / searxng / anysearch / exa
|
|
|
276
276
|
blockSystemSearch: false # true = 屏蔽系统自带搜索:强制接管并把 deepseek-official/search-api 移出引擎链
|
|
277
277
|
advanceFetchEnabled: true # false = 拒绝 advance_fetch 调用(热生效)
|
|
278
278
|
fetchTakeover: false # true = 注册并钉选 web.fetchProvider = union-search,接管宿主 web_fetch 出口(需宿主 ≥0.2.1-rc.2)
|
|
279
|
+
browserFetchTier: false # true = 登录墙/反爬/JS 空壳页命中时借 dsh-browser-cdp(≥1.15.0)的已登录浏览器重抓(带 cookie,默认关)
|
|
280
|
+
browserFetchAllowHosts: "" # 升级档域名白名单(逗号分隔后缀,含子域);空 = 不限制(仍受总开关)
|
|
279
281
|
advanceFetchAllowPrivate: false # true = 放行 advance_fetch 访问回环/内网(局域网设备场景;协议/重定向门不变)
|
|
280
282
|
advanceFetchUserAgent: "" # 空 = 内置默认 UA;可自定义用于按 UA 拦截的站
|
|
281
283
|
advanceFetchReferer: "" # 空 = 不发 Referer;可配防盗链图床/接口解锁
|
|
@@ -350,6 +352,7 @@ deepseekApiKey: ...
|
|
|
350
352
|
- 支持超时和大小限制
|
|
351
353
|
- **0.2.1-rc.2+ 宿主新增内置 `deepseek-fetch-api` 选项(Fetch $0.75/千次,2026-11-01 起按次计费)**:`blockSystemSearch` 开启时会把 `web.fetchProvider` 钳制回免费的 `http`(保留抓取、不产生抓取账单;显式指定的第三方 fetch provider 不动)
|
|
352
354
|
- **fetch provider 接管(0.12.0,需宿主 ≥0.2.1-rc.2)**:设置面开启 `fetchTakeover` 后,本插件注册并钉选 `web.fetchProvider: union-search`,`web_fetch` 改走本插件抓取栈——ALPN 直连 + 宿主同款 Markdown 优化器,正文在插件侧完成转换(kind:text),不再受宿主「先截断后转换」影响(大页只剩标题的 #161 形态);SSRF 地址门/charset 解码/重定向限次同样生效。关闭后自动回落免费 `http`;卸载/停用后的残留钉选可用 `node node_modules/dsh-union-search/bin/restore.js --apply` 清理
|
|
355
|
+
- **浏览器升级档(0.13.0,需同会话安装 dsh-browser-cdp ≥1.15.0)**:`fetchTakeover` 开启后,若直连结果命中登录墙(HTTP 401/403)/反爬挑战/JS 空壳页特征,经 cordis 服务总线调用 browser-cdp 的 `browser-fetch` 服务在**已登录的 agent 浏览器**里开后台 tab 重抓渲染后 DOM,再进同一套优化器出成品 markdown,结果尾部标注「fetched via user browser (session cookies included)」。⚠️ 总开关 `browserFetchTier` 默认关:带 cookie 访问由搜索结果(不可信文本)驱动的 URL 是身份泄漏面,建议配合 `browserFetchAllowHosts` 只钉登录墙域名;browser-cdp 不在位或服务报错时静默降级回直连形态
|
|
353
356
|
- ⚠️ 注意:`web_fetch` 无 SSRF 防护,agent 理论上可访问内网地址——按需使用
|
|
354
357
|
|
|
355
358
|
#### 平台搜索(platform_search)
|
|
@@ -678,6 +681,8 @@ provider: bing # ddg / ddg-lite / bing / searxng / anysearch / exa
|
|
|
678
681
|
blockSystemSearch: false # true = block the built-in official search: force takeover + exclude deepseek-official/search-api from every chain
|
|
679
682
|
advanceFetchEnabled: true # false = advance_fetch calls are rejected (hot)
|
|
680
683
|
fetchTakeover: false # true = register & pin web.fetchProvider = union-search (host >= 0.2.1-rc.2)
|
|
684
|
+
browserFetchTier: false # true = re-fetch login-walled / anti-bot / JS-shell pages through dsh-browser-cdp's logged-in browser (>= 1.15.0); off by default
|
|
685
|
+
browserFetchAllowHosts: "" # browser-tier domain allowlist (comma-separated suffixes, subdomains included); empty = unrestricted (master switch still gates it)
|
|
681
686
|
advanceFetchAllowPrivate: false # true = allow advance_fetch to reach loopback/private targets (LAN devices; protocol/redirect gates unchanged)
|
|
682
687
|
advanceFetchUserAgent: "" # empty = built-in UA; customize for sites that block by User-Agent
|
|
683
688
|
advanceFetchReferer: "" # empty = no Referer; useful for hotlink-protected image hosts/APIs
|
|
@@ -752,6 +757,7 @@ After searching, the agent can **read full webpage content** (e.g., *"Open the f
|
|
|
752
757
|
- Supports timeout and response size limits.
|
|
753
758
|
- **0.2.1-rc.2+ ships a built-in `deepseek-fetch-api` option (Fetch $0.75 per 1,000 requests, metered from 2026-11-01)**: with `blockSystemSearch` on it clamps `web.fetchProvider` back to the free `http` provider (fetch kept, no fetch billings); a third-party fetch provider you picked explicitly is left alone.
|
|
754
759
|
- **Fetch-provider takeover (0.12.0, host >= 0.2.1-rc.2)**: turning on `fetchTakeover` registers and pins `web.fetchProvider: union-search`, routing `web_fetch` through this plugin's retrieval stack — ALPN direct fetch plus the host-twin Markdown optimizer, conversion finished plugin-side (kind:text) so the host's truncate-before-convert pipeline (the "big page collapses to just a title" shape, upstream #161) can no longer mangle it; the SSRF address gate, charset decoding and redirect caps apply as well. Turning it off falls back to the free `http` provider; a leftover pin after uninstall/disable is cleaned by `node node_modules/dsh-union-search/bin/restore.js --apply`.
|
|
760
|
+
- **Browser upgrade tier (0.13.0, needs dsh-browser-cdp >= 1.15.0 in the same session)**: when `fetchTakeover` is on and a direct fetch hits a login wall (HTTP 401/403), an anti-bot challenge or a JS-rendered shell, the plugin calls browser-cdp's `browser-fetch` service over the cordis bus and re-fetches the rendered DOM from a background tab of the **logged-in agent browser**, then runs it through the same optimizer; results carry a "fetched via user browser (session cookies included)" note. ⚠️ `browserFetchTier` is off by default — fetching injection-driven URLs with your cookies is an identity-leak surface, so pair it with `browserFetchAllowHosts` (pin only the login-walled domains). Missing service or any browser-side error silently falls back to the direct-fetch shape.
|
|
755
761
|
- ⚠️ Note: `web_fetch` does not have SSRF protection; the agent could theoretically access internal network addresses. Use as needed.
|
|
756
762
|
|
|
757
763
|
#### Platform Search (`platform_search`)
|
package/lib/client.js
CHANGED
|
@@ -201,6 +201,10 @@ window.__ModuleLoader__.load({
|
|
|
201
201
|
blockSystemSearchHint: "开启后强制接管 web_search,并把出厂的 deepseek-official 引擎从所有引擎链(首选/回退/Auto/multi/引擎测试)中剔除;保存即生效,无需重启。",
|
|
202
202
|
fetchTakeover: "接管 web_fetch(fetch provider)",
|
|
203
203
|
fetchTakeoverHint: "开启后本插件注册并钉选宿主 web_fetch 的 fetch provider(union-search):抓取走本插件通道(ALPN 直连 + 宿主同款 Markdown 优化器,正文在插件侧完成转换,不受宿主截断影响)。关闭后自动回落免费 http 档;你显式指定的第三方 fetch provider 不会被覆盖。需宿主 ≥0.2.1-rc.2(旧宿主无此缝)。",
|
|
204
|
+
browserFetchTier: "浏览器升级档(需 dsh-browser-cdp ≥1.15.0)",
|
|
205
|
+
browserFetchTierHint: "⚠️ 以你的登录身份访问网页:仅在 web_fetch 命中登录墙/反爬/JS 空壳页时,改借已登录浏览器重抓(携带 cookie)。默认关;只在确实需要读取登录后内容时开启,建议配合域名白名单使用。结果会标注「经用户浏览器抓取」。",
|
|
206
|
+
browserFetchAllowHosts: "升级档域名白名单",
|
|
207
|
+
browserFetchAllowHostsHint: "逗号分隔域名后缀(含子域),如 linkedin.com,weibo.com;空 = 不限制(仍受上方总开关控制)。建议只钉登录墙域名,避免任意 URL 都被带 cookie 访问。",
|
|
204
208
|
advanceFetchEnabled: "advance_fetch 工具",
|
|
205
209
|
advanceFetchEnabledHint: "【实验性 · 免费】零 key、零按次计费(区别于按次计费的付费搜索 API)。整页 GitHub-Flavored Markdown(宿主同款转换配置)+ CSS selector/fields 定向结构化抽取。关闭后调用被拒绝(热生效),系统提示词也不再宣传该工具。",
|
|
206
210
|
advanceFetchAllowPrivate: "允许 advance_fetch 访问内网",
|
|
@@ -333,6 +337,10 @@ window.__ModuleLoader__.load({
|
|
|
333
337
|
blockSystemSearchHint: "When on, web_search is force-taken-over by this plugin and the shipped deepseek-official engine is excluded from every engine chain (preferred / fallback / auto / multi / engine tests). Takes effect on save; no restart needed.",
|
|
334
338
|
fetchTakeover: "Take over web_fetch (fetch provider)",
|
|
335
339
|
fetchTakeoverHint: "When on, this plugin registers and pins the host's web_fetch fetch provider (union-search): retrieval runs through this plugin's stack (ALPN direct fetch + host-twin Markdown optimizer, conversion finishes plugin-side so host output caps cannot mangle it). Turning it off falls back to the free http provider; a third-party fetch provider you picked explicitly is never overridden. Requires host >= 0.2.1-rc.2 (older hosts have no fetch seam).",
|
|
340
|
+
browserFetchTier: "Browser upgrade tier (needs dsh-browser-cdp >= 1.15.0)",
|
|
341
|
+
browserFetchTierHint: "⚠️ Visits pages AS YOU (session cookies). When a web_fetch hits a login wall / anti-bot page / JS shell, the page is re-fetched through the logged-in agent browser instead. Off by default; enable only when you truly need post-login content, ideally with the host allowlist below. Upgraded results are labelled “fetched via user browser”.",
|
|
342
|
+
browserFetchAllowHosts: "Browser-tier host allowlist",
|
|
343
|
+
browserFetchAllowHostsHint: "Comma-separated domain suffixes (subdomains included), e.g. linkedin.com,weibo.com; empty = unrestricted (still gated by the master switch above). Recommended: pin only the login-walled domains so arbitrary URLs never get fetched with your cookies.",
|
|
336
344
|
advanceFetchEnabled: "advance_fetch tool",
|
|
337
345
|
advanceFetchEnabledHint: "[Experimental · free] No API key and no per-request billing (unlike the metered paid search APIs). Whole-page GitHub-Flavored Markdown (host-twin conversion profile) + CSS selector/fields structured extraction. When off, calls are rejected (hot) and the system prompt stops advertising the tool.",
|
|
338
346
|
advanceFetchAllowPrivate: "Allow advance_fetch to reach private networks",
|
|
@@ -925,6 +933,8 @@ window.__ModuleLoader__.load({
|
|
|
925
933
|
// 屏蔽系统自带搜索(blockSystemSearch):强制接管 + 剔除出厂 deepseek-official
|
|
926
934
|
const [blockSystemSearch, setBlockSystemSearch] = react.useState(false);
|
|
927
935
|
const [fetchTakeover, setFetchTakeover] = react.useState(false);
|
|
936
|
+
const [browserFetchTier, setBrowserFetchTier] = react.useState(false);
|
|
937
|
+
const [browserFetchAllowHosts, setBrowserFetchAllowHosts] = react.useState("");
|
|
928
938
|
// 0.10.3:自有 advance_fetch 开关 / SearXNG 语言锁定档
|
|
929
939
|
const [advanceFetchEnabled, setAdvanceFetchEnabled] = react.useState(true);
|
|
930
940
|
const [advanceFetchAllowPrivate, setAdvanceFetchAllowPrivate] = react.useState(false);
|
|
@@ -1008,6 +1018,8 @@ window.__ModuleLoader__.load({
|
|
|
1008
1018
|
setCacheTtl(v.cacheTtl === undefined ? 5 : Math.min(Math.max(Number(v.cacheTtl) ?? 5, 0), 5));
|
|
1009
1019
|
setBlockSystemSearch(v.blockSystemSearch === true);
|
|
1010
1020
|
setFetchTakeover(v.fetchTakeover === true);
|
|
1021
|
+
setBrowserFetchTier(v.browserFetchTier === true);
|
|
1022
|
+
setBrowserFetchAllowHosts(typeof v.browserFetchAllowHosts === "string" ? v.browserFetchAllowHosts : "");
|
|
1011
1023
|
setAdvanceFetchEnabled(v.advanceFetchEnabled !== false);
|
|
1012
1024
|
setAdvanceFetchAllowPrivate(v.advanceFetchAllowPrivate === true);
|
|
1013
1025
|
setSearxngLang(typeof v.searxngLanguage === "string" && v.searxngLanguage ? v.searxngLanguage : "auto");
|
|
@@ -1240,6 +1252,8 @@ window.__ModuleLoader__.load({
|
|
|
1240
1252
|
ops.push({ op: "set", path: ["cacheTtl"], value: Math.min(Math.max(Number(cacheTtl) ?? 5, 0), 5) });
|
|
1241
1253
|
ops.push({ op: "set", path: ["blockSystemSearch"], value: blockSystemSearch });
|
|
1242
1254
|
ops.push({ op: "set", path: ["fetchTakeover"], value: fetchTakeover });
|
|
1255
|
+
ops.push({ op: "set", path: ["browserFetchTier"], value: browserFetchTier });
|
|
1256
|
+
ops.push({ op: "set", path: ["browserFetchAllowHosts"], value: String(browserFetchAllowHosts).trim() });
|
|
1243
1257
|
ops.push({ op: "set", path: ["advanceFetchEnabled"], value: advanceFetchEnabled });
|
|
1244
1258
|
ops.push({ op: "set", path: ["advanceFetchAllowPrivate"], value: advanceFetchAllowPrivate });
|
|
1245
1259
|
ops.push({ op: "set", path: ["searxngLanguage"], value: searxngLang });
|
|
@@ -2371,6 +2385,49 @@ react_jsx_runtime.jsx("div", {
|
|
|
2371
2385
|
}),
|
|
2372
2386
|
],
|
|
2373
2387
|
}),
|
|
2388
|
+
react_jsx_runtime.jsx("div", {
|
|
2389
|
+
className: "dshfs-field",
|
|
2390
|
+
children: [
|
|
2391
|
+
react_jsx_runtime.jsx("label", {
|
|
2392
|
+
className: "dshfs-platform",
|
|
2393
|
+
children: [
|
|
2394
|
+
react_jsx_runtime.jsx("input", {
|
|
2395
|
+
type: "checkbox",
|
|
2396
|
+
checked: browserFetchTier,
|
|
2397
|
+
disabled: !ready || saving,
|
|
2398
|
+
onChange: (e) => {
|
|
2399
|
+
setBrowserFetchTier(e.target.checked);
|
|
2400
|
+
setDirty(true);
|
|
2401
|
+
setFailed(false);
|
|
2402
|
+
setSaveError("");
|
|
2403
|
+
},
|
|
2404
|
+
}),
|
|
2405
|
+
t.browserFetchTier,
|
|
2406
|
+
],
|
|
2407
|
+
}),
|
|
2408
|
+
react_jsx_runtime.jsx("p", {
|
|
2409
|
+
className: "dshfs-hint",
|
|
2410
|
+
children: t.browserFetchTierHint,
|
|
2411
|
+
}),
|
|
2412
|
+
react_jsx_runtime.jsx("input", {
|
|
2413
|
+
type: "text",
|
|
2414
|
+
className: "dshfs-input",
|
|
2415
|
+
placeholder: "linkedin.com,weibo.com",
|
|
2416
|
+
value: browserFetchAllowHosts,
|
|
2417
|
+
disabled: !ready || saving || !browserFetchTier,
|
|
2418
|
+
onChange: (e) => {
|
|
2419
|
+
setBrowserFetchAllowHosts(e.target.value);
|
|
2420
|
+
setDirty(true);
|
|
2421
|
+
setFailed(false);
|
|
2422
|
+
setSaveError("");
|
|
2423
|
+
},
|
|
2424
|
+
}),
|
|
2425
|
+
react_jsx_runtime.jsx("p", {
|
|
2426
|
+
className: "dshfs-hint",
|
|
2427
|
+
children: t.browserFetchAllowHostsHint,
|
|
2428
|
+
}),
|
|
2429
|
+
],
|
|
2430
|
+
}),
|
|
2374
2431
|
react_jsx_runtime.jsx("div", {
|
|
2375
2432
|
className: "dshfs-field",
|
|
2376
2433
|
children: [
|
package/lib/index.js
CHANGED
|
@@ -3673,6 +3673,60 @@ function providerTextFrom(result) {
|
|
|
3673
3673
|
return String(result.markdown ?? result.text ?? "");
|
|
3674
3674
|
}
|
|
3675
3675
|
|
|
3676
|
+
// 浏览器升级档判据(0.13.0,导出供测试):
|
|
3677
|
+
// hostInAllowlist:逗号分隔后缀表;空表=全放行(总开关在调用方);匹配 host 全名或 .后缀。
|
|
3678
|
+
function hostInAllowlist(hostname, allowCsv) {
|
|
3679
|
+
const list = String(allowCsv ?? "").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
3680
|
+
if (list.length === 0) return true;
|
|
3681
|
+
const h = String(hostname ?? "").toLowerCase();
|
|
3682
|
+
return list.some((d) => h === d || h.endsWith(`.${d}`));
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
// 升级特征:直连报错(HTTP 4xx / 反爬挑战页)或成功但 note 里报了 JS 空壳/frameset。
|
|
3686
|
+
// 其余失败(网络错/5xx/超时)不升级——浏览器对这些问题帮助有限且成本高一量级。
|
|
3687
|
+
function browserUpgradeNeeded(result, error) {
|
|
3688
|
+
if (error) return /HTTP 4\d\d|anti-bot challenge|captcha/i.test(String((error && error.message) || error));
|
|
3689
|
+
if (result && result.note && /JS-rendered shell|frameset/i.test(String(result.note))) return true;
|
|
3690
|
+
return false;
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
// 0.13.0 浏览器升级档执行:调 cdp 的 fetchRenderedHtml 拿渲染后 HTML,喂同一套抽取/优化器链,
|
|
3694
|
+
// 出口形状与直连 provider 一致;正文尾部带「经用户浏览器抓取(含登录态)」声明。服务侧任何
|
|
3695
|
+
// 失败/空结果回 null,由调用方降级回直连形态。
|
|
3696
|
+
async function browserTierFetch(svc, url, signal) {
|
|
3697
|
+
const r = await svc.fetchRenderedHtml({ url, waitUntil: "load", maxBytes: 2_000_000, timeoutMs: 30000 }, signal);
|
|
3698
|
+
if (!r || r.ok !== true || !r.html) return null;
|
|
3699
|
+
const out = extractBySelector(r.html, { baseUrl: r.finalUrl || url });
|
|
3700
|
+
const md = out.markdown ?? "";
|
|
3701
|
+
if (!md.trim()) return null;
|
|
3702
|
+
const text = smartTruncate(md, ADVANCE_FETCH_MAX_CHARS_DEFAULT);
|
|
3703
|
+
const notes = ["fetched via user browser (session cookies included)", out.note, r.truncated ? "browser html exceeded byte budget" : null].filter(Boolean);
|
|
3704
|
+
return {
|
|
3705
|
+
url: r.finalUrl || url,
|
|
3706
|
+
statusCode: typeof r.statusCode === "number" ? r.statusCode : 200,
|
|
3707
|
+
body: { kind: "text", content: `${text}\n\n[note: ${notes.join("; ")}]` },
|
|
3708
|
+
truncated: Boolean(r.truncated) || text.length < md.length,
|
|
3709
|
+
};
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
// 0.13.0 provider 出口形状(直连与升级共用):kind:text 成品 markdown,宿主不再二次转换。
|
|
3713
|
+
function shapeFetchResult(request, result) {
|
|
3714
|
+
return {
|
|
3715
|
+
url: result.finalUrl ?? String(request.url),
|
|
3716
|
+
statusCode: result.statusCode ?? 200,
|
|
3717
|
+
body: { kind: "text", content: providerTextFrom(result) },
|
|
3718
|
+
truncated: Boolean(result.truncated),
|
|
3719
|
+
};
|
|
3720
|
+
}
|
|
3721
|
+
|
|
3722
|
+
function safeHost(url) {
|
|
3723
|
+
try {
|
|
3724
|
+
return new URL(String(url)).hostname;
|
|
3725
|
+
} catch {
|
|
3726
|
+
return "";
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3676
3730
|
//#region bridge
|
|
3677
3731
|
const MAX_JSON_BODY_BYTES = 64 * 1024;
|
|
3678
3732
|
|
|
@@ -4233,6 +4287,12 @@ const Config = z.object({
|
|
|
4233
4287
|
// web_fetch 出口改走本插件抓取栈(ALPN 直连 + 宿主同款 markdown 优化器,kind:text 抢在宿主
|
|
4234
4288
|
// 「先 2e5 截断再 HTML→MD」之前完成转换)。关闭时 available()=false,完全不参与宿主选择。
|
|
4235
4289
|
fetchTakeover: z.boolean().default(false).volatile(),
|
|
4290
|
+
// 浏览器升级档(0.13.0,需 dsh-browser-cdp >= 1.15.0 同在会话):fetch provider 直连结果命中
|
|
4291
|
+
// 登录墙/反爬/JS 空壳特征时,改借用户已登录浏览器重抓。默认关——带 cookie 访问由搜索结果
|
|
4292
|
+
// (不可信文本)驱动的 URL 是身份泄漏面,只在确需登录后内容时手动开启。
|
|
4293
|
+
browserFetchTier: z.boolean().default(false).volatile(),
|
|
4294
|
+
// 逗号分隔域名后缀 allowlist(命中含子域);空 = 不限制(仍受 browserFetchTier 总开关)。建议只钉登录墙域名。
|
|
4295
|
+
browserFetchAllowHosts: z.string().default("").volatile(),
|
|
4236
4296
|
// 插件自有 advance_fetch 工具开关(0.10.3,热生效):关闭后 execute 拒绝调用,提示词不再宣传
|
|
4237
4297
|
advanceFetchEnabled: z.boolean().default(true).volatile(),
|
|
4238
4298
|
// SSRF 地址门的显式豁免(0.10.4):true = 允许回环/内网目标(局域网设备抓取);协议/重定向门不变
|
|
@@ -5109,23 +5169,45 @@ function apply(ctx, config) {
|
|
|
5109
5169
|
// 宿主选择规则里根本不参与(不引入 AMBIGUOUS);开启 → 单可用自动选或随 takeover 钉选。
|
|
5110
5170
|
// 旧宿主无 registerFetchProvider 缝:能力探测跳过,不崩。
|
|
5111
5171
|
if (typeof ctx.web.registerFetchProvider === "function") {
|
|
5172
|
+
// 惰性探测 dsh-browser-cdp 的 browser-fetch 服务(cordis 服务总线):未装/未启用时
|
|
5173
|
+
// ctx.get 回 undefined,升级档自动惰性降级,不需要任何配置联动。
|
|
5174
|
+
const getBrowserFetch = () => {
|
|
5175
|
+
try {
|
|
5176
|
+
return ctx.get("browser-fetch") ?? null;
|
|
5177
|
+
} catch {
|
|
5178
|
+
return null;
|
|
5179
|
+
}
|
|
5180
|
+
};
|
|
5112
5181
|
ctx.web.registerFetchProvider({
|
|
5113
5182
|
id: "union-search",
|
|
5114
5183
|
available: () => current().fetchTakeover === true,
|
|
5115
5184
|
async fetch(request, signal) {
|
|
5116
|
-
const
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
}
|
|
5185
|
+
const cfg = current();
|
|
5186
|
+
const tierAllows = () => cfg.browserFetchTier === true && hostInAllowlist(safeHost(request.url), cfg.browserFetchAllowHosts);
|
|
5187
|
+
let result = null;
|
|
5188
|
+
let directErr = null;
|
|
5189
|
+
try {
|
|
5190
|
+
result = await advanceFetch(request.url, {
|
|
5191
|
+
mode: "markdown",
|
|
5192
|
+
allowPrivate: cfg.advanceFetchAllowPrivate === true,
|
|
5193
|
+
userAgent: cfg.advanceFetchUserAgent ?? "",
|
|
5194
|
+
referer: cfg.advanceFetchReferer ?? "",
|
|
5195
|
+
cookieMap: cfg.advanceFetchCookieMap ?? "",
|
|
5196
|
+
}, signal);
|
|
5197
|
+
} catch (error) {
|
|
5198
|
+
// 升级档未开启或不命中判据 → 原样抛(与 0.12.0 行为完全一致)
|
|
5199
|
+
if (!tierAllows() || !browserUpgradeNeeded(null, error) || signal?.aborted) throw error;
|
|
5200
|
+
directErr = error;
|
|
5201
|
+
}
|
|
5202
|
+
if (result && !(tierAllows() && browserUpgradeNeeded(result, null))) {
|
|
5203
|
+
return shapeFetchResult(request, result);
|
|
5204
|
+
}
|
|
5205
|
+
// 命中升级特征:借 dsh-browser-cdp 的已登录浏览器重抓(服务不在位则静默降级)。
|
|
5206
|
+
const svc = getBrowserFetch();
|
|
5207
|
+
const upgraded = svc ? await browserTierFetch(svc, String(request.url), signal).catch(() => null) : null;
|
|
5208
|
+
if (upgraded) return upgraded;
|
|
5209
|
+
if (directErr) throw directErr;
|
|
5210
|
+
return shapeFetchResult(request, result);
|
|
5129
5211
|
},
|
|
5130
5212
|
});
|
|
5131
5213
|
}
|
|
@@ -6278,4 +6360,6 @@ export {
|
|
|
6278
6360
|
httpsFetchText,
|
|
6279
6361
|
alpnHttpsAgent,
|
|
6280
6362
|
providerTextFrom,
|
|
6363
|
+
hostInAllowlist,
|
|
6364
|
+
browserUpgradeNeeded,
|
|
6281
6365
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-union-search",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-rc.2",
|
|
4
4
|
"description": "Union web search for DeepSeek Harness (renamed from dsh-free-search): free keyless engines + many professional paid search APIs — 28 engines (Bing/DuckDuckGo/AnySearch/SearXNG multi-instance union/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Zhihu global/site via MCP and Perplexity/SerpBase/Serply/DeepSeek official/You.com/Baidu/Kimi/Aliyun/Doubao/Zhipu/Bocha/Metaso with key; OpenAI/Gemini/Claude/Grok model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + multi mode (parallel top-3 merge) + multi_search cross-source tool + failure-aware fallback + block system built-in search toggle + experimental free advance_fetch (no API key, no billing; host-twin GitHub-Flavored Markdown conversion + CSS selector/fields structured extraction) + time filtering + platform search + web_fetch, with web settings UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dsh-union-search-restore": "bin/restore.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "node --test test/md.test.mjs test/egress.test.mjs test/relevance.test.mjs test/upgrade.test.mjs test/alpn.test.mjs test/restore.test.mjs test/fetch-provider.test.mjs test/credentials.test.mjs test/tool-face.test.mjs test/notes-channel.test.mjs"
|
|
11
|
+
"test": "node --test test/md.test.mjs test/egress.test.mjs test/relevance.test.mjs test/upgrade.test.mjs test/alpn.test.mjs test/restore.test.mjs test/fetch-provider.test.mjs test/browser-tier.test.mjs test/credentials.test.mjs test/tool-face.test.mjs test/notes-channel.test.mjs"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": "./lib/index.js",
|