dsh-free-search 0.9.37 → 0.9.39

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
- - **35 个引擎可选**:DuckDuckGo(html/lite)、Bing、SearXNG(元搜索,支持自定义实例)、AnySearch、Exa、Tavily、Keenable、Firecrawl、Parallel、Perplexity、SerpBase、Serply、Outcrawl、DeepSeek 官方、DeepSeek 原生搜索 API、You.com、百度千帆、Kimi、阿里云百炼、火山联网搜索(豆包搜索)、知乎全网/站内(`zhihu_global`/`zhihu_site`,经知乎开放平台 MCP)、Antigravity CLI 搜索(`agy`,需本机安装)、OpenAI / Gemini / Claude 模型内置搜索。默认自动回退链覆盖其中 27 个;5 个 HTML SERP 引擎默认不参与,OpenAI / Gemini / Claude 三个按次计费引擎只在显式点名时运行。
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 三个按次计费引擎只在显式点名时运行。
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` / 引擎测试都不再用它),并可用 ↑↓ 调整全局回退顺序(一键恢复默认)。
@@ -48,7 +48,7 @@
48
48
 
49
49
  - **统一引擎回退** —— 任何引擎失败(付费/免费,缺 key/401/限流/网络)自动轮流尝试下一个引擎:首选引擎 → 其他引擎(exa/tavily/keenable/firecrawl/parallel/you 无 key 也会尝试,因为它们自带 keyless 免费额度)→ 剩余免费引擎,搜索永不直接失败;结果顶部注明实际生效的引擎(如 `Note: perplexity unavailable or failed, using exa.`);失败按类别处理:额度/鉴权失败 → 本会话冷却该引擎,反爬 → 短退避,超时/5xx/限流 → 同引擎重试一次,解析失败/0 结果 → 不冷却(详见下文「失败分类与引擎冷却」)。
50
50
  - **多 key 轮换** —— 任何 key 字段(或对应环境变量)都可以用逗号 / 分号 / 换行分隔多把 key;平时按请求轮流使用(round-robin,避免单 key 撞 QPS/RPM 风控),遇到 401/402/429(鉴权失败、额度耗尽、限流)先轮换同一引擎的下一把,再走引擎回退;`multi` 模式同样生效(#96)。
51
- - **按 key 冷却与诊断** —— 429 与额度错误按 key 分别冷却,同一引擎的其他 key 不受牵连;冷却状态写入磁盘,重启后仍在;失败信息和日志里的 key 一律打码;设置页底部的「诊断」按钮列出每个引擎当前为什么不可用、冷却还剩多久。
51
+ - **按 key 冷却与诊断** —— 429 与额度错误按 key 分别冷却,同一引擎的其他 key 不受牵连;冷却状态写入磁盘,重启后仍在;失败信息和日志里的 key 一律打码;设置页底部的「诊断」按钮列出每个引擎当前为什么不可用、冷却还剩多久,以及本次进程内的调用次数、成功/空/失败和平均耗时;同一引擎并发超过 2 会排队(HTML SERP 为 1),避免免费引擎被同时打爆。
52
52
  - **自带更新** —— 卡片底部显示当前版本和「检查更新」;npm 安装的版本可一键升级到 latest,本地 link 开发模式改为跳转 npm 页面并提示 `git pull`。
53
53
  - **引擎测试** —— `free_search_test` 工具让 agent 一键测试所有引擎;设置页也有「测试引擎」按钮(直测当前引擎,不走回退链,付费引擎无 key 会明确报错)。
54
54
  - **截断安全** —— 标题和摘要按码点截断,搜索结果、工具输出和 `web_fetch` 正文在离开插件前统一清除孤立代理;含 emoji 的结果不会再让会话历史出现无法序列化的字符(#108)。
@@ -76,7 +76,7 @@
76
76
 
77
77
  #### 抓取与工具
78
78
 
79
- - **网页抓取(web_fetch)** —— 让 agent 抓取网页内容(官方 `dsh-web-fetch-http` provider,纯 JS,零额外依赖),可自动接管 `web.fetchProvider` 为插件的直连 → exa → firecrawl → crawl4ai 质量链。
79
+ - **网页抓取(web_fetch)** —— 让 agent 抓取网页内容(官方 `dsh-web-fetch-http` provider,纯 JS,零额外依赖),可自动接管 `web.fetchProvider` 为插件的直连 → 浏览器渲染 → exa / firecrawl → crawl4ai 质量链。T1.5 浏览器渲染可在设置页关闭,exa 与 firecrawl 的先后顺序也可切换;私网、回环和云元数据地址一律拒绝(SSRF 防护)。
80
80
 
81
81
  <img src="https://raw.githubusercontent.com/DDDMUC/dsh-free-search/master/assets/ui-fetch.png" alt="抓取与平台:web_fetch 接管、Key 存储位置与平台搜索开关" width="100%" />
82
82
  <sub>▲ 抓取:自动接管 web_fetch、Key 存储位置与平台搜索开关</sub>
@@ -93,7 +93,7 @@
93
93
 
94
94
  #### 设置页与目录
95
95
 
96
- - **网页设置页** —— 引擎切换 + API key 配置(UI 中 key 脱敏显示「已配置」)+ 中英文切换;入口在左侧「插件」页的组件行配置(`plugins.row.config`,DSH 0.1.7-rc.1+)。远程访问(VPS / 反向代理 / 自定义域名)下也能用:桥接接口沿用宿主的 Host 围栏,`--trusted-host` 与 `--public-url` 声明的地址会放行(#84)。
96
+ - **网页设置页** —— 引擎切换 + API key 配置(UI 中 key 脱敏显示「已配置」)+ 中英文切换;入口在左侧「插件」页的组件行配置(`plugins.row.config`,DSH 0.2.1-rc.2+)。远程访问(VPS / 反向代理 / 自定义域名)下也能用:桥接接口沿用宿主的 Host 围栏,`--trusted-host` 与 `--public-url` 声明的地址会放行(#84)。
97
97
 
98
98
  <img src="https://raw.githubusercontent.com/DDDMUC/dsh-free-search/master/assets/ui-apikeys.png" alt="全局回退优先级与每引擎 API key" width="100%" />
99
99
  <sub>▲ 全局回退优先级:每行一个引擎,右侧填该引擎的 API key(已配置会脱敏显示)</sub>
@@ -147,6 +147,7 @@
147
147
  | `serpbase` | SerpBase | 付费 | 需 `SERPBASE_API_KEY`(serpbase.dev,注册送 100 次免费额度) |
148
148
  | `serply` | Serply | 付费 | 需 `SERPLY_API_KEY`(serply.io,新账户 30 天内 2,500 次免费额度);Google 网页结果,按设置页语言本地化 |
149
149
  | `outcrawl` | Outcrawl | 付费 | 需 `OUTCRAWL_API_KEY`(outcrawl.ai,每月 1,000 credits 免费额度);网页搜索结果(标题/链接/摘要),单次最多 20 条 |
150
+ | `google` | Google 自定义搜索 | 免费额度 | 需 `GOOGLE_CSE_API_KEY` 和 Programmable Search Engine ID(`googleCseId` / cx);Google 官方 Custom Search JSON API,每天 100 次免费,按次计费超额;支持 `hl`、安全搜索和 `dateRestrict` 时间过滤 |
150
151
  | `deepseek-official` | DeepSeek 官方 | 付费 | 需 `DEEPSEEK_API_KEY`;走 Anthropic 兼容的 `web_search` 服务端工具,每次搜索是一整个模型轮次(慢、耗 token) |
151
152
  | `deepseek-tools` | DeepSeek 原生搜索 API | 付费 | 需 `DEEPSEEK_API_KEY`(与上一档共用);直接 `POST /v1/tools/search`,无模型参与,返回结构化 `results[]`(`title`/`url`/`summary`/`date`),同 query 实测 ~0.3s vs 上一档 ~5-6s |
152
153
  | `baidu` | 百度千帆 AI 搜索 | 额度 | 需 `BAIDU_API_KEY`(千帆 AI 搜索,每日赠 50 次,超额按量后付费);中文全网,支持时间过滤 |
@@ -207,6 +208,8 @@
207
208
 
208
209
  ### 安装
209
210
 
211
+ 需要 **DSH 0.2.1-rc.2 或更新的 0.2.x**;更早的 0.1.x 宿主不满足 `engines.dsh`,插件管理器会拒绝安装。
212
+
210
213
  ```sh
211
214
  git clone https://github.com/DDDMUC/dsh-free-search.git
212
215
  dsh plugin --profile web add /path/to/dsh-free-search
@@ -268,14 +271,14 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
268
271
 
269
272
  #### 网页设置(推荐)
270
273
 
271
- 安装后打开配置页(DSH 0.1.7-rc.1+):
274
+ 安装后打开配置页(DSH 0.2.1-rc.2+):
272
275
 
273
276
  - 左侧 **插件** 页 → **已安装** 分组 → `free-search` → 点击组件行 `web-search-free`(行内"配置"入口)
274
277
 
275
278
  配置页提供:
276
279
 
277
280
  - **Search engine**:下拉框切换引擎,保存即生效
278
- - **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / Outcrawl / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel / You.com 不填也可免 key 使用)
281
+ - **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 使用)
279
282
  - **推荐**:付费引擎 key 建议写入 harness 凭据中心 `~/.dsh/.credentials.yaml`(如 `DEEPSEEK_API_KEY: sk-...`,与官方 LLM provider 一致,一处管理所有 key)。插件读取优先级:凭据中心 > 设置页 > 环境变量,设置页填的 key 仅作为遗留兼容。
280
283
  - **Test engine**:直测当前引擎可用性(不走回退链,付费引擎无 key 会明确报错)
281
284
  - **Use Bing default**:把当前搜索引擎切回稳定的免费 Bing;`Discard` 只撤销尚未保存的编辑
@@ -367,7 +370,7 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
367
370
 
368
371
  #### 配置文件
369
372
 
370
- DSH 0.1.7-rc.1 起,配置跟随 profile 的插件条目保存:设置页与 `/free-search-engine` 都会写入当前 profile 的 `cordis.patch.yml` 中 `web-search-free`(`dsh-free-search`)条目的 `config`。
373
+ 从 DSH 0.1.7-rc.1 起(当前版本要求 0.2.1-rc.2+),配置跟随 profile 的插件条目保存:设置页与 `/free-search-engine` 都会写入当前 profile 的 `cordis.patch.yml` 中 `web-search-free`(`dsh-free-search`)条目的 `config`。
371
374
 
372
375
  旧版 `~/.dsh/settings.yaml` 的 `free-search:` 段**不会被 DSH 核心自动导入**(核心的 `importLegacyDocument` 只为 `ui-developer-tools` / `ui-onboarding` / `shell` 三个段提供了映射),原文件在导入其它段后会被改名为 `settings.yaml.imported`,该段的值只留在那里。插件会在启动时检测 `settings.yaml.imported`(或仍存在的 `settings.yaml`)中的 `free-search:` 段,把可识别的字段**一次性补种**进当前 profile 的条目 `config`(写一次后不再重复,可在启动日志看到 `free-search: migrated N field(s)…`)。如果你想手动处理,也可以照着 `settings.yaml.imported` 里的值在插件页行配置中填一遍。
373
376
 
@@ -394,6 +397,8 @@ promptToolsLang: "" # 工具段那句话的语言,zh 或 en;留空
394
397
  disabledTools: [] # 关掉的工具不再注册(例如 [domain_search]),schema 一并从上下文消失
395
398
  bingMarket: zh-CN # Bing 市场;留空 = 自动(不发送 mkt)
396
399
  fetchProviderTakeover: true # false = 保留你显式 pin 的 fetchProvider: http
400
+ browserFetch: true # 直连失败时用系统浏览器无头渲染
401
+ fetchPrefer: exa # exa | firecrawl —— 两者都失败后先试哪个 keyed 抓取层
397
402
  region: cn-zh # DuckDuckGo 区域(可选)
398
403
  searxngInstances: # 自定义 SearXNG 实例(可选)
399
404
  - https://your-instance.example
@@ -417,6 +422,8 @@ perplexityApiKey: ...
417
422
  serpbaseApiKey: ... # 或通过设置页填写
418
423
  serplyApiKey: ... # 或通过设置页填写
419
424
  outcrawlApiKey: ... # 或通过设置页填写
425
+ googleCseApiKey: ... # Google Custom Search API key
426
+ googleCseId: "..." # Programmable Search Engine 的 cx
420
427
  deepseekApiKey: ...
421
428
  ```
422
429
 
@@ -578,7 +585,7 @@ Search engine test:
578
585
 
579
586
  #### 离线自检断言(tools/)
580
587
 
581
- 仓库自带 **47 个**零依赖断言脚本(合计 **776 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
588
+ 仓库自带 **50 个**零依赖断言脚本(合计 **796 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
582
589
 
583
590
  | 脚本 | 覆盖 | 运行(项数) |
584
591
  |---|---|---|
@@ -589,13 +596,16 @@ Search engine test:
589
596
  | `assert-multi-policy.mjs` | multi 执行策略:并发上限是天花板 / 目标成功源非硬下限 / 凭据资格在上限之前分流 / **Fast·Balanced·Deep 档位** | `node tools/assert-multi-policy.mjs`(146) |
590
597
  | `assert-multi-limit.mjs` | multi 结果上限(#109):默认 20 / 硬上限 100 / 配置归一化、单次 maxResults 受上限约束、工具参数与本段提示词写明生效上限、设置页字段与保存 | `node tools/assert-multi-limit.mjs`(6) |
591
598
  | `assert-maintenance.mjs` | 维护面:CI 在 Node 20/22/24 跑全部断言并过打包闸门、发布脚本会 bump / 校验 / 打 tag / 可发布、恢复官方 provider 的桥接与设置页按钮 | `node tools/assert-maintenance.mjs`(4) |
592
- | `assert-engine-modules.mjs` | 引擎分层:实现文件存在且被 index 引用、引擎函数已迁出 index、设置页引擎 id 与服务端清单一致、清单覆盖 35 个引擎且免费/按次标记正确 | `node tools/assert-engine-modules.mjs`(4) |
599
+ | `assert-engine-modules.mjs` | 引擎分层:实现文件存在且被 index 引用、引擎函数已迁出 index、设置页引擎 id 与服务端清单一致、清单覆盖 36 个引擎且免费/按次标记正确 | `node tools/assert-engine-modules.mjs`(4) |
593
600
  | `assert-result-ranking.mjs` | 合并排序:**eTLD+1 同域判定** / 域名轮转 / `seenIn` 降为末位 / 时效仅带时间过滤时生效 | `node tools/assert-result-ranking.mjs`(31) |
594
601
  | `assert-url-norm.mjs` | URL 规范化:只剔已审计的 tracking 参数,保留可能区分资源的参数 | `node tools/assert-url-norm.mjs`(72) |
595
602
  | `assert-prompt-contract.mjs` | 系统提示词契约:**检索≠抓取**、不可信边界、模型内置搜索只在显式选中时运行 | `node tools/assert-prompt-contract.mjs`(9) |
596
603
  | `assert-research-degradation.mjs` | research 无 key 全降级、`node:sqlite` no-op、90s 预算隔离、缓存目录可配置、`budget.exhausted` 契约名 | `node tools/assert-research-degradation.mjs`(19) |
597
604
  | `assert-research-call-wrappers.mjs` | research 四个 `call*` 包装层的替身/底层透传(#75 回归) | `node tools/assert-research-call-wrappers.mjs`(23) |
598
605
  | `assert-fetch-chain.mjs` | `fs-quality-fetch` 四层链序、任一层命中即停、exa 失败静默降级 firecrawl、全层失败聚合报错 | `node tools/assert-fetch-chain.mjs`(8) |
606
+ | `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、非 HTTPS 与带凭据 URL 拒绝、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(6) |
607
+ | `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) |
608
+ | `assert-engine-runtime.mjs` | 引擎运行时:按引擎并发上限(普通 2 / HTML SERP 1)、排队与 abort 清理、成功/空/失败/平均耗时统计、provider 与 runEngineTest 两条路径接线、诊断报告带 stats | `node tools/assert-engine-runtime.mjs`(4) |
599
609
  | `assert-single-fetch-layer.mjs` | 抓取层全库只有一份实现、依赖单向、替身键不串层 | `node tools/assert-single-fetch-layer.mjs`(22) |
600
610
  | `assert-vertical.mjs` | `domain_search` 41 引擎注册表、每引擎 desc、未知引擎报错、不依赖 research | `node tools/assert-vertical.mjs`(8) |
601
611
  | `assert-free-search-test-schema.mjs` | `free_search_test` 输出 schema 与真实产出一致(含 auto/multi 虚拟模式) | `node tools/assert-free-search-test-schema.mjs`(8) |
@@ -680,7 +690,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
680
690
  #### Engines and switching
681
691
 
682
692
  - **Zero Cost** — Multiple free engines with no API key or registration required
683
- - **35 engines available** — DuckDuckGo (HTML / Lite), Bing, AnySearch AI, SearXNG (meta-search with custom instances), Exa, Tavily, Keenable, Firecrawl, Parallel, Perplexity, SerpBase, Serply, Outcrawl, 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 27 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.
693
+ - **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.
684
694
  - **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.
685
695
  - **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).
686
696
  - **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).
@@ -694,7 +704,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
694
704
 
695
705
  - **Unified Engine Fallback** — Any engine failure (paid or free, missing key, 401, rate limit, network error) automatically tries the next engine: the configured engine first, then other engines (exa/tavily/keenable/firecrawl/parallel/you are tried even without a key because they have built-in keyless quota), then the remaining free engines (Bing/AnySearch etc.) — with a note attached to the results naming the engine that actually served them (e.g. `Note: perplexity unavailable or failed, using exa.`). Failures are classified: quota/auth failures cool the engine down for the session, anti-bot walls back off briefly, timeout/5xx/rate-limit failures retry the same engine once, and parse errors / 0 results are reported without cooling it down. Search never fails outright.
696
706
  - **Multi-key rotation** — Any key field (or its env var) accepts several keys separated by commas, semicolons or newlines. Keys are used round-robin per request, and on 401/402/429 the same engine retries with the next key before the engine-level fallback runs. This also applies inside `multi` mode (#96).
697
- - **Per-key cooldowns and diagnostics** — a 429 or quota error cools the key that hit it, not every other key of the same engine; the state is written to disk and survives a restart; keys are masked in failure text and logs; the Diagnose button at the bottom of the settings page lists why each engine is currently unavailable and how long its cooldown has left.
707
+ - **Per-key cooldowns and diagnostics** — a 429 or quota error cools the key that hit it, not every other key of the same engine; the state is written to disk and survives a restart; keys are masked in failure text and logs; the Diagnose button at the bottom of the settings page lists why each engine is currently unavailable, how long its cooldown has left, and the in-process call count, success/empty/failure split and average latency; concurrent calls to one engine queue beyond 2 (1 for HTML SERP), so a free engine is not hammered in the same second.
698
708
  - **Built-in updater** — the card footer shows the version and a Check update button; npm installs upgrade to latest in one click, while a local link install links to the npm page and points at git pull instead.
699
709
  - **Engine Testing** — `free_search_test` for the agent to check all engines in one call; the settings UI also has a "Test engine" button that tests the selected engine directly (no fallback chain; paid engines without a key report an explicit error).
700
710
  - **Truncation safety** — titles and snippets are cut by code point, and search results, tool output and web_fetch bodies are stripped of lone surrogates before leaving the plugin; an emoji can no longer make history unserializable (#108).
@@ -722,7 +732,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
722
732
 
723
733
  #### Fetch and tools
724
734
 
725
- - **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 → exa → firecrawl → crawl4ai quality chain.
735
+ - **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).
726
736
 
727
737
  <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%" />
728
738
  <sub>▲ Fetch: web_fetch takeover, key storage location and platform search switches</sub>
@@ -739,7 +749,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
739
749
 
740
750
  #### Settings and rail
741
751
 
742
- - **Web Settings UI** — Engine switching, API key configuration (keys masked as "configured" in the UI), and a Chinese/English toggle; the entry is the component-row config (`plugins.row.config`) on the sidebar Plugins page (DSH 0.1.7-rc.1+). Remote access (VPS, reverse proxy, custom domain) works too: the bridge reuses the host's own Host fence, so addresses declared with `--trusted-host` or `--public-url` are accepted (#84).
752
+ - **Web Settings UI** — Engine switching, API key configuration (keys masked as "configured" in the UI), and a Chinese/English toggle; the entry is the component-row config (`plugins.row.config`) on the sidebar Plugins page (DSH 0.2.1-rc.2+). Remote access (VPS, reverse proxy, custom domain) works too: the bridge reuses the host's own Host fence, so addresses declared with `--trusted-host` or `--public-url` are accepted (#84).
743
753
 
744
754
  <img src="https://raw.githubusercontent.com/DDDMUC/dsh-free-search/master/assets/ui-apikeys.png" alt="Global fallback priority and per-engine API keys" width="100%" />
745
755
  <sub>▲ Global fallback priority: one engine per row, its API key on the right (configured keys are masked)</sub>
@@ -794,6 +804,7 @@ If this plugin has been helpful, a ⭐ on [GitHub](https://github.com/DDDMUC/dsh
794
804
  | `serpbase` | SerpBase | Paid | Requires `SERPBASE_API_KEY` (serpbase.dev, 100 free queries on signup) |
795
805
  | `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 |
796
806
  | `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 |
807
+ | `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 |
797
808
  | `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) |
798
809
  | `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 |
799
810
  | `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 |
@@ -855,6 +866,8 @@ Rule of thumb for a default pool: **① as the floor + ③ as the workhorse**;
855
866
 
856
867
  ### Installation
857
868
 
869
+ Requires **DSH 0.2.1-rc.2 or a newer 0.2.x**; older 0.1.x hosts do not satisfy `engines.dsh` and the plugin manager will refuse the install.
870
+
858
871
  ```sh
859
872
  git clone https://github.com/DDDMUC/dsh-free-search.git
860
873
  dsh plugin --profile web add /path/to/dsh-free-search
@@ -916,14 +929,14 @@ This plugin intentionally specifies `@deepseek-ai/dsh-settings` and `@deepseek-a
916
929
 
917
930
  #### Web Settings (Recommended)
918
931
 
919
- After installation, open the config page (DSH 0.1.7-rc.1+):
932
+ After installation, open the config page (DSH 0.2.1-rc.2+):
920
933
 
921
934
  - Sidebar **Plugins** page → **Installed** group → `free-search` → click the `web-search-free` component row (the row's "configure" entry)
922
935
 
923
936
  The config page provides:
924
937
 
925
938
  - **Search engine**: Select an engine from the dropdown; changes take effect immediately upon saving.
926
- - **API keys**: Enter keys for Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / You.com (password fields; displayed as "configured" once saved; Exa / Tavily / Keenable / Firecrawl / Parallel / You.com work without a key too).
939
+ - **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).
927
940
  - **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.
928
941
  - **Test engine**: Tests the selected engine directly (no fallback chain; paid engines without a key report an explicit error).
929
942
  - **Use Bing default**: stage a switch back to the stable free Bing engine; `Discard` only cancels unsaved edits
@@ -1015,7 +1028,7 @@ If you deliberately pinned `fetchProvider: http` (you only want the built-in fet
1015
1028
 
1016
1029
  #### Configuration File
1017
1030
 
1018
- Since DSH 0.1.7-rc.1 the configuration is stored with the profile's plugin entry: the settings page and `/free-search-engine` both write the `config` of the `web-search-free` (`dsh-free-search`) entry in the active profile's `cordis.patch.yml`.
1031
+ Since DSH 0.1.7-rc.1 (the current release line requires 0.2.1-rc.2+) the configuration is stored with the profile's plugin entry: the settings page and `/free-search-engine` both write the `config` of the `web-search-free` (`dsh-free-search`) entry in the active profile's `cordis.patch.yml`.
1019
1032
 
1020
1033
  The old `free-search:` section of `~/.dsh/settings.yaml` is **not** imported by the DSH core (`importLegacyDocument` only maps `ui-developer-tools` / `ui-onboarding` / `shell`); the file is renamed to `settings.yaml.imported` after the other sections are imported, and the section's values stay there. The plugin detects that section in `settings.yaml.imported` (or in a still-present `settings.yaml`) at startup and seeds the recognized fields into this entry's `config` **once** (watch for `free-search: migrated N field(s)…` in the startup log). You can also migrate manually by copying the values from `settings.yaml.imported` into the plugin row config.
1021
1034
 
@@ -1042,6 +1055,8 @@ promptConstraintsIndex: 0
1042
1055
  disabledTools: [] # tools that are not registered at all (e.g. [domain_search]); their schemas leave the context too
1043
1056
  bingMarket: zh-CN # Bing market; empty = automatic (no mkt sent)
1044
1057
  fetchProviderTakeover: true # false = keep the fetchProvider: http you pinned yourself
1058
+ browserFetch: true # use the system browser headless renderer when direct fetch fails
1059
+ fetchPrefer: exa # exa | firecrawl — which keyed fetch tier to try first
1045
1060
  region: cn-zh # DuckDuckGo region (optional)
1046
1061
  searxngInstances: # Custom SearXNG instances (optional)
1047
1062
  - https://your-instance.example
@@ -1065,6 +1080,8 @@ perplexityApiKey: ...
1065
1080
  serpbaseApiKey: ... # Or configure via the web settings UI
1066
1081
  serplyApiKey: ... # Or configure via the web settings UI
1067
1082
  outcrawlApiKey: ... # Or configure via the web settings UI
1083
+ googleCseApiKey: ... # Google Custom Search API key
1084
+ googleCseId: "..." # Programmable Search Engine cx
1068
1085
  deepseekApiKey: ...
1069
1086
  ```
1070
1087
 
@@ -1226,7 +1243,7 @@ Restart `dsh web` after switching to apply changes.
1226
1243
 
1227
1244
  #### Offline self-check assertions (`tools/`)
1228
1245
 
1229
- **Forty-seven** zero-dependency assertion scripts ship with the repo (**776 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1246
+ **Fifty** zero-dependency assertion scripts ship with the repo (**796 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1230
1247
 
1231
1248
  | Script | Covers | Run (count) |
1232
1249
  |---|---|---|
@@ -1237,13 +1254,16 @@ Restart `dsh web` after switching to apply changes.
1237
1254
  | `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) |
1238
1255
  | `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) |
1239
1256
  | `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) |
1240
- | `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, and the catalog covers 35 engines with the right free/explicit flags | `node tools/assert-engine-modules.mjs` (4) |
1257
+ | `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, and the catalog covers 36 engines with the right free/explicit flags | `node tools/assert-engine-modules.mjs` (4) |
1241
1258
  | `assert-result-ranking.mjs` | merged ranking: **eTLD+1 same-site detection** / domain round-robin / `seenIn` demoted / freshness only under a time filter | `node tools/assert-result-ranking.mjs` (31) |
1242
1259
  | `assert-url-norm.mjs` | URL normalization: strips only audited tracking params, keeps params that may identify different resources | `node tools/assert-url-norm.mjs` (72) |
1243
1260
  | `assert-prompt-contract.mjs` | system-prompt contract: **search ≠ fetch**, untrusted-data boundary, model engines only when explicitly selected | `node tools/assert-prompt-contract.mjs` (9) |
1244
1261
  | `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) |
1245
1262
  | `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) |
1246
1263
  | `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) |
1264
+ | `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) |
1265
+ | `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) |
1266
+ | `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) |
1247
1267
  | `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) |
1248
1268
  | `assert-vertical.mjs` | `domain_search` registry of 41 engines, per-engine descriptions, unknown-engine errors, no research dependency | `node tools/assert-vertical.mjs` (8) |
1249
1269
  | `assert-free-search-test-schema.mjs` | `free_search_test` output schema matches real output (incl. auto/multi virtual modes) | `node tools/assert-free-search-test-schema.mjs` (8) |
package/lib/client.js CHANGED
@@ -429,6 +429,14 @@ window.__ModuleLoader__.load({
429
429
  marketAuto: "自动 —— 不发送 mkt(推荐用于非上列地区)",
430
430
  fetchTakeoverLabel: "自动接管 web_fetch",
431
431
  fetchTakeoverHint: "开启时:web.fetchProvider 未设置或仍是出厂默认 http 会接管为 fs-quality-fetch。如果你刻意 pin 了 http(例如只想用内置抓取),关掉此项。",
432
+ browserFetchLabel: "用本机浏览器渲染",
433
+ browserFetchHint: "直连失败时用系统 Chrome/Edge 无头加载页面,能过 JS 挑战;没有浏览器时自动跳过。",
434
+ fetchPreferLabel: "抓取质量链顺序",
435
+ fetchPreferExa: "Exa 优先",
436
+ fetchPreferFirecrawl: "Firecrawl 优先",
437
+ fetchPreferHint: "直连和浏览器都失败后先试哪个;只有两个都配了 key 时才有区别。",
438
+ googleCseIdLabel: "Google 搜索引擎 ID",
439
+ googleCseIdHint: "Programmable Search Engine 的 cx(形如 0123…:abc…);配合 GOOGLE_CSE_API_KEY 使用,免费 100 次/天。",
432
440
  restoreOfficial: "恢复官方搜索",
433
441
  restoreOfficialHint: "把 web.searchProvider 改回 deepseek-official、web.fetchProvider 改回 http。停用或卸载本插件前建议先点一次,避免宿主报 configured web provider \"ddg\" is not registered。",
434
442
  restoringOfficial: "恢复中…",
@@ -585,6 +593,14 @@ window.__ModuleLoader__.load({
585
593
  marketAuto: "Automatic — send no mkt (recommended outside the listed regions)",
586
594
  fetchTakeoverLabel: "Take over web_fetch automatically",
587
595
  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
+ browserFetchLabel: "Render with the local browser",
597
+ browserFetchHint: "When direct fetch fails, load the page in headless Chrome/Edge to pass JS challenges; skipped when no browser is installed.",
598
+ fetchPreferLabel: "Fetch quality-chain order",
599
+ fetchPreferExa: "Exa first",
600
+ fetchPreferFirecrawl: "Firecrawl first",
601
+ fetchPreferHint: "Which keyed tier to try first after direct and browser both fail; only matters when both keys are configured.",
602
+ googleCseIdLabel: "Google Programmable Search engine ID",
603
+ googleCseIdHint: "The cx from Programmable Search Engine (looks like 0123…:abc…); used with GOOGLE_CSE_API_KEY, free 100 queries/day.",
588
604
  restoreOfficial: "Restore official search",
589
605
  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.",
590
606
  restoringOfficial: "Restoring…",
@@ -634,7 +650,7 @@ window.__ModuleLoader__.load({
634
650
  "cache_search",
635
651
  "domain_search",
636
652
  ];
637
- const PLUGIN_VERSION = "0.9.37";
653
+ const PLUGIN_VERSION = "0.9.39";
638
654
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
639
655
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
640
656
  const NAV_ITEMS = [
@@ -674,6 +690,7 @@ window.__ModuleLoader__.load({
674
690
  { id: "serpbase", label: "SerpBase · Google", badge: "API KEY", link: "https://serpbase.dev" },
675
691
  { id: "serply", label: "Serply · Google", badge: "API KEY", link: "https://serply.io" },
676
692
  { id: "outcrawl", label: "Outcrawl", badge: "API KEY", link: "https://outcrawl.ai" },
693
+ { id: "google", label: "Google · 自定义搜索", badge: "API KEY", link: "https://developers.google.com/custom-search/v1/overview" },
677
694
  { id: "deepseek-official", label: "DeepSeek Official", badge: "API KEY", link: "https://platform.deepseek.com/api_keys" },
678
695
  { id: "deepseek-tools", label: "DeepSeek Tools API", badge: "API KEY", link: "https://api-docs.deepseek.com/zh-cn/guides/search" },
679
696
  { id: "you", label: "You.com", badge: "FREE", link: "https://you.com/platform/api-keys" },
@@ -898,6 +915,8 @@ window.__ModuleLoader__.load({
898
915
  const [safeSearch, setSafeSearch] = react.useState("off");
899
916
  const [bingMarket, setBingMarket] = react.useState("zh-CN");
900
917
  const [fetchProviderTakeover, setFetchProviderTakeover] = react.useState(true);
918
+ const [browserFetch, setBrowserFetch] = react.useState(true);
919
+ const [fetchPrefer, setFetchPrefer] = react.useState("exa");
901
920
  const [anysearchKey, setAnysearchKey] = react.useState("");
902
921
  const [exaKey, setExaKey] = react.useState("");
903
922
  const [tavilyKey, setTavilyKey] = react.useState("");
@@ -909,6 +928,8 @@ window.__ModuleLoader__.load({
909
928
  const [serpbaseKey, setSerpbaseKey] = react.useState("");
910
929
  const [serplyKey, setSerplyKey] = react.useState("");
911
930
  const [outcrawlKey, setOutcrawlKey] = react.useState("");
931
+ const [googleKey, setGoogleKey] = react.useState("");
932
+ const [googleCx, setGoogleCx] = react.useState("");
912
933
  const [youcomKey, setYoucomKey] = react.useState("");
913
934
  const [baiduKey, setBaiduKey] = react.useState("");
914
935
  const [kimiKey, setKimiKey] = react.useState("");
@@ -993,6 +1014,7 @@ window.__ModuleLoader__.load({
993
1014
  serpbase: [serpbaseKey, setSerpbaseKey],
994
1015
  serply: [serplyKey, setSerplyKey],
995
1016
  outcrawl: [outcrawlKey, setOutcrawlKey],
1017
+ google: [googleKey, setGoogleKey],
996
1018
  you: [youcomKey, setYoucomKey],
997
1019
  baidu: [baiduKey, setBaiduKey],
998
1020
  kimi: [kimiKey, setKimiKey],
@@ -1059,6 +1081,8 @@ window.__ModuleLoader__.load({
1059
1081
  setSafeSearch(v.safeSearch === "strict" || v.safeSearch === "moderate" ? v.safeSearch : "off");
1060
1082
  setBingMarket(v.bingMarket === undefined ? "zh-CN" : v.bingMarket);
1061
1083
  setFetchProviderTakeover(v.fetchProviderTakeover !== false);
1084
+ setBrowserFetch(v.browserFetch !== false);
1085
+ setFetchPrefer(v.fetchPrefer === "firecrawl" ? "firecrawl" : "exa");
1062
1086
  setLang(v.lang ?? "zh");
1063
1087
  setUiLang(typeof v.uiLang === "string" ? v.uiLang : "");
1064
1088
  setPromptLanguage(v.promptLanguage === "zh" ? "zh" : "en");
@@ -1079,6 +1103,8 @@ window.__ModuleLoader__.load({
1079
1103
  setSerpbaseKey(v.serpbaseApiKey ?? "");
1080
1104
  setSerplyKey(v.serplyApiKey ?? "");
1081
1105
  setOutcrawlKey(v.outcrawlApiKey ?? "");
1106
+ setGoogleKey(v.googleCseApiKey ?? "");
1107
+ setGoogleCx(v.googleCseId ?? "");
1082
1108
  setYoucomKey(v.youcomApiKey ?? "");
1083
1109
  setBaiduKey(v.baiduApiKey ?? "");
1084
1110
  setKimiKey(v.kimiApiKey ?? "");
@@ -1127,6 +1153,7 @@ window.__ModuleLoader__.load({
1127
1153
  if (path === "jinaApiKey") configured.jina = true;
1128
1154
  if (path === "searxngBearerToken") configured.searxng = true;
1129
1155
  if (path === "degoogApiKey") configured.degoog = true;
1156
+ if (path === "googleCseApiKey") configured.google = true;
1130
1157
  }
1131
1158
  }
1132
1159
  setKeysConfigured(configured);
@@ -1138,7 +1165,7 @@ window.__ModuleLoader__.load({
1138
1165
  const cred = await bridgeCredentialsStatus();
1139
1166
  if (cred.ok) {
1140
1167
  const cc = {};
1141
- 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", baiduApiKey: "baidu", kimiApiKey: "kimi", aliyunApiKey: "aliyun", doubaoApiKey: "doubao", openaiApiKey: "openai", geminiApiKey: "gemini", claudeApiKey: "claude", zhihuApiKey: "zhihu", tinyfishApiKey: "tinyfish", jinaApiKey: "jina", searxngBearerToken: "searxng" };
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" };
1142
1169
  for (const [k, v] of Object.entries(cred.value.configured ?? {})) {
1143
1170
  if (map[k]) cc[map[k]] = v;
1144
1171
  }
@@ -1186,6 +1213,7 @@ window.__ModuleLoader__.load({
1186
1213
  ["serpbaseApiKey", serpbaseKey],
1187
1214
  ["serplyApiKey", serplyKey],
1188
1215
  ["outcrawlApiKey", outcrawlKey],
1216
+ ["googleCseApiKey", googleKey],
1189
1217
  ["youcomApiKey", youcomKey],
1190
1218
  ["baiduApiKey", baiduKey],
1191
1219
  ["kimiApiKey", kimiKey],
@@ -1231,6 +1259,9 @@ window.__ModuleLoader__.load({
1231
1259
  ops.push({ op: "set", path: ["safeSearch"], value: safeSearch });
1232
1260
  ops.push({ op: "set", path: ["bingMarket"], value: bingMarket });
1233
1261
  ops.push({ op: "set", path: ["fetchProviderTakeover"], value: fetchProviderTakeover });
1262
+ ops.push({ op: "set", path: ["googleCseId"], value: googleCx.trim() });
1263
+ ops.push({ op: "set", path: ["browserFetch"], value: browserFetch });
1264
+ ops.push({ op: "set", path: ["fetchPrefer"], value: fetchPrefer === "firecrawl" ? "firecrawl" : "exa" });
1234
1265
  if (keyStorage !== "credentials") {
1235
1266
  // settings 模式:key 写入当前 profile 的插件条目 config(cordis.patch.yml)
1236
1267
  for (const [field, value] of keyFields) {
@@ -1976,6 +2007,33 @@ react_jsx_runtime.jsx("div", {
1976
2007
  }),
1977
2008
  ],
1978
2009
  }),
2010
+ react_jsx_runtime.jsx("div", {
2011
+ className: "dshfs-field",
2012
+ children: [
2013
+ react_jsx_runtime.jsx("div", {
2014
+ className: "dshfs-label",
2015
+ children: t.googleCseIdLabel,
2016
+ }),
2017
+ react_jsx_runtime.jsx("input", {
2018
+ className: "dshfs-input",
2019
+ type: "text",
2020
+ value: googleCx,
2021
+ spellCheck: false,
2022
+ placeholder: "0123456789:abcdef",
2023
+ disabled: !ready || saving,
2024
+ onChange: (e) => {
2025
+ setGoogleCx(e.target.value);
2026
+ setDirty(true);
2027
+ setFailed(false);
2028
+ setSaveError("");
2029
+ },
2030
+ }),
2031
+ react_jsx_runtime.jsx("p", {
2032
+ className: "dshfs-hint",
2033
+ children: t.googleCseIdHint,
2034
+ }),
2035
+ ],
2036
+ }),
1979
2037
  react_jsx_runtime.jsx("div", {
1980
2038
  className: "dshfs-field",
1981
2039
  id: "dshfs-anchor-fallback",
@@ -2304,6 +2362,61 @@ react_jsx_runtime.jsx("div", {
2304
2362
  }),
2305
2363
  ],
2306
2364
  }),
2365
+ react_jsx_runtime.jsx("div", {
2366
+ className: "dshfs-field",
2367
+ children: [
2368
+ react_jsx_runtime.jsx("label", {
2369
+ className: "dshfs-platform",
2370
+ children: [
2371
+ react_jsx_runtime.jsx("input", {
2372
+ type: "checkbox",
2373
+ checked: browserFetch,
2374
+ disabled: !ready || saving,
2375
+ onChange: (e) => {
2376
+ setBrowserFetch(e.target.checked);
2377
+ setDirty(true);
2378
+ setFailed(false);
2379
+ setSaveError("");
2380
+ },
2381
+ }),
2382
+ t.browserFetchLabel,
2383
+ ],
2384
+ }),
2385
+ react_jsx_runtime.jsx("p", {
2386
+ className: "dshfs-hint",
2387
+ children: t.browserFetchHint,
2388
+ }),
2389
+ ],
2390
+ }),
2391
+ react_jsx_runtime.jsx("div", {
2392
+ className: "dshfs-field",
2393
+ children: [
2394
+ react_jsx_runtime.jsx("div", {
2395
+ className: "dshfs-label",
2396
+ children: t.fetchPreferLabel,
2397
+ }),
2398
+ react_jsx_runtime.jsx("select", {
2399
+ className: "dshfs-select",
2400
+ value: fetchPrefer,
2401
+ style: { colorScheme: selectColorScheme },
2402
+ disabled: !ready || saving,
2403
+ onChange: (e) => {
2404
+ setFetchPrefer(e.target.value === "firecrawl" ? "firecrawl" : "exa");
2405
+ setDirty(true);
2406
+ setFailed(false);
2407
+ setSaveError("");
2408
+ },
2409
+ children: [
2410
+ react_jsx_runtime.jsx("option", { value: "exa", children: t.fetchPreferExa }),
2411
+ react_jsx_runtime.jsx("option", { value: "firecrawl", children: t.fetchPreferFirecrawl }),
2412
+ ],
2413
+ }),
2414
+ react_jsx_runtime.jsx("p", {
2415
+ className: "dshfs-hint",
2416
+ children: t.fetchPreferHint,
2417
+ }),
2418
+ ],
2419
+ }),
2307
2420
  react_jsx_runtime.jsx("div", {
2308
2421
  className: "dshfs-field",
2309
2422
  children: [
package/lib/doctor.js CHANGED
@@ -55,6 +55,13 @@ export function buildDoctorReport({
55
55
  }
56
56
  const mark = engine.disabled || engine.credential?.configured === false || (engine.cooling?.remainingMs ?? 0) > 0 ? " " : "*";
57
57
  lines.push(` ${mark} ${engine.id.padEnd(16)} ${flags.join(" · ") || "ready"}`);
58
+ if (engine.stats && engine.stats.calls > 0) {
59
+ const stats = engine.stats;
60
+ const last = stats.lastErrorClass ? ` · last ${stats.lastErrorClass}` : "";
61
+ lines.push(
62
+ ` calls ${stats.calls} · ok ${stats.ok} · empty ${stats.empty} · fail ${stats.fail} · avg ${stats.avgMs}ms${last}`
63
+ );
64
+ }
58
65
  }
59
66
 
60
67
  if (engines.some((engine) => engine.cooling?.reason)) {
@@ -23,6 +23,7 @@ const BASE_ENGINES = [
23
23
  { id: "serpbase", free: false, time: false },
24
24
  { id: "serply", free: false, time: false },
25
25
  { id: "outcrawl", free: false, time: false },
26
+ { id: "google", free: false, time: true },
26
27
  { id: "deepseek-official", free: false, time: false },
27
28
  { id: "deepseek-tools", free: false, time: true },
28
29
  { id: "you", free: false, time: false },
@@ -56,6 +57,7 @@ export const TIME_ENGINES = [
56
57
  "exa",
57
58
  "keenable",
58
59
  "firecrawl",
60
+ "google",
59
61
  "parallel",
60
62
  "searxng",
61
63
  "degoog",
@@ -80,6 +82,7 @@ export const DEFAULT_FALLBACK_ORDER = [
80
82
  "serpbase",
81
83
  "serply",
82
84
  "outcrawl",
85
+ "google",
83
86
  "agy",
84
87
  "deepseek-tools",
85
88
  "deepseek-official",
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Per-engine concurrency limit and in-process call statistics.
3
+ *
4
+ * Multi mode and overlapping user calls can hit the same engine at once; without
5
+ * a gate a free HTML engine gets several requests in the same second and starts
6
+ * serving captchas. The stats feed the doctor report ("why is this engine not
7
+ * being used" plus how it has been behaving).
8
+ */
9
+
10
+ export function createEngineRuntime({ now = () => Date.now() } = {}) {
11
+ const active = new Map();
12
+ const waiters = new Map();
13
+ const stats = new Map();
14
+
15
+ const ensure = (engine) => {
16
+ if (!stats.has(engine)) stats.set(engine, { calls: 0, ok: 0, empty: 0, fail: 0, totalMs: 0, lastErrorClass: "" });
17
+ return stats.get(engine);
18
+ };
19
+ const bucket = (engine) => {
20
+ if (!active.has(engine)) active.set(engine, 0);
21
+ if (!waiters.has(engine)) waiters.set(engine, []);
22
+ return { waiters: waiters.get(engine), active };
23
+ };
24
+
25
+ function acquire(engine, limit, signal) {
26
+ const state = bucket(engine);
27
+ if ((active.get(engine) ?? 0) < limit) {
28
+ active.set(engine, (active.get(engine) ?? 0) + 1);
29
+ return Promise.resolve();
30
+ }
31
+ return new Promise((resolve, reject) => {
32
+ const waiter = () => {
33
+ cleanup();
34
+ active.set(engine, (active.get(engine) ?? 0) + 1);
35
+ resolve();
36
+ };
37
+ const onAbort = () => {
38
+ cleanup();
39
+ const list = state.waiters;
40
+ const at = list.indexOf(waiter);
41
+ if (at >= 0) list.splice(at, 1);
42
+ reject(signal?.reason instanceof Error ? signal.reason : new Error("aborted"));
43
+ };
44
+ const cleanup = () => signal?.removeEventListener("abort", onAbort);
45
+ if (signal) {
46
+ if (signal.aborted) {
47
+ reject(signal.reason instanceof Error ? signal.reason : new Error("aborted"));
48
+ return;
49
+ }
50
+ signal.addEventListener("abort", onAbort, { once: true });
51
+ }
52
+ state.waiters.push(waiter);
53
+ });
54
+ }
55
+
56
+ function release(engine) {
57
+ active.set(engine, Math.max(0, (active.get(engine) ?? 1) - 1));
58
+ const list = waiters.get(engine) ?? [];
59
+ const next = list.shift();
60
+ if (next) next();
61
+ }
62
+
63
+ async function run(engine, limit, fn, { signal } = {}) {
64
+ await acquire(engine, Math.max(1, limit), signal);
65
+ try {
66
+ return await fn();
67
+ } finally {
68
+ release(engine);
69
+ }
70
+ }
71
+
72
+ function record(engine, { ms, sources = 0, error } = {}) {
73
+ const entry = ensure(engine);
74
+ entry.calls += 1;
75
+ if (error) {
76
+ entry.fail += 1;
77
+ if (typeof error.class === "string") entry.lastErrorClass = error.class;
78
+ } else if (sources > 0) {
79
+ entry.ok += 1;
80
+ } else {
81
+ entry.empty += 1;
82
+ }
83
+ if (Number.isFinite(ms) && ms >= 0) entry.totalMs += ms;
84
+ }
85
+
86
+ function snapshot() {
87
+ const out = {};
88
+ for (const [engine, entry] of stats) {
89
+ out[engine] = {
90
+ calls: entry.calls,
91
+ ok: entry.ok,
92
+ empty: entry.empty,
93
+ fail: entry.fail,
94
+ avgMs: entry.calls > 0 ? Math.round(entry.totalMs / entry.calls) : 0,
95
+ lastErrorClass: entry.lastErrorClass,
96
+ };
97
+ }
98
+ return out;
99
+ }
100
+
101
+ return { run, record, snapshot, now };
102
+ }
103
+
104
+ /** Default limit per engine: scraped HTML pages are more fragile than APIs. */
105
+ export const ENGINE_CONCURRENCY_LIMIT = 2;
106
+ export const SERP_CONCURRENCY_LIMIT = 1;