dsh-free-search 0.9.25 → 0.9.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,7 +37,7 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
37
37
 
38
38
  设置页第七段「提示词」分成三段:状态、工具、约束。每段都有自己的翻页器,页 1 是内置英文、页 2 是内置中文,都按当前配置实时生成,不入盘,不能删也不能改;页 3 起是你自己加的页。发送时每段取你当前停的那一页,拼起来就是注入内容;三段都空则整段不注入。
39
39
 
40
- 「工具」那一段是九个工具各一行:前面的勾选框决定这个工具给不给模型,后面的框里是写给模型的那句话,只读,跟插件更新走,不能改。这一段的右上角有中英切换,一下切换全部工具,还有「全选」和「全不选」两个按钮。取消勾选的工具不再交给模型,工具说明也一并从请求里去掉,那一段里也不会再列出它。想加自己的要求,写在「约束」那一段的自定义页里。
40
+ 「工具」那一段是九个工具各一行:前面的勾选框决定这个工具给不给模型,后面的框里是写给模型的那句话,只读,跟插件更新走,不能改。这一段的右上角有中英切换,一下切换全部工具;工具列表最上面是一个「全选」勾选框,勾上就是全部交给模型,取消就是全部不交,只勾一部分时它显示为半选。取消勾选的工具不再交给模型,工具说明也一并从请求里去掉,那一段里也不会再列出它。想加自己的要求,写在「约束」那一段的自定义页里。
41
41
 
42
42
  ### 分区链接契约(与 dsh-url-router 对接)
43
43
 
@@ -524,7 +524,7 @@ Search engine test:
524
524
 
525
525
  #### 离线自检断言(tools/)
526
526
 
527
- 仓库自带 **35 个**零依赖断言脚本(合计 **649 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
527
+ 仓库自带 **35 个**零依赖断言脚本(合计 **653 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
528
528
 
529
529
  | 脚本 | 覆盖 | 运行(项数) |
530
530
  |---|---|---|
@@ -550,7 +550,7 @@ Search engine test:
550
550
  | `assert-prompt-language.mjs` | 提示词语言(en/zh):语言回退、9 个工具双语文案、标识符不被翻译、占位符插值、切换时只重注册一次 | `node tools/assert-prompt-language.mjs`(7) |
551
551
  | `assert-tool-schema-size.mjs` | 工具 schema 体积(#94):共享引擎 id 常量、`domain_search` 不内嵌逐引擎句子、三处合计 < 1.6k 字符 | `node tools/assert-tool-schema-size.mjs`(5) |
552
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) |
553
+ | `assert-prompt-injection.mjs` | 提示词分页(#102):两页内置在前、自定义页在后、当前页即注入、空页不注入、内置页分状态/工具/约束三块、内置随 describe 下发不再单独请求、工具开关落到每个注册点、第七段 UI | `node tools/assert-prompt-injection.mjs`(15) |
554
554
  | `assert-rail-section.mjs` | 页内目录的机器可读当前段:卡片根 `data-dsh-fs-section` 与 `railActive` 绑定、六段 id 固定、滚动监听仍在更新 | `node tools/assert-rail-section.mjs`(4) |
555
555
  | `assert-package-files.mjs` | 发布清单闸门(#97):`files` 展开后必须覆盖被引用的本地模块、入口点与 `cordis.patch.yml`,并确认 `prepack` 守卫生效 | `node tools/assert-package-files.mjs`(4) |
556
556
  | `assert-key-rotation.mjs` | 多 key 轮换(#96):round-robin 与 peek、单 key 不推进、配额优先于 429 的分类、轮换候选集合、`multi` 模式内重试与预检不消耗 key | `node tools/assert-key-rotation.mjs`(7) |
@@ -618,7 +618,7 @@ This plugin provides multiple free search engines with automatic fallback, compl
618
618
 
619
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
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.
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 top right has a Chinese/English switch that flips every tool at once, and the list starts with a Select all checkbox: check it to hand every tool to the model, clear it to hand none, and it shows the half state when only some are checked. 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
622
 
623
623
  ### Section-link contract (with dsh-url-router)
624
624
 
@@ -1106,7 +1106,7 @@ Restart `dsh web` after switching to apply changes.
1106
1106
 
1107
1107
  #### Offline self-check assertions (`tools/`)
1108
1108
 
1109
- **Thirty-five** zero-dependency assertion scripts ship with the repo (**649 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1109
+ **Thirty-five** zero-dependency assertion scripts ship with the repo (**653 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1110
1110
 
1111
1111
  | Script | Covers | Run (count) |
1112
1112
  |---|---|---|
@@ -1132,7 +1132,7 @@ Restart `dsh web` after switching to apply changes.
1132
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) |
1133
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) |
1134
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) |
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` (15) |
1136
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) |
1137
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) |
1138
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) |
package/lib/client.js CHANGED
@@ -402,7 +402,6 @@ window.__ModuleLoader__.load({
402
402
  segTools: "工具",
403
403
  segConstraints: "约束",
404
404
  toolSelectAll: "全选",
405
- toolSelectNone: "全不选",
406
405
  promptHint: "第 1 页和第 2 页无法编辑和删除,其余页可自由编辑。",
407
406
  promptPlaceholder: "想固定发什么就加一页",
408
407
 
@@ -531,8 +530,7 @@ window.__ModuleLoader__.load({
531
530
  segState: "State",
532
531
  segTools: "Tools",
533
532
  segConstraints: "Constraints",
534
- toolSelectAll: "All",
535
- toolSelectNone: "None",
533
+ toolSelectAll: "Select all",
536
534
  promptHint: "Pages 1 and 2 cannot be edited or deleted; the rest are yours to edit.",
537
535
  promptPlaceholder: "Add a page for anything you always want to send",
538
536
 
@@ -564,7 +562,7 @@ window.__ModuleLoader__.load({
564
562
  "cache_search",
565
563
  "domain_search",
566
564
  ];
567
- const PLUGIN_VERSION = "0.9.25";
565
+ const PLUGIN_VERSION = "0.9.27";
568
566
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
569
567
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
570
568
  const NAV_ITEMS = [
@@ -1338,25 +1336,32 @@ window.__ModuleLoader__.load({
1338
1336
  children: [
1339
1337
  react_jsx_runtime.jsx("button", { type: "button", className: "dshfs-pagerBtn" + (toolsLang === "zh" ? " is-active" : ""), disabled: !ready || saving, onClick: () => { setPromptToolsLang("zh"); setDirty(true); setFailed(false); setSaveError(""); }, children: "中" }, "zh"),
1340
1338
  react_jsx_runtime.jsx("button", { type: "button", className: "dshfs-pagerBtn" + (toolsLang === "en" ? " is-active" : ""), disabled: !ready || saving, onClick: () => { setPromptToolsLang("en"); setDirty(true); setFailed(false); setSaveError(""); }, children: "EN" }, "en"),
1341
- react_jsx_runtime.jsx("button", { type: "button", className: "dshfs-pagerBtn", disabled: !ready || saving || disabledTools.length === 0, onClick: () => { setDisabledTools([]); setDirty(true); setFailed(false); setSaveError(""); }, children: t.toolSelectAll }, "all"),
1342
- react_jsx_runtime.jsx("button", { type: "button", className: "dshfs-pagerBtn", disabled: !ready || saving || disabledTools.length === TOOL_TOGGLES.length, onClick: () => { setDisabledTools(TOOL_TOGGLES.slice()); setDirty(true); setFailed(false); setSaveError(""); }, children: t.toolSelectNone }, "none"),
1343
1339
  ],
1344
1340
  }),
1345
1341
  ],
1346
1342
  }),
1343
+ react_jsx_runtime.jsx("label", {
1344
+ className: "dshfs-platform dshfs-selectAll",
1345
+ children: [
1346
+ react_jsx_runtime.jsx("input", {
1347
+ type: "checkbox",
1348
+ checked: disabledTools.length === 0,
1349
+ disabled: !ready || saving,
1350
+ ref: (node) => { if (node) node.indeterminate = disabledTools.length > 0 && disabledTools.length < TOOL_TOGGLES.length; },
1351
+ onChange: () => {
1352
+ setDisabledTools(disabledTools.length === 0 ? TOOL_TOGGLES.slice() : []);
1353
+ setDirty(true);
1354
+ setFailed(false);
1355
+ setSaveError("");
1356
+ },
1357
+ }),
1358
+ t.toolSelectAll,
1359
+ ],
1360
+ }),
1347
1361
  ...TOOL_TOGGLES.map(renderToolRow),
1348
1362
  ],
1349
1363
  });
1350
1364
  const renderPromptSegment = (segment) => {
1351
- if (segment.key === "tools") {
1352
- return react_jsx_runtime.jsx("div", {
1353
- className: "dshfs-segment",
1354
- children: [
1355
- react_jsx_runtime.jsx("div", { className: "dshfs-label", children: segment.title }),
1356
- ...TOOL_TOGGLES.map(renderToolRow),
1357
- ],
1358
- }, segment.key);
1359
- }
1360
1365
  const total = 2 + segment.pages.length;
1361
1366
  const kind = segment.index === 0 ? "builtin-en" : segment.index === 1 ? "builtin-zh" : "user";
1362
1367
  const textAt = (index) => {
package/lib/index.js CHANGED
@@ -3594,6 +3594,19 @@ function makeBridgeRoutes(settings, search, testEngine, getCredentials) {
3594
3594
  // 九个工具的固定顺序,提示词与设置页都用它。
3595
3595
  export const TOOL_IDS = ["free_search_test", "platform_search", "video_search", "weather", "advanced_search", "multi_search", "research", "cache_search", "domain_search"];
3596
3596
 
3597
+ // #102:三段拼起来就是注入给模型的提示词。空字符串表示整段不注入。
3598
+ export function composeInjectedPrompt(cfg) {
3599
+ const blocks = buildBuiltinPromptBlocks(cfg);
3600
+ const toolsLang = promptLanguageOf({ promptLanguage: cfg.promptToolsLang || cfg.promptLanguage });
3601
+ return [
3602
+ effectivePromptText({ builtins: blocks.state, pages: cfg.promptStatePages, index: cfg.promptStateIndex }),
3603
+ blocks.tools[toolsLang],
3604
+ effectivePromptText({ builtins: blocks.constraints, pages: cfg.promptConstraintsPages, index: cfg.promptConstraintsIndex }),
3605
+ ]
3606
+ .filter(Boolean)
3607
+ .join("\n\n");
3608
+ }
3609
+
3597
3610
  // #102:三段内置内容,按当前配置插值。都不入盘,跟插件更新走。
3598
3611
  function buildBlocksForLang(cfg, lang) {
3599
3612
  const copy = systemCopy(lang);
@@ -5764,16 +5777,14 @@ function apply(ctx, config) {
5764
5777
  refreshPrompt = () => {
5765
5778
  if (disposeSection) { disposeSection(); disposeSection = null; }
5766
5779
  const cfg = current();
5767
- // #102:状态与约束各取当前页;工具段只有语言开关,勾选决定列哪几个。
5768
- const blocks = buildBuiltinPromptBlocks(cfg);
5769
- const toolsLang = promptLanguageOf({ promptLanguage: cfg.promptToolsLang || cfg.promptLanguage });
5770
- const injected = [
5771
- effectivePromptText({ builtins: blocks.state, pages: cfg.promptStatePages, index: cfg.promptStateIndex }),
5772
- blocks[toolsLang].tools,
5773
- effectivePromptText({ builtins: blocks.constraints, pages: cfg.promptConstraintsPages, index: cfg.promptConstraintsIndex }),
5774
- ]
5775
- .filter(Boolean)
5776
- .join("\n\n");
5780
+ // #102:三段拼起来就是注入内容;拼装出错要报出来,不能静默少一段。
5781
+ let injected = "";
5782
+ try {
5783
+ injected = composeInjectedPrompt(cfg);
5784
+ } catch (error) {
5785
+ logger.warn(`free-search: could not build the prompt section (${error instanceof Error ? error.message : String(error)})`);
5786
+ return;
5787
+ }
5777
5788
  if (!injected) return;
5778
5789
  disposeSection = sctx.systemPrompt.section({ name: "free-search:engines", order: 500, text: injected });
5779
5790
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.25",
3
+ "version": "0.9.27",
4
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",