@fffangchenghao/dsh-web-search 0.20.0 → 0.20.1
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/CHANGELOG.md +26 -4
- package/README.md +37 -18
- package/README.zh-CN.md +33 -18
- package/client.js +119 -3
- package/docs/store-evidence.md +1 -1
- package/lib/bridge.d.ts +18 -0
- package/lib/bridge.js +145 -0
- package/lib/index.js +6 -2
- package/lib/inject.d.ts +25 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.20.1
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **A manual update button for deployments without `dsh-autoupdater`.** When
|
|
7
|
+
the Settings page is local and npm reports a newer version, it shows
|
|
8
|
+
**Install update**. The button posts to a loopback-only
|
|
9
|
+
`/api/dsh-web-search/update` bridge, which calls the Host's built-in
|
|
10
|
+
`pluginManager.installBundle` with exactly
|
|
11
|
+
`@fffangchenghao/dsh-web-search@latest`; it never accepts a package name from
|
|
12
|
+
the browser. A `link:`/`file:` checkout is refused rather than replaced, a
|
|
13
|
+
deployment without a plugin manager reports that honestly, and a successful
|
|
14
|
+
install says that a restart is required. This is manual, not a scheduler:
|
|
15
|
+
periodic checks still belong to `dsh-autoupdater`.
|
|
16
|
+
- **The npm version comparison is now directional.** A local build newer than
|
|
17
|
+
the registry is no longer labelled "update available"; the button appears
|
|
18
|
+
only when the registry version is actually newer.
|
|
19
|
+
- **Update-bridge tests.** 8 new cases cover the fixed package spec, link/file
|
|
20
|
+
refusal, manager absence, `ctx.get` fallback, method/loopback/origin guards,
|
|
21
|
+
malformed bodies and manager failure results.
|
|
22
|
+
|
|
23
|
+
**Test suite: 664 tests across 50 files** (663 pass, 1 skipped).
|
|
24
|
+
|
|
3
25
|
## 0.20.0
|
|
4
26
|
|
|
5
27
|
### Added
|
|
@@ -14,8 +36,8 @@
|
|
|
14
36
|
npm bundle so the profile-level `dsh-autoupdater` manages it; `link:`/`file:`
|
|
15
37
|
checkouts are intentionally excluded by that updater. The Settings card shows
|
|
16
38
|
the latest npm version and the running build; the plugin never hot-swaps its
|
|
17
|
-
own loaded code. The desktop profile is
|
|
18
|
-
|
|
39
|
+
own loaded code. The desktop profile is now installed from npm (`0.20.0`), so the profile
|
|
40
|
+
updater no longer classifies it as a local checkout.
|
|
19
41
|
- **`advanced_search` uses the official Chrome Releases feed for a windowed
|
|
20
42
|
Chrome security/release query.** The feed carries the real post date that a
|
|
21
43
|
search snippet often loses; the result note states how many posts fell inside
|
|
@@ -66,7 +88,7 @@
|
|
|
66
88
|
|
|
67
89
|
- **Ecosystem comparison refreshed.** The README now carries a 2026-10-25 snapshot with GitHub stars, last-month npm downloads, test evidence and package size for the main DSH competitors; stale claims about tool counts, store status and test leadership were removed.
|
|
68
90
|
|
|
69
|
-
**Test suite:
|
|
91
|
+
**Test suite: 656 tests across 49 files** (655 pass, 1 skipped). The new
|
|
70
92
|
unified-tool, platform, cache, mirror and landing-page tests are included.
|
|
71
93
|
- **`engine_test`: one probe per engine, with a reason.** A new model tool tests
|
|
72
94
|
one engine or all eight, bypasses the cache and never changes cooldown state,
|
|
@@ -293,7 +315,7 @@
|
|
|
293
315
|
and a success clears its strikes. A throttled or rejected key retries the same
|
|
294
316
|
request on the next key once, in both search and page extraction. Pools are
|
|
295
317
|
cached per Settings value, so editing the field starts clean.
|
|
296
|
-
- **Settings page polish.** A sticky jump bar scrolls to any of the
|
|
318
|
+
- **Settings page polish.** A sticky jump bar scrolls to any of the six groups,
|
|
297
319
|
and a line under the title compares the installed version with npm's latest
|
|
298
320
|
(hidden when the registry is unreachable rather than guessed).
|
|
299
321
|
- **Portable skill.** `skills/dsh-web-search/SKILL.md` states when to search,
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
11
11
|
<a href="https://www.npmjs.com/package/@fffangchenghao/dsh-web-search"><img src="https://img.shields.io/npm/v/@fffangchenghao/dsh-web-search.svg" alt="npm version"></a>
|
|
12
|
-
<img src="https://img.shields.io/badge/tests-
|
|
12
|
+
<img src="https://img.shields.io/badge/tests-664%20passing-brightgreen" alt="tests">
|
|
13
13
|
<img src="https://img.shields.io/badge/engines-8%2C%20zero%20API%20key-brightgreen" alt="engines">
|
|
14
14
|
<img src="https://img.shields.io/badge/node-%3E%3D22.18-blue" alt="node">
|
|
15
15
|
<img src="https://img.shields.io/badge/dsh-%3E%3D0.2.1--rc.2%20%3C0.3.0-blueviolet" alt="dsh">
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- **No API key, eight engines.** AnySearch, CN Bing, DuckDuckGo HTML, www Bing, DuckDuckGo Lite and 360 Search are scraped directly; Exa joins the primary tier through its keyless MCP endpoint, and Firecrawl's search API is the measured fallback. The plugin works out of the box.
|
|
22
22
|
- **The ranking is measured, not asserted.** Cross-engine reciprocal-rank fusion with authority and freshness boosts, a 20-query offline benchmark, and an 81-configuration parameter sweep — one of the few search plugins here that publishes its metric, per-query output and confidence intervals. See [How the ranking works](docs/rrf-ranking.md).
|
|
23
23
|
- **Fetching admits failure.** Binary documents and empty 200 responses are rejected by name (`SEARCH_UNSUPPORTED`, `SEARCH_EMPTY`) instead of being returned as noise; the direct → tunnel → render → extract ladder shares one 25 s budget and stops when there is no time left. The budget is per request — there is a regression test for exactly that.
|
|
24
|
-
- **
|
|
24
|
+
- **664 tests across 50 files**, a committed `lib/`, declared `engines.dsh` / `engines.node`, and a [SECURITY.md](SECURITY.md) that lists every process, host and file the plugin touches.
|
|
25
25
|
- **Bilingual documentation.** This README and [中文说明](README.zh-CN.md) are maintained side by side.
|
|
26
26
|
|
|
27
27
|

|
|
@@ -38,10 +38,10 @@ The web-search corner of the DSH plugin ecosystem is crowded. A fresh snapshot
|
|
|
38
38
|
| Key-free path | 8 engines, all key-free | ~30-engine free/paid chain | 5 defaults (seam, Exa, DDG, Bing, Jina) | Firecrawl + Keenable keyless defaults | 1 anonymous AnySearch API |
|
|
39
39
|
| Dedicated vertical sources | 34 (8 on by default) | 41 | platform registry, not a vertical catalog | web + X, no vertical catalog | vertical API behind AnySearch |
|
|
40
40
|
| Model-facing tools | 1 (`web_tools`, 8 actions) | ~10 | 2 (`web_index` / `web_call`, 20 actions) | native search/fetch + skill | 5 |
|
|
41
|
-
| Tests |
|
|
41
|
+
| Tests | 50 files / 664 cases, locally verified | no test script in `package.json` | 774 unit + 94 bench, self-reported | Vitest configured; count not published | Vitest configured; count not published |
|
|
42
42
|
| GitHub stars | 0 | 620 | 77 | 836 | 663 |
|
|
43
43
|
| npm downloads, last month | 1,087 | 52,436 | 6,420 | 43,151 | 9,251 |
|
|
44
|
-
| npm unpacked size |
|
|
44
|
+
| npm unpacked size | 1.1 MB | 0.70 MB | 3.05 MB | 0.51 MB | 0.27 MB |
|
|
45
45
|
|
|
46
46
|
This is a capability snapshot, not a league table with one winner. The honest
|
|
47
47
|
read is:
|
|
@@ -49,7 +49,7 @@ read is:
|
|
|
49
49
|
- **Feature depth:** upper-middle. `dsh-free-search` has more engines and
|
|
50
50
|
verticals; `dsh-web-search-pro` has a deeper evidence/ranking pipeline and far
|
|
51
51
|
more platform backends; `modsearch` is the stronger cross-host bridge.
|
|
52
|
-
- **Engineering and verification:** near the top.
|
|
52
|
+
- **Engineering and verification:** near the top. 664 local tests, a replayable
|
|
53
53
|
ranking benchmark, declared security boundaries and one runtime dependency
|
|
54
54
|
put it alongside the best-maintained entries, while remaining much smaller
|
|
55
55
|
than the Playwright-heavy option.
|
|
@@ -57,9 +57,9 @@ read is:
|
|
|
57
57
|
Chrome, PostgreSQL and AI Act paths and the 34-source vertical layer are not
|
|
58
58
|
common in the other plugins.
|
|
59
59
|
- **Adoption and maturity:** bottom third of this sample. The public npm release
|
|
60
|
-
is 0.
|
|
61
|
-
|
|
62
|
-
- **Tool-surface economy:** now competitive. 0.20.
|
|
60
|
+
is 0.20.1, matching this tree, but the GitHub repository is four days old
|
|
61
|
+
with no stars and little independent adoption.
|
|
62
|
+
- **Tool-surface economy:** now competitive. 0.20.x exposes one `web_tools`
|
|
63
63
|
entry with eight actions, close to `dsh-web-search-pro`'s two tools with 20
|
|
64
64
|
actions; the legacy eight-name surface remains opt-in for old prompts.
|
|
65
65
|
|
|
@@ -304,8 +304,8 @@ Each line is the plain version first, the technical note second. The technical n
|
|
|
304
304
|
*Technical: proxy sources in order — the `proxy` setting, then `DSH_WEB_SEARCH_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `HTTP_PROXY`, then macOS `scutil --proxy`; HTTP proxies only (`CONNECT`), not `socks5://`.*
|
|
305
305
|
|
|
306
306
|
14. **Every setting is editable in the UI.**
|
|
307
|
-
|
|
308
|
-
*Technical: all
|
|
307
|
+
Thirty controls in six groups; a save takes effect on the next search, apart from `cachePersist` and `cacheFile` (cache wiring at mount) and `toolSurface` (the tool registry is built at mount).
|
|
308
|
+
*Technical: all thirty fields carry `.volatile()`, so the Host commits them in place instead of remounting the plugin; `cacheTtlMs` and `cacheEntries` are re-read per use, `fetchFormat` and `fetchMaxLength` are resolved per request, `renderJs` and `renderTimeoutMs` per fetch; `proxy` and `timeoutMs` are taken at mount, and so is the cache wiring that `cachePersist` and `cacheFile` decide. `toolSurface` is read at mount when the registry is built, so a change needs a reload even though the value is committed live.*
|
|
309
309
|
|
|
310
310
|
15. **Failures are explained, not silently empty.**
|
|
311
311
|
When nothing succeeds, the error lists which engines were tried and why each one failed.
|
|
@@ -405,7 +405,7 @@ via an optional `onPage` sink.*
|
|
|
405
405
|
|
|
406
406
|
## Tool surface: one entry point, eight actions
|
|
407
407
|
|
|
408
|
-
0.20.
|
|
408
|
+
0.20.x changes the model-facing surface. The eight capabilities above are now
|
|
409
409
|
actions on one `web_tools` tool instead of eight separate registrations. A call
|
|
410
410
|
looks like:
|
|
411
411
|
|
|
@@ -444,14 +444,26 @@ Use an npm install, not a `link:`/local checkout:
|
|
|
444
444
|
dsh plugin --profile web add @fffangchenghao/dsh-web-search@latest
|
|
445
445
|
```
|
|
446
446
|
|
|
447
|
-
Then keep
|
|
448
|
-
|
|
447
|
+
Then keep a profile updater such as `dsh-autoupdater` (or
|
|
448
|
+
`dsh-self-upgrade`) enabled. The updater checks the npm dist-tag,
|
|
449
449
|
updates in an idle window, and asks for a restart on desktop. `link:` and
|
|
450
450
|
`file:` installs are deliberately skipped by such updaters because replacing a
|
|
451
451
|
local checkout with the registry package would destroy the checkout.
|
|
452
452
|
|
|
453
|
-
The Settings card always shows the latest npm version
|
|
454
|
-
|
|
453
|
+
The Settings card always shows the latest npm version. If it is newer and the
|
|
454
|
+
page is local, it also shows **Install update**. That button delegates to the
|
|
455
|
+
Host's built-in `pluginManager` (the same service `dsh plugin` uses), installs
|
|
456
|
+
the exact npm package and tells you to restart. It works **without**
|
|
457
|
+
`dsh-autoupdater`; what it does not do is run periodically. The remote web
|
|
458
|
+
surface hides the button, and a `link:`/`file:` checkout is refused before it
|
|
459
|
+
can be replaced. If the deployment has no plugin manager, the button reports
|
|
460
|
+
that instead of pretending to update.
|
|
461
|
+
|
|
462
|
+
Automatic updates trade review for freshness: the updater installs the
|
|
463
|
+
registry package without a human reading the diff. If that trade is wrong for
|
|
464
|
+
your deployment, pin an exact version and leave the profile updater off. The
|
|
465
|
+
plugin never spawns `pnpm` itself; the manual button only asks the Host to do
|
|
466
|
+
it.
|
|
455
467
|
|
|
456
468
|
## Installing and enabling it
|
|
457
469
|
|
|
@@ -559,7 +571,7 @@ Values saved from the Settings page apply immediately; only `cachePersist` and `
|
|
|
559
571
|
|
|
560
572
|
Any one of these:
|
|
561
573
|
|
|
562
|
-
1. **Look at Settings**: Settings → "Web search (Bing)" should show
|
|
574
|
+
1. **Look at Settings**: Settings → "Web search (Bing)" should show six groups of controls, 30 in all. That means the plugin loaded and the Host accepted its schema.
|
|
563
575
|
2. **Look at the log**: no warning such as `1 entry did not activate`.
|
|
564
576
|
3. **Just try it**: ask something that obviously needs the network, such as "search for a DSH plugin tutorial and give me the links". Watch whether `web_search` is called and whether the links are real.
|
|
565
577
|
|
|
@@ -567,7 +579,7 @@ If the Settings card appears but search still fails, start with [docs/troublesho
|
|
|
567
579
|
|
|
568
580
|
## Using the Settings page
|
|
569
581
|
|
|
570
|
-
Open Settings → "Web search (Bing)".
|
|
582
|
+
Open Settings → "Web search (Bing)". Thirty controls, arranged in six groups, plus an **Engine health** check. A sticky jump bar at the top scrolls to any group, and a line under the title compares the installed version with the latest one on npm (it stays hidden when the registry cannot be reached, so it never guesses). Each group owns one kind of decision:
|
|
571
583
|
|
|
572
584
|
| Group | Controls | What it decides |
|
|
573
585
|
| --- | --- | --- |
|
|
@@ -576,6 +588,7 @@ Open Settings → "Web search (Bing)". Twenty-nine controls, arranged in five gr
|
|
|
576
588
|
| Dedicated search | 3 | Which sources `domain_search` queries, results per source, deadline per source |
|
|
577
589
|
| Fetching | 4 | What `web_fetch` returns — Markdown or plain text, how many characters, whether a browser may render a shell, and how long that render may take |
|
|
578
590
|
| Cache and cooldowns | 6 | How long results are remembered, how many, whether the cache is saved to disk, and how long a throttled engine rests |
|
|
591
|
+
| Model tools | 1 | Whether the eight optional capabilities appear as one `web_tools` action tool or the legacy eight names. Requires a reload |
|
|
579
592
|
|
|
580
593
|
### Engines and transport (9)
|
|
581
594
|
|
|
@@ -631,9 +644,15 @@ Open Settings → "Web search (Bing)". Twenty-nine controls, arranged in five gr
|
|
|
631
644
|
| Cooldown (ms) | `baseCooldownMs` | `300000` | First rest after throttling, five minutes |
|
|
632
645
|
| Max cooldown (ms) | `maxCooldownMs` | `1800000` | Ceiling for the doubling backoff, thirty minutes |
|
|
633
646
|
|
|
647
|
+
### Model tools (1)
|
|
648
|
+
|
|
649
|
+
| Control | Key | Default | Plain meaning |
|
|
650
|
+
| --- | --- | --- | --- |
|
|
651
|
+
| Tool surface | `toolSurface` | `unified` | `unified` registers one `web_tools` with eight actions; `legacy` keeps the old eight standalone names for existing prompts. Changing it builds a different registry, so reload the plugin after saving |
|
|
652
|
+
|
|
634
653
|
### My advice
|
|
635
654
|
|
|
636
|
-
**For normal use: leave all
|
|
655
|
+
**For normal use: leave all thirty alone. The defaults are the tuned values.**
|
|
637
656
|
|
|
638
657
|
Only these situations are worth changing:
|
|
639
658
|
|
package/README.zh-CN.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
11
11
|
<a href="https://www.npmjs.com/package/@fffangchenghao/dsh-web-search"><img src="https://img.shields.io/npm/v/@fffangchenghao/dsh-web-search.svg" alt="npm 版本"></a>
|
|
12
|
-
<img src="https://img.shields.io/badge/tests-
|
|
12
|
+
<img src="https://img.shields.io/badge/tests-664%20passing-brightgreen" alt="测试">
|
|
13
13
|
<img src="https://img.shields.io/badge/engines-8%2C%20zero%20API%20key-brightgreen" alt="引擎">
|
|
14
14
|
<img src="https://img.shields.io/badge/node-%3E%3D22.18-blue" alt="node">
|
|
15
15
|
<img src="https://img.shields.io/badge/dsh-%3E%3D0.2.1--rc.2%20%3C0.3.0-blueviolet" alt="dsh">
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- **不要 API key,八个引擎。** AnySearch、必应中国、DuckDuckGo HTML、必应国际、DuckDuckGo Lite、360 搜索直接抓取;Exa 走它的免密钥 MCP 通道加入主引擎,Firecrawl 的搜索 API 作为实测后的兜底。装好就能用。
|
|
22
22
|
- **排序是量出来的,不是写出来的。** 跨引擎 RRF 融合,叠加权威度与时效加权;20 条离线基准 + 81 组参数扫描,是这类插件里少数同时公开指标、逐条输出和置信区间的。方法见 [排序是怎么做的](docs/rrf-ranking.md)。
|
|
23
23
|
- **抓取会承认失败。** 二进制文档和「200 但正文为空」会被明确拒绝(`SEARCH_UNSUPPORTED`、`SEARCH_EMPTY`),而不是当噪音返回;direct → tunnel → render → extract 四级阶梯共享 25 秒预算,预算不足就不再起新的一级。预算是「每次请求」而不是「插件启动时」,这点有回归测试守着。
|
|
24
|
-
- **
|
|
24
|
+
- **50 个测试文件、664 个用例**,`lib/` 产物入库,声明了 `engines.dsh` / `engines.node`,[SECURITY.md](SECURITY.md) 逐项列出插件会碰的进程、主机和文件。
|
|
25
25
|
- **双语文档。** 本文件和 [English README](README.md) 同步维护。
|
|
26
26
|
|
|
27
27
|

|
|
@@ -38,23 +38,23 @@ DSH 插件生态里的「联网搜索」已经很挤。下面是一张 2026-10-2
|
|
|
38
38
|
| 免 key 路径 | 8 个引擎,全部免 key | ~30 个免费/付费引擎链 | 默认 5 个(seam、Exa、DDG、Bing、Jina) | Firecrawl + Keenable 免 key 默认 | 1 个 AnySearch 匿名 API |
|
|
39
39
|
| 专门数据源 | 34 个(默认开 8 个) | 41 个 | 平台注册表,不是垂直源目录 | 网页 + X,无垂直源目录 | AnySearch 的垂直 API |
|
|
40
40
|
| 面向模型的工具 | 1 个(`web_tools`,8 个 action) | ~10 个 | 2 个(`web_index` / `web_call`,20 个动作) | 原生搜索/抓取 + skill | 5 个 |
|
|
41
|
-
| 测试 |
|
|
41
|
+
| 测试 | 50 文件 / 664 用例,本地实测 | `package.json` 无测试脚本 | 774 单元 + 94 bench,自报 | 配了 Vitest,未公布数量 | 配了 Vitest,未公布数量 |
|
|
42
42
|
| GitHub stars | 0 | 620 | 77 | 836 | 663 |
|
|
43
43
|
| npm 近一月下载 | 1,087 | 52,436 | 6,420 | 43,151 | 9,251 |
|
|
44
|
-
| npm 解包大小 |
|
|
44
|
+
| npm 解包大小 | 1.1 MB | 0.70 MB | 3.05 MB | 0.51 MB | 0.27 MB |
|
|
45
45
|
|
|
46
46
|
这不是「只有一个冠军」的排行榜,比较诚实的结论是:
|
|
47
47
|
|
|
48
48
|
- **功能深度:中上。** `dsh-free-search` 引擎和垂直源更多;
|
|
49
49
|
`dsh-web-search-pro` 的证据/排序管线和平台后端更深;`modsearch` 的跨宿主
|
|
50
50
|
能力更强。
|
|
51
|
-
- **工程质量与可验证性:接近第一梯队。**
|
|
51
|
+
- **工程质量与可验证性:接近第一梯队。** 664 个本地测试、可重放的排序基准、
|
|
52
52
|
明确的安全边界、只有 1 个运行时依赖,同时体积远小于 Playwright 重型方案。
|
|
53
53
|
- **免 key + 官方源纠错:最强卖点。** Chrome、PostgreSQL、AI Act 的官方路径
|
|
54
54
|
和 34 个垂直源,不是其他插件普遍具备的。
|
|
55
|
-
- **采用度与成熟度:这个样本里的后段。** 公开 npm
|
|
56
|
-
|
|
57
|
-
- **工具面的经济性:现在有竞争力。** 0.20.
|
|
55
|
+
- **采用度与成熟度:这个样本里的后段。** 公开 npm 已是 0.20.1,与这棵树一致;但 GitHub 仓库创建 4 天、0 stars,
|
|
56
|
+
还缺少独立采用。
|
|
57
|
+
- **工具面的经济性:现在有竞争力。** 0.20.x 只暴露一个 `web_tools` + 8 个
|
|
58
58
|
action,接近 `dsh-web-search-pro` 的 2 工具 + 20 动作;旧的八个工具名保留为
|
|
59
59
|
可选兼容模式。
|
|
60
60
|
|
|
@@ -297,8 +297,8 @@ Harness 里有个叫 `web` 的**服务**,它自己不会搜索,只负责「
|
|
|
297
297
|
*技术补充:代理来源依次是配置里的 `proxy`、环境变量 `DSH_WEB_SEARCH_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `HTTP_PROXY`、macOS 的 `scutil --proxy`;只支持 HTTP 代理(`CONNECT`),不支持 `socks5://`。*
|
|
298
298
|
|
|
299
299
|
14. **所有设置都能在界面上改,不用编辑文件。**
|
|
300
|
-
设置页有
|
|
301
|
-
*技术补充:
|
|
300
|
+
设置页有 30 个控件,分六组;保存后下一次搜索就生效;只有 `cachePersist` / `cacheFile`(决定缓存接线)和 `toolSurface`(工具注册表在挂载时构建)要重载插件。
|
|
301
|
+
*技术补充:30 个字段全部标了 `.volatile()`,Host 以 live commit 方式原地更新,不重挂载插件;`cacheTtlMs` 与 `cacheEntries` 每次使用都重读;抓取提供方在挂载时取走 `proxy`、`timeoutMs`、`fetchFormat`、`fetchMaxLength`;`renderJs` 与 `renderTimeoutMs` 每次抓取重读;缓存接线也在那时取走 `cachePersist` 与 `cacheFile`。*
|
|
302
302
|
|
|
303
303
|
15. **失败会解释原因,不会静默返回空。**
|
|
304
304
|
一家都没成功时,报错里会列出「试过哪些引擎、各自为什么失败」。
|
|
@@ -386,7 +386,7 @@ URL、摘要和能拿到的日期。兜底结果还会按平台域名过滤,
|
|
|
386
386
|
|
|
387
387
|
## 工具面:一个入口,八个动作
|
|
388
388
|
|
|
389
|
-
0.20.
|
|
389
|
+
0.20.x 改变了模型看到的工具面。上面的八种能力现在是同一个 `web_tools`
|
|
390
390
|
工具的不同 `action`,不再是八个独立注册。调用长这样:
|
|
391
391
|
|
|
392
392
|
```json
|
|
@@ -421,13 +421,21 @@ URL、摘要和能拿到的日期。兜底结果还会按平台域名过滤,
|
|
|
421
421
|
dsh plugin --profile web add @fffangchenghao/dsh-web-search@latest
|
|
422
422
|
```
|
|
423
423
|
|
|
424
|
-
然后保持
|
|
425
|
-
|
|
424
|
+
然后保持 `dsh-autoupdater`(或 `dsh-self-upgrade`)这类 profile
|
|
425
|
+
更新器开启。它会按计划检查 npm dist-tag,在空闲窗口更新,
|
|
426
426
|
桌面版提示重启。`link:`/`file:` 安装会被这类更新器主动跳过,因为用 registry
|
|
427
427
|
包替换本地 checkout 会破坏开发目录。
|
|
428
428
|
|
|
429
|
-
设置页会显示 npm
|
|
430
|
-
|
|
429
|
+
设置页会显示 npm 最新版。如果它比当前版本新,且页面在本地,还会显示
|
|
430
|
+
**安装更新**按钮。这个按钮不是自己跑 pnpm,而是调用 DSH 内置的
|
|
431
|
+
`pluginManager`(和 `dsh plugin` 同一条路径)安装精确的 npm 包,然后提示重启。
|
|
432
|
+
它**不依赖 `dsh-autoupdater`**;它只是手动的,不会定时轮询。远程 Web 页面
|
|
433
|
+
不显示按钮;`link:`/`file:` 安装会在替换前被拒绝。如果部署没有插件管理器,
|
|
434
|
+
按钮会明确报错,而不是假装更新成功。
|
|
435
|
+
|
|
436
|
+
自动更新是用「少一次人工 review」换「更快拿到修复」:更新器会直接安装 registry
|
|
437
|
+
包,不会等人读 diff。如果你的部署不能接受这个交换,就固定精确版本并关掉
|
|
438
|
+
profile 更新器。插件本身从不 fork/exec `pnpm`;手动按钮只是请 Host 执行安装。
|
|
431
439
|
|
|
432
440
|
## 安装与启用
|
|
433
441
|
|
|
@@ -535,7 +543,7 @@ pnpm install
|
|
|
535
543
|
|
|
536
544
|
三个办法,任选:
|
|
537
545
|
|
|
538
|
-
1. **看设置页**:设置 → 「网页搜索(Bing
|
|
546
|
+
1. **看设置页**:设置 → 「网页搜索(Bing)」,能看到六组、共 30 个控件,说明插件被加载了,schema 也被 Host 收录了。
|
|
539
547
|
2. **看日志**:启动日志里没有 `1 entry did not activate` 这类警告。
|
|
540
548
|
3. **直接试**:问一个明显需要联网的问题,比如「帮我搜一下 DSH 插件开发教程,给我链接」。看模型有没有调用 `web_search`,返回的链接是不是真实可达。
|
|
541
549
|
|
|
@@ -543,7 +551,7 @@ pnpm install
|
|
|
543
551
|
|
|
544
552
|
## 设置页怎么用
|
|
545
553
|
|
|
546
|
-
打开 设置 → 「网页搜索(Bing)」。页面上一共
|
|
554
|
+
打开 设置 → 「网页搜索(Bing)」。页面上一共 30 个控件,按六组排列,外加一个**引擎健康**检查。顶部有一条随滚动固定的跳转栏,点组名直接跳过去;标题下还会拿当前版本和 npm 上的最新版比一下(连不上 npm 时这行不显示,不会瞎猜)。每组只管一类事:
|
|
547
555
|
|
|
548
556
|
| 组 | 控件数 | 这组管什么 |
|
|
549
557
|
| --- | --- | --- |
|
|
@@ -552,6 +560,7 @@ pnpm install
|
|
|
552
560
|
| 专用检索 | 3 | `domain_search` 查哪些源、每个源返回几条、每个源等多久 |
|
|
553
561
|
| 抓取 | 4 | `web_fetch` 返回 Markdown 还是纯文本、最多返回多少字符、要不要用浏览器渲染空壳页面、渲染最多等多久 |
|
|
554
562
|
| 缓存与冷却 | 6 | 结果记多久、记多少条、要不要写进硬盘、被限流后歇多久 |
|
|
563
|
+
| 模型工具 | 1 | 八种可选能力是统一成一个 `web_tools`,还是保留旧的八个工具名;切换后要重载 |
|
|
555
564
|
|
|
556
565
|
### 引擎与传输(9 个)
|
|
557
566
|
|
|
@@ -607,9 +616,15 @@ pnpm install
|
|
|
607
616
|
| 被拒后歇多久 | `baseCooldownMs` | `300000` | 被限流后第一次歇多久,5 分钟 |
|
|
608
617
|
| 歇息上限 | `maxCooldownMs` | `1800000` | 连续失败时冷却翻倍的上限,30 分钟 |
|
|
609
618
|
|
|
619
|
+
### 模型工具(1 个)
|
|
620
|
+
|
|
621
|
+
| 控件 | 配置键 | 默认 | 人话 |
|
|
622
|
+
| --- | --- | --- | --- |
|
|
623
|
+
| 工具面 | `toolSurface` | `unified` | `unified` 只注册一个 `web_tools`,用八个 action;`legacy` 保留旧的八个独立工具名,兼容旧提示词。切换会重建注册表,保存后要重载插件 |
|
|
624
|
+
|
|
610
625
|
### 给你的建议
|
|
611
626
|
|
|
612
|
-
**只想正常用:
|
|
627
|
+
**只想正常用:30 个控件全都别改,默认值就是调过的。**
|
|
613
628
|
|
|
614
629
|
只有这些情况值得动:
|
|
615
630
|
|
package/client.js
CHANGED
|
@@ -39,6 +39,33 @@
|
|
|
39
39
|
var React = require('react');
|
|
40
40
|
var h = React.createElement;
|
|
41
41
|
|
|
42
|
+
/** Compare dotted versions without treating a local build as older. */
|
|
43
|
+
function isNewerVersion(candidate, current) {
|
|
44
|
+
try {
|
|
45
|
+
var a = String(candidate).split('-')[0].split('.').map(function (part) { return Number(part); });
|
|
46
|
+
var b = String(current).split('-')[0].split('.').map(function (part) { return Number(part); });
|
|
47
|
+
var length = Math.max(a.length, b.length);
|
|
48
|
+
for (var i = 0; i < length; i += 1) {
|
|
49
|
+
var left = a[i] === undefined || !isFinite(a[i]) ? 0 : a[i];
|
|
50
|
+
var right = b[i] === undefined || !isFinite(b[i]) ? 0 : b[i];
|
|
51
|
+
if (left !== right) return left > right;
|
|
52
|
+
}
|
|
53
|
+
return String(candidate).indexOf('-') === -1 && String(current).indexOf('-') !== -1;
|
|
54
|
+
} catch (ignored) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The one-click updater route only exists on the local desktop surface. */
|
|
60
|
+
function isLocalPage() {
|
|
61
|
+
try {
|
|
62
|
+
var host = window.location.hostname;
|
|
63
|
+
return host === '127.0.0.1' || host === 'localhost' || host === '::1' || host === '[::1]';
|
|
64
|
+
} catch (ignored) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
42
69
|
/** Dictionary namespace owned by this plugin. */
|
|
43
70
|
var NS = 'webSearchBing';
|
|
44
71
|
/** The Settings surface slot: one settings page per list entry. */
|
|
@@ -47,7 +74,7 @@
|
|
|
47
74
|
var ENTRY = 'web-search-bing';
|
|
48
75
|
var PACKAGE_NAME = 'dsh-web-search-bing';
|
|
49
76
|
/** Keep in step with package.json; compared with the npm registry. */
|
|
50
|
-
var VERSION = '0.20.
|
|
77
|
+
var VERSION = '0.20.1';
|
|
51
78
|
/** Snapshot used while no configuration service is reachable. */
|
|
52
79
|
var EMPTY_STATE = { status: 'unavailable', value: undefined, base: undefined, user: undefined, revision: undefined, writable: false };
|
|
53
80
|
|
|
@@ -167,7 +194,15 @@
|
|
|
167
194
|
title: '网页搜索(Bing)',
|
|
168
195
|
jumpTo: '跳到',
|
|
169
196
|
latest: 'npm 最新版',
|
|
170
|
-
autoUpdateHint: '
|
|
197
|
+
autoUpdateHint: '定时自动更新需要 profile 更新器(dsh-autoupdater);「安装更新」按钮不依赖它:它会请 Host 插件管理器安装 npm 包,装完需重启。link:/file: 安装会被拒绝。',
|
|
198
|
+
updateButton: '安装更新',
|
|
199
|
+
updateInstalling: '正在安装…请保持此页打开。',
|
|
200
|
+
updateDone: '更新已安装。',
|
|
201
|
+
updateRestart: '更新已安装;重启 DeepSeek Harness 后生效。',
|
|
202
|
+
updateFailed: '更新失败:',
|
|
203
|
+
updateLocal: '当前是 link:/file: 安装。请先改成 npm 安装,再使用这个按钮。',
|
|
204
|
+
updateRemote: '更新按钮只在本地桌面 App 中可用。',
|
|
205
|
+
updateUnavailable: '当前部署没有内置插件管理器;请用 profile 的包管理器更新。',
|
|
171
206
|
upToDate: '已是最新',
|
|
172
207
|
updateAvailable: '有新版本',
|
|
173
208
|
description: '编辑免密钥搜索提供方:引擎白名单、等待策略、代理、结果上限、排序、缓存、冷却与专用检索源。模型工具:web_search、web_fetch,以及一个统一的 web_tools action 工具(旧版八个工具名可选)。',
|
|
@@ -531,6 +566,9 @@
|
|
|
531
566
|
var testPair = React.useState({ phase: 'idle', value: null, error: null });
|
|
532
567
|
var test = testPair[0];
|
|
533
568
|
var setTest = testPair[1];
|
|
569
|
+
var installPair = React.useState({ phase: 'idle', message: '', version: '' });
|
|
570
|
+
var installation = installPair[0];
|
|
571
|
+
var setInstallation = installPair[1];
|
|
534
572
|
|
|
535
573
|
// Ask the npm registry once per mount. A failure (offline, proxy
|
|
536
574
|
// down, registry error) hides the line instead of showing an
|
|
@@ -556,6 +594,47 @@
|
|
|
556
594
|
setErrors({});
|
|
557
595
|
}, [state.revision]);
|
|
558
596
|
|
|
597
|
+
function installUpdate() {
|
|
598
|
+
if (installation.phase === 'working') return;
|
|
599
|
+
setInstallation({ phase: 'working', message: '', version: '' });
|
|
600
|
+
try {
|
|
601
|
+
fetch('/api/dsh-web-search/update', {
|
|
602
|
+
method: 'POST',
|
|
603
|
+
headers: { 'content-type': 'application/json' },
|
|
604
|
+
body: '{}'
|
|
605
|
+
}).then(function (response) {
|
|
606
|
+
return response.json().then(function (body) {
|
|
607
|
+
return { status: response.status, body: body };
|
|
608
|
+
}, function () {
|
|
609
|
+
return { status: response.status, body: null };
|
|
610
|
+
});
|
|
611
|
+
}).then(function (out) {
|
|
612
|
+
var body = out.body;
|
|
613
|
+
if (out.status === 200 && body !== null && body.ok === true) {
|
|
614
|
+
setInstallation({
|
|
615
|
+
phase: body.restartRequired === true ? 'restart' : 'done',
|
|
616
|
+
message: '',
|
|
617
|
+
version: typeof body.version === 'string' ? body.version : ''
|
|
618
|
+
});
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
var code = body === null ? '' : body.code;
|
|
622
|
+
var message = code === 'local-install'
|
|
623
|
+
? t('updateLocal')
|
|
624
|
+
: code === 'manager-unavailable' || out.status === 404 || out.status === 405
|
|
625
|
+
? t('updateUnavailable')
|
|
626
|
+
: body !== null && typeof body.message === 'string'
|
|
627
|
+
? body.message
|
|
628
|
+
: t('updateFailed') + 'HTTP ' + out.status;
|
|
629
|
+
setInstallation({ phase: 'failed', message: message, version: '' });
|
|
630
|
+
}, function (error) {
|
|
631
|
+
setInstallation({ phase: 'failed', message: String(error), version: '' });
|
|
632
|
+
});
|
|
633
|
+
} catch (error) {
|
|
634
|
+
setInstallation({ phase: 'failed', message: String(error), version: '' });
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
559
638
|
var ready = form !== null && form !== undefined && state.status === 'ready';
|
|
560
639
|
var values = ready && state.value !== null && typeof state.value === 'object' ? state.value : {};
|
|
561
640
|
var current = draft === null ? toDraft(values) : draft;
|
|
@@ -645,7 +724,7 @@
|
|
|
645
724
|
h('p', { key: 'description', style: { margin: 0, fontSize: '13px', lineHeight: 1.5, color: 'var(--dsw-alias-label-tertiary)' } }, t('description'))
|
|
646
725
|
];
|
|
647
726
|
if (latest !== null) {
|
|
648
|
-
var newer = latest
|
|
727
|
+
var newer = isNewerVersion(latest, VERSION);
|
|
649
728
|
children.push(h('p', {
|
|
650
729
|
key: 'latest',
|
|
651
730
|
style: { margin: 0, fontSize: '12px', color: newer ? 'var(--dsw-alias-state-warn-primary)' : 'var(--dsw-alias-label-tertiary)' },
|
|
@@ -654,6 +733,43 @@
|
|
|
654
733
|
children.push(h('p', {
|
|
655
734
|
key: 'auto-update', style: { margin: 0, fontSize: '11px', lineHeight: 1.5, color: 'var(--dsw-alias-label-tertiary)' }, role: 'note'
|
|
656
735
|
}, t('autoUpdateHint')));
|
|
736
|
+
if (newer) {
|
|
737
|
+
if (isLocalPage()) {
|
|
738
|
+
children.push(h('button', {
|
|
739
|
+
key: 'install-update',
|
|
740
|
+
type: 'button',
|
|
741
|
+
disabled: installation.phase === 'working',
|
|
742
|
+
onClick: installUpdate,
|
|
743
|
+
style: {
|
|
744
|
+
alignSelf: 'flex-start',
|
|
745
|
+
padding: '5px 10px',
|
|
746
|
+
borderRadius: '6px',
|
|
747
|
+
border: '1px solid var(--dsw-alias-border-l1)',
|
|
748
|
+
background: 'var(--dsw-alias-bg-base)',
|
|
749
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
750
|
+
cursor: installation.phase === 'working' ? 'wait' : 'pointer',
|
|
751
|
+
fontSize: '12px'
|
|
752
|
+
}
|
|
753
|
+
}, installation.phase === 'working' ? t('updateInstalling') : t('updateButton')));
|
|
754
|
+
} else {
|
|
755
|
+
children.push(h('p', {
|
|
756
|
+
key: 'update-remote', style: { margin: 0, fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)' }
|
|
757
|
+
}, t('updateRemote')));
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (installation.phase === 'working') {
|
|
761
|
+
children.push(h('p', {
|
|
762
|
+
key: 'update-status', style: { margin: 0, fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)' }, role: 'status', 'aria-live': 'polite'
|
|
763
|
+
}, t('updateInstalling')));
|
|
764
|
+
} else if (installation.phase === 'restart' || installation.phase === 'done') {
|
|
765
|
+
children.push(h('p', {
|
|
766
|
+
key: 'update-status', style: { margin: 0, fontSize: '12px', color: 'var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary))' }, role: 'status'
|
|
767
|
+
}, t(installation.phase === 'restart' ? 'updateRestart' : 'updateDone') + (installation.version === '' ? '' : ' (' + installation.version + ')')));
|
|
768
|
+
} else if (installation.phase === 'failed') {
|
|
769
|
+
children.push(h('p', {
|
|
770
|
+
key: 'update-status', style: { margin: 0, fontSize: '12px', color: 'var(--dsw-alias-state-warn-primary)' }, role: 'alert'
|
|
771
|
+
}, t('updateFailed') + installation.message));
|
|
772
|
+
}
|
|
657
773
|
}
|
|
658
774
|
|
|
659
775
|
if (!ready) {
|
package/docs/store-evidence.md
CHANGED
|
@@ -23,7 +23,7 @@ Only `0.2.1-rc.2` is declared, because that is the version actually exercised.
|
|
|
23
23
|
## Environment
|
|
24
24
|
|
|
25
25
|
- macOS (arm64), DeepSeek Harness **0.2.1-rc.2** (`dsh --version`), Node 22.18+.
|
|
26
|
-
- Runtime artifacts: `lib/` is committed to this repository (
|
|
26
|
+
- Runtime artifacts: `lib/` is committed to this repository (78 files, 900 KiB),
|
|
27
27
|
so the fixed commit's tree contains `lib/index.js` and `lib/index.d.ts`.
|
|
28
28
|
- Disposable profile for the destructive steps: a fresh `DSH_HOME` created with
|
|
29
29
|
`mktemp -d`; the real `~/.dsh` was never written to. Bundled pnpm 11.28.5.
|
package/lib/bridge.d.ts
CHANGED
|
@@ -2,11 +2,29 @@ import type { EngineTestRunner } from './engine-test.ts';
|
|
|
2
2
|
import type { InjectableHost, ServiceContext } from './inject.ts';
|
|
3
3
|
/** Route prefix the client fetches; kept stable for the shipped settings page. */
|
|
4
4
|
export declare const ENGINE_TEST_BRIDGE_PATH = "/api/dsh-web-search/engine-test";
|
|
5
|
+
/** Settings-page update button; the only package it may install is this one. */
|
|
6
|
+
export declare const UPDATE_BRIDGE_PATH = "/api/dsh-web-search/update";
|
|
7
|
+
/** Exact package this bridge is allowed to install. */
|
|
8
|
+
export declare const OWN_PACKAGE_NAME = "@fffangchenghao/dsh-web-search";
|
|
5
9
|
/** The injected services this bridge needs; `webServer` may be absent. */
|
|
6
10
|
export type BridgeContext = ServiceContext;
|
|
11
|
+
/** A context that can inject the web server and may look up the plugin manager. */
|
|
12
|
+
export type UpdateContext = InjectableHost & Pick<InjectableHost, 'get'>;
|
|
7
13
|
/** A context that may support `inject`; test hosts often do not. */
|
|
8
14
|
export type InjectableContext = InjectableHost;
|
|
9
15
|
export type { WebServerLike } from './inject.ts';
|
|
16
|
+
/**
|
|
17
|
+
* The Settings page's update button.
|
|
18
|
+
*
|
|
19
|
+
* It deliberately does not run a package manager itself: the host's own
|
|
20
|
+
* `pluginManager` owns the profile lock and the pnpm invocation. The bridge
|
|
21
|
+
* only accepts this package, refuses a local link/file install, and reports
|
|
22
|
+
* that a restart is required. The model tool path is untouched.
|
|
23
|
+
*
|
|
24
|
+
* @param ctx - injectable plugin context.
|
|
25
|
+
* @returns a disposer, or `undefined` when the host has no injectable server.
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerUpdateBridge(ctx: UpdateContext): (() => void) | undefined;
|
|
10
28
|
/**
|
|
11
29
|
* Register the engine-test endpoint.
|
|
12
30
|
* @param ctx - injectable plugin context.
|
package/lib/bridge.js
CHANGED
|
@@ -2,6 +2,10 @@ import { runEngineTestValue } from "./engine-test.js";
|
|
|
2
2
|
import { HOSTS } from "./engines.js";
|
|
3
3
|
/** Route prefix the client fetches; kept stable for the shipped settings page. */
|
|
4
4
|
export const ENGINE_TEST_BRIDGE_PATH = '/api/dsh-web-search/engine-test';
|
|
5
|
+
/** Settings-page update button; the only package it may install is this one. */
|
|
6
|
+
export const UPDATE_BRIDGE_PATH = '/api/dsh-web-search/update';
|
|
7
|
+
/** Exact package this bridge is allowed to install. */
|
|
8
|
+
export const OWN_PACKAGE_NAME = '@fffangchenghao/dsh-web-search';
|
|
5
9
|
/** Largest request body the bridge will read. */
|
|
6
10
|
const MAX_BODY_BYTES = 16 * 1024;
|
|
7
11
|
/** Whether an address is loopback. */
|
|
@@ -95,6 +99,147 @@ function parseBody(body) {
|
|
|
95
99
|
...(query === undefined ? {} : { query: query.trim() }),
|
|
96
100
|
};
|
|
97
101
|
}
|
|
102
|
+
/** A local checkout must never be replaced by the registry package. */
|
|
103
|
+
function isLocalSource(source) {
|
|
104
|
+
return typeof source === 'string' && /(?:^|@)(?:link|file|workspace):/iu.test(source);
|
|
105
|
+
}
|
|
106
|
+
/** Read the plugin manager from the injected context or the service registry. */
|
|
107
|
+
function managerOf(ctx, services) {
|
|
108
|
+
const injected = services.pluginManager;
|
|
109
|
+
if (injected !== undefined)
|
|
110
|
+
return injected;
|
|
111
|
+
if (typeof ctx.get !== 'function')
|
|
112
|
+
return undefined;
|
|
113
|
+
try {
|
|
114
|
+
const candidate = ctx.get('pluginManager');
|
|
115
|
+
if (typeof candidate !== 'object' || candidate === null)
|
|
116
|
+
return undefined;
|
|
117
|
+
const manager = candidate;
|
|
118
|
+
return typeof manager.listBundles === 'function' && typeof manager.installBundle === 'function'
|
|
119
|
+
? manager
|
|
120
|
+
: undefined;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** Human-readable failure from a manager result. */
|
|
127
|
+
function failureText(error) {
|
|
128
|
+
if (error === undefined)
|
|
129
|
+
return 'the plugin manager rejected the update';
|
|
130
|
+
return error.diagnostic ?? error.code ?? 'the plugin manager rejected the update';
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The Settings page's update button.
|
|
134
|
+
*
|
|
135
|
+
* It deliberately does not run a package manager itself: the host's own
|
|
136
|
+
* `pluginManager` owns the profile lock and the pnpm invocation. The bridge
|
|
137
|
+
* only accepts this package, refuses a local link/file install, and reports
|
|
138
|
+
* that a restart is required. The model tool path is untouched.
|
|
139
|
+
*
|
|
140
|
+
* @param ctx - injectable plugin context.
|
|
141
|
+
* @returns a disposer, or `undefined` when the host has no injectable server.
|
|
142
|
+
*/
|
|
143
|
+
export function registerUpdateBridge(ctx) {
|
|
144
|
+
if (typeof ctx.inject !== 'function')
|
|
145
|
+
return undefined;
|
|
146
|
+
try {
|
|
147
|
+
ctx.inject(['webServer'], (services) => {
|
|
148
|
+
const webServer = services?.webServer;
|
|
149
|
+
if (webServer === undefined || typeof webServer.register !== 'function')
|
|
150
|
+
return;
|
|
151
|
+
const mount = () => {
|
|
152
|
+
const off = webServer.register({
|
|
153
|
+
kind: 'exact',
|
|
154
|
+
path: UPDATE_BRIDGE_PATH,
|
|
155
|
+
async handler(request, response) {
|
|
156
|
+
if (request.method !== 'POST') {
|
|
157
|
+
writeJson(response, 405, { ok: false, code: 'method-not-allowed', message: 'POST only' });
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (!isAllowed(request)) {
|
|
161
|
+
writeJson(response, 403, { ok: false, code: 'forbidden', message: 'loopback settings only' });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const body = await readJson(request);
|
|
165
|
+
if (body === undefined || typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
166
|
+
writeJson(response, 400, { ok: false, code: 'invalid-json', message: 'body must be a JSON object' });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const manager = managerOf(ctx, services);
|
|
170
|
+
if (manager === undefined) {
|
|
171
|
+
writeJson(response, 503, {
|
|
172
|
+
ok: false,
|
|
173
|
+
code: 'manager-unavailable',
|
|
174
|
+
message: 'this deployment has no plugin manager; use the profile package manager instead',
|
|
175
|
+
});
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const bundles = await manager.listBundles();
|
|
180
|
+
const own = bundles.find((bundle) => bundle.name === OWN_PACKAGE_NAME && bundle.installed !== false);
|
|
181
|
+
if (own === undefined) {
|
|
182
|
+
writeJson(response, 409, {
|
|
183
|
+
ok: false,
|
|
184
|
+
code: 'not-installed',
|
|
185
|
+
message: 'this package is not an installed profile bundle',
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (isLocalSource(own.source)) {
|
|
190
|
+
writeJson(response, 409, {
|
|
191
|
+
ok: false,
|
|
192
|
+
code: 'local-install',
|
|
193
|
+
message: 'link:/file: installs are not replaced by the button; install from npm first',
|
|
194
|
+
});
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const result = await manager.installBundle(`${OWN_PACKAGE_NAME}@latest`, { saveExact: true });
|
|
198
|
+
if (result.application === 'failed' || result.application === 'cancelled') {
|
|
199
|
+
writeJson(response, 502, {
|
|
200
|
+
ok: false,
|
|
201
|
+
code: result.application,
|
|
202
|
+
message: failureText(result.error),
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
writeJson(response, 200, {
|
|
207
|
+
ok: true,
|
|
208
|
+
changed: result.changed,
|
|
209
|
+
application: result.application,
|
|
210
|
+
version: result.version ?? null,
|
|
211
|
+
restartRequired: result.application === 'restart-required',
|
|
212
|
+
message: result.changed
|
|
213
|
+
? result.application === 'restart-required'
|
|
214
|
+
? 'update installed; restart DeepSeek Harness to load it'
|
|
215
|
+
: 'update installed'
|
|
216
|
+
: 'already at the latest version',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
writeJson(response, 502, {
|
|
221
|
+
ok: false,
|
|
222
|
+
code: 'install-failed',
|
|
223
|
+
message: error instanceof Error ? error.message : String(error),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
return typeof off === 'function' ? off : undefined;
|
|
229
|
+
};
|
|
230
|
+
if (typeof services.effect === 'function')
|
|
231
|
+
services.effect(mount);
|
|
232
|
+
else
|
|
233
|
+
mount();
|
|
234
|
+
});
|
|
235
|
+
return () => {
|
|
236
|
+
// The injected disposer owns the route; nothing else to release here.
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
98
243
|
/**
|
|
99
244
|
* Register the engine-test endpoint.
|
|
100
245
|
* @param ctx - injectable plugin context.
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import { alternateOfficialUrl } from "./mirrors.js";
|
|
|
23
23
|
import { searchPlatforms } from "./platforms.js";
|
|
24
24
|
import { registerPlatformTool } from "./platform-tool.js";
|
|
25
25
|
import { registerEngineTestTool } from "./engine-test.js";
|
|
26
|
-
import { registerEngineTestBridge } from "./bridge.js";
|
|
26
|
+
import { registerEngineTestBridge, registerUpdateBridge } from "./bridge.js";
|
|
27
27
|
import { registerAdvancedSearchTool, undatedWindowNote } from "./advanced-search.js";
|
|
28
28
|
import { searchVerticals } from "./verticals.js";
|
|
29
29
|
import { routePackageQuery } from "./query-router.js";
|
|
@@ -290,7 +290,8 @@ export function apply(ctx, config = {}) {
|
|
|
290
290
|
...(mounted.proxy === undefined ? {} : { proxy: mounted.proxy }),
|
|
291
291
|
...(mounted.anysearchApiKey.length === 0 ? {} : { anysearchApiKey: mounted.anysearchApiKey }),
|
|
292
292
|
}));
|
|
293
|
-
// Optional half:
|
|
293
|
+
// Optional half: the eight capabilities exposed through `web_tools` (or the
|
|
294
|
+
// legacy names). Fail-safe by
|
|
294
295
|
// construction — a deployment without `ctx.tools` still loads this plugin and
|
|
295
296
|
// keeps `web_search`; the registration path is the host's
|
|
296
297
|
// `ToolRuntime.register(definition)`.
|
|
@@ -524,6 +525,9 @@ export function apply(ctx, config = {}) {
|
|
|
524
525
|
// gets one narrow loopback endpoint. The model-facing tool above stays the
|
|
525
526
|
// primary path; this bridge is best-effort and silent on hosts without it.
|
|
526
527
|
registerEngineTestBridge(ctx, runEngineTest);
|
|
528
|
+
// The Settings page also gets a one-click update path; it uses the host
|
|
529
|
+
// plugin manager rather than bundling a second updater.
|
|
530
|
+
registerUpdateBridge(ctx);
|
|
527
531
|
}
|
|
528
532
|
export { Config, resolveConfig } from "./config.js";
|
|
529
533
|
/**
|
package/lib/inject.d.ts
CHANGED
|
@@ -31,13 +31,38 @@ export interface SystemPromptSectionOptions {
|
|
|
31
31
|
export interface SystemPromptLike {
|
|
32
32
|
section(options: SystemPromptSectionOptions): unknown;
|
|
33
33
|
}
|
|
34
|
+
/** The slice of the host plugin manager the Settings update button needs. */
|
|
35
|
+
export interface PluginManagerLike {
|
|
36
|
+
/** Profile bundles, used to refuse a link:/file: install before replacing it. */
|
|
37
|
+
listBundles(): Promise<Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
installed?: boolean;
|
|
40
|
+
source?: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
}>>;
|
|
43
|
+
/** Install one exact bundle spec; the host persists it in the profile. */
|
|
44
|
+
installBundle(spec: string, options?: {
|
|
45
|
+
saveExact?: boolean;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
changed: boolean;
|
|
48
|
+
application: 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
|
|
49
|
+
version?: string;
|
|
50
|
+
error?: {
|
|
51
|
+
code?: string;
|
|
52
|
+
diagnostic?: string;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
34
56
|
/** Services that may arrive through one `ctx.inject` callback. */
|
|
35
57
|
export interface ServiceContext {
|
|
36
58
|
webServer?: WebServerLike;
|
|
37
59
|
systemPrompt?: SystemPromptLike;
|
|
60
|
+
pluginManager?: PluginManagerLike;
|
|
38
61
|
effect?: (execute: () => (() => void) | void) => unknown;
|
|
39
62
|
}
|
|
40
63
|
/** A context that may support Cordis's dynamic dependency injection. */
|
|
41
64
|
export interface InjectableHost {
|
|
42
65
|
inject?: (dependencies: string[], callback: (context: ServiceContext) => unknown) => unknown;
|
|
66
|
+
/** Optional service lookup for hosts that expose a manager outside inject. */
|
|
67
|
+
get?: (name: string) => unknown;
|
|
43
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fffangchenghao/dsh-web-search",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "DSH bundle: key-free web search, page fetch and one web_tools action tool for verticals, platforms and cited research; eight engines fused with RRF, 34 vertical sources, official-source checks and a replayable benchmark.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|