dsh-free-search 0.9.22 → 0.9.25
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 +60 -4
- package/lib/client.js +366 -6
- package/lib/index.js +93 -31
- package/lib/prompt_i18n.js +375 -308
- package/lib/research.js +5 -4
- package/lib/vertical.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,24 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
|
|
|
31
31
|
- **零成本** —— 多个免费引擎,无需 key、无需注册
|
|
32
32
|
- **多引擎可选**:DuckDuckGo(html/lite)、Bing、SearXNG(元搜索,支持自定义实例)、AnySearch、Exa、Tavily、Keenable、Firecrawl、Parallel、Perplexity、SerpBase、Serply、DeepSeek 官方、DeepSeek 原生搜索 API、You.com、百度千帆、Kimi、阿里云百炼、火山联网搜索(豆包搜索)、知乎全网/站内(`zhihu_global`/`zhihu_site`,经知乎开放平台 MCP)、OpenAI / Gemini / Claude 模型内置搜索
|
|
33
33
|
- **网页设置页** —— 引擎切换 + API key 配置(UI 中 key 脱敏显示"已配置")+ 中英文切换;入口在左侧「插件」页的组件行配置(`plugins.row.config`,DSH 0.1.7-rc.1+)。远程访问(VPS / 反向代理 / 自定义域名)下也能用:桥接接口沿用宿主的 Host 围栏,`--trusted-host` 与 `--public-url` 声明的地址会放行(#84)
|
|
34
|
-
- **右侧浮动目录** —— 卡片右侧的页面留白里浮出「引擎 / 回退 / 语言池 / 搜索行为 / 抓取 /
|
|
34
|
+
- **右侧浮动目录** —— 卡片右侧的页面留白里浮出「引擎 / 回退 / 语言池 / 搜索行为 / 抓取 / 性能 / 提示词管理」七个快捷跳转,滚动自动高亮当前项、点击平滑跳转;不占用正文宽度(正文布局与 0.9.6 一致),右侧留白不足时自动隐藏;每项都是真链接(`#/panel/plugins/dsh-free-search/<分区>`),可复制、可开新标签,见下方「分区链接契约」
|
|
35
|
+
|
|
36
|
+
### 提示词分三段
|
|
37
|
+
|
|
38
|
+
设置页第七段「提示词」分成三段:状态、工具、约束。每段都有自己的翻页器,页 1 是内置英文、页 2 是内置中文,都按当前配置实时生成,不入盘,不能删也不能改;页 3 起是你自己加的页。发送时每段取你当前停的那一页,拼起来就是注入内容;三段都空则整段不注入。
|
|
39
|
+
|
|
40
|
+
「工具」那一段是九个工具各一行:前面的勾选框决定这个工具给不给模型,后面的框里是写给模型的那句话,只读,跟插件更新走,不能改。这一段的右上角有中英切换,一下切换全部工具,还有「全选」和「全不选」两个按钮。取消勾选的工具不再交给模型,工具说明也一并从请求里去掉,那一段里也不会再列出它。想加自己的要求,写在「约束」那一段的自定义页里。
|
|
41
|
+
|
|
42
|
+
### 分区链接契约(与 dsh-url-router 对接)
|
|
43
|
+
|
|
44
|
+
规则见 `dsh-url-router/docs/panel-sections.md`(数量不限,当前 7 段:engines / fallback / pools / behavior / fetch / performance / prompt):
|
|
45
|
+
|
|
46
|
+
- 页面根发布**恰好一个** `data-dsh-panel-section="<id>"` = 读者正在看的那一节(跟着滚动走,不做“到底=最后一节”的猜测)
|
|
47
|
+
- 每个分区容器带 `data-dsh-section="<id>"`(滚动目标)
|
|
48
|
+
- 侧栏每项是 `<a data-dsh-section="<id>" href="#/panel/plugins/dsh-free-search/<id>">`
|
|
49
|
+
- 本插件**不写 URL**:`location.hash` / `history.pushState` / `replaceState` 一律不碰,地址栏唯一写者是 dsh-url-router;地址栏里出现本页分区链接时(`hashchange`)插件负责把它滚进视野
|
|
50
|
+
|
|
51
|
+
加新分区只需三步:容器加 `data-dsh-section="<新id>"`、`NAV_ITEMS` 加一条(侧栏锚点自动生成,href 由 `item.id` 拼)、`assert-rail-section` 的 id 列表加一项。
|
|
35
52
|
- **多 key 轮换** —— 任何 key 字段(或对应环境变量)都可以用逗号 / 分号 / 换行分隔多把 key;平时按请求轮流使用(round-robin,避免单 key 撞 QPS/RPM 风控),遇到 401/402/429(鉴权失败、额度耗尽、限流)先轮换同一引擎的下一把,再走引擎回退;`multi` 模式同样生效(#96)
|
|
36
53
|
- **弹出式切换命令** —— 聊天框输入 `/free-search-engine`,弹出引擎选择窗口,点选即切换(等效设置页 + 保存)
|
|
37
54
|
- **引擎测试** —— `free_search_test` 工具让 agent 一键测试所有引擎;设置页也有"测试引擎"按钮(直测当前引擎,不走回退链,付费引擎无 key 会明确报错)
|
|
@@ -314,6 +331,16 @@ lang: zh # 搜索语言池/本地化(zh / en / ru …,不
|
|
|
314
331
|
# web_fetch(fs-quality-fetch)的 Accept-Language 同样跟随 lang,不再固定中文(#92)。
|
|
315
332
|
uiLang: zh # 设置页界面语言(zh / en);留空则跟随 lang
|
|
316
333
|
promptLanguage: en # 注入给模型的系统提示词与工具描述语言(en / zh);只翻叙述文字,工具名/参数/枚举保持英文
|
|
334
|
+
# 提示词分三段:状态 / 工具 / 约束。每段页 1 是内置英文、页 2 是内置中文(都不入盘),页 3 起是你写的。
|
|
335
|
+
promptStatePages: []
|
|
336
|
+
promptStateIndex: 0
|
|
337
|
+
promptToolsPages: []
|
|
338
|
+
promptToolsIndex: 0
|
|
339
|
+
promptConstraintsPages: []
|
|
340
|
+
promptConstraintsIndex: 0
|
|
341
|
+
promptToolsLang: "" # the language of the tool lines, zh or en; empty follows promptLanguage
|
|
342
|
+
promptToolsLang: "" # 工具段那句话的语言,zh 或 en;留空跟随 promptLanguage
|
|
343
|
+
disabledTools: [] # 关掉的工具不再注册(例如 [domain_search]),schema 一并从上下文消失
|
|
317
344
|
bingMarket: zh-CN # Bing 市场;留空 = 自动(不发送 mkt)
|
|
318
345
|
fetchProviderTakeover: true # false = 保留你显式 pin 的 fetchProvider: http
|
|
319
346
|
region: cn-zh # DuckDuckGo 区域(可选)
|
|
@@ -497,7 +524,7 @@ Search engine test:
|
|
|
497
524
|
|
|
498
525
|
#### 离线自检断言(tools/)
|
|
499
526
|
|
|
500
|
-
仓库自带 **
|
|
527
|
+
仓库自带 **35 个**零依赖断言脚本(合计 **649 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
|
|
501
528
|
|
|
502
529
|
| 脚本 | 覆盖 | 运行(项数) |
|
|
503
530
|
|---|---|---|
|
|
@@ -523,6 +550,7 @@ Search engine test:
|
|
|
523
550
|
| `assert-prompt-language.mjs` | 提示词语言(en/zh):语言回退、9 个工具双语文案、标识符不被翻译、占位符插值、切换时只重注册一次 | `node tools/assert-prompt-language.mjs`(7) |
|
|
524
551
|
| `assert-tool-schema-size.mjs` | 工具 schema 体积(#94):共享引擎 id 常量、`domain_search` 不内嵌逐引擎句子、三处合计 < 1.6k 字符 | `node tools/assert-tool-schema-size.mjs`(5) |
|
|
525
552
|
| `assert-config-seat.mjs` | 配置入口(#101):卡片同时挂在 `plugins.bundle.config`(key = 包名,渲染在包页)与 `plugins.row.config`(老入口),两者共用同一渲染器 | `node tools/assert-config-seat.mjs`(4) |
|
|
553
|
+
| `assert-prompt-injection.mjs` | 提示词分页(#102):两页内置在前、自定义页在后、当前页即注入、空页不注入、内置页分状态/工具/约束三块、内置随 describe 下发不再单独请求、工具开关落到每个注册点、第七段 UI | `node tools/assert-prompt-injection.mjs`(11) |
|
|
526
554
|
| `assert-rail-section.mjs` | 页内目录的机器可读当前段:卡片根 `data-dsh-fs-section` 与 `railActive` 绑定、六段 id 固定、滚动监听仍在更新 | `node tools/assert-rail-section.mjs`(4) |
|
|
527
555
|
| `assert-package-files.mjs` | 发布清单闸门(#97):`files` 展开后必须覆盖被引用的本地模块、入口点与 `cordis.patch.yml`,并确认 `prepack` 守卫生效 | `node tools/assert-package-files.mjs`(4) |
|
|
528
556
|
| `assert-key-rotation.mjs` | 多 key 轮换(#96):round-robin 与 peek、单 key 不推进、配额优先于 429 的分类、轮换候选集合、`multi` 模式内重试与预检不消耗 key | `node tools/assert-key-rotation.mjs`(7) |
|
|
@@ -584,7 +612,24 @@ This plugin provides multiple free search engines with automatic fallback, compl
|
|
|
584
612
|
- **Zero Cost** — Multiple free engines with no API key or registration required
|
|
585
613
|
- **Multi-Engine Support** — DuckDuckGo (HTML / Lite), Bing, AnySearch AI, SearXNG (meta-search with custom instances), Exa, Tavily, Keenable, Firecrawl, Parallel, Perplexity, SerpBase, Serply, DeepSeek Official, You.com, Baidu Qianfan, Kimi, Aliyun Bailian, Volcano Doubao, Zhihu web-wide/site search (`zhihu_global`/`zhihu_site`, via the Zhihu open-platform MCP), and the model-based OpenAI / Gemini / Claude searches
|
|
586
614
|
- **Web Settings UI** — Engine switching, API key configuration (keys masked as "configured" in the UI), and a Chinese/English toggle; the entry is the component-row config (`plugins.row.config`) on the sidebar Plugins page (DSH 0.1.7-rc.1+). Remote access (VPS, reverse proxy, custom domain) works too: the bridge reuses the host's own Host fence, so addresses declared with `--trusted-host` or `--public-url` are accepted (#84)
|
|
587
|
-
- **Right-hand section rail** — A floating list (Engines / Fallback / Language pools / Search behaviour / Fetch / Performance) sits in the page margin to the right of the card: it highlights the section you are in while scrolling and jumps smoothly on click. It is rendered in a portal and never narrows the card, so the body layout is unchanged; it hides itself when the margin is too tight.
|
|
615
|
+
- **Right-hand section rail** — A floating list (Engines / Fallback / Language pools / Search behaviour / Fetch / Performance / Prompts) sits in the page margin to the right of the card: it highlights the section you are in while scrolling and jumps smoothly on click. It is rendered in a portal and never narrows the card, so the body layout is unchanged; it hides itself when the margin is too tight. Every entry is a real link (`#/panel/plugins/dsh-free-search/<section>`), so it can be copied or opened in a tab - see the section-link contract below.
|
|
616
|
+
|
|
617
|
+
### The prompt has three segments
|
|
618
|
+
|
|
619
|
+
The seventh section is split into state, tools and constraints. Each has its own pager: page 1 is the built-in English page and page 2 the built-in Chinese one, both generated from the current config, never stored, and neither deletable nor editable; page 3 onwards is yours. What gets sent is the current page of each segment, joined; when all three are empty nothing is injected.
|
|
620
|
+
|
|
621
|
+
The tools segment is one row per tool: the checkbox decides whether the tool is handed to the model, and the box next to it shows the line written for that tool. Those lines are read only and follow plugin updates, and The controls at the top right are a Chinese/English switch that flips every tool at once, plus All and None to check or clear the whole list. An unchecked tool is not handed to the model, its tool description leaves the request too, and the segment stops listing it. Put your own requirements on a custom page of the constraints segment.
|
|
622
|
+
|
|
623
|
+
### Section-link contract (with dsh-url-router)
|
|
624
|
+
|
|
625
|
+
Rules live in `dsh-url-router/docs/panel-sections.md` (no fixed count; seven sections today: engines / fallback / pools / behavior / fetch / performance / prompt):
|
|
626
|
+
|
|
627
|
+
- the page root publishes **exactly one** `data-dsh-panel-section="<id>"` = the section the reader is looking at (it follows scrolling; it never guesses "at the bottom = last section")
|
|
628
|
+
- every section container carries `data-dsh-section="<id>"` (the scroll target)
|
|
629
|
+
- every rail entry is `<a data-dsh-section="<id>" href="#/panel/plugins/dsh-free-search/<id>">`
|
|
630
|
+
- this plugin **never writes the URL**: `location.hash` / `history.pushState` / `history.replaceState` are untouched because dsh-url-router owns the address bar; when a section link appears there, a `hashchange` listener scrolls that section into view
|
|
631
|
+
|
|
632
|
+
Adding a section takes three steps: put `data-dsh-section="<new id>"` on the container, add one `NAV_ITEMS` entry (the rail anchor is generated from `item.id`), and add the id to `assert-rail-section`.
|
|
588
633
|
- **Multi-key rotation** — Any key field (or its env var) accepts several keys separated by commas, semicolons or newlines. Keys are used round-robin per request (so a single key never absorbs every call), and on 401/402/429 (bad key, quota exhausted, rate limited) the same engine retries with the next key before the engine-level fallback runs. This also applies inside `multi` mode (#96).
|
|
589
634
|
- **Popup Switch Command** — Type `/free-search-engine` in the chat: a picker opens with all engines; click one to switch (equivalent to the settings page + save)
|
|
590
635
|
- **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)
|
|
@@ -868,6 +913,16 @@ lang: zh # search language pools / localization (zh / en / ru
|
|
|
868
913
|
# web_fetch (fs-quality-fetch) sends the same Accept-Language instead of a fixed Chinese one (#92).
|
|
869
914
|
uiLang: zh # settings UI language (zh / en); empty = follow lang
|
|
870
915
|
promptLanguage: en # language of the system prompt section and tool descriptions (en / zh); prose only - tool names, params and enums stay English
|
|
916
|
+
# The prompt has three segments: state, tools, constraints. In each one page 1 is the
|
|
917
|
+
# built-in English page and page 2 the built-in Chinese one (neither is stored);
|
|
918
|
+
# page 3 onwards is yours.
|
|
919
|
+
promptStatePages: []
|
|
920
|
+
promptStateIndex: 0
|
|
921
|
+
promptToolsPages: []
|
|
922
|
+
promptToolsIndex: 0
|
|
923
|
+
promptConstraintsPages: []
|
|
924
|
+
promptConstraintsIndex: 0
|
|
925
|
+
disabledTools: [] # tools that are not registered at all (e.g. [domain_search]); their schemas leave the context too
|
|
871
926
|
bingMarket: zh-CN # Bing market; empty = automatic (no mkt sent)
|
|
872
927
|
fetchProviderTakeover: true # false = keep the fetchProvider: http you pinned yourself
|
|
873
928
|
region: cn-zh # DuckDuckGo region (optional)
|
|
@@ -1051,7 +1106,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1051
1106
|
|
|
1052
1107
|
#### Offline self-check assertions (`tools/`)
|
|
1053
1108
|
|
|
1054
|
-
**Thirty-
|
|
1109
|
+
**Thirty-five** zero-dependency assertion scripts ship with the repo (**649 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
|
|
1055
1110
|
|
|
1056
1111
|
| Script | Covers | Run (count) |
|
|
1057
1112
|
|---|---|---|
|
|
@@ -1077,6 +1132,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1077
1132
|
| `assert-prompt-language.mjs` | Prompt language (en/zh): fallback rules, bilingual copy for all 9 tools, identifiers left untranslated, placeholder interpolation, and one re-registration per language change | `node tools/assert-prompt-language.mjs` (7) |
|
|
1078
1133
|
| `assert-tool-schema-size.mjs` | Tool schema budget (#94): one shared engine-id constant, no per-engine sentences in `domain_search`, the three schemas under 1.6k chars combined | `node tools/assert-tool-schema-size.mjs` (5) |
|
|
1079
1134
|
| `assert-config-seat.mjs` | Config entry point (#101): the card is registered on `plugins.bundle.config` (keyed by the package name, rendered on the bundle page) and on `plugins.row.config` (older entry), both sharing one renderer | `node tools/assert-config-seat.mjs` (4) |
|
|
1135
|
+
| `assert-prompt-injection.mjs` | Paged prompt (#102): two built-in pages first, user pages after, the current page is what gets injected, an empty page injects nothing, the generated page split into State/Tools/Constraints blocks, built-ins delivered with describe instead of a second request, tool switches wired into every registrar, and the seventh section UI | `node tools/assert-prompt-injection.mjs` (11) |
|
|
1080
1136
|
| `assert-rail-section.mjs` | Machine-readable active section for the in-page rail: the card root's `data-dsh-fs-section` tracks `railActive`, the six section ids are fixed, and the scroll spy still updates it | `node tools/assert-rail-section.mjs` (4) |
|
|
1081
1137
|
| `assert-package-files.mjs` | Packaging gate (#97): after expanding `files`, every imported local module, the entry points and `cordis.patch.yml` must be published, and the `prepack` guard must be wired | `node tools/assert-package-files.mjs` (4) |
|
|
1082
1138
|
| `assert-key-rotation.mjs` | Multi-key rotation (#96): round-robin and peek, single keys never advancing, quota classification ahead of 429, the rotation-candidate set, and in-engine retries that keep multi-mode preflight from consuming keys | `node tools/assert-key-rotation.mjs` (7) |
|