@240xu/dsh-websearch 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/backends/exa.js +0 -24
- package/lib/provider.js +21 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
|
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/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.1",
|
|
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",
|