@240xu/dsh-websearch 2.13.0 → 2.13.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/README.md +5 -5
- package/lib/backends/exa.js +0 -24
- package/lib/backends/parallel.js +0 -1
- package/lib/client.js +22 -6
- package/lib/index.js +1 -1
- package/lib/provider.js +21 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ pnpm install
|
|
|
101
101
|
| `intervention` | balanced | 搜索介入程度:`official` / `balanced` / `thorough`(见下表) |
|
|
102
102
|
| `numResults` | 10 | 每次搜索返回结果数(1-100;Exa 上限 100,official 档沿用宿主工具的条数上限) |
|
|
103
103
|
| `includeDomains` | 空 | 仅约束 OpenAI/Anthropic 原生后端(最多 20;其余后端不支持,合并结果仍可能来自其他域名) |
|
|
104
|
-
| `excludeDomains` | 空 | 排除这些域名(最多 20;Anthropic
|
|
104
|
+
| `excludeDomains` | 空 | 排除这些域名(最多 20;OpenAI/Anthropic 均只发一个列表,include 优先) |
|
|
105
105
|
| `concurrency` | 6 | 并发后端数(1-10) |
|
|
106
106
|
| `backendTimeoutMs` | 24000 | 单后端超时毫秒(为宿主 30s 工具超时预留余量) |
|
|
107
107
|
| `recency` | any | 时间范围过滤:day / week / month / year(映射到各后端原生参数) |
|
|
@@ -164,7 +164,7 @@ pnpm install
|
|
|
164
164
|
|
|
165
165
|
- 每后端请求条数上调至 `ceil(maxResults × 1.5)`,全局去重后仍按 maxResults 截断——牺牲带宽换覆盖面。
|
|
166
166
|
- 后端能力适配(feature-detect,不破坏旧参数):Tavily 自动切 `search_depth: advanced`(2 credits,多 snippet/URL);SearXNG 类目扩为 `general,news,it`(Search API `categories` 逗号列表)。
|
|
167
|
-
- Exa
|
|
167
|
+
- Exa:只发送工具 schema 声明的 `query` / `numResults`;不注入 category(`tools/list` 未声明)。
|
|
168
168
|
|
|
169
169
|
### 3. 运维可观测(P2)
|
|
170
170
|
|
|
@@ -269,7 +269,7 @@ tests/
|
|
|
269
269
|
node --test tests/
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
当前
|
|
272
|
+
当前 232/232 pass(`node --test tests/*.test.js`;`tests/up-health.test.mjs` 单独跑)。
|
|
273
273
|
|
|
274
274
|
### Test-only dependencies
|
|
275
275
|
|
|
@@ -294,7 +294,7 @@ v2.7.0 缓存/熔断/历史三项的依据与刻意取舍(含查证过的反
|
|
|
294
294
|
1. **熔断器(Circuit Breaker)**:出处 Michael T. Nygard《Release It!》(Pragmatic Bookshelf, 2007) 与 Microsoft Azure Architecture Center「Circuit Breaker pattern」https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker 。经典状态机是 Closed → Open → Half-Open(半开态放行少量探测请求)。**本插件刻意省略半开态**:冷却到期即视为 Closed(下一次真实搜索就是探测),失败则立即重新开窗——因为这里的"请求"是一次多后端扇出中的单个后端调用,探测请求必然真实发生且失败成本只是一次软降级,无需额外探测计数器;同时保留 fail-open 兜底(全部冷却时放行),比经典模式更保守。
|
|
295
295
|
2. **缓存失效(TTL-only vs 事件驱动)**:Cloudflare「Retention vs Freshness (TTL)」https://developers.cloudflare.com/cache/concepts/retention-vs-freshness/ 与「Revalidation」https://developers.cloudflare.com/cache/concepts/revalidation/ 。搜索结果没有可靠的原站变更信号可订阅(网页索引持续变化),事件驱动失效无锚点;TTL-only + 把 TTL 做成设置项(默认 900s)+ key 纳入后端组合,是"可接受的最终一致性"。取舍:900s 内索引更新不可见——对搜索场景可接受,且用户可调低。
|
|
296
296
|
3. **原子写(tmp + renameSync)**:POSIX 上 rename(2) 原子替换(Node 文档:newPath 已存在时覆盖);Windows 上 libuv 将 fs.rename 映射为 MoveFileExW(MOVEFILE_REPLACE_EXISTING)(libuv#283 https://github.com/joyent/libuv/issues/283 ,LWN 讨论 https://lwn.net/Articles/682988/ 指出 MS 文档不承诺该调用的原子性)。**结论:POSIX 双端原子;Windows 实践上等价但官方文档不背书**——因此本插件在写入端额外做了兜底:读端永远校验 JSON 完整性、坏条目按 miss 处理并删除,即使 Windows 上出现半写状态也不会返回坏数据。
|
|
297
|
-
4b. **查全查多(v2.8.0)**:Tavily Search API(`search_depth: advanced` 2 credits、`max_results` 0-20、`include_answer`、topic=news 时间加权)https://docs.tavily.com/api-reference/endpoint/search ;Exa Search API(type 分类检索、category 枚举、livecrawl;注意 2026 版 coding-agent 指南声明 neural 为 legacy 术语、且告诫勿臆造 category
|
|
297
|
+
4b. **查全查多(v2.8.0)**:Tavily Search API(`search_depth: advanced` 2 credits、`max_results` 0-20、`include_answer`、topic=news 时间加权)https://docs.tavily.com/api-reference/endpoint/search ;Exa Search API(type 分类检索、category 枚举、livecrawl;注意 2026 版 coding-agent 指南声明 neural 为 legacy 术语、且告诫勿臆造 category 值;2.13.1 起插件已停止注入 category——MCP tools/list 未声明该参数)https://exa.ai/docs/reference/search-api-guide-for-coding-agents 与 https://github.com/exa-labs/openapi-spec/blob/master/exa-openapi-spec.yaml ;SearXNG Search API(`categories` 逗号多类目、`language`)https://docs.searxng.org/dev/search_api.html ;Brave Search API(`freshness`、`result_filter`,本轮仅调研未接线)https://api-dashboard.search.brave.com/app/documentation 。多查询融合:RRF 出自 Cormack et al. 2009,RAG-Fusion 实现 https://github.com/Raudaschl/rag-fusion ;HyDE https://arxiv.org/abs/2212.10496 ;**门控依据** arXiv:2404.01037(盲目多查询劣化)——因此 multiQuery 默认关、启发式从严、原查询全权重参与。
|
|
298
298
|
4c. **per-backend 超时**:不可达主机的 TCP 连接失败不受应用层超时保护,只能靠 abort 计时器兜底;ddg(HTML 抓取)与 SearXNG(公共实例无 SLA)是拖尾主力,8s 上限取「P50 成功延迟的一个数量级」。
|
|
299
299
|
4d. **搜索历史隐私**:Article 29 Working Party 意见书 WP148 https://ec.europa.eu/justice/article-29/documentation/opinion-recommendation/files/2008/wp148_en.pdf 认定查询日志(query + 时间 + 来源标识)属个人数据;EFF 六条自保建议 https://w2.eff.org/Privacy/search/searchtips.pdf 的第一条是"别在搜索词里放 PII"——说明 query 天然可能携带 PII(人名、账号、地址)。本插件的取舍:历史只存 {query, time, resultCount, backendsOk/Total}(无 IP、无 cookie、无结果 URL)、环形 50 条自动滚动即短保留、本机存储不出网、提供 historyEnabled 开关与 POST clear 端点。**未做 query 脱敏**:脱敏会破坏"查看最近搜了什么"的核心用途,且本机单用户场景下该数据本就在 DSH 会话日志里存在;若未来历史跨设备同步,脱敏/加密是上线前置条件。
|
|
300
300
|
|
|
@@ -311,7 +311,7 @@ MIT © 2026 240xu
|
|
|
311
311
|
校验在建 timeout 前)逃出后 `running` 永不递减,泄漏 ≥ concurrency 后所有任务
|
|
312
312
|
永久排队且超时机制未武装(实测 HUNG exit=13)。改 `Promise.resolve().then(fn)`。
|
|
313
313
|
- **[P1] exa category 漏门控**:tavily/searxng 的 deepCoverage 增强都门控,唯独
|
|
314
|
-
exa 漏了——默认关 deepCoverage 也注入 category 收窄结果,与 README
|
|
314
|
+
exa 漏了——默认关 deepCoverage 也注入 category 收窄结果,与 README 承诺相反(2.13.1 已整体移除 category 注入)。
|
|
315
315
|
- 回归测试 3 条(零结果/limiter 不死锁带 HUNG 超时护栏/exa 双态门控);
|
|
316
316
|
`createLimiter` 导出供测试。89/89。
|
|
317
317
|
|
package/lib/backends/exa.js
CHANGED
|
@@ -14,22 +14,6 @@ import { describeError } from "../util/describe-error.js";
|
|
|
14
14
|
const EXA_ENDPOINT = "https://mcp.exa.ai/mcp";
|
|
15
15
|
const EXA_TOOL = "web_search_exa";
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Infer an Exa data category from the query (v2.8.0). Only high-confidence
|
|
19
|
-
* patterns map — Exa rejects unknown categories with a 400, so this returns
|
|
20
|
-
* undefined unless a signal is explicit. Valid values per the Exa OpenAPI
|
|
21
|
-
* enum: github / "research paper" / news / pdf / company / people /
|
|
22
|
-
* "personal site" / "financial report".
|
|
23
|
-
*/
|
|
24
|
-
export function inferExaCategory(query) {
|
|
25
|
-
const q = typeof query === "string" ? query.toLowerCase() : "";
|
|
26
|
-
if (!q) return undefined;
|
|
27
|
-
if (/\bgithub\b|\brepo\b|repository|开源项目|源码/.test(q)) return "github";
|
|
28
|
-
if (/\barxiv\b|\bpaper\b|论文|研究文献|preprint/.test(q)) return "research paper";
|
|
29
|
-
if (/\bnews\b|新闻|最新消息|动态/.test(q)) return "news";
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
17
|
export const exaBackend = {
|
|
34
18
|
id: "exa",
|
|
35
19
|
requiresCredential: false,
|
|
@@ -43,14 +27,6 @@ export const exaBackend = {
|
|
|
43
27
|
query: request.query,
|
|
44
28
|
numResults: Math.max(1, Math.min(Number(request.maxResults) || 10, 100)),
|
|
45
29
|
};
|
|
46
|
-
// v2.8.0: category inference — deepCoverage-gated like tavily (searchDepth
|
|
47
|
-
// advanced) and searxng (category sweep): 2.8.1 审计发现此处漏了门控,
|
|
48
|
-
// 默认关着 deepCoverage 也注入 category,把结果悄悄收窄到单类目,与 README
|
|
49
|
-
// 「deepCoverage 深度覆盖」承诺相反。
|
|
50
|
-
if (request.deepCoverage === true) {
|
|
51
|
-
const category = inferExaCategory(request.query);
|
|
52
|
-
if (category) args.category = category;
|
|
53
|
-
}
|
|
54
30
|
hooks.recordRequest?.({
|
|
55
31
|
endpoint: EXA_ENDPOINT,
|
|
56
32
|
toolName: EXA_TOOL,
|
package/lib/backends/parallel.js
CHANGED
|
@@ -37,7 +37,6 @@ export const parallelBackend = {
|
|
|
37
37
|
|
|
38
38
|
async search(request, signal, options, hooks = {}) {
|
|
39
39
|
const args = {
|
|
40
|
-
objective: request.query,
|
|
41
40
|
objective: request.searchPlan?.objective ?? request.query,
|
|
42
41
|
search_queries: request.searchPlan?.queries?.slice(0, 3) ?? [request.query],
|
|
43
42
|
session_id: SESSION_ID,
|
package/lib/client.js
CHANGED
|
@@ -133,6 +133,8 @@ window.__ModuleLoader__.load({
|
|
|
133
133
|
resultHeaderLabel: "结果引用提示头",
|
|
134
134
|
cacheLabel: "结果缓存",
|
|
135
135
|
cacheTtlLabel: "缓存有效期(秒)",
|
|
136
|
+
cacheTtlHint: "30 秒的整数倍;0 = 不缓存(no-store)",
|
|
137
|
+
cacheOffHint: "结果缓存关闭时此项不生效。",
|
|
136
138
|
fallbackHint: "全部后端已关闭:搜索将回退到默认免 Key 后端(计量型仍保持关闭)",
|
|
137
139
|
invalidFields: "以下字段未通过校验:",
|
|
138
140
|
readOnlyScope: "当前配置只读(可能由宿主锁定)",
|
|
@@ -223,6 +225,8 @@ window.__ModuleLoader__.load({
|
|
|
223
225
|
resultHeaderLabel: "Citation header",
|
|
224
226
|
cacheLabel: "Result cache",
|
|
225
227
|
cacheTtlLabel: "Cache TTL (s)",
|
|
228
|
+
cacheTtlHint: "Multiple of 30 s; 0 disables the cache (no-store).",
|
|
229
|
+
cacheOffHint: "Ignored while the result cache is off.",
|
|
226
230
|
fallbackHint: "All backends off: search falls back to the default keyless four (metered backends stay off).",
|
|
227
231
|
invalidFields: "Fields failed validation:",
|
|
228
232
|
readOnlyScope: "Configuration is read-only (locked by host?)",
|
|
@@ -239,7 +243,7 @@ window.__ModuleLoader__.load({
|
|
|
239
243
|
};
|
|
240
244
|
|
|
241
245
|
//#region styles
|
|
242
|
-
const css = ".wsc-card{display:flex;flex-direction:column;gap:8px}.wsc-sectionTitle{margin:24px 0 0;font-size:14px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}.wsc-toggles{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:6px}.wsc-toggle{display:flex;align-items:center;gap:8px;padding:7px 10px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:13px;color:var(--dsw-alias-label-primary);background:0 0;transition:background-color .16s,border-color .16s}@media (hover:hover){.wsc-toggle:hover{background:var(--dsw-alias-interactive-bg-hover)}}.wsc-toggle input{accent-color:var(--dsw-alias-brand-primary)}.wsc-toggle:has(input:focus-visible){outline:none;box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.wsc-toggle input:focus-visible{outline:none}.wsc-input,.wsc-keyInput{box-sizing:border-box;height:32px;width:100%;padding:0 10px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;font-family:inherit}select.wsc-input{cursor:pointer;max-width:240px}.wsc-input:focus,.wsc-keyInput:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}.wsc-input:disabled,.wsc-keyInput:disabled{opacity:.6;cursor:default}.wsc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px}.wsc-fieldHead{display:flex;justify-content:space-between;align-items:center;margin-bottom:3px}.wsc-label{font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary)}.wsc-badge{font-size:11px;padding:1px 8px;border-radius:var(--dsw-radius-xs);border:.5px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary)}.wsc-badgeOn{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-state-success-primary)}.wsc-hint{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-secondary);margin:3px 0 0}.wsc-error{color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 85%,var(--dsw-alias-label-primary));font-size:12px}.wsc-warn{color:color-mix(in srgb,var(--dsw-alias-state-warn-label) 65%,var(--dsw-alias-label-primary));font-size:12px}.wsc-strip{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-module-platform)}.wsc-keyCard{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill)}.wsc-live{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-height:16px}.wsc-actionsStatic{position:static;border-top:0;padding:0;background:transparent}.wsc-actions{position:sticky;bottom:0;display:flex;gap:8px;align-items:center;padding:8px 0;background:var(--dsw-alias-bg-layer-2);border-top:.5px solid var(--dsw-alias-border-l2)}.wsc-btn{box-sizing:border-box;cursor:pointer;border:none;border-radius:var(--dsw-radius-md);height:36px;padding:0 14px;font-size:14px;line-height:22px;font-family:inherit;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.wsc-btn:hover:not(.wsc-btnGhost):not(:disabled){background:var(--dsw-alias-button-primary-hover)}.wsc-btn:focus-visible{outline:none;box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.wsc-btnGhost{background:0 0;color:var(--dsw-alias-label-primary);border:.5px solid var(--dsw-alias-border-l3)}.wsc-btnGhost:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}.wsc-btn:disabled{opacity:.4;cursor:default}.wsc-status{font-size:12px;color:var(--dsw-alias-label-secondary)}.wsc-status.wsc-error{color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 85%,var(--dsw-alias-label-primary))}.wsc-status.wsc-warn{color:color-mix(in srgb,var(--dsw-alias-state-warn-label) 65%,var(--dsw-alias-label-primary))}.wsc-dot{width:8px;height:8px;border-radius:50%;display:inline-block}.wsc-dotOn{background:var(--dsw-alias-state-success-primary)}.wsc-dotWarn{background:var(--dsw-alias-state-warn-primary)}.wsc-dotOff{background:var(--dsw-alias-label-tertiary)}.wsc-link{color:color-mix(in srgb,var(--dsw-alias-link) 90%,var(--dsw-alias-label-primary));text-decoration:none;border-radius:var(--dsw-radius-xs)}.wsc-link:hover{text-decoration:underline}.wsc-card fieldset[disabled] .wsc-toggle{opacity:.6;cursor:default}.wsc-card fieldset[disabled] .wsc-toggle:hover{background:transparent}";
|
|
246
|
+
const css = ".wsc-card{display:flex;flex-direction:column;gap:8px}.wsc-sectionTitle{margin:24px 0 0;font-size:14px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}.wsc-toggles{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:6px}.wsc-toggle{display:flex;align-items:center;gap:8px;padding:7px 10px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:13px;color:var(--dsw-alias-label-primary);background:0 0;transition:background-color .16s,border-color .16s}@media (hover:hover){.wsc-toggle:hover{background:var(--dsw-alias-interactive-bg-hover)}}.wsc-toggle input{accent-color:var(--dsw-alias-brand-primary)}.wsc-toggle:has(input:focus-visible){outline:none;box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.wsc-toggle input:focus-visible{outline:none}.wsc-input,.wsc-keyInput{box-sizing:border-box;height:32px;width:100%;padding:0 10px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;font-family:inherit}select.wsc-input{cursor:pointer;max-width:240px}.wsc-input[aria-invalid='true']{border-color:var(--dsw-alias-state-error-primary)}.wsc-input:focus,.wsc-keyInput:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}.wsc-input:disabled,.wsc-keyInput:disabled{opacity:.6;cursor:default}.wsc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px}.wsc-fieldHead{display:flex;justify-content:space-between;align-items:center;margin-bottom:3px}.wsc-label{font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary)}.wsc-badge{font-size:11px;padding:1px 8px;border-radius:var(--dsw-radius-xs);border:.5px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary)}.wsc-badgeOn{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-state-success-primary)}.wsc-hint{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-secondary);margin:3px 0 0}.wsc-error{color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 85%,var(--dsw-alias-label-primary));font-size:12px}.wsc-warn{color:color-mix(in srgb,var(--dsw-alias-state-warn-label) 65%,var(--dsw-alias-label-primary));font-size:12px}.wsc-strip{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-module-platform)}.wsc-keyCard{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill)}.wsc-live{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-height:16px}.wsc-actionsStatic{position:static;border-top:0;padding:0;background:transparent}.wsc-actions{position:sticky;bottom:0;display:flex;gap:8px;align-items:center;padding:8px 0;background:var(--dsw-alias-bg-layer-2);border-top:.5px solid var(--dsw-alias-border-l2)}.wsc-btn{box-sizing:border-box;cursor:pointer;border:none;border-radius:var(--dsw-radius-md);height:36px;padding:0 14px;font-size:14px;line-height:22px;font-family:inherit;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.wsc-btn:hover:not(.wsc-btnGhost):not(:disabled){background:var(--dsw-alias-button-primary-hover)}.wsc-btn:focus-visible{outline:none;box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.wsc-btnGhost{background:0 0;color:var(--dsw-alias-label-primary);border:.5px solid var(--dsw-alias-border-l3)}.wsc-btnGhost:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}.wsc-btn:disabled{opacity:.4;cursor:default}.wsc-status{font-size:12px;color:var(--dsw-alias-label-secondary)}.wsc-status.wsc-error{color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 85%,var(--dsw-alias-label-primary))}.wsc-status.wsc-warn{color:color-mix(in srgb,var(--dsw-alias-state-warn-label) 65%,var(--dsw-alias-label-primary))}.wsc-dot{width:8px;height:8px;border-radius:50%;display:inline-block}.wsc-dotOn{background:var(--dsw-alias-state-success-primary)}.wsc-dotWarn{background:var(--dsw-alias-state-warn-primary)}.wsc-dotOff{background:var(--dsw-alias-label-tertiary)}.wsc-link{color:color-mix(in srgb,var(--dsw-alias-link) 90%,var(--dsw-alias-label-primary));text-decoration:none;border-radius:var(--dsw-radius-xs)}.wsc-link:hover{text-decoration:underline}.wsc-card fieldset[disabled] .wsc-toggle{opacity:.6;cursor:default}.wsc-card fieldset[disabled] .wsc-toggle:hover{background:transparent}";
|
|
243
247
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"dsh-websearch/card\"]") === null) {
|
|
244
248
|
const tag = document.createElement("style");
|
|
245
249
|
tag.dataset.plugin = "@240xu/dsh-websearch";
|
|
@@ -640,7 +644,7 @@ window.__ModuleLoader__.load({
|
|
|
640
644
|
* as if it had been saved. A second call while one is running is a no-op.
|
|
641
645
|
*/
|
|
642
646
|
async save() {
|
|
643
|
-
if (this.saving) return;
|
|
647
|
+
if (this.saving || (this.staged.size === 0 && this.stagedKeys.size === 0)) return;
|
|
644
648
|
this.saving = true; this.failed = false;
|
|
645
649
|
this.conflict = false; this.failedFields.clear(); this.republish();
|
|
646
650
|
const doneFields = [];
|
|
@@ -692,6 +696,10 @@ window.__ModuleLoader__.load({
|
|
|
692
696
|
fieldOps.push({ op: "set", path: [field], value: staged.text }); fieldOpNames.push(field);
|
|
693
697
|
}
|
|
694
698
|
}
|
|
699
|
+
if (this.failedFields.size > 0) {
|
|
700
|
+
// All-or-nothing: never half-commit a Save the card reports as failed.
|
|
701
|
+
this.saving = false; this.republish(); return;
|
|
702
|
+
}
|
|
695
703
|
if (fieldOps.length > 0) {
|
|
696
704
|
if (typeof this.scope.setMany === "function") {
|
|
697
705
|
await this.scope.setMany(fieldOps);
|
|
@@ -941,6 +949,7 @@ window.__ModuleLoader__.load({
|
|
|
941
949
|
function SettingsFields(props) {
|
|
942
950
|
const { state, card, t } = props;
|
|
943
951
|
const selVal = (f, dflt) => state.stagedText(f) ?? String(state.value[f] ?? dflt);
|
|
952
|
+
const cacheOn = selVal("cacheEnabled", "true") !== "false";
|
|
944
953
|
const recencyOptions = [
|
|
945
954
|
{ value: "any", label: t("recencyAny") },
|
|
946
955
|
{ value: "day", label: t("recencyDay") },
|
|
@@ -986,7 +995,8 @@ window.__ModuleLoader__.load({
|
|
|
986
995
|
] }),
|
|
987
996
|
react_jsx_runtime.jsxs("div", { children: [
|
|
988
997
|
react_jsx_runtime.jsx("div", { className: "wsc-fieldHead", children: react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("cacheTtlLabel") }) }),
|
|
989
|
-
react_jsx_runtime.jsx("input", { className: "wsc-input", "aria-label": t("cacheTtlLabel"), value: state.stagedText("cacheTtl") ?? String(state.value.cacheTtl ?? ""), onChange: (e) => card.edit("cacheTtl", e.target.value), inputMode: "numeric" }),
|
|
998
|
+
react_jsx_runtime.jsx("input", { className: "wsc-input", id: "wsc-cacheTtl", "aria-label": t("cacheTtlLabel"), "aria-describedby": "wsc-cacheTtl-hint", "aria-invalid": state.failedFields.includes("cacheTtl") || undefined, disabled: !cacheOn, value: state.stagedText("cacheTtl") ?? String(state.value.cacheTtl ?? ""), onChange: (e) => card.edit("cacheTtl", e.target.value), inputMode: "numeric" }),
|
|
999
|
+
react_jsx_runtime.jsx("p", { className: "wsc-hint", id: "wsc-cacheTtl-hint", children: cacheOn ? t("cacheTtlHint") : t("cacheTtlHint") + " " + t("cacheOffHint") }),
|
|
990
1000
|
] }),
|
|
991
1001
|
] }),
|
|
992
1002
|
react_jsx_runtime.jsx("h4", { className: "wsc-sectionTitle", children: t("shapingTitle") }),
|
|
@@ -1047,16 +1057,16 @@ window.__ModuleLoader__.load({
|
|
|
1047
1057
|
}) }),
|
|
1048
1058
|
state.stagedCount > 0 && react_jsx_runtime.jsx("p", { style: { margin: 0, fontSize: 12, opacity: .65 }, children: t("unsavedHint") }),
|
|
1049
1059
|
react_jsx_runtime.jsxs("div", { className: "wsc-actions", children: [
|
|
1050
|
-
react_jsx_runtime.jsx("button", { className: "wsc-btn", disabled: state.saving || state.
|
|
1060
|
+
react_jsx_runtime.jsx("button", { className: "wsc-btn", disabled: state.saving || state.writable === false, onClick: () => card.save(), children: state.saving ? t("saving") : t("save") }),
|
|
1051
1061
|
(state.stagedCount > 0) && react_jsx_runtime.jsx("button", { className: "wsc-btn wsc-btnGhost", disabled: state.saving, onClick: () => card.discard(), children: t("discard") }),
|
|
1052
1062
|
react_jsx_runtime.jsxs("span", { className: "wsc-live", role: "status", "aria-live": "polite", children: [
|
|
1053
1063
|
state.failed && !state.conflict && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-error", children: t("saveFailed") }),
|
|
1054
1064
|
state.toggleFailed && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-error", children: t("toggleFailed") + (state.toggleConflict ? " — " + t("conflict") : "") }),
|
|
1055
|
-
(state.failedFields.length > 0) && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-warn", children: t("invalidFields") + " " + state.failedFields.join(", ") }),
|
|
1065
|
+
(state.failedFields.length > 0) && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-warn", children: t("invalidFields") + " " + state.failedFields.map((f) => t({ cacheTtl: "cacheTtlLabel", backendTimeoutMs: "timeoutLabel", numResults: "numResultsLabel", concurrency: "concurrencyLabel" }[f] ?? f)).join(", ") }),
|
|
1056
1066
|
state.conflict && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-warn", children: t("conflictHint") }),
|
|
1057
|
-
state.conflict && react_jsx_runtime.jsx("button", { className: "wsc-btn wsc-btnGhost", disabled: state.saving, onClick: () => card.retry(), children: t("retry") }),
|
|
1058
1067
|
!state.failed && !state.saving && state.savedAt > 0 && react_jsx_runtime.jsx("span", { className: "wsc-status", children: t("savedOk") }),
|
|
1059
1068
|
] }),
|
|
1069
|
+
state.conflict && react_jsx_runtime.jsx("button", { className: "wsc-btn wsc-btnGhost", disabled: state.saving, onClick: () => card.retry(), children: t("retry") }),
|
|
1060
1070
|
] }),
|
|
1061
1071
|
] });
|
|
1062
1072
|
}
|
|
@@ -1064,6 +1074,11 @@ window.__ModuleLoader__.load({
|
|
|
1064
1074
|
function UnifiedSearchSection(props) {
|
|
1065
1075
|
const state = props.useUnifiedSearchCard((snapshot) => snapshot);
|
|
1066
1076
|
const card = { edit: props.edit, setToggle: props.setToggle, reset: props.reset, editKey: props.editKey, save: props.save, discard: props.discard, retry: props.retry };
|
|
1077
|
+
react.useEffect(() => {
|
|
1078
|
+
if (!state.failedFields || state.failedFields.length === 0) return;
|
|
1079
|
+
if (typeof document === "undefined") return;
|
|
1080
|
+
document.querySelector('.wsc-input[aria-invalid="true"]')?.focus();
|
|
1081
|
+
}, [state.failedFields.join(",")]);
|
|
1067
1082
|
// Occupants of settings.plugin.item render inside the tab's <ul>; use <li>.
|
|
1068
1083
|
if (!state.ready) {
|
|
1069
1084
|
return react_jsx_runtime.jsx("div", { className: "wsc-card", style: { fontSize: 12, opacity: .6 }, role: "status", "aria-live": "polite", children: props.t("loading") });
|
|
@@ -1107,6 +1122,7 @@ window.__ModuleLoader__.load({
|
|
|
1107
1122
|
{ value: "false", label: props.t("off") },
|
|
1108
1123
|
];
|
|
1109
1124
|
const selVal = (f, dflt) => state.stagedText(f) ?? String(state.value[f] ?? dflt);
|
|
1125
|
+
const cacheOn = selVal("cacheEnabled", "true") !== "false";
|
|
1110
1126
|
|
|
1111
1127
|
return react_jsx_runtime.jsxs("div", { className: "wsc-card", children: [
|
|
1112
1128
|
react_jsx_runtime.jsx(StatusSummary, { state, enabledCount, hasOverride: override.length > 0, keysReady, t: props.t }),
|
package/lib/index.js
CHANGED
|
@@ -179,7 +179,7 @@ export const Config = z.object({
|
|
|
179
179
|
includeDomains: z.string().default("")
|
|
180
180
|
.description("只约束 OpenAI/Anthropic 原生后端的允许域名(逗号/空格分隔,最多 20 个);其余后端不支持,合并结果仍可能来自其他域名"),
|
|
181
181
|
excludeDomains: z.string().default("")
|
|
182
|
-
.description("排除这些域名(逗号/空格分隔,最多 20 个);Anthropic
|
|
182
|
+
.description("排除这些域名(逗号/空格分隔,最多 20 个);OpenAI 与 Anthropic 均只发一个列表(include 优先)"),
|
|
183
183
|
dedupStrategy: z.union(["url", "url+title"]).default("url")
|
|
184
184
|
.description("去重策略:url 仅按链接;url+title 额外合并同标题的转载镜像"),
|
|
185
185
|
rerank: z.boolean().default(false)
|
package/lib/provider.js
CHANGED
|
@@ -585,9 +585,12 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
585
585
|
rateLimited: rateLimited(err), keylessRejected: keylessRejected(err), retryAfterMs: retryAfterMsFrom(err),
|
|
586
586
|
});
|
|
587
587
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
if (timedOut) {
|
|
589
|
+
const wrapped = new WebError(reason, "WEB_PROVIDER_ERROR", { cause: err instanceof Error ? err : undefined });
|
|
590
|
+
wrapped.timedOut = true;
|
|
591
|
+
throw wrapped;
|
|
592
|
+
}
|
|
593
|
+
throw err;
|
|
591
594
|
},
|
|
592
595
|
)
|
|
593
596
|
.finally(() => { clearTimeout(timeoutId); guardCleanup(); });
|
|
@@ -631,10 +634,11 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
631
634
|
// would contradict a success from the same backend in variant 1.
|
|
632
635
|
const minVariantBudgetMs = Math.min(Number(opts.backendTimeoutMs) || 24000, 2000);
|
|
633
636
|
if (remaining < minVariantBudgetMs) break;
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
// the
|
|
637
|
-
|
|
637
|
+
// Per-backend timeout is a contract, not a per-variant quota: a
|
|
638
|
+
// variant gets the configured timeout while the shared deadline still
|
|
639
|
+
// bounds the whole search. Dividing by the variant count made a
|
|
640
|
+
// healthy 1s backend fail at 666ms under three variants.
|
|
641
|
+
const share = Math.max(1, Math.min(remaining, Number(opts.backendTimeoutMs) || 24000));
|
|
638
642
|
// Parallel can merge the derived facets into one request; give it the
|
|
639
643
|
// plan on the primary variant and skip it for later variants. Other
|
|
640
644
|
// backends must not opt into handlesAllVariants (they cannot merge
|
|
@@ -659,7 +663,11 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
659
663
|
};
|
|
660
664
|
const fold = await fanoutVariant(variantReq, share, searchDeadline, variantEligible);
|
|
661
665
|
if (variantIndex === 0 && useMulti) {
|
|
662
|
-
|
|
666
|
+
// A hung plan backend will not recover under a smaller later share;
|
|
667
|
+
// only fast failures fall back to per-facet retries.
|
|
668
|
+
primaryPlanFailed = fold.failures.some(
|
|
669
|
+
(failure) => planBackendIds.has(failure.id) && failure.err?.timedOut !== true,
|
|
670
|
+
);
|
|
663
671
|
}
|
|
664
672
|
for (const outcome of fold.health) {
|
|
665
673
|
const prev = searchHealth.get(outcome.id);
|
|
@@ -720,14 +728,17 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
720
728
|
foldedTelemetry.push(copy);
|
|
721
729
|
continue;
|
|
722
730
|
}
|
|
731
|
+
if (prev.ok === true) continue; // a success already won; keep its latency
|
|
723
732
|
if (t.ok === true) {
|
|
724
733
|
prev.ok = true;
|
|
734
|
+
prev.skipped = false;
|
|
725
735
|
prev.count = Math.max(prev.count ?? 0, t.count ?? 0);
|
|
726
736
|
prev.error = undefined;
|
|
727
|
-
|
|
737
|
+
prev.ms = t.ms ?? 0;
|
|
738
|
+
} else {
|
|
728
739
|
prev.error = t.error;
|
|
740
|
+
prev.ms = Math.max(prev.ms ?? 0, t.ms ?? 0);
|
|
729
741
|
}
|
|
730
|
-
prev.ms = Math.max(prev.ms ?? 0, t.ms ?? 0);
|
|
731
742
|
}
|
|
732
743
|
const okCount = foldedTelemetry.filter((t) => t.ok).length;
|
|
733
744
|
const historyOk = new Set(allTelemetry.filter((t) => t.ok).map((t) => t.id)).size;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@240xu/dsh-websearch",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.2",
|
|
4
4
|
"description": "Unified web search provider for DeepSeek Harness (ctx.web): 13 backends — Exa + Parallel + DDG + SearXNG (keyless), DeepSeek + Anthropic + OpenAI + Brave + Tavily + Serper + Mojeek (key-gated via Settings credentials), Firecrawl + TinyFish (metered keyless, opt-in). Registers provider id \"unified\" for zero-config web_search. 统一网页搜索聚合:13 后端并发扇出、去重合并。See CHANGELOG.md for version history.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|