@wenaixi/searchfuse 0.1.0 → 0.1.2
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 +157 -1
- package/README.md +2 -10
- package/README.zh-CN.md +2 -10
- package/SECURITY.md +36 -2
- package/claude/.claude-plugin/plugin.json +1 -1
- package/claude/hooks/register.ts +90 -18
- package/dist/kernel.js +17 -6
- package/dist/main.js +64 -21
- package/dist/{search-BIW13Csk.js → search-DeT416xs.js} +123 -11
- package/dist/serve-ensure.js +1 -140
- package/dist/serveEnsure-BTj9IifL.js +632 -0
- package/dsh/index.js +137 -3
- package/omp/extension.ts +263 -29
- package/omp/host-types.d.ts +47 -0
- package/omp/tsconfig.json +13 -0
- package/package.json +3 -7
- package/skills/searchfuse/SKILL.md +4 -4
- package/skills/searchfuse/references/configure.md +4 -2
- package/skills/searchfuse/references/runtime.md +1 -1
- package/skills/searchfuse/scripts/run.ps1 +1 -1
- package/skills/searchfuse/scripts/run.sh +1 -1
- package/dist/serve-Bfqz-nCB.js +0 -279
- package/docs/commit.md +0 -77
- package/docs/dsh.md +0 -205
- package/docs/harness-setup.md +0 -78
- package/docs/parity-matrix.md +0 -61
- package/docs/searxng-setup.md +0 -117
- package/docs/security.md +0 -59
- package/docs/settings-redesign-decisions.md +0 -407
- package/docs/superpowers/plans/2026-11-24-serve-lifecycle.md +0 -880
- package/docs/superpowers/reports/2026-11-24-serve-lifecycle-ledger.md +0 -211
- package/docs/superpowers/specs/2026-11-20-searchfuse-dual-host-design.md +0 -172
- package/docs/superpowers/specs/2026-11-21-searchfuse-tri-host-design.md +0 -659
- package/docs/superpowers/specs/2026-11-21-tri-host-takeover-design.md +0 -363
- package/docs/superpowers/specs/2026-11-22-settings-card-refactor-design.md +0 -117
- package/docs/superpowers/specs/2026-11-24-serve-lifecycle-design.md +0 -155
- package/docs/testing.md +0 -92
- package/docs/troubleshooting.md +0 -258
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,160 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
|
|
14
14
|
暂无。
|
|
15
15
|
|
|
16
|
+
## [0.1.2] - 2026-11-28
|
|
17
|
+
|
|
18
|
+
这一版只做一件事:**让冷却机制在生产路径上真的工作,并补齐 omp 那一端**。
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **omp 扩展没有候选端口探测。** 删掉 `runtime.json` 后(服务被 kill 时
|
|
23
|
+
`close()` 跑不到),omp 的 `readServeRuntime` 直接返回 undefined,会认为服务
|
|
24
|
+
不在,白等 15 秒再报不可用。主包、dsh、claude 三端在 0.1.1 都有候选探测,
|
|
25
|
+
只有这一端漏了——CHANGELOG 里「三端都能找回」的说法对它不成立。现已内联
|
|
26
|
+
同一套身份算法,`tryServe` 与 `healthOnce` 都改走 `locateServeRuntime`。
|
|
27
|
+
实测:删文件后用真实 `omp -p` 搜索,13 条结果,仍只有 1 个实例。
|
|
28
|
+
- **冷却控制器从未传入三端的真实链路。** `src/kernel.ts`(dsh / claude hook /
|
|
29
|
+
omp 扩展全部走它)与 `src/serve.ts` 的三个端点都没传 `cooldown`,只有 CLI 的
|
|
30
|
+
`searchfuse search` 传了——而三端没有一个走那条路。结果是 `state.json`
|
|
31
|
+
永远是空的,被额度耗尽的引擎每次运行都被重新撞一遍墙。三个端点里
|
|
32
|
+
`/v1/read-page` 是最晚被发现的:修前两个时漏了它,而 omp 的 `read_page`
|
|
33
|
+
走的正是这条。
|
|
34
|
+
- **融合模式只读冷却、从不写。** 即使控制器传进去了,默认的 `rrf` 模式下
|
|
35
|
+
`record`/`clear` 也只挂在链式路径上。`FanoutResult` 现在带 `outcomes`
|
|
36
|
+
(保留原始 `Error` 对象,而不只是格式化后的字符串),融合路径据此记冷却;
|
|
37
|
+
全灭时 `fanout` 抛出的 error 上也挂着 `outcomes`,那正是最该记的情况。
|
|
38
|
+
- **多密钥引擎在融合模式下会一直用那把已耗尽的 key。** 所有 HTTP provider 只读
|
|
39
|
+
`splitApiKeys(apiKey)[0]`,而密钥轮换只发生在链式路径。链式把 key1 记成冷却
|
|
40
|
+
后,下一次融合运行仍拿它去打同一堵墙。现在融合组目标时把健康的 key 排到首位,
|
|
41
|
+
不必改任何 provider。
|
|
42
|
+
- **429 携带额度原因时被当成瞬时限流。** firecrawl 的免注册额度用完回 429,
|
|
43
|
+
正文写着 `"reason":"credits"` 与 `"retry_after_seconds":66233`——那是花光的
|
|
44
|
+
预算,不是每秒一次的抖动。`classifyQuota` 早先只看 `/429/` 就返回 null,
|
|
45
|
+
而 `retry_after_seconds` 这个权威恢复时间全仓库没人读。现在认这类 JSON
|
|
46
|
+
字段,恢复时间按 `retry_after_seconds` → `Resets in 94h19m9s` → 兜底 TTL
|
|
47
|
+
的精度顺序取。
|
|
48
|
+
- **额度码的复合形态被判漏。** 判定「额度类」的正则早先写 `credits?\b`,
|
|
49
|
+
但 JS 正则里 `_` 属于 `\w`,`_` 与字母之间**不构成词边界**,于是
|
|
50
|
+
`"reason":"credits_exhausted"`、`credits_depleted` 这种最常见形状全部漏判;
|
|
51
|
+
连字符形态 `daily-limit` 也漏(`[_-]?` 只允许下划线)。漏判的后果是每次运行
|
|
52
|
+
都重新撞一次墙。现在改成显式后跟断言 `credits(?=["_]|$)`,并接受连字符。
|
|
53
|
+
- **瞬时限流码被误判成额度。** 同一个正则里独立成词的 `limit_reached` 会命中
|
|
54
|
+
`rate_limit_reached` / `requests_limit_reached` 这类极常见的限流码,把一秒钟的
|
|
55
|
+
抖动记成 45 分钟冷却——正是这段逻辑声明要避免的反向错误。现在 `limit` 必须
|
|
56
|
+
带 `usage`/`daily`/`monthly`/`plan`/`billing` 这类表示配额的前缀。
|
|
57
|
+
- **外部可控的秒数能让冷却记录抛 RangeError。** `"retry_after_seconds":99999999999999`
|
|
58
|
+
会算出 Invalid Date,而 Date 对象永远 truthy,`if (!until)` 拦不住,调用方
|
|
59
|
+
`toISOString()` 抛出并**替换掉原本的引擎失败原因**。现在验证结果日期有效,
|
|
60
|
+
并在记录侧包一层兜底。
|
|
61
|
+
- **`claude/.claude-plugin/plugin.json` 的版本号不在盖章表里。** 0.1.1 发版后
|
|
62
|
+
`searchfuse --version` 报 0.1.1,而宿主里显示的仍是 0.1.0。已纳入
|
|
63
|
+
`stampTargets`。
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
|
|
67
|
+
- **成功引擎只在确实有冷却记录时才清状态。** `clearEngineCooldown` 无条件读盘
|
|
68
|
+
(写被短路,读不会),融合模式下每个成功引擎触发一次,六个引擎就是每请求
|
|
69
|
+
六次读盘,而绝大多数时候是空操作。
|
|
70
|
+
|
|
71
|
+
## [0.1.1] - 2026-11-27
|
|
72
|
+
|
|
73
|
+
这一版只做一件事:**服务定位不再依赖一个会消失的文件**。
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
- **`runtime.json` 消失后三端全部失联(僵尸态)。** 该文件曾是服务身份的唯一
|
|
78
|
+
凭证,而它在 `close()` 里被删除;进程被信号杀掉或崩溃时 `close` 跑不到,于是
|
|
79
|
+
出现「服务还在听、文件已经没了」的状态。实测 PID 27056 监听 64683(**旧机制
|
|
80
|
+
下的观测值**:那时端口由内核随机分配)而 `runtime.json` 不存在,三端读不到
|
|
81
|
+
端口,全部退回 spawn 慢路径。
|
|
82
|
+
- **并发 `serve --ensure` 的进程雪崩。** `serve.port` 默认 0(内核随机挑端口),
|
|
83
|
+
并发的多个实例各绑各的端口、全部成功、全部常驻,谁最后写 `runtime.json` 谁赢,
|
|
84
|
+
其余成为占坑的孤儿。
|
|
85
|
+
- **先退出的实例会删掉后退出的那个的文件。** `close()` 原先无条件 `rmSync`,
|
|
86
|
+
服务 A 关闭时把服务 B 写下的 `runtime.json` 一并删掉,B 瞬间变瞎。
|
|
87
|
+
- **5xx 错误正文被吞。** dsh 的 `tryServe` 早先「先探 `/healthz` 再返回」,
|
|
88
|
+
服务活着但健康检查恰好不通时被判成「服务不存在」,于是回退 spawn kernel,
|
|
89
|
+
服务端 5xx 正文里逐引擎的尝试轨迹就此消失,用户看到「不可达」而非真实原因。
|
|
90
|
+
|
|
91
|
+
### Added
|
|
92
|
+
|
|
93
|
+
- **目录指纹与确定性候选端口。** 指纹是 `sha256(realpath(~/.searchfuse).toLowerCase())`
|
|
94
|
+
的前 8 位,归一化消除尾斜杠、`.` 段与大小写差异。候选端口从
|
|
95
|
+
`42000 + (指纹 % 2000)` 起连续 8 个,同一份状态目录必然得到同一组。
|
|
96
|
+
服务按候选顺序找第一个能绑的,被占则顺延,全部被占才报错。
|
|
97
|
+
- **`GET /identity` 端点。** 返回 `{port, pid, fingerprint, version}`,免鉴权、
|
|
98
|
+
不泄露 token。客户端按候选端口逐个探测,**必须比对指纹**才认——只看 `/healthz`
|
|
99
|
+
200 会把恰好占着那个端口的别的程序认成自己的服务,然后把 token 发给它。
|
|
100
|
+
- **两级服务定位。** `runtime.json` 降级为缓存:文件在且形状合法就直接用;
|
|
101
|
+
文件不在才走候选探测。三端(CLI / dsh / Claude Code)同一套判定。
|
|
102
|
+
- **`hosts sync` 把身份写进 Claude settings。** mod 的沙箱里既没有 `process`
|
|
103
|
+
也没有 `crypto`,算不了指纹,只能拿 CLI 预先算好的 `fingerprint` 与 `ports`。
|
|
104
|
+
|
|
105
|
+
### Changed
|
|
106
|
+
|
|
107
|
+
- **`/healthz` 的 body 保持纯文本 `OK`。** 四个现存消费者都只看状态码,
|
|
108
|
+
把 body 换成 JSON 是无谓的破坏性变更;身份校验走独立的 `/identity`。
|
|
109
|
+
- **`typecheck` 接上 `omp/tsconfig.json` 与 `claude/tsconfig.json`。**
|
|
110
|
+
此前这两份从来不在 CI 里跑,「四道类型门禁」实际只有两道在跑。
|
|
111
|
+
|
|
112
|
+
### Tests
|
|
113
|
+
|
|
114
|
+
- 新增 `src/serveIdentity.test.ts`(6 条):确定性、归一化、候选范围与连续性。
|
|
115
|
+
- 新增 `src/serveIdentity.postcondition.test.ts`(8 条):用真实 HTTP 服务
|
|
116
|
+
钉住核心承诺——文件删掉后靠指纹找回服务、`ensureServeRunning` 不另起实例、
|
|
117
|
+
陌生服务占着候选端口不会被误认、`/identity` 与目录推导一致、候选被占时顺延。
|
|
118
|
+
- 新增 `src/serveIdentity.parity.test.ts`(4 条):锁住三份拷贝一致。任何一份
|
|
119
|
+
漂移都会造成「服务绑一个端口、客户端去探另一个」,症状与「服务没起来」
|
|
120
|
+
一模一样,是最难查的一类故障。
|
|
121
|
+
- 反向验证:破坏指纹校验 → 「陌生服务」那条变红;去掉候选探测层 →
|
|
122
|
+
「不另起实例」那条变红。两条都亲眼看到变红再恢复。
|
|
123
|
+
|
|
124
|
+
三项实测的端到端结果:
|
|
125
|
+
|
|
126
|
+
1. **服务绑在候选段内。** 本机指纹 `21fe1ece` → 候选 `42158..42165`,服务实际绑
|
|
127
|
+
42158,`runtime.json` 与 `/identity` 报出的指纹与推导值一致。
|
|
128
|
+
2. **文件消失后三端都能找回。** 删掉 `runtime.json` 后:CLI / serveEnsure 在
|
|
129
|
+
42158 认出指纹;dsh 的 `locateServeRuntime` 走候选探测,真实搜到 28 条结果
|
|
130
|
+
(内容 809 字符);Claude Code 从 settings 里的 `ports` 逐个探测。
|
|
131
|
+
3. **并发不雪崩。** 6 个进程同时跑 `serve --ensure`:1 个起服务、5 个报
|
|
132
|
+
「Already running」退出,候选段内只有 1 个 LISTENING。
|
|
133
|
+
4. **删掉 runtime.json 后再 ensure 不起第二个。** 这是审查员实证击穿的那条:
|
|
134
|
+
修复前 A 活 42800 → 删文件 → B 起在 42801 → 两个都在听。修复后报
|
|
135
|
+
「Already running on 42158」,监听数始终为 1。
|
|
136
|
+
|
|
137
|
+
### 审查后补齐(第二轮)
|
|
138
|
+
|
|
139
|
+
两轮独立审查(代码审查 + 测试守护力)之后补的:
|
|
140
|
+
|
|
141
|
+
- **`serve --ensure` 接上候选探测**(阻断级)。它是唯一真正起服务的入口,
|
|
142
|
+
早先只信 `runtime.json`,文件一消失就在下一个候选上起第二个实例。判据
|
|
143
|
+
抽成 `findRunningServe`,CLI 与插件侧共用同一个函数。
|
|
144
|
+
- **指纹改用 `realpathSync`**。junction 与它指向的目标现在算出同一个指纹。
|
|
145
|
+
Windows 的 8.3 短名(`C:\Users\ADMINI~1`)仍不会被展开——实测确认,
|
|
146
|
+
`os.homedir()` 正常返回长名时碰不到,文档已如实写明这个限制。
|
|
147
|
+
- **`syncClaudeSettings` 的早退判据**从「只比 enabled」改成「所有要写的字段
|
|
148
|
+
都比」。升级用户的旧 settings 没有 fingerprint/ports,只看 enabled 会早退,
|
|
149
|
+
新字段永远写不进去。
|
|
150
|
+
- **omp 与 claude 的 `runtime.json` 形状检查**补齐 `Number.isInteger` 校验,
|
|
151
|
+
与 `serveEnsure` / `main.ts` 逐条一致。
|
|
152
|
+
- **`__APP_VERSION__` 只守卫一次**、`/identity` 与 runtime.json 写入共用。
|
|
153
|
+
早先裸跑时服务能起、`/identity` 能答,但 runtime.json 永远写不出。
|
|
154
|
+
- **`parity` 测试改成抽取 dsh 真身函数体求值**。先前从源码抓数字再自己重建,
|
|
155
|
+
常量对得上但归一化/取模/截断任一漂移时全量测试零红——实测把 dsh 的
|
|
156
|
+
`.toLowerCase()` 删掉,838 条一条不红。现在三条反向验证都能变红
|
|
157
|
+
(去掉 toLowerCase → 4 红、取模 2000→2001 → 2 红、截断 8→6 → 3 红)。
|
|
158
|
+
- **候选端口遇 `EACCES` 也换下一个**(不只是 `EADDRINUSE`);`listening`
|
|
159
|
+
改 `once`,避免候选重试时重复写 runtime.json。
|
|
160
|
+
- **候选模式下的实例收敛**:启动成功后检查前序候选,有同指纹服务就让位退出。
|
|
161
|
+
- **锁等待超时的错误文案**区分「持锁者还在跑」与「持锁者已死」两种真相。
|
|
162
|
+
- 删掉 `candidatePorts` 里永不触发的 `<= 65535` 守卫(它让函数可能返回少于
|
|
163
|
+
8 个元素,与契约矛盾);`serve.ts` 两处「固定端口」过时注释改成候选语义。
|
|
164
|
+
|
|
165
|
+
<!-- 0.1.0 的完整记录见下 -->
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<!-- 0.1.0 的完整记录见下 -->
|
|
169
|
+
|
|
16
170
|
## [0.1.0] - 2026-11-26
|
|
17
171
|
|
|
18
172
|
首个正式版本。searchfuse 是一个给模型用的联网搜索插件:把搜索查询变成带来源
|
|
@@ -127,5 +281,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
127
281
|
`rootDir`(否则退出码 2、`dsh/index.js` 不生成,包装不上);undici 8 对
|
|
128
282
|
`http://` 目标改用标准代理转发而非 CONNECT 隧道,测试里的假代理两条路都要接。
|
|
129
283
|
|
|
130
|
-
[Unreleased]: https://github.com/Wenaixi/searchfuse/compare/v0.1.
|
|
284
|
+
[Unreleased]: https://github.com/Wenaixi/searchfuse/compare/v0.1.2...HEAD
|
|
285
|
+
[0.1.2]: https://github.com/Wenaixi/searchfuse/releases/tag/v0.1.2
|
|
286
|
+
[0.1.1]: https://github.com/Wenaixi/searchfuse/releases/tag/v0.1.1
|
|
131
287
|
[0.1.0]: https://github.com/Wenaixi/searchfuse/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -12,10 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
14
|
<a href="./README.zh-CN.md">简体中文</a> ·
|
|
15
|
-
<a href="docs/troubleshooting.md">Troubleshooting</a> ·
|
|
16
15
|
<a href="skills/searchfuse/references/configure.md">Configuration</a> ·
|
|
17
16
|
<a href="skills/searchfuse/references/output-schema.md">Output contract</a> ·
|
|
18
|
-
<a href="docs/security.md">Security</a> ·
|
|
19
17
|
<a href="https://github.com/liustack/modlens">ModLens (vision)</a>
|
|
20
18
|
</p>
|
|
21
19
|
|
|
@@ -36,7 +34,7 @@ Hit a problem? [Open an issue](https://github.com/Wenaixi/searchfuse/issues/new/
|
|
|
36
34
|
|
|
37
35
|
## Features
|
|
38
36
|
|
|
39
|
-
- **The strongest free web search plugin for DeepSeek Harness (dsh):** one command installs it, `npx -y @deepseek-ai/dsh plugin --profile web add @wenaixi/searchfuse@0.1.
|
|
37
|
+
- **The strongest free web search plugin for DeepSeek Harness (dsh):** one command installs it, `npx -y @deepseek-ai/dsh plugin --profile web add @wenaixi/searchfuse@0.1.2`. In the desktop app's Add plugin dialog, enter `@wenaixi/searchfuse`, not the GitHub URL.
|
|
40
38
|
- **Free out of the box, no signup.** Search and page fetch run on Firecrawl Keyless by default: [1,000 free credits/month](https://www.firecrawl.dev/blog/firecrawl-keyless-launch), no account, no API key, no card. Every fallback channel is free too: Keenable, AnySearch, and You.com each add a keyless pool, the bundled SearXNG instance needs no key at all, Antigravity CLI needs only a browser sign-in, and Tavily, Exa, and a free Firecrawl key each add their own monthly quota with no card required.
|
|
41
39
|
- **Fused search, not failover.** By default `web_search` asks every reachable engine at once and merges their ranked lists with reciprocal rank fusion, so an answer reflects several indexes and a page two engines agree on outranks one only a single engine liked. Set `aggregate.mode: chain` in `~/.searchfuse/config.json` for the old sequential behaviour.
|
|
42
40
|
- **Automatic failover.** When a channel fails or exhausts its quota, the next one takes over. Under fusion, one engine erroring costs only its own contribution; the rest of the answer stands and the failure is named in `uncertainty`.
|
|
@@ -122,17 +120,11 @@ Once installed, you do not need to remember any commands. Just chat. Ask anythin
|
|
|
122
120
|
| :-- | :-- |
|
|
123
121
|
| [INSTALL.md](INSTALL.md) | Installing the skill step by step (written for an agent) |
|
|
124
122
|
| [CLI manual](skills/searchfuse/references/cli.md) | The CLI the skill drives: flags, config, doctor |
|
|
125
|
-
| [Troubleshooting](docs/troubleshooting.md) | A command failed and the message needs decoding |
|
|
126
123
|
| [Configuration](skills/searchfuse/references/configure.md) | Setting a key, switching engines, fixing config |
|
|
127
124
|
| [Output contract](skills/searchfuse/references/output-schema.md) | Parsing the JSON or building on it |
|
|
128
|
-
| [SearXNG setup](docs/searxng-setup.md) | Running your own instance to reach Google's index |
|
|
129
|
-
| [dsh plugin](docs/dsh.md) | Installing, configuring, verifying, and updating the native dsh bundle |
|
|
130
|
-
| [Harness setup](docs/harness-setup.md) | Wiring it into Codex, Claude Code, OpenCode, or Pi |
|
|
131
|
-
| [Security](docs/security.md) | SSRF guards, DNS-rebinding protection, untrusted input |
|
|
132
|
-
| [Testing](docs/testing.md) | Running the suite or writing a test that can fail |
|
|
133
125
|
| [CHANGELOG](CHANGELOG.md) | Finding what changed in a version |
|
|
134
126
|
|
|
135
|
-
Proxy fake-IP mode (Clash, Clash Verge Rev, mihomo, Surge) works out of the box. DNS answers in `198.18.0.0/15` are treated as fake-IP placeholders with no switch needed. Literal URLs such as `http://198.18.0.5/` stay blocked when `allowPrivateNetwork` is off.
|
|
127
|
+
Proxy fake-IP mode (Clash, Clash Verge Rev, mihomo, Surge) works out of the box. DNS answers in `198.18.0.0/15` are treated as fake-IP placeholders with no switch needed. Literal URLs such as `http://198.18.0.5/` stay blocked when `allowPrivateNetwork` is off.
|
|
136
128
|
|
|
137
129
|
## Contributing
|
|
138
130
|
|
package/README.zh-CN.md
CHANGED
|
@@ -12,10 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
14
|
<a href="./README.md">English</a> ·
|
|
15
|
-
<a href="docs/troubleshooting.md">故障排查</a> ·
|
|
16
15
|
<a href="skills/searchfuse/references/configure.md">配置</a> ·
|
|
17
16
|
<a href="skills/searchfuse/references/output-schema.md">输出契约</a> ·
|
|
18
|
-
<a href="docs/security.md">安全</a> ·
|
|
19
17
|
<a href="https://github.com/liustack/modlens">ModLens(视觉)</a>
|
|
20
18
|
</p>
|
|
21
19
|
|
|
@@ -36,7 +34,7 @@ DeepSeek 和 GLM 等模型没有联网能力或联网能力羸弱。SearchFuse
|
|
|
36
34
|
|
|
37
35
|
## 特性
|
|
38
36
|
|
|
39
|
-
- **全网最强的 DeepSeek Harness (dsh) 免费联网搜索插件:** 一条命令即刻安装 `npx -y @deepseek-ai/dsh plugin --profile web add @wenaixi/searchfuse@0.1.
|
|
37
|
+
- **全网最强的 DeepSeek Harness (dsh) 免费联网搜索插件:** 一条命令即刻安装 `npx -y @deepseek-ai/dsh plugin --profile web add @wenaixi/searchfuse@0.1.2`。桌面版「添加插件」里填 `@wenaixi/searchfuse`,不要填 GitHub 地址。
|
|
40
38
|
- **开箱免费,免注册。** 搜索和单页抓取默认跑在 Firecrawl 免注册通道上:[每月 1,000 免费 credits](https://www.firecrawl.dev/blog/firecrawl-keyless-launch),没有账号、没有 API key、没有绑卡。后备通道也全部免费:Keenable、AnySearch 和 You.com 各有一条免注册额度,随包的 SearXNG 实例完全不需要 key,Antigravity CLI 只需浏览器登录,Tavily、Exa 和免费的 Firecrawl key 各带独立的月度额度,均不要求绑卡。
|
|
41
39
|
- **融合搜索,不是故障转移。** 默认情况下 `web_search` 同时询问每个可达引擎,用倒数排名融合合并它们的排序列表,于是答案反映多个索引;两个引擎都认可的页面,排在只有一个引擎喜欢的页面之前。想要旧的串行行为,在 `~/.searchfuse/config.json` 里写 `aggregate.mode: chain`。
|
|
42
40
|
- **自动故障转移。** 一个通道失败或额度耗尽时自动切换下一个。融合模式下,一个引擎报错只损失它自己那份贡献,答案其余部分照常成立,失败原因写进 `uncertainty`。
|
|
@@ -122,17 +120,11 @@ dsh 用户还有一条不碰命令行的路。在 dsh 侧栏点开「插件」
|
|
|
122
120
|
| :------------------------------------------------------- | :------------------------------------------ |
|
|
123
121
|
| [INSTALL.md](INSTALL.md) | 一步步安装 skill(为 agent 编写) |
|
|
124
122
|
| [CLI 手册](skills/searchfuse/references/cli.md) | skill 所驱动的 CLI:参数、配置与体检 |
|
|
125
|
-
| [故障排查](docs/troubleshooting.md) | 命令报错,查成因和解法 |
|
|
126
123
|
| [配置手册](skills/searchfuse/references/configure.md) | 配置 key、切换引擎、排查配置 |
|
|
127
124
|
| [输出契约](skills/searchfuse/references/output-schema.md) | 解析 JSON 或构建下游工具 |
|
|
128
|
-
| [SearXNG 搭建](docs/searxng-setup.md) | 自建实例,用它够到 Google 的索引 |
|
|
129
|
-
| [dsh 插件](docs/dsh.md) | 安装、配置、验证与更新原生 dsh bundle |
|
|
130
|
-
| [宿主接入](docs/harness-setup.md) | 在 Codex、Claude Code、OpenCode、Pi 中配置 |
|
|
131
|
-
| [安全说明](docs/security.md) | SSRF 防护、DNS 重绑定防护、不可信输入的处理 |
|
|
132
|
-
| [测试指南](docs/testing.md) | 跑测试套件,或写一条会失败的测试 |
|
|
133
125
|
| [更新日志](CHANGELOG.md) | 查询版本变更 |
|
|
134
126
|
|
|
135
|
-
Clash、Clash Verge Rev、mihomo、Surge 的代理 fake-ip 模式开箱即用:DNS 返回的 `198.18.0.0/15` 地址会被视为 fake-ip 占位值,不用开任何开关。URL 中直写的 `http://198.18.0.5/` 这类地址在 `allowPrivateNetwork` 关闭时仍会被拦。
|
|
127
|
+
Clash、Clash Verge Rev、mihomo、Surge 的代理 fake-ip 模式开箱即用:DNS 返回的 `198.18.0.0/15` 地址会被视为 fake-ip 占位值,不用开任何开关。URL 中直写的 `http://198.18.0.5/` 这类地址在 `allowPrivateNetwork` 关闭时仍会被拦。
|
|
136
128
|
|
|
137
129
|
## 参与方式
|
|
138
130
|
|
package/SECURITY.md
CHANGED
|
@@ -16,5 +16,39 @@ or input that triggers it, and the smallest reproduction you can manage.
|
|
|
16
16
|
The most sensitive surface is the local `http` fetch engine, which makes requests
|
|
17
17
|
to URLs an agent may have pulled from untrusted page content. Its SSRF guards,
|
|
18
18
|
the one known DNS-rebinding gap, and how untrusted content is handled are
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
summarised here. Read this first: a report about the already-documented rebinding
|
|
20
|
+
window is not a new finding.
|
|
21
|
+
|
|
22
|
+
### What is already guarded
|
|
23
|
+
|
|
24
|
+
- Private and reserved address ranges are blocked unless `allowPrivateNetwork`
|
|
25
|
+
is on, and that switch never authorises disclosure to the Firecrawl cloud: a
|
|
26
|
+
private target written literally in the URL is never sent upstream under any
|
|
27
|
+
configuration.
|
|
28
|
+
- The DNS answer is resolved once and the connection is pinned to the IP that
|
|
29
|
+
passed the check, while the Host header and TLS SNI keep the original hostname.
|
|
30
|
+
Every redirect hop re-validates and re-pins.
|
|
31
|
+
- **Known gap:** the window between the check and the connect. Pinning closes
|
|
32
|
+
most of it, but a resolver that answers differently between the two lookups is
|
|
33
|
+
the residual risk. This is documented deliberately, not an oversight.
|
|
34
|
+
- Proxy fake-IP answers (`198.18.0.0/15`) are treated as placeholders. Literal
|
|
35
|
+
URLs such as `http://198.18.0.5/` stay blocked when `allowPrivateNetwork` is
|
|
36
|
+
off.
|
|
37
|
+
|
|
38
|
+
### Keys and outbound output
|
|
39
|
+
|
|
40
|
+
- Keys live in `~/.searchfuse/config.json` at mode 0600 in a 0700 directory.
|
|
41
|
+
There is no keychain integration and no encryption at rest: file permissions
|
|
42
|
+
plus the output boundaries below are the protection.
|
|
43
|
+
- `config show`, `doctor`, and the dsh settings card mask keys. Referenced
|
|
44
|
+
external text (gateway error bodies, subprocess stderr) is scrubbed before
|
|
45
|
+
reaching the terminal, `attempts`, `warnings`, or the cooldown state file.
|
|
46
|
+
- Environment variables (`TAVILY_API_KEY`, `EXA_API_KEY`, `FIRECRAWL_API_KEY`,
|
|
47
|
+
`KEENABLE_API_KEY`, `ANYSEARCH_API_KEY`) override the file and are never
|
|
48
|
+
written to disk.
|
|
49
|
+
|
|
50
|
+
### Untrusted page content
|
|
51
|
+
|
|
52
|
+
Fetched pages are data, never instructions. The local engine does not run
|
|
53
|
+
JavaScript, so a client-rendered page comes back as an empty shell and the
|
|
54
|
+
result says so in `uncertainty` rather than presenting the shell as content.
|
package/claude/hooks/register.ts
CHANGED
|
@@ -148,47 +148,119 @@ let cachedStamp = '';
|
|
|
148
148
|
* 判断——比 mtime 简单,且 runtime.json 只在服务起停时变。
|
|
149
149
|
*/
|
|
150
150
|
/**
|
|
151
|
-
* 找到 `runtime.json`
|
|
151
|
+
* 找到 `runtime.json` 的绝对路径与身份信息。
|
|
152
152
|
*
|
|
153
153
|
* 为什么需要这一步:宿主的 mod 沙箱里 **`~` 不展开**,`$.env.get('HOME')`
|
|
154
154
|
* 也返回 undefined(实测),所以拿不到家目录。唯一可行的办法是让
|
|
155
155
|
* `searchfuse hosts sync` 把绝对路径写进 Claude 的 settings,mod 通过
|
|
156
156
|
* `$.settings.read` 读回来——那条通道是宿主明确支持的。
|
|
157
157
|
*
|
|
158
|
+
* 同时把 fingerprint 与候选端口带回来:runtime.json 会在服务被 kill 时
|
|
159
|
+
* 消失(close 跑不到),那时只能靠这些候选端口逐个探 `/identity` 并把
|
|
160
|
+
* 应答者自称的指纹与本机算好的比对。沙箱里没有 crypto,算不了指纹,
|
|
161
|
+
* 所以由 CLI 侧预先写好。
|
|
162
|
+
*
|
|
158
163
|
* 读不到就返回 undefined:调用方据此回退到 `$.process.run` 直接跑 kernel。
|
|
159
164
|
*/
|
|
160
|
-
async function
|
|
165
|
+
async function hostInfoFromSettings(
|
|
166
|
+
$: HostDollar,
|
|
167
|
+
next: HostNext,
|
|
168
|
+
): Promise<{ runtimePath?: string; fingerprint?: string; ports?: number[] } | undefined> {
|
|
161
169
|
try {
|
|
162
170
|
const value = await $.settings.read({ key: 'searchfuseHosts', signal: next.signal });
|
|
163
171
|
const hosts = asRecord(value);
|
|
164
172
|
const claude = asRecord(hosts?.claudeCode);
|
|
165
|
-
|
|
166
|
-
|
|
173
|
+
if (claude === undefined) return undefined;
|
|
174
|
+
const path = claude.runtimePath;
|
|
175
|
+
const fingerprint = claude.fingerprint;
|
|
176
|
+
const ports = claude.ports;
|
|
177
|
+
return {
|
|
178
|
+
runtimePath: typeof path === 'string' && path !== '' ? path : undefined,
|
|
179
|
+
fingerprint: typeof fingerprint === 'string' && fingerprint !== '' ? fingerprint : undefined,
|
|
180
|
+
ports: Array.isArray(ports) ? ports.filter((p): p is number => typeof p === 'number' && Number.isInteger(p)) : undefined,
|
|
181
|
+
};
|
|
167
182
|
} catch {
|
|
168
183
|
return undefined;
|
|
169
184
|
}
|
|
170
185
|
}
|
|
171
186
|
|
|
187
|
+
async function runtimePathFromSettings($: HostDollar, next: HostNext): Promise<string | undefined> {
|
|
188
|
+
return (await hostInfoFromSettings($, next))?.runtimePath;
|
|
189
|
+
}
|
|
190
|
+
|
|
172
191
|
async function readServeRuntime(
|
|
173
192
|
$: HostDollar,
|
|
174
193
|
next: HostNext,
|
|
175
194
|
): Promise<ServeRuntime | undefined> {
|
|
176
|
-
const
|
|
177
|
-
if (runtimePath
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
const info = await hostInfoFromSettings($, next);
|
|
196
|
+
if (info?.runtimePath !== undefined) {
|
|
197
|
+
try {
|
|
198
|
+
const raw = await $.fs.read(info.runtimePath);
|
|
199
|
+
if (raw === cachedStamp && cachedRuntime !== undefined) return cachedRuntime;
|
|
200
|
+
const parsed = JSON.parse(raw) as { port?: unknown; token?: unknown };
|
|
201
|
+
// 与 omp、src/serveEnsure.ts、src/main.ts 逐条一致:整数校验 + 非空
|
|
202
|
+
// token。三处读同一个文件,宽严不一会让它们对「服务在不在」给出相反
|
|
203
|
+
// 答案——`3.5` 与 `NaN` 都是 `typeof === 'number'`。
|
|
204
|
+
if (
|
|
205
|
+
typeof parsed.port === 'number' &&
|
|
206
|
+
Number.isInteger(parsed.port) &&
|
|
207
|
+
typeof parsed.token === 'string' &&
|
|
208
|
+
parsed.token !== ''
|
|
209
|
+
) {
|
|
210
|
+
cachedRuntime = { port: parsed.port, token: parsed.token };
|
|
211
|
+
cachedStamp = raw;
|
|
212
|
+
return cachedRuntime;
|
|
213
|
+
}
|
|
214
|
+
} catch {
|
|
215
|
+
// 文件不在或读不了:往下走候选探测。
|
|
216
|
+
cachedRuntime = undefined;
|
|
217
|
+
cachedStamp = '';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// runtime.json 不在(服务被 kill 时 close 跑不到,文件会消失)。
|
|
222
|
+
// 按 CLI 预先写进 settings 的候选端口逐个探 /identity,指纹匹配才算。
|
|
223
|
+
// 只探 200 会把恰好占着那个端口的别的程序认成自己的服务,然后把 token
|
|
224
|
+
// 发给它。
|
|
225
|
+
if (info?.fingerprint === undefined || info.ports === undefined || info.ports.length === 0) {
|
|
190
226
|
return undefined;
|
|
191
227
|
}
|
|
228
|
+
// token 文件与 runtime.json 同目录:`runtime.json` → `serve-token`。
|
|
229
|
+
// 沙箱里读不了家目录,但这条路径由 runtimePath 直接推出,不需要 HOME。
|
|
230
|
+
const tokenPath = info.runtimePath === undefined ? undefined : serveTokenPathFrom(info.runtimePath);
|
|
231
|
+
if (tokenPath === undefined) return undefined;
|
|
232
|
+
for (const port of info.ports) {
|
|
233
|
+
try {
|
|
234
|
+
const body = await $.http.fetch(`http://127.0.0.1:${port}/identity`, {
|
|
235
|
+
headers: { accept: 'application/json' },
|
|
236
|
+
});
|
|
237
|
+
if (!body.ok) continue;
|
|
238
|
+
const parsed = JSON.parse(body.text) as { fingerprint?: unknown };
|
|
239
|
+
if (parsed.fingerprint !== info.fingerprint) continue;
|
|
240
|
+
// 指纹对上了:端口是这一份的服务,token 从同目录的 token 文件读。
|
|
241
|
+
const token = (await $.fs.read(tokenPath)).trim();
|
|
242
|
+
if (token !== '') {
|
|
243
|
+
cachedRuntime = { port, token };
|
|
244
|
+
cachedStamp = '';
|
|
245
|
+
return cachedRuntime;
|
|
246
|
+
}
|
|
247
|
+
} catch {
|
|
248
|
+
// 该端口不通或不是 JSON:换下一个。
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 从 runtime.json 的绝对路径推出 serve-token 的绝对路径。
|
|
256
|
+
*
|
|
257
|
+
* 两者永远同目录(都由 `serve.ts` 的 `runtimePath()` / `serveTokenPath()` 拼出),
|
|
258
|
+
* 所以这里只做一次字符串替换,不必再往 settings 里多写一条路径。
|
|
259
|
+
*/
|
|
260
|
+
function serveTokenPathFrom(runtimePath: string): string | undefined {
|
|
261
|
+
const index = runtimePath.lastIndexOf('runtime.json');
|
|
262
|
+
if (index === -1) return undefined;
|
|
263
|
+
return `${runtimePath.slice(0, index)}serve-token`;
|
|
192
264
|
}
|
|
193
265
|
|
|
194
266
|
/**
|
package/dist/kernel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as loadConfigFile, _ as currentConfigPath, m as allowsPrivateNetwork, t as runSearch } from "./search-
|
|
1
|
+
import { C as loadConfigFile, _ as currentConfigPath, i as buildCooldownController, m as allowsPrivateNetwork, t as runSearch } from "./search-DeT416xs.js";
|
|
2
2
|
// src/kernel.ts
|
|
3
3
|
/** 退出码。列成常量而不是散在代码里,因为调用方要按它们分支。 */
|
|
4
4
|
var EXIT_OK = 0;
|
|
@@ -15,14 +15,24 @@ function fail(message) {
|
|
|
15
15
|
*
|
|
16
16
|
* 手写而不是用 commander:这个入口要极薄,多加一个依赖就多一层要与
|
|
17
17
|
* 宿主版本对齐的东西。参数只有六个,手写更可靠。
|
|
18
|
+
*
|
|
19
|
+
* 别名必须把 CLI(`dist/main.js`)的短选项也列上:两边共用同一套 argv
|
|
20
|
+
* 契约,只认长选项会让 `-e foo`、`-s x` 被**整个跳过**,而不是报错。
|
|
21
|
+
* 那种跳过是最坏的一种沉默——参数看着给了,行为却是「按默认来」,
|
|
22
|
+
* 于是 `-e <拼错的引擎名>` 会回退成一次全引擎融合,花掉谁的额度都不会有人知道。
|
|
18
23
|
*/
|
|
19
24
|
function takeOption(args, ...names) {
|
|
20
25
|
for (let i = 0; i < args.length; i++) if (names.includes(args[i])) {
|
|
21
26
|
const value = args[i + 1];
|
|
22
|
-
if (value === void 0 || value
|
|
27
|
+
if (value === void 0 || looksLikeOption(value)) return;
|
|
23
28
|
return value;
|
|
24
29
|
}
|
|
25
30
|
}
|
|
31
|
+
/** 一个词是不是选项本身(而不是它的值)。 */
|
|
32
|
+
function looksLikeOption(word) {
|
|
33
|
+
if (word.startsWith("--")) return true;
|
|
34
|
+
return /^-[A-Za-z]$/.test(word);
|
|
35
|
+
}
|
|
26
36
|
/** 解析成整数;给了但不成整数就报错,而不是静默回落默认值。 */
|
|
27
37
|
function takeNumber(args, ...names) {
|
|
28
38
|
const raw = takeOption(args, ...names);
|
|
@@ -34,7 +44,7 @@ function takeNumber(args, ...names) {
|
|
|
34
44
|
async function main() {
|
|
35
45
|
const args = process.argv.slice(2);
|
|
36
46
|
const query = takeOption(args, "-q", "--query");
|
|
37
|
-
const url = takeOption(args, "--url");
|
|
47
|
+
const url = takeOption(args, "-u", "--url");
|
|
38
48
|
const hasQuery = query !== void 0 && query.trim() !== "";
|
|
39
49
|
const hasUrl = url !== void 0 && url.trim() !== "";
|
|
40
50
|
if (!hasQuery && !hasUrl) fail("nothing to do: give --query (or -q) to search, or --url to fetch a page");
|
|
@@ -42,14 +52,15 @@ async function main() {
|
|
|
42
52
|
const result = await runSearch({
|
|
43
53
|
query,
|
|
44
54
|
url,
|
|
45
|
-
engine: takeOption(args, "--engine"),
|
|
46
|
-
sources: takeOption(args, "--source"),
|
|
55
|
+
engine: takeOption(args, "-e", "--engine"),
|
|
56
|
+
sources: takeOption(args, "-s", "--source"),
|
|
47
57
|
timeoutMs: takeNumber(args, "--timeout") ?? DEFAULT_TIMEOUT_MS,
|
|
48
58
|
deadlineMs: takeNumber(args, "--deadline"),
|
|
49
59
|
deadlineStartedAt: performance.timeOrigin,
|
|
50
60
|
maxResults: takeNumber(args, "--max-results"),
|
|
51
61
|
allowPrivateNetwork: allowsPrivateNetwork(config),
|
|
52
|
-
config
|
|
62
|
+
config,
|
|
63
|
+
cooldown: buildCooldownController(config)
|
|
53
64
|
});
|
|
54
65
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
55
66
|
const hasResults = result.results.some((entry) => entry.status !== "unavailable");
|