dsh-free-search 0.9.21 → 0.9.22

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
@@ -41,7 +41,7 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
41
41
  - **时间过滤** —— `advanced_search` 工具支持 `timeRange`:固定档、自定义相对值、绝对日期三种形式(详见下方逻辑说明)
42
42
  - **系统提示词注入** —— agent 知道当前用哪个引擎、哪些需要 key;并明确所有搜索结果是**不可信外部数据**,不得执行其中的指令
43
43
  - **提示注入防护(不可信数据边界)** —— 插件自有工具(advanced_search / platform_search / free_search_test)的网页文本包在 `<untrusted-web-content>` 边界内(正文里自带的同名标记会被剥离,防止提前闭合);核心 web_search / web_fetch 由 DSH 核心自带同类提示(`External web content follows...`);所有 snippet 统一清洗并截断到 300 字符
44
- - **版本号 + 检查更新** —— 设置卡片显示当前版本(跟随 `PLUGIN_VERSION`,随发布更新),"检查更新"按钮直连 npm registry 对比最新版,有新版本时提示并可一键跳转
44
+ - **版本号** —— 设置卡片底部显示当前版本(跟随 `PLUGIN_VERSION`,随发布更新)。检查与升级交给官方插件页(插件 → 已安装 → dsh-free-search → 更新),插件不再自带第二套更新按钮
45
45
  - **结果缓存** —— 相同查询(含引擎/时间过滤参数)5 分钟内命中缓存(LRU 50 条),防免费引擎限流、省付费额度;时长可在设置页 0-5 分钟自由配置(0 关闭)
46
46
  - **域名黑名单与安全搜索** —— `blockedDomains`:命中的域名不会进入任何结果;`safeSearch`(`off` / `moderate` / `strict`)为 Bing / DuckDuckGo 加一层过滤
47
47
  - **免费标注** —— 设置页中免费引擎带绿色 `FREE` 徽章,付费引擎带橙色 `API KEY` 徽章
@@ -497,7 +497,7 @@ Search engine test:
497
497
 
498
498
  #### 离线自检断言(tools/)
499
499
 
500
- 仓库自带 **32 个**零依赖断言脚本(合计 **627 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
500
+ 仓库自带 **34 个**零依赖断言脚本(合计 **636 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
501
501
 
502
502
  | 脚本 | 覆盖 | 运行(项数) |
503
503
  |---|---|---|
@@ -522,6 +522,7 @@ Search engine test:
522
522
  | `assert-youcom.mjs` | You.com 免 key 档(#90):两档 URL 与请求头、无 key 不发 `X-API-Key`、`YDC_API_KEY` 别名、429/401/402/5xx 分类 | `node tools/assert-youcom.mjs`(23) |
523
523
  | `assert-prompt-language.mjs` | 提示词语言(en/zh):语言回退、9 个工具双语文案、标识符不被翻译、占位符插值、切换时只重注册一次 | `node tools/assert-prompt-language.mjs`(7) |
524
524
  | `assert-tool-schema-size.mjs` | 工具 schema 体积(#94):共享引擎 id 常量、`domain_search` 不内嵌逐引擎句子、三处合计 < 1.6k 字符 | `node tools/assert-tool-schema-size.mjs`(5) |
525
+ | `assert-config-seat.mjs` | 配置入口(#101):卡片同时挂在 `plugins.bundle.config`(key = 包名,渲染在包页)与 `plugins.row.config`(老入口),两者共用同一渲染器 | `node tools/assert-config-seat.mjs`(4) |
525
526
  | `assert-rail-section.mjs` | 页内目录的机器可读当前段:卡片根 `data-dsh-fs-section` 与 `railActive` 绑定、六段 id 固定、滚动监听仍在更新 | `node tools/assert-rail-section.mjs`(4) |
526
527
  | `assert-package-files.mjs` | 发布清单闸门(#97):`files` 展开后必须覆盖被引用的本地模块、入口点与 `cordis.patch.yml`,并确认 `prepack` 守卫生效 | `node tools/assert-package-files.mjs`(4) |
527
528
  | `assert-key-rotation.mjs` | 多 key 轮换(#96):round-robin 与 peek、单 key 不推进、配额优先于 429 的分类、轮换候选集合、`multi` 模式内重试与预检不消耗 key | `node tools/assert-key-rotation.mjs`(7) |
@@ -593,7 +594,7 @@ This plugin provides multiple free search engines with automatic fallback, compl
593
594
  - **Time Filtering** — The `advanced_search` tool supports `timeRange`: fixed tiers, custom relative values, or an absolute date (details below)
594
595
  - **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
595
596
  - **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
596
- - **Version + Update Check** — The settings card shows the current version (tracks PLUGIN_VERSION, bumped on release), and a "Check update" button queries the npm registry to compare against the latest release, prompting a one-click jump when a newer version exists
597
+ - **Version label** — the settings card shows the current version (tracks PLUGIN_VERSION, bumped on release). Checking and updating is the official plugin page's job (Plugins -> Installed -> dsh-free-search -> Update); the plugin ships no second updater
597
598
  - **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)
598
599
  - **Domain blocklist & safe search** — `blockedDomains` keeps matching domains out of every result; `safeSearch` (`off` / `moderate` / `strict`) adds a filter layer for Bing / DuckDuckGo
599
600
  - **Visual Badges** — Free engines feature a green `FREE` badge, while paid engines show an orange `API KEY` badge in the settings UI
@@ -1050,7 +1051,7 @@ Restart `dsh web` after switching to apply changes.
1050
1051
 
1051
1052
  #### Offline self-check assertions (`tools/`)
1052
1053
 
1053
- **Thirty-two** zero-dependency assertion scripts ship with the repo (**627 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1054
+ **Thirty-four** zero-dependency assertion scripts ship with the repo (**636 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1054
1055
 
1055
1056
  | Script | Covers | Run (count) |
1056
1057
  |---|---|---|
@@ -1075,6 +1076,7 @@ Restart `dsh web` after switching to apply changes.
1075
1076
  | `assert-youcom.mjs` | You.com keyless tier (#90): both URLs and headers, no `X-API-Key` without a key, the `YDC_API_KEY` alias, and 429/401/402/5xx classification | `node tools/assert-youcom.mjs` (23) |
1076
1077
  | `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) |
1077
1078
  | `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
+ | `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) |
1078
1080
  | `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) |
1079
1081
  | `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) |
1080
1082
  | `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
@@ -123,9 +123,6 @@ window.__ModuleLoader__.load({
123
123
  ".dshfs-save:hover:not(:disabled){background:#0077ed;transform:translateY(-1px);box-shadow:0 2px 4px rgba(0,0,0,.15)}",
124
124
  ".dshfs-save:active:not(:disabled){transform:scale(0.98)}",
125
125
  "@media (prefers-color-scheme: dark){.dshfs-save{background:#0a84ff;color:#ffffff}.dshfs-save:hover:not(:disabled){background:#1e8eff}}",
126
- ".dshfs-upgrade{border:1px solid rgba(52,199,89,.4);background:rgba(52,199,89,.15);color:#248a3d}",
127
- "@media (prefers-color-scheme: dark){.dshfs-upgrade{color:#30d158}}",
128
- ".dshfs-upgrade:hover:not(:disabled){background:rgba(52,199,89,.25)}",
129
126
  ".dshfs-badge{background:rgba(0,0,0,.05);color:#1d1d1f;white-space:nowrap;border-radius:999px;flex:none;padding:2px 8px;font-size:11px;font-weight:600;letter-spacing:0.3px}",
130
127
  "@media (prefers-color-scheme: dark){.dshfs-badge{background:rgba(255,255,255,.1);color:#f5f5f7}}",
131
128
  ".dshfs-badgeAuto{background:rgba(175,82,222,.15);color:#af52de;border:1px solid rgba(175,82,222,.2)}",
@@ -140,15 +137,7 @@ window.__ModuleLoader__.load({
140
137
  "@media (prefers-color-scheme: dark){.dshfs-langToggle{color:#a1a1a6}}",
141
138
  ".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}",
142
139
  "@media (prefers-color-scheme: dark){.dshfs-update{color:#ff9f0a}}",
143
- ".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}",
144
- "@media (prefers-color-scheme: dark){.dshfs-updateOk{color:#30d158}}",
145
140
  ".dshfs-updateLine{display:flex;align-items:center;gap:10px;flex-wrap:wrap}",
146
- ".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)}",
147
- "@media (prefers-color-scheme: dark){.dshfs-updatePill{color:#0a84ff;background:rgba(10,132,255,.15);border-color:rgba(10,132,255,.25)}}",
148
- ".dshfs-updatePill:hover:not(:disabled){background:rgba(0,113,227,.15);border-color:rgba(0,113,227,.3)}",
149
- "@media (prefers-color-scheme: dark){.dshfs-updatePill:hover:not(:disabled){background:rgba(10,132,255,.2);border-color:rgba(10,132,255,.4)}}",
150
- ".dshfs-updatePill:disabled{opacity:.5;cursor:default}",
151
- ".dshfs-updateIcon{flex:none;display:block}",
152
141
  ".dshfs-version{color:#6e6e73;font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}",
153
142
  "@media (prefers-color-scheme: dark){.dshfs-version{color:#a1a1a6}}"
154
143
  ].join("");
@@ -255,18 +244,6 @@ window.__ModuleLoader__.load({
255
244
  testOk: (r) => `✓ ${r.count} 条结果(引擎: ${r.engine})${r.content ? ` — ${r.content}` : ""}${r.sample ? ` · 例如 "${r.sample.slice(0, 40)}"` : ""}`,
256
245
  testFail: (e) => `✗ ${e}`,
257
246
  toggleLang: "EN",
258
- checkUpdate: "检查更新",
259
- checkingUpdate: "检查中…",
260
- updateAvailable: (c, l) => `发现新版本 v${l}(当前 v${c})`,
261
- updateLatest: (c) => `已是最新版本 v${c}`,
262
- updateCheckFailed: "检查更新失败(无法访问 npm registry)",
263
- updateView: "查看 →",
264
- hasUpdate: "有更新",
265
- upgrade: "升级",
266
- upgrading: "升级中…",
267
- upgradeLinkMode: "(本地开发模式,升级请用 git pull)",
268
- upgradeDone: (l) => `升级到 v${l} 完成,重启 dsh 后生效`,
269
- upgradeFailed: (m) => `升级失败:${m}`,
270
247
  safeSearchLabel: "安全搜索过滤 (adlt)",
271
248
  safeSearchOff: "关闭 —— 引擎默认(不加参数)",
272
249
  safeSearchModerate: "中等 —— Bing 默认",
@@ -388,18 +365,6 @@ window.__ModuleLoader__.load({
388
365
  testOk: (r) => `✓ ${r.count} results (engine: ${r.engine})${r.content ? ` — ${r.content}` : ""}${r.sample ? ` · e.g. "${r.sample.slice(0, 40)}"` : ""}`,
389
366
  testFail: (e) => `✗ ${e}`,
390
367
  toggleLang: "中文",
391
- checkUpdate: "Check update",
392
- checkingUpdate: "Checking…",
393
- updateAvailable: (c, l) => `New version v${l} available (current v${c})`,
394
- updateLatest: (c) => `You're on the latest version v${c}`,
395
- updateCheckFailed: "Update check failed (cannot reach npm registry)",
396
- updateView: "View →",
397
- hasUpdate: "Update available",
398
- upgrade: "Upgrade",
399
- upgrading: "Upgrading…",
400
- upgradeLinkMode: "(local dev install - use git pull to update)",
401
- upgradeDone: (l) => `Upgraded to v${l} - restart dsh to apply`,
402
- upgradeFailed: (m) => `Upgrade failed: ${m}`,
403
368
  safeSearchLabel: "Safe search filter (adlt)",
404
369
  safeSearchOff: "Off - engine default (no filtering)",
405
370
  safeSearchModerate: "Moderate - Bing default",
@@ -437,7 +402,7 @@ window.__ModuleLoader__.load({
437
402
  };
438
403
  const tt = (lang) => I18N[String(lang ?? "").trim().toLowerCase() === "zh" ? "zh" : "en"];
439
404
  // 当前插件版本(与 lib/index.js 的 PLUGIN_VERSION 保持一致;跟随上游 v0.7.5)
440
- const PLUGIN_VERSION = "0.9.21";
405
+ const PLUGIN_VERSION = "0.9.22";
441
406
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
442
407
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
443
408
  const NAV_ITEMS = [
@@ -585,15 +550,6 @@ window.__ModuleLoader__.load({
585
550
  return response.json();
586
551
  }
587
552
 
588
- async function bridgeCheckUpdate() {
589
- const response = await fetch(`${BRIDGE_PREFIX}/check-update`, {
590
- method: "POST",
591
- headers: { "content-type": "application/json" },
592
- body: "{}",
593
- });
594
- return response.json();
595
- }
596
-
597
553
  async function bridgeCredentialsStatus() {
598
554
  const response = await fetch(`${BRIDGE_PREFIX}/credentials-status`, {
599
555
  method: "POST",
@@ -736,9 +692,6 @@ window.__ModuleLoader__.load({
736
692
  const [saveError, setSaveError] = react.useState("");
737
693
  const [testing, setTesting] = react.useState(false);
738
694
  const [testResult, setTestResult] = react.useState(null);
739
- const [checkingUpdate, setCheckingUpdate] = react.useState(false);
740
- const [upgrading, setUpgrading] = react.useState(false);
741
- const [updateInfo, setUpdateInfo] = react.useState(null);
742
695
  // 回退优先级/池列表行内 key 输入:引擎 id → [当前值, setter](zhihu 两引擎共享 ZHIHU_API_KEY)
743
696
  const KEY_INPUTS = {
744
697
  anysearch: [anysearchKey, setAnysearchKey],
@@ -1040,51 +993,6 @@ window.__ModuleLoader__.load({
1040
993
  }
1041
994
  };
1042
995
 
1043
- const runCheckUpdate = async () => {
1044
- setCheckingUpdate(true);
1045
- setUpdateInfo(null);
1046
- setFailed(false);
1047
- setSaveError("");
1048
- try {
1049
- const result = await bridgeCheckUpdate();
1050
- if (result.ok) {
1051
- setUpdateInfo({ ok: true, ...result.value });
1052
- } else {
1053
- setUpdateInfo({ ok: false });
1054
- }
1055
- } catch {
1056
- setUpdateInfo({ ok: false });
1057
- } finally {
1058
- setCheckingUpdate(false);
1059
- }
1060
- };
1061
-
1062
- const runUpdate = async () => {
1063
- setUpgrading(true);
1064
- setUpdateInfo(null);
1065
- setFailed(false);
1066
- setSaveError("");
1067
- try {
1068
- const response = await fetch(`${BRIDGE_PREFIX}/update`, {
1069
- method: "POST",
1070
- headers: { "content-type": "application/json" },
1071
- body: "{}",
1072
- });
1073
- const result = await response.json();
1074
- if (result.ok) {
1075
- setUpdateInfo({ ok: true, hasUpdate: false, upgraded: true, message: result.value.message, latest: result.value.latest });
1076
- } else {
1077
- setUpdateInfo({ ok: false, upgradeFailed: result.message ?? "upgrade failed" });
1078
- }
1079
- } catch {
1080
- setUpdateInfo({ ok: false, upgradeFailed: "request failed" });
1081
- } finally {
1082
- setUpgrading(false);
1083
- }
1084
- };
1085
-
1086
- // 浮动目录(#85):放在卡片右侧的页面留白里,绝对定位不参与卡片布局,
1087
- // 所以正文宽度和 0.9.8 完全一致;留白不足(窄窗口/卡片贴边)时直接隐藏。
1088
996
  react.useEffect(() => {
1089
997
  if (!open) return undefined;
1090
998
  const place = () => {
@@ -1374,6 +1282,7 @@ window.__ModuleLoader__.load({
1374
1282
  react_jsx_runtime.jsx("button", {
1375
1283
  type: "button",
1376
1284
  className: "dshfs-railItem" + (railActive === item.id ? " dshfs-railItemActive" : ""),
1285
+ "data-dsh-fs-section": item.id,
1377
1286
  onClick: () => goToSection(item.id),
1378
1287
  children: [
1379
1288
  react_jsx_runtime.jsx("span", { className: "dshfs-railDot" }),
@@ -2024,86 +1933,7 @@ react_jsx_runtime.jsx("div", {
2024
1933
  className: "dshfs-footerLeft",
2025
1934
  children: [
2026
1935
  react_jsx_runtime.jsx("span", { className: "dshfs-version", children: "v" + PLUGIN_VERSION }),
2027
- updateInfo && updateInfo.ok && updateInfo.hasUpdate && !updateInfo.installable
2028
- ? react_jsx_runtime.jsx("a", {
2029
- className: "dshfs-updatePill",
2030
- href: updateInfo.updateUrl,
2031
- target: "_blank",
2032
- rel: "noopener noreferrer",
2033
- title: t.updateAvailable(updateInfo.current, updateInfo.latest),
2034
- children: [
2035
- react_jsx_runtime.jsx("svg", {
2036
- className: "dshfs-updateIcon",
2037
- viewBox: "0 0 16 16",
2038
- width: 14,
2039
- height: 14,
2040
- "aria-hidden": "true",
2041
- children: react_jsx_runtime.jsx("path", {
2042
- 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",
2043
- fill: "none",
2044
- stroke: "currentColor",
2045
- strokeWidth: 1.6,
2046
- strokeLinecap: "round",
2047
- strokeLinejoin: "round",
2048
- }),
2049
- }),
2050
- t.hasUpdate,
2051
- ],
2052
- })
2053
- : react_jsx_runtime.jsx("button", {
2054
- className: "dshfs-updatePill",
2055
- type: "button",
2056
- title: updateInfo && updateInfo.ok && updateInfo.hasUpdate ? t.updateAvailable(updateInfo.current, updateInfo.latest) : undefined,
2057
- onClick: updateInfo && updateInfo.ok && updateInfo.hasUpdate ? runUpdate : runCheckUpdate,
2058
- disabled: upgrading || checkingUpdate || saving || !ready,
2059
- children: [
2060
- react_jsx_runtime.jsx("svg", {
2061
- className: "dshfs-updateIcon",
2062
- viewBox: "0 0 16 16",
2063
- width: 14,
2064
- height: 14,
2065
- "aria-hidden": "true",
2066
- children: react_jsx_runtime.jsx("path", {
2067
- 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",
2068
- fill: "none",
2069
- stroke: "currentColor",
2070
- strokeWidth: 1.6,
2071
- strokeLinecap: "round",
2072
- strokeLinejoin: "round",
2073
- }),
2074
- }),
2075
- upgrading
2076
- ? t.upgrading
2077
- : checkingUpdate
2078
- ? t.checkingUpdate
2079
- : updateInfo && updateInfo.ok && updateInfo.hasUpdate
2080
- ? t.hasUpdate
2081
- : t.checkUpdate,
2082
- ],
2083
- }),
2084
- updateInfo && updateInfo.ok
2085
- ? updateInfo.upgraded
2086
- ? react_jsx_runtime.jsx("span", {
2087
- className: "dshfs-updateOk",
2088
- children: t.upgradeDone(updateInfo.latest),
2089
- })
2090
- : updateInfo.hasUpdate
2091
- ? updateInfo.installable
2092
- ? null
2093
- : react_jsx_runtime.jsx("span", {
2094
- className: "dshfs-version",
2095
- children: t.upgradeLinkMode,
2096
- })
2097
- : react_jsx_runtime.jsx("span", {
2098
- className: "dshfs-updateOk",
2099
- children: t.updateLatest(updateInfo.current),
2100
- })
2101
- : updateInfo && !updateInfo.ok
2102
- ? react_jsx_runtime.jsx("span", {
2103
- className: "dshfs-failed",
2104
- children: updateInfo.upgradeFailed ? t.upgradeFailed(updateInfo.upgradeFailed) : t.updateCheckFailed,
2105
- })
2106
- : null,
1936
+
2107
1937
  ],
2108
1938
  }),
2109
1939
  react_jsx_runtime.jsx("div", {
@@ -2188,6 +2018,21 @@ react_jsx_runtime.jsx("div", {
2188
2018
  // description 必须传函数:ui-commands 读回的是 contribution.description(),
2189
2019
  // 传字符串会抛 TypeError: contribution.description is not a function;该异常
2190
2020
  // 会让整份 "/" 候选列表一起失败,菜单空白、其他命令也一起点不到。
2021
+ // #101: also claim the bundle-level seat (keyed by the package name) so the
2022
+ // card renders on the bundle page itself, between the description and the
2023
+ // rows. The row-level seat stays registered for the older entry point.
2024
+ ctx.slots.inject("plugins.bundle.config", () =>
2025
+ ctx.slots.register(
2026
+ {
2027
+ name: "plugins.bundle.config",
2028
+ key: "dsh-free-search",
2029
+ },
2030
+ (slotProps) =>
2031
+ slotProps && slotProps.view === "summary"
2032
+ ? summaryText()
2033
+ : react_jsx_runtime.jsx(FreeSearchCard, { page: true })
2034
+ )
2035
+ );
2191
2036
  ctx.inject(["commandUi"], (sctx) => {
2192
2037
  const command = sctx.get("commandUi");
2193
2038
  sctx.effect(() => {
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 { exec, execFile } from "node:child_process";
7
+ import { 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";
@@ -423,65 +423,7 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
423
423
  return [...ordered, ...remaining];
424
424
  }
425
425
 
426
- // 当前插件版本(发布时与 package.json 同步;跟随上游 v0.7.5,不在 PR 里 bump)
427
- const PLUGIN_VERSION = "0.9.21";
428
- // 检查更新的 npm registry 元数据地址(dsh-free-search 是 npmjs 上的公开包)
429
- const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-free-search/latest";
430
- const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-free-search";
431
- const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
432
426
 
433
- // 查询 npm registry 的最新版本;失败时返回 null(网络/代理问题不阻塞设置页)
434
- async function fetchLatestVersion(signal) {
435
- const controller = new AbortController();
436
- const timer = setTimeout(() => controller.abort(), 10000);
437
- const onAbort = () => controller.abort();
438
- signal?.addEventListener("abort", onAbort);
439
- try {
440
- const response = await fetch(NPM_REGISTRY_URL, {
441
- headers: { accept: "application/json", "user-agent": "deepseek-harness/free-search" },
442
- signal: controller.signal,
443
- });
444
- if (!response.ok) return null;
445
- const data = await response.json();
446
- return typeof data.version === "string" ? data.version : null;
447
- } catch {
448
- return null;
449
- } finally {
450
- clearTimeout(timer);
451
- signal?.removeEventListener("abort", onAbort);
452
- }
453
- }
454
-
455
- // 简单的 semver 比较(仅处理 x.y.z 主/次/补丁,忽略预发布标签);a>b 返回 1, a<b 返回 -1, 相等返回 0
456
- function compareVersions(a, b) {
457
- const na = String(a).split(".").map((n) => parseInt(n, 10) || 0);
458
- const nb = String(b).split(".").map((n) => parseInt(n, 10) || 0);
459
- for (let i = 0; i < 3; i++) {
460
- if ((na[i] ?? 0) > (nb[i] ?? 0)) return 1;
461
- if ((na[i] ?? 0) < (nb[i] ?? 0)) return -1;
462
- }
463
- return 0;
464
- }
465
-
466
- // 检测插件的安装模式:遍历 profiles/*/node_modules/dsh-free-search,
467
- // symlink(link: 本地开发)→ isLink=true;npm 真安装 → isLink=false;找不到 → null
468
- function detectInstallMode() {
469
- const profilesDir = path.join(process.cwd(), "profiles");
470
- let found = null;
471
- try {
472
- for (const name of fs.readdirSync(profilesDir)) {
473
- const pkgPath = path.join(profilesDir, name, "node_modules", "dsh-free-search");
474
- if (!fs.existsSync(pkgPath)) continue;
475
- let isLink = false;
476
- try {
477
- isLink = fs.lstatSync(pkgPath).isSymbolicLink();
478
- } catch {}
479
- found = { profileDir: path.join(profilesDir, name), isLink };
480
- break;
481
- }
482
- } catch {}
483
- return found;
484
- }
485
427
 
486
428
  // time_range 支持:固定档 day/week/month/year,或自定义(相对 12h/3d/2mo/1y、绝对 YYYY-MM-DD)
487
429
  const TIME_RANGES = ["day", "week", "month", "year"];
@@ -3414,65 +3356,6 @@ function makeBridgeRoutes(settings, search, testEngine, getCredentials) {
3414
3356
  .map((descriptor) => String(descriptor.ns));
3415
3357
 
3416
3358
  const handlers = {
3417
- async checkUpdate() {
3418
- const latest = await fetchLatestVersion();
3419
- if (latest === null) {
3420
- return {
3421
- ok: false,
3422
- code: "update-check-failed",
3423
- message: "could not reach the npm registry (network/proxy) - check your connection",
3424
- };
3425
- }
3426
- const cmp = compareVersions(latest, PLUGIN_VERSION);
3427
- const mode = detectInstallMode();
3428
- return {
3429
- ok: true,
3430
- value: {
3431
- current: PLUGIN_VERSION,
3432
- latest,
3433
- hasUpdate: cmp > 0,
3434
- updateUrl: PLUGIN_NPM_URL,
3435
- repoUrl: PLUGIN_REPO_URL,
3436
- // 可一键升级:npm 真安装时 true;本地 link 开发模式 false(升级请 git pull 源码)
3437
- installable: mode !== null && !mode.isLink,
3438
- installMode: mode?.isLink ? "link" : mode !== null ? "registry" : "unknown",
3439
- },
3440
- };
3441
- },
3442
- // 一键升级:仅在 npm 真安装模式下执行 pnpm 升级;link 模式拒绝(避免破坏本地开发链路)
3443
- async updatePlugin() {
3444
- const mode = detectInstallMode();
3445
- if (mode === null) {
3446
- return { ok: false, code: "install-not-found", message: "could not locate dsh-free-search in any profile" };
3447
- }
3448
- if (mode.isLink) {
3449
- return {
3450
- ok: false,
3451
- code: "local-link-mode",
3452
- message: "local development install (symlink) - update the source repo instead (git pull), then restart dsh",
3453
- };
3454
- }
3455
- try {
3456
- const result = await new Promise((resolve, reject) => {
3457
- exec("pnpm add dsh-free-search@latest", { cwd: mode.profileDir, timeout: 120000 }, (error, stdout, stderr) => {
3458
- if (error) reject(new Error(`upgrade failed: ${(stderr || stdout || error.message).trim().slice(0, 300)}`));
3459
- else resolve(stdout);
3460
- });
3461
- });
3462
- const latest = await fetchLatestVersion();
3463
- return {
3464
- ok: true,
3465
- value: {
3466
- updated: true,
3467
- latest: latest ?? "unknown",
3468
- message: `upgraded to latest - restart dsh to apply`,
3469
- output: String(result).trim().slice(0, 200),
3470
- },
3471
- };
3472
- } catch (error) {
3473
- return { ok: false, code: "upgrade-failed", message: error instanceof Error ? error.message : String(error) };
3474
- }
3475
- },
3476
3359
  async rawSearch(request) {
3477
3360
  if (request === null || typeof request !== "object" || typeof request.query !== "string" || request.query.length === 0) {
3478
3361
  return { ok: false, code: "search-rejected", message: "malformed bridge search request (query is required)" };
@@ -3684,22 +3567,6 @@ function makeBridgeRoutes(settings, search, testEngine, getCredentials) {
3684
3567
  writeJson(res, 200, await handlers.credentialsUnset(body));
3685
3568
  },
3686
3569
  },
3687
- {
3688
- kind: "exact",
3689
- path: `${BRIDGE_PREFIX}/check-update`,
3690
- handler: async (req, res) => {
3691
- if (!guard(req, res)) return;
3692
- writeJson(res, 200, await handlers.checkUpdate());
3693
- },
3694
- },
3695
- {
3696
- kind: "exact",
3697
- path: `${BRIDGE_PREFIX}/update`,
3698
- handler: async (req, res) => {
3699
- if (!guard(req, res)) return;
3700
- writeJson(res, 200, await handlers.updatePlugin());
3701
- },
3702
- },
3703
3570
  {
3704
3571
  kind: "exact",
3705
3572
  path: `${BRIDGE_PREFIX}/raw-search`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
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",