dsh-free-search 0.9.41 → 0.9.42

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
@@ -34,7 +34,7 @@
34
34
  #### 引擎与切换
35
35
 
36
36
  - **零成本** —— 多个免费引擎,无需 key、无需注册
37
- - **36 个引擎可选**:DuckDuckGo(html/lite)、Bing、SearXNG(元搜索,支持自定义实例)、AnySearch、Exa、Tavily、Keenable、Firecrawl、Parallel、Perplexity、SerpBase、Serply、Outcrawl、Google 自定义搜索(`google`,需 API key + CSE ID)、DeepSeek 官方、DeepSeek 原生搜索 API、You.com、百度千帆、Kimi、阿里云百炼、火山联网搜索(豆包搜索)、知乎全网/站内(`zhihu_global`/`zhihu_site`,经知乎开放平台 MCP)、Antigravity CLI 搜索(`agy`,需本机安装)、OpenAI / Gemini / Claude 模型内置搜索。默认自动回退链覆盖其中 28 个;5 个 HTML SERP 引擎默认不参与,OpenAI / Gemini / Claude 三个按次计费引擎只在显式点名时运行。
37
+ - **37 个引擎可选**:DuckDuckGo(html/lite)、Bing、SearXNG(元搜索,支持自定义实例)、AnySearch、Exa、Tavily、Keenable、Firecrawl、Parallel、Perplexity、SerpBase、Serply、Outcrawl、Google 自定义搜索(`google`,需 API key + CSE ID)、秘塔搜索(`metaso`,官方 API,按点数计费)、DeepSeek 官方、DeepSeek 原生搜索 API、You.com、百度千帆、Kimi、阿里云百炼、火山联网搜索(豆包搜索)、知乎全网/站内(`zhihu_global`/`zhihu_site`,经知乎开放平台 MCP)、Antigravity CLI 搜索(`agy`,需本机安装)、OpenAI / Gemini / Claude 模型内置搜索。默认自动回退链覆盖其中 28 个;5 个 HTML SERP 引擎默认不参与,OpenAI / Gemini / Claude 三个模型引擎和 Metaso 都只在显式点名时运行。
38
38
  - **5 个 HTML 搜索页引擎(默认关闭)** —— 把传统搜索页并入同一套引擎 / 回退 / 冷却 / 设置体系:`baidu-html`(百度网页)、`so360`、`sogou`、`wechat`(微信文章)、`toutiao`。免 key、免额度,代价是抓页面:验证码/反爬按 `bot-wall` 归类并让整个家族冷却 10 分钟(整段出口 IP 都会被打标),结果也没有 API 摘要。它们默认不进 auto / 回退链 / 语言池,只在显式 `engine=` 或加入语言池时运行。
39
39
  - **引擎白名单** —— 设置页「只使用勾选的引擎」开启后,只有勾选的引擎可用,升级新增的引擎默认不启用;配置里对应 `allowedEngines`(非空时等价于把其余引擎全部禁用)。
40
40
  - **全局引擎开关与回退优先级** —— 设置页可勾选/取消引擎(取消后全局生效:普通搜索 / Auto / `advanced_search` / `multi_search` / 引擎测试都不再用它),并可用 ↑↓ 调整全局回退顺序(一键恢复默认)。
@@ -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 的先后顺序也可切换;私网、回环和云元数据地址一律拒绝(SSRF 防护)。
80
+ - **网页抓取(web_fetch)** —— 让 agent 抓取网页内容(官方 `dsh-web-fetch-http` provider,纯 JS,零额外依赖),可自动接管 `web.fetchProvider` 为插件的直连 → 浏览器渲染 → exa / firecrawl → crawl4ai 质量链。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>
@@ -149,6 +149,7 @@
149
149
  | `serply` | Serply | 付费 | 需 `SERPLY_API_KEY`(serply.io,新账户 30 天内 2,500 次免费额度);Google 网页结果,按设置页语言本地化 |
150
150
  | `outcrawl` | Outcrawl | 付费 | 需 `OUTCRAWL_API_KEY`(outcrawl.ai,每月 1,000 credits 免费额度);网页搜索结果(标题/链接/摘要),单次最多 20 条 |
151
151
  | `google` | Google 自定义搜索 | 免费额度 | 需 `GOOGLE_CSE_API_KEY` 和 Programmable Search Engine ID(`googleCseId` / cx);Google 官方 Custom Search JSON API,每天 100 次免费,按次计费超额;支持 `hl`、安全搜索和 `dateRestrict` 时间过滤 |
152
+ | `metaso` | 秘塔搜索 | 付费(点数) | 需 `METASO_API_KEY`(metaso.cn/api);官方 AI 搜索 API,按点数计费(约 0.03 元/次,新用户有体验额度);支持网页 / 文库 / 学术三种 `scope`,返回摘要和来源;不在默认回退顺序里,配 key 后显式选用 |
152
153
  | `deepseek-official` | DeepSeek 官方 | 付费 | 需 `DEEPSEEK_API_KEY`;走 Anthropic 兼容的 `web_search` 服务端工具,每次搜索是一整个模型轮次(慢、耗 token) |
153
154
  | `deepseek-tools` | DeepSeek 原生搜索 API | 付费 | 需 `DEEPSEEK_API_KEY`(与上一档共用);直接 `POST /v1/tools/search`,无模型参与,返回结构化 `results[]`(`title`/`url`/`summary`/`date`),同 query 实测 ~0.3s vs 上一档 ~5-6s |
154
155
  | `baidu` | 百度千帆 AI 搜索 | 额度 | 需 `BAIDU_API_KEY`(千帆 AI 搜索,每日赠 50 次,超额按量后付费);中文全网,支持时间过滤 |
@@ -279,7 +280,7 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
279
280
  配置页提供:
280
281
 
281
282
  - **Search engine**:下拉框切换引擎,保存即生效
282
- - **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / Outcrawl / Google CSE / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel / You.com 不填也可免 key 使用)
283
+ - **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / Outcrawl / Google CSE / Metaso / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel / You.com 不填也可免 key 使用)
283
284
  - **推荐**:付费引擎 key 建议写入 harness 凭据中心 `~/.dsh/.credentials.yaml`(如 `DEEPSEEK_API_KEY: sk-...`,与官方 LLM provider 一致,一处管理所有 key)。插件读取优先级:凭据中心 > 设置页 > 环境变量,设置页填的 key 仅作为遗留兼容。
284
285
  - **Test engine**:直测当前引擎可用性(不走回退链,付费引擎无 key 会明确报错)
285
286
  - **Use Bing default**:把当前搜索引擎切回稳定的免费 Bing;`Discard` 只撤销尚未保存的编辑
@@ -399,6 +400,7 @@ disabledTools: [] # 关掉的工具不再注册(例如 [domain_searc
399
400
  bingMarket: zh-CN # Bing 市场;留空 = 自动(不发送 mkt)
400
401
  fetchProviderTakeover: true # false = 保留你显式 pin 的 fetchProvider: http
401
402
  browserFetch: true # 直连失败时用系统浏览器无头渲染
403
+ allowFakeIpCidrs: [] # 显式放行的保留网段,例如 Clash/mihomo fake-ip 的 198.18.0.0/15
402
404
  fetchPrefer: exa # exa | firecrawl —— 两者都失败后先试哪个 keyed 抓取层
403
405
  region: cn-zh # DuckDuckGo 区域(可选)
404
406
  searxngInstances: # 自定义 SearXNG 实例(可选)
@@ -425,6 +427,8 @@ serplyApiKey: ... # 或通过设置页填写
425
427
  outcrawlApiKey: ... # 或通过设置页填写
426
428
  googleCseApiKey: ... # Google Custom Search API key
427
429
  googleCseId: "..." # Programmable Search Engine 的 cx
430
+ metasoApiKey: ... # Metaso API key (metaso.cn/api)
431
+ metasoScope: webpage # webpage | document | scholar
428
432
  deepseekApiKey: ...
429
433
  ```
430
434
 
@@ -512,7 +516,7 @@ Search engine test:
512
516
 
513
517
  - 自动跟随重定向、解码正文(HTML 转文本)
514
518
  - 支持超时和大小限制
515
- - ⚠️ 注意:`web_fetch` 无 SSRF 防护,agent 理论上可访问内网地址——按需使用
519
+ - ⚠️ 注意:`web_fetch` 默认拒绝回环、私网、链路本地和云元数据地址。若使用 Clash / mihomo TUN 的 fake-ip DNS,请把对应网段(常见 `198.18.0.0/15`)加入设置页的「额外允许的网段」,否则所有被代理域名都会被判成私网而抓取失败;只放行 fake-ip 保留段,不要放行 RFC1918。
516
520
 
517
521
  #### 平台搜索(platform_search)
518
522
 
@@ -586,7 +590,7 @@ Search engine test:
586
590
 
587
591
  #### 离线自检断言(tools/)
588
592
 
589
- 仓库自带 **55 个**零依赖断言脚本(合计 **827 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑。一次跑全部:`npm test`。
593
+ 仓库自带 **56 个**零依赖断言脚本(合计 **839 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑。一次跑全部:`npm test`。
590
594
 
591
595
  | 脚本 | 覆盖 | 运行(项数) |
592
596
  |---|---|---|
@@ -597,7 +601,7 @@ Search engine test:
597
601
  | `assert-multi-policy.mjs` | multi 执行策略:并发上限是天花板 / 目标成功源非硬下限 / 凭据资格在上限之前分流 / **Fast·Balanced·Deep 档位** | `node tools/assert-multi-policy.mjs`(146) |
598
602
  | `assert-multi-limit.mjs` | multi 结果上限(#109):默认 20 / 硬上限 100 / 配置归一化、单次 maxResults 受上限约束、工具参数与本段提示词写明生效上限、设置页字段与保存 | `node tools/assert-multi-limit.mjs`(6) |
599
603
  | `assert-maintenance.mjs` | 维护面:CI 在 Node 20/22/24 跑全部断言并过打包闸门、发布脚本会 bump / 校验 / 打 tag / 可发布、恢复官方 provider 的桥接与设置页按钮 | `node tools/assert-maintenance.mjs`(4) |
600
- | `assert-engine-modules.mjs` | 引擎分层:实现文件存在且被 index 引用、引擎函数已迁出 index、设置页引擎 id 与服务端清单一致、清单覆盖 36 个引擎且免费/按次标记正确、index 不引用引擎私有名 | `node tools/assert-engine-modules.mjs`(6) |
604
+ | `assert-engine-modules.mjs` | 引擎分层:实现文件存在且被 index 引用、引擎函数已迁出 index、设置页引擎 id 与服务端清单一致、清单覆盖 37 个引擎且免费/按次标记正确、index 不引用引擎私有名 | `node tools/assert-engine-modules.mjs`(6) |
601
605
  | `assert-bing-relevance.mjs` | Bing 相关性(#112):单字中文 token 被剔除、无关替代 SERP 被拒、真正相关的结果通过、只命中通用引擎名的整批被拒、单一 token 覆盖一半时放行、单字/纯数字查询的显式行为 | `node tools/assert-bing-relevance.mjs`(6) |
602
606
  | `assert-quality.mjs` | 研究证据闸门:8 源 / 3 域 / 3 正文 / 2 日期为 high,3 源 / 2 域 / 1 正文为 medium,单源与失败注记为 low,空包为 low,research 的 schema/输出/brief 接线 | `node tools/assert-quality.mjs`(6) |
603
607
  | `assert-dedupe.mjs` | 近重复去重:MinHash 同文本同签名、同 URL 去重、跨站转载去重、不同文章保留且顺序不变、阈值可调、provider 与 multi 两条路径接线 | `node tools/assert-dedupe.mjs`(6) |
@@ -608,7 +612,8 @@ Search engine test:
608
612
  | `assert-research-degradation.mjs` | research 无 key 全降级、`node:sqlite` no-op、90s 预算隔离、缓存目录可配置、`budget.exhausted` 契约名 | `node tools/assert-research-degradation.mjs`(19) |
609
613
  | `assert-research-call-wrappers.mjs` | research 四个 `call*` 包装层的替身/底层透传(#75 回归) | `node tools/assert-research-call-wrappers.mjs`(23) |
610
614
  | `assert-fetch-chain.mjs` | `fs-quality-fetch` 四层链序、任一层命中即停、exa 失败静默降级 firecrawl、全层失败聚合报错 | `node tools/assert-fetch-chain.mjs`(8) |
611
- | `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、非 HTTPS 与带凭据 URL 拒绝、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(6) |
615
+ | `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、非 HTTPS 与带凭据 URL 拒绝、fake-ip 网段默认拒绝且仅按配置放行、放行后仍拒绝回环/私网、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(8) |
616
+ | `assert-metaso.mjs` | 秘塔搜索:key 必填、请求体(q/scope/size/summary/raw/concise)、摘要与日期映射、文库数组、size 上限、无效 scope 回退、401/402/429/400 错误分类、注册与默认回退排除 | `node tools/assert-metaso.mjs`(6) |
612
617
  | `assert-google-cse.mjs` | Google Custom Search:key+ID 必填、请求参数(q/num/start/hl/safe/dateRestrict)、结果映射与发布日期、超过 10 条分页、403/429/400 错误分类、时间档映射、全链路注册 | `node tools/assert-google-cse.mjs`(6) |
613
618
  | `assert-engine-runtime.mjs` | 引擎运行时:按引擎并发上限(普通 2 / HTML SERP 1)、排队与 abort 清理、成功/空/失败/平均耗时统计、provider 与 runEngineTest 两条路径接线、诊断报告带 stats | `node tools/assert-engine-runtime.mjs`(4) |
614
619
  | `assert-single-fetch-layer.mjs` | 抓取层全库只有一份实现、依赖单向、替身键不串层 | `node tools/assert-single-fetch-layer.mjs`(22) |
@@ -695,7 +700,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
695
700
  #### Engines and switching
696
701
 
697
702
  - **Zero Cost** — Multiple free engines with no API key or registration required
698
- - **36 engines available** — DuckDuckGo (HTML / Lite), Bing, AnySearch AI, SearXNG (meta-search with custom instances), Exa, Tavily, Keenable, Firecrawl, Parallel, Perplexity, SerpBase, Serply, Outcrawl, Google Programmable Search (`google`, needs an API key plus a CSE ID), DeepSeek Official, DeepSeek Native Search API, You.com, Baidu Qianfan, Kimi, Aliyun Bailian, Volcano Doubao, Zhihu web-wide/site search (`zhihu_global`/`zhihu_site`, via the Zhihu open-platform MCP), Antigravity CLI search (`agy`, requires the local CLI), and the model-based OpenAI / Gemini / Claude searches. The default auto-fallback chain covers 28 of them; the 5 HTML SERP engines stay out by default and the per-call billed OpenAI / Gemini / Claude engines run only when explicitly named.
703
+ - **37 engines available** — DuckDuckGo (HTML / Lite), Bing, AnySearch AI, SearXNG (meta-search with custom instances), Exa, Tavily, Keenable, Firecrawl, Parallel, Perplexity, SerpBase, Serply, Outcrawl, Google Programmable Search (`google`, needs an API key plus a CSE ID), Metaso (秘塔搜索, official API, billed per call), DeepSeek Official, DeepSeek Native Search API, You.com, Baidu Qianfan, Kimi, Aliyun Bailian, Volcano Doubao, Zhihu web-wide/site search (`zhihu_global`/`zhihu_site`, via the Zhihu open-platform MCP), Antigravity CLI search (`agy`, requires the local CLI), and the model-based OpenAI / Gemini / Claude searches. The default auto-fallback chain covers 28 of them; the 5 HTML SERP engines stay out by default and the per-call billed OpenAI / Gemini / Claude engines and Metaso run only when explicitly named.
699
704
  - **5 HTML SERP engines (off by default)** — Traditional result pages join the same engine / fallback / cooldown / settings machinery: `baidu-html` (Baidu web), `so360`, `sogou`, `wechat` (WeChat articles) and `toutiao`. No key, no quota — the trade-off is scraping: captcha/anti-bot pages are classified as `bot-wall` and cool the whole family down for 10 minutes (the egress IP gets flagged as a whole), and results carry no API snippets. They never join auto routing, the fallback chain or the language pools; they only run when named via `engine=` or added to a pool.
700
705
  - **Engine whitelist** — turn on Use only the checked engines and only those engines stay usable; engines added by later versions stay off. It maps to `allowedEngines` in the config (a non-empty list is equivalent to disabling every other engine).
701
706
  - **Global engine enable/disable & fallback priority** — uncheck engines you never want (applies everywhere: web_search fallback, Auto routing, advanced_search, multi_search, engine tests) and reorder the global fallback chain with ↑↓ (one-click reset).
@@ -738,7 +743,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
738
743
 
739
744
  #### Fetch and tools
740
745
 
741
- - **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; loopback, private-network and cloud-metadata addresses are rejected (SSRF guard).
746
+ - **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; 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.
742
747
 
743
748
  <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%" />
744
749
  <sub>▲ Fetch: web_fetch takeover, key storage location and platform search switches</sub>
@@ -811,6 +816,7 @@ If this plugin has been helpful, a ⭐ on [GitHub](https://github.com/DDDMUC/dsh
811
816
  | `serply` | Serply | Paid | Requires `SERPLY_API_KEY` (serply.io, 2,500 free credits for the first 30 days); Google web results localized to the settings language |
812
817
  | `outcrawl` | Outcrawl | Paid | Requires `OUTCRAWL_API_KEY` (outcrawl.ai, free tier of 1,000 credits a month); web results with title, URL and snippet, up to 20 per search |
813
818
  | `google` | Google Programmable Search | Free quota | Requires `GOOGLE_CSE_API_KEY` and a Programmable Search Engine ID (`googleCseId` / cx); official Custom Search JSON API, 100 free queries/day then billed; supports `hl`, safe search and `dateRestrict` time filtering |
819
+ | `metaso` | Metaso (秘塔搜索) | Paid (credits) | Requires `METASO_API_KEY` (metaso.cn/api); official AI search API billed per call (about ¥0.03/query, trial credits for new accounts); supports webpage / document / scholar scopes and returns summaries with sources; not in the default fallback order, use it explicitly after configuring a key |
814
820
  | `deepseek-official` | DeepSeek Official | Paid | Requires `DEEPSEEK_API_KEY`; uses the Anthropic-compatible `web_search` server tool, so every search is a full model turn (slow, token-billed) |
815
821
  | `deepseek-tools` | DeepSeek Native Search API | Paid | Requires `DEEPSEEK_API_KEY` (shared with the row above); calls `POST /v1/tools/search` directly, no model involved, returns structured `results[]` (`title`/`url`/`summary`/`date`) — measured ~0.3s vs ~5-6s for the row above on the same query |
816
822
  | `baidu` | Baidu Qianfan AI Search | Quota | Requires `BAIDU_API_KEY` (Qianfan AI Search, 50 free calls/day then pay-as-you-go); Chinese web-wide, supports time filtering |
@@ -942,7 +948,7 @@ After installation, open the config page (DSH 0.2.1-rc.2+):
942
948
  The config page provides:
943
949
 
944
950
  - **Search engine**: Select an engine from the dropdown; changes take effect immediately upon saving.
945
- - **API keys**: Enter keys for Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / Google CSE / You.com (password fields; displayed as "configured" once saved; Exa / Tavily / Keenable / Firecrawl / Parallel / You.com work without a key too).
951
+ - **API keys**: Enter keys for Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / Google CSE / Metaso / You.com (password fields; displayed as "configured" once saved; Exa / Tavily / Keenable / Firecrawl / Parallel / You.com work without a key too).
946
952
  - **Recommended**: store paid-engine keys in the harness credential center `~/.dsh/.credentials.yaml` (e.g. `DEEPSEEK_API_KEY: sk-...`, same as the official LLM providers — one place for all keys). Resolution order: credentials center > settings page > environment variable; the settings-page fields remain for backward compatibility.
947
953
  - **Test engine**: Tests the selected engine directly (no fallback chain; paid engines without a key report an explicit error).
948
954
  - **Use Bing default**: stage a switch back to the stable free Bing engine; `Discard` only cancels unsaved edits
@@ -1062,6 +1068,7 @@ disabledTools: [] # tools that are not registered at all (e.g. [domain
1062
1068
  bingMarket: zh-CN # Bing market; empty = automatic (no mkt sent)
1063
1069
  fetchProviderTakeover: true # false = keep the fetchProvider: http you pinned yourself
1064
1070
  browserFetch: true # use the system browser headless renderer when direct fetch fails
1071
+ allowFakeIpCidrs: [] # reserved ranges to allow explicitly, e.g. 198.18.0.0/15 for Clash/mihomo fake-ip
1065
1072
  fetchPrefer: exa # exa | firecrawl — which keyed fetch tier to try first
1066
1073
  region: cn-zh # DuckDuckGo region (optional)
1067
1074
  searxngInstances: # Custom SearXNG instances (optional)
@@ -1088,6 +1095,8 @@ serplyApiKey: ... # Or configure via the web settings UI
1088
1095
  outcrawlApiKey: ... # Or configure via the web settings UI
1089
1096
  googleCseApiKey: ... # Google Custom Search API key
1090
1097
  googleCseId: "..." # Programmable Search Engine cx
1098
+ metasoApiKey: ... # Metaso API key (metaso.cn/api)
1099
+ metasoScope: webpage # webpage | document | scholar
1091
1100
  deepseekApiKey: ...
1092
1101
  ```
1093
1102
 
@@ -1175,7 +1184,7 @@ After searching, the agent can **read full webpage content** (e.g., *"Open the f
1175
1184
 
1176
1185
  - Automatically follows redirects and decodes HTML to plain text.
1177
1186
  - Supports timeout and response size limits.
1178
- - ⚠️ Note: `web_fetch` does not have SSRF protection; the agent could theoretically access internal network addresses. Use as needed.
1187
+ - ⚠️ 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 fake-ip reserved ranges, never RFC1918.
1179
1188
 
1180
1189
  #### Platform Search (`platform_search`)
1181
1190
 
@@ -1249,7 +1258,7 @@ Restart `dsh web` after switching to apply changes.
1249
1258
 
1250
1259
  #### Offline self-check assertions (`tools/`)
1251
1260
 
1252
- **Fifty-five** zero-dependency assertion scripts ship with the repo (**827 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20. Run everything with `npm test`.
1261
+ **Fifty-six** zero-dependency assertion scripts ship with the repo (**839 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20. Run everything with `npm test`.
1253
1262
 
1254
1263
  | Script | Covers | Run (count) |
1255
1264
  |---|---|---|
@@ -1260,7 +1269,7 @@ Restart `dsh web` after switching to apply changes.
1260
1269
  | `assert-multi-policy.mjs` | multi execution policy: ceiling semantics / target-is-not-a-hard-minimum / credential eligibility before the ceiling / **Fast·Balanced·Deep presets** | `node tools/assert-multi-policy.mjs` (146) |
1261
1270
  | `assert-multi-limit.mjs` | Multi result ceiling (#109): default 20 / hard max 100 / config normalisation, per-call maxResults clamped to the ceiling, tool copy and prompt state name the effective limit, settings field and save path | `node tools/assert-multi-limit.mjs` (6) |
1262
1271
  | `assert-maintenance.mjs` | Maintenance surface: CI runs every assertion on Node 20/22/24 plus the packaging gate, the release script bumps / verifies / tags / can publish, and the restore-official-provider bridge and settings button are wired | `node tools/assert-maintenance.mjs` (4) |
1263
- | `assert-engine-modules.mjs` | Engine layout: module files exist and are imported, implementations have left index.js, the client engine ids match the server catalog, the catalog covers 36 engines with the right free/explicit flags, and index never reads an engine-private name | `node tools/assert-engine-modules.mjs` (6) |
1272
+ | `assert-engine-modules.mjs` | Engine layout: module files exist and are imported, implementations have left index.js, the client engine ids match the server catalog, the catalog covers 37 engines with the right free/explicit flags, and index never reads an engine-private name | `node tools/assert-engine-modules.mjs` (6) |
1264
1273
  | `assert-bing-relevance.mjs` | Bing relevance (#112): single-character CJK tokens removed, an unrelated substituted SERP rejected, genuinely relevant results accepted, a batch matching only a generic engine name rejected, one distinctive token covering half the query accepted, and explicit single-character/numeric behaviour | `node tools/assert-bing-relevance.mjs` (6) |
1265
1274
  | `assert-quality.mjs` | Research evidence gate: 8 sources / 3 domains / 3 bodies / 2 dates is high, 3 / 2 / 1 is medium, a single source or a degraded note is low, an empty package is low, and research wires the gate into schema, output and brief | `node tools/assert-quality.mjs` (6) |
1266
1275
  | `assert-dedupe.mjs` | Near-duplicate removal: identical text shares a MinHash signature, exact URLs and cross-site copies are dropped, different articles survive in order, the threshold is configurable, and both the provider and multi paths run it | `node tools/assert-dedupe.mjs` (6) |
@@ -1271,7 +1280,8 @@ Restart `dsh web` after switching to apply changes.
1271
1280
  | `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) |
1272
1281
  | `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) |
1273
1282
  | `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) |
1274
- | `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, provider wiring and settings | `node tools/assert-fetch-ssrf.mjs` (6) |
1283
+ | `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, loopback/RFC1918 still blocked after opt-in, provider wiring and settings | `node tools/assert-fetch-ssrf.mjs` (8) |
1284
+ | `assert-metaso.mjs` | Metaso search: key required, request body (q/scope/size/summary/raw/concise), summary and date mapping, document array, size clamp, invalid scope fallback, 401/402/429/400 error classes, registration and default-chain exclusion | `node tools/assert-metaso.mjs` (6) |
1275
1285
  | `assert-google-cse.mjs` | Google Custom Search: key + ID required, request params (q/num/start/hl/safe/dateRestrict), result mapping with dates, pagination past ten results, 403/429/400 classification, time-range mapping, full registration | `node tools/assert-google-cse.mjs` (6) |
1276
1286
  | `assert-engine-runtime.mjs` | Engine runtime: per-engine concurrency caps (2 normally, 1 for HTML SERP), queueing with abort cleanup, ok/empty/fail/average-latency stats, wiring on both the provider and runEngineTest paths, and stats in the doctor report | `node tools/assert-engine-runtime.mjs` (4) |
1277
1287
  | `assert-single-fetch-layer.mjs` | exactly one fetch implementation repo-wide, one-way deps, seams owned by the right layer | `node tools/assert-single-fetch-layer.mjs` (22) |
package/lib/client.js CHANGED
@@ -431,12 +431,21 @@ window.__ModuleLoader__.load({
431
431
  fetchTakeoverHint: "开启时:web.fetchProvider 未设置或仍是出厂默认 http 会接管为 fs-quality-fetch。如果你刻意 pin 了 http(例如只想用内置抓取),关掉此项。",
432
432
  browserFetchLabel: "用本机浏览器渲染",
433
433
  browserFetchHint: "直连失败时用系统 Chrome/Edge 无头加载页面,能过 JS 挑战;没有浏览器时自动跳过。",
434
+ fakeIpCidrsLabel: "额外允许的网段(fake-ip 透明代理)",
435
+ fakeIpCidrsHint: "一行一个 CIDR。Clash/mihomo TUN 的 fake-ip 通常是 198.18.0.0/15;只豁免这里列出的保留段,回环、私网、链路本地和云元数据仍会被拦截。",
434
436
  fetchPreferLabel: "抓取质量链顺序",
435
437
  fetchPreferExa: "Exa 优先",
436
438
  fetchPreferFirecrawl: "Firecrawl 优先",
437
439
  fetchPreferHint: "直连和浏览器都失败后先试哪个;只有两个都配了 key 时才有区别。",
438
440
  googleCseIdLabel: "Google 搜索引擎 ID",
439
441
  googleCseIdHint: "Programmable Search Engine 的 cx(形如 0123…:abc…);配合 GOOGLE_CSE_API_KEY 使用,免费 100 次/天。",
442
+ metasoKeyLabel: "秘塔 API key",
443
+ metasoKeyHint: "在 metaso.cn/api 创建;按点数计费,新用户有体验额度。",
444
+ metasoScopeLabel: "秘塔搜索范围",
445
+ metasoScopeWebpage: "网页",
446
+ metasoScopeDocument: "文库",
447
+ metasoScopeScholar: "学术",
448
+ metasoScopeHint: "网页最通用;文库面向 PDF/文档,学术面向论文,单次消耗更高。",
440
449
  restoreOfficial: "恢复官方搜索",
441
450
  restoreOfficialHint: "把 web.searchProvider 改回 deepseek-official、web.fetchProvider 改回 http。停用或卸载本插件前建议先点一次,避免宿主报 configured web provider \"ddg\" is not registered。",
442
451
  restoringOfficial: "恢复中…",
@@ -595,12 +604,21 @@ window.__ModuleLoader__.load({
595
604
  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).",
596
605
  browserFetchLabel: "Render with the local browser",
597
606
  browserFetchHint: "When direct fetch fails, load the page in headless Chrome/Edge to pass JS challenges; skipped when no browser is installed.",
607
+ fakeIpCidrsLabel: "Extra allowed networks (fake-ip proxy)",
608
+ fakeIpCidrsHint: "One CIDR per line. Clash/mihomo TUN fake-ip commonly uses 198.18.0.0/15; only the ranges listed here are exempted. Loopback, RFC1918, link-local and cloud metadata stay blocked.",
598
609
  fetchPreferLabel: "Fetch quality-chain order",
599
610
  fetchPreferExa: "Exa first",
600
611
  fetchPreferFirecrawl: "Firecrawl first",
601
612
  fetchPreferHint: "Which keyed tier to try first after direct and browser both fail; only matters when both keys are configured.",
602
613
  googleCseIdLabel: "Google Programmable Search engine ID",
603
614
  googleCseIdHint: "The cx from Programmable Search Engine (looks like 0123…:abc…); used with GOOGLE_CSE_API_KEY, free 100 queries/day.",
615
+ metasoKeyLabel: "Metaso API key",
616
+ metasoKeyHint: "Create one at metaso.cn/api; billed per call, new accounts get trial credits.",
617
+ metasoScopeLabel: "Metaso search scope",
618
+ metasoScopeWebpage: "Webpages",
619
+ metasoScopeDocument: "Documents",
620
+ metasoScopeScholar: "Scholars",
621
+ metasoScopeHint: "Webpages is the general default; documents targets PDFs/files and scholars targets papers, both cost more per call.",
604
622
  restoreOfficial: "Restore official search",
605
623
  restoreOfficialHint: "Sets web.searchProvider back to deepseek-official and web.fetchProvider back to http. Run this before disabling or uninstalling the plugin, otherwise the host reports configured web provider \"ddg\" is not registered.",
606
624
  restoringOfficial: "Restoring…",
@@ -650,7 +668,7 @@ window.__ModuleLoader__.load({
650
668
  "cache_search",
651
669
  "domain_search",
652
670
  ];
653
- const PLUGIN_VERSION = "0.9.41";
671
+ const PLUGIN_VERSION = "0.9.42";
654
672
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
655
673
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
656
674
  const NAV_ITEMS = [
@@ -691,6 +709,7 @@ window.__ModuleLoader__.load({
691
709
  { id: "serply", label: "Serply · Google", badge: "API KEY", link: "https://serply.io" },
692
710
  { id: "outcrawl", label: "Outcrawl", badge: "API KEY", link: "https://outcrawl.ai" },
693
711
  { id: "google", label: "Google · 自定义搜索", badge: "API KEY", link: "https://developers.google.com/custom-search/v1/overview" },
712
+ { id: "metaso", label: "Metaso · 秘塔搜索", badge: "API KEY", link: "https://metaso.cn/api" },
694
713
  { id: "deepseek-official", label: "DeepSeek Official", badge: "API KEY", link: "https://platform.deepseek.com/api_keys" },
695
714
  { id: "deepseek-tools", label: "DeepSeek Tools API", badge: "API KEY", link: "https://api-docs.deepseek.com/zh-cn/guides/search" },
696
715
  { id: "you", label: "You.com", badge: "FREE", link: "https://you.com/platform/api-keys" },
@@ -714,10 +733,10 @@ window.__ModuleLoader__.load({
714
733
  ];
715
734
  const ENGINE_IDS = ENGINES.filter((engine) => engine.id !== "auto" && engine.id !== "multi").map((engine) => engine.id);
716
735
  // 与 lib/index.js 的 EXPLICIT_ONLY_ENGINES 同源:按次计费、只在显式选中时运行,因此不提供入池候选。
717
- const EXPLICIT_ONLY_ENGINES = ["openai", "gemini", "claude"];
736
+ const EXPLICIT_ONLY_ENGINES = ["openai", "gemini", "claude", "metaso"];
718
737
  // 与 lib/serp_engines.js 的 SERP_ENGINE_IDS 同源:HTML 抓取型引擎,默认不进自动回退链。
719
738
  const SERP_ENGINE_IDS = ["baidu-html", "so360", "sogou", "wechat", "toutiao"];
720
- const MODEL_ENGINES = ENGINES.filter((engine) => EXPLICIT_ONLY_ENGINES.includes(engine.id));
739
+ const MODEL_ENGINES = ENGINES.filter((engine) => EXPLICIT_ONLY_ENGINES.includes(engine.id) && engine.id !== "metaso");
721
740
  const DEFAULT_FALLBACK_ORDER = ["exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "outcrawl", "agy", "deepseek-tools", "deepseek-official", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "bing", "anysearch", "ddg", "ddg-lite", "searxng", "degoog", "zhihu_global", "zhihu_site"];
722
741
  const normalizeFallbackOrder = (value) => {
723
742
  const configured = Array.isArray(value) ? value.filter((id) => ENGINE_IDS.includes(id)) : [];
@@ -916,6 +935,7 @@ window.__ModuleLoader__.load({
916
935
  const [bingMarket, setBingMarket] = react.useState("zh-CN");
917
936
  const [fetchProviderTakeover, setFetchProviderTakeover] = react.useState(true);
918
937
  const [browserFetch, setBrowserFetch] = react.useState(true);
938
+ const [allowFakeIpCidrs, setAllowFakeIpCidrs] = react.useState("");
919
939
  const [fetchPrefer, setFetchPrefer] = react.useState("exa");
920
940
  const [anysearchKey, setAnysearchKey] = react.useState("");
921
941
  const [exaKey, setExaKey] = react.useState("");
@@ -930,6 +950,8 @@ window.__ModuleLoader__.load({
930
950
  const [outcrawlKey, setOutcrawlKey] = react.useState("");
931
951
  const [googleKey, setGoogleKey] = react.useState("");
932
952
  const [googleCx, setGoogleCx] = react.useState("");
953
+ const [metasoKey, setMetasoKey] = react.useState("");
954
+ const [metasoScope, setMetasoScope] = react.useState("webpage");
933
955
  const [youcomKey, setYoucomKey] = react.useState("");
934
956
  const [baiduKey, setBaiduKey] = react.useState("");
935
957
  const [kimiKey, setKimiKey] = react.useState("");
@@ -1082,6 +1104,7 @@ window.__ModuleLoader__.load({
1082
1104
  setBingMarket(v.bingMarket === undefined ? "zh-CN" : v.bingMarket);
1083
1105
  setFetchProviderTakeover(v.fetchProviderTakeover !== false);
1084
1106
  setBrowserFetch(v.browserFetch !== false);
1107
+ setAllowFakeIpCidrs((Array.isArray(v.allowFakeIpCidrs) ? v.allowFakeIpCidrs : []).join("\n"));
1085
1108
  setFetchPrefer(v.fetchPrefer === "firecrawl" ? "firecrawl" : "exa");
1086
1109
  setLang(v.lang ?? "zh");
1087
1110
  setUiLang(typeof v.uiLang === "string" ? v.uiLang : "");
@@ -1105,6 +1128,8 @@ window.__ModuleLoader__.load({
1105
1128
  setOutcrawlKey(v.outcrawlApiKey ?? "");
1106
1129
  setGoogleKey(v.googleCseApiKey ?? "");
1107
1130
  setGoogleCx(v.googleCseId ?? "");
1131
+ setMetasoKey(v.metasoApiKey ?? "");
1132
+ setMetasoScope(v.metasoScope === "document" || v.metasoScope === "scholar" ? v.metasoScope : "webpage");
1108
1133
  setYoucomKey(v.youcomApiKey ?? "");
1109
1134
  setBaiduKey(v.baiduApiKey ?? "");
1110
1135
  setKimiKey(v.kimiApiKey ?? "");
@@ -1154,6 +1179,7 @@ window.__ModuleLoader__.load({
1154
1179
  if (path === "searxngBearerToken") configured.searxng = true;
1155
1180
  if (path === "degoogApiKey") configured.degoog = true;
1156
1181
  if (path === "googleCseApiKey") configured.google = true;
1182
+ if (path === "metasoApiKey") configured.metaso = true;
1157
1183
  }
1158
1184
  }
1159
1185
  setKeysConfigured(configured);
@@ -1165,7 +1191,7 @@ window.__ModuleLoader__.load({
1165
1191
  const cred = await bridgeCredentialsStatus();
1166
1192
  if (cred.ok) {
1167
1193
  const cc = {};
1168
- const map = { anysearchApiKey: "anysearch", exaApiKey: "exa", tavilyApiKey: "tavily", keenableApiKey: "keenable", firecrawlApiKey: "firecrawl", parallelApiKey: "parallel", perplexityApiKey: "perplexity", deepseekApiKey: "deepseek", serpbaseApiKey: "serpbase", serplyApiKey: "serply", outcrawlApiKey: "outcrawl", youcomApiKey: "youcom", degoogApiKey: "degoog", googleCseApiKey: "google", baiduApiKey: "baidu", kimiApiKey: "kimi", aliyunApiKey: "aliyun", doubaoApiKey: "doubao", openaiApiKey: "openai", geminiApiKey: "gemini", claudeApiKey: "claude", zhihuApiKey: "zhihu", tinyfishApiKey: "tinyfish", jinaApiKey: "jina", searxngBearerToken: "searxng" };
1194
+ const map = { anysearchApiKey: "anysearch", exaApiKey: "exa", tavilyApiKey: "tavily", keenableApiKey: "keenable", firecrawlApiKey: "firecrawl", parallelApiKey: "parallel", perplexityApiKey: "perplexity", deepseekApiKey: "deepseek", serpbaseApiKey: "serpbase", serplyApiKey: "serply", outcrawlApiKey: "outcrawl", youcomApiKey: "youcom", degoogApiKey: "degoog", googleCseApiKey: "google", metasoApiKey: "metaso", baiduApiKey: "baidu", kimiApiKey: "kimi", aliyunApiKey: "aliyun", doubaoApiKey: "doubao", openaiApiKey: "openai", geminiApiKey: "gemini", claudeApiKey: "claude", zhihuApiKey: "zhihu", tinyfishApiKey: "tinyfish", jinaApiKey: "jina", searxngBearerToken: "searxng" };
1169
1195
  for (const [k, v] of Object.entries(cred.value.configured ?? {})) {
1170
1196
  if (map[k]) cc[map[k]] = v;
1171
1197
  }
@@ -1214,6 +1240,7 @@ window.__ModuleLoader__.load({
1214
1240
  ["serplyApiKey", serplyKey],
1215
1241
  ["outcrawlApiKey", outcrawlKey],
1216
1242
  ["googleCseApiKey", googleKey],
1243
+ ["metasoApiKey", metasoKey],
1217
1244
  ["youcomApiKey", youcomKey],
1218
1245
  ["baiduApiKey", baiduKey],
1219
1246
  ["kimiApiKey", kimiKey],
@@ -1260,7 +1287,13 @@ window.__ModuleLoader__.load({
1260
1287
  ops.push({ op: "set", path: ["bingMarket"], value: bingMarket });
1261
1288
  ops.push({ op: "set", path: ["fetchProviderTakeover"], value: fetchProviderTakeover });
1262
1289
  ops.push({ op: "set", path: ["googleCseId"], value: googleCx.trim() });
1290
+ ops.push({ op: "set", path: ["metasoScope"], value: metasoScope === "document" || metasoScope === "scholar" ? metasoScope : "webpage" });
1263
1291
  ops.push({ op: "set", path: ["browserFetch"], value: browserFetch });
1292
+ ops.push({
1293
+ op: "set",
1294
+ path: ["allowFakeIpCidrs"],
1295
+ value: [...new Set(String(allowFakeIpCidrs ?? "").split(/[\s,]+/).map((s) => s.trim()).filter(Boolean))],
1296
+ });
1264
1297
  ops.push({ op: "set", path: ["fetchPrefer"], value: fetchPrefer === "firecrawl" ? "firecrawl" : "exa" });
1265
1298
  if (keyStorage !== "credentials") {
1266
1299
  // settings 模式:key 写入当前 profile 的插件条目 config(cordis.patch.yml)
@@ -2034,6 +2067,63 @@ react_jsx_runtime.jsx("div", {
2034
2067
  }),
2035
2068
  ],
2036
2069
  }),
2070
+ react_jsx_runtime.jsx("div", {
2071
+ className: "dshfs-field",
2072
+ children: [
2073
+ react_jsx_runtime.jsx("div", {
2074
+ className: "dshfs-label",
2075
+ children: t.metasoKeyLabel,
2076
+ }),
2077
+ react_jsx_runtime.jsx("input", {
2078
+ className: "dshfs-input",
2079
+ type: "password",
2080
+ value: metasoKey,
2081
+ spellCheck: false,
2082
+ placeholder: "API key",
2083
+ disabled: !ready || saving,
2084
+ onChange: (e) => {
2085
+ setMetasoKey(e.target.value);
2086
+ setDirty(true);
2087
+ setFailed(false);
2088
+ setSaveError("");
2089
+ },
2090
+ }),
2091
+ react_jsx_runtime.jsx("p", {
2092
+ className: "dshfs-hint",
2093
+ children: t.metasoKeyHint,
2094
+ }),
2095
+ ],
2096
+ }),
2097
+ react_jsx_runtime.jsx("div", {
2098
+ className: "dshfs-field",
2099
+ children: [
2100
+ react_jsx_runtime.jsx("div", {
2101
+ className: "dshfs-label",
2102
+ children: t.metasoScopeLabel,
2103
+ }),
2104
+ react_jsx_runtime.jsx("select", {
2105
+ className: "dshfs-select",
2106
+ value: metasoScope,
2107
+ style: { colorScheme: selectColorScheme },
2108
+ disabled: !ready || saving,
2109
+ onChange: (e) => {
2110
+ setMetasoScope(e.target.value === "document" || e.target.value === "scholar" ? e.target.value : "webpage");
2111
+ setDirty(true);
2112
+ setFailed(false);
2113
+ setSaveError("");
2114
+ },
2115
+ children: [
2116
+ react_jsx_runtime.jsx("option", { value: "webpage", children: t.metasoScopeWebpage }),
2117
+ react_jsx_runtime.jsx("option", { value: "document", children: t.metasoScopeDocument }),
2118
+ react_jsx_runtime.jsx("option", { value: "scholar", children: t.metasoScopeScholar }),
2119
+ ],
2120
+ }),
2121
+ react_jsx_runtime.jsx("p", {
2122
+ className: "dshfs-hint",
2123
+ children: t.metasoScopeHint,
2124
+ }),
2125
+ ],
2126
+ }),
2037
2127
  react_jsx_runtime.jsx("div", {
2038
2128
  className: "dshfs-field",
2039
2129
  id: "dshfs-anchor-fallback",
@@ -2388,6 +2478,33 @@ react_jsx_runtime.jsx("div", {
2388
2478
  }),
2389
2479
  ],
2390
2480
  }),
2481
+ react_jsx_runtime.jsx("div", {
2482
+ className: "dshfs-field",
2483
+ children: [
2484
+ react_jsx_runtime.jsx("div", {
2485
+ className: "dshfs-label",
2486
+ children: t.fakeIpCidrsLabel,
2487
+ }),
2488
+ react_jsx_runtime.jsx("textarea", {
2489
+ className: "dshfs-textarea",
2490
+ rows: 3,
2491
+ placeholder: "198.18.0.0/15",
2492
+ value: allowFakeIpCidrs,
2493
+ spellCheck: false,
2494
+ disabled: !ready || saving,
2495
+ onChange: (e) => {
2496
+ setAllowFakeIpCidrs(e.target.value);
2497
+ setDirty(true);
2498
+ setFailed(false);
2499
+ setSaveError("");
2500
+ },
2501
+ }),
2502
+ react_jsx_runtime.jsx("p", {
2503
+ className: "dshfs-hint",
2504
+ children: t.fakeIpCidrsHint,
2505
+ }),
2506
+ ],
2507
+ }),
2391
2508
  react_jsx_runtime.jsx("div", {
2392
2509
  className: "dshfs-field",
2393
2510
  children: [
@@ -24,6 +24,7 @@ const BASE_ENGINES = [
24
24
  { id: "serply", free: false, time: false },
25
25
  { id: "outcrawl", free: false, time: false },
26
26
  { id: "google", free: false, time: true },
27
+ { id: "metaso", free: false, time: false, explicitOnly: true },
27
28
  { id: "deepseek-official", free: false, time: false },
28
29
  { id: "deepseek-tools", free: false, time: true },
29
30
  { id: "you", free: false, time: false },
@@ -0,0 +1,112 @@
1
+ // Metaso (秘塔搜索) official search API.
2
+ // POST https://metaso.cn/api/v1/search with a Bearer key; billed per call,
3
+ // so this engine is keyed and deliberately absent from the default fallback.
4
+ import { uniqueSources } from "./shared.js";
5
+
6
+ const METASO_URL = "https://metaso.cn/api/v1/search";
7
+ const MAX_RESULTS = 50;
8
+
9
+ export const METASO_SCOPES = ["webpage", "document", "scholar"];
10
+
11
+ const RESULT_ARRAYS = {
12
+ webpage: "webpages",
13
+ document: "documents",
14
+ scholar: "scholars",
15
+ };
16
+
17
+ export function normalizeMetasoScope(value) {
18
+ const scope = String(value ?? "").trim().toLowerCase();
19
+ return METASO_SCOPES.includes(scope) ? scope : "webpage";
20
+ }
21
+
22
+ function metasoErrorMessage(status, detail) {
23
+ let upstream = "";
24
+ try {
25
+ const parsed = JSON.parse(detail);
26
+ upstream = parsed?.message ?? parsed?.error ?? "";
27
+ } catch {}
28
+ const suffix = upstream ? `: ${String(upstream).slice(0, 200)}` : "";
29
+ if (status === 401) {
30
+ return "Metaso API key is invalid (HTTP 401) - update it in Settings > Plugins > Free Search";
31
+ }
32
+ if (status === 402) return `Metaso account has no usable credits (HTTP 402)${suffix}`;
33
+ if (status === 429) return `Metaso quota/rate limit exceeded (HTTP 429)${suffix}`;
34
+ if (status === 400) return `Metaso search request failed (HTTP 400)${suffix} - check the API key and scope`;
35
+ return `Metaso API error (HTTP ${status})${suffix}`;
36
+ }
37
+
38
+ function publishedDate(value) {
39
+ const text = String(value ?? "").trim();
40
+ return /^\d{4}-\d{2}-\d{2}/.test(text) ? text.slice(0, 10) : "";
41
+ }
42
+
43
+ export async function searchMetaso(query, maxResults, apiKey, scope, _timeRange, signal) {
44
+ if (!apiKey) throw new Error("Metaso search requires METASO_API_KEY");
45
+ const limit = Math.min(Math.max(Number(maxResults) || 10, 1), MAX_RESULTS);
46
+ const normalizedScope = normalizeMetasoScope(scope);
47
+
48
+ const controller = new AbortController();
49
+ const timer = setTimeout(() => controller.abort(), 30000);
50
+ const onAbort = () => controller.abort();
51
+ signal?.addEventListener("abort", onAbort);
52
+
53
+ let response;
54
+ try {
55
+ response = await fetch(METASO_URL, {
56
+ method: "POST",
57
+ redirect: "error",
58
+ headers: {
59
+ authorization: `Bearer ${apiKey}`,
60
+ "content-type": "application/json",
61
+ accept: "application/json",
62
+ "user-agent": "deepseek-harness/free-search",
63
+ },
64
+ body: JSON.stringify({
65
+ q: query,
66
+ scope: normalizedScope,
67
+ size: limit,
68
+ includeSummary: true,
69
+ includeRawContent: false,
70
+ conciseSnippet: true,
71
+ }),
72
+ signal: controller.signal,
73
+ });
74
+ } catch (error) {
75
+ if (signal?.aborted) throw error;
76
+ if (error?.name === "AbortError") throw new Error("Metaso request timed out");
77
+ throw new Error(`Metaso request failed: ${error?.message ?? String(error)}`);
78
+ } finally {
79
+ clearTimeout(timer);
80
+ signal?.removeEventListener("abort", onAbort);
81
+ }
82
+
83
+ if (!response.ok) {
84
+ const detail = await response.text().catch(() => "");
85
+ throw new Error(metasoErrorMessage(response.status, detail));
86
+ }
87
+
88
+ let data;
89
+ try {
90
+ data = await response.json();
91
+ } catch {
92
+ throw new Error("Metaso returned an invalid JSON response");
93
+ }
94
+
95
+ const items = Array.isArray(data?.[RESULT_ARRAYS[normalizedScope]]) ? data[RESULT_ARRAYS[normalizedScope]] : [];
96
+ const sources = items
97
+ .map((item) => {
98
+ const url = String(item?.link ?? "").trim();
99
+ if (!url) return null;
100
+ const snippet = String(item?.summary ?? item?.snippet ?? "").trim();
101
+ const date = publishedDate(item?.date);
102
+ return {
103
+ url,
104
+ ...(item?.title ? { title: String(item.title) } : {}),
105
+ ...(snippet ? { snippet } : {}),
106
+ ...(date ? { publishedAt: date } : {}),
107
+ };
108
+ })
109
+ .filter(Boolean);
110
+
111
+ return { sources: uniqueSources(sources, limit), truncated: false };
112
+ }
@@ -13,7 +13,7 @@ import { tmpdir } from "node:os";
13
13
  import { join } from "node:path";
14
14
  import { callExa, callFirecrawl, callCrawl4ai } from "./fetch_upstream.js";
15
15
  import { stripLoneSurrogates } from "./safe_text.js";
16
- import { assertPublicUrl, safeLookup } from "./ssrf.js";
16
+ import { assertPublicUrl, makeSafeLookup } from "./ssrf.js";
17
17
 
18
18
  const T1_MIN_CHARS = 300;
19
19
  const TEXTUAL = /text\/|json|xml|javascript|application\/json/i;
@@ -303,6 +303,7 @@ export function createFetchProvider({
303
303
  acceptLanguage = () => "en-US,en;q=0.9",
304
304
  browserEnabled = () => true,
305
305
  prefer = () => "exa",
306
+ allowedCidrs = () => [],
306
307
  validateUrl = assertPublicUrl,
307
308
  }) {
308
309
  return {
@@ -313,13 +314,15 @@ export function createFetchProvider({
313
314
  const url = String(request?.url || "");
314
315
  if (!/^https:\/\//i.test(url)) throw new Error(`fs-quality-fetch: only https URLs are supported (got "${url.slice(0, 60)}")`);
315
316
  // SSRF guard: never fetch loopback / private / metadata addresses, and use a
316
- // lookup that re-checks every redirect hop.
317
- await validateUrl(url);
317
+ // lookup that re-checks every redirect hop. Explicitly allowed CIDRs cover
318
+ // transparent-proxy fake-ip ranges (Clash/mihomo 198.18.0.0/15).
319
+ const allowed = allowedCidrs();
320
+ await validateUrl(url, { allowedCidrs: allowed });
318
321
  const errors = [];
319
322
 
320
323
  // T1:直连(文本类内容;二进制交给后层——exa 取正文,PDF 等仍由 firecrawl 处理)
321
324
  try {
322
- const r = await httpsGetFollow(url, { headers: browserishHeaders(acceptLanguage()), signal, lookup: safeLookup });
325
+ const r = await httpsGetFollow(url, { headers: browserishHeaders(acceptLanguage()), signal, lookup: makeSafeLookup(allowed) });
323
326
  if (r.status < 400 && TEXTUAL.test(r.contentType) && r.text.length >= T1_MIN_CHARS) {
324
327
  return { url: r.url, statusCode: r.status, body: { kind: "html", content: stripLoneSurrogates(r.text) }, truncated: false };
325
328
  }
package/lib/index.js CHANGED
@@ -40,6 +40,7 @@ import { searchSerpbase } from "./engines/serpbase.js";
40
40
  import { searchSerply } from "./engines/serply.js";
41
41
  import { searchOutcrawl } from "./engines/outcrawl.js";
42
42
  import { searchGoogle } from "./engines/google.js";
43
+ import { searchMetaso } from "./engines/metaso.js";
43
44
  import { createEngineRuntime, ENGINE_CONCURRENCY_LIMIT, SERP_CONCURRENCY_LIMIT } from "./engine_runtime.js";
44
45
  import { classifyIntent, preferForIntent } from "./intent.js";
45
46
  import { dedupeNearDuplicates } from "./dedupe.js";
@@ -1811,6 +1812,7 @@ const KEY_REF_MAP = {
1811
1812
  serplyApiKey: "SERPLY_API_KEY",
1812
1813
  outcrawlApiKey: "OUTCRAWL_API_KEY",
1813
1814
  googleCseApiKey: "GOOGLE_CSE_API_KEY",
1815
+ metasoApiKey: "METASO_API_KEY",
1814
1816
  deepseekApiKey: "DEEPSEEK_API_KEY",
1815
1817
  // 设置页写入的凭据槽位保持旧名,已保存的 key 不受影响;读取时 YDC_API_KEY 优先(见 resolveYoucomApiKey)
1816
1818
  youcomApiKey: "YOUCOM_API_KEY",
@@ -1871,6 +1873,9 @@ const Config = z.object({
1871
1873
  fetchProviderTakeover: z.boolean().default(true).volatile(),
1872
1874
  // T1.5 headless browser rendering (default on, matching 0.9.x behaviour).
1873
1875
  browserFetch: z.boolean().default(true).volatile(),
1876
+ // Opt-in reserved ranges for transparent-proxy fake-ip DNS (Clash/mihomo
1877
+ // commonly use 198.18.0.0/15). Loopback / RFC1918 / link-local stay blocked.
1878
+ allowFakeIpCidrs: z.array(z.string()).default([]).volatile(),
1874
1879
  // Which keyed tier runs first after direct/browser: "exa" (default) or "firecrawl".
1875
1880
  fetchPrefer: z.string().default("exa").volatile(),
1876
1881
  safeSearch: z.string().default("off").volatile(),
@@ -1878,6 +1883,8 @@ const Config = z.object({
1878
1883
  // degoog(自建搜索聚合器,见 https://github.com/degoog-org/degoog):需要自己的实例,默认不启用。
1879
1884
  degoogInstances: z.array(z.string()).volatile(),
1880
1885
  googleCseId: z.string().default("").volatile(),
1886
+ metasoApiKey: z.string().role("secret").volatile(),
1887
+ metasoScope: z.string().default("webpage").volatile(),
1881
1888
  searxngBearerToken: z.string().role("secret").volatile(),
1882
1889
  degoogApiKey: z.string().role("secret").volatile(),
1883
1890
  platforms: z.array(z.string()).default(["github", "v2ex", "bilibili", "reddit", "hn", "stackoverflow", "wikipedia", "npm", "youtube", "vimeo", "juejin", "douban", "qiita", "x"]).volatile(),
@@ -2413,6 +2420,10 @@ function apply(ctx, config) {
2413
2420
  safeSearch: cfg.safeSearch,
2414
2421
  }, signal);
2415
2422
  },
2423
+ metaso: async ({ query, maxResults, timeRange, signal }) => {
2424
+ const key = await requireEngineKey("METASO_API_KEY", "metasoApiKey", "Metaso", " (get one at metaso.cn/api)");
2425
+ return searchMetaso(query, maxResults, key, current().metasoScope, timeRange, signal);
2426
+ },
2416
2427
  you: async ({ query, maxResults, signal }) =>
2417
2428
  searchYoucom(query, maxResults, await resolveYoucomKey(), signal),
2418
2429
  tinyfish: async ({ query, maxResults, timeRange, signal }) =>
@@ -2896,6 +2907,7 @@ function apply(ctx, config) {
2896
2907
  acceptLanguage: () => acceptLanguageFor(current()),
2897
2908
  browserEnabled: () => current().browserFetch !== false,
2898
2909
  prefer: () => (current().fetchPrefer === "firecrawl" ? "firecrawl" : "exa"),
2910
+ allowedCidrs: () => current().allowFakeIpCidrs ?? [],
2899
2911
  });
2900
2912
  registerOnce(() => ctx.web.registerFetchProvider(fetchProvider), fetchProvider, "fetch provider");
2901
2913
 
@@ -3067,6 +3079,11 @@ function apply(ctx, config) {
3067
3079
  safeSearch: cfg.safeSearch,
3068
3080
  });
3069
3081
  }
3082
+ case "metaso": {
3083
+ const key = await resolveApiKey("METASO_API_KEY", "metasoApiKey");
3084
+ if (!key) return { ok: false, error: "METASO_API_KEY not configured" };
3085
+ return await searchMetaso(q, n, key, cfg.metasoScope, tr);
3086
+ }
3070
3087
  case "agy": {
3071
3088
  if (!agyAvailable()) return { ok: false, error: "Antigravity CLI not installed (install Antigravity or set AGY_BIN)" };
3072
3089
  return await searchAgy(q, n, {});
@@ -221,6 +221,7 @@ export const REQUIRED_CREDENTIALS = {
221
221
  serply: [{ env: "SERPLY_API_KEY", settings: "serplyApiKey" }],
222
222
  outcrawl: [{ env: "OUTCRAWL_API_KEY", settings: "outcrawlApiKey" }],
223
223
  google: [{ env: "GOOGLE_CSE_API_KEY", settings: "googleCseApiKey" }],
224
+ metaso: [{ env: "METASO_API_KEY", settings: "metasoApiKey" }],
224
225
  tinyfish: [{ env: "TINYFISH_API_KEY", settings: "tinyfishApiKey" }],
225
226
  jina: [{ env: "JINA_API_KEY", settings: "jinaApiKey" }],
226
227
  baidu: [{ env: "BAIDU_API_KEY", settings: "baiduApiKey" }],
package/lib/ssrf.js CHANGED
@@ -39,12 +39,74 @@ function isPublicIPv6(address) {
39
39
  return true;
40
40
  }
41
41
 
42
- /** True only for globally routable addresses; unknown input is treated as unsafe. */
43
- export function isPublicAddress(address) {
42
+ function buildAllowedList(cidrs) {
43
+ const list = new net.BlockList();
44
+ for (const raw of Array.isArray(cidrs) ? cidrs : []) {
45
+ const text = String(raw ?? "").trim();
46
+ if (!text) continue;
47
+ const slash = text.lastIndexOf("/");
48
+ const address = slash >= 0 ? text.slice(0, slash) : text;
49
+ const family = net.isIP(address);
50
+ if (!family) continue;
51
+ const max = family === 4 ? 32 : 128;
52
+ const prefix = slash >= 0 ? Number(text.slice(slash + 1)) : max;
53
+ if (!Number.isInteger(prefix) || prefix < 0 || prefix > max) continue;
54
+ try {
55
+ list.addSubnet(address, prefix, family === 4 ? "ipv4" : "ipv6");
56
+ } catch {
57
+ // ignore malformed CIDRs; config is also editable by hand
58
+ }
59
+ }
60
+ return list;
61
+ }
62
+
63
+ /** True when the address falls inside one of the user-configured CIDRs. */
64
+ export function isAddressAllowed(address, allowedCidrs = []) {
44
65
  const family = net.isIP(String(address));
45
- if (family === 4) return isPublicIPv4(String(address));
46
- if (family === 6) return isPublicIPv6(String(address));
47
- return false;
66
+ if (!family) return false;
67
+ return buildAllowedList(allowedCidrs).check(String(address), family === 4 ? "ipv4" : "ipv6");
68
+ }
69
+
70
+ function isHardBlockedIPv4(address) {
71
+ const parts = ipv4Parts(address);
72
+ if (parts === null) return false;
73
+ const [a, b] = parts;
74
+ if (a === 0 || a === 10 || a === 127) return true;
75
+ if (a === 169 && b === 254) return true;
76
+ if (a === 172 && b >= 16 && b <= 31) return true;
77
+ if (a === 192 && b === 168) return true;
78
+ if (a === 100 && b >= 64 && b <= 127) return true;
79
+ return a >= 224;
80
+ }
81
+
82
+ /** Ranges that stay blocked even if a user lists them in allowFakeIpCidrs. */
83
+ function isHardBlocked(address) {
84
+ const family = net.isIP(address);
85
+ if (family === 4) return isHardBlockedIPv4(address);
86
+ if (family !== 6) return true;
87
+ const value = address.toLowerCase();
88
+ if (value === "::" || value === "::1") return true;
89
+ if (value.startsWith("::ffff:")) return isHardBlockedIPv4(value.slice(7));
90
+ if (value.startsWith("fc") || value.startsWith("fd")) return true;
91
+ if (/^fe[89ab]/.test(value)) return true;
92
+ return value.startsWith("ff");
93
+ }
94
+
95
+ /**
96
+ * True only for globally routable addresses; unknown input is treated as unsafe.
97
+ * `allowedCidrs` is an explicit opt-in for reserved ranges (e.g. Clash/mihomo
98
+ * fake-ip 198.18.0.0/15). Loopback, RFC1918, link-local and multicast stay
99
+ * blocked even when listed.
100
+ */
101
+ export function isPublicAddress(address, { allowedCidrs = [], allowedList } = {}) {
102
+ const text = String(address);
103
+ const family = net.isIP(text);
104
+ if (!family) return false;
105
+ if (isHardBlocked(text)) return false;
106
+ const allowed = allowedList ?? buildAllowedList(allowedCidrs);
107
+ if (allowed.check(text, family === 4 ? "ipv4" : "ipv6")) return true;
108
+ if (family === 4) return isPublicIPv4(text);
109
+ return isPublicIPv6(text);
48
110
  }
49
111
 
50
112
  function bareHost(hostname) {
@@ -52,32 +114,37 @@ function bareHost(hostname) {
52
114
  }
53
115
 
54
116
  /** dns.lookup replacement that refuses to connect to private addresses (redirects included). */
55
- export function safeLookup(hostname, options, callback) {
56
- const host = bareHost(hostname);
57
- dns.lookup(host, { ...options, all: true }, (error, addresses) => {
58
- if (error) {
59
- callback(error);
60
- return;
61
- }
62
- const list = Array.isArray(addresses) ? addresses : [];
63
- const blocked = list.find((entry) => !isPublicAddress(entry.address));
64
- if (blocked) {
65
- callback(new Error(`SSRF blocked: ${host} resolves to private address ${blocked.address}`));
66
- return;
67
- }
68
- if (options?.all) {
69
- callback(null, list);
70
- return;
71
- }
72
- callback(null, list[0]?.address, list[0]?.family);
73
- });
117
+ export function makeSafeLookup(allowedCidrs = []) {
118
+ const allowedList = buildAllowedList(allowedCidrs);
119
+ return function lookup(hostname, options, callback) {
120
+ const host = bareHost(hostname);
121
+ dns.lookup(host, { ...options, all: true }, (error, addresses) => {
122
+ if (error) {
123
+ callback(error);
124
+ return;
125
+ }
126
+ const list = Array.isArray(addresses) ? addresses : [];
127
+ const blocked = list.find((entry) => !isPublicAddress(entry.address, { allowedList }));
128
+ if (blocked) {
129
+ callback(new Error(`SSRF blocked: ${host} resolves to private address ${blocked.address}`));
130
+ return;
131
+ }
132
+ if (options?.all) {
133
+ callback(null, list);
134
+ return;
135
+ }
136
+ callback(null, list[0]?.address, list[0]?.family);
137
+ });
138
+ };
74
139
  }
75
140
 
141
+ export const safeLookup = makeSafeLookup();
142
+
76
143
  /**
77
144
  * Reject non-HTTPS URLs and hosts that resolve (or literally point) to a private
78
145
  * address. A custom lookup is allowed for tests.
79
146
  */
80
- export async function assertPublicUrl(rawUrl, { lookup = dns.promises.lookup } = {}) {
147
+ export async function assertPublicUrl(rawUrl, { lookup = dns.promises.lookup, allowedCidrs = [] } = {}) {
81
148
  let target;
82
149
  try {
83
150
  target = new URL(String(rawUrl ?? ""));
@@ -89,7 +156,7 @@ export async function assertPublicUrl(rawUrl, { lookup = dns.promises.lookup } =
89
156
  const host = bareHost(target.hostname);
90
157
  if (host === "") throw new Error("URL has no host");
91
158
  if (net.isIP(host)) {
92
- if (!isPublicAddress(host)) throw new Error(`SSRF blocked: ${host} is a private address`);
159
+ if (!isPublicAddress(host, { allowedCidrs })) throw new Error(`SSRF blocked: ${host} is a private address`);
93
160
  return target;
94
161
  }
95
162
  let addresses;
@@ -99,7 +166,7 @@ export async function assertPublicUrl(rawUrl, { lookup = dns.promises.lookup } =
99
166
  throw new Error(`cannot resolve host "${host}"`);
100
167
  }
101
168
  const list = Array.isArray(addresses) ? addresses : [addresses];
102
- const blocked = list.find((entry) => !isPublicAddress(entry?.address ?? entry));
169
+ const blocked = list.find((entry) => !isPublicAddress(entry?.address ?? entry, { allowedCidrs }));
103
170
  if (blocked) {
104
171
  throw new Error(`SSRF blocked: ${host} resolves to private address ${blocked.address ?? blocked}`);
105
172
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.41",
4
- "description": "Free web search for DeepSeek Harness: 27 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/Baidu/Kimi/Aliyun/Doubao with key; OpenAI/Gemini/Claude model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + editable zh/en language pools + multi mode (parallel full language-pool merge) + multi_search cross-source tool + failure-aware fallback (quota/auth cooldown, transient retry, fallbackOn) + time filtering + platform search + domain blocklist (blockedDomains) + web_fetch, with web settings UI.",
3
+ "version": "0.9.42",
4
+ "description": "Free web search for DeepSeek Harness: 37 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/Baidu/Kimi/Aliyun/Doubao/Google CSE/Metaso with key; OpenAI/Gemini/Claude model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + editable zh/en language pools + multi mode (parallel full language-pool merge) + multi_search cross-source tool + failure-aware fallback (quota/auth cooldown, transient retry, fallbackOn) + time filtering + platform search + domain blocklist (blockedDomains) + web_fetch, with web settings UI.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {