@240xu/dsh-websearch 2.13.2 → 2.13.3
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/provider.js +16 -11
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/provider.js
CHANGED
|
@@ -497,12 +497,6 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
497
497
|
}
|
|
498
498
|
const configuredTimeoutMs = effectiveBackendTimeoutMs(id, backendTimeoutMs);
|
|
499
499
|
const effectiveTimeoutMs = Math.max(1, Math.min(configuredTimeoutMs, variantBudgetMs, remainingNow));
|
|
500
|
-
// A call cut below its configured timeout by the shared budget is
|
|
501
|
-
// not an outage: do not fold it into the breaker/health.
|
|
502
|
-
// Startup jitter can shave a millisecond off the configured timeout; only
|
|
503
|
-
// a material cut is budget starvation.
|
|
504
|
-
const budgetClipped = effectiveTimeoutMs < configuredTimeoutMs
|
|
505
|
-
&& remainingNow < configuredTimeoutMs - 10;
|
|
506
500
|
const timeoutId = setTimeout(() => controller.abort(), effectiveTimeoutMs);
|
|
507
501
|
// A backend that ignores its signal (blackholed TCP, stuck proxy)
|
|
508
502
|
// must not hold the whole fan-out past its budget. Race the call
|
|
@@ -626,13 +620,16 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
626
620
|
const searchHealth = new Map();
|
|
627
621
|
const planBackendIds = new Set(eligible.filter(({ backend }) => backend.handlesAllVariants === true).map(({ id }) => id));
|
|
628
622
|
let primaryPlanFailed = false;
|
|
623
|
+
let variantsRun = 0;
|
|
629
624
|
for (let variantIndex = 0; variantIndex < variants.length; variantIndex += 1) {
|
|
630
625
|
const variantQuery = variants[variantIndex];
|
|
631
626
|
const remaining = searchDeadline - Date.now();
|
|
632
627
|
// Do not start a variant that cannot get a meaningful slice: its
|
|
633
628
|
// "timeout" would be budget exhaustion, not a backend outage, and
|
|
634
629
|
// would contradict a success from the same backend in variant 1.
|
|
635
|
-
|
|
630
|
+
// A 2s budget must still be able to run three fast facets; the floor
|
|
631
|
+
// only prevents starting a variant that cannot get a meaningful slice.
|
|
632
|
+
const minVariantBudgetMs = Math.min(Number(opts.backendTimeoutMs) || 24000, 1000);
|
|
636
633
|
if (remaining < minVariantBudgetMs) break;
|
|
637
634
|
// Per-backend timeout is a contract, not a per-variant quota: a
|
|
638
635
|
// variant gets the configured timeout while the shared deadline still
|
|
@@ -676,12 +673,16 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
676
673
|
} else if (prev.ok !== true) {
|
|
677
674
|
searchHealth.set(outcome.id, {
|
|
678
675
|
...outcome,
|
|
676
|
+
// A later non-credential failure in another variant must not
|
|
677
|
+
// erase the missing-key diagnosis.
|
|
678
|
+
credentialMissing: prev.credentialMissing === true || outcome.credentialMissing === true,
|
|
679
679
|
rateLimited: prev.rateLimited === true || outcome.rateLimited === true,
|
|
680
680
|
keylessRejected: prev.keylessRejected === true || outcome.keylessRejected === true,
|
|
681
681
|
retryAfterMs: Math.max(prev.retryAfterMs ?? 0, outcome.retryAfterMs ?? 0) || undefined,
|
|
682
682
|
});
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
+
variantsRun += 1;
|
|
685
686
|
allTelemetry.push(...fold.telemetry);
|
|
686
687
|
allFailures.push(...fold.failures);
|
|
687
688
|
if (fold.hardError !== null && hardError === null) hardError = fold.hardError;
|
|
@@ -696,12 +697,16 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
696
697
|
perVariant.push({ query: variantQuery, ordered, mergedContent: fold.mergedContent });
|
|
697
698
|
}
|
|
698
699
|
|
|
700
|
+
const variantsSkipped = variants.length - variantsRun;
|
|
701
|
+
const facetNote = useMulti && variantsSkipped > 0
|
|
702
|
+
? ` · multiQuery: ${variantsSkipped}/${variants.length} facets not run (search budget)`
|
|
703
|
+
: "";
|
|
699
704
|
// Fold the breaker once per backend per search. `null` (breaker off) is
|
|
700
705
|
// honoured by recordBackendHealth and never publishes a cooldown.
|
|
701
706
|
for (const [id, outcome] of searchHealth) {
|
|
702
707
|
recordBackendHealth(
|
|
703
708
|
id,
|
|
704
|
-
{ ok: outcome.ok, at: outcome.at, ms: outcome.ms, count: outcome.count, error: outcome.error },
|
|
709
|
+
{ ok: outcome.ok, at: outcome.at, ms: outcome.ms, count: outcome.count, error: outcome.error, credentialMissing: outcome.credentialMissing === true },
|
|
705
710
|
breakerCfg,
|
|
706
711
|
{
|
|
707
712
|
rateLimited: outcome.rateLimited === true,
|
|
@@ -772,7 +777,7 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
772
777
|
}
|
|
773
778
|
// Store the pre-telemetry core (sources + headered content) so a cache
|
|
774
779
|
// hit reproduces the exact sources and the model-facing header.
|
|
775
|
-
if (cacheKey && cache) {
|
|
780
|
+
if (cacheKey && cache && variantsSkipped === 0) {
|
|
776
781
|
cache.set(cacheKey, {
|
|
777
782
|
sources, content: outContent,
|
|
778
783
|
truncated: maxResults === seamBound && ordered.length > maxResults,
|
|
@@ -813,7 +818,7 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
813
818
|
})
|
|
814
819
|
.concat(cooledParts);
|
|
815
820
|
if (foldedTelemetry.length > 12) parts.push(`… +${foldedTelemetry.length - 12}`);
|
|
816
|
-
const line = "[websearch backends]" + TELEMETRY_TAG + " " + parts.join(" · ");
|
|
821
|
+
const line = "[websearch backends]" + TELEMETRY_TAG + " " + parts.join(" · ") + facetNote;
|
|
817
822
|
outContent = outContent === undefined ? line : outContent + "\n\n" + line;
|
|
818
823
|
}
|
|
819
824
|
return {
|
|
@@ -845,7 +850,7 @@ export function createUnifiedSearchProvider({ ctx, resolveOptions, backends, cac
|
|
|
845
850
|
return t.id + " ✗" + t.ms + "ms" + (label ? " (" + label + ")" : "");
|
|
846
851
|
});
|
|
847
852
|
if (foldedTelemetry.length > 12) parts.push(`… +${foldedTelemetry.length - 12}`);
|
|
848
|
-
const line = "[websearch backends]" + TELEMETRY_TAG + " " + parts.join(" · ");
|
|
853
|
+
const line = "[websearch backends]" + TELEMETRY_TAG + " " + parts.join(" · ") + facetNote;
|
|
849
854
|
emptyContent = emptyContent === undefined ? line : emptyContent + "\n\n" + line;
|
|
850
855
|
}
|
|
851
856
|
recordHistory(history, request?.query, 0, historyOk, historyTotal);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@240xu/dsh-websearch",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.3",
|
|
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",
|