dsh-union-search 0.11.5 → 0.11.6
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 +2 -2
- package/bin/restore.js +109 -0
- package/lib/index.js +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -172,7 +172,7 @@ Error: configured web provider "ddg" is not registered
|
|
|
172
172
|
|
|
173
173
|
现在没有这层覆盖:插件被停用时 `web.searchProvider` 保持官方默认(`deepseek-official`),搜索至少还能走官方通道;插件启用时由上面的运行时接管切到 `ddg`。
|
|
174
174
|
|
|
175
|
-
> **0.2.1-rc.2 机制变化**:宿主删掉了可写的运行时选择字段,改为每次调用读 `web` 条配置的 volatile 值(未配置且多个可用 provider 时报 `WEB_PROVIDER_AMBIGUOUS`)。本插件能力探测分流:≤rc.1 仍走内存接管(非持久);rc.2+ 经 settings 服务把 `web.searchProvider: ddg` 钉进条配置(**持久**)——若后续停用本插件,记得删掉该字段(或拨回官方开关),否则宿主会响亮报 `CONFIGURED_MISSING
|
|
175
|
+
> **0.2.1-rc.2 机制变化**:宿主删掉了可写的运行时选择字段,改为每次调用读 `web` 条配置的 volatile 值(未配置且多个可用 provider 时报 `WEB_PROVIDER_AMBIGUOUS`)。本插件能力探测分流:≤rc.1 仍走内存接管(非持久);rc.2+ 经 settings 服务把 `web.searchProvider: ddg` 钉进条配置(**持久**)——若后续停用本插件,记得删掉该字段(或拨回官方开关),否则宿主会响亮报 `CONFIGURED_MISSING`;不想手动改可以直接跑随包的清理器:`node node_modules/dsh-union-search/bin/restore.js --apply`(0.11.6+,扫描各 profile 的 `cordis.patch.yml` 只删本插件钉选的那行,默认 dry-run);`blockSystemSearch` 开启时同步把 `fetchProvider` 钉回 `http`(web_fetch 保留,钳离按次计费的 `deepseek-fetch-api`;你若显式指定了第三方 fetch provider,则不动它)。
|
|
176
176
|
|
|
177
177
|
> **0.2.2-rc.5 机制变化(重要,失败形态变了)**:宿主把 `- id: web` 里写死的 `searchProvider: deepseek-search-api` **删掉了**,只留 `fetchProvider: http`,改成"未配置就按模型请求的路由自选"——`deepseek-official` / `deepseek-account` 两条路由选 `deepseek-official`(服务端 Messages 搜索,不按次计费),其余路由和无模型请求选 `deepseek-search-api`。
|
|
178
178
|
> 对本插件的三个后果:①接管判据不受影响(未设置 → 仍是本插件的接管分支,`ddg` 两种出厂 id 仍在白名单内);②**钉选变得更要紧**——一旦 `settings.mutate` 没落地(settings 服务尚未挂载时本插件会延迟重试),`web_search` 不再报 `WEB_PROVIDER_AMBIGUOUS`,而是**静默**走官方通道,看起来像"插件没生效"却没有任何错误;③设置页的搜索 provider 菜单多出一个「自动」项(`AUTO_ID` 空串),选中它会 `resetField` 清掉 `searchProvider` 覆盖,于是本插件的钉选被解除、搜索回到官方通道——这不是 bug,是官方新语义,但要知道点了什么。
|
|
@@ -572,7 +572,7 @@ Error: configured web provider "ddg" is not registered
|
|
|
572
572
|
|
|
573
573
|
Without that override, a disabled plugin leaves `web.searchProvider` at the shipped default (`deepseek-official`) so search still works through the official provider; when the plugin is enabled the runtime takeover above points it at `ddg`.
|
|
574
574
|
|
|
575
|
-
> **0.2.1-rc.2 mechanism change**: the host removed the writable runtime selection field and now reads the volatile `web` entry config on every call (unset + multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`). This plugin probes the capability: ≤rc.1 keeps the in-memory takeover (non-persistent); on rc.2+ it pins `web.searchProvider: ddg` into the entry config through the settings service (**persistent**) — if you later disable this plugin, remove that field (or flip the official switch back), otherwise the host fails loudly with `CONFIGURED_MISSING
|
|
575
|
+
> **0.2.1-rc.2 mechanism change**: the host removed the writable runtime selection field and now reads the volatile `web` entry config on every call (unset + multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`). This plugin probes the capability: ≤rc.1 keeps the in-memory takeover (non-persistent); on rc.2+ it pins `web.searchProvider: ddg` into the entry config through the settings service (**persistent**) — if you later disable this plugin, remove that field (or flip the official switch back), otherwise the host fails loudly with `CONFIGURED_MISSING`; as a shortcut, run the bundled cleaner: `node node_modules/dsh-union-search/bin/restore.js --apply` (0.11.6+, scans each profile's `cordis.patch.yml` and removes only the line this plugin pinned; dry-run by default). With `blockSystemSearch` on, `fetchProvider` is also clamped to `http` (web_fetch is kept; the metered `deepseek-fetch-api` is not). If you explicitly picked a third-party fetch provider, it is left alone.
|
|
576
576
|
|
|
577
577
|
> **0.2.2-rc.5 mechanism change (important — the failure mode changed)**: the host **deleted** the hard-coded `searchProvider: deepseek-search-api` from `- id: web`, keeping only `fetchProvider: http`, and now selects per model-request route when nothing is configured — `deepseek-official` / `deepseek-account` routes get `deepseek-official` (server-side Messages search, not billed per search), every other route and requests outside a model turn get `deepseek-search-api`.
|
|
578
578
|
> Three consequences for this plugin: ① the takeover criterion is unaffected (unset → still this plugin's takeover branch, and both shipped ids stay in the whitelist); ② **the pin matters more than before** — if `settings.mutate` never lands (this plugin defers and retries when the settings service is not mounted yet), `web_search` no longer raises `WEB_PROVIDER_AMBIGUOUS`; it **silently** goes to the official provider, so it looks like "the plugin did nothing" with no error at all; ③ the search-provider menu on the settings page gained an "Automatic" entry (empty id), and picking it calls `resetField`, clearing the `searchProvider` override — i.e. it releases this plugin's pin and search returns to the official provider. That is official behaviour, not a bug, but be aware of what the click does.
|
package/bin/restore.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// 接管悬空引用清理器(0.11.6,上游 #159 / 767b5a4 概念移植)。
|
|
2
|
+
// 背景:本插件运行时把 web.searchProvider 钉成 "ddg"(settings.mutate 落 profile 条配置),
|
|
3
|
+
// 停用/卸载后该字段悬空,宿主报 CONFIGURED_MISSING 且 web_search 起不来。
|
|
4
|
+
// 用法(插件目录已不存在也能跑——从任意位置用 node 直接执行本文件):
|
|
5
|
+
// node restore.js # 默认 --dry,只报告将删什么
|
|
6
|
+
// node restore.js --apply # 落盘
|
|
7
|
+
// node restore.js --profiles-dir <d> # 指定 dsh 根(其下有 profiles/*/cordis.patch.yml)
|
|
8
|
+
// node restore.js --include-fetch --apply # 连 fetchProvider 行一并清(默认保留:指向宿主内建档)
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
12
|
+
const PINNED_SEARCH_ID = "ddg"; // 与 lib/index.js 的 provider.id 一致(index.js:4412 实证)
|
|
13
|
+
|
|
14
|
+
// 逐行状态机:定位 `- id: web` 条目 → 其 config 块内的 searchProvider/fetchProvider 行。
|
|
15
|
+
// 块边界按缩进判定:条目起于 `- ` 行,后续行缩进 > 条目缩进即属该条目;缩进回落即出块。
|
|
16
|
+
export function processPatchText(text, { includeFetch = false } = {}) {
|
|
17
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
18
|
+
const lines = text.split(/\r?\n/);
|
|
19
|
+
const out = [];
|
|
20
|
+
const removed = [];
|
|
21
|
+
let entryIndent = -1; // -1 = 不在 web 条目内
|
|
22
|
+
let inConfig = false;
|
|
23
|
+
let configIndent = -1;
|
|
24
|
+
for (const line of lines) {
|
|
25
|
+
const indent = line.match(/^\s*/)[0].length;
|
|
26
|
+
const isBlank = !line.trim();
|
|
27
|
+
if (entryIndent !== -1 && !isBlank && indent <= entryIndent) {
|
|
28
|
+
entryIndent = -1; // 出了 web 条目块(遇到同级或更浅的非空行)
|
|
29
|
+
inConfig = false;
|
|
30
|
+
}
|
|
31
|
+
if (entryIndent === -1 && /^\s*-\s+id:\s*web\s*$/.test(line)) {
|
|
32
|
+
entryIndent = indent;
|
|
33
|
+
out.push(line);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (entryIndent !== -1) {
|
|
37
|
+
if (!inConfig && /^\s*config:\s*$/.test(line)) {
|
|
38
|
+
inConfig = true;
|
|
39
|
+
configIndent = indent;
|
|
40
|
+
out.push(line);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (inConfig && indent > configIndent) {
|
|
44
|
+
if (new RegExp(`^\\s*searchProvider:\\s*['"]?${PINNED_SEARCH_ID}['"]?\\s*(#.*)?$`).test(line)) {
|
|
45
|
+
removed.push(`searchProvider: ${PINNED_SEARCH_ID}`);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (includeFetch && /^\s*fetchProvider:/.test(line)) {
|
|
49
|
+
removed.push(line.trim());
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
} else if (inConfig && indent <= configIndent && !isBlank) {
|
|
53
|
+
inConfig = false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
out.push(line);
|
|
57
|
+
}
|
|
58
|
+
return { text: out.join(eol), removed, inWebEntry: entryIndent !== -1 };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 找 profiles/*/cordis.patch.yml(含 patch.yaml 变体)
|
|
62
|
+
export function findPatchFiles(profilesDir) {
|
|
63
|
+
const hits = [];
|
|
64
|
+
let names = [];
|
|
65
|
+
try {
|
|
66
|
+
names = fs.readdirSync(profilesDir);
|
|
67
|
+
} catch {
|
|
68
|
+
return hits;
|
|
69
|
+
}
|
|
70
|
+
for (const name of names) {
|
|
71
|
+
for (const fname of ["cordis.patch.yml", "cordis.patch.yaml"]) {
|
|
72
|
+
const p = path.join(profilesDir, name, fname);
|
|
73
|
+
if (fs.existsSync(p)) hits.push(p);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return hits;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function main(argv) {
|
|
80
|
+
const apply = argv.includes("--apply");
|
|
81
|
+
const includeFetch = argv.includes("--include-fetch");
|
|
82
|
+
const di = argv.indexOf("--profiles-dir");
|
|
83
|
+
const profilesDir = di !== -1 && argv[di + 1] ? argv[di + 1] : path.join(process.cwd(), "profiles");
|
|
84
|
+
const files = findPatchFiles(profilesDir);
|
|
85
|
+
if (files.length === 0) {
|
|
86
|
+
console.log(`未发现任何 cordis.patch.yml(目录:${profilesDir})——无需清理。`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let total = 0;
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
const before = fs.readFileSync(file, "utf8");
|
|
92
|
+
const { text, removed } = processPatchText(before, { includeFetch });
|
|
93
|
+
if (removed.length === 0) {
|
|
94
|
+
console.log(`- ${file}: 干净`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
total += removed.length;
|
|
98
|
+
console.log(`- ${file}:`);
|
|
99
|
+
for (const r of removed) console.log(` 将删除 ${r}`);
|
|
100
|
+
if (apply) fs.writeFileSync(file, text);
|
|
101
|
+
}
|
|
102
|
+
console.log(total === 0 ? "没有发现本插件钉选造成的悬空字段。" :
|
|
103
|
+
(apply ? `已清理 ${total} 行(重启 dsh 生效)。` : `dry-run:共 ${total} 行待删;加 --apply 落盘。`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 仅直接运行时执行 main(被 import 时不跑)
|
|
107
|
+
if (process.argv[1] && import.meta.url === `file:///${process.argv[1].replace(/\\/g, "/")}`) {
|
|
108
|
+
main(process.argv.slice(2));
|
|
109
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -5097,7 +5097,7 @@ function apply(ctx, config) {
|
|
|
5097
5097
|
// config.searchProvider.get()(volatile);未配置且多个可用 provider → WEB_PROVIDER_AMBIGUOUS 抛错。
|
|
5098
5098
|
// 此时唯一钳制入口是 settings.mutate("web", …):会落入 profile 条配置(持久),
|
|
5099
5099
|
// 代价:停用本插件后 web.searchProvider: ddg 悬空,宿主会响亮报 CONFIGURED_MISSING
|
|
5100
|
-
//
|
|
5100
|
+
// 而非静默回官方;可直接跑 bin/restore.js --apply 清掉该字段(0.11.6+,只删本插件钉选行)。
|
|
5101
5101
|
// 接管判据(两代一致):
|
|
5102
5102
|
// - 未设置 searchProvider:接管(rc.5 起这是常态:出厂不再写 searchProvider);
|
|
5103
5103
|
// - 仍是出厂 id(deepseek-official / rc.2 起的 deepseek-search-api):接管;
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-union-search",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
4
|
"description": "Union web search for DeepSeek Harness (renamed from dsh-free-search): free keyless engines + many professional paid search APIs — 28 engines (Bing/DuckDuckGo/AnySearch/SearXNG multi-instance union/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Zhihu global/site via MCP and Perplexity/SerpBase/Serply/DeepSeek official/You.com/Baidu/Kimi/Aliyun/Doubao/Zhipu/Bocha/Metaso with key; OpenAI/Gemini/Claude/Grok model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + multi mode (parallel top-3 merge) + multi_search cross-source tool + failure-aware fallback + block system built-in search toggle + experimental free advance_fetch (no API key, no billing; host-twin GitHub-Flavored Markdown conversion + CSS selector/fields structured extraction) + time filtering + platform search + web_fetch, with web settings UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"dsh-union-search-restore": "bin/restore.js"
|
|
9
|
+
},
|
|
7
10
|
"scripts": {
|
|
8
|
-
"test": "node --test test/md.test.mjs test/egress.test.mjs test/relevance.test.mjs test/upgrade.test.mjs test/alpn.test.mjs test/credentials.test.mjs test/tool-face.test.mjs test/notes-channel.test.mjs"
|
|
11
|
+
"test": "node --test test/md.test.mjs test/egress.test.mjs test/relevance.test.mjs test/upgrade.test.mjs test/alpn.test.mjs test/restore.test.mjs test/credentials.test.mjs test/tool-face.test.mjs test/notes-channel.test.mjs"
|
|
9
12
|
},
|
|
10
13
|
"exports": {
|
|
11
14
|
".": "./lib/index.js",
|
|
@@ -17,6 +20,7 @@
|
|
|
17
20
|
"lib/index.js",
|
|
18
21
|
"lib/client.js",
|
|
19
22
|
"lib/mcp_adapter.js",
|
|
23
|
+
"bin/restore.js",
|
|
20
24
|
"cordis.patch.yml",
|
|
21
25
|
"README.md",
|
|
22
26
|
"locale"
|