@240xu/dsh-websearch 2.12.0 → 2.13.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.
Files changed (2) hide show
  1. package/lib/provider.js +9 -2
  2. package/package.json +1 -1
package/lib/provider.js CHANGED
@@ -370,7 +370,7 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
370
370
  // cache hit for a four-backend search used to report one backend.
371
371
  const hitOk = Number.isInteger(hit.value.backendsOk) ? hit.value.backendsOk : 1;
372
372
  const hitTotal = Number.isInteger(hit.value.backendsTotal) ? hit.value.backendsTotal : 1;
373
- recordHistory(history, request?.query, hit.value.sources.length, hitOk, hitTotal);
373
+ recordHistory(history, request?.query, safeSources.length, hitOk, hitTotal);
374
374
  return {
375
375
  sources: safeSources,
376
376
  ...(hitContent !== undefined ? { content: hitContent } : {}),
@@ -621,6 +621,8 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
621
621
  // Final outcome per backend across every variant. Success wins; otherwise
622
622
  // keep the latest failure and the most severe quota classification.
623
623
  const searchHealth = new Map();
624
+ const planBackendIds = new Set(eligible.filter(({ backend }) => backend.handlesAllVariants === true).map(({ id }) => id));
625
+ let primaryPlanFailed = false;
624
626
  for (let variantIndex = 0; variantIndex < variants.length; variantIndex += 1) {
625
627
  const variantQuery = variants[variantIndex];
626
628
  const remaining = searchDeadline - Date.now();
@@ -640,7 +642,9 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
640
642
  const searchPlan = useMulti && variantIndex === 0
641
643
  ? { objective: effReq.query, queries: variants.slice(0, 3) }
642
644
  : undefined;
643
- const variantEligible = variantIndex === 0
645
+ // If the single planned call failed, later variants retry the
646
+ // plan-capable backend per facet instead of silently losing it.
647
+ const variantEligible = variantIndex === 0 || primaryPlanFailed
644
648
  ? eligible
645
649
  : eligible.filter(({ backend }) => backend.handlesAllVariants !== true);
646
650
  const variantReq = {
@@ -654,6 +658,9 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
654
658
  pageLimit: coverage && !useMulti ? 2 : 1,
655
659
  };
656
660
  const fold = await fanoutVariant(variantReq, share, searchDeadline, variantEligible);
661
+ if (variantIndex === 0 && useMulti) {
662
+ primaryPlanFailed = fold.failures.some((failure) => planBackendIds.has(failure.id));
663
+ }
657
664
  for (const outcome of fold.health) {
658
665
  const prev = searchHealth.get(outcome.id);
659
666
  if (prev === undefined || outcome.ok === true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@240xu/dsh-websearch",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
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",