@240xu/dsh-websearch 2.13.8 → 2.13.9
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 -0
- package/lib/cache.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -208,6 +208,7 @@ pnpm install
|
|
|
208
208
|
- 存储位置:`$DSH_HOME/cache/websearch/results/`,单条目一个 JSON 文件,tmp+rename 原子写,超出上限按最旧淘汰;任何 fs 错误都被吞掉,缓存坏了绝不影响搜索。
|
|
209
209
|
- 设置:`cacheEnabled`(默认 true)、`cacheTtl`(秒,默认 900;**0 = no-store**,不读也不写)。
|
|
210
210
|
- 上限 200 条,超出按 mtime 最旧淘汰;缓存目录 0700、文件 0600(查询与结果属于用户数据)。
|
|
211
|
+
- 缓存键带 `CACHE_SEMANTICS_VERSION`;修改结果语义(如多查询截断、计划解析)时升版,旧条目自动 miss,不会回放旧行为。
|
|
211
212
|
- 清理:`rm -rf $DSH_HOME/cache/websearch/results`(`DSH_HOME` 通常为 `~/.dsh`)。
|
|
212
213
|
|
|
213
214
|
### 2. 后端熔断器(默认开,保守阈值)
|
package/lib/cache.js
CHANGED
|
@@ -36,7 +36,7 @@ export const CACHE_DEFAULTS = {
|
|
|
36
36
|
* which duplicate's title/snippet wins, so both must miss (arch-review P1-1).
|
|
37
37
|
* Pure function; exported for tests and host reuse.
|
|
38
38
|
*/
|
|
39
|
-
export function cacheKeyFor({ query, filters, maxResults, backends, mode, resultOptions }) {
|
|
39
|
+
export function cacheKeyFor({ query, filters, maxResults, backends, mode, resultOptions, version = CACHE_SEMANTICS_VERSION }) {
|
|
40
40
|
const backendSet = Array.isArray(backends) ? backends.join(",") : "";
|
|
41
41
|
let shaped = {};
|
|
42
42
|
if (resultOptions && typeof resultOptions === "object") {
|
|
@@ -51,10 +51,18 @@ export function cacheKeyFor({ query, filters, maxResults, backends, mode, result
|
|
|
51
51
|
b: backendSet,
|
|
52
52
|
m: typeof mode === "string" ? mode : "",
|
|
53
53
|
o: shaped,
|
|
54
|
+
v: Number(version) || 0,
|
|
54
55
|
});
|
|
55
56
|
return createHash("sha256").update(canonical).digest("hex").slice(0, 32);
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Bump when a change alters cached result semantics without changing the
|
|
61
|
+
* existing key fields (e.g. multi-query truncation, plan parsing). Old
|
|
62
|
+
* entries then miss instead of replaying results produced by the old code.
|
|
63
|
+
*/
|
|
64
|
+
export const CACHE_SEMANTICS_VERSION = 2;
|
|
65
|
+
|
|
58
66
|
/** Age of a record in whole seconds (bounded >= 0). */
|
|
59
67
|
function ageSeconds(record, nowMs) {
|
|
60
68
|
return Math.max(0, Math.floor((nowMs - (record?.time ?? 0)) / 1000));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@240xu/dsh-websearch",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.9",
|
|
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",
|