dsh-free-search 0.9.31 → 0.9.32
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 +8 -3
- package/lib/client.js +171 -1
- package/lib/index.js +141 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
|
|
|
33
33
|
- **5 个 HTML 搜索页引擎(默认关闭)** —— 把传统搜索页并入同一套引擎 / 回退 / 冷却 / 设置体系:`baidu-html`(百度网页)、`so360`、`sogou`、`wechat`(微信文章)、`toutiao`。免 key、免额度,代价是抓页面:验证码/反爬按 `bot-wall` 归类并让整个家族冷却 10 分钟(整段出口 IP 都会被打标),结果也没有 API 摘要。它们默认不进 auto / 回退链 / 语言池,只在显式 `engine=` 或加入语言池时运行。
|
|
34
34
|
- **按 key 冷却与诊断** —— 429 与额度错误按 key 分别冷却,同一引擎的其他 key 不受牵连;冷却状态写入磁盘,重启后仍在;失败信息和日志里的 key 一律打码;设置页底部的「诊断」按钮列出每个引擎当前为什么不可用、冷却还剩多久
|
|
35
35
|
- **引擎白名单** —— 设置页「只使用勾选的引擎」开启后,只有勾选的引擎可用,升级新增的引擎默认不启用;配置里对应 `allowedEngines`(非空时等价于把其余引擎全部禁用)
|
|
36
|
+
- **自带更新** —— 卡片底部显示当前版本和「检查更新」;npm 安装的版本可一键升级到 latest,本地 link 开发模式改为跳转 npm 页面并提示 git pull
|
|
36
37
|
- **网页设置页** —— 引擎切换 + API key 配置(UI 中 key 脱敏显示"已配置")+ 中英文切换;入口在左侧「插件」页的组件行配置(`plugins.row.config`,DSH 0.1.7-rc.1+)。远程访问(VPS / 反向代理 / 自定义域名)下也能用:桥接接口沿用宿主的 Host 围栏,`--trusted-host` 与 `--public-url` 声明的地址会放行(#84)
|
|
37
38
|
- **右侧浮动目录** —— 卡片右侧的页面留白里浮出「引擎 / 回退 / 语言池 / 搜索行为 / 抓取 / 性能 / 提示词管理」七个快捷跳转,滚动自动高亮当前项、点击平滑跳转;不占用正文宽度(正文布局与 0.9.6 一致),右侧留白不足时自动隐藏;每项都是真链接(`#/panel/plugins/dsh-free-search/<分区>`),可复制、可开新标签,见下方「分区链接契约」
|
|
38
39
|
|
|
@@ -537,7 +538,7 @@ Search engine test:
|
|
|
537
538
|
|
|
538
539
|
#### 离线自检断言(tools/)
|
|
539
540
|
|
|
540
|
-
仓库自带 **
|
|
541
|
+
仓库自带 **43 个**零依赖断言脚本(合计 **753 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
|
|
541
542
|
|
|
542
543
|
| 脚本 | 覆盖 | 运行(项数) |
|
|
543
544
|
|---|---|---|
|
|
@@ -575,6 +576,8 @@ Search engine test:
|
|
|
575
576
|
| `assert-doctor.mjs` | 诊断报告:时长格式化、头部版本 / Node / DSH 主目录 / 生效默认 / 提示词字数、每个引擎的标记与原因、冷却原因去重列出、提示词未注入的提示 | `node tools/assert-doctor.mjs`(5) |
|
|
576
577
|
| `assert-agy.mjs` | Antigravity CLI:提示词查询 / 条数 / JSON 契约、structuredOutput 与 response 两种信封、非 SUCCESS 透出上游原因、URL 过滤与截断、CLI 参数、注入 runner 跳过 PATH 检查 | `node tools/assert-agy.mjs`(6) |
|
|
577
578
|
| `assert-allowed-engines.mjs` | 引擎白名单(#106):条目归一化、空名单保持原状、非空时禁用其余全部(含未来新增)、显式禁用优先、错拼不锁死搜索、白名单内引擎可入链(HTML 家族 / 按次计费)、auto 只路由白名单、内置提示词只列白名单且回退为 none、schema 默认空 | `node tools/assert-allowed-engines.mjs`(9) |
|
|
579
|
+
| `assert-updater.mjs` | 自带更新:版本比较、registry 探测(成功 / 非 200 / 网络失败返回 null)、安装模式识别(真实安装优先于 link)、客户端按钮与桥接、服务端两条路由与 pnpm 升级命令、卡片版本跟 package.json 一致 | `node tools/assert-updater.mjs`(9) |
|
|
580
|
+
| `assert-inject.mjs` | 旧版 Cordis 兼容(#107):静态 inject 声明 web / settings / tools / systemPrompt、可选服务只走 `ctx.get`、回调上下文的属性读取都在 inject 里、动态依赖列表没有未知服务 | `node tools/assert-inject.mjs`(4) |
|
|
578
581
|
| `assert-degoog.mjs` | degoog 自建实例(#85):`/api/search` URL 规范化、查询编码、`time`/`lang` 参数、注册表位置、无需凭据 | `node tools/assert-degoog.mjs`(7) |
|
|
579
582
|
| `assert-multikey.mjs` | 多 key 字段:单 key 不变、逗号/分号/换行分隔、空白项丢弃、空输入为空数组 | `node tools/assert-multikey.mjs`(3) |
|
|
580
583
|
| `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
|
|
@@ -662,7 +665,7 @@ Adding a section takes three steps: put `data-dsh-section="<new id>"` on the con
|
|
|
662
665
|
- **Time Filtering** — The `advanced_search` tool supports `timeRange`: fixed tiers, custom relative values, or an absolute date (details below)
|
|
663
666
|
- **System Prompt Injection** — The agent is aware of the currently active engine and which engines require API keys; it is also told that all search output is **untrusted external data** and must never be executed as instructions
|
|
664
667
|
- **Prompt-Injection Guard (untrusted-data boundary)** — Web-derived text from the plugin's own tools (`advanced_search` / `platform_search` / `free_search_test`) is wrapped in an explicit `<untrusted-web-content>` boundary (look-alike tags inside the text are stripped to prevent early closure); the core `web_search` / `web_fetch` tools carry DSH core's own notice (`External web content follows...`); every snippet is cleaned and capped at 300 characters
|
|
665
|
-
- **
|
|
668
|
+
- **Built-in updater** — the card footer shows the version and a Check update button; npm installs upgrade to latest in one click, while a local link install links to the npm page and points at git pull instead
|
|
666
669
|
- **Result Caching** — Identical queries (same engine / time-filter args) hit an LRU cache (50 entries) for up to 5 minutes, protecting free engines from rate-limiting and saving paid quota; the TTL is configurable from 0-5 minutes in the settings UI (0 disables caching)
|
|
667
670
|
- **Domain blocklist & safe search** — `blockedDomains` keeps matching domains out of every result; `safeSearch` (`off` / `moderate` / `strict`) adds a filter layer for Bing / DuckDuckGo
|
|
668
671
|
- **Visual Badges** — Free engines feature a green `FREE` badge, while paid engines show an orange `API KEY` badge in the settings UI
|
|
@@ -1139,7 +1142,7 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1139
1142
|
|
|
1140
1143
|
#### Offline self-check assertions (`tools/`)
|
|
1141
1144
|
|
|
1142
|
-
**Forty-
|
|
1145
|
+
**Forty-three** zero-dependency assertion scripts ship with the repo (**753 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
|
|
1143
1146
|
|
|
1144
1147
|
| Script | Covers | Run (count) |
|
|
1145
1148
|
|---|---|---|
|
|
@@ -1177,6 +1180,8 @@ Restart `dsh web` after switching to apply changes.
|
|
|
1177
1180
|
| `assert-doctor.mjs` | Doctor report: duration formatting, version / Node / DSH home / effective default / prompt size header, a mark and reason per engine, cooldown reasons listed once, a warning when the prompt is not injected | `node tools/assert-doctor.mjs` (5) |
|
|
1178
1181
|
| `assert-agy.mjs` | Antigravity CLI: query / cap / JSON contract in the prompt, structuredOutput and response envelopes, upstream reason on non-SUCCESS, URL filtering and truncation, CLI flags, injected runner skips the PATH check | `node tools/assert-agy.mjs` (6) |
|
|
1179
1182
|
| `assert-allowed-engines.mjs` | Engine whitelist (#106): entries normalised, an empty list changes nothing, a non-empty list disables everything else (including future engines), explicit disables win, a typo does not brick search, whitelisted engines join the chain (HTML family / billed), Auto only routes allowed engines, the built-in prompt lists only them with a none fallback, and the schema defaults to empty | `node tools/assert-allowed-engines.mjs` (9) |
|
|
1183
|
+
| `assert-updater.mjs` | Built-in updater: version comparison, registry probe (success / non-200 / network failure yields null), install-mode detection (a real install beats a link), the client button and bridge helper, both server routes with the pnpm upgrade command, and the card version matching package.json | `node tools/assert-updater.mjs` (9) |
|
|
1184
|
+
| `assert-inject.mjs` | Older Cordis compatibility (#107): the static inject list declares web / settings / tools / systemPrompt, optional services are read through `ctx.get`, every property read on a callback context is declared, and dynamic dependency lists contain no unknown services | `node tools/assert-inject.mjs` (4) |
|
|
1180
1185
|
| `assert-degoog.mjs` | degoog self-hosted instance (#85): `/api/search` URL normalisation, query encoding, `time`/`lang` parameters, registry placement, no credentials needed | `node tools/assert-degoog.mjs` (7) |
|
|
1181
1186
|
| `assert-multikey.mjs` | multi-key fields: a single key is unchanged, comma/semicolon/newline separate keys, blank entries are dropped, empty input yields none | `node tools/assert-multikey.mjs` (3) |
|
|
1182
1187
|
| `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) |
|
package/lib/client.js
CHANGED
|
@@ -272,6 +272,17 @@ window.__ModuleLoader__.load({
|
|
|
272
272
|
".dshfs-update{color:#cc7a00;flex:none;font-size:12px;white-space:nowrap;border:1px solid rgba(255,149,0,.3);background:rgba(255,149,0,.12);border-radius:999px;padding:2px 8px}",
|
|
273
273
|
"@media (prefers-color-scheme: dark){.dshfs-update{color:#ff9f0a}}",
|
|
274
274
|
".dshfs-updateLine{display:flex;align-items:center;gap:10px;flex-wrap:wrap}",
|
|
275
|
+
".dshfs-upgrade{border:1px solid rgba(52,199,89,.4);background:rgba(52,199,89,.15);color:#248a3d}",
|
|
276
|
+
"@media (prefers-color-scheme: dark){.dshfs-upgrade{color:#30d158}}",
|
|
277
|
+
".dshfs-upgrade:hover:not(:disabled){background:rgba(52,199,89,.25)}",
|
|
278
|
+
".dshfs-updateOk{color:#248a3d;flex:none;font-size:12px;white-space:nowrap;border:1px solid rgba(52,199,89,.3);background:rgba(52,199,89,.12);border-radius:999px;padding:2px 8px}",
|
|
279
|
+
"@media (prefers-color-scheme: dark){.dshfs-updateOk{color:#30d158}}",
|
|
280
|
+
".dshfs-updatePill{display:inline-flex;align-items:center;gap:6px;border:1px solid rgba(0,113,227,.2);background:rgba(0,113,227,.1);color:#0071e3;font:inherit;font-size:13px;font-weight:500;line-height:1;cursor:pointer;padding:6px 12px;border-radius:999px;text-decoration:none;white-space:nowrap;transition:all 180ms cubic-bezier(.4,0,.2,1)}",
|
|
281
|
+
"@media (prefers-color-scheme: dark){.dshfs-updatePill{color:#0a84ff;background:rgba(10,132,255,.15);border-color:rgba(10,132,255,.25)}}",
|
|
282
|
+
".dshfs-updatePill:hover:not(:disabled){background:rgba(0,113,227,.15);border-color:rgba(0,113,227,.3)}",
|
|
283
|
+
"@media (prefers-color-scheme: dark){.dshfs-updatePill:hover:not(:disabled){background:rgba(10,132,255,.2);border-color:rgba(10,132,255,.4)}}",
|
|
284
|
+
".dshfs-updatePill:disabled{opacity:.5;cursor:default}",
|
|
285
|
+
".dshfs-updateIcon{flex:none;display:block}",
|
|
275
286
|
".dshfs-version{color:#6e6e73;font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}",
|
|
276
287
|
"@media (prefers-color-scheme: dark){.dshfs-version{color:#a1a1a6}}"
|
|
277
288
|
].join("");
|
|
@@ -385,6 +396,18 @@ window.__ModuleLoader__.load({
|
|
|
385
396
|
testOk: (r) => `✓ ${r.count} 条结果(引擎: ${r.engine})${r.content ? ` — ${r.content}` : ""}${r.sample ? ` · 例如 "${r.sample.slice(0, 40)}"` : ""}`,
|
|
386
397
|
testFail: (e) => `✗ ${e}`,
|
|
387
398
|
toggleLang: "EN",
|
|
399
|
+
checkUpdate: "检查更新",
|
|
400
|
+
checkingUpdate: "检查中…",
|
|
401
|
+
updateAvailable: (c, l) => `发现新版本 v${l}(当前 v${c})`,
|
|
402
|
+
updateLatest: (c) => `已是最新版本 v${c}`,
|
|
403
|
+
updateCheckFailed: "检查更新失败(无法访问 npm registry)",
|
|
404
|
+
updateView: "查看 →",
|
|
405
|
+
hasUpdate: "有更新",
|
|
406
|
+
upgrade: "升级",
|
|
407
|
+
upgrading: "升级中…",
|
|
408
|
+
upgradeLinkMode: "(本地开发模式,升级请用 git pull)",
|
|
409
|
+
upgradeDone: (l) => `升级到 v${l} 完成,重启 dsh 后生效`,
|
|
410
|
+
upgradeFailed: (m) => `升级失败:${m}`,
|
|
388
411
|
safeSearchLabel: "安全搜索过滤 (adlt)",
|
|
389
412
|
safeSearchOff: "关闭 —— 引擎默认(不加参数)",
|
|
390
413
|
safeSearchModerate: "中等 —— Bing 默认",
|
|
@@ -521,6 +544,18 @@ window.__ModuleLoader__.load({
|
|
|
521
544
|
testOk: (r) => `✓ ${r.count} results (engine: ${r.engine})${r.content ? ` — ${r.content}` : ""}${r.sample ? ` · e.g. "${r.sample.slice(0, 40)}"` : ""}`,
|
|
522
545
|
testFail: (e) => `✗ ${e}`,
|
|
523
546
|
toggleLang: "中文",
|
|
547
|
+
checkUpdate: "Check update",
|
|
548
|
+
checkingUpdate: "Checking…",
|
|
549
|
+
updateAvailable: (c, l) => `New version v${l} available (current v${c})`,
|
|
550
|
+
updateLatest: (c) => `You're on the latest version v${c}`,
|
|
551
|
+
updateCheckFailed: "Update check failed (cannot reach npm registry)",
|
|
552
|
+
updateView: "View →",
|
|
553
|
+
hasUpdate: "Update available",
|
|
554
|
+
upgrade: "Upgrade",
|
|
555
|
+
upgrading: "Upgrading…",
|
|
556
|
+
upgradeLinkMode: "(local dev install - use git pull to update)",
|
|
557
|
+
upgradeDone: (l) => `Upgraded to v${l} - restart dsh to apply`,
|
|
558
|
+
upgradeFailed: (m) => `Upgrade failed: ${m}`,
|
|
524
559
|
safeSearchLabel: "Safe search filter (adlt)",
|
|
525
560
|
safeSearchOff: "Off - engine default (no filtering)",
|
|
526
561
|
safeSearchModerate: "Moderate - Bing default",
|
|
@@ -578,7 +613,7 @@ window.__ModuleLoader__.load({
|
|
|
578
613
|
"cache_search",
|
|
579
614
|
"domain_search",
|
|
580
615
|
];
|
|
581
|
-
const PLUGIN_VERSION = "0.9.
|
|
616
|
+
const PLUGIN_VERSION = "0.9.32";
|
|
582
617
|
const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
|
|
583
618
|
// 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
|
|
584
619
|
const NAV_ITEMS = [
|
|
@@ -709,6 +744,15 @@ window.__ModuleLoader__.load({
|
|
|
709
744
|
return { domains, stats };
|
|
710
745
|
};
|
|
711
746
|
|
|
747
|
+
async function bridgeCheckUpdate() {
|
|
748
|
+
const response = await fetch(`${BRIDGE_PREFIX}/check-update`, {
|
|
749
|
+
method: "POST",
|
|
750
|
+
headers: { "content-type": "application/json" },
|
|
751
|
+
body: "{}",
|
|
752
|
+
});
|
|
753
|
+
return response.json();
|
|
754
|
+
}
|
|
755
|
+
|
|
712
756
|
// 诊断文本由服务端拼好,客户端只负责显示。
|
|
713
757
|
async function bridgeDoctor() {
|
|
714
758
|
const response = await fetch(`${BRIDGE_PREFIX}/doctor`, {
|
|
@@ -897,6 +941,9 @@ window.__ModuleLoader__.load({
|
|
|
897
941
|
const [saveError, setSaveError] = react.useState("");
|
|
898
942
|
const [testing, setTesting] = react.useState(false);
|
|
899
943
|
const [testResult, setTestResult] = react.useState(null);
|
|
944
|
+
const [checkingUpdate, setCheckingUpdate] = react.useState(false);
|
|
945
|
+
const [upgrading, setUpgrading] = react.useState(false);
|
|
946
|
+
const [updateInfo, setUpdateInfo] = react.useState(null);
|
|
900
947
|
const [doctorText, setDoctorText] = react.useState("");
|
|
901
948
|
const [doctorRunning, setDoctorRunning] = react.useState(false);
|
|
902
949
|
// 回退优先级/池列表行内 key 输入:引擎 id → [当前值, setter](zhihu 两引擎共享 ZHIHU_API_KEY)
|
|
@@ -1195,6 +1242,49 @@ window.__ModuleLoader__.load({
|
|
|
1195
1242
|
setSaveError("");
|
|
1196
1243
|
};
|
|
1197
1244
|
|
|
1245
|
+
const runCheckUpdate = async () => {
|
|
1246
|
+
setCheckingUpdate(true);
|
|
1247
|
+
setUpdateInfo(null);
|
|
1248
|
+
setFailed(false);
|
|
1249
|
+
setSaveError("");
|
|
1250
|
+
try {
|
|
1251
|
+
const result = await bridgeCheckUpdate();
|
|
1252
|
+
if (result.ok && result.value && typeof result.value.current === "string" && typeof result.value.latest === "string") {
|
|
1253
|
+
setUpdateInfo({ ok: true, ...result.value });
|
|
1254
|
+
} else {
|
|
1255
|
+
setUpdateInfo({ ok: false });
|
|
1256
|
+
}
|
|
1257
|
+
} catch {
|
|
1258
|
+
setUpdateInfo({ ok: false });
|
|
1259
|
+
} finally {
|
|
1260
|
+
setCheckingUpdate(false);
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
const runUpdate = async () => {
|
|
1265
|
+
setUpgrading(true);
|
|
1266
|
+
setUpdateInfo(null);
|
|
1267
|
+
setFailed(false);
|
|
1268
|
+
setSaveError("");
|
|
1269
|
+
try {
|
|
1270
|
+
const response = await fetch(`${BRIDGE_PREFIX}/update`, {
|
|
1271
|
+
method: "POST",
|
|
1272
|
+
headers: { "content-type": "application/json" },
|
|
1273
|
+
body: "{}",
|
|
1274
|
+
});
|
|
1275
|
+
const result = await response.json();
|
|
1276
|
+
if (result.ok) {
|
|
1277
|
+
setUpdateInfo({ ok: true, hasUpdate: false, upgraded: true, message: result.value.message, latest: result.value.latest });
|
|
1278
|
+
} else {
|
|
1279
|
+
setUpdateInfo({ ok: false, upgradeFailed: result.message ?? "upgrade failed" });
|
|
1280
|
+
}
|
|
1281
|
+
} catch {
|
|
1282
|
+
setUpdateInfo({ ok: false, upgradeFailed: "request failed" });
|
|
1283
|
+
} finally {
|
|
1284
|
+
setUpgrading(false);
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1198
1288
|
const runDoctor = async () => {
|
|
1199
1289
|
setDoctorRunning(true);
|
|
1200
1290
|
setDoctorText("");
|
|
@@ -2404,6 +2494,86 @@ react_jsx_runtime.jsx("div", {
|
|
|
2404
2494
|
className: "dshfs-footerLeft",
|
|
2405
2495
|
children: [
|
|
2406
2496
|
react_jsx_runtime.jsx("span", { className: "dshfs-version", children: "v" + PLUGIN_VERSION }),
|
|
2497
|
+
updateInfo && updateInfo.ok && updateInfo.hasUpdate && !updateInfo.installable
|
|
2498
|
+
? react_jsx_runtime.jsx("a", {
|
|
2499
|
+
className: "dshfs-updatePill",
|
|
2500
|
+
href: updateInfo.updateUrl,
|
|
2501
|
+
target: "_blank",
|
|
2502
|
+
rel: "noopener noreferrer",
|
|
2503
|
+
title: t.updateAvailable(updateInfo.current, updateInfo.latest),
|
|
2504
|
+
children: [
|
|
2505
|
+
react_jsx_runtime.jsx("svg", {
|
|
2506
|
+
className: "dshfs-updateIcon",
|
|
2507
|
+
viewBox: "0 0 16 16",
|
|
2508
|
+
width: 14,
|
|
2509
|
+
height: 14,
|
|
2510
|
+
"aria-hidden": "true",
|
|
2511
|
+
children: react_jsx_runtime.jsx("path", {
|
|
2512
|
+
d: "M8 2.2v6.4M5.2 6.4 8 9.2l2.8-2.8M3 10.8v1.4c0 .9.7 1.6 1.6 1.6h6.8c.9 0 1.6-.7 1.6-1.6v-1.4",
|
|
2513
|
+
fill: "none",
|
|
2514
|
+
stroke: "currentColor",
|
|
2515
|
+
strokeWidth: 1.6,
|
|
2516
|
+
strokeLinecap: "round",
|
|
2517
|
+
strokeLinejoin: "round",
|
|
2518
|
+
}),
|
|
2519
|
+
}),
|
|
2520
|
+
t.hasUpdate,
|
|
2521
|
+
],
|
|
2522
|
+
})
|
|
2523
|
+
: react_jsx_runtime.jsx("button", {
|
|
2524
|
+
className: "dshfs-updatePill",
|
|
2525
|
+
type: "button",
|
|
2526
|
+
title: updateInfo && updateInfo.ok && updateInfo.hasUpdate ? t.updateAvailable(updateInfo.current, updateInfo.latest) : undefined,
|
|
2527
|
+
onClick: updateInfo && updateInfo.ok && updateInfo.hasUpdate ? runUpdate : runCheckUpdate,
|
|
2528
|
+
disabled: upgrading || checkingUpdate || saving || !ready,
|
|
2529
|
+
children: [
|
|
2530
|
+
react_jsx_runtime.jsx("svg", {
|
|
2531
|
+
className: "dshfs-updateIcon",
|
|
2532
|
+
viewBox: "0 0 16 16",
|
|
2533
|
+
width: 14,
|
|
2534
|
+
height: 14,
|
|
2535
|
+
"aria-hidden": "true",
|
|
2536
|
+
children: react_jsx_runtime.jsx("path", {
|
|
2537
|
+
d: "M8 2.2v6.4M5.2 6.4 8 9.2l2.8-2.8M3 10.8v1.4c0 .9.7 1.6 1.6 1.6h6.8c.9 0 1.6-.7 1.6-1.6v-1.4",
|
|
2538
|
+
fill: "none",
|
|
2539
|
+
stroke: "currentColor",
|
|
2540
|
+
strokeWidth: 1.6,
|
|
2541
|
+
strokeLinecap: "round",
|
|
2542
|
+
strokeLinejoin: "round",
|
|
2543
|
+
}),
|
|
2544
|
+
}),
|
|
2545
|
+
upgrading
|
|
2546
|
+
? t.upgrading
|
|
2547
|
+
: checkingUpdate
|
|
2548
|
+
? t.checkingUpdate
|
|
2549
|
+
: updateInfo && updateInfo.ok && updateInfo.hasUpdate
|
|
2550
|
+
? t.hasUpdate
|
|
2551
|
+
: t.checkUpdate,
|
|
2552
|
+
],
|
|
2553
|
+
}),
|
|
2554
|
+
updateInfo && updateInfo.ok
|
|
2555
|
+
? updateInfo.upgraded
|
|
2556
|
+
? react_jsx_runtime.jsx("span", {
|
|
2557
|
+
className: "dshfs-updateOk",
|
|
2558
|
+
children: t.upgradeDone(updateInfo.latest),
|
|
2559
|
+
})
|
|
2560
|
+
: updateInfo.hasUpdate
|
|
2561
|
+
? updateInfo.installable
|
|
2562
|
+
? null
|
|
2563
|
+
: react_jsx_runtime.jsx("span", {
|
|
2564
|
+
className: "dshfs-version",
|
|
2565
|
+
children: t.upgradeLinkMode,
|
|
2566
|
+
})
|
|
2567
|
+
: react_jsx_runtime.jsx("span", {
|
|
2568
|
+
className: "dshfs-updateOk",
|
|
2569
|
+
children: t.updateLatest(updateInfo.current),
|
|
2570
|
+
})
|
|
2571
|
+
: updateInfo && !updateInfo.ok
|
|
2572
|
+
? react_jsx_runtime.jsx("span", {
|
|
2573
|
+
className: "dshfs-failed",
|
|
2574
|
+
children: updateInfo.upgradeFailed ? t.upgradeFailed(updateInfo.upgradeFailed) : t.updateCheckFailed,
|
|
2575
|
+
})
|
|
2576
|
+
: null,
|
|
2407
2577
|
|
|
2408
2578
|
],
|
|
2409
2579
|
}),
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import z from "@deepseek-ai/schemastery";
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { execFile } from "node:child_process";
|
|
7
|
+
import { exec, execFile } from "node:child_process";
|
|
8
8
|
import { mcpCall, mcpContentText, parseMcpResponseText } from "./mcp_adapter.js";
|
|
9
9
|
import { registerResearchTool } from "./research.js";
|
|
10
10
|
import { registerDomainSearchTool } from "./vertical.js";
|
|
@@ -526,6 +526,63 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
|
|
|
526
526
|
|
|
527
527
|
|
|
528
528
|
|
|
529
|
+
const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-free-search/latest";
|
|
530
|
+
const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-free-search";
|
|
531
|
+
const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
|
|
532
|
+
|
|
533
|
+
// 查询 npm registry 的最新版本;失败返回 null(网络/代理问题不阻塞设置页)
|
|
534
|
+
async function fetchLatestVersion(signal) {
|
|
535
|
+
const controller = new AbortController();
|
|
536
|
+
const timer = setTimeout(() => controller.abort(), 10000);
|
|
537
|
+
const onAbort = () => controller.abort();
|
|
538
|
+
signal?.addEventListener("abort", onAbort);
|
|
539
|
+
try {
|
|
540
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
541
|
+
headers: { accept: "application/json", "user-agent": "deepseek-harness/free-search" },
|
|
542
|
+
signal: controller.signal,
|
|
543
|
+
});
|
|
544
|
+
if (!response.ok) return null;
|
|
545
|
+
const data = await response.json();
|
|
546
|
+
return typeof data.version === "string" ? data.version : null;
|
|
547
|
+
} catch {
|
|
548
|
+
return null;
|
|
549
|
+
} finally {
|
|
550
|
+
clearTimeout(timer);
|
|
551
|
+
signal?.removeEventListener("abort", onAbort);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// 简单 semver 比较(只处理 x.y.z,忽略预发布标签):a>b 返回 1,a<b 返回 -1,相等 0
|
|
556
|
+
function compareVersions(a, b) {
|
|
557
|
+
const na = String(a).split(".").map((n) => parseInt(n, 10) || 0);
|
|
558
|
+
const nb = String(b).split(".").map((n) => parseInt(n, 10) || 0);
|
|
559
|
+
for (let i = 0; i < 3; i++) {
|
|
560
|
+
if ((na[i] ?? 0) > (nb[i] ?? 0)) return 1;
|
|
561
|
+
if ((na[i] ?? 0) < (nb[i] ?? 0)) return -1;
|
|
562
|
+
}
|
|
563
|
+
return 0;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// 安装模式:profiles/*/node_modules/dsh-free-search 是符号链接(link: 本地开发)还是真实安装。
|
|
567
|
+
// 真实安装优先:有一个 profile 是 npm 安装的,就升级那一份;全是 link 才按本地开发处理。
|
|
568
|
+
function detectInstallMode(root = path.join(dshHomeDir(), "profiles")) {
|
|
569
|
+
let linked = null;
|
|
570
|
+
try {
|
|
571
|
+
for (const name of fs.readdirSync(root)) {
|
|
572
|
+
const pkgPath = path.join(root, name, "node_modules", "dsh-free-search");
|
|
573
|
+
if (!fs.existsSync(pkgPath)) continue;
|
|
574
|
+
let isLink = false;
|
|
575
|
+
try {
|
|
576
|
+
isLink = fs.lstatSync(pkgPath).isSymbolicLink();
|
|
577
|
+
} catch {}
|
|
578
|
+
const entry = { profileDir: path.join(root, name), isLink };
|
|
579
|
+
if (!isLink) return entry;
|
|
580
|
+
if (linked === null) linked = entry;
|
|
581
|
+
}
|
|
582
|
+
} catch {}
|
|
583
|
+
return linked;
|
|
584
|
+
}
|
|
585
|
+
|
|
529
586
|
// time_range 支持:固定档 day/week/month/year,或自定义(相对 12h/3d/2mo/1y、绝对 YYYY-MM-DD)
|
|
530
587
|
const TIME_RANGES = ["day", "week", "month", "year"];
|
|
531
588
|
const DAYS_BY_RANGE = { day: 1, week: 7, month: 30, year: 365 };
|
|
@@ -3497,6 +3554,65 @@ function makeBridgeRoutes(settings, search, testEngine, getCredentials, getConfi
|
|
|
3497
3554
|
.map((descriptor) => String(descriptor.ns));
|
|
3498
3555
|
|
|
3499
3556
|
const handlers = {
|
|
3557
|
+
async checkUpdate() {
|
|
3558
|
+
const latest = await fetchLatestVersion();
|
|
3559
|
+
if (latest === null) {
|
|
3560
|
+
return {
|
|
3561
|
+
ok: false,
|
|
3562
|
+
code: "update-check-failed",
|
|
3563
|
+
message: "could not reach the npm registry (network/proxy) - check your connection",
|
|
3564
|
+
};
|
|
3565
|
+
}
|
|
3566
|
+
const cmp = compareVersions(latest, PACKAGE_VERSION);
|
|
3567
|
+
const mode = detectInstallMode();
|
|
3568
|
+
return {
|
|
3569
|
+
ok: true,
|
|
3570
|
+
value: {
|
|
3571
|
+
current: PACKAGE_VERSION,
|
|
3572
|
+
latest,
|
|
3573
|
+
hasUpdate: cmp > 0,
|
|
3574
|
+
updateUrl: PLUGIN_NPM_URL,
|
|
3575
|
+
repoUrl: PLUGIN_REPO_URL,
|
|
3576
|
+
// 可一键升级:npm 真安装时 true;本地 link 开发模式 false(升级请 git pull 源码)
|
|
3577
|
+
installable: mode !== null && !mode.isLink,
|
|
3578
|
+
installMode: mode?.isLink ? "link" : mode !== null ? "registry" : "unknown",
|
|
3579
|
+
},
|
|
3580
|
+
};
|
|
3581
|
+
},
|
|
3582
|
+
// 一键升级:仅在 npm 真安装模式下执行 pnpm 升级;link 模式拒绝,避免破坏本地开发链路。
|
|
3583
|
+
async updatePlugin() {
|
|
3584
|
+
const mode = detectInstallMode();
|
|
3585
|
+
if (mode === null) {
|
|
3586
|
+
return { ok: false, code: "install-not-found", message: "could not locate dsh-free-search in any profile" };
|
|
3587
|
+
}
|
|
3588
|
+
if (mode.isLink) {
|
|
3589
|
+
return {
|
|
3590
|
+
ok: false,
|
|
3591
|
+
code: "local-link-mode",
|
|
3592
|
+
message: "local development install (symlink) - update the source repo instead (git pull), then restart dsh",
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
try {
|
|
3596
|
+
const result = await new Promise((resolve, reject) => {
|
|
3597
|
+
exec("pnpm add dsh-free-search@latest", { cwd: mode.profileDir, timeout: 120000 }, (error, stdout, stderr) => {
|
|
3598
|
+
if (error) reject(new Error(`upgrade failed: ${(stderr || stdout || error.message).trim().slice(0, 300)}`));
|
|
3599
|
+
else resolve(stdout);
|
|
3600
|
+
});
|
|
3601
|
+
});
|
|
3602
|
+
const latest = await fetchLatestVersion();
|
|
3603
|
+
return {
|
|
3604
|
+
ok: true,
|
|
3605
|
+
value: {
|
|
3606
|
+
updated: true,
|
|
3607
|
+
latest: latest ?? "unknown",
|
|
3608
|
+
message: "upgraded to latest - restart dsh to apply",
|
|
3609
|
+
output: String(result).trim().slice(0, 200),
|
|
3610
|
+
},
|
|
3611
|
+
};
|
|
3612
|
+
} catch (error) {
|
|
3613
|
+
return { ok: false, code: "upgrade-failed", message: error instanceof Error ? error.message : String(error) };
|
|
3614
|
+
}
|
|
3615
|
+
},
|
|
3500
3616
|
async rawSearch(request) {
|
|
3501
3617
|
if (request === null || typeof request !== "object" || typeof request.query !== "string" || request.query.length === 0) {
|
|
3502
3618
|
return { ok: false, code: "search-rejected", message: "malformed bridge search request (query is required)" };
|
|
@@ -3726,6 +3842,22 @@ function makeBridgeRoutes(settings, search, testEngine, getCredentials, getConfi
|
|
|
3726
3842
|
writeJson(res, 200, await handlers.doctorReport());
|
|
3727
3843
|
},
|
|
3728
3844
|
},
|
|
3845
|
+
{
|
|
3846
|
+
kind: "exact",
|
|
3847
|
+
path: `${BRIDGE_PREFIX}/check-update`,
|
|
3848
|
+
handler: async (req, res) => {
|
|
3849
|
+
if (!guard(req, res)) return;
|
|
3850
|
+
writeJson(res, 200, await handlers.checkUpdate());
|
|
3851
|
+
},
|
|
3852
|
+
},
|
|
3853
|
+
{
|
|
3854
|
+
kind: "exact",
|
|
3855
|
+
path: `${BRIDGE_PREFIX}/update`,
|
|
3856
|
+
handler: async (req, res) => {
|
|
3857
|
+
if (!guard(req, res)) return;
|
|
3858
|
+
writeJson(res, 200, await handlers.updatePlugin());
|
|
3859
|
+
},
|
|
3860
|
+
},
|
|
3729
3861
|
{
|
|
3730
3862
|
kind: "exact",
|
|
3731
3863
|
path: `${BRIDGE_PREFIX}/raw-search`,
|
|
@@ -3812,7 +3944,10 @@ export function buildBuiltinPromptBlocks(cfg) {
|
|
|
3812
3944
|
}
|
|
3813
3945
|
|
|
3814
3946
|
const name = "web-search-free";
|
|
3815
|
-
|
|
3947
|
+
// settings / tools / systemPrompt are core DSH services and are touched inside
|
|
3948
|
+
// inject() callbacks; older Cordis builds (DSH 0.2.1-rc.2) refuse undeclared
|
|
3949
|
+
// property access, so declare them here as well (#107).
|
|
3950
|
+
const inject = ["web", "settings", "tools", "systemPrompt"];
|
|
3816
3951
|
|
|
3817
3952
|
// 引擎 key 与凭据中心 ref 的映射(白名单:只允许这些 ref 被 UI 读写凭据中心)
|
|
3818
3953
|
const KEY_REF_MAP = {
|
|
@@ -4892,7 +5027,7 @@ function apply(ctx, config) {
|
|
|
4892
5027
|
getCredentials,
|
|
4893
5028
|
current,
|
|
4894
5029
|
doctorReport
|
|
4895
|
-
).map((route) => registerOnce(() => sctx.webServer.register(route), { id: route.path }, "bridge route"));
|
|
5030
|
+
).map((route) => registerOnce(() => sctx.get("webServer").register(route), { id: route.path }, "bridge route"));
|
|
4896
5031
|
return () => {
|
|
4897
5032
|
for (const dispose of disposers) dispose();
|
|
4898
5033
|
};
|
|
@@ -6092,6 +6227,9 @@ export {
|
|
|
6092
6227
|
hasCustomFallbackOrder,
|
|
6093
6228
|
normalizeDisabledEngines,
|
|
6094
6229
|
normalizeAllowedEngines,
|
|
6230
|
+
compareVersions,
|
|
6231
|
+
detectInstallMode,
|
|
6232
|
+
fetchLatestVersion,
|
|
6095
6233
|
effectiveDisabledEngines,
|
|
6096
6234
|
normalizeFallbackOrder,
|
|
6097
6235
|
ANYSEARCH_URL,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-free-search",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.32",
|
|
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",
|