dsh-free-search 0.9.14 → 0.9.16
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 +27 -13
- package/lib/client.js +17 -9
- package/lib/fetch_provider.js +27 -27
- package/lib/index.js +147 -23
- package/lib/multi_policy.js +1 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
|
|
|
37
37
|
- **引擎测试** —— `free_search_test` 工具让 agent 一键测试所有引擎;设置页也有"测试引擎"按钮(直测当前引擎,不走回退链,付费引擎无 key 会明确报错)
|
|
38
38
|
- **全局引擎开关与回退优先级** —— 设置页可勾选/取消引擎(取消后全局生效:普通搜索 / Auto / `advanced_search` / `multi_search` / 引擎测试都不再用它),并可用 ↑↓ 调整全局回退顺序(一键恢复默认)
|
|
39
39
|
- **Multi 模式** —— 可把搜索引擎设为 `Multi Search`:`web_search` 按查询语言并发**对应语言池的全部**已启用引擎(不再是前 3 个;中文/英文池可在设置页编辑,每池最低 2 个引擎)、按 URL 合并去重(同站判定用 **eTLD+1**)、跨源命中的结果优先;设置页有 **Fast / Balanced / Deep** 三档强度,也可手填并发上限与目标成功源数;整轮检索共享 **30 秒总预算**,到点返回已有结果(代价是成倍消耗额度;multi 失败会自动退回单引擎回退链)
|
|
40
|
-
- **统一引擎回退** —— 任何引擎失败(付费/免费,缺 key/401/限流/网络)自动轮流尝试下一个引擎:首选引擎 → 其他引擎(exa/tavily/keenable/firecrawl/parallel 无 key 也会尝试,因为它们自带 keyless 免费额度)→ 剩余免费引擎,搜索永不直接失败;结果顶部注明实际生效的引擎(如 `Note: perplexity unavailable or failed, using exa.`);失败按类别处理:额度/鉴权失败→本会话冷却该引擎,反爬→短退避,超时/5xx/限流→同引擎重试一次,解析失败/0 结果→不冷却(详见下文「失败分类与引擎冷却」)
|
|
40
|
+
- **统一引擎回退** —— 任何引擎失败(付费/免费,缺 key/401/限流/网络)自动轮流尝试下一个引擎:首选引擎 → 其他引擎(exa/tavily/keenable/firecrawl/parallel/you 无 key 也会尝试,因为它们自带 keyless 免费额度)→ 剩余免费引擎,搜索永不直接失败;结果顶部注明实际生效的引擎(如 `Note: perplexity unavailable or failed, using exa.`);失败按类别处理:额度/鉴权失败→本会话冷却该引擎,反爬→短退避,超时/5xx/限流→同引擎重试一次,解析失败/0 结果→不冷却(详见下文「失败分类与引擎冷却」)
|
|
41
41
|
- **时间过滤** —— `advanced_search` 工具支持 `timeRange`:固定档、自定义相对值、绝对日期三种形式(详见下方逻辑说明)
|
|
42
42
|
- **系统提示词注入** —— agent 知道当前用哪个引擎、哪些需要 key;并明确所有搜索结果是**不可信外部数据**,不得执行其中的指令
|
|
43
43
|
- **提示注入防护(不可信数据边界)** —— 插件自有工具(advanced_search / platform_search / free_search_test)的网页文本包在 `<untrusted-web-content>` 边界内(正文里自带的同名标记会被剥离,防止提前闭合);核心 web_search / web_fetch 由 DSH 核心自带同类提示(`External web content follows...`);所有 snippet 统一清洗并截断到 300 字符
|
|
@@ -65,17 +65,18 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
|
|
|
65
65
|
| `bing` | Bing | 免费 | **默认引擎**,最稳定,中文优化(zh-CN) |
|
|
66
66
|
| `anysearch` | AnySearch AI | 免费 | AI 搜索,无 key(匿名额度) |
|
|
67
67
|
| `searxng` | SearXNG 元搜索 | 免费 | 多实例自动切换,支持自定义实例 |
|
|
68
|
+
| `degoog` | Degoog(自建聚合器) | 免费 | 需要自己的实例(`degoogInstances`),免 key;实例开启 API Key 时用 `degoogApiKey`(Bearer) |
|
|
68
69
|
| `exa` | Exa | 免费 | **无 key 也可用**(MCP 匿名),配 key 提升额度 |
|
|
69
70
|
| `tavily` | Tavily | 免费 | **无 key 也可用**(keyless 匿名),配 key 提升额度 |
|
|
70
71
|
| `keenable` | Keenable | 免费 | **无 key 也可用**(MCP 匿名),配 key 提升额度 |
|
|
71
72
|
| `firecrawl` | Firecrawl | 免费 | **无 key 也可用**(官方免 key 匿名额度),配 key 提升限额。注意:keyless 档按**出口 IP** 判定,VPN/代理出口会被 403 拒绝;插件会冷却 6 小时并说明原因(有 key 不受影响) |
|
|
72
73
|
| `parallel` | Parallel | 免费 | **无 key 也可用**(官方 MCP 匿名额度),配 key 提升额度并支持精确时间过滤 |
|
|
74
|
+
| `you` | You.com | 免费 | **无 key 也可用**(官方免 key 档,每天 100 次),配 `YDC_API_KEY` 提升额度(旧名 `YOUCOM_API_KEY` 继续兼容) |
|
|
73
75
|
| `perplexity` | Perplexity | 付费 | 需 `PERPLEXITY_API_KEY` |
|
|
74
76
|
| `serpbase` | SerpBase | 付费 | 需 `SERPBASE_API_KEY`(serpbase.dev,注册送 100 次免费额度) |
|
|
75
77
|
| `serply` | Serply | 付费 | 需 `SERPLY_API_KEY`(serply.io,新账户 30 天内 2,500 次免费额度);Google 网页结果,按设置页语言本地化 |
|
|
76
78
|
| `deepseek-official` | DeepSeek 官方 | 付费 | 需 `DEEPSEEK_API_KEY`;走 Anthropic 兼容的 `web_search` 服务端工具,每次搜索是一整个模型轮次(慢、耗 token) |
|
|
77
79
|
| `deepseek-tools` | DeepSeek 原生搜索 API | 付费 | 需 `DEEPSEEK_API_KEY`(与上一档共用);直接 `POST /v1/tools/search`,无模型参与,返回结构化 `results[]`(`title`/`url`/`summary`/`date`),同 query 实测 ~0.3s vs 上一档 ~5-6s |
|
|
78
|
-
| `you` | You.com | 付费 | 需 `YOUCOM_API_KEY`(you.com/platform/api-keys,注册即送免费额度) |
|
|
79
80
|
| `baidu` | 百度千帆 AI 搜索 | 额度 | 需 `BAIDU_API_KEY`(千帆 AI 搜索,每日赠 50 次,超额按量后付费);中文全网,支持时间过滤 |
|
|
80
81
|
| `kimi` | Kimi(Moonshot)联网搜索 | 付费 | 需 `MOONSHOT_API_KEY`(basic 约 ¥0.01/次),返回带正文 chunks 的中文结果;**无免费额度**,适合显式选用或作质量升级池,不建议放进默认并发池 |
|
|
81
82
|
| `kimi` | Kimi(Moonshot)联网搜索 | 付费 | 需 `MOONSHOT_API_KEY`(basic 约 ¥0.01/次),返回带正文 chunks 的中文结果 |
|
|
@@ -110,9 +111,9 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
|
|
|
110
111
|
| 档位 | 引擎 | 超出后 |
|
|
111
112
|
|---|---|---|
|
|
112
113
|
| ① 无限免 key | `ddg` / `ddg-lite` / `bing` / `searxng` / `anysearch` | — |
|
|
113
|
-
| ② 匿名额度(不配 key 也能跑) | `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` | 配 key 提额 |
|
|
114
|
+
| ② 匿名额度(不配 key 也能跑) | `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you`(每天 100 次) | 配 key 提额 |
|
|
114
115
|
| ③ 免费额度(需 key) | `zhihu_global` / `zhihu_site`(每日 5,000 次试用)、`doubao`(每月 500 次)、`baidu`(每日 50 次)、`aliyun`(新用户 200 次包) | 按量后付费 |
|
|
115
|
-
| ④ 付费升级(需 key 才有产出) | `serpbase`(注册送 100 次)/ `serply`(30 天 2,500 次)/ `
|
|
116
|
+
| ④ 付费升级(需 key 才有产出) | `serpbase`(注册送 100 次)/ `serply`(30 天 2,500 次)/ `perplexity` / `deepseek-official` / `deepseek-tools` / `kimi` | 按量 / 按次 |
|
|
116
117
|
| ⑤ 按次计费(模型内置,显式-only) | `openai` / `gemini` / `claude` | 按 token + 每次搜索 |
|
|
117
118
|
|
|
118
119
|
选默认池的经验:**① 打底 + ③ 打主力**;② 可以进但要知道它在烧匿名额度;④ 只在你确实需要该源时显式选用;⑤ 永不入池。完整的逐引擎额度事实与默认池提案见 [docs/engine-quota-tiers.md](./docs/engine-quota-tiers.md)。
|
|
@@ -124,6 +125,7 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
|
|
|
124
125
|
- **Tavily**:通过 `x-tavily-access-mode: keyless` 头走 keyless 匿名额度,不配 key 即可用;配置 `TAVILY_API_KEY` 后走账号档,额度更高、结果质量更稳定。
|
|
125
126
|
- **Keenable**:无 key 时走其公开 MCP 端点(`api.keenable.ai/mcp`)匿名调用;配置 `KEENABLE_API_KEY` 后走 REST API(`api.keenable.ai/v1/search`),额度更高、按组织限流。
|
|
126
127
|
- **Firecrawl**:其 `/v2/search` 端点**无需 key** 即可使用(官方文档明确说明,有匿名限流);配置 `FIRECRAWL_API_KEY` 后可提高限额。支持 `tbs` 时间过滤(`qdr:h/d/w/m/y` 与自定义日期区间)。
|
|
128
|
+
- **You.com**:无 key 时走官方免 key 档(`api.you.com/v1/agents/search`),每天 100 次免费搜索,无需注册;配置 `YDC_API_KEY`(旧名 `YOUCOM_API_KEY` 继续兼容)后走官方 Search API(`ydc-index.io/v1/search`),额度更高。
|
|
127
129
|
|
|
128
130
|
### 安装
|
|
129
131
|
|
|
@@ -205,7 +207,7 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
|
|
|
205
207
|
配置页提供:
|
|
206
208
|
|
|
207
209
|
- **Search engine**:下拉框切换引擎,保存即生效
|
|
208
|
-
- **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel 不填也可免 key 使用)
|
|
210
|
+
- **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel / You.com 不填也可免 key 使用)
|
|
209
211
|
- **推荐**:付费引擎 key 建议写入 harness 凭据中心 `~/.dsh/.credentials.yaml`(如 `DEEPSEEK_API_KEY: sk-...`,与官方 LLM provider 一致,一处管理所有 key)。插件读取优先级:凭据中心 > 设置页 > 环境变量,设置页填的 key 仅作为遗留兼容。
|
|
210
212
|
- **Test engine**:直测当前引擎可用性(不走回退链,付费引擎无 key 会明确报错)
|
|
211
213
|
- **Use Bing default**:把当前搜索引擎切回稳定的免费 Bing;`Discard` 只撤销尚未保存的编辑
|
|
@@ -317,6 +319,9 @@ region: cn-zh # DuckDuckGo 区域(可选)
|
|
|
317
319
|
searxngInstances: # 自定义 SearXNG 实例(可选)
|
|
318
320
|
- https://your-instance.example
|
|
319
321
|
searxngBearerToken: ... # 可选:发送 Authorization: Bearer <token>(设置页「SearXNG Bearer Token」同款)
|
|
322
|
+
degoogInstances: # 自建 degoog 实例(可选,例如 https://search.example.com)
|
|
323
|
+
- https://search.example.com
|
|
324
|
+
degoogApiKey: ... # 可选:实例开启 API Key 时使用的 Bearer 密钥
|
|
320
325
|
safeSearch: off # 安全搜索:off(默认)/ moderate / strict,作用于 bing / ddg / ddg-lite
|
|
321
326
|
blockedDomains: # 域名黑名单(可选):命中的域名不会进入结果
|
|
322
327
|
- spam-example.com
|
|
@@ -491,7 +496,7 @@ Search engine test:
|
|
|
491
496
|
|
|
492
497
|
#### 离线自检断言(tools/)
|
|
493
498
|
|
|
494
|
-
仓库自带 **
|
|
499
|
+
仓库自带 **26 个**零依赖断言脚本(合计 **587 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
|
|
495
500
|
|
|
496
501
|
| 脚本 | 覆盖 | 运行(项数) |
|
|
497
502
|
|---|---|---|
|
|
@@ -513,6 +518,8 @@ Search engine test:
|
|
|
513
518
|
| `assert-parallel-mcp.mjs` | Parallel MCP 引擎:25 s 超时/调用方取消覆盖**响应体读取**、共享 SSE 解析器(通知/多行帧)、6 类错误路径、REST 精确时间过滤 | `node tools/assert-parallel-mcp.mjs`(15) |
|
|
514
519
|
| `assert-output-language.mjs` | 语言分支(#92):`searchLanguage` 支持 zh/en/ja/ru/de/es/fr/ko 其余回退 en、`outputLanguage` 只输出 zh/en、天气文案 zh/en/ja(其它回退英文,含 WMO 描述与正文)、置信度说明随语言、失败备注随语言 | `node tools/assert-output-language.mjs`(10) |
|
|
515
520
|
| `assert-uncertainty.mjs` | 输出契约:0/1 源为 low、2 源与同站为 medium、3 个不同域为 high、时间过滤无日期、失败备注、聚合站提示 | `node tools/assert-uncertainty.mjs`(8) |
|
|
521
|
+
| `assert-youcom.mjs` | You.com 免 key 档(#90):两档 URL 与请求头、无 key 不发 `X-API-Key`、`YDC_API_KEY` 别名、429/401/402/5xx 分类 | `node tools/assert-youcom.mjs`(23) |
|
|
522
|
+
| `assert-degoog.mjs` | degoog 自建实例(#85):`/api/search` URL 规范化、查询编码、`time`/`lang` 参数、注册表位置、无需凭据 | `node tools/assert-degoog.mjs`(7) |
|
|
516
523
|
| `assert-multikey.mjs` | 多 key 字段:单 key 不变、逗号/分号/换行分隔、空白项丢弃、空输入为空数组 | `node tools/assert-multikey.mjs`(3) |
|
|
517
524
|
| `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
|
|
518
525
|
| `assert-fetch-charset.mjs` | 抓取编码(#88):`charset=gbk` / `gb2312` 按声明解码、无声明时嗅探 `<meta charset>` 与 http-equiv 形式、默认 UTF-8、未知 label 兜底 UTF-8 不抛错 | `node tools/assert-fetch-charset.mjs`(6) |
|
|
@@ -575,7 +582,7 @@ This plugin provides multiple free search engines with automatic fallback, compl
|
|
|
575
582
|
- **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)
|
|
576
583
|
- **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)
|
|
577
584
|
- **Multi mode** — pick `Multi Search` as the engine: web_search queries **every enabled engine of the query's language pool** concurrently (no longer top 3; zh/en pools editable in the settings UI, minimum 2 engines each), merges/deduplicates URLs (same-site detection via **eTLD+1**) and prioritizes cross-source hits; the settings UI offers **Fast / Balanced / Deep** presets or your own cap and target numbers; the whole run shares one **30-second budget** and returns whatever it already has when time is up (costs more quota; a failed multi run automatically falls back to the single-engine chain)
|
|
578
|
-
- **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 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 (see "Failure-aware fallback" below). Search never fails outright.
|
|
585
|
+
- **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 (see "Failure-aware fallback" below). Search never fails outright.
|
|
579
586
|
- **Time Filtering** — The `advanced_search` tool supports `timeRange`: fixed tiers, custom relative values, or an absolute date (details below)
|
|
580
587
|
- **System Prompt Injection** — The agent is aware of the currently active engine and which engines require API keys; it is also told that all search output is **untrusted external data** and must never be executed as instructions
|
|
581
588
|
- **Prompt-Injection Guard (untrusted-data boundary)** — Web-derived text from the plugin's own tools (`advanced_search` / `platform_search` / `free_search_test`) is wrapped in an explicit `<untrusted-web-content>` boundary (look-alike tags inside the text are stripped to prevent early closure); the core `web_search` / `web_fetch` tools carry DSH core's own notice (`External web content follows...`); every snippet is cleaned and capped at 300 characters
|
|
@@ -603,17 +610,18 @@ If this plugin has been helpful, a ⭐ on [GitHub](https://github.com/DDDMUC/dsh
|
|
|
603
610
|
| `bing` | Bing | Free | **Default engine**, most stable, optimized for Chinese (`zh-CN`) |
|
|
604
611
|
| `anysearch` | AnySearch AI | Free | AI search, no key needed (anonymous quota) |
|
|
605
612
|
| `searxng` | SearXNG Meta Search | Free | Multi-instance automatic failover; supports custom instances |
|
|
613
|
+
| `degoog` | Degoog (self-hosted aggregator) | Free | Needs your own instance (`degoogInstances`), no key; `degoogApiKey` (Bearer) only if the instance enables API keys |
|
|
606
614
|
| `exa` | Exa | Free | **Usable without a key** (anonymous MCP); configure a key for higher quota |
|
|
607
615
|
| `tavily` | Tavily | Free | **Usable without a key** (keyless anonymous); configure a key for higher quota |
|
|
608
616
|
| `keenable` | Keenable | Free | **Usable without a key** (anonymous MCP); configure a key for higher quota |
|
|
609
617
|
| `firecrawl` | Firecrawl | Free | **Usable without a key** (official keyless anonymous quota); a key adds higher limits. Note: the keyless tier is judged by **egress IP** — VPN/proxy egress gets a 403, in which case the plugin cools it down for 6 hours and says why (a key is unaffected) |
|
|
610
618
|
| `parallel` | Parallel | Free | **Works without a key** (official MCP anonymous quota); a key raises limits and enables precise time filtering |
|
|
619
|
+
| `you` | You.com | Free | **Works without a key** (official keyless tier, 100 searches a day); set `YDC_API_KEY` for higher limits (the old `YOUCOM_API_KEY` name still works) |
|
|
611
620
|
| `perplexity` | Perplexity | Paid | Requires `PERPLEXITY_API_KEY` |
|
|
612
621
|
| `serpbase` | SerpBase | Paid | Requires `SERPBASE_API_KEY` (serpbase.dev, 100 free queries on signup) |
|
|
613
622
|
| `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 |
|
|
614
623
|
| `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) |
|
|
615
624
|
| `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 |
|
|
616
|
-
| `you` | You.com | Paid | Requires `YOUCOM_API_KEY` (you.com/platform/api-keys, free tier on signup) |
|
|
617
625
|
| `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 |
|
|
618
626
|
| `kimi` | Kimi (Moonshot) Web Search | Paid | Requires `MOONSHOT_API_KEY` (basic ~¥0.01/call); returns Chinese results with body chunks; **no free quota**, so prefer explicit selection or the escalation pool over the default concurrent pool |
|
|
619
627
|
| `kimi` | Kimi (Moonshot) Web Search | Paid | Requires `MOONSHOT_API_KEY` (basic ~¥0.01/call); returns Chinese results with body chunks |
|
|
@@ -628,7 +636,7 @@ If this plugin has been helpful, a ⭐ on [GitHub](https://github.com/DDDMUC/dsh
|
|
|
628
636
|
| `claude` | Claude server-side web_search | Paid | Requires `ANTHROPIC_API_KEY`; results come from `web_search_tool_result`. **Billed per search, explicit selection only**; default `claude-sonnet-5-5`, model/endpoint configurable (`claudeModel` / `claudeBaseUrl`) |
|
|
629
637
|
|
|
630
638
|
- **Default engine is `bing`** (free and most stable), ready to use out of the box after installation.
|
|
631
|
-
- **Auto-failover**: any engine failure (rate-limited free engine, or missing/invalid paid key, network error) automatically tries the next engine — the configured engine first, then other engines (exa/tavily/keenable/firecrawl/parallel 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.`). Search never fails outright because of engine issues.
|
|
639
|
+
- **Auto-failover**: any engine failure (rate-limited free engine, or missing/invalid paid key, 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.`). Search never fails outright because of engine issues.
|
|
632
640
|
- **Official Links in Settings**: Free engines display "Visit Website →", while paid engines display "Get API Key →" (opens in a new tab):
|
|
633
641
|
- Exa: <https://dashboard.exa.ai/api-keys>
|
|
634
642
|
- Tavily: <https://app.tavily.com/home>
|
|
@@ -649,9 +657,9 @@ The free/paid binary is not what decides **who belongs in a default pool** — t
|
|
|
649
657
|
| Tier | Engines | Past the allowance |
|
|
650
658
|
|---|---|---|
|
|
651
659
|
| ① Unlimited, no key | `ddg` / `ddg-lite` / `bing` / `searxng` / `anysearch` | — |
|
|
652
|
-
| ② Anonymous quota (runs without a key) | `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` | key raises the quota |
|
|
660
|
+
| ② Anonymous quota (runs without a key) | `exa` / `tavily` / `keenable` / `firecrawl` / `parallel` / `you` (100/day) | key raises the quota |
|
|
653
661
|
| ③ Free quota (key required) | `zhihu_global` / `zhihu_site` (5,000/day trial), `doubao` (500/month), `baidu` (50/day), `aliyun` (200-call starter pack) | pay-as-you-go |
|
|
654
|
-
| ④ Paid upgrade (needs a key to return anything) | `serpbase` (100 free on signup) / `serply` (2,500 for 30 days) / `
|
|
662
|
+
| ④ Paid upgrade (needs a key to return anything) | `serpbase` (100 free on signup) / `serply` (2,500 for 30 days) / `perplexity` / `deepseek-official` / `deepseek-tools` / `kimi` | per call / per query |
|
|
655
663
|
| ⑤ Per-call billing (model built-in, explicit-only) | `openai` / `gemini` / `claude` | per token + per search |
|
|
656
664
|
|
|
657
665
|
Rule of thumb for a default pool: **① as the floor + ③ as the workhorse**; ② is allowed but remember it burns anonymous quota; ④ only when you actually want that source; ⑤ never enters a pool. Per-engine facts and a default-pool proposal live in [docs/engine-quota-tiers.md](./docs/engine-quota-tiers.md).
|
|
@@ -663,6 +671,7 @@ Rule of thumb for a default pool: **① as the floor + ③ as the workhorse**;
|
|
|
663
671
|
- **Tavily**: offers keyless anonymous quota via the `x-tavily-access-mode: keyless` header — it works without a key; configuring `TAVILY_API_KEY` switches to the account tier for higher quota and more stable results.
|
|
664
672
|
- **Keenable**: without a key it is called via its public MCP endpoint (`api.keenable.ai/mcp`); configuring `KEENABLE_API_KEY` switches to the REST API (`api.keenable.ai/v1/search`) for higher quota and organization-scoped rate limits.
|
|
665
673
|
- **Firecrawl**: its `/v2/search` endpoint works **without a key** out of the box (the official docs state "No API key needed to get started", with anonymous rate limits); configuring `FIRECRAWL_API_KEY` raises the limits. Supports `tbs` time filtering (`qdr:h/d/w/m/y` and custom date ranges).
|
|
674
|
+
- **You.com**: without a key it calls the official keyless tier (`api.you.com/v1/agents/search`), 100 free searches a day with no signup; setting `YDC_API_KEY` (the old `YOUCOM_API_KEY` name still works) switches to the Search API (`ydc-index.io/v1/search`) for higher limits.
|
|
666
675
|
|
|
667
676
|
### Installation
|
|
668
677
|
|
|
@@ -744,7 +753,7 @@ After installation, open the config page (DSH 0.1.7-rc.1+):
|
|
|
744
753
|
The config page provides:
|
|
745
754
|
|
|
746
755
|
- **Search engine**: Select an engine from the dropdown; changes take effect immediately upon saving.
|
|
747
|
-
- **API keys**: Enter keys for Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek (password fields; displayed as "configured" once saved; Exa / Tavily / Keenable / Firecrawl / Parallel work without a key too).
|
|
756
|
+
- **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).
|
|
748
757
|
- **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.
|
|
749
758
|
- **Test engine**: Tests the selected engine directly (no fallback chain; paid engines without a key report an explicit error).
|
|
750
759
|
- **Use Bing default**: stage a switch back to the stable free Bing engine; `Discard` only cancels unsaved edits
|
|
@@ -856,6 +865,9 @@ region: cn-zh # DuckDuckGo region (optional)
|
|
|
856
865
|
searxngInstances: # Custom SearXNG instances (optional)
|
|
857
866
|
- https://your-instance.example
|
|
858
867
|
searxngBearerToken: ... # Optional: send Authorization: Bearer <token> (same as the "SearXNG Bearer Token" row in the settings UI)
|
|
868
|
+
degoogInstances: # Self-hosted degoog instances (optional, e.g. https://search.example.com)
|
|
869
|
+
- https://search.example.com
|
|
870
|
+
degoogApiKey: ... # Optional: bearer key, only when your instance enables API keys
|
|
859
871
|
safeSearch: off # Safe search: off (default) / moderate / strict; applies to bing / ddg / ddg-lite
|
|
860
872
|
blockedDomains: # Domain blocklist (optional): matching domains never enter the results
|
|
861
873
|
- spam-example.com
|
|
@@ -1030,7 +1042,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1030
1042
|
|
|
1031
1043
|
#### Offline self-check assertions (`tools/`)
|
|
1032
1044
|
|
|
1033
|
-
**Twenty-
|
|
1045
|
+
**Twenty-six** zero-dependency assertion scripts ship with the repo (**587 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
|
|
1034
1046
|
|
|
1035
1047
|
| Script | Covers | Run (count) |
|
|
1036
1048
|
|---|---|---|
|
|
@@ -1052,6 +1064,8 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1052
1064
|
| `assert-parallel-mcp.mjs` | Parallel MCP engine: the 25 s timeout / caller abort covers the **body read**, shared SSE parser (notifications, multiline frames), six error paths, REST precise time filtering | `node tools/assert-parallel-mcp.mjs` (15) |
|
|
1053
1065
|
| `assert-output-language.mjs` | language branches (#92): `searchLanguage` passes zh/en/ja/ru/de/es/fr/ko through and falls back to en, `outputLanguage` only returns zh/en, weather text has zh/en/ja (WMO descriptions and body; others fall back to English), and both confidence and failure notes follow the language | `node tools/assert-output-language.mjs` (10) |
|
|
1054
1066
|
| `assert-uncertainty.mjs` | output contract: 0/1 source is low, two sources or a single site is medium, three distinct domains is high, time filter without dates, failure notes, aggregator caveat | `node tools/assert-uncertainty.mjs` (8) |
|
|
1067
|
+
| `assert-youcom.mjs` | You.com keyless tier (#90): both URLs and headers, no `X-API-Key` without a key, the `YDC_API_KEY` alias, and 429/401/402/5xx classification | `node tools/assert-youcom.mjs` (23) |
|
|
1068
|
+
| `assert-degoog.mjs` | degoog self-hosted instance (#85): `/api/search` URL normalisation, query encoding, `time`/`lang` parameters, registry placement, no credentials needed | `node tools/assert-degoog.mjs` (7) |
|
|
1055
1069
|
| `assert-multikey.mjs` | multi-key fields: a single key is unchanged, comma/semicolon/newline separate keys, blank entries are dropped, empty input yields none | `node tools/assert-multikey.mjs` (3) |
|
|
1056
1070
|
| `assert-firecrawl-keyless.mjs` | Firecrawl keyless egress refusal: only a 403 with the VPN/proxy wording counts, plain 403 and 401/429/500 do not, and the cooldown starts inactive | `node tools/assert-firecrawl-keyless.mjs` (5) |
|
|
1057
1071
|
| `assert-fetch-charset.mjs` | fetch encoding (#88): `charset=gbk` / `gb2312` decoded as declared, `<meta charset>` and the http-equiv form sniffed when the header omits it, UTF-8 by default, and an unknown label falls back to UTF-8 instead of throwing | `node tools/assert-fetch-charset.mjs` (6) |
|
package/lib/client.js
CHANGED
|
@@ -168,7 +168,7 @@ window.__ModuleLoader__.load({
|
|
|
168
168
|
const NS = "web-search-free";
|
|
169
169
|
const I18N = {
|
|
170
170
|
zh: {
|
|
171
|
-
description: "免费搜索 —— 无需 API key(Bing / DuckDuckGo / AnySearch / Exa / Tavily / Keenable / Firecrawl / Parallel
|
|
171
|
+
description: "免费搜索 —— 无需 API key(Bing / DuckDuckGo / AnySearch / Exa / Tavily / Keenable / Firecrawl / Parallel / You.com)",
|
|
172
172
|
unsaved: "未保存",
|
|
173
173
|
searchEngine: "搜索引擎",
|
|
174
174
|
visit: "访问官网 →",
|
|
@@ -177,6 +177,7 @@ window.__ModuleLoader__.load({
|
|
|
177
177
|
apiKeys: "API 密钥",
|
|
178
178
|
anysearchPh: (c) => c ? "AnySearch API 密钥(已配置)" : "AnySearch API 密钥(可选,不填免费匿名,填了提额)",
|
|
179
179
|
exaPh: (c) => c ? "Exa API 密钥(已配置)" : "Exa API 密钥(可选,不填也可免费使用)",
|
|
180
|
+
degoogPh: (c) => c ? "Degoog Bearer 密钥(已配置)" : "Degoog Bearer 密钥(实例开启 API Key 时才需要)",
|
|
180
181
|
tavilyPh: (c) => c ? "Tavily API 密钥(已配置)" : "Tavily API 密钥(可选,不填也可免费使用)",
|
|
181
182
|
keenablePh: (c) => c ? "Keenable API 密钥(已配置)" : "Keenable API 密钥(可选,不填也可免费使用)",
|
|
182
183
|
firecrawlPh: (c) => c ? "Firecrawl API 密钥(已配置)" : "Firecrawl API 密钥(可选,不填也可免费使用)",
|
|
@@ -185,7 +186,7 @@ window.__ModuleLoader__.load({
|
|
|
185
186
|
deepseekPh: (c) => c ? "DeepSeek API 密钥(已配置)" : "DeepSeek API 密钥(sk-...)",
|
|
186
187
|
serpbasePh: (c) => c ? "SerpBase API 密钥(已配置)" : "SerpBase API 密钥(serpbase.dev 获取)",
|
|
187
188
|
serplyPh: (c) => c ? "Serply API 密钥(已配置)" : "Serply API 密钥(serply.io 获取)",
|
|
188
|
-
youcomPh: (c) => c ? "You.com API 密钥(已配置)" : "You.com API
|
|
189
|
+
youcomPh: (c) => c ? "You.com API 密钥(已配置)" : "You.com API 密钥(可选,不填也可免费使用,每天 100 次;YDC_API_KEY)",
|
|
189
190
|
baiduPh: (c) => c ? "Baidu API 密钥(已配置)" : "百度千帆 API 密钥(BAIDU_API_KEY)",
|
|
190
191
|
kimiPh: (c) => c ? "Kimi API 密钥(已配置)" : "Kimi API 密钥(MOONSHOT_API_KEY)",
|
|
191
192
|
aliyunPh: (c) => c ? "Aliyun API 密钥(已配置)" : "阿里云 DashScope 密钥(DASHSCOPE_API_KEY)",
|
|
@@ -296,7 +297,7 @@ window.__ModuleLoader__.load({
|
|
|
296
297
|
starCta: "行,给你一颗 Star",
|
|
297
298
|
},
|
|
298
299
|
en: {
|
|
299
|
-
description: "Free web search — no API key needed (Bing / DuckDuckGo / AnySearch / Exa / Tavily / Keenable / Firecrawl / Parallel
|
|
300
|
+
description: "Free web search — no API key needed (Bing / DuckDuckGo / AnySearch / Exa / Tavily / Keenable / Firecrawl / Parallel / You.com)",
|
|
300
301
|
unsaved: "unsaved",
|
|
301
302
|
searchEngine: "Search engine",
|
|
302
303
|
visit: "Visit website →",
|
|
@@ -305,6 +306,7 @@ window.__ModuleLoader__.load({
|
|
|
305
306
|
apiKeys: "API keys",
|
|
306
307
|
anysearchPh: (c) => c ? "AnySearch API key (configured)" : "AnySearch API key (optional, free anonymous without; key raises quota)",
|
|
307
308
|
exaPh: (c) => c ? "Exa API key (configured)" : "Exa API key (optional, free without)",
|
|
309
|
+
degoogPh: (c) => c ? "Degoog bearer key (configured)" : "Degoog bearer key (only if your instance enables API keys)",
|
|
308
310
|
tavilyPh: (c) => c ? "Tavily API key (configured)" : "Tavily API key (optional, free without)",
|
|
309
311
|
keenablePh: (c) => c ? "Keenable API key (configured)" : "Keenable API key (optional, free without)",
|
|
310
312
|
firecrawlPh: (c) => c ? "Firecrawl API key (configured)" : "Firecrawl API key (optional, free without)",
|
|
@@ -313,7 +315,7 @@ window.__ModuleLoader__.load({
|
|
|
313
315
|
deepseekPh: (c) => c ? "DeepSeek API key (configured)" : "DeepSeek API key (sk-...)",
|
|
314
316
|
serpbasePh: (c) => c ? "SerpBase API key (configured)" : "SerpBase API key (from serpbase.dev)",
|
|
315
317
|
serplyPh: (c) => c ? "Serply API key (configured)" : "Serply API key (from serply.io)",
|
|
316
|
-
youcomPh: (c) => c ? "You.com API key (configured)" : "You.com API key (
|
|
318
|
+
youcomPh: (c) => c ? "You.com API key (configured)" : "You.com API key (optional, free without: 100 searches a day; YDC_API_KEY)",
|
|
317
319
|
baiduPh: (c) => c ? "Baidu API key (configured)" : "Baidu Qianfan API key (BAIDU_API_KEY)",
|
|
318
320
|
kimiPh: (c) => c ? "Kimi API key (configured)" : "Kimi API key (MOONSHOT_API_KEY)",
|
|
319
321
|
aliyunPh: (c) => c ? "Aliyun API key (configured)" : "Aliyun DashScope API key (DASHSCOPE_API_KEY)",
|
|
@@ -426,7 +428,7 @@ window.__ModuleLoader__.load({
|
|
|
426
428
|
};
|
|
427
429
|
const tt = (lang) => I18N[String(lang ?? "").trim().toLowerCase() === "zh" ? "zh" : "en"];
|
|
428
430
|
// 当前插件版本(与 lib/index.js 的 PLUGIN_VERSION 保持一致;跟随上游 v0.7.5)
|
|
429
|
-
const PLUGIN_VERSION = "0.9.
|
|
431
|
+
const PLUGIN_VERSION = "0.9.16";
|
|
430
432
|
const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
|
|
431
433
|
// 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
|
|
432
434
|
const NAV_ITEMS = [
|
|
@@ -455,6 +457,7 @@ window.__ModuleLoader__.load({
|
|
|
455
457
|
{ id: "bing", label: "Bing", badge: "FREE", link: "https://www.bing.com" },
|
|
456
458
|
{ id: "anysearch", label: "AnySearch · AI", badge: "FREE", link: "https://anysearch.com" },
|
|
457
459
|
{ id: "searxng", label: "SearXNG · 元搜索", badge: "FREE", link: "https://github.com/searxng/searxng" },
|
|
460
|
+
{ id: "degoog", label: "Degoog · 自建聚合", badge: "FREE", link: "https://github.com/degoog-org/degoog" },
|
|
458
461
|
{ id: "exa", label: "Exa", badge: "FREE", link: "https://dashboard.exa.ai/api-keys" },
|
|
459
462
|
{ id: "tavily", label: "Tavily", badge: "FREE", link: "https://app.tavily.com/home" },
|
|
460
463
|
{ id: "keenable", label: "Keenable", badge: "FREE", link: "https://keenable.ai/login" },
|
|
@@ -465,7 +468,7 @@ window.__ModuleLoader__.load({
|
|
|
465
468
|
{ id: "serply", label: "Serply · Google", badge: "API KEY", link: "https://serply.io" },
|
|
466
469
|
{ id: "deepseek-official", label: "DeepSeek Official", badge: "API KEY", link: "https://platform.deepseek.com/api_keys" },
|
|
467
470
|
{ id: "deepseek-tools", label: "DeepSeek Tools API", badge: "API KEY", link: "https://api-docs.deepseek.com/zh-cn/guides/search" },
|
|
468
|
-
{ id: "you", label: "You.com", badge: "
|
|
471
|
+
{ id: "you", label: "You.com", badge: "FREE", link: "https://you.com/platform/api-keys" },
|
|
469
472
|
{ id: "baidu", label: "Baidu · 百度千帆", badge: "API KEY", link: "https://console.bce.baidu.com/qianfan" },
|
|
470
473
|
{ id: "kimi", label: "Kimi · Moonshot", badge: "API KEY", link: "https://platform.moonshot.cn" },
|
|
471
474
|
{ id: "aliyun", label: "Aliyun · 百炼", badge: "API KEY", link: "https://bailian.console.aliyun.com" },
|
|
@@ -482,7 +485,7 @@ window.__ModuleLoader__.load({
|
|
|
482
485
|
// 与 lib/index.js 的 EXPLICIT_ONLY_ENGINES 同源:按次计费、只在显式选中时运行,因此不提供入池候选。
|
|
483
486
|
const EXPLICIT_ONLY_ENGINES = ["openai", "gemini", "claude"];
|
|
484
487
|
const MODEL_ENGINES = ENGINES.filter((engine) => EXPLICIT_ONLY_ENGINES.includes(engine.id));
|
|
485
|
-
const DEFAULT_FALLBACK_ORDER = ["exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "deepseek-tools", "deepseek-official", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "bing", "anysearch", "ddg", "ddg-lite", "searxng", "zhihu_global", "zhihu_site"];
|
|
488
|
+
const DEFAULT_FALLBACK_ORDER = ["exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "deepseek-tools", "deepseek-official", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "bing", "anysearch", "ddg", "ddg-lite", "searxng", "degoog", "zhihu_global", "zhihu_site"];
|
|
486
489
|
const normalizeFallbackOrder = (value) => {
|
|
487
490
|
const configured = Array.isArray(value) ? value.filter((id) => ENGINE_IDS.includes(id)) : [];
|
|
488
491
|
return [...new Set([...configured, ...DEFAULT_FALLBACK_ORDER, ...ENGINE_IDS.filter((id) => !EXPLICIT_ONLY_ENGINES.includes(id))])].filter((id) => !EXPLICIT_ONLY_ENGINES.includes(id));
|
|
@@ -680,6 +683,7 @@ window.__ModuleLoader__.load({
|
|
|
680
683
|
const [tinyfishKey, setTinyfishKey] = react.useState("");
|
|
681
684
|
const [jinaKey, setJinaKey] = react.useState("");
|
|
682
685
|
const [searxngToken, setSearxngToken] = react.useState("");
|
|
686
|
+
const [degoogKey, setDegoogKey] = react.useState("");
|
|
683
687
|
const [platforms, setPlatforms] = react.useState(["github", "v2ex", "bilibili", "reddit", "hn", "stackoverflow", "wikipedia", "npm", "youtube", "vimeo", "juejin", "douban", "qiita"]);
|
|
684
688
|
const [cacheTtl, setCacheTtl] = react.useState(5);
|
|
685
689
|
const [multiMaxEngines, setMultiMaxEngines] = react.useState(0);
|
|
@@ -746,6 +750,7 @@ window.__ModuleLoader__.load({
|
|
|
746
750
|
tinyfish: [tinyfishKey, setTinyfishKey],
|
|
747
751
|
jina: [jinaKey, setJinaKey],
|
|
748
752
|
searxng: [searxngToken, setSearxngToken],
|
|
753
|
+
degoog: [degoogKey, setDegoogKey],
|
|
749
754
|
zhihu_global: [zhihuKey, setZhihuKey],
|
|
750
755
|
zhihu_site: [zhihuKey, setZhihuKey],
|
|
751
756
|
openai: [openaiKey, setOpenaiKey],
|
|
@@ -755,7 +760,7 @@ window.__ModuleLoader__.load({
|
|
|
755
760
|
// #68 密钥状态可视化:引擎 id → 配置中心键名(少数引擎不同名),三态:已配置/可选/缺失
|
|
756
761
|
const CONFIGURED_KEY_ID = { "deepseek-official": "deepseek", "deepseek-tools": "deepseek", you: "youcom", zhihu_global: "zhihu", zhihu_site: "zhihu" };
|
|
757
762
|
const NO_KEY_ENGINES = ["ddg", "ddg-lite", "bing"];
|
|
758
|
-
const OPTIONAL_KEY_ENGINES = ["anysearch", "exa", "tavily", "keenable", "firecrawl", "parallel", "searxng"];
|
|
763
|
+
const OPTIONAL_KEY_ENGINES = ["anysearch", "exa", "tavily", "keenable", "firecrawl", "parallel", "searxng", "degoog", "you"];
|
|
759
764
|
const hasConfiguredKey = (id) => {
|
|
760
765
|
const k = CONFIGURED_KEY_ID[id] ?? id;
|
|
761
766
|
return Boolean(keysConfigured[k] || credConfigured[k]);
|
|
@@ -819,6 +824,7 @@ window.__ModuleLoader__.load({
|
|
|
819
824
|
setTinyfishKey(v.tinyfishApiKey ?? "");
|
|
820
825
|
setJinaKey(v.jinaApiKey ?? "");
|
|
821
826
|
setSearxngToken(v.searxngBearerToken ?? "");
|
|
827
|
+
setDegoogKey(v.degoogApiKey ?? "");
|
|
822
828
|
setPlatforms(Array.isArray(v.platforms) && v.platforms.length > 0 ? v.platforms : ["github", "v2ex", "bilibili", "reddit", "hn", "stackoverflow", "wikipedia", "npm", "youtube", "vimeo", "juejin", "douban", "qiita"]);
|
|
823
829
|
setCacheTtl(v.cacheTtl === undefined ? 5 : Math.min(Math.max(Number(v.cacheTtl) ?? 5, 0), 5));
|
|
824
830
|
// #69:multi 上限 0 = 不限制(旧行为);目标成功源数下限 1
|
|
@@ -851,6 +857,7 @@ window.__ModuleLoader__.load({
|
|
|
851
857
|
if (path === "tinyfishApiKey") configured.tinyfish = true;
|
|
852
858
|
if (path === "jinaApiKey") configured.jina = true;
|
|
853
859
|
if (path === "searxngBearerToken") configured.searxng = true;
|
|
860
|
+
if (path === "degoogApiKey") configured.degoog = true;
|
|
854
861
|
}
|
|
855
862
|
}
|
|
856
863
|
setKeysConfigured(configured);
|
|
@@ -862,7 +869,7 @@ window.__ModuleLoader__.load({
|
|
|
862
869
|
const cred = await bridgeCredentialsStatus();
|
|
863
870
|
if (cred.ok) {
|
|
864
871
|
const cc = {};
|
|
865
|
-
const map = { anysearchApiKey: "anysearch", exaApiKey: "exa", tavilyApiKey: "tavily", keenableApiKey: "keenable", firecrawlApiKey: "firecrawl", parallelApiKey: "parallel", perplexityApiKey: "perplexity", deepseekApiKey: "deepseek", serpbaseApiKey: "serpbase", serplyApiKey: "serply", youcomApiKey: "youcom", baiduApiKey: "baidu", kimiApiKey: "kimi", aliyunApiKey: "aliyun", doubaoApiKey: "doubao", openaiApiKey: "openai", geminiApiKey: "gemini", claudeApiKey: "claude", zhihuApiKey: "zhihu", tinyfishApiKey: "tinyfish", jinaApiKey: "jina", searxngBearerToken: "searxng" };
|
|
872
|
+
const map = { anysearchApiKey: "anysearch", exaApiKey: "exa", tavilyApiKey: "tavily", keenableApiKey: "keenable", firecrawlApiKey: "firecrawl", parallelApiKey: "parallel", perplexityApiKey: "perplexity", deepseekApiKey: "deepseek", serpbaseApiKey: "serpbase", serplyApiKey: "serply", 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" };
|
|
866
873
|
for (const [k, v] of Object.entries(cred.value.configured ?? {})) {
|
|
867
874
|
if (map[k]) cc[map[k]] = v;
|
|
868
875
|
}
|
|
@@ -921,6 +928,7 @@ window.__ModuleLoader__.load({
|
|
|
921
928
|
["tinyfishApiKey", tinyfishKey],
|
|
922
929
|
["jinaApiKey", jinaKey],
|
|
923
930
|
["searxngBearerToken", searxngToken],
|
|
931
|
+
["degoogApiKey", degoogKey],
|
|
924
932
|
];
|
|
925
933
|
if (keyStorage === "credentials") {
|
|
926
934
|
for (const [field, value] of keyFields) {
|
package/lib/fetch_provider.js
CHANGED
|
@@ -122,33 +122,33 @@ function browserDumpDom(browserPath, url, { timeoutMs = 25000, signal } = {}) {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
// #88:按声明的 charset 解码。GBK/GB2312/Big5/Shift_JIS 老站很常见,
|
|
126
|
-
// 一律当 UTF-8 会得到整页 \uFFFD,而且不会报错、不会降级,模型直接吃一页乱码。
|
|
127
|
-
function parseCharset(contentType) {
|
|
128
|
-
const match = /charset\s*=\s*"?([^";\s]+)"?/i.exec(String(contentType || ""));
|
|
129
|
-
return match ? match[1].trim().toLowerCase() : "";
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function sniffHtmlCharset(buffer) {
|
|
133
|
-
const head = buffer.subarray(0, 2048).toString("latin1");
|
|
134
|
-
let match = /<meta[^>]+charset\s*=\s*["']?\s*([\w.:-]+)/i.exec(head);
|
|
135
|
-
if (match) return match[1].toLowerCase();
|
|
136
|
-
match = /<meta[^>]+content\s*=\s*["'][^"']*charset\s*=\s*([\w.:-]+)/i.exec(head);
|
|
137
|
-
return match ? match[1].toLowerCase() : "";
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function decodeBody(buffer, contentType) {
|
|
141
|
-
let label = parseCharset(contentType);
|
|
142
|
-
if (!label && /html|xml/i.test(String(contentType || ""))) label = sniffHtmlCharset(buffer);
|
|
143
|
-
if (!label) label = "utf-8";
|
|
144
|
-
try {
|
|
145
|
-
return new TextDecoder(label, { fatal: false }).decode(buffer);
|
|
146
|
-
} catch {
|
|
147
|
-
// 无法识别的 label(或该 Node 没编进对应编码表):退回 UTF-8,不抛错。
|
|
148
|
-
return buffer.toString("utf8");
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
125
|
+
// #88:按声明的 charset 解码。GBK/GB2312/Big5/Shift_JIS 老站很常见,
|
|
126
|
+
// 一律当 UTF-8 会得到整页 \uFFFD,而且不会报错、不会降级,模型直接吃一页乱码。
|
|
127
|
+
function parseCharset(contentType) {
|
|
128
|
+
const match = /charset\s*=\s*"?([^";\s]+)"?/i.exec(String(contentType || ""));
|
|
129
|
+
return match ? match[1].trim().toLowerCase() : "";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function sniffHtmlCharset(buffer) {
|
|
133
|
+
const head = buffer.subarray(0, 2048).toString("latin1");
|
|
134
|
+
let match = /<meta[^>]+charset\s*=\s*["']?\s*([\w.:-]+)/i.exec(head);
|
|
135
|
+
if (match) return match[1].toLowerCase();
|
|
136
|
+
match = /<meta[^>]+content\s*=\s*["'][^"']*charset\s*=\s*([\w.:-]+)/i.exec(head);
|
|
137
|
+
return match ? match[1].toLowerCase() : "";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function decodeBody(buffer, contentType) {
|
|
141
|
+
let label = parseCharset(contentType);
|
|
142
|
+
if (!label && /html|xml/i.test(String(contentType || ""))) label = sniffHtmlCharset(buffer);
|
|
143
|
+
if (!label) label = "utf-8";
|
|
144
|
+
try {
|
|
145
|
+
return new TextDecoder(label, { fatal: false }).decode(buffer);
|
|
146
|
+
} catch {
|
|
147
|
+
// 无法识别的 label(或该 Node 没编进对应编码表):退回 UTF-8,不抛错。
|
|
148
|
+
return buffer.toString("utf8");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
152
|
/** GET 跟随重定向(≤5 跳),返回最终 URL / 状态 / 正文 / 内容类型;支持 gzip/br/deflate 解压。 */
|
|
153
153
|
export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal } = {}, transport = https) {
|
|
154
154
|
return new Promise((resolve, reject) => {
|
package/lib/index.js
CHANGED
|
@@ -155,6 +155,9 @@ const KEENABLE_MCP_URL = "https://api.keenable.ai/mcp";
|
|
|
155
155
|
const SERPBASE_URL = "https://api.serpbase.dev/google/search";
|
|
156
156
|
const SERPLY_URL = "https://api.serply.io/v1/search";
|
|
157
157
|
const YOUCOM_URL = "https://ydc-index.io/v1/search";
|
|
158
|
+
// You.com 免 key 档:同样的 query / count 参数与 results.web[] 响应,每天 100 次免费搜索
|
|
159
|
+
const YOUCOM_FREE_URL = "https://api.you.com/v1/agents/search";
|
|
160
|
+
const YOUCOM_KEYS_LINK = "https://you.com/platform/api-keys";
|
|
158
161
|
const TINYFISH_URL = "https://api.search.tinyfish.ai";
|
|
159
162
|
const JINA_URL = "https://s.jina.ai/";
|
|
160
163
|
const DOUBAO_SEARCH_URL = "https://open.feedcoopapi.com/search_api/web_search";
|
|
@@ -243,8 +246,8 @@ const logOnce = (log, level, message) => {
|
|
|
243
246
|
if (typeof sink === "function") sink.call(log, message);
|
|
244
247
|
};
|
|
245
248
|
// 意见 A:zhihu_global / zhihu_site 需要 ZHIHU_API_KEY,不属于免 key 引擎(不得进入 FREE_ENGINES)
|
|
246
|
-
const FREE_ENGINES = ["ddg", "ddg-lite", "bing", "searxng", "anysearch"];
|
|
247
|
-
const ALL_ENGINES = ["ddg", "ddg-lite", "bing", "searxng", "anysearch", "exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "deepseek-official", "deepseek-tools", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "zhihu_global", "zhihu_site", "openai", "gemini", "claude"];
|
|
249
|
+
const FREE_ENGINES = ["ddg", "ddg-lite", "bing", "searxng", "degoog", "anysearch"];
|
|
250
|
+
const ALL_ENGINES = ["ddg", "ddg-lite", "bing", "searxng", "degoog", "anysearch", "exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "deepseek-official", "deepseek-tools", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "zhihu_global", "zhihu_site", "openai", "gemini", "claude"];
|
|
248
251
|
|
|
249
252
|
// 模型内置搜索(按次计费):只在你显式选中该引擎时使用;自动回退链与 auto 路由都不会兜底到它们。
|
|
250
253
|
const EXPLICIT_ONLY_ENGINES = ["openai", "gemini", "claude"];
|
|
@@ -321,12 +324,12 @@ const FAILURE_CLASS_LABELS = {
|
|
|
321
324
|
|
|
322
325
|
// 支持 time_range 过滤的引擎(zhihu_global:global_search 的 filter 支持 publish_time>=unix秒,已实测;zhihu_site 未验证,不加)
|
|
323
326
|
// deepseek-tools:原生搜索端点没有独立时间字段,但 query 语法支持 after:/before:,由 deepseekToolsQuery 注入。
|
|
324
|
-
const TIME_ENGINES = ["tavily", "exa", "keenable", "firecrawl", "parallel", "searxng", "ddg", "ddg-lite", "baidu", "doubao", "tinyfish", "deepseek-tools", "zhihu_global"];
|
|
327
|
+
const TIME_ENGINES = ["tavily", "exa", "keenable", "firecrawl", "parallel", "searxng", "degoog", "ddg", "ddg-lite", "baidu", "doubao", "tinyfish", "deepseek-tools", "zhihu_global"];
|
|
325
328
|
|
|
326
329
|
// 虚拟搜索模式:不是单个引擎,而是 provider.search 内部的路由/并发策略
|
|
327
330
|
const SEARCH_MODES = ["auto", "multi"];
|
|
328
331
|
|
|
329
|
-
const DEFAULT_FALLBACK_ORDER = ["exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "deepseek-tools", "deepseek-official", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "bing", "anysearch", "ddg", "ddg-lite", "searxng", "zhihu_global", "zhihu_site"];
|
|
332
|
+
const DEFAULT_FALLBACK_ORDER = ["exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "deepseek-tools", "deepseek-official", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "bing", "anysearch", "ddg", "ddg-lite", "searxng", "degoog", "zhihu_global", "zhihu_site"];
|
|
330
333
|
|
|
331
334
|
function normalizeDisabledEngines(value) {
|
|
332
335
|
if (!Array.isArray(value)) return [];
|
|
@@ -399,7 +402,7 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
|
|
|
399
402
|
}
|
|
400
403
|
|
|
401
404
|
// 当前插件版本(发布时与 package.json 同步;跟随上游 v0.7.5,不在 PR 里 bump)
|
|
402
|
-
const PLUGIN_VERSION = "0.9.
|
|
405
|
+
const PLUGIN_VERSION = "0.9.16";
|
|
403
406
|
// 检查更新的 npm registry 元数据地址(dsh-free-search 是 npmjs 上的公开包)
|
|
404
407
|
const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-free-search/latest";
|
|
405
408
|
const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-free-search";
|
|
@@ -867,6 +870,74 @@ async function searchSearxng(query, maxResults, options, signal) {
|
|
|
867
870
|
}
|
|
868
871
|
//#endregion
|
|
869
872
|
|
|
873
|
+
//#region degoog (self-hosted search aggregator, opt-in)
|
|
874
|
+
// degoog 的 JSON API:GET /api/search?q=…&type=web(可选 time / lang),结果在 results[] 里
|
|
875
|
+
// (url / title / snippet)。实例若开了 apiKeySearchEnabled,需要 Authorization: Bearer <serverKey>。
|
|
876
|
+
const DEGOOG_TIME = { day: "day", week: "week", month: "month", year: "year" };
|
|
877
|
+
|
|
878
|
+
/** 把实例地址规范化成 /api/search URL;允许用户写 `https://host` 或 `https://host/api`。 */
|
|
879
|
+
export function degoogSearchUrl(base, query, { timeRange, lang } = {}) {
|
|
880
|
+
const root = String(base ?? "").trim().replace(/\/+$/, "");
|
|
881
|
+
const endpoint = /\/api$/i.test(root) ? `${root}/search` : `${root}/api/search`;
|
|
882
|
+
const params = new URLSearchParams({ q: String(query ?? ""), type: "web" });
|
|
883
|
+
if (timeRange) {
|
|
884
|
+
const tr = DEGOOG_TIME[approximateTimeRange(timeRange.days ?? 7)];
|
|
885
|
+
if (tr) params.set("time", tr);
|
|
886
|
+
}
|
|
887
|
+
if (lang) params.set("lang", String(lang));
|
|
888
|
+
return `${endpoint}?${params}`;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
async function searchDegoog(query, maxResults, options, signal) {
|
|
892
|
+
const instances = (Array.isArray(options?.degoogInstances) ? options.degoogInstances : [])
|
|
893
|
+
.map((entry) => String(entry ?? "").trim())
|
|
894
|
+
.filter(Boolean);
|
|
895
|
+
const errors = [];
|
|
896
|
+
for (const base of instances) {
|
|
897
|
+
try {
|
|
898
|
+
const ctrl = new AbortController();
|
|
899
|
+
const timer = setTimeout(() => ctrl.abort(), 10000);
|
|
900
|
+
const onAbort = () => ctrl.abort();
|
|
901
|
+
signal?.addEventListener("abort", onAbort);
|
|
902
|
+
const response = await fetch(degoogSearchUrl(base, query, { timeRange: options?.timeRange, lang: options?.lang }), {
|
|
903
|
+
headers: {
|
|
904
|
+
"user-agent": USER_AGENT,
|
|
905
|
+
accept: "application/json",
|
|
906
|
+
...(options?.degoogApiKey ? { authorization: `Bearer ${options.degoogApiKey}` } : {}),
|
|
907
|
+
},
|
|
908
|
+
redirect: "error",
|
|
909
|
+
signal: ctrl.signal,
|
|
910
|
+
});
|
|
911
|
+
clearTimeout(timer);
|
|
912
|
+
signal?.removeEventListener("abort", onAbort);
|
|
913
|
+
if (response.status === 401 || response.status === 403) {
|
|
914
|
+
errors.push(`${base}: HTTP ${response.status} (check degoogApiKey)`);
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
if (!response.ok) {
|
|
918
|
+
errors.push(`${base}: HTTP ${response.status}`);
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
const data = await response.json().catch(() => null);
|
|
922
|
+
const rows = Array.isArray(data?.results) ? data.results : [];
|
|
923
|
+
const sources = rows
|
|
924
|
+
.filter((row) => row && row.url)
|
|
925
|
+
.map((row) => ({
|
|
926
|
+
url: String(row.url),
|
|
927
|
+
...(row.title ? { title: String(row.title) } : {}),
|
|
928
|
+
...(row.snippet ?? row.content ? { snippet: String(row.snippet ?? row.content) } : {}),
|
|
929
|
+
}));
|
|
930
|
+
if (sources.length > 0) return { sources: uniqueSources(sources, maxResults ?? 10), truncated: false };
|
|
931
|
+
errors.push(`${base}: 0 results`);
|
|
932
|
+
} catch (error) {
|
|
933
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
934
|
+
errors.push(`${base}: ${message}`);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
const detail = errors.length > 0 ? errors.join(", ") : "no instances configured (set degoogInstances in the plugin config)";
|
|
938
|
+
throw new Error(`all degoog instances failed: ${detail.slice(0, 300)}`);
|
|
939
|
+
}
|
|
940
|
+
//#endregion
|
|
870
941
|
//#region keyless engines (AnySearch / Exa MCP - free, no API key)
|
|
871
942
|
const ANYSEARCH_URL = "https://api.anysearch.com/v1/search";
|
|
872
943
|
const EXA_MCP_URL = "https://mcp.exa.ai/mcp";
|
|
@@ -2255,16 +2326,17 @@ async function searchSerply(query, maxResults, apiKey, options, signal) {
|
|
|
2255
2326
|
return { sources: uniqueSources(sources, maxResults ?? 10), truncated: false };
|
|
2256
2327
|
}
|
|
2257
2328
|
|
|
2258
|
-
// You.com
|
|
2329
|
+
// You.com:无 key 走免 key 档(api.you.com/v1/agents/search,每天 100 次),有 key 走官方 Search API(X-API-Key)。
|
|
2330
|
+
// key 读取 YDC_API_KEY(标准名),旧名 YOUCOM_API_KEY 继续兼容,见 resolveYoucomApiKey。
|
|
2259
2331
|
async function searchYoucom(query, maxResults, apiKey, signal) {
|
|
2260
|
-
|
|
2261
|
-
// 官方 Search API(keyed tier):GET + query 参数,X-API-Key 认证;count 为每段条数上限
|
|
2332
|
+
// 两档参数相同:GET + query 参数;count 为每段条数上限
|
|
2262
2333
|
const params = new URLSearchParams({ query, count: String(Math.min(maxResults ?? 10, 20)) });
|
|
2263
|
-
const
|
|
2334
|
+
const keyed = Boolean(apiKey);
|
|
2335
|
+
const response = await fetch(`${keyed ? YOUCOM_URL : YOUCOM_FREE_URL}?${params}`, {
|
|
2264
2336
|
method: "GET",
|
|
2265
2337
|
redirect: "error",
|
|
2266
2338
|
headers: {
|
|
2267
|
-
"X-API-Key": apiKey,
|
|
2339
|
+
...(keyed ? { "X-API-Key": apiKey } : {}),
|
|
2268
2340
|
accept: "application/json",
|
|
2269
2341
|
"user-agent": "deepseek-harness/free-search",
|
|
2270
2342
|
},
|
|
@@ -2272,13 +2344,16 @@ async function searchYoucom(query, maxResults, apiKey, signal) {
|
|
|
2272
2344
|
});
|
|
2273
2345
|
if (!response.ok) {
|
|
2274
2346
|
const detail = await response.text().catch(() => "");
|
|
2275
|
-
if (response.status === 401 || response.status === 403) {
|
|
2347
|
+
if (keyed && (response.status === 401 || response.status === 403)) {
|
|
2276
2348
|
throw new Error(`You.com API key is invalid (HTTP ${response.status}) - update it in Settings > Plugins > Free Search`);
|
|
2277
2349
|
}
|
|
2278
2350
|
if (response.status === 402) {
|
|
2279
2351
|
throw new Error(`You.com quota/billing error (HTTP 402) - check usage at you.com/platform/api-keys. ${detail.slice(0, 200)}`);
|
|
2280
2352
|
}
|
|
2281
2353
|
if (response.status === 429) {
|
|
2354
|
+
if (!keyed) {
|
|
2355
|
+
throw new Error(`You.com free tier rate limit exceeded (HTTP 429) - set YDC_API_KEY for higher limits: ${YOUCOM_KEYS_LINK}`);
|
|
2356
|
+
}
|
|
2282
2357
|
throw new Error("You.com rate limit exceeded (HTTP 429) - check your plan at you.com/platform/api-keys");
|
|
2283
2358
|
}
|
|
2284
2359
|
throw new Error(`You.com API error (HTTP ${response.status}): ${detail.slice(0, 200)}`);
|
|
@@ -2301,6 +2376,23 @@ async function searchYoucom(query, maxResults, apiKey, signal) {
|
|
|
2301
2376
|
return { sources: uniqueSources(sources, maxResults ?? 10), truncated: false };
|
|
2302
2377
|
}
|
|
2303
2378
|
|
|
2379
|
+
// You.com key 解析(纯函数,便于断言):凭据中心 YDC_API_KEY → 凭据中心 YOUCOM_API_KEY → 设置页 youcomApiKey
|
|
2380
|
+
// → 环境变量 YDC_API_KEY → 环境变量 YOUCOM_API_KEY。与其它引擎一样凭据中心优先;旧名只是别名,已有配置不受影响。
|
|
2381
|
+
const YOUCOM_KEY_REFS = ["YDC_API_KEY", "YOUCOM_API_KEY"];
|
|
2382
|
+
async function resolveYoucomApiKey({ resolveCredential, settingsValue, env } = {}) {
|
|
2383
|
+
if (resolveCredential) {
|
|
2384
|
+
for (const ref of YOUCOM_KEY_REFS) {
|
|
2385
|
+
const value = await resolveCredential(ref);
|
|
2386
|
+
if (value) return value;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
if (settingsValue) return settingsValue;
|
|
2390
|
+
for (const ref of YOUCOM_KEY_REFS) {
|
|
2391
|
+
if (env?.[ref]) return env[ref];
|
|
2392
|
+
}
|
|
2393
|
+
return "";
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2304
2396
|
// TinyFish Search(api.search.tinyfish.ai):GET + X-API-Key;免费 12000 请求/天。
|
|
2305
2397
|
// 支持 after_date / before_date(YYYY-MM-DD)时间过滤。
|
|
2306
2398
|
async function searchTinyfish(query, maxResults, apiKey, timeRange, signal) {
|
|
@@ -3430,6 +3522,7 @@ const KEY_REF_MAP = {
|
|
|
3430
3522
|
serpbaseApiKey: "SERPBASE_API_KEY",
|
|
3431
3523
|
serplyApiKey: "SERPLY_API_KEY",
|
|
3432
3524
|
deepseekApiKey: "DEEPSEEK_API_KEY",
|
|
3525
|
+
// 设置页写入的凭据槽位保持旧名,已保存的 key 不受影响;读取时 YDC_API_KEY 优先(见 resolveYoucomApiKey)
|
|
3433
3526
|
youcomApiKey: "YOUCOM_API_KEY",
|
|
3434
3527
|
baiduApiKey: "BAIDU_API_KEY",
|
|
3435
3528
|
kimiApiKey: "MOONSHOT_API_KEY",
|
|
@@ -3472,7 +3565,10 @@ const Config = z.object({
|
|
|
3472
3565
|
fetchProviderTakeover: z.boolean().default(true).volatile(),
|
|
3473
3566
|
safeSearch: z.string().default("off").volatile(),
|
|
3474
3567
|
searxngInstances: z.array(z.string()).volatile(),
|
|
3568
|
+
// degoog(自建搜索聚合器,见 https://github.com/degoog-org/degoog):需要自己的实例,默认不启用。
|
|
3569
|
+
degoogInstances: z.array(z.string()).volatile(),
|
|
3475
3570
|
searxngBearerToken: z.string().role("secret").volatile(),
|
|
3571
|
+
degoogApiKey: z.string().role("secret").volatile(),
|
|
3476
3572
|
platforms: z.array(z.string()).default(["github", "v2ex", "bilibili", "reddit", "hn", "stackoverflow", "wikipedia", "npm", "youtube", "vimeo", "juejin", "douban", "qiita"]).volatile(),
|
|
3477
3573
|
anysearchApiKey: z.string().role("secret").volatile(),
|
|
3478
3574
|
exaApiKey: z.string().role("secret").volatile(),
|
|
@@ -3530,6 +3626,7 @@ const LEGACY_MIGRATABLE_KEYS = [
|
|
|
3530
3626
|
"safeSearch",
|
|
3531
3627
|
"searxngInstances",
|
|
3532
3628
|
"searxngBearerToken",
|
|
3629
|
+
"degoogApiKey",
|
|
3533
3630
|
"platforms",
|
|
3534
3631
|
"anysearchApiKey",
|
|
3535
3632
|
"exaApiKey",
|
|
@@ -3808,6 +3905,21 @@ function apply(ctx, config) {
|
|
|
3808
3905
|
return resolveApiKey("GOOGLE_API_KEY", undefined);
|
|
3809
3906
|
};
|
|
3810
3907
|
const resolveClaudeKey = () => resolveApiKey("ANTHROPIC_API_KEY", "claudeApiKey");
|
|
3908
|
+
// You.com:标准名 YDC_API_KEY,旧名 YOUCOM_API_KEY 作为别名继续生效(不配 key 走免 key 档)
|
|
3909
|
+
const resolveYoucomKey = () =>
|
|
3910
|
+
resolveYoucomApiKey({
|
|
3911
|
+
resolveCredential: async (ref) => {
|
|
3912
|
+
const credentials = getCredentials();
|
|
3913
|
+
if (!credentials) return "";
|
|
3914
|
+
try {
|
|
3915
|
+
return (await credentials.resolve(ref))?.value ?? "";
|
|
3916
|
+
} catch {
|
|
3917
|
+
return "";
|
|
3918
|
+
}
|
|
3919
|
+
},
|
|
3920
|
+
settingsValue: current().youcomApiKey,
|
|
3921
|
+
env: process.env,
|
|
3922
|
+
});
|
|
3811
3923
|
|
|
3812
3924
|
// 总控 provider:按 settings 的 provider 字段路由到任意引擎。
|
|
3813
3925
|
// 任何引擎失败(缺 key / 401 / 限流 / 网络)都会自动轮流尝试下一个引擎,
|
|
@@ -3926,7 +4038,9 @@ function apply(ctx, config) {
|
|
|
3926
4038
|
chain = [...preferredFirst, ...others];
|
|
3927
4039
|
}
|
|
3928
4040
|
}
|
|
3929
|
-
|
|
4041
|
+
const degoogReady = Array.isArray(cfg.degoogInstances) && cfg.degoogInstances.some((entry) => String(entry ?? "").trim() !== "");
|
|
4042
|
+
// degoog 是自建实例:没配实例时不进自动链(显式选择仍会给出明确报错)
|
|
4043
|
+
chain = [...new Set(chain)].filter((engine) => !disabledSet.has(engine) && (engine !== "degoog" || degoogReady || engine === preferred));
|
|
3930
4044
|
if (chain.length === 0) throw new Error("all search engines are disabled");
|
|
3931
4045
|
|
|
3932
4046
|
let lastError = null;
|
|
@@ -3971,6 +4085,13 @@ function apply(ctx, config) {
|
|
|
3971
4085
|
result = await searchBing(request.query, request.maxResults, cfg, effSignal);
|
|
3972
4086
|
} else if (engine === "searxng") {
|
|
3973
4087
|
result = await searchSearxng(request.query, request.maxResults, { ...cfg, timeRange, searxngBearerToken: await resolveApiKey("SEARXNG_BEARER_TOKEN", "searxngBearerToken") }, effSignal);
|
|
4088
|
+
} else if (engine === "degoog") {
|
|
4089
|
+
result = await searchDegoog(request.query, request.maxResults, {
|
|
4090
|
+
...cfg,
|
|
4091
|
+
timeRange,
|
|
4092
|
+
lang: searchLanguage(configLanguage(cfg)),
|
|
4093
|
+
degoogApiKey: await resolveApiKey("DEGOOG_API_KEY", "degoogApiKey"),
|
|
4094
|
+
}, effSignal);
|
|
3974
4095
|
} else if (engine === "anysearch") {
|
|
3975
4096
|
const key = await resolveApiKey("ANYSEARCH_API_KEY", "anysearchApiKey");
|
|
3976
4097
|
result = await searchAnysearch(request.query, request.maxResults, effSignal, key);
|
|
@@ -4055,14 +4176,8 @@ function apply(ctx, config) {
|
|
|
4055
4176
|
}
|
|
4056
4177
|
result = await searchSerply(request.query, request.maxResults, key, cfg, effSignal);
|
|
4057
4178
|
} else if (engine === "you") {
|
|
4058
|
-
// you.com
|
|
4059
|
-
const key = await
|
|
4060
|
-
if (!key) {
|
|
4061
|
-
lastError = new Error("You.com requires YOUCOM_API_KEY (get one at you.com/platform/api-keys)");
|
|
4062
|
-
if (engine === preferred) preferredFailure = "YOUCOM_API_KEY is not configured";
|
|
4063
|
-
logger.warn(`free-search: engine "${engine}" skipped (no key), trying next engine`);
|
|
4064
|
-
continue; // 无 key 跳过
|
|
4065
|
-
}
|
|
4179
|
+
// you.com:有 key(YDC_API_KEY / 旧名 YOUCOM_API_KEY)走官方 Search API,无 key 走免 key 档(每天 100 次)
|
|
4180
|
+
const key = await resolveYoucomKey();
|
|
4066
4181
|
result = await searchYoucom(request.query, request.maxResults, key, effSignal);
|
|
4067
4182
|
} else if (engine === "tinyfish") {
|
|
4068
4183
|
// tinyfish:必须配置 TINYFISH_API_KEY(无 key 跳过);免费 12000 请求/天
|
|
@@ -4489,6 +4604,13 @@ function apply(ctx, config) {
|
|
|
4489
4604
|
return await searchBing(q, n, cfg);
|
|
4490
4605
|
case "searxng":
|
|
4491
4606
|
return await searchSearxng(q, n, { ...cfg, timeRange: tr, searxngBearerToken: await resolveApiKey("SEARXNG_BEARER_TOKEN", "searxngBearerToken") });
|
|
4607
|
+
case "degoog":
|
|
4608
|
+
return await searchDegoog(q, n, {
|
|
4609
|
+
...cfg,
|
|
4610
|
+
timeRange: tr,
|
|
4611
|
+
lang: searchLanguage(configLanguage(cfg)),
|
|
4612
|
+
degoogApiKey: await resolveApiKey("DEGOOG_API_KEY", "degoogApiKey"),
|
|
4613
|
+
});
|
|
4492
4614
|
case "anysearch": {
|
|
4493
4615
|
const key = await resolveApiKey("ANYSEARCH_API_KEY", "anysearchApiKey");
|
|
4494
4616
|
return await searchAnysearch(q, n, undefined, key);
|
|
@@ -4599,8 +4721,7 @@ function apply(ctx, config) {
|
|
|
4599
4721
|
return await searchClaude(q, n, key, current());
|
|
4600
4722
|
}
|
|
4601
4723
|
case "you": {
|
|
4602
|
-
const key = await
|
|
4603
|
-
if (!key) return { ok: false, error: "YOUCOM_API_KEY not configured" };
|
|
4724
|
+
const key = await resolveYoucomKey();
|
|
4604
4725
|
return await searchYoucom(q, n, key);
|
|
4605
4726
|
}
|
|
4606
4727
|
default:
|
|
@@ -5526,7 +5647,7 @@ export {
|
|
|
5526
5647
|
KEENABLE_URL,
|
|
5527
5648
|
PARALLEL_URL,
|
|
5528
5649
|
PLATFORMS,
|
|
5529
|
-
SEARXNG_INSTANCES,
|
|
5650
|
+
SEARXNG_INSTANCES,
|
|
5530
5651
|
TAVILY_URL,
|
|
5531
5652
|
TIME_ENGINES,
|
|
5532
5653
|
TIME_RANGES,
|
|
@@ -5570,6 +5691,9 @@ export {
|
|
|
5570
5691
|
searchTinyfish,
|
|
5571
5692
|
searchJina,
|
|
5572
5693
|
searchYoucom,
|
|
5694
|
+
resolveYoucomApiKey,
|
|
5695
|
+
YOUCOM_FREE_URL,
|
|
5696
|
+
YOUCOM_URL,
|
|
5573
5697
|
searchZhihuGlobal,
|
|
5574
5698
|
searchZhihuSite,
|
|
5575
5699
|
ZHIHU_MCP_URL,
|
package/lib/multi_policy.js
CHANGED
|
@@ -208,7 +208,7 @@ export function rankMergedResults(items, { appliesFreshness = false } = {}) {
|
|
|
208
208
|
* `if (!key) return { error: "<ENV> not configured" }` 的引擎**,与代码自身对
|
|
209
209
|
* 「缺 key」的声明严格一致。
|
|
210
210
|
* - 免 key 引擎 ddg/ddg-lite/bing/searxng 不收;
|
|
211
|
-
* - 有免 key 兜底的 anysearch(key 可空)/ exa、parallel(回落 MCP
|
|
211
|
+
* - 有免 key 兜底的 anysearch(key 可空)/ exa、parallel(回落 MCP)/ you(无 key 走免 key 档)不收;
|
|
212
212
|
* - tavily/keenable/firecrawl 分支没有 not configured 检查(缺 key 时会带着空串去请求,
|
|
213
213
|
* 以鉴权失败收场),暂不收——那属于另一个行为变更,需单独决定。
|
|
214
214
|
* settings 字段必须带上:只在环境变量里找 key 会漏掉「仅填在设置页」的用户。
|
|
@@ -236,7 +236,6 @@ export const REQUIRED_CREDENTIALS = {
|
|
|
236
236
|
{ env: "GOOGLE_API_KEY", settings: null },
|
|
237
237
|
],
|
|
238
238
|
claude: [{ env: "ANTHROPIC_API_KEY", settings: "claudeApiKey" }],
|
|
239
|
-
you: [{ env: "YOUCOM_API_KEY", settings: "youcomApiKey" }],
|
|
240
239
|
};
|
|
241
240
|
|
|
242
241
|
/** 该引擎需要哪些凭据描述符;不需要凭据(免 key / 有兜底)时返回 null。 */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-free-search",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "Free web search for DeepSeek Harness: 27 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/
|
|
3
|
+
"version": "0.9.16",
|
|
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.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|