@fffangchenghao/dsh-web-search 0.23.0 → 0.24.0
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 +30 -0
- package/README.md +25 -5
- package/README.zh-CN.md +22 -5
- package/SECURITY.md +11 -6
- package/client.js +1 -1
- package/docs/images/web-tools-demo.svg +1 -1
- package/docs/quickstart.md +6 -0
- package/docs/store-evidence.md +6 -1
- package/lib/proxy.d.ts +16 -3
- package/lib/proxy.js +66 -18
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **Windows system-proxy detection.** When no explicit proxy or proxy
|
|
7
|
+
environment variable is set, the plugin reads `ProxyEnable` / `ProxyServer`
|
|
8
|
+
from the current user's Windows Internet Settings (`HKCU\...\Internet
|
|
9
|
+
Settings`) with a fixed, absolute `reg.exe` probe. A bare `host:port` and the
|
|
10
|
+
`http=...;https=...` map are both accepted; SOCKS-only and PAC-only settings
|
|
11
|
+
are left alone rather than guessed. macOS `scutil` behavior is unchanged.
|
|
12
|
+
- **Windows CI.** The GitHub Actions matrix now includes `windows-latest`; the
|
|
13
|
+
install, typecheck, full test suite, build and entry-point checks all pass on
|
|
14
|
+
Windows, macOS and Ubuntu (Node 24).
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **Cross-platform test command.** `npm test` now passes a quoted glob to
|
|
18
|
+
Node's test runner instead of relying on shell expansion, which cmd.exe does
|
|
19
|
+
not perform.
|
|
20
|
+
- **Windows cache path test.** The cache-path assertion uses the platform
|
|
21
|
+
temporary directory instead of a hard-coded `/tmp` path.
|
|
22
|
+
|
|
23
|
+
### Documentation
|
|
24
|
+
- **Windows install notes.** README, Chinese README and the quickstart document
|
|
25
|
+
the identical PowerShell command, the no-native-addon requirement, automatic
|
|
26
|
+
system-proxy detection, PAC-only fallback and the `%USERPROFILE%` cache path.
|
|
27
|
+
- **Security boundary updated.** [SECURITY.md](SECURITY.md) now lists the
|
|
28
|
+
Windows registry probe alongside the macOS `scutil` probe and records its
|
|
29
|
+
fixed argv, timeout and data access.
|
|
30
|
+
|
|
31
|
+
**Test suite: 690 tests across 56 files** (689 pass, 1 skipped).
|
|
32
|
+
|
|
3
33
|
## 0.23.0
|
|
4
34
|
|
|
5
35
|
### Added
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
12
|
<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>
|
|
13
|
-
<img src="https://img.shields.io/badge/tests-
|
|
13
|
+
<img src="https://img.shields.io/badge/tests-690%20tests-brightgreen" alt="tests">
|
|
14
14
|
<img src="https://img.shields.io/badge/engines-8%2C%20zero%20API%20key-brightgreen" alt="engines">
|
|
15
15
|
<img src="https://img.shields.io/badge/node-%3E%3D22.18-blue" alt="node">
|
|
16
16
|
<img src="https://img.shields.io/badge/dsh-%3E%3D0.2.1--rc.2%20%3C0.3.0-blueviolet" alt="dsh">
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
- **One package, two runtimes.** DSH gets the native plugin and one `web_tools` entry; Claude Code, Codex and other MCP clients get the same keyless search through a dependency-free stdio server with `search`, `fetch`, `research` and `domain_search`. See [Cross-agent MCP](docs/cross-agent.md).
|
|
28
28
|
- **Measured in public, including the losses.** A 30-query bilingual comparison records availability, latency, unique domains, official-domain presence and every failure against keyless Firecrawl and anonymous Exa. The follow-up documents the Exa architecture difference, the 3 s CJK budget and the Rust official-source lookup. Exa is faster here; this plugin returns more distinct domains. Both test arms were keyless. The method and raw results are in [docs/comparison.md](docs/comparison.md) and a [public gist](https://gist.github.com/fangchenghao/3db9838fa98928435c1c2df38202c373).
|
|
29
29
|
- **Fetching admits failure.** Binary documents and empty 200 responses are rejected by name (`SEARCH_UNSUPPORTED`, `SEARCH_EMPTY`) instead of being returned as noise; arXiv PDF links are the deliberate exception and are read through the HTML full-text view; 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.
|
|
30
|
-
- **
|
|
30
|
+
- **Windows is a first-class host.** Pure ESM, no native addon or install script; the system proxy is discovered from Windows Internet Settings, and the full suite runs on a `windows-latest` CI runner. See [Install on Windows](#windows).
|
|
31
|
+
- **690 tests across 56 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.
|
|
31
32
|
- **Bilingual documentation.** This README and [中文说明](README.zh-CN.md) are maintained side by side.
|
|
32
33
|
|
|
33
34
|

|
|
@@ -44,7 +45,7 @@ The web-search corner of the DSH plugin ecosystem is crowded. A fresh snapshot
|
|
|
44
45
|
| 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 |
|
|
45
46
|
| Dedicated vertical sources | 34 (8 on by default) | 41 | platform registry, not a vertical catalog | web + X, no vertical catalog | vertical API behind AnySearch |
|
|
46
47
|
| Model-facing tools | 1 (`web_tools`, 8 actions) + 4 MCP tools | ~10 | 2 (`web_index` / `web_call`, 20 actions) | native search/fetch + skill | 5 |
|
|
47
|
-
| Tests | 56 files /
|
|
48
|
+
| Tests | 56 files / 690 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 |
|
|
48
49
|
| GitHub stars | 0 | 620 | 77 | 836 | 663 |
|
|
49
50
|
| npm downloads, last month | 1,087 | 52,436 | 6,420 | 43,151 | 9,251 |
|
|
50
51
|
| npm unpacked size | 1.2 MB | 0.70 MB | 3.05 MB | 0.51 MB | 0.27 MB |
|
|
@@ -55,7 +56,7 @@ read is:
|
|
|
55
56
|
- **Feature depth:** upper-middle. `dsh-free-search` has more engines and
|
|
56
57
|
verticals; `dsh-web-search-pro` has a deeper evidence/ranking pipeline and far
|
|
57
58
|
more platform backends; `modsearch` is the stronger cross-host bridge.
|
|
58
|
-
- **Engineering and verification:** near the top.
|
|
59
|
+
- **Engineering and verification:** near the top. 690 local tests, a replayable
|
|
59
60
|
ranking benchmark, declared security boundaries and one runtime dependency
|
|
60
61
|
put it alongside the best-maintained entries, while remaining much smaller
|
|
61
62
|
than the Playwright-heavy option.
|
|
@@ -63,7 +64,7 @@ read is:
|
|
|
63
64
|
Chrome, PostgreSQL and AI Act paths and the 34-source vertical layer are not
|
|
64
65
|
common in the other plugins.
|
|
65
66
|
- **Adoption and maturity:** bottom third of this sample. The public npm release
|
|
66
|
-
is 0.
|
|
67
|
+
is 0.24.0, matching this tree, but the GitHub repository is four days old
|
|
67
68
|
with no stars and little independent adoption.
|
|
68
69
|
- **Tool-surface economy:** now competitive. 0.20.x exposes one `web_tools`
|
|
69
70
|
entry with eight actions, close to `dsh-web-search-pro`'s two tools with 20
|
|
@@ -489,6 +490,25 @@ a `link:` if you want the profile updater to manage it:
|
|
|
489
490
|
dsh plugin --profile web add @fffangchenghao/dsh-web-search@latest
|
|
490
491
|
```
|
|
491
492
|
|
|
493
|
+
### Windows
|
|
494
|
+
|
|
495
|
+
The package has no native addon; Node 22.18+ is enough. In PowerShell the
|
|
496
|
+
install command is unchanged:
|
|
497
|
+
|
|
498
|
+
```powershell
|
|
499
|
+
dsh plugin --profile web add @fffangchenghao/dsh-web-search@latest
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
If `dsh` is not on `PATH`, run the same command through the DSH installation's
|
|
503
|
+
CLI, or install the npm package from the plugin manager in Settings. Restart
|
|
504
|
+
DSH once after installation.
|
|
505
|
+
|
|
506
|
+
The plugin reads the Windows system proxy from Internet Settings (the same
|
|
507
|
+
`ProxyEnable` / `ProxyServer` values Clash and other clients set) and falls
|
|
508
|
+
back to `HTTPS_PROXY` / `HTTP_PROXY` / `DSH_WEB_SEARCH_PROXY`. A PAC-only proxy
|
|
509
|
+
is not executed; set the `proxy` setting explicitly for that case. The cache
|
|
510
|
+
lives at `%USERPROFILE%\.dsh\cache\dsh-web-search\cache.json`.
|
|
511
|
+
|
|
492
512
|
The rest of this section is the source-checkout development path.
|
|
493
513
|
|
|
494
514
|
### Step 1: build
|
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-690%20tests-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">
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
- **一个包,两种运行时。** DSH 里是原生插件和唯一的 `web_tools` 入口;Claude Code、Codex 等 MCP 客户端通过零依赖的 stdio server 使用同一套免密钥搜索,提供 `search`、`fetch`、`research`、`domain_search`。见 [跨 Agent MCP](docs/cross-agent.md)。
|
|
27
27
|
- **公开测量,也公开输的地方。** 30 条中英查询对比记录可用性、延迟、独立域名、官方域名命中与每一条失败;对比对象是免 key Firecrawl 和匿名 Exa。这里 Exa 更快,本插件返回的独立域名更多;两条对比路径都未使用 key。方法和原始结果在 [docs/comparison.md](docs/comparison.md);Exa 架构差异、中文 3 秒预算和 Rust 官方源见 [延迟与官方源](docs/latency-and-sources.md)。
|
|
28
28
|
- **抓取会承认失败。** 二进制文档和「200 但正文为空」会被明确拒绝(`SEARCH_UNSUPPORTED`、`SEARCH_EMPTY`),而不是当噪音返回;arXiv 的 PDF 链接是有意保留的例外,会改读 HTML 全文;direct → tunnel → render → extract 四级阶梯共享 25 秒预算,预算不足就不再起新的一级。预算是「每次请求」而不是「插件启动时」,这点有回归测试守着。
|
|
29
|
-
- **
|
|
29
|
+
- **Windows 是一等宿主。** 纯 ESM,没有原生扩展或安装脚本;会自动读取 Windows 的 Internet 设置代理,完整测试套件也在 `windows-latest` CI 上跑通。安装见[Windows 小节](#windows)。
|
|
30
|
+
- **56 个测试文件、690 个用例**,`lib/` 产物入库,声明了 `engines.dsh` / `engines.node`,[SECURITY.md](SECURITY.md) 逐项列出插件会碰的进程、主机和文件。
|
|
30
31
|
- **双语文档。** 本文件和 [English README](README.md) 同步维护。
|
|
31
32
|
|
|
32
33
|

|
|
@@ -43,7 +44,7 @@ DSH 插件生态里的「联网搜索」已经很挤。下面是一张 2026-10-2
|
|
|
43
44
|
| 免 key 路径 | 8 个引擎,全部免 key | ~30 个免费/付费引擎链 | 默认 5 个(seam、Exa、DDG、Bing、Jina) | Firecrawl + Keenable 免 key 默认 | 1 个 AnySearch 匿名 API |
|
|
44
45
|
| 专门数据源 | 34 个(默认开 8 个) | 41 个 | 平台注册表,不是垂直源目录 | 网页 + X,无垂直源目录 | AnySearch 的垂直 API |
|
|
45
46
|
| 面向模型的工具 | 1 个(`web_tools`,8 个 action)+ 4 个 MCP 工具 | ~10 个 | 2 个(`web_index` / `web_call`,20 个动作) | 原生搜索/抓取 + skill | 5 个 |
|
|
46
|
-
| 测试 | 56 文件 /
|
|
47
|
+
| 测试 | 56 文件 / 690 用例,本地实测 | `package.json` 无测试脚本 | 774 单元 + 94 bench,自报 | 配了 Vitest,未公布数量 | 配了 Vitest,未公布数量 |
|
|
47
48
|
| GitHub stars | 0 | 620 | 77 | 836 | 663 |
|
|
48
49
|
| npm 近一月下载 | 1,087 | 52,436 | 6,420 | 43,151 | 9,251 |
|
|
49
50
|
| npm 解包大小 | 1.2 MB | 0.70 MB | 3.05 MB | 0.51 MB | 0.27 MB |
|
|
@@ -53,11 +54,11 @@ DSH 插件生态里的「联网搜索」已经很挤。下面是一张 2026-10-2
|
|
|
53
54
|
- **功能深度:中上。** `dsh-free-search` 引擎和垂直源更多;
|
|
54
55
|
`dsh-web-search-pro` 的证据/排序管线和平台后端更深;`modsearch` 的跨宿主
|
|
55
56
|
能力更强。
|
|
56
|
-
- **工程质量与可验证性:接近第一梯队。**
|
|
57
|
+
- **工程质量与可验证性:接近第一梯队。** 690 个本地测试、可重放的排序基准、
|
|
57
58
|
明确的安全边界、只有 1 个运行时依赖,同时体积远小于 Playwright 重型方案。
|
|
58
59
|
- **免 key + 官方源纠错:最强卖点。** Chrome、PostgreSQL、AI Act 的官方路径
|
|
59
60
|
和 34 个垂直源,不是其他插件普遍具备的。
|
|
60
|
-
- **采用度与成熟度:这个样本里的后段。** 公开 npm 已是 0.
|
|
61
|
+
- **采用度与成熟度:这个样本里的后段。** 公开 npm 已是 0.24.0,与这棵树一致;但 GitHub 仓库创建 4 天、0 stars,
|
|
61
62
|
还缺少独立采用。
|
|
62
63
|
- **工具面的经济性:现在有竞争力。** 0.20.x 只暴露一个 `web_tools` + 8 个
|
|
63
64
|
action,接近 `dsh-web-search-pro` 的 2 工具 + 20 动作;旧的八个工具名保留为
|
|
@@ -460,6 +461,22 @@ profile 更新器。插件本身从不 fork/exec `pnpm`;手动按钮只是请
|
|
|
460
461
|
dsh plugin --profile web add @fffangchenghao/dsh-web-search@latest
|
|
461
462
|
```
|
|
462
463
|
|
|
464
|
+
### Windows
|
|
465
|
+
|
|
466
|
+
插件没有原生扩展,Node 22.18 以上即可。PowerShell 里的安装命令完全一样:
|
|
467
|
+
|
|
468
|
+
```powershell
|
|
469
|
+
dsh plugin --profile web add @fffangchenghao/dsh-web-search@latest
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
如果 `dsh` 不在 `PATH`,用 DSH 安装目录里的 CLI 执行同一条命令,或者在
|
|
473
|
+
Settings 的插件管理器里安装这个 npm 包。安装后重启一次 DSH。
|
|
474
|
+
|
|
475
|
+
插件会读取 Windows「Internet 设置」里的系统代理(Clash 等客户端写入的
|
|
476
|
+
`ProxyEnable` / `ProxyServer`),也会回退到 `HTTPS_PROXY` / `HTTP_PROXY` /
|
|
477
|
+
`DSH_WEB_SEARCH_PROXY`。只提供 PAC 的代理不会被执行,请显式填写 `proxy`
|
|
478
|
+
设置。缓存位置是 `%USERPROFILE%\.dsh\cache\dsh-web-search\cache.json`。
|
|
479
|
+
|
|
463
480
|
下面是从源码 checkout 开发的路径。
|
|
464
481
|
|
|
465
482
|
### 第一步:构建
|
package/SECURITY.md
CHANGED
|
@@ -40,6 +40,8 @@ Outbound TCP/HTTPS only, plus one local system query described below.
|
|
|
40
40
|
| `api.anysearch.com` | optional: search and page extraction, **only when an AnySearch key is configured** |
|
|
41
41
|
| your configured proxy | HTTP `CONNECT` tunnel for the hosts above |
|
|
42
42
|
|
|
43
|
+
On Windows the system proxy is read locally from `HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings`; that registry read is not network traffic.
|
|
44
|
+
|
|
43
45
|
`web_fetch` and `read_page` reach **any** HTTP(S) URL the model asks for; that is
|
|
44
46
|
their purpose. `engine_test` sends its probe query to the engines it tests, just
|
|
45
47
|
like a normal search; `advanced_search` is an ordinary search with a per-call
|
|
@@ -61,14 +63,17 @@ rungs failed. Nothing else is transmitted.
|
|
|
61
63
|
|
|
62
64
|
## Processes
|
|
63
65
|
|
|
64
|
-
The plugin spawns
|
|
66
|
+
The plugin spawns at most one system-proxy helper, selected by OS:
|
|
65
67
|
|
|
66
68
|
- `/usr/sbin/scutil --proxy` — macOS only, when `useProxy` is on, no explicit
|
|
67
|
-
proxy is configured, and the system proxy has to be discovered.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
proxy is configured, and the system proxy has to be discovered.
|
|
70
|
+
- `%SystemRoot%\System32\reg.exe query HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings` — Windows only under the same conditions.
|
|
71
|
+
The absolute path avoids a hijacked `PATH`; the key and value names are fixed.
|
|
72
|
+
|
|
73
|
+
Both probes use a fixed argv (no shell, no interpolation, no model- or
|
|
74
|
+
user-controlled arguments), parse stdout locally with fixed regexes, discard
|
|
75
|
+
stderr, and are capped at 2 s before the child is killed. They read nothing but
|
|
76
|
+
the system proxy settings.
|
|
72
77
|
|
|
73
78
|
The optional renderer is a **library**, not a command: when the user installed
|
|
74
79
|
`playwright` or `playwright-core` and enabled `renderJs`, the plugin imports it
|
package/client.js
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
var ENTRY = 'web-search-bing';
|
|
75
75
|
var PACKAGE_NAME = 'dsh-web-search-bing';
|
|
76
76
|
/** Keep in step with package.json; compared with the npm registry. */
|
|
77
|
-
var VERSION = '0.
|
|
77
|
+
var VERSION = '0.24.0';
|
|
78
78
|
/** Snapshot used while no configuration service is reachable. */
|
|
79
79
|
var EMPTY_STATE = { status: 'unavailable', value: undefined, base: undefined, user: undefined, revision: undefined, writable: false };
|
|
80
80
|
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<rect x="70" y="620" width="330" height="76" rx="14" fill="#101d31" stroke="#26364f"/>
|
|
53
53
|
<text x="92" y="651" class="m" font-size="13">Engines</text><text x="92" y="677" class="t" font-size="20" font-weight="700">8 key-free paths</text>
|
|
54
54
|
<rect x="420" y="620" width="330" height="76" rx="14" fill="#101d31" stroke="#26364f"/>
|
|
55
|
-
<text x="442" y="651" class="m" font-size="13">Tests</text><text x="442" y="677" class="t" font-size="20" font-weight="700">
|
|
55
|
+
<text x="442" y="651" class="m" font-size="13">Tests</text><text x="442" y="677" class="t" font-size="20" font-weight="700">690 local cases</text>
|
|
56
56
|
<rect x="770" y="620" width="360" height="76" rx="14" fill="#101d31" stroke="#26364f"/>
|
|
57
57
|
<text x="792" y="651" class="m" font-size="13">Cross-agent</text><text x="792" y="677" class="t" font-size="20" font-weight="700">MCP stdio server</text>
|
|
58
58
|
</g>
|
package/docs/quickstart.md
CHANGED
|
@@ -13,6 +13,12 @@ dsh plugin --profile defaults add @fffangchenghao/dsh-web-search@latest
|
|
|
13
13
|
Use your profile name instead of `defaults` if you run a named profile. Restart
|
|
14
14
|
DeepSeek Harness once after installation. No API key is required.
|
|
15
15
|
|
|
16
|
+
On Windows the command is identical in PowerShell; the plugin has no native
|
|
17
|
+
addon and needs only Node 22.18+. If `dsh` is not on `PATH`, use the CLI from
|
|
18
|
+
the DSH installation directory or install the npm package from Settings. The
|
|
19
|
+
plugin reads the Windows system proxy from Internet Settings automatically;
|
|
20
|
+
for a PAC-only proxy, set `proxy` or `DSH_WEB_SEARCH_PROXY` explicitly.
|
|
21
|
+
|
|
16
22
|
Verify in **Settings → Plugins → Web Search**:
|
|
17
23
|
|
|
18
24
|
- the engine health section can run a one-probe-per-engine test;
|
package/docs/store-evidence.md
CHANGED
|
@@ -23,10 +23,15 @@ 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 (86 files,
|
|
26
|
+
- Runtime artifacts: `lib/` is committed to this repository (86 files, 956 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.
|
|
30
|
+
- **Windows CI:** GitHub Actions `windows-latest`, Node 24. Install, typecheck,
|
|
31
|
+
the full test suite, build and the entry-point import all pass. Run:
|
|
32
|
+
https://github.com/fangchenghao/dsh-web-search/actions/runs/40354223874
|
|
33
|
+
(the matrix also runs on macOS and Ubuntu). This is a CI environment, not a
|
|
34
|
+
claim about every Windows terminal or proxy client.
|
|
30
35
|
|
|
31
36
|
## install — passed
|
|
32
37
|
|
package/lib/proxy.d.ts
CHANGED
|
@@ -77,8 +77,21 @@ export declare function noProxyIsLoopbackOnly(raw: string | undefined): boolean;
|
|
|
77
77
|
*/
|
|
78
78
|
export declare function proxyFromEnv(env?: NodeJS.ProcessEnv): string | undefined;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
80
|
+
* Parse the output of `reg query` for the Windows Internet Settings key.
|
|
81
|
+
*
|
|
82
|
+
* Windows stores the system proxy in the registry, not in an environment
|
|
83
|
+
* variable. `ProxyServer` may be a bare `host:port` or a semicolon-separated
|
|
84
|
+
* map such as `http=host:port;https=host:port`; SOCKS values are skipped
|
|
85
|
+
* because this transport only speaks HTTP `CONNECT`.
|
|
86
|
+
*
|
|
87
|
+
* @param output - stdout from `reg query HKCU\...\Internet Settings`.
|
|
88
|
+
* @returns an `http://` proxy URL, or `undefined` when disabled/unusable.
|
|
89
|
+
*/
|
|
90
|
+
export declare function proxyFromWindowsRegistry(output: string): string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Read the system proxy: `scutil --proxy` on macOS, the Internet Settings
|
|
93
|
+
* registry value on Windows. This is where a Clash-style client publishes
|
|
94
|
+
* `127.0.0.1:7890` when "set as system proxy" is on.
|
|
82
95
|
*
|
|
83
96
|
* @returns the HTTPS/HTTP proxy URL, or `undefined` on any other platform or
|
|
84
97
|
* when no proxy is enabled.
|
|
@@ -88,7 +101,7 @@ export declare function proxyFromSystem(): Promise<string | undefined>;
|
|
|
88
101
|
* Decide which proxy to use, if any.
|
|
89
102
|
*
|
|
90
103
|
* Order: an explicit plugin setting, the cached decision, the environment, then
|
|
91
|
-
* the macOS
|
|
104
|
+
* the system proxy (macOS `scutil`, Windows Internet Settings). The system proxy is only honoured when its port
|
|
92
105
|
* accepts a connection, so turning the tunnel off degrades to a direct request
|
|
93
106
|
* instead of breaking search. The decision is cached for a minute.
|
|
94
107
|
*
|
package/lib/proxy.js
CHANGED
|
@@ -21,6 +21,7 @@ import { spawn } from 'node:child_process';
|
|
|
21
21
|
import { once } from 'node:events';
|
|
22
22
|
import http from 'node:http';
|
|
23
23
|
import net from 'node:net';
|
|
24
|
+
import { join } from 'node:path';
|
|
24
25
|
import tls from 'node:tls';
|
|
25
26
|
import zlib from 'node:zlib';
|
|
26
27
|
/** How long a resolved proxy decision stays valid, in milliseconds. */
|
|
@@ -177,17 +178,9 @@ export function proxyFromEnv(env = process.env) {
|
|
|
177
178
|
}
|
|
178
179
|
return undefined;
|
|
179
180
|
}
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
* @returns the HTTPS/HTTP proxy URL, or `undefined` on any other platform or
|
|
185
|
-
* when no proxy is enabled.
|
|
186
|
-
*/
|
|
187
|
-
export async function proxyFromSystem() {
|
|
188
|
-
if (process.platform !== 'darwin')
|
|
189
|
-
return undefined;
|
|
190
|
-
const output = await new Promise((resolve) => {
|
|
181
|
+
/** Run a short local probe; any failure or timeout means "no answer". */
|
|
182
|
+
async function captureProbe(command, args, timeoutMs = 2_000) {
|
|
183
|
+
return await new Promise((resolve) => {
|
|
191
184
|
let text = '';
|
|
192
185
|
let settled = false;
|
|
193
186
|
const finish = (value) => {
|
|
@@ -197,21 +190,76 @@ export async function proxyFromSystem() {
|
|
|
197
190
|
clearTimeout(timer);
|
|
198
191
|
resolve(value);
|
|
199
192
|
};
|
|
200
|
-
|
|
201
|
-
//
|
|
202
|
-
const child = spawn('/usr/sbin/scutil', ['--proxy'], { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
203
|
-
// `scutil` answers in milliseconds; a wedged system call must not hold a
|
|
204
|
-
// search open, so the probe is capped and the child is killed on expiry.
|
|
193
|
+
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
194
|
+
// A wedged system call must not hold a search open.
|
|
205
195
|
const timer = setTimeout(() => {
|
|
206
196
|
child.kill();
|
|
207
197
|
finish('');
|
|
208
|
-
},
|
|
198
|
+
}, timeoutMs);
|
|
209
199
|
child.stdout.on('data', (chunk) => {
|
|
210
200
|
text += chunk.toString();
|
|
211
201
|
});
|
|
212
202
|
child.on('error', () => finish(''));
|
|
213
203
|
child.on('close', () => finish(text));
|
|
214
204
|
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Parse the output of `reg query` for the Windows Internet Settings key.
|
|
208
|
+
*
|
|
209
|
+
* Windows stores the system proxy in the registry, not in an environment
|
|
210
|
+
* variable. `ProxyServer` may be a bare `host:port` or a semicolon-separated
|
|
211
|
+
* map such as `http=host:port;https=host:port`; SOCKS values are skipped
|
|
212
|
+
* because this transport only speaks HTTP `CONNECT`.
|
|
213
|
+
*
|
|
214
|
+
* @param output - stdout from `reg query HKCU\...\Internet Settings`.
|
|
215
|
+
* @returns an `http://` proxy URL, or `undefined` when disabled/unusable.
|
|
216
|
+
*/
|
|
217
|
+
export function proxyFromWindowsRegistry(output) {
|
|
218
|
+
if ((/ProxyEnable\s+REG_DWORD\s+0x([0-9a-f]+)/iu.exec(output)?.[1] ?? '0') === '0')
|
|
219
|
+
return undefined;
|
|
220
|
+
const raw = /ProxyServer\s+REG_SZ\s+(.+)/iu.exec(output)?.[1]?.trim();
|
|
221
|
+
if (raw === undefined || raw.length === 0)
|
|
222
|
+
return undefined;
|
|
223
|
+
let server = raw;
|
|
224
|
+
if (server.includes('=')) {
|
|
225
|
+
const entries = new Map(server.split(';').map((part) => {
|
|
226
|
+
const at = part.indexOf('=');
|
|
227
|
+
return at < 0 ? [part.toLowerCase(), ''] : [part.slice(0, at).trim().toLowerCase(), part.slice(at + 1).trim()];
|
|
228
|
+
}));
|
|
229
|
+
server = entries.get('https') || entries.get('http') || '';
|
|
230
|
+
}
|
|
231
|
+
if (server.length === 0 || /^socks/iu.test(server))
|
|
232
|
+
return undefined;
|
|
233
|
+
const value = /^[a-z][a-z0-9+.-]*:\/\//iu.test(server) ? server : `http://${server}`;
|
|
234
|
+
const parsed = proxyUrl(value);
|
|
235
|
+
return parsed === undefined ? undefined : formatProxyUrl(parsed);
|
|
236
|
+
}
|
|
237
|
+
/** Read the Windows system proxy from HKCU Internet Settings. */
|
|
238
|
+
async function proxyFromWindows() {
|
|
239
|
+
const root = process.env['SystemRoot'] ?? process.env['windir'] ?? 'C:\\Windows';
|
|
240
|
+
// Absolute path: a hijacked PATH entry must not receive this spawn.
|
|
241
|
+
const output = await captureProbe(join(root, 'System32', 'reg.exe'), [
|
|
242
|
+
'query',
|
|
243
|
+
'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
|
244
|
+
]);
|
|
245
|
+
return proxyFromWindowsRegistry(output);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Read the system proxy: `scutil --proxy` on macOS, the Internet Settings
|
|
249
|
+
* registry value on Windows. This is where a Clash-style client publishes
|
|
250
|
+
* `127.0.0.1:7890` when "set as system proxy" is on.
|
|
251
|
+
*
|
|
252
|
+
* @returns the HTTPS/HTTP proxy URL, or `undefined` on any other platform or
|
|
253
|
+
* when no proxy is enabled.
|
|
254
|
+
*/
|
|
255
|
+
export async function proxyFromSystem() {
|
|
256
|
+
if (process.platform === 'win32')
|
|
257
|
+
return await proxyFromWindows();
|
|
258
|
+
if (process.platform !== 'darwin')
|
|
259
|
+
return undefined;
|
|
260
|
+
// Absolute path: a hijacked PATH entry must not be able to receive this
|
|
261
|
+
// spawn. macOS ships scutil at /usr/sbin/scutil.
|
|
262
|
+
const output = await captureProbe('/usr/sbin/scutil', ['--proxy']);
|
|
215
263
|
if (!/HTTPSEnable\s*:\s*1|HTTPEnable\s*:\s*1/.test(output))
|
|
216
264
|
return undefined;
|
|
217
265
|
const host = /HTTPSProxy\s*:\s*(\S+)/.exec(output)?.[1] ?? /HTTPProxy\s*:\s*(\S+)/.exec(output)?.[1];
|
|
@@ -238,7 +286,7 @@ async function reachable(proxy, timeoutMs = 400) {
|
|
|
238
286
|
* Decide which proxy to use, if any.
|
|
239
287
|
*
|
|
240
288
|
* Order: an explicit plugin setting, the cached decision, the environment, then
|
|
241
|
-
* the macOS
|
|
289
|
+
* the system proxy (macOS `scutil`, Windows Internet Settings). The system proxy is only honoured when its port
|
|
242
290
|
* accepts a connection, so turning the tunnel off degrades to a direct request
|
|
243
291
|
* instead of breaking search. The decision is cached for a minute.
|
|
244
292
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fffangchenghao/dsh-web-search",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
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, arXiv research lookups and readable papers, official release facts, a replayable benchmark, an optional Firecrawl key and a dependency-free MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc -p tsconfig.json",
|
|
40
40
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
41
|
-
"test": "node --test test
|
|
41
|
+
"test": "node --test \"test/**/*.test.ts\"",
|
|
42
42
|
"check": "npm run typecheck && npm run test",
|
|
43
43
|
"prepublishOnly": "npm run build"
|
|
44
44
|
},
|