@240xu/dsh-websearch 2.8.1 → 2.8.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 +13 -0
- package/lib/backends/exa.js +8 -4
- package/lib/provider.js +33 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,3 +253,16 @@ v2.7.0 缓存/熔断/历史三项的依据与刻意取舍(含查证过的反
|
|
|
253
253
|
## License | 许可
|
|
254
254
|
|
|
255
255
|
MIT © 2026 240xu
|
|
256
|
+
|
|
257
|
+
## 2.8.2 · Bug 猎场修复(P1×3 + 回归测试)
|
|
258
|
+
|
|
259
|
+
- **[P1] 零结果伪造失败**:所有后端成功但 0 命中时,原实现落进 `all enabled
|
|
260
|
+
backends failed (0) - `(计数自相矛盾、detail 空)并丢弃 mergedContent(Tavily
|
|
261
|
+
直答)。成功即空 → 正常返回 `{sources:[]}` + history 记录。
|
|
262
|
+
- **[P1] limiter 死锁**:`Promise.resolve(fn())` 先执行 fn——同步抛出(如 baseURL
|
|
263
|
+
校验在建 timeout 前)逃出后 `running` 永不递减,泄漏 ≥ concurrency 后所有任务
|
|
264
|
+
永久排队且超时机制未武装(实测 HUNG exit=13)。改 `Promise.resolve().then(fn)`。
|
|
265
|
+
- **[P1] exa category 漏门控**:tavily/searxng 的 deepCoverage 增强都门控,唯独
|
|
266
|
+
exa 漏了——默认关 deepCoverage 也注入 category 收窄结果,与 README 承诺相反。
|
|
267
|
+
- 回归测试 3 条(零结果/limiter 不死锁带 HUNG 超时护栏/exa 双态门控);
|
|
268
|
+
`createLimiter` 导出供测试。89/89。
|
package/lib/backends/exa.js
CHANGED
|
@@ -42,10 +42,14 @@ export const exaBackend = {
|
|
|
42
42
|
query: request.query,
|
|
43
43
|
numResults: request.maxResults ?? 8,
|
|
44
44
|
};
|
|
45
|
-
// v2.8.0: category inference
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// v2.8.0: category inference — deepCoverage-gated like tavily (searchDepth
|
|
46
|
+
// advanced) and searxng (category sweep): 2.8.1 审计发现此处漏了门控,
|
|
47
|
+
// 默认关着 deepCoverage 也注入 category,把结果悄悄收窄到单类目,与 README
|
|
48
|
+
// 「deepCoverage 深度覆盖」承诺相反。
|
|
49
|
+
if (request.deepCoverage === true) {
|
|
50
|
+
const category = inferExaCategory(request.query);
|
|
51
|
+
if (category) args.category = category;
|
|
52
|
+
}
|
|
49
53
|
hooks.recordRequest?.({
|
|
50
54
|
endpoint: EXA_ENDPOINT,
|
|
51
55
|
toolName: EXA_TOOL,
|
package/lib/provider.js
CHANGED
|
@@ -82,7 +82,8 @@ export function getBackendBreaker(id) {
|
|
|
82
82
|
* Simple concurrency limiter using a semaphore pattern.
|
|
83
83
|
* No external dependency needed.
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
// 2.8.2: exported for P1 regression tests (limiter sync-throw deadlock)
|
|
86
|
+
export function createLimiter(concurrency) {
|
|
86
87
|
const queue = [];
|
|
87
88
|
let running = 0;
|
|
88
89
|
|
|
@@ -95,7 +96,12 @@ function createLimiter(concurrency) {
|
|
|
95
96
|
while (running < concurrency && queue.length > 0) {
|
|
96
97
|
const { fn, resolve, reject } = queue.shift();
|
|
97
98
|
running++;
|
|
98
|
-
|
|
99
|
+
// 2.8.2(P1):必须 .then(fn) 而非 Promise.resolve(fn())——后者先执行
|
|
100
|
+
// fn(),同步抛出(如 runBackend 的 baseURL 校验在创建 timeout 之前 throw)
|
|
101
|
+
// 会逃出本函数:running 已 ++ 却永不 --(finally 没挂上),leaked 计数
|
|
102
|
+
// ≥ concurrency 后所有后续任务永久排队,且 timeoutId 未创建 → 超时也救不了
|
|
103
|
+
// (实测全挂起 exit=13)。.then(fn) 把同步抛出转为 rejection 落进 finally。
|
|
104
|
+
Promise.resolve().then(fn).then(resolve).catch(reject).finally(() => {
|
|
99
105
|
running--;
|
|
100
106
|
process();
|
|
101
107
|
});
|
|
@@ -435,6 +441,31 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
435
441
|
};
|
|
436
442
|
}
|
|
437
443
|
|
|
444
|
+
// 2.8.2(P1):零结果 ≠ 全部失败。所有后端成功但确实 0 条命中(冷僻查询/
|
|
445
|
+
// 过滤后为空)时,原实现无条件落入下面的 throw,模型端拿到
|
|
446
|
+
// `all enabled backends failed (0) - `(detail 空、计数自相矛盾),且丢弃已
|
|
447
|
+
// 拿到的 mergedContent(如 Tavily 直答)。成功即空 → 正常返回空结果。
|
|
448
|
+
if (allFailures.length === 0) {
|
|
449
|
+
let emptyContent = perVariant.find((v) => v.mergedContent !== undefined)?.mergedContent;
|
|
450
|
+
if (opts.resultHeader !== false && emptyContent !== undefined) {
|
|
451
|
+
const header = resultHeader(typeof request?.query === "string" && /[\u4e00-\u9fff]/.test(request.query) ? "zh" : "en");
|
|
452
|
+
emptyContent = header + "\n\n" + emptyContent;
|
|
453
|
+
}
|
|
454
|
+
history?.record({
|
|
455
|
+
query: request?.query,
|
|
456
|
+
time: Date.now(),
|
|
457
|
+
resultCount: 0,
|
|
458
|
+
backendsOk: allTelemetry.filter((t) => t.ok).length,
|
|
459
|
+
backendsTotal: allTelemetry.length,
|
|
460
|
+
});
|
|
461
|
+
if (cacheKey && cache) cache.set(cacheKey, { sources: [], content: emptyContent, truncated: false });
|
|
462
|
+
return {
|
|
463
|
+
sources: [],
|
|
464
|
+
...(emptyContent !== undefined ? { content: emptyContent } : {}),
|
|
465
|
+
truncated: false,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
438
469
|
// All enabled backends failed - synthesize one meaningful error that
|
|
439
470
|
// names each backend's own reason so the caller (model or user) can act.
|
|
440
471
|
const detail = allFailures.slice(0, 4)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@240xu/dsh-websearch",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"description": "Unified web search provider for DeepSeek Harness (ctx.web): 11 backends — Exa + Parallel + DDG + SearXNG (keyless), DeepSeek + Anthropic + OpenAI + Brave + Tavily + Serper + Mojeek (key-gated via Settings credentials). Registers provider id \"unified\" for zero-config web_search. 统一网页搜索聚合:11 后端并发扇出、去重合并,零依赖。See CHANGELOG.md for version history.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|