dsh-free-search 0.9.42 → 0.9.43
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 +20 -10
- package/lib/client.js +129 -4
- package/lib/engine_meta.js +1 -0
- package/lib/engines/yandex.js +170 -0
- package/lib/index.js +57 -2
- package/lib/multi_policy.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
#### 引擎与切换
|
|
35
35
|
|
|
36
36
|
- **零成本** —— 多个免费引擎,无需 key、无需注册
|
|
37
|
-
- **
|
|
37
|
+
- **38 个引擎可选**:DuckDuckGo(html/lite)、Bing、SearXNG(元搜索,支持自定义实例)、AnySearch、Exa、Tavily、Keenable、Firecrawl、Parallel、Perplexity、SerpBase、Serply、Outcrawl、Google 自定义搜索(`google`,需 API key + CSE ID)、秘塔搜索(`metaso`,官方 API,按点数计费)、Yandex 搜索(`yandex`,官方 API,按请求计费,需 folder 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 三个模型引擎、Metaso 和 Yandex 都只在显式点名时运行。
|
|
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` / 引擎测试都不再用它),并可用 ↑↓ 调整全局回退顺序(一键恢复默认)。
|
|
@@ -150,6 +150,7 @@
|
|
|
150
150
|
| `outcrawl` | Outcrawl | 付费 | 需 `OUTCRAWL_API_KEY`(outcrawl.ai,每月 1,000 credits 免费额度);网页搜索结果(标题/链接/摘要),单次最多 20 条 |
|
|
151
151
|
| `google` | Google 自定义搜索 | 免费额度 | 需 `GOOGLE_CSE_API_KEY` 和 Programmable Search Engine ID(`googleCseId` / cx);Google 官方 Custom Search JSON API,每天 100 次免费,按次计费超额;支持 `hl`、安全搜索和 `dateRestrict` 时间过滤 |
|
|
152
152
|
| `metaso` | 秘塔搜索 | 付费(点数) | 需 `METASO_API_KEY`(metaso.cn/api);官方 AI 搜索 API,按点数计费(约 0.03 元/次,新用户有体验额度);支持网页 / 文库 / 学术三种 `scope`,返回摘要和来源;不在默认回退顺序里,配 key 后显式选用 |
|
|
153
|
+
| `yandex` | Yandex 搜索 | 付费 | 需 `YANDEX_API_KEY` 和 `yandexFolderId`(AI Studio,按请求计费,需 billing account);官方 Search API,`searchType` 支持 RU/TR/COM/KK/BE/UZ,响应为 Base64 XML;支持 day / 2 weeks / month 时间过滤;显式专用 |
|
|
153
154
|
| `deepseek-official` | DeepSeek 官方 | 付费 | 需 `DEEPSEEK_API_KEY`;走 Anthropic 兼容的 `web_search` 服务端工具,每次搜索是一整个模型轮次(慢、耗 token) |
|
|
154
155
|
| `deepseek-tools` | DeepSeek 原生搜索 API | 付费 | 需 `DEEPSEEK_API_KEY`(与上一档共用);直接 `POST /v1/tools/search`,无模型参与,返回结构化 `results[]`(`title`/`url`/`summary`/`date`),同 query 实测 ~0.3s vs 上一档 ~5-6s |
|
|
155
156
|
| `baidu` | 百度千帆 AI 搜索 | 额度 | 需 `BAIDU_API_KEY`(千帆 AI 搜索,每日赠 50 次,超额按量后付费);中文全网,支持时间过滤 |
|
|
@@ -280,7 +281,7 @@ DSH 0.2.1 设置 → 网页搜索 → **DeepSeek 搜索 API** 开关会和本插
|
|
|
280
281
|
配置页提供:
|
|
281
282
|
|
|
282
283
|
- **Search engine**:下拉框切换引擎,保存即生效
|
|
283
|
-
- **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / Outcrawl / Google CSE / Metaso / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel / You.com 不填也可免 key 使用)
|
|
284
|
+
- **API keys**:为 Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / SerpBase / Serply / Outcrawl / Google CSE / Metaso / Yandex / You.com 填写 key(密码框,保存后只显示"已配置";Exa / Tavily / Keenable / Firecrawl / Parallel / You.com 不填也可免 key 使用)
|
|
284
285
|
- **推荐**:付费引擎 key 建议写入 harness 凭据中心 `~/.dsh/.credentials.yaml`(如 `DEEPSEEK_API_KEY: sk-...`,与官方 LLM provider 一致,一处管理所有 key)。插件读取优先级:凭据中心 > 设置页 > 环境变量,设置页填的 key 仅作为遗留兼容。
|
|
285
286
|
- **Test engine**:直测当前引擎可用性(不走回退链,付费引擎无 key 会明确报错)
|
|
286
287
|
- **Use Bing default**:把当前搜索引擎切回稳定的免费 Bing;`Discard` 只撤销尚未保存的编辑
|
|
@@ -429,6 +430,9 @@ googleCseApiKey: ... # Google Custom Search API key
|
|
|
429
430
|
googleCseId: "..." # Programmable Search Engine 的 cx
|
|
430
431
|
metasoApiKey: ... # Metaso API key (metaso.cn/api)
|
|
431
432
|
metasoScope: webpage # webpage | document | scholar
|
|
433
|
+
yandexApiKey: ... # Yandex Search API key (AI Studio)
|
|
434
|
+
yandexFolderId: "..." # folder the key was created in
|
|
435
|
+
yandexSearchType: auto # auto | ru | tr | com | kk | be | uz
|
|
432
436
|
deepseekApiKey: ...
|
|
433
437
|
```
|
|
434
438
|
|
|
@@ -590,7 +594,7 @@ Search engine test:
|
|
|
590
594
|
|
|
591
595
|
#### 离线自检断言(tools/)
|
|
592
596
|
|
|
593
|
-
仓库自带 **
|
|
597
|
+
仓库自带 **57 个**零依赖断言脚本(合计 **851 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑。一次跑全部:`npm test`。
|
|
594
598
|
|
|
595
599
|
| 脚本 | 覆盖 | 运行(项数) |
|
|
596
600
|
|---|---|---|
|
|
@@ -601,7 +605,7 @@ Search engine test:
|
|
|
601
605
|
| `assert-multi-policy.mjs` | multi 执行策略:并发上限是天花板 / 目标成功源非硬下限 / 凭据资格在上限之前分流 / **Fast·Balanced·Deep 档位** | `node tools/assert-multi-policy.mjs`(146) |
|
|
602
606
|
| `assert-multi-limit.mjs` | multi 结果上限(#109):默认 20 / 硬上限 100 / 配置归一化、单次 maxResults 受上限约束、工具参数与本段提示词写明生效上限、设置页字段与保存 | `node tools/assert-multi-limit.mjs`(6) |
|
|
603
607
|
| `assert-maintenance.mjs` | 维护面:CI 在 Node 20/22/24 跑全部断言并过打包闸门、发布脚本会 bump / 校验 / 打 tag / 可发布、恢复官方 provider 的桥接与设置页按钮 | `node tools/assert-maintenance.mjs`(4) |
|
|
604
|
-
| `assert-engine-modules.mjs` | 引擎分层:实现文件存在且被 index 引用、引擎函数已迁出 index、设置页引擎 id 与服务端清单一致、清单覆盖
|
|
608
|
+
| `assert-engine-modules.mjs` | 引擎分层:实现文件存在且被 index 引用、引擎函数已迁出 index、设置页引擎 id 与服务端清单一致、清单覆盖 38 个引擎且免费/按次标记正确、index 不引用引擎私有名 | `node tools/assert-engine-modules.mjs`(6) |
|
|
605
609
|
| `assert-bing-relevance.mjs` | Bing 相关性(#112):单字中文 token 被剔除、无关替代 SERP 被拒、真正相关的结果通过、只命中通用引擎名的整批被拒、单一 token 覆盖一半时放行、单字/纯数字查询的显式行为 | `node tools/assert-bing-relevance.mjs`(6) |
|
|
606
610
|
| `assert-quality.mjs` | 研究证据闸门:8 源 / 3 域 / 3 正文 / 2 日期为 high,3 源 / 2 域 / 1 正文为 medium,单源与失败注记为 low,空包为 low,research 的 schema/输出/brief 接线 | `node tools/assert-quality.mjs`(6) |
|
|
607
611
|
| `assert-dedupe.mjs` | 近重复去重:MinHash 同文本同签名、同 URL 去重、跨站转载去重、不同文章保留且顺序不变、阈值可调、provider 与 multi 两条路径接线 | `node tools/assert-dedupe.mjs`(6) |
|
|
@@ -613,6 +617,7 @@ Search engine test:
|
|
|
613
617
|
| `assert-research-call-wrappers.mjs` | research 四个 `call*` 包装层的替身/底层透传(#75 回归) | `node tools/assert-research-call-wrappers.mjs`(23) |
|
|
614
618
|
| `assert-fetch-chain.mjs` | `fs-quality-fetch` 四层链序、任一层命中即停、exa 失败静默降级 firecrawl、全层失败聚合报错 | `node tools/assert-fetch-chain.mjs`(8) |
|
|
615
619
|
| `assert-fetch-ssrf.mjs` | 抓取 SSRF 防护:公网/私网/保留地址判定、DNS 解析到私网拒绝、localhost 与 IP 字面量拒绝、非 HTTPS 与带凭据 URL 拒绝、fake-ip 网段默认拒绝且仅按配置放行、放行后仍拒绝回环/私网、provider 接线与设置项 | `node tools/assert-fetch-ssrf.mjs`(8) |
|
|
620
|
+
| `assert-yandex.mjs` | Yandex Search:key+folder 必填、Api-Key/请求体/分组、searchType 与 period/family 映射、Base64 XML 解析与日期、错误分类、注册与显式专用 | `node tools/assert-yandex.mjs`(6) |
|
|
616
621
|
| `assert-metaso.mjs` | 秘塔搜索:key 必填、请求体(q/scope/size/summary/raw/concise)、摘要与日期映射、文库数组、size 上限、无效 scope 回退、401/402/429/400 错误分类、注册与默认回退排除 | `node tools/assert-metaso.mjs`(6) |
|
|
617
622
|
| `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) |
|
|
618
623
|
| `assert-engine-runtime.mjs` | 引擎运行时:按引擎并发上限(普通 2 / HTML SERP 1)、排队与 abort 清理、成功/空/失败/平均耗时统计、provider 与 runEngineTest 两条路径接线、诊断报告带 stats | `node tools/assert-engine-runtime.mjs`(4) |
|
|
@@ -647,7 +652,7 @@ Search engine test:
|
|
|
647
652
|
| `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
|
|
648
653
|
| `assert-fetch-charset.mjs` | 抓取编码(#88):`charset=gbk` / `gb2312` 按声明解码、无声明时嗅探 `<meta charset>` 与 http-equiv 形式、默认 UTF-8、未知 label 兜底 UTF-8 不抛错 | `node tools/assert-fetch-charset.mjs`(6) |
|
|
649
654
|
| `assert-fetch-abort.mjs` | 抓取中断(#87):压缩响应中途断连必须 reject(不再永久 pending)、明文断连同样 reject、abort 能打断停滞的 gzip 流、complete 响应与重定向仍正常 | `node tools/assert-fetch-abort.mjs`(6) |
|
|
650
|
-
| `assert-bridge-access.mjs` | 桥接 Host 围栏(#84):loopback 放行、remote peer 打 loopback Host 拒绝、`--trusted-host`(无端口匹配任意端口 / 带端口精确匹配)、`--public-url
|
|
655
|
+
| `assert-bridge-access.mjs` | 桥接 Host 围栏(#84):loopback 放行、remote peer 打 loopback Host 拒绝、`--trusted-host`(无端口匹配任意端口 / 带端口精确匹配)、`--public-url`、绑定地址、跨站与异源拒绝、connection 鉴权委托与 fail-closed | `node tools/assert-bridge-access.mjs`(13) |
|
|
651
656
|
| `assert-provider-takeover.mjs` | provider 接管:旧属性 API 与 rc.2 的 `config.*` ref 两套兼容、`settings.mutate(web)` 单批写入、显式指定的 provider 不被抢占、`fetchProviderTakeover: false` 时保留显式 `http`、describe 噪声不误报、嵌套 config 变化与 web 重建分别成行、关闭 DSH 搜索开关后重新接管且不抢 `deepseek-search-api`、apply 重入/重复注册不再中断、重复日志去重 | `node tools/assert-provider-takeover.mjs`(16) |
|
|
652
657
|
|
|
653
658
|
任何一个失败会以非 0 退出码结束并列出失败项;把某个旧版本文件路径作为参数传进去,可以看到修复前必红(用来证明断言不是空转)。改动发布相关逻辑后建议先跑一遍再发版。
|
|
@@ -700,7 +705,7 @@ This plugin solves exactly that: multiple free engines plus automatic fallback,
|
|
|
700
705
|
#### Engines and switching
|
|
701
706
|
|
|
702
707
|
- **Zero Cost** — Multiple free engines with no API key or registration required
|
|
703
|
-
- **
|
|
708
|
+
- **38 engines available** — DuckDuckGo (HTML / Lite), Bing, AnySearch AI, SearXNG (meta-search with custom instances), Exa, Tavily, Keenable, Firecrawl, Parallel, Perplexity, SerpBase, Serply, Outcrawl, Google Programmable Search (`google`, needs an API key plus a CSE ID), Metaso (秘塔搜索, official API, billed per call), Yandex Search (official API, billed per request, folder ID required), 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, Metaso and Yandex run only when explicitly named.
|
|
704
709
|
- **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.
|
|
705
710
|
- **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).
|
|
706
711
|
- **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).
|
|
@@ -817,6 +822,7 @@ If this plugin has been helpful, a ⭐ on [GitHub](https://github.com/DDDMUC/dsh
|
|
|
817
822
|
| `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 |
|
|
818
823
|
| `google` | Google Programmable Search | Free quota | Requires `GOOGLE_CSE_API_KEY` and a Programmable Search Engine ID (`googleCseId` / cx); official Custom Search JSON API, 100 free queries/day then billed; supports `hl`, safe search and `dateRestrict` time filtering |
|
|
819
824
|
| `metaso` | Metaso (秘塔搜索) | Paid (credits) | Requires `METASO_API_KEY` (metaso.cn/api); official AI search API billed per call (about ¥0.03/query, trial credits for new accounts); supports webpage / document / scholar scopes and returns summaries with sources; not in the default fallback order, use it explicitly after configuring a key |
|
|
825
|
+
| `yandex` | Yandex Search | Paid | Requires `YANDEX_API_KEY` and `yandexFolderId` (AI Studio; billed per request to a billing account); official Search API with RU/TR/COM/KK/BE/UZ search types and Base64 XML responses; supports day / 2 weeks / month time filters; explicit-only |
|
|
820
826
|
| `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) |
|
|
821
827
|
| `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 |
|
|
822
828
|
| `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 |
|
|
@@ -948,7 +954,7 @@ After installation, open the config page (DSH 0.2.1-rc.2+):
|
|
|
948
954
|
The config page provides:
|
|
949
955
|
|
|
950
956
|
- **Search engine**: Select an engine from the dropdown; changes take effect immediately upon saving.
|
|
951
|
-
- **API keys**: Enter keys for Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / Google CSE / Metaso / You.com (password fields; displayed as "configured" once saved; Exa / Tavily / Keenable / Firecrawl / Parallel / You.com work without a key too).
|
|
957
|
+
- **API keys**: Enter keys for Exa / Tavily / Keenable / Firecrawl / Parallel / Perplexity / DeepSeek / Google CSE / Metaso / Yandex / You.com (password fields; displayed as "configured" once saved; Exa / Tavily / Keenable / Firecrawl / Parallel / You.com work without a key too).
|
|
952
958
|
- **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.
|
|
953
959
|
- **Test engine**: Tests the selected engine directly (no fallback chain; paid engines without a key report an explicit error).
|
|
954
960
|
- **Use Bing default**: stage a switch back to the stable free Bing engine; `Discard` only cancels unsaved edits
|
|
@@ -1097,6 +1103,9 @@ googleCseApiKey: ... # Google Custom Search API key
|
|
|
1097
1103
|
googleCseId: "..." # Programmable Search Engine cx
|
|
1098
1104
|
metasoApiKey: ... # Metaso API key (metaso.cn/api)
|
|
1099
1105
|
metasoScope: webpage # webpage | document | scholar
|
|
1106
|
+
yandexApiKey: ... # Yandex Search API key (AI Studio)
|
|
1107
|
+
yandexFolderId: "..." # folder the key was created in
|
|
1108
|
+
yandexSearchType: auto # auto | ru | tr | com | kk | be | uz
|
|
1100
1109
|
deepseekApiKey: ...
|
|
1101
1110
|
```
|
|
1102
1111
|
|
|
@@ -1258,7 +1267,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1258
1267
|
|
|
1259
1268
|
#### Offline self-check assertions (`tools/`)
|
|
1260
1269
|
|
|
1261
|
-
**Fifty-
|
|
1270
|
+
**Fifty-seven** zero-dependency assertion scripts ship with the repo (**851 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20. Run everything with `npm test`.
|
|
1262
1271
|
|
|
1263
1272
|
| Script | Covers | Run (count) |
|
|
1264
1273
|
|---|---|---|
|
|
@@ -1269,7 +1278,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1269
1278
|
| `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) |
|
|
1270
1279
|
| `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) |
|
|
1271
1280
|
| `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) |
|
|
1272
|
-
| `assert-engine-modules.mjs` | Engine layout: module files exist and are imported, implementations have left index.js, the client engine ids match the server catalog, the catalog covers
|
|
1281
|
+
| `assert-engine-modules.mjs` | Engine layout: module files exist and are imported, implementations have left index.js, the client engine ids match the server catalog, the catalog covers 38 engines with the right free/explicit flags, and index never reads an engine-private name | `node tools/assert-engine-modules.mjs` (6) |
|
|
1273
1282
|
| `assert-bing-relevance.mjs` | Bing relevance (#112): single-character CJK tokens removed, an unrelated substituted SERP rejected, genuinely relevant results accepted, a batch matching only a generic engine name rejected, one distinctive token covering half the query accepted, and explicit single-character/numeric behaviour | `node tools/assert-bing-relevance.mjs` (6) |
|
|
1274
1283
|
| `assert-quality.mjs` | Research evidence gate: 8 sources / 3 domains / 3 bodies / 2 dates is high, 3 / 2 / 1 is medium, a single source or a degraded note is low, an empty package is low, and research wires the gate into schema, output and brief | `node tools/assert-quality.mjs` (6) |
|
|
1275
1284
|
| `assert-dedupe.mjs` | Near-duplicate removal: identical text shares a MinHash signature, exact URLs and cross-site copies are dropped, different articles survive in order, the threshold is configurable, and both the provider and multi paths run it | `node tools/assert-dedupe.mjs` (6) |
|
|
@@ -1281,6 +1290,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1281
1290
|
| `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) |
|
|
1282
1291
|
| `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) |
|
|
1283
1292
|
| `assert-fetch-ssrf.mjs` | Fetch SSRF guard: public/private/reserved address classification, DNS resolving to a private address rejected, localhost and IP literals rejected, non-HTTPS and credential URLs rejected, fake-ip ranges blocked by default and allowed only when configured, loopback/RFC1918 still blocked after opt-in, provider wiring and settings | `node tools/assert-fetch-ssrf.mjs` (8) |
|
|
1293
|
+
| `assert-yandex.mjs` | Yandex Search: key + folder required, Api-Key/body/grouping, searchType and period/family mapping, Base64 XML parsing and dates, error classes, registration and explicit-only | `node tools/assert-yandex.mjs` (6) |
|
|
1284
1294
|
| `assert-metaso.mjs` | Metaso search: key required, request body (q/scope/size/summary/raw/concise), summary and date mapping, document array, size clamp, invalid scope fallback, 401/402/429/400 error classes, registration and default-chain exclusion | `node tools/assert-metaso.mjs` (6) |
|
|
1285
1295
|
| `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) |
|
|
1286
1296
|
| `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) |
|
|
@@ -1315,7 +1325,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1315
1325
|
| `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) |
|
|
1316
1326
|
| `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) |
|
|
1317
1327
|
| `assert-fetch-abort.mjs` | fetch interruption (#87): a compressed response cut mid-body rejects instead of hanging forever, identity truncation rejects too, abort breaks a stalled gzip stream, and complete responses plus redirects still work | `node tools/assert-fetch-abort.mjs` (6) |
|
|
1318
|
-
| `assert-bridge-access.mjs` | bridge Host fence (#84): loopback allowed, a remote peer behind a loopback Host refused, `--trusted-host` (port-less matches any port, explicit port matches exactly), `--public-url`, the bind address, cross-site and foreign-Origin refused | `node tools/assert-bridge-access.mjs` (
|
|
1328
|
+
| `assert-bridge-access.mjs` | bridge Host fence (#84): loopback allowed, a remote peer behind a loopback Host refused, `--trusted-host` (port-less matches any port, explicit port matches exactly), `--public-url`, the bind address, cross-site and foreign-Origin refused, connection-auth delegation and fail-closed behavior | `node tools/assert-bridge-access.mjs` (13) |
|
|
1319
1329
|
| `assert-provider-takeover.mjs` | provider takeover: both the legacy property API and the rc.2 `config.*` refs, a single batched `settings.mutate(web)`, explicit foreign providers left untouched, an explicit `http` kept when `fetchProviderTakeover` is off, describe()-triggered events ignored when nothing changed, nested config changes and web rebuilds reported separately, re-takeover after DSH's search switch is turned off without fighting an explicit `deepseek-search-api`, apply re-entry / duplicate registrations tolerated, and repeated logs deduplicated | `node tools/assert-provider-takeover.mjs` (16) |
|
|
1320
1330
|
|
|
1321
1331
|
Any failure exits non-zero with the failing items listed. Passing the path of an older file shows the pre-fix failures (proving the assertions are not vacuous). Worth running before a release.
|
package/lib/client.js
CHANGED
|
@@ -446,6 +446,19 @@ window.__ModuleLoader__.load({
|
|
|
446
446
|
metasoScopeDocument: "文库",
|
|
447
447
|
metasoScopeScholar: "学术",
|
|
448
448
|
metasoScopeHint: "网页最通用;文库面向 PDF/文档,学术面向论文,单次消耗更高。",
|
|
449
|
+
yandexKeyLabel: "Yandex API key",
|
|
450
|
+
yandexKeyHint: "在 Yandex AI Studio 创建,需要同时有 folder ID;按请求计费,需绑定 billing account。",
|
|
451
|
+
yandexFolderLabel: "Yandex folder ID",
|
|
452
|
+
yandexFolderHint: "创建 API key 时所在的 folder;在 AI Studio 顶部文件夹名旁复制。",
|
|
453
|
+
yandexSearchTypeLabel: "Yandex 搜索区域",
|
|
454
|
+
yandexSearchTypeAuto: "自动(按查询语言)",
|
|
455
|
+
yandexSearchTypeRu: "RU · 俄罗斯",
|
|
456
|
+
yandexSearchTypeTr: "TR · 土耳其",
|
|
457
|
+
yandexSearchTypeCom: "COM · 国际",
|
|
458
|
+
yandexSearchTypeKk: "KK · 哈萨克斯坦",
|
|
459
|
+
yandexSearchTypeBe: "BE · 白俄罗斯",
|
|
460
|
+
yandexSearchTypeUz: "UZ · 乌兹别克斯坦",
|
|
461
|
+
yandexSearchTypeHint: "自动按 lang 选择;也可以固定到某个区域。",
|
|
449
462
|
restoreOfficial: "恢复官方搜索",
|
|
450
463
|
restoreOfficialHint: "把 web.searchProvider 改回 deepseek-official、web.fetchProvider 改回 http。停用或卸载本插件前建议先点一次,避免宿主报 configured web provider \"ddg\" is not registered。",
|
|
451
464
|
restoringOfficial: "恢复中…",
|
|
@@ -619,6 +632,19 @@ window.__ModuleLoader__.load({
|
|
|
619
632
|
metasoScopeDocument: "Documents",
|
|
620
633
|
metasoScopeScholar: "Scholars",
|
|
621
634
|
metasoScopeHint: "Webpages is the general default; documents targets PDFs/files and scholars targets papers, both cost more per call.",
|
|
635
|
+
yandexKeyLabel: "Yandex API key",
|
|
636
|
+
yandexKeyHint: "Create one in Yandex AI Studio; a folder ID is required too, and requests are billed to a billing account.",
|
|
637
|
+
yandexFolderLabel: "Yandex folder ID",
|
|
638
|
+
yandexFolderHint: "The folder the API key was created in; copy it from the folder name in AI Studio.",
|
|
639
|
+
yandexSearchTypeLabel: "Yandex search region",
|
|
640
|
+
yandexSearchTypeAuto: "Auto (follow query language)",
|
|
641
|
+
yandexSearchTypeRu: "RU · Russia",
|
|
642
|
+
yandexSearchTypeTr: "TR · Turkey",
|
|
643
|
+
yandexSearchTypeCom: "COM · International",
|
|
644
|
+
yandexSearchTypeKk: "KK · Kazakhstan",
|
|
645
|
+
yandexSearchTypeBe: "BE · Belarus",
|
|
646
|
+
yandexSearchTypeUz: "UZ · Uzbekistan",
|
|
647
|
+
yandexSearchTypeHint: "Auto follows lang; pin a region to override.",
|
|
622
648
|
restoreOfficial: "Restore official search",
|
|
623
649
|
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.",
|
|
624
650
|
restoringOfficial: "Restoring…",
|
|
@@ -668,7 +694,7 @@ window.__ModuleLoader__.load({
|
|
|
668
694
|
"cache_search",
|
|
669
695
|
"domain_search",
|
|
670
696
|
];
|
|
671
|
-
const PLUGIN_VERSION = "0.9.
|
|
697
|
+
const PLUGIN_VERSION = "0.9.43";
|
|
672
698
|
const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
|
|
673
699
|
// 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
|
|
674
700
|
const NAV_ITEMS = [
|
|
@@ -710,6 +736,7 @@ window.__ModuleLoader__.load({
|
|
|
710
736
|
{ id: "outcrawl", label: "Outcrawl", badge: "API KEY", link: "https://outcrawl.ai" },
|
|
711
737
|
{ id: "google", label: "Google · 自定义搜索", badge: "API KEY", link: "https://developers.google.com/custom-search/v1/overview" },
|
|
712
738
|
{ id: "metaso", label: "Metaso · 秘塔搜索", badge: "API KEY", link: "https://metaso.cn/api" },
|
|
739
|
+
{ id: "yandex", label: "Yandex · 搜索 API", badge: "API KEY", link: "https://aistudio.yandex.cloud" },
|
|
713
740
|
{ id: "deepseek-official", label: "DeepSeek Official", badge: "API KEY", link: "https://platform.deepseek.com/api_keys" },
|
|
714
741
|
{ id: "deepseek-tools", label: "DeepSeek Tools API", badge: "API KEY", link: "https://api-docs.deepseek.com/zh-cn/guides/search" },
|
|
715
742
|
{ id: "you", label: "You.com", badge: "FREE", link: "https://you.com/platform/api-keys" },
|
|
@@ -733,10 +760,10 @@ window.__ModuleLoader__.load({
|
|
|
733
760
|
];
|
|
734
761
|
const ENGINE_IDS = ENGINES.filter((engine) => engine.id !== "auto" && engine.id !== "multi").map((engine) => engine.id);
|
|
735
762
|
// 与 lib/index.js 的 EXPLICIT_ONLY_ENGINES 同源:按次计费、只在显式选中时运行,因此不提供入池候选。
|
|
736
|
-
const EXPLICIT_ONLY_ENGINES = ["openai", "gemini", "claude", "metaso"];
|
|
763
|
+
const EXPLICIT_ONLY_ENGINES = ["openai", "gemini", "claude", "metaso", "yandex"];
|
|
737
764
|
// 与 lib/serp_engines.js 的 SERP_ENGINE_IDS 同源:HTML 抓取型引擎,默认不进自动回退链。
|
|
738
765
|
const SERP_ENGINE_IDS = ["baidu-html", "so360", "sogou", "wechat", "toutiao"];
|
|
739
|
-
const MODEL_ENGINES = ENGINES.filter((engine) => EXPLICIT_ONLY_ENGINES.includes(engine.id) && engine.id !== "metaso");
|
|
766
|
+
const MODEL_ENGINES = ENGINES.filter((engine) => EXPLICIT_ONLY_ENGINES.includes(engine.id) && engine.id !== "metaso" && engine.id !== "yandex");
|
|
740
767
|
const DEFAULT_FALLBACK_ORDER = ["exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "serply", "outcrawl", "agy", "deepseek-tools", "deepseek-official", "you", "baidu", "kimi", "aliyun", "doubao", "tinyfish", "jina", "bing", "anysearch", "ddg", "ddg-lite", "searxng", "degoog", "zhihu_global", "zhihu_site"];
|
|
741
768
|
const normalizeFallbackOrder = (value) => {
|
|
742
769
|
const configured = Array.isArray(value) ? value.filter((id) => ENGINE_IDS.includes(id)) : [];
|
|
@@ -952,6 +979,9 @@ window.__ModuleLoader__.load({
|
|
|
952
979
|
const [googleCx, setGoogleCx] = react.useState("");
|
|
953
980
|
const [metasoKey, setMetasoKey] = react.useState("");
|
|
954
981
|
const [metasoScope, setMetasoScope] = react.useState("webpage");
|
|
982
|
+
const [yandexKey, setYandexKey] = react.useState("");
|
|
983
|
+
const [yandexFolder, setYandexFolder] = react.useState("");
|
|
984
|
+
const [yandexType, setYandexType] = react.useState("auto");
|
|
955
985
|
const [youcomKey, setYoucomKey] = react.useState("");
|
|
956
986
|
const [baiduKey, setBaiduKey] = react.useState("");
|
|
957
987
|
const [kimiKey, setKimiKey] = react.useState("");
|
|
@@ -1130,6 +1160,9 @@ window.__ModuleLoader__.load({
|
|
|
1130
1160
|
setGoogleCx(v.googleCseId ?? "");
|
|
1131
1161
|
setMetasoKey(v.metasoApiKey ?? "");
|
|
1132
1162
|
setMetasoScope(v.metasoScope === "document" || v.metasoScope === "scholar" ? v.metasoScope : "webpage");
|
|
1163
|
+
setYandexKey(v.yandexApiKey ?? "");
|
|
1164
|
+
setYandexFolder(v.yandexFolderId ?? "");
|
|
1165
|
+
setYandexType(["ru", "tr", "com", "kk", "be", "uz"].includes(v.yandexSearchType) ? v.yandexSearchType : "auto");
|
|
1133
1166
|
setYoucomKey(v.youcomApiKey ?? "");
|
|
1134
1167
|
setBaiduKey(v.baiduApiKey ?? "");
|
|
1135
1168
|
setKimiKey(v.kimiApiKey ?? "");
|
|
@@ -1180,6 +1213,7 @@ window.__ModuleLoader__.load({
|
|
|
1180
1213
|
if (path === "degoogApiKey") configured.degoog = true;
|
|
1181
1214
|
if (path === "googleCseApiKey") configured.google = true;
|
|
1182
1215
|
if (path === "metasoApiKey") configured.metaso = true;
|
|
1216
|
+
if (path === "yandexApiKey") configured.yandex = true;
|
|
1183
1217
|
}
|
|
1184
1218
|
}
|
|
1185
1219
|
setKeysConfigured(configured);
|
|
@@ -1191,7 +1225,7 @@ window.__ModuleLoader__.load({
|
|
|
1191
1225
|
const cred = await bridgeCredentialsStatus();
|
|
1192
1226
|
if (cred.ok) {
|
|
1193
1227
|
const cc = {};
|
|
1194
|
-
const map = { anysearchApiKey: "anysearch", exaApiKey: "exa", tavilyApiKey: "tavily", keenableApiKey: "keenable", firecrawlApiKey: "firecrawl", parallelApiKey: "parallel", perplexityApiKey: "perplexity", deepseekApiKey: "deepseek", serpbaseApiKey: "serpbase", serplyApiKey: "serply", outcrawlApiKey: "outcrawl", youcomApiKey: "youcom", degoogApiKey: "degoog", googleCseApiKey: "google", metasoApiKey: "metaso", baiduApiKey: "baidu", kimiApiKey: "kimi", aliyunApiKey: "aliyun", doubaoApiKey: "doubao", openaiApiKey: "openai", geminiApiKey: "gemini", claudeApiKey: "claude", zhihuApiKey: "zhihu", tinyfishApiKey: "tinyfish", jinaApiKey: "jina", searxngBearerToken: "searxng" };
|
|
1228
|
+
const map = { anysearchApiKey: "anysearch", exaApiKey: "exa", tavilyApiKey: "tavily", keenableApiKey: "keenable", firecrawlApiKey: "firecrawl", parallelApiKey: "parallel", perplexityApiKey: "perplexity", deepseekApiKey: "deepseek", serpbaseApiKey: "serpbase", serplyApiKey: "serply", outcrawlApiKey: "outcrawl", youcomApiKey: "youcom", degoogApiKey: "degoog", googleCseApiKey: "google", metasoApiKey: "metaso", yandexApiKey: "yandex", baiduApiKey: "baidu", kimiApiKey: "kimi", aliyunApiKey: "aliyun", doubaoApiKey: "doubao", openaiApiKey: "openai", geminiApiKey: "gemini", claudeApiKey: "claude", zhihuApiKey: "zhihu", tinyfishApiKey: "tinyfish", jinaApiKey: "jina", searxngBearerToken: "searxng" };
|
|
1195
1229
|
for (const [k, v] of Object.entries(cred.value.configured ?? {})) {
|
|
1196
1230
|
if (map[k]) cc[map[k]] = v;
|
|
1197
1231
|
}
|
|
@@ -1241,6 +1275,7 @@ window.__ModuleLoader__.load({
|
|
|
1241
1275
|
["outcrawlApiKey", outcrawlKey],
|
|
1242
1276
|
["googleCseApiKey", googleKey],
|
|
1243
1277
|
["metasoApiKey", metasoKey],
|
|
1278
|
+
["yandexApiKey", yandexKey],
|
|
1244
1279
|
["youcomApiKey", youcomKey],
|
|
1245
1280
|
["baiduApiKey", baiduKey],
|
|
1246
1281
|
["kimiApiKey", kimiKey],
|
|
@@ -1288,6 +1323,8 @@ window.__ModuleLoader__.load({
|
|
|
1288
1323
|
ops.push({ op: "set", path: ["fetchProviderTakeover"], value: fetchProviderTakeover });
|
|
1289
1324
|
ops.push({ op: "set", path: ["googleCseId"], value: googleCx.trim() });
|
|
1290
1325
|
ops.push({ op: "set", path: ["metasoScope"], value: metasoScope === "document" || metasoScope === "scholar" ? metasoScope : "webpage" });
|
|
1326
|
+
ops.push({ op: "set", path: ["yandexFolderId"], value: yandexFolder.trim() });
|
|
1327
|
+
ops.push({ op: "set", path: ["yandexSearchType"], value: ["ru", "tr", "com", "kk", "be", "uz"].includes(yandexType) ? yandexType : "auto" });
|
|
1291
1328
|
ops.push({ op: "set", path: ["browserFetch"], value: browserFetch });
|
|
1292
1329
|
ops.push({
|
|
1293
1330
|
op: "set",
|
|
@@ -2124,6 +2161,94 @@ react_jsx_runtime.jsx("div", {
|
|
|
2124
2161
|
}),
|
|
2125
2162
|
],
|
|
2126
2163
|
}),
|
|
2164
|
+
react_jsx_runtime.jsx("div", {
|
|
2165
|
+
className: "dshfs-field",
|
|
2166
|
+
children: [
|
|
2167
|
+
react_jsx_runtime.jsx("div", {
|
|
2168
|
+
className: "dshfs-label",
|
|
2169
|
+
children: t.yandexKeyLabel,
|
|
2170
|
+
}),
|
|
2171
|
+
react_jsx_runtime.jsx("input", {
|
|
2172
|
+
className: "dshfs-input",
|
|
2173
|
+
type: "password",
|
|
2174
|
+
value: yandexKey,
|
|
2175
|
+
spellCheck: false,
|
|
2176
|
+
placeholder: "API key",
|
|
2177
|
+
disabled: !ready || saving,
|
|
2178
|
+
onChange: (e) => {
|
|
2179
|
+
setYandexKey(e.target.value);
|
|
2180
|
+
setDirty(true);
|
|
2181
|
+
setFailed(false);
|
|
2182
|
+
setSaveError("");
|
|
2183
|
+
},
|
|
2184
|
+
}),
|
|
2185
|
+
react_jsx_runtime.jsx("p", {
|
|
2186
|
+
className: "dshfs-hint",
|
|
2187
|
+
children: t.yandexKeyHint,
|
|
2188
|
+
}),
|
|
2189
|
+
],
|
|
2190
|
+
}),
|
|
2191
|
+
react_jsx_runtime.jsx("div", {
|
|
2192
|
+
className: "dshfs-field",
|
|
2193
|
+
children: [
|
|
2194
|
+
react_jsx_runtime.jsx("div", {
|
|
2195
|
+
className: "dshfs-label",
|
|
2196
|
+
children: t.yandexFolderLabel,
|
|
2197
|
+
}),
|
|
2198
|
+
react_jsx_runtime.jsx("input", {
|
|
2199
|
+
className: "dshfs-input",
|
|
2200
|
+
type: "text",
|
|
2201
|
+
value: yandexFolder,
|
|
2202
|
+
spellCheck: false,
|
|
2203
|
+
placeholder: "b1g...",
|
|
2204
|
+
disabled: !ready || saving,
|
|
2205
|
+
onChange: (e) => {
|
|
2206
|
+
setYandexFolder(e.target.value);
|
|
2207
|
+
setDirty(true);
|
|
2208
|
+
setFailed(false);
|
|
2209
|
+
setSaveError("");
|
|
2210
|
+
},
|
|
2211
|
+
}),
|
|
2212
|
+
react_jsx_runtime.jsx("p", {
|
|
2213
|
+
className: "dshfs-hint",
|
|
2214
|
+
children: t.yandexFolderHint,
|
|
2215
|
+
}),
|
|
2216
|
+
],
|
|
2217
|
+
}),
|
|
2218
|
+
react_jsx_runtime.jsx("div", {
|
|
2219
|
+
className: "dshfs-field",
|
|
2220
|
+
children: [
|
|
2221
|
+
react_jsx_runtime.jsx("div", {
|
|
2222
|
+
className: "dshfs-label",
|
|
2223
|
+
children: t.yandexSearchTypeLabel,
|
|
2224
|
+
}),
|
|
2225
|
+
react_jsx_runtime.jsx("select", {
|
|
2226
|
+
className: "dshfs-select",
|
|
2227
|
+
value: yandexType,
|
|
2228
|
+
style: { colorScheme: selectColorScheme },
|
|
2229
|
+
disabled: !ready || saving,
|
|
2230
|
+
onChange: (e) => {
|
|
2231
|
+
setYandexType(["ru", "tr", "com", "kk", "be", "uz"].includes(e.target.value) ? e.target.value : "auto");
|
|
2232
|
+
setDirty(true);
|
|
2233
|
+
setFailed(false);
|
|
2234
|
+
setSaveError("");
|
|
2235
|
+
},
|
|
2236
|
+
children: [
|
|
2237
|
+
react_jsx_runtime.jsx("option", { value: "auto", children: t.yandexSearchTypeAuto }),
|
|
2238
|
+
react_jsx_runtime.jsx("option", { value: "ru", children: t.yandexSearchTypeRu }),
|
|
2239
|
+
react_jsx_runtime.jsx("option", { value: "tr", children: t.yandexSearchTypeTr }),
|
|
2240
|
+
react_jsx_runtime.jsx("option", { value: "com", children: t.yandexSearchTypeCom }),
|
|
2241
|
+
react_jsx_runtime.jsx("option", { value: "kk", children: t.yandexSearchTypeKk }),
|
|
2242
|
+
react_jsx_runtime.jsx("option", { value: "be", children: t.yandexSearchTypeBe }),
|
|
2243
|
+
react_jsx_runtime.jsx("option", { value: "uz", children: t.yandexSearchTypeUz }),
|
|
2244
|
+
],
|
|
2245
|
+
}),
|
|
2246
|
+
react_jsx_runtime.jsx("p", {
|
|
2247
|
+
className: "dshfs-hint",
|
|
2248
|
+
children: t.yandexSearchTypeHint,
|
|
2249
|
+
}),
|
|
2250
|
+
],
|
|
2251
|
+
}),
|
|
2127
2252
|
react_jsx_runtime.jsx("div", {
|
|
2128
2253
|
className: "dshfs-field",
|
|
2129
2254
|
id: "dshfs-anchor-fallback",
|
package/lib/engine_meta.js
CHANGED
|
@@ -25,6 +25,7 @@ const BASE_ENGINES = [
|
|
|
25
25
|
{ id: "outcrawl", free: false, time: false },
|
|
26
26
|
{ id: "google", free: false, time: true },
|
|
27
27
|
{ id: "metaso", free: false, time: false, explicitOnly: true },
|
|
28
|
+
{ id: "yandex", free: false, time: false, explicitOnly: true },
|
|
28
29
|
{ id: "deepseek-official", free: false, time: false },
|
|
29
30
|
{ id: "deepseek-tools", free: false, time: true },
|
|
30
31
|
{ id: "you", free: false, time: false },
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// Yandex Search API (official, paid). REST returns Base64-encoded XML in
|
|
2
|
+
// rawData; the engine decodes it and maps <doc> entries to the common shape.
|
|
3
|
+
import { stripTags, uniqueSources } from "./shared.js";
|
|
4
|
+
|
|
5
|
+
const YANDEX_URL = "https://searchapi.api.cloud.yandex.net/v2/web/search";
|
|
6
|
+
const MAX_RESULTS = 50;
|
|
7
|
+
|
|
8
|
+
export const YANDEX_SEARCH_TYPES = ["auto", "ru", "tr", "com", "kk", "be", "uz"];
|
|
9
|
+
|
|
10
|
+
const SEARCH_TYPE_BY_LANG = {
|
|
11
|
+
ru: "SEARCH_TYPE_RU",
|
|
12
|
+
tr: "SEARCH_TYPE_TR",
|
|
13
|
+
kk: "SEARCH_TYPE_KK",
|
|
14
|
+
be: "SEARCH_TYPE_BE",
|
|
15
|
+
uz: "SEARCH_TYPE_UZ",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const PERIODS = [
|
|
19
|
+
{ maxDays: 1, period: "PERIOD_DAY" },
|
|
20
|
+
{ maxDays: 14, period: "PERIOD_2_WEEKS" },
|
|
21
|
+
{ maxDays: 31, period: "PERIOD_MONTH" },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export function normalizeYandexSearchType(value, lang = "en") {
|
|
25
|
+
const choice = String(value ?? "").trim().toLowerCase();
|
|
26
|
+
if (choice !== "" && choice !== "auto" && YANDEX_SEARCH_TYPES.includes(choice)) {
|
|
27
|
+
return `SEARCH_TYPE_${choice.toUpperCase()}`;
|
|
28
|
+
}
|
|
29
|
+
return SEARCH_TYPE_BY_LANG[String(lang ?? "").toLowerCase()] ?? "SEARCH_TYPE_COM";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function yandexPeriod(timeRange) {
|
|
33
|
+
if (!timeRange) return undefined;
|
|
34
|
+
const days = timeRange.after
|
|
35
|
+
? Math.max(1, Math.ceil((Date.now() - Date.parse(`${timeRange.after}T00:00:00Z`)) / 86_400_000))
|
|
36
|
+
: Number(timeRange.days);
|
|
37
|
+
if (!Number.isFinite(days) || days <= 0) return undefined;
|
|
38
|
+
return PERIODS.find((entry) => days <= entry.maxDays)?.period;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function familyMode(safeSearch) {
|
|
42
|
+
if (safeSearch === "strict") return "FAMILY_MODE_STRICT";
|
|
43
|
+
if (safeSearch === "moderate") return "FAMILY_MODE_MODERATE";
|
|
44
|
+
if (safeSearch === "off") return "FAMILY_MODE_NONE";
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function yandexErrorMessage(status, detail) {
|
|
49
|
+
let upstream = "";
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(detail);
|
|
52
|
+
upstream = parsed?.message ?? parsed?.error?.message ?? "";
|
|
53
|
+
} catch {}
|
|
54
|
+
const suffix = upstream ? `: ${String(upstream).slice(0, 200)}` : "";
|
|
55
|
+
if (status === 401 || status === 403) {
|
|
56
|
+
return `Yandex API key or folder is invalid, or the key lacks the search-api.webSearch.user role (HTTP ${status})${suffix}`;
|
|
57
|
+
}
|
|
58
|
+
if (status === 429) return `Yandex quota/rate limit exceeded (HTTP 429)${suffix}`;
|
|
59
|
+
if (status === 400) return `Yandex search request failed (HTTP 400)${suffix} - check yandexFolderId and the query`;
|
|
60
|
+
return `Yandex API error (HTTP ${status})${suffix}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function xmlText(raw) {
|
|
64
|
+
return stripTags(String(raw ?? "").replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, "$1")).trim();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function publishedDate(raw) {
|
|
68
|
+
const text = String(raw ?? "").trim();
|
|
69
|
+
const match = text.match(/^(\d{4})(\d{2})(\d{2})(?:T|$)/);
|
|
70
|
+
return match ? `${match[1]}-${match[2]}-${match[3]}` : "";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function parseYandexXml(xml) {
|
|
74
|
+
const sources = [];
|
|
75
|
+
const docs = String(xml ?? "").matchAll(/<doc(?:\s[^>]*)?>([\s\S]*?)<\/doc>/g);
|
|
76
|
+
for (const match of docs) {
|
|
77
|
+
const block = match[1];
|
|
78
|
+
const url = xmlText(block.match(/<url>([\s\S]*?)<\/url>/)?.[1]);
|
|
79
|
+
if (!url) continue;
|
|
80
|
+
const title = xmlText(block.match(/<title>([\s\S]*?)<\/title>/)?.[1]);
|
|
81
|
+
const passages = [...block.matchAll(/<passage>([\s\S]*?)<\/passage>/g)]
|
|
82
|
+
.map((entry) => xmlText(entry[1]))
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
const snippet = passages.slice(0, 3).join(" ").slice(0, 1000);
|
|
85
|
+
const date = publishedDate(xmlText(block.match(/<modtime>([\s\S]*?)<\/modtime>/)?.[1]));
|
|
86
|
+
sources.push({
|
|
87
|
+
url,
|
|
88
|
+
...(title ? { title } : {}),
|
|
89
|
+
...(snippet ? { snippet } : {}),
|
|
90
|
+
...(date ? { publishedAt: date } : {}),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return sources;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function searchYandex(query, maxResults, apiKey, folderId, options = {}, timeRange, signal) {
|
|
97
|
+
if (!apiKey) throw new Error("Yandex search requires YANDEX_API_KEY");
|
|
98
|
+
if (!folderId) throw new Error("Yandex search requires a folder ID (yandexFolderId)");
|
|
99
|
+
const limit = Math.min(Math.max(Number(maxResults) || 10, 1), MAX_RESULTS);
|
|
100
|
+
const searchType = normalizeYandexSearchType(options.searchType, options.lang);
|
|
101
|
+
const family = familyMode(options.safeSearch);
|
|
102
|
+
const period = yandexPeriod(timeRange);
|
|
103
|
+
|
|
104
|
+
const controller = new AbortController();
|
|
105
|
+
const timer = setTimeout(() => controller.abort(), 30000);
|
|
106
|
+
const onAbort = () => controller.abort();
|
|
107
|
+
signal?.addEventListener("abort", onAbort);
|
|
108
|
+
|
|
109
|
+
let response;
|
|
110
|
+
try {
|
|
111
|
+
response = await fetch(YANDEX_URL, {
|
|
112
|
+
method: "POST",
|
|
113
|
+
redirect: "error",
|
|
114
|
+
headers: {
|
|
115
|
+
authorization: `Api-Key ${apiKey}`,
|
|
116
|
+
"content-type": "application/json",
|
|
117
|
+
accept: "application/json",
|
|
118
|
+
"user-agent": "deepseek-harness/free-search",
|
|
119
|
+
},
|
|
120
|
+
body: JSON.stringify({
|
|
121
|
+
query: {
|
|
122
|
+
searchType,
|
|
123
|
+
queryText: String(query),
|
|
124
|
+
...(family === undefined ? {} : { familyMode: family }),
|
|
125
|
+
},
|
|
126
|
+
groupSpec: {
|
|
127
|
+
groupMode: "GROUP_MODE_FLAT",
|
|
128
|
+
groupsOnPage: String(limit),
|
|
129
|
+
docsInGroup: "1",
|
|
130
|
+
},
|
|
131
|
+
maxPassages: "3",
|
|
132
|
+
...(options.region ? { region: String(options.region) } : {}),
|
|
133
|
+
folderId,
|
|
134
|
+
responseFormat: "FORMAT_XML",
|
|
135
|
+
...(period === undefined ? {} : { period }),
|
|
136
|
+
}),
|
|
137
|
+
signal: controller.signal,
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (signal?.aborted) throw error;
|
|
141
|
+
if (error?.name === "AbortError") throw new Error("Yandex request timed out");
|
|
142
|
+
throw new Error(`Yandex request failed: ${error?.message ?? String(error)}`);
|
|
143
|
+
} finally {
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
signal?.removeEventListener("abort", onAbort);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!response.ok) {
|
|
149
|
+
const detail = await response.text().catch(() => "");
|
|
150
|
+
throw new Error(yandexErrorMessage(response.status, detail));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let data;
|
|
154
|
+
try {
|
|
155
|
+
data = await response.json();
|
|
156
|
+
} catch {
|
|
157
|
+
throw new Error("Yandex returned an invalid JSON response");
|
|
158
|
+
}
|
|
159
|
+
if (typeof data?.rawData !== "string" || data.rawData === "") {
|
|
160
|
+
throw new Error("Yandex response has no rawData");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let xml;
|
|
164
|
+
try {
|
|
165
|
+
xml = Buffer.from(data.rawData, "base64").toString("utf8");
|
|
166
|
+
} catch {
|
|
167
|
+
throw new Error("Yandex rawData is not valid Base64");
|
|
168
|
+
}
|
|
169
|
+
return { sources: uniqueSources(parseYandexXml(xml), limit), truncated: false };
|
|
170
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -41,6 +41,7 @@ import { searchSerply } from "./engines/serply.js";
|
|
|
41
41
|
import { searchOutcrawl } from "./engines/outcrawl.js";
|
|
42
42
|
import { searchGoogle } from "./engines/google.js";
|
|
43
43
|
import { searchMetaso } from "./engines/metaso.js";
|
|
44
|
+
import { searchYandex } from "./engines/yandex.js";
|
|
44
45
|
import { createEngineRuntime, ENGINE_CONCURRENCY_LIMIT, SERP_CONCURRENCY_LIMIT } from "./engine_runtime.js";
|
|
45
46
|
import { classifyIntent, preferForIntent } from "./intent.js";
|
|
46
47
|
import { dedupeNearDuplicates } from "./dedupe.js";
|
|
@@ -1358,7 +1359,23 @@ function toView(descriptor) {
|
|
|
1358
1359
|
};
|
|
1359
1360
|
}
|
|
1360
1361
|
|
|
1361
|
-
|
|
1362
|
+
/**
|
|
1363
|
+
* The plugin's exact routes are longer than DSH's `/api` prefix, so they run
|
|
1364
|
+
* before the host's admission check. Ask the connection service for the same
|
|
1365
|
+
* decision; if it is unavailable, fail closed instead of exposing the bridge.
|
|
1366
|
+
*/
|
|
1367
|
+
export function bridgeAuthRejection(request, connection) {
|
|
1368
|
+
if (connection === undefined || connection === null) return 503;
|
|
1369
|
+
const reject = connection.requestRejection;
|
|
1370
|
+
if (typeof reject !== "function") return 503;
|
|
1371
|
+
try {
|
|
1372
|
+
return reject.call(connection, request) ?? undefined;
|
|
1373
|
+
} catch {
|
|
1374
|
+
return 503;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
function makeBridgeRoutes(settings, search, testEngine, getCredentials, getConfig = () => ({}), doctor = async () => "", connection = () => undefined) {
|
|
1362
1379
|
const allowlisted = () =>
|
|
1363
1380
|
settings
|
|
1364
1381
|
.describe({ redactSecrets: true })
|
|
@@ -1603,6 +1620,11 @@ function makeBridgeRoutes(settings, search, testEngine, getCredentials, getConfi
|
|
|
1603
1620
|
};
|
|
1604
1621
|
|
|
1605
1622
|
const guard = (req, res) => {
|
|
1623
|
+
const rejection = bridgeAuthRejection(req, connection());
|
|
1624
|
+
if (rejection !== undefined) {
|
|
1625
|
+
writeJson(res, rejection, { error: "host authentication required" });
|
|
1626
|
+
return false;
|
|
1627
|
+
}
|
|
1606
1628
|
if (!isBridgeRequestAllowed(req)) {
|
|
1607
1629
|
writeJson(res, 403, { error: "requests must come from the local host or a configured trusted host" });
|
|
1608
1630
|
return false;
|
|
@@ -1813,6 +1835,7 @@ const KEY_REF_MAP = {
|
|
|
1813
1835
|
outcrawlApiKey: "OUTCRAWL_API_KEY",
|
|
1814
1836
|
googleCseApiKey: "GOOGLE_CSE_API_KEY",
|
|
1815
1837
|
metasoApiKey: "METASO_API_KEY",
|
|
1838
|
+
yandexApiKey: "YANDEX_API_KEY",
|
|
1816
1839
|
deepseekApiKey: "DEEPSEEK_API_KEY",
|
|
1817
1840
|
// 设置页写入的凭据槽位保持旧名,已保存的 key 不受影响;读取时 YDC_API_KEY 优先(见 resolveYoucomApiKey)
|
|
1818
1841
|
youcomApiKey: "YOUCOM_API_KEY",
|
|
@@ -1885,6 +1908,9 @@ const Config = z.object({
|
|
|
1885
1908
|
googleCseId: z.string().default("").volatile(),
|
|
1886
1909
|
metasoApiKey: z.string().role("secret").volatile(),
|
|
1887
1910
|
metasoScope: z.string().default("webpage").volatile(),
|
|
1911
|
+
yandexApiKey: z.string().role("secret").volatile(),
|
|
1912
|
+
yandexFolderId: z.string().default("").volatile(),
|
|
1913
|
+
yandexSearchType: z.string().default("auto").volatile(),
|
|
1888
1914
|
searxngBearerToken: z.string().role("secret").volatile(),
|
|
1889
1915
|
degoogApiKey: z.string().role("secret").volatile(),
|
|
1890
1916
|
platforms: z.array(z.string()).default(["github", "v2ex", "bilibili", "reddit", "hn", "stackoverflow", "wikipedia", "npm", "youtube", "vimeo", "juejin", "douban", "qiita", "x"]).volatile(),
|
|
@@ -2424,6 +2450,18 @@ function apply(ctx, config) {
|
|
|
2424
2450
|
const key = await requireEngineKey("METASO_API_KEY", "metasoApiKey", "Metaso", " (get one at metaso.cn/api)");
|
|
2425
2451
|
return searchMetaso(query, maxResults, key, current().metasoScope, timeRange, signal);
|
|
2426
2452
|
},
|
|
2453
|
+
yandex: async ({ query, maxResults, timeRange, signal }) => {
|
|
2454
|
+
const key = await requireEngineKey("YANDEX_API_KEY", "yandexApiKey", "Yandex", " (create one at aistudio.yandex.cloud)");
|
|
2455
|
+
const cfg = current();
|
|
2456
|
+
if (!cfg.yandexFolderId) {
|
|
2457
|
+
throw new EngineSkip("Yandex requires a folder ID (yandexFolderId)", "yandexFolderId is not configured");
|
|
2458
|
+
}
|
|
2459
|
+
return searchYandex(query, maxResults, key, cfg.yandexFolderId, {
|
|
2460
|
+
searchType: cfg.yandexSearchType,
|
|
2461
|
+
lang: searchLanguage(configLanguage(cfg)),
|
|
2462
|
+
safeSearch: cfg.safeSearch,
|
|
2463
|
+
}, timeRange, signal);
|
|
2464
|
+
},
|
|
2427
2465
|
you: async ({ query, maxResults, signal }) =>
|
|
2428
2466
|
searchYoucom(query, maxResults, await resolveYoucomKey(), signal),
|
|
2429
2467
|
tinyfish: async ({ query, maxResults, timeRange, signal }) =>
|
|
@@ -2863,7 +2901,14 @@ function apply(ctx, config) {
|
|
|
2863
2901
|
},
|
|
2864
2902
|
getCredentials,
|
|
2865
2903
|
current,
|
|
2866
|
-
doctorReport
|
|
2904
|
+
doctorReport,
|
|
2905
|
+
() => {
|
|
2906
|
+
try {
|
|
2907
|
+
return sctx.get("connection");
|
|
2908
|
+
} catch {
|
|
2909
|
+
return undefined;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2867
2912
|
).map((route) => registerOnce(() => sctx.get("webServer").register(route), { id: route.path }, "bridge route"));
|
|
2868
2913
|
return () => {
|
|
2869
2914
|
for (const dispose of disposers) dispose();
|
|
@@ -3084,6 +3129,16 @@ function apply(ctx, config) {
|
|
|
3084
3129
|
if (!key) return { ok: false, error: "METASO_API_KEY not configured" };
|
|
3085
3130
|
return await searchMetaso(q, n, key, cfg.metasoScope, tr);
|
|
3086
3131
|
}
|
|
3132
|
+
case "yandex": {
|
|
3133
|
+
const key = await resolveApiKey("YANDEX_API_KEY", "yandexApiKey");
|
|
3134
|
+
if (!key) return { ok: false, error: "YANDEX_API_KEY not configured" };
|
|
3135
|
+
if (!cfg.yandexFolderId) return { ok: false, error: "yandexFolderId not configured" };
|
|
3136
|
+
return await searchYandex(q, n, key, cfg.yandexFolderId, {
|
|
3137
|
+
searchType: cfg.yandexSearchType,
|
|
3138
|
+
lang: searchLanguage(configLanguage(cfg)),
|
|
3139
|
+
safeSearch: cfg.safeSearch,
|
|
3140
|
+
}, tr);
|
|
3141
|
+
}
|
|
3087
3142
|
case "agy": {
|
|
3088
3143
|
if (!agyAvailable()) return { ok: false, error: "Antigravity CLI not installed (install Antigravity or set AGY_BIN)" };
|
|
3089
3144
|
return await searchAgy(q, n, {});
|
package/lib/multi_policy.js
CHANGED
|
@@ -222,6 +222,7 @@ export const REQUIRED_CREDENTIALS = {
|
|
|
222
222
|
outcrawl: [{ env: "OUTCRAWL_API_KEY", settings: "outcrawlApiKey" }],
|
|
223
223
|
google: [{ env: "GOOGLE_CSE_API_KEY", settings: "googleCseApiKey" }],
|
|
224
224
|
metaso: [{ env: "METASO_API_KEY", settings: "metasoApiKey" }],
|
|
225
|
+
yandex: [{ env: "YANDEX_API_KEY", settings: "yandexApiKey" }],
|
|
225
226
|
tinyfish: [{ env: "TINYFISH_API_KEY", settings: "tinyfishApiKey" }],
|
|
226
227
|
jina: [{ env: "JINA_API_KEY", settings: "jinaApiKey" }],
|
|
227
228
|
baidu: [{ env: "BAIDU_API_KEY", settings: "baiduApiKey" }],
|
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:
|
|
3
|
+
"version": "0.9.43",
|
|
4
|
+
"description": "Free web search for DeepSeek Harness: 38 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/Baidu/Kimi/Aliyun/Doubao/Google CSE/Metaso/Yandex 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": {
|