dsh-free-search 0.9.62 → 0.9.64

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 CHANGED
@@ -77,7 +77,7 @@
77
77
 
78
78
  #### 抓取与工具
79
79
 
80
- - **网页抓取(web_fetch)** —— 让 agent 抓取网页内容(官方 `dsh-web-fetch-http` provider,纯 JS,零额外依赖),可自动接管 `web.fetchProvider` 为插件的直连 → 浏览器渲染 → exa / firecrawl → crawl4ai 质量链。T1.5 浏览器渲染可在设置页关闭,exa 与 firecrawl 的先后顺序也可切换;默认只抓 HTTPS,设置页可开启 `allowHttp`(HTTP 目标先尝试 HTTPS 升级,再走 HTTP / 浏览器 / 云端);私网、回环和云元数据地址一律拒绝(SSRF 防护)。Clash / mihomo TUN 的 fake-ip 网段(常见 198.18.0.0/15)可在「额外允许的网段」里显式放行,否则系统 DNS 返回的占位地址会被当成私网拒绝。
80
+ - **网页抓取(web_fetch)** —— 让 agent 抓取网页内容(官方 `dsh-web-fetch-http` provider,纯 JS,零额外依赖),可自动接管 `web.fetchProvider` 为插件的直连 → 浏览器渲染 → exa / firecrawl → crawl4ai 质量链。直连层同时支持 `http://` 与 `https://` 目标,并按每一跳的协议选择传输;只有 `http(s)` 以外的协议会被拒绝。T1.5 浏览器渲染可在设置页关闭,exa 与 firecrawl 的先后顺序也可切换;私网、回环和云元数据地址一律拒绝(SSRF 防护)。Clash / mihomo TUN 的 fake-ip 网段(常见 198.18.0.0/15)可在「额外允许的网段」里显式放行,否则系统 DNS 返回的占位地址会被当成私网拒绝。
81
81
 
82
82
  <img src="https://raw.githubusercontent.com/DDDMUC/dsh-free-search/master/assets/ui-fetch.png" alt="抓取与平台:web_fetch 接管、Key 存储位置与平台搜索开关" width="100%" />
83
83
  <sub>▲ 抓取:自动接管 web_fetch、Key 存储位置与平台搜索开关</sub>
@@ -264,10 +264,12 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
264
264
 
265
265
  | 操作 | 结果 |
266
266
  |---|---|
267
- | 打开开关 | `web.searchProvider` 写成 `deepseek-search-api`(属于「显式选择其他 provider」),**本插件主动让路**,搜索走官方直连 API;抓取同时变成 `deepseek-fetch-api`。**0.9.62 起**抓取侧仍会接管为 `fs-quality-fetch`,搜索侧保持官方选择 |
267
+ | 打开开关 | `web.searchProvider` 写成 `deepseek-search-api`(属于「显式选择其他 provider」),**本插件主动让路**,搜索走官方直连 API;抓取同时变成 `deepseek-fetch-api` |
268
268
  | 关闭开关 | DSH 会把整行 `- id: web` 删掉,provider 回到当前版本的官方默认:0.2.2-rc.2 起是 `deepseek-search-api`(按 Search API 计费),旧版是 `deepseek-official`(模型搜索,一次完整 aux 请求,按 token 计费);都不是免费引擎 |
269
269
  | 关闭后 | **0.9.8 起**:插件检测到任一官方默认会在运行时补一次接管(日志 `DSH's search switch put the web providers back to the official defaults — re-took …`),通常几秒内恢复免费链路;若没恢复,完整重启 DSH |
270
270
 
271
+ 开关打开期间,`fetchProvider` 会一直停在 `deepseek-fetch-api`,`web_fetch` 也就一直走官方计费接口,`fs-quality-fetch` 的直连/浏览器/exa/firecrawl 一层都不会被调用(报错信息来自 DeepSeek,与插件无关)。这是插件默认让路的结果,不是上游故障。想「官方搜索 + 插件抓取」同时在,打开本插件设置页「抓取」段的**强制接管 web_fetch**(写入 `fetchProviderForce: true`),保存即生效,不用重启;也可以手写 `fetchProvider: fs-quality-fetch`。
272
+
271
273
  想换引擎请用 `/free-search-engine` 或本插件设置页,**不要动那个开关**。打开开关再关掉,官方直连会退回模型搜索,直到插件重新接管或重启。
272
274
 
273
275
  > 如果你在 0.1.x 时代按旧文档手写过 `- id: web`,现在可以删掉:0.2.x 由运行时接管写入。手写时注意 `fetchProvider` 应该是 `fs-quality-fetch`(本插件注册的抓取 provider),不是 `http`。
@@ -379,6 +381,8 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
379
381
 
380
382
  如果你**特意** pin 了 `fetchProvider: http`(只想要内置抓取),把 `fetchProviderTakeover` 设为 `false` 即可:本插件不再把 `http` 当成「出厂默认」去接管,但仍会在完全未设置时补上。
381
383
 
384
+ DSH 的搜索开关会把 `fetchProvider` 写成 `deepseek-fetch-api`,默认同样让路。要把抓取抢回来又不想改 YAML,打开 `fetchProviderForce`(设置页「抓取」段的「强制接管」):它忽略上面那条判据,保存后立即把 `web.fetchProvider` 写回 `fs-quality-fetch`。
385
+
382
386
  `searchProvider` 的规则相同:未设置或仍是当前版本的官方默认(`deepseek-search-api` / `deepseek-official`)时接管,显式指定其它 provider 时不抢占。
383
387
 
384
388
  #### 配置文件
@@ -410,6 +414,7 @@ promptToolsLang: "" # 工具段那句话的语言,zh 或 en;留空
410
414
  disabledTools: [] # 关掉的工具不再注册(例如 [domain_search]),schema 一并从上下文消失
411
415
  bingMarket: zh-CN # Bing 市场;留空 = 自动(不发送 mkt)
412
416
  fetchProviderTakeover: true # false = 保留你显式 pin 的 fetchProvider: http
417
+ fetchProviderForce: false # true = 连 DSH 搜索开关写进来的 deepseek-fetch-api 也接管(#142)
413
418
  browserFetch: true # 直连失败时用系统浏览器无头渲染
414
419
  allowFakeIpCidrs: [] # 显式放行的保留网段,例如 Clash/mihomo fake-ip 的 198.18.0.0/15
415
420
  fetchPrefer: exa # exa | firecrawl —— 两者都失败后先试哪个 keyed 抓取层
@@ -533,7 +538,6 @@ Search engine test:
533
538
 
534
539
  - 自动跟随重定向、解码正文(HTML 转文本)
535
540
  - 支持超时和大小限制
536
- - 默认只抓 HTTPS;HTTP 目标默认被拒绝。设置页开启「允许抓取 http 页面」后,会先尝试 HTTPS 升级,失败再走 HTTP / 浏览器 / 云端 tier
537
541
  - ⚠️ 注意:`web_fetch` 默认拒绝回环、私网、链路本地和云元数据地址。若使用 Clash / mihomo TUN 的 fake-ip DNS,请把对应网段(常见 `198.18.0.0/15`)加入设置页的「额外允许的网段」,否则所有被代理域名都会被判成私网而抓取失败;只放行 fake-ip 网段,不要放行 RFC1918;IPv6 fake-ip 常用 ULA(如 `fdfe:dcba:9876::/64`),需要显式加入才会放行。
538
542
 
539
543
  #### MCP server(stdio)
@@ -544,7 +548,7 @@ Search engine test:
544
548
  npx -y -p dsh-free-search dsh-free-search-mcp
545
549
  ```
546
550
 
547
- `web_search` 默认只自动调用免 key 的 Bing / DuckDuckGo;在参数或 `MCP_SEARCH_ENGINE` 里显式点名 `google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` 时才会使用付费引擎;`anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` 可显式选择,且有免 key 档。支持 `time_range`(day/week/month/year)。`advanced_search` 是同一后端的兼容别名,便于按宿主工具名调用。`web_fetch` 仍走直连 / 浏览器 / Exa / Firecrawl。`multi_search` 并行合并多个引擎(默认只跑免费引擎),`domain_search` 直查包/论文/CVE/财报/金融/法律等垂直源,`platform_search` 直查 GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/掘金/豆瓣/Qiita/YouTube/Vimeo/X,`video_search` 查 Bing/DDG 视频,`research` 做轻量多引擎检索 + 抓取 + 证据摘要,`weather` 查询 1–7 天天气;不监听端口。Claude Desktop 配置示例:
551
+ `web_search` 默认只自动调用免 key 的 Bing / DuckDuckGo;在参数或 `MCP_SEARCH_ENGINE` 里显式点名 `google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` / `perplexity` / `serpbase` / `serply` / `outcrawl` / `tinyfish` / `jina` / `kimi` / `aliyun` / `doubao` / `zhihu-global` / `zhihu-site` / `specstream` / `deepseek-official` 时才会使用付费引擎;`anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` 可显式选择,且有免 key 档。支持 `time_range`(day/week/month/year)。`advanced_search` 是同一后端的兼容别名,便于按宿主工具名调用。`web_fetch` 仍走直连 / 浏览器 / Exa / Firecrawl。`multi_search` 并行合并多个引擎(默认只跑免费引擎),`domain_search` 直查包/论文/CVE/财报/金融/法律等垂直源,`platform_search` 直查 GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/掘金/豆瓣/Qiita/YouTube/Vimeo/X,`video_search` 查 Bing/DDG 视频,`research` 做轻量多引擎检索 + 抓取 + 证据摘要,`weather` 查询 1–7 天天气;不监听端口。Claude Desktop 配置示例:
548
552
 
549
553
  ```json
550
554
  {
@@ -660,8 +664,9 @@ npx -y -p dsh-free-search dsh-free-search-mcp
660
664
  | `assert-prompt-contract.mjs` | 系统提示词契约:**检索≠抓取**、不可信边界、模型内置搜索只在显式选中时运行 | `node tools/assert-prompt-contract.mjs`(9) |
661
665
  | `assert-research-degradation.mjs` | research 无 key 全降级、`node:sqlite` no-op、90s 预算隔离、缓存目录可配置、`budget.exhausted` 契约名 | `node tools/assert-research-degradation.mjs`(19) |
662
666
  | `assert-research-call-wrappers.mjs` | research 四个 `call*` 包装层的替身/底层透传(#75 回归) | `node tools/assert-research-call-wrappers.mjs`(23) |
663
- | `assert-fetch-chain.mjs` | `fs-quality-fetch` 四层链序、任一层命中即停、exa 失败静默降级 firecrawl、全层失败聚合报错 | `node tools/assert-fetch-chain.mjs`(8) |
664
- | `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、非 HTTPS 与带凭据 URL 拒绝、fake-ip 网段默认拒绝且仅按配置放行、IPv6 ULA 显式放行、放行后仍拒绝回环/IPv4 私网/链路本地、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(8) |
667
+ | `assert-fetch-chain.mjs` | `fs-quality-fetch` 四层链序、任一层命中即停、exa 失败静默降级 firecrawl、全层失败聚合报错、http 目标进到 tier 链而不是被入口断言拒绝 | `node tools/assert-fetch-chain.mjs`(9) |
668
+ | `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、`http://` 与 `https://` 放行而其他协议与带凭据 URL 拒绝、http 目标解析到私网同样拒绝、fake-ip 网段默认拒绝且仅按配置放行、IPv6 ULA 显式放行、放行后仍拒绝回环/IPv4 私网/链路本地、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(10) |
669
+ | `assert-fetch-http.mjs` | 明文 http 目标(#143):直连层按协议选 transport、http 重定向可跟随、provider 不再在入口拒绝 http 而交给 tier 链、全层失败报直连原因而不再报 only https、非 http(s) 协议仍拒、`agentForUrl` 为 http 目标选明文隧道 agent、经 `CONNECT` 隧道抓取 http 页面 | `node tools/assert-fetch-http.mjs`(7) |
665
670
  | `assert-mcp.mjs` | MCP stdio 面:initialize 协议协商、tools/list 的 JSON Schema、tools/call 文本结果、工具错误与 JSON-RPC 错误区分、必填参数校验、显式付费引擎与新 provider、advanced/multi/domain/platform/video/research/weather 新工具、bin/files 打包 | `node tools/assert-mcp.mjs`(10) |
666
671
  | `assert-mcp.mjs` | MCP stdio surface: initialize negotiation, tools/list JSON Schema, tools/call text results, tool errors vs JSON-RPC errors, required arguments, explicit keyed engines and new providers, advanced/multi/domain/platform/video/research/weather tools, bin/files packaging | `node tools/assert-mcp.mjs` (10) |
667
672
  | `assert-baidu.mjs` | 百度千帆:key 必填、web_search 首请求、403 或 results.code 额度错误回退 chat/completions(stream:false)、401 不回退、双端失败合并报错 | `node tools/assert-baidu.mjs`(6) |
@@ -706,7 +711,7 @@ npx -y -p dsh-free-search dsh-free-search-mcp
706
711
  | `assert-fetch-abort.mjs` | 抓取中断(#87):压缩响应中途断连必须 reject(不再永久 pending)、明文断连同样 reject、abort 能打断停滞的 gzip 流、complete 响应与重定向仍正常 | `node tools/assert-fetch-abort.mjs`(6) |
707
712
  | `assert-fetch-proxy.mjs` | 抓取层代理:`http_proxy` / `https_proxy` / `all_proxy` / `no_proxy` 解析(大小写与小写优先、空值视为未设置)、`NO_PROXY` 的域名 / `host:port` / `*` 匹配、loopback 恒直连、`socks5://` 忽略、`CONNECT` 隧道握手与 `Proxy-Authorization`、代理拒绝与提前断连不挂起、有 agent 时重定向每一跳仍过 SSRF 校验、浏览器 tier 的 `--proxy-server` | `node tools/assert-fetch-proxy.mjs`(12) |
708
713
  | `assert-bridge-access.mjs` | 桥接 Host 围栏(#84):loopback 放行、remote peer 打 loopback Host 拒绝、`--trusted-host`(无端口匹配任意端口 / 带端口精确匹配)、`--public-url`、绑定地址、跨站与异源拒绝、connection 鉴权委托与 fail-closed、设置客户端按 `document.baseURI` 解析子路径 | `node tools/assert-bridge-access.mjs`(14) |
709
- | `assert-provider-takeover.mjs` | provider 接管:旧属性 API 与 rc.2 的 `config.*` ref 两套兼容、`settings.mutate(web)` 单批写入、显式指定的 provider 不被抢占、`fetchProviderTakeover: false` 时保留显式 `http`、describe 噪声不误报、嵌套 config 变化与 web 重建分别成行、关闭 DSH 搜索开关后重新接管(`deepseek-search-api` / `deepseek-official` 均视为官方默认)、打开 DeepSeek 开关(`deepseek-fetch-api`)时搜索让路但抓取仍接管、apply 重入/重复注册不再中断、重复日志去重 | `node tools/assert-provider-takeover.mjs`(20) |
714
+ | `assert-provider-takeover.mjs` | provider 接管:旧属性 API 与 rc.2 的 `config.*` ref 两套兼容、`settings.mutate(web)` 单批写入、显式指定的 provider 不被抢占、`fetchProviderTakeover: false` 时保留显式 `http`、`fetchProviderForce` 抢回 `deepseek-fetch-api` 且不动搜索、开关打开时保存设置即补接管(关闭时不动 web)、describe 噪声不误报、嵌套 config 变化与 web 重建分别成行、关闭 DSH 搜索开关后重新接管(`deepseek-search-api` / `deepseek-official` 均视为官方默认)、apply 重入/重复注册不再中断、重复日志去重 | `node tools/assert-provider-takeover.mjs`(25) |
710
715
 
711
716
  任何一个失败会以非 0 退出码结束并列出失败项;把某个旧版本文件路径作为参数传进去,可以看到修复前必红(用来证明断言不是空转)。改动发布相关逻辑后建议先跑一遍再发版。
712
717
 
@@ -728,6 +733,7 @@ export NO_PROXY=localhost,127.0.0.1,::1 # 可选
728
733
  ```
729
734
 
730
735
  - 只支持 `http://` / `https://` 代理(可带 Basic 认证);`socks5://` 会被忽略并直连。
736
+ - `http://` 目标同样走代理:隧道建立后直接用明文 socket,不会对不支持 TLS 的站点叠一层 TLS 握手。
731
737
  - loopback 地址(`localhost`、`127.0.0.1`、`::1`、`127.0.0.0/8`)恒直连。
732
738
  - `NO_PROXY` 支持逗号分隔的域名、`host:port` 与 `*`。
733
739
  - 走代理时域名由代理端解析,`lookup` 钩子失效;因此重定向的每一跳都会先显式过一遍 SSRF 校验,`allowFakeIpCidrs` 等设置继续生效。
@@ -813,7 +819,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
813
819
 
814
820
  #### Fetch and tools
815
821
 
816
- - **Webpage Fetching (`web_fetch`)** — Allows the agent to read full webpage contents (official `dsh-web-fetch-http` provider, pure JS, zero extra dependencies); it can take over `web.fetchProvider` with the plugin's direct → browser render → exa / firecrawl → crawl4ai quality chain. The headless browser tier can be switched off in Settings and the exa/firecrawl order is configurable; only HTTPS is fetched by default and the API target first tries HTTPS, then HTTP / browser / cloud tiers when `allowHttp` is enabled in Settings; loopback, private-network and cloud-metadata addresses are rejected (SSRF guard). Clash / mihomo TUN fake-ip ranges (usually 198.18.0.0/15) can be allowed explicitly under extra allowed networks, otherwise the placeholder addresses returned by system DNS are rejected as private.
822
+ - **Webpage Fetching (`web_fetch`)** — Allows the agent to read full webpage contents (official `dsh-web-fetch-http` provider, pure JS, zero extra dependencies); it can take over `web.fetchProvider` with the plugin's direct → browser render → exa / firecrawl → crawl4ai quality chain. The direct tier handles `http://` as well as `https://` targets and picks the transport per hop; only schemes other than `http(s)` are refused. The headless browser tier can be switched off in Settings and the exa/firecrawl order is configurable; loopback, private-network and cloud-metadata addresses are rejected (SSRF guard). Clash / mihomo TUN fake-ip ranges (usually 198.18.0.0/15) can be allowed explicitly under extra allowed networks, otherwise the placeholder addresses returned by system DNS are rejected as private.
817
823
 
818
824
  <img src="https://raw.githubusercontent.com/DDDMUC/dsh-free-search/master/assets/ui-fetch.png" alt="Fetch and platforms: web_fetch takeover, key storage and platform switches" width="100%" />
819
825
  <sub>▲ Fetch: web_fetch takeover, key storage location and platform search switches</sub>
@@ -1002,10 +1008,12 @@ DSH 0.2.1 has Settings → Web search → **DeepSeek search API**, which interac
1002
1008
 
1003
1009
  | Action | Result |
1004
1010
  |---|---|
1005
- | Turn the switch on | `web.searchProvider` becomes `deepseek-search-api` (an explicit choice), so search goes through the official direct API; fetch becomes `deepseek-fetch-api`. **Since 0.9.62** the fetch side is still taken over as `fs-quality-fetch`, while search stays on the official choice |
1011
+ | Turn the switch on | `web.searchProvider` becomes `deepseek-search-api` (an explicit choice), so **this plugin steps aside** and search goes through the official direct API; fetch becomes `deepseek-fetch-api` as well |
1006
1012
  | Turn the switch off | DSH deletes the whole `- id: web` row, so the provider falls back to the shipped default for the running DSH: `deepseek-search-api` since 0.2.2-rc.2 (billed per Search API call), or `deepseek-official` on older hosts (model search: a full auxiliary request, billed per token). Neither is a free engine |
1007
1013
  | After turning it off | **Since 0.9.8**: the plugin notices either official default and re-takes at runtime (log line `DSH's search switch put the web providers back to the official defaults — re-took …`), normally within seconds; if it does not, restart DSH |
1008
1014
 
1015
+ While the switch is on, `fetchProvider` stays at `deepseek-fetch-api`, so `web_fetch` keeps going through the paid official API and none of the `fs-quality-fetch` tiers (direct / browser / exa / firecrawl) run — the error text comes from DeepSeek and never mentions the plugin. That is the plugin stepping aside on purpose, not an upstream outage. To keep official search and the plugin's fetch chain at the same time, turn on **Force the web_fetch takeover** in this plugin's settings (writes `fetchProviderForce: true`); saving applies immediately, no restart. Setting `fetchProvider: fs-quality-fetch` by hand does the same.
1016
+
1009
1017
  Use `/free-search-engine` or this plugin's settings page to change engines, **not that switch**. Turning it on and then off drops you from the official direct API back to model search until the plugin re-takes over or DSH restarts.
1010
1018
 
1011
1019
  > If you hand-wrote `- id: web` back in the 0.1.x era, you can drop it now: 0.2.x writes it at runtime. If you do declare it by hand, `fetchProvider` should be `fs-quality-fetch` (the fetch provider this plugin registers), not `http`.
@@ -1117,6 +1125,8 @@ Otherwise startup can loop on "write the `web` config → the web service rebuil
1117
1125
 
1118
1126
  If you deliberately pinned `fetchProvider: http` (you only want the built-in fetcher), set `fetchProviderTakeover: false`: `http` is no longer treated as the factory default, while a completely unset provider is still filled in.
1119
1127
 
1128
+ DSH's search switch writes `fetchProvider: deepseek-fetch-api`, and the plugin steps aside for that too. To take fetch back without editing YAML, turn on `fetchProviderForce` ("Force the web_fetch takeover" in the settings page's fetch section): it ignores the rule above and writes `web.fetchProvider` back to `fs-quality-fetch` as soon as the setting is saved.
1129
+
1120
1130
  `searchProvider` follows the same rule: taken over when unset or still the running host's official default (`deepseek-search-api` / `deepseek-official`), never when explicitly pointed elsewhere.
1121
1131
 
1122
1132
  #### Configuration File
@@ -1148,6 +1158,7 @@ promptConstraintsIndex: 0
1148
1158
  disabledTools: [] # tools that are not registered at all (e.g. [domain_search]); their schemas leave the context too
1149
1159
  bingMarket: zh-CN # Bing market; empty = automatic (no mkt sent)
1150
1160
  fetchProviderTakeover: true # false = keep the fetchProvider: http you pinned yourself
1161
+ fetchProviderForce: false # true = also take over the deepseek-fetch-api written by DSH's search switch (#142)
1151
1162
  browserFetch: true # use the system browser headless renderer when direct fetch fails
1152
1163
  allowFakeIpCidrs: [] # reserved ranges to allow explicitly, e.g. 198.18.0.0/15 for Clash/mihomo fake-ip
1153
1164
  fetchPrefer: exa # exa | firecrawl — which keyed fetch tier to try first
@@ -1271,7 +1282,6 @@ After searching, the agent can **read full webpage content** (e.g., *"Open the f
1271
1282
 
1272
1283
  - Automatically follows redirects and decodes HTML to plain text.
1273
1284
  - Supports timeout and response size limits.
1274
- - Fetches HTTPS only by default; plain HTTP URLs are rejected until "Allow plain HTTP fetches" is enabled in Settings, then it first tries an HTTPS upgrade before HTTP / browser / cloud tiers.
1275
1285
  - ⚠️ Note: `web_fetch` rejects loopback, private, link-local and cloud-metadata addresses by default. Under Clash / mihomo TUN fake-ip DNS, add the fake-ip range (usually `198.18.0.0/15`) to extra allowed networks in Settings, otherwise every proxied host resolves to a placeholder address and is rejected; only allow the fake-ip ranges, never RFC1918; IPv6 fake-ip often uses a ULA such as `fdfe:dcba:9876::/64`, which must be listed explicitly.
1276
1286
 
1277
1287
  #### MCP server (stdio)
@@ -1282,7 +1292,7 @@ The repo also ships a standalone stdio MCP server for Claude Desktop, Cursor, Co
1282
1292
  npx -y -p dsh-free-search dsh-free-search-mcp
1283
1293
  ```
1284
1294
 
1285
- `web_search` auto-runs only the keyless Bing / DuckDuckGo engines; a keyed engine (`google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu`) runs only when named in the argument or `MCP_SEARCH_ENGINE`; `anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` can also be named explicitly and have keyless tiers. It supports `time_range` (day/week/month/year). `advanced_search` is a compatibility alias over the same backend for hosts that call that tool name. `web_fetch` still uses direct / browser / Exa / Firecrawl. `multi_search` merges several engines in parallel (free engines by default), `domain_search` queries structured package/paper/CVE/filing/finance/law sources, `platform_search` queries GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/Juejin/Douban/Qiita/YouTube/Vimeo/X, `video_search` queries Bing/DDG videos, `research` runs a lightweight multi-engine search + fetch + evidence brief, and `weather` returns a 1-7 day forecast; the server does not listen on a port. Claude Desktop example:
1295
+ `web_search` auto-runs only the keyless Bing / DuckDuckGo engines; a keyed engine (`google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` / `perplexity` / `serpbase` / `serply` / `outcrawl` / `tinyfish` / `jina` / `kimi` / `aliyun` / `doubao` / `zhihu-global` / `zhihu-site` / `specstream` / `deepseek-official`) runs only when named in the argument or `MCP_SEARCH_ENGINE`; `anysearch` / `searxng` / `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` can also be named explicitly and have keyless tiers. It supports `time_range` (day/week/month/year). `advanced_search` is a compatibility alias over the same backend for hosts that call that tool name. `web_fetch` still uses direct / browser / Exa / Firecrawl. `multi_search` merges several engines in parallel (free engines by default), `domain_search` queries structured package/paper/CVE/filing/finance/law sources, `platform_search` queries GitHub/HN/Reddit/npm/Wikipedia/Bilibili/V2EX/Juejin/Douban/Qiita/YouTube/Vimeo/X, `video_search` queries Bing/DDG videos, `research` runs a lightweight multi-engine search + fetch + evidence brief, and `weather` returns a 1-7 day forecast; the server does not listen on a port. Claude Desktop example:
1286
1296
 
1287
1297
  ```json
1288
1298
  {
@@ -1399,7 +1409,8 @@ Restart `dsh web` after switching to apply changes.
1399
1409
  | `assert-research-degradation.mjs` | research degrades fully without keys, `node:sqlite` no-op, 90s budget isolation, configurable cache dir, `budget.exhausted` contract names | `node tools/assert-research-degradation.mjs` (19) |
1400
1410
  | `assert-research-call-wrappers.mjs` | the four research `call*` wrappers proxy to stubs / the real layer (#75 regression) | `node tools/assert-research-call-wrappers.mjs` (23) |
1401
1411
  | `assert-fetch-chain.mjs` | `fs-quality-fetch` tier ordering, stop-on-first-success, silent firecrawl degradation, aggregated all-tiers failure | `node tools/assert-fetch-chain.mjs` (8) |
1402
- | `assert-fetch-ssrf.mjs` | Fetch SSRF guard: public/private/reserved address classification, DNS resolving to a private address rejected, localhost and IP literals rejected, non-HTTPS and credential URLs rejected, fake-ip ranges blocked by default and allowed only when configured, IPv6 ULA allowed only when listed, loopback/IPv4-private/link-local still blocked after opt-in, provider wiring and settings | `node tools/assert-fetch-ssrf.mjs` (8) |
1412
+ | `assert-fetch-ssrf.mjs` | Fetch SSRF guard: public/private/reserved address classification, DNS resolving to a private address rejected, localhost and IP literals rejected, `http://` accepted while other schemes and credential URLs are refused, an http host resolving to a private address rejected, fake-ip ranges blocked by default and allowed only when configured, IPv6 ULA allowed only when listed, loopback/IPv4-private/link-local still blocked after opt-in, provider wiring and settings | `node tools/assert-fetch-ssrf.mjs` (10) |
1413
+ | `assert-fetch-http.mjs` | Plain-http targets (#143): the direct tier picks its transport per protocol, http redirects are followed, the provider no longer refuses http up front and lets the tier chain run, an all-tiers failure reports the direct error instead of an https-only assertion, other schemes still refused, `agentForUrl` hands http targets a plain tunnel agent, and an http page is fetched through a `CONNECT` tunnel | `node tools/assert-fetch-http.mjs` (7) |
1403
1414
  | `assert-baidu.mjs` | Baidu Qianfan: key required, web_search first, 403 or results.code quota fallback to chat/completions (stream:false), no fallback on 401, combined error when both fail | `node tools/assert-baidu.mjs` (6) |
1404
1415
  | `assert-deepseek-endpoint.mjs` | DeepSeek search endpoint: default URL, base/full-URL normalization, custom endpoint receives bearer/key/query, config and settings wiring | `node tools/assert-deepseek-endpoint.mjs` (4) |
1405
1416
  | `assert-yuanbao.mjs` | key required, Bearer gateway and Query/Mode/Site/FromTime, natural and VR page parsing, date normalization, error classes, registration and explicit-only | `node tools/assert-yuanbao.mjs` (6) |
@@ -1442,7 +1453,7 @@ Restart `dsh web` after switching to apply changes.
1442
1453
  | `assert-fetch-abort.mjs` | fetch interruption (#87): a compressed response cut mid-body rejects instead of hanging forever, identity truncation rejects too, abort breaks a stalled gzip stream, and complete responses plus redirects still work | `node tools/assert-fetch-abort.mjs` (6) |
1443
1454
  | `assert-fetch-proxy.mjs` | proxy support for the fetch tiers: `http_proxy` / `https_proxy` / `all_proxy` / `no_proxy` parsing (either case, lowercase wins, empty means unset), `NO_PROXY` domain / `host:port` / `*` matching, loopback always direct, `socks5://` ignored, the `CONNECT` tunnel handshake and `Proxy-Authorization`, a refusing proxy and an early disconnect never hanging, the SSRF guard still applied to every redirect hop when an agent is in use, and `--proxy-server` for the browser tier | `node tools/assert-fetch-proxy.mjs` (12) |
1444
1455
  | `assert-bridge-access.mjs` | bridge Host fence (#84): loopback allowed, a remote peer behind a loopback Host refused, `--trusted-host` (port-less matches any port, explicit port matches exactly), `--public-url`, the bind address, cross-site and foreign-Origin refused, connection-auth delegation, fail-closed behavior, and settings-client subpath resolution via `document.baseURI` | `node tools/assert-bridge-access.mjs` (14) |
1445
- | `assert-provider-takeover.mjs` | provider takeover: both the legacy property API and the rc.2 `config.*` refs, a single batched `settings.mutate(web)`, explicit foreign providers left untouched, an explicit `http` kept when `fetchProviderTakeover` is off, describe()-triggered events ignored when nothing changed, nested config changes and web rebuilds reported separately, re-takeover after DSH's search switch is turned off (both `deepseek-search-api` and `deepseek-official` count as the factory default), stepping aside for search but still taking over fetch on the explicit `deepseek-fetch-api` switch, apply re-entry / duplicate registrations tolerated, and repeated logs deduplicated | `node tools/assert-provider-takeover.mjs` (20) |
1456
+ | `assert-provider-takeover.mjs` | provider takeover: both the legacy property API and the rc.2 `config.*` refs, a single batched `settings.mutate(web)`, explicit foreign providers left untouched, an explicit `http` kept when `fetchProviderTakeover` is off, `fetchProviderForce` taking `deepseek-fetch-api` back without touching search, saving the plugin settings re-taking fetch right away (and leaving web alone when off), describe()-triggered events ignored when nothing changed, nested config changes and web rebuilds reported separately, re-takeover after DSH's search switch is turned off (both `deepseek-search-api` and `deepseek-official` count as the factory default), apply re-entry / duplicate registrations tolerated, and repeated logs deduplicated | `node tools/assert-provider-takeover.mjs` (25) |
1446
1457
 
1447
1458
  Any failure exits non-zero with the failing items listed. Passing the path of an older file shows the pre-fix failures (proving the assertions are not vacuous). Worth running before a release.
1448
1459
 
package/lib/client.js CHANGED
@@ -448,6 +448,8 @@ window.__ModuleLoader__.load({
448
448
  marketAuto: "自动 —— 不发送 mkt(推荐用于非上列地区)",
449
449
  fetchTakeoverLabel: "自动接管 web_fetch",
450
450
  fetchTakeoverHint: "开启时:web.fetchProvider 未设置或仍是出厂默认 http 会接管为 fs-quality-fetch。如果你刻意 pin 了 http(例如只想用内置抓取),关掉此项。",
451
+ fetchForceLabel: "强制接管 web_fetch",
452
+ fetchForceHint: "DSH 的「DeepSeek 搜索 API」开关会把 web.fetchProvider 写成 deepseek-fetch-api,即使关掉搜索开关,抓取也会一直走官方计费接口。勾选此项后,保存即把抓取改回 fs-quality-fetch,忽略上一项的判据。",
451
453
  browserFetchLabel: "用本机浏览器渲染",
452
454
  browserFetchHint: "直连失败时用系统 Chrome/Edge 无头加载页面,能过 JS 挑战;没有浏览器时自动跳过。",
453
455
  allowHttpLabel: "允许抓取 http 页面",
@@ -669,6 +671,8 @@ window.__ModuleLoader__.load({
669
671
  marketAuto: "Automatic — send no mkt (recommended outside the listed regions)",
670
672
  fetchTakeoverLabel: "Take over web_fetch automatically",
671
673
  fetchTakeoverHint: "On: when web.fetchProvider is unset or still the factory default http, it is taken over as fs-quality-fetch. Turn this off if you deliberately pinned http (e.g. you only want the built-in fetcher).",
674
+ fetchForceLabel: "Force the web_fetch takeover",
675
+ fetchForceHint: "DSH's DeepSeek search switch writes web.fetchProvider as deepseek-fetch-api, so fetches keep going through the paid official API even after the switch is turned off. With this on, saving sets fetch back to fs-quality-fetch and ignores the check above.",
672
676
  browserFetchLabel: "Render with the local browser",
673
677
  browserFetchHint: "When direct fetch fails, load the page in headless Chrome/Edge to pass JS challenges; skipped when no browser is installed.",
674
678
  allowHttpLabel: "Allow plain HTTP fetches",
@@ -773,7 +777,7 @@ window.__ModuleLoader__.load({
773
777
  "cache_search",
774
778
  "domain_search",
775
779
  ];
776
- const PLUGIN_VERSION = "0.9.62";
780
+ const PLUGIN_VERSION = "0.9.64";
777
781
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
778
782
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
779
783
  const NAV_ITEMS = [
@@ -1108,6 +1112,7 @@ window.__ModuleLoader__.load({
1108
1112
  const [safeSearch, setSafeSearch] = react.useState("off");
1109
1113
  const [bingMarket, setBingMarket] = react.useState("zh-CN");
1110
1114
  const [fetchProviderTakeover, setFetchProviderTakeover] = react.useState(true);
1115
+ const [fetchProviderForce, setFetchProviderForce] = react.useState(false);
1111
1116
  const [browserFetch, setBrowserFetch] = react.useState(true);
1112
1117
  const [allowHttp, setAllowHttp] = react.useState(false);
1113
1118
  const [allowFakeIpCidrs, setAllowFakeIpCidrs] = react.useState("");
@@ -1451,6 +1456,7 @@ window.__ModuleLoader__.load({
1451
1456
  setSafeSearch(v.safeSearch === "strict" || v.safeSearch === "moderate" ? v.safeSearch : "off");
1452
1457
  setBingMarket(v.bingMarket === undefined ? "zh-CN" : v.bingMarket);
1453
1458
  setFetchProviderTakeover(v.fetchProviderTakeover !== false);
1459
+ setFetchProviderForce(v.fetchProviderForce === true);
1454
1460
  setBrowserFetch(v.browserFetch !== false);
1455
1461
  setAllowHttp(v.allowHttp === true);
1456
1462
  setAllowFakeIpCidrs((Array.isArray(v.allowFakeIpCidrs) ? v.allowFakeIpCidrs : []).join("\n"));
@@ -1664,6 +1670,7 @@ window.__ModuleLoader__.load({
1664
1670
  ops.push({ op: "set", path: ["safeSearch"], value: safeSearch });
1665
1671
  ops.push({ op: "set", path: ["bingMarket"], value: bingMarket });
1666
1672
  ops.push({ op: "set", path: ["fetchProviderTakeover"], value: fetchProviderTakeover });
1673
+ ops.push({ op: "set", path: ["fetchProviderForce"], value: fetchProviderForce });
1667
1674
  ops.push({ op: "set", path: ["googleCseId"], value: googleCx.trim() });
1668
1675
  ops.push({ op: "set", path: ["metasoScope"], value: metasoScope === "document" || metasoScope === "scholar" ? metasoScope : "webpage" });
1669
1676
  ops.push({ op: "set", path: ["yandexFolderId"], value: yandexFolder.trim() });
@@ -2870,6 +2877,32 @@ react_jsx_runtime.jsx("div", {
2870
2877
  }),
2871
2878
  ],
2872
2879
  }),
2880
+ react_jsx_runtime.jsx("div", {
2881
+ className: "dshfs-field",
2882
+ children: [
2883
+ react_jsx_runtime.jsx("label", {
2884
+ className: "dshfs-check",
2885
+ children: [
2886
+ react_jsx_runtime.jsx("input", {
2887
+ type: "checkbox",
2888
+ checked: fetchProviderForce,
2889
+ disabled: !ready || saving,
2890
+ onChange: (e) => {
2891
+ setFetchProviderForce(e.target.checked);
2892
+ setDirty(true);
2893
+ setFailed(false);
2894
+ setSaveError("");
2895
+ },
2896
+ }),
2897
+ react_jsx_runtime.jsx("span", { children: t.fetchForceLabel }),
2898
+ ],
2899
+ }),
2900
+ react_jsx_runtime.jsx("p", {
2901
+ className: "dshfs-hint",
2902
+ children: t.fetchForceHint,
2903
+ }),
2904
+ ],
2905
+ }),
2873
2906
  react_jsx_runtime.jsx("div", {
2874
2907
  className: "dshfs-field",
2875
2908
  children: [
@@ -1,12 +1,12 @@
1
1
  // 质量链 fetch provider:接管宿主 web_fetch(替代基础 http provider)。
2
- // T1 直连(跟随重定向,仅文本类内容)→ T2 exa contents($1/1000 页,清洗正文 markdown,文本质量好且便宜)
2
+ // T1 直连(http/https 均支持,按目标协议选 transport;跟随重定向,仅文本类内容)→ T2 exa contents($1/1000 页,清洗正文 markdown,文本质量好且便宜)
3
3
  // → T3 firecrawl(Markdown,反爬/JS/PDF)→ T4 crawl4ai(Markdown 备份)。
4
4
  // firecrawl 额度保护:仅在前层(直连/exa)失败时才走;exa 失败静默降级不抛。
5
5
  // 契约:WebFetchResult { url, statusCode, body: {kind:'html'|'text', content}, truncated }(CLOSED 联合类型)。
6
6
  // ponytail: 无服务级令牌桶——web_fetch 为单发用户/agent 驱动调用,非扇出;若未来批量调用再引入共享调度。
7
7
 
8
- import https from "node:https";
9
8
  import http from "node:http";
9
+ import https from "node:https";
10
10
  import zlib from "node:zlib";
11
11
  import { spawn } from "node:child_process";
12
12
  import { existsSync, mkdtempSync, rmSync } from "node:fs";
@@ -164,7 +164,7 @@ function decodeBody(buffer, contentType) {
164
164
  }
165
165
 
166
166
  /** GET 跟随重定向(≤5 跳),返回最终 URL / 状态 / 正文 / 内容类型;支持 gzip/br/deflate 解压。 */
167
- export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal, lookup, agent = null } = {}, transport = https) {
167
+ export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal, lookup, agent = null } = {}, transport = null) {
168
168
  return new Promise((resolve, reject) => {
169
169
  let settled = false;
170
170
  let activeReq = null;
@@ -212,9 +212,13 @@ export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal, l
212
212
  settle(false, error);
213
213
  return;
214
214
  }
215
+ const hopAgent = typeof agent === "function" ? agent(target.toString()) : agent;
216
+ // 按每一跳的协议选 transport:http 目标走明文,https 目标走 TLS;
217
+ // 跨协议的跳转(http → https、https → http)因此不会拿错模块。
218
+ const hopTransport = transport ?? (target.protocol === "http:" ? http : https);
215
219
  // 走代理时主机名由代理解析,transport 的 lookup 钩子不再生效;重定向的每一跳
216
220
  // 因此在这里显式过一遍 SSRF 校验,避免代理成为绕过守卫的通道。
217
- if (agent && lookup) {
221
+ if (hopAgent && lookup) {
218
222
  try {
219
223
  await new Promise((resolve, reject) => lookup(target.hostname, { all: true }, (error) => (error ? reject(error) : resolve(undefined))));
220
224
  } catch (error) {
@@ -223,7 +227,7 @@ export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal, l
223
227
  }
224
228
  if (settled) return;
225
229
  }
226
- const req = transport.request(
230
+ const req = hopTransport.request(
227
231
  {
228
232
  hostname: target.hostname,
229
233
  port: target.port || (target.protocol === "http:" ? 80 : 443),
@@ -231,8 +235,8 @@ export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal, l
231
235
  method: "GET",
232
236
  headers,
233
237
  timeout: timeoutMs,
234
- ...(lookup && !agent ? { lookup } : {}),
235
- ...(agent ? { agent } : {}),
238
+ ...(lookup && !hopAgent ? { lookup } : {}),
239
+ ...(hopAgent ? { agent: hopAgent } : {}),
236
240
  },
237
241
  (res) => {
238
242
  activeRes = res;
@@ -353,7 +357,6 @@ export function createFetchProvider({
353
357
  browserEnabled = () => true,
354
358
  prefer = () => "exa",
355
359
  allowedCidrs = () => [],
356
- allowHttp = () => false,
357
360
  validateUrl = assertPublicUrl,
358
361
  }) {
359
362
  // 每个 provider 实例按 proxy URL 复用同一条隧道 agent。
@@ -364,45 +367,31 @@ export function createFetchProvider({
364
367
  available() { return true; },
365
368
  async fetch(request, signal) {
366
369
  const url = String(request?.url || "");
367
- let target;
368
- try {
369
- target = new URL(url);
370
- } catch {
371
- throw new Error(`fs-quality-fetch: invalid URL (got "${url.slice(0, 60)}")`);
372
- }
373
- const isHttp = target.protocol === "http:";
374
- if (isHttp && !allowHttp()) {
375
- throw new Error(`fs-quality-fetch: http URLs require allowHttp (got "${url.slice(0, 60)}"); enable "Allow HTTP fetches" in Settings > Plugins > Free Search`);
376
- }
377
- if (!isHttp && target.protocol !== "https:") {
378
- throw new Error(`fs-quality-fetch: only https URLs are supported (got "${url.slice(0, 60)}")`);
379
- }
370
+ // 协议校验交给下面的 SSRF guard(只放行 http/https)。早期版本在这里直接
371
+ // 拒绝非 https 目标,等于把 T1 直连的限制提升成了 provider 级断言,连带把
372
+ // T1.5 浏览器和 T2/T3 第三方 tier 一起封杀(#143)。
380
373
  // SSRF guard: never fetch loopback / private / metadata addresses, and use a
381
374
  // lookup that re-checks every redirect hop. Explicitly allowed CIDRs cover
382
375
  // transparent-proxy fake-ip ranges (Clash/mihomo 198.18.0.0/15).
383
376
  const allowed = allowedCidrs();
384
- await validateUrl(url, { allowedCidrs: allowed, allowedProtocols: allowHttp() ? ["https:", "http:"] : ["https:"] });
377
+ await validateUrl(url, { allowedCidrs: allowed });
385
378
  const errors = [];
386
379
 
387
380
  // T1:直连(文本类内容;二进制交给后层——exa 取正文,PDF 等仍由 firecrawl 处理)
388
381
  try {
389
- const proxyUrl = proxyForTarget(url, readProxyEnv());
390
- const directUrl = isHttp ? `https://${target.host}${target.pathname}${target.search}` : url;
391
- if (isHttp && proxyUrl) {
392
- errors.push("direct: http target with a proxy is left to the browser/upstream tier");
393
- } else {
394
- const r = await httpsGetFollow(directUrl, {
395
- headers: browserishHeaders(acceptLanguage()),
396
- signal,
397
- lookup: makeSafeLookup(allowed),
398
- agent: isHttp ? null : agentForUrl(url, { settings: readProxyEnv(), cache: proxyAgents }),
399
- }, isHttp ? http : https);
400
- if (r.status < 400 && TEXTUAL.test(r.contentType) && r.text.length >= T1_MIN_CHARS) {
401
- return { url: r.url, statusCode: r.status, body: { kind: "html", content: stripLoneSurrogates(r.text) }, truncated: false };
402
- }
403
- if (r.status >= 400) errors.push(`direct HTTP ${r.status}`);
404
- else errors.push(`direct: ${r.contentType || "unknown type"} ${r.text.length}B`);
382
+ // 沿用宿主/环境里的代理配置:T1 用 node:http(s),看不到 undici 的全局 dispatcher。
383
+ // 每一跳按目标协议选 agent(http 走明文 CONNECT 隧道),重定向跨协议也成立。
384
+ const r = await httpsGetFollow(url, {
385
+ headers: browserishHeaders(acceptLanguage()),
386
+ signal,
387
+ lookup: makeSafeLookup(allowed),
388
+ agent: (target) => agentForUrl(target, { settings: readProxyEnv(), cache: proxyAgents }),
389
+ });
390
+ if (r.status < 400 && TEXTUAL.test(r.contentType) && r.text.length >= T1_MIN_CHARS) {
391
+ return { url: r.url, statusCode: r.status, body: { kind: "html", content: stripLoneSurrogates(r.text) }, truncated: false };
405
392
  }
393
+ if (r.status >= 400) errors.push(`direct HTTP ${r.status}`);
394
+ else errors.push(`direct: ${r.contentType || "unknown type"} ${r.text.length}B`);
406
395
  } catch (e) { errors.push(`direct: ${e.message}`); }
407
396
 
408
397
  // T1.5:系统浏览器无头渲染(执行 JS 过挑战,抓直连拿不到的页面;无浏览器或设置里关掉时跳过)