dsh-free-search 0.9.56 → 0.9.58

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
@@ -543,7 +543,7 @@ Search engine test:
543
543
  npx -y -p dsh-free-search dsh-free-search-mcp
544
544
  ```
545
545
 
546
- `web_search` 默认只自动调用免 key 的 Bing / DuckDuckGo;在参数或 `MCP_SEARCH_ENGINE` 里显式点名 `google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` 时才会使用付费引擎。支持 `time_range`(day/week/month/year)。`web_fetch` 仍走直连 / 浏览器 / Exa / Firecrawl。不暴露 `research`、`multi_search`,也不监听端口。Claude Desktop 配置示例:
546
+ `web_search` 默认只自动调用免 key 的 Bing / DuckDuckGo;在参数或 `MCP_SEARCH_ENGINE` 里显式点名 `google` / `baidu` / `brave` / `metaso` / `yandex` / `yuanbao` / `deepseek-tools` / `zhipu` 时才会使用付费引擎。支持 `time_range`(day/week/month/year)。`web_fetch` 仍走直连 / 浏览器 / Exa / Firecrawl。`multi_search` 并行合并多个引擎(默认只跑免费引擎),`domain_search` 直查包/论文/CVE/财报/金融/法律等垂直源,`weather` 查询 1–7 天天气;不暴露 `research`,也不监听端口。Claude Desktop 配置示例:
547
547
 
548
548
  ```json
549
549
  {
@@ -631,7 +631,7 @@ npx -y -p dsh-free-search dsh-free-search-mcp
631
631
 
632
632
  #### 离线自检断言(tools/)
633
633
 
634
- 仓库自带 **70 个**零依赖断言脚本(合计 **1032 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑。一次跑全部:`npm test`。
634
+ 仓库自带 **71 个**零依赖断言脚本(合计 **1045 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑。一次跑全部:`npm test`。
635
635
 
636
636
  | 脚本 | 覆盖 | 运行(项数) |
637
637
  |---|---|---|
@@ -661,8 +661,8 @@ npx -y -p dsh-free-search dsh-free-search-mcp
661
661
  | `assert-research-call-wrappers.mjs` | research 四个 `call*` 包装层的替身/底层透传(#75 回归) | `node tools/assert-research-call-wrappers.mjs`(23) |
662
662
  | `assert-fetch-chain.mjs` | `fs-quality-fetch` 四层链序、任一层命中即停、exa 失败静默降级 firecrawl、全层失败聚合报错 | `node tools/assert-fetch-chain.mjs`(8) |
663
663
  | `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、非 HTTPS 与带凭据 URL 拒绝、fake-ip 网段默认拒绝且仅按配置放行、IPv6 ULA 显式放行、放行后仍拒绝回环/IPv4 私网/链路本地、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(8) |
664
- | `assert-mcp.mjs` | MCP stdio 面:initialize 协议协商、tools/list 的 JSON Schema、tools/call 文本结果、工具错误与 JSON-RPC 错误区分、必填参数校验、显式付费引擎与新 provider、bin/files 打包 | `node tools/assert-mcp.mjs`(9) |
665
- | `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, bin/files packaging | `node tools/assert-mcp.mjs` (9) |
664
+ | `assert-mcp.mjs` | MCP stdio 面:initialize 协议协商、tools/list 的 JSON Schema、tools/call 文本结果、工具错误与 JSON-RPC 错误区分、必填参数校验、显式付费引擎与新 provider、multi/domain/weather 新工具、bin/files 打包 | `node tools/assert-mcp.mjs`(10) |
665
+ | `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, multi/domain/weather tools, bin/files packaging | `node tools/assert-mcp.mjs` (10) |
666
666
  | `assert-baidu.mjs` | 百度千帆:key 必填、web_search 首请求、403 或 results.code 额度错误回退 chat/completions(stream:false)、401 不回退、双端失败合并报错 | `node tools/assert-baidu.mjs`(6) |
667
667
  | `assert-deepseek-endpoint.mjs` | DeepSeek 搜索端点:默认地址、base/完整 URL 归一、自定义 endpoint 收 Bearer/key/query、配置与设置页接线 | `node tools/assert-deepseek-endpoint.mjs`(4) |
668
668
  | `assert-yuanbao.mjs` |key 必填、Bearer 网关/Query/Mode/Site/FromTime、自然与 VR 页面解析、日期归一、错误分类、注册与显式专用 | `node tools/assert-yuanbao.mjs`(6) |
@@ -703,6 +703,7 @@ npx -y -p dsh-free-search dsh-free-search-mcp
703
703
  | `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
704
704
  | `assert-fetch-charset.mjs` | 抓取编码(#88):`charset=gbk` / `gb2312` 按声明解码、无声明时嗅探 `<meta charset>` 与 http-equiv 形式、默认 UTF-8、未知 label 兜底 UTF-8 不抛错 | `node tools/assert-fetch-charset.mjs`(6) |
705
705
  | `assert-fetch-abort.mjs` | 抓取中断(#87):压缩响应中途断连必须 reject(不再永久 pending)、明文断连同样 reject、abort 能打断停滞的 gzip 流、complete 响应与重定向仍正常 | `node tools/assert-fetch-abort.mjs`(6) |
706
+ | `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) |
706
707
  | `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) |
707
708
  | `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) |
708
709
 
@@ -712,15 +713,27 @@ npx -y -p dsh-free-search dsh-free-search-mcp
712
713
 
713
714
  ### 代理说明(国内用户)
714
715
 
715
- DuckDuckGo 等引擎可能需要代理才能访问,而 Node.js 的 `fetch` 默认不走系统代理。需要给 dsh 进程设置(Node 24+):
716
+ 本插件有两条独立的出网路径,代理对两条都要配:
717
+
718
+ 1. **搜索**(`web_search` / `multi_search` / `advanced_search` / `platform_search` / `video_search` 等)走 `globalThis.fetch`(undici),是否代理由 undici 的全局 dispatcher 决定。
719
+ 2. **抓取正文**(`web_fetch` 与 `research` 的 T1 直连、T1.5 无头浏览器,以及 exa / firecrawl / crawl4ai 的云端调用)历史上直接用 `node:https` 与子进程,**既不读代理环境变量,也不受 undici dispatcher 影响**。所以会出现「搜索能通、抓取一直超时」——设置里的代理插件对第二层无效。现在这一层自己读代理环境变量,并为每一跳建立 HTTP `CONNECT` 隧道(浏览器 tier 则传 `--proxy-server`)。
720
+
721
+ 配置方式(`http_proxy` / `https_proxy` / `all_proxy` / `no_proxy`,大小写均可,小写优先,空值视为未设置):
716
722
 
717
723
  ```sh
718
- export NODE_USE_ENV_PROXY=1
719
724
  export HTTPS_PROXY=http://127.0.0.1:7897 # 你的代理地址
720
725
  export HTTP_PROXY=http://127.0.0.1:7897
726
+ export NO_PROXY=localhost,127.0.0.1,::1 # 可选
721
727
  ```
722
728
 
723
- Windows 用户:桌面快捷方式已内置此配置(`set NODE_USE_ENV_PROXY=1&& set HTTPS_PROXY=...`)。
729
+ - 只支持 `http://` / `https://` 代理(可带 Basic 认证);`socks5://` 会被忽略并直连。
730
+ - loopback 地址(`localhost`、`127.0.0.1`、`::1`、`127.0.0.0/8`)恒直连。
731
+ - `NO_PROXY` 支持逗号分隔的域名、`host:port` 与 `*`。
732
+ - 走代理时域名由代理端解析,`lookup` 钩子失效;因此重定向的每一跳都会先显式过一遍 SSRF 校验,`allowFakeIpCidrs` 等设置继续生效。
733
+ - 代理不可达时按原有逻辑降级到云端 tier,错误信息里会带 `proxy <host> refused CONNECT ...` 之类的具体原因。
734
+ - 不依赖 Node 24 的 `NODE_USE_ENV_PROXY`,Node ≥ 20 即可;该变量只影响 undici 那条路径。
735
+
736
+ Windows 用户:桌面快捷方式已内置 `NODE_USE_ENV_PROXY=1` + `HTTPS_PROXY`(`set NODE_USE_ENV_PROXY=1&& set HTTPS_PROXY=...`)。
724
737
 
725
738
  ### 工作原理
726
739
 
@@ -1267,7 +1280,7 @@ The repo also ships a standalone stdio MCP server for Claude Desktop, Cursor, Co
1267
1280
  npx -y -p dsh-free-search dsh-free-search-mcp
1268
1281
  ```
1269
1282
 
1270
- `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`. It supports `time_range` (day/week/month/year). `web_fetch` still uses direct / browser / Exa / Firecrawl. It does not expose `research` or `multi_search`, and it does not listen on a port. Claude Desktop example:
1283
+ `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`. It supports `time_range` (day/week/month/year). `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, and `weather` returns a 1-7 day forecast; `research` remains unavailable, and the server does not listen on a port. Claude Desktop example:
1271
1284
 
1272
1285
  ```json
1273
1286
  {
@@ -1355,7 +1368,7 @@ Restart `dsh web` after switching to apply changes.
1355
1368
 
1356
1369
  #### Offline self-check assertions (`tools/`)
1357
1370
 
1358
- **Seventy** zero-dependency assertion scripts ship with the repo (**1032 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20. Run everything with `npm test`.
1371
+ **Seventy-one** zero-dependency assertion scripts ship with the repo (**1045 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20. Run everything with `npm test`.
1359
1372
 
1360
1373
  | Script | Covers | Run (count) |
1361
1374
  |---|---|---|
@@ -1425,6 +1438,7 @@ Restart `dsh web` after switching to apply changes.
1425
1438
  | `assert-firecrawl-keyless.mjs` | Firecrawl keyless egress refusal: only a 403 with the VPN/proxy wording counts, plain 403 and 401/429/500 do not, and the cooldown starts inactive | `node tools/assert-firecrawl-keyless.mjs` (5) |
1426
1439
  | `assert-fetch-charset.mjs` | fetch encoding (#88): `charset=gbk` / `gb2312` decoded as declared, `<meta charset>` and the http-equiv form sniffed when the header omits it, UTF-8 by default, and an unknown label falls back to UTF-8 instead of throwing | `node tools/assert-fetch-charset.mjs` (6) |
1427
1440
  | `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) |
1441
+ | `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) |
1428
1442
  | `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) |
1429
1443
  | `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 the explicit `deepseek-fetch-api` switch, apply re-entry / duplicate registrations tolerated, and repeated logs deduplicated | `node tools/assert-provider-takeover.mjs` (20) |
1430
1444
 
@@ -1434,15 +1448,27 @@ Any failure exits non-zero with the failing items listed. Passing the path of an
1434
1448
 
1435
1449
  ### Proxy Note (for Users in Mainland China)
1436
1450
 
1437
- Engines like DuckDuckGo may require a proxy. Since Node.js `fetch` does not use the system proxy by default, set the following environment variables for the dsh process (Node 24+):
1451
+ This plugin has two independent outbound paths, and both need the proxy configured:
1452
+
1453
+ 1. **Search** (`web_search` / `multi_search` / `advanced_search` / `platform_search` / `video_search`, …) goes through `globalThis.fetch` (undici), so whether it is proxied depends on undici's global dispatcher.
1454
+ 2. **Body fetching** (`web_fetch`, plus the T1 direct fetch and T1.5 headless-browser tiers of `research`, and the exa / firecrawl / crawl4ai cloud calls) used plain `node:https` and child processes. That layer **never read the proxy environment variables and never saw the undici dispatcher**, which is why search works while fetching keeps timing out — a proxy plugin installed for undici cannot reach it. It now reads the proxy environment itself and opens an HTTP `CONNECT` tunnel per hop (the browser tier gets `--proxy-server` instead).
1455
+
1456
+ Configure (`http_proxy` / `https_proxy` / `all_proxy` / `no_proxy`, either case, lowercase wins, empty means unset):
1438
1457
 
1439
1458
  ```sh
1440
- export NODE_USE_ENV_PROXY=1
1441
1459
  export HTTPS_PROXY=http://127.0.0.1:7897 # Your proxy address
1442
1460
  export HTTP_PROXY=http://127.0.0.1:7897
1461
+ export NO_PROXY=localhost,127.0.0.1,::1 # Optional
1443
1462
  ```
1444
1463
 
1445
- Windows users: The desktop shortcut already includes this configuration (`set NODE_USE_ENV_PROXY=1&& set HTTPS_PROXY=...`).
1464
+ - Only `http://` / `https://` proxies are supported (Basic auth allowed); `socks5://` is ignored and the request goes direct.
1465
+ - Loopback addresses (`localhost`, `127.0.0.1`, `::1`, `127.0.0.0/8`) always go direct.
1466
+ - `NO_PROXY` accepts comma-separated domains, `host:port`, and `*`.
1467
+ - When proxied, the proxy resolves the hostname so the `lookup` hook no longer applies; every redirect hop is therefore re-checked by the SSRF guard explicitly, and settings such as `allowFakeIpCidrs` keep working.
1468
+ - If the proxy is unreachable the usual degradation to the cloud tiers still happens, and the error message names the reason (`proxy <host> refused CONNECT ...`).
1469
+ - This does not depend on Node 24's `NODE_USE_ENV_PROXY`; Node ≥ 20 is enough. That variable only affects the undici path.
1470
+
1471
+ Windows users: The desktop shortcut already includes `NODE_USE_ENV_PROXY=1` + `HTTPS_PROXY` (`set NODE_USE_ENV_PROXY=1&& set HTTPS_PROXY=...`).
1446
1472
 
1447
1473
  ### How It Works
1448
1474
 
package/lib/client.js CHANGED
@@ -769,7 +769,7 @@ window.__ModuleLoader__.load({
769
769
  "cache_search",
770
770
  "domain_search",
771
771
  ];
772
- const PLUGIN_VERSION = "0.9.56";
772
+ const PLUGIN_VERSION = "0.9.58";
773
773
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
774
774
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
775
775
  const NAV_ITEMS = [