dsh-free-search 0.9.11 → 0.9.13

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 CHANGED
@@ -305,7 +305,10 @@ DSH 0.1.7-rc.1 起,配置跟随 profile 的插件条目保存:设置页与 `
305
305
  # profiles/<profile>/cordis.patch.yml 中该条目的 config:
306
306
  provider: bing # ddg / ddg-lite / bing / searxng / anysearch / exa / tavily / keenable / firecrawl / parallel / perplexity / serpbase / serply / deepseek-official / deepseek-tools / you / baidu / kimi / aliyun / doubao / zhihu_global / zhihu_site / openai / gemini / claude / auto / multi
307
307
  fallbackOn: [quota, auth, bot-wall, transient, invalid-response, unknown] # 允许触发回退的失败类别;[] = 任何失败都立即中止(默认全部)
308
- lang: zh # 搜索语言池/本地化(zh / en / ru …,不再被设置页强行改写)
308
+ lang: zh # 搜索语言池/本地化(zh / en / ru …,不再被设置页强行改写)
309
+ # lang 决定:Bing 的 mkt/Accept-Language、Wikipedia 子域(ja → ja.wikipedia.org)、地理编码语言;
310
+ # 我们自己渲染的文案只有中文/英文两套,其它语言(ja/ru/de…)一律走英文,避免回答前先塞一段中文(#92)。
311
+ # web_fetch(fs-quality-fetch)的 Accept-Language 同样跟随 lang,不再固定中文(#92)。
309
312
  uiLang: zh # 设置页界面语言(zh / en);留空则跟随 lang
310
313
  bingMarket: zh-CN # Bing 市场;留空 = 自动(不发送 mkt)
311
314
  fetchProviderTakeover: true # false = 保留你显式 pin 的 fetchProvider: http
@@ -487,7 +490,7 @@ Search engine test:
487
490
 
488
491
  #### 离线自检断言(tools/)
489
492
 
490
- 仓库自带 **23 个**零依赖断言脚本(合计 **550 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
493
+ 仓库自带 **24 个**零依赖断言脚本(合计 **558 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
491
494
 
492
495
  | 脚本 | 覆盖 | 运行(项数) |
493
496
  |---|---|---|
@@ -507,6 +510,7 @@ Search engine test:
507
510
  | `assert-killtree-win32.mjs` | Windows 子进程树终止(#74):不再依赖 `taskkill` | `node tools/assert-killtree-win32.mjs`(8) |
508
511
  | `assert-killtree-portable.mjs` | 跨平台 `killTree` 便携版契约 | `node tools/assert-killtree-portable.mjs`(5) |
509
512
  | `assert-parallel-mcp.mjs` | Parallel MCP 引擎:25 s 超时/调用方取消覆盖**响应体读取**、共享 SSE 解析器(通知/多行帧)、6 类错误路径、REST 精确时间过滤 | `node tools/assert-parallel-mcp.mjs`(15) |
513
+ | `assert-output-language.mjs` | 语言分支(#92):`searchLanguage` 支持 zh/en/ja/ru/de/es/fr/ko 其余回退 en、`outputLanguage` 只输出 zh/en、天气文案 ja→英文、置信度说明随语言、失败备注随语言 | `node tools/assert-output-language.mjs`(8) |
510
514
  | `assert-uncertainty.mjs` | 输出契约:0/1 源为 low、2 源与同站为 medium、3 个不同域为 high、时间过滤无日期、失败备注、聚合站提示 | `node tools/assert-uncertainty.mjs`(8) |
511
515
  | `assert-multikey.mjs` | 多 key 字段:单 key 不变、逗号/分号/换行分隔、空白项丢弃、空输入为空数组 | `node tools/assert-multikey.mjs`(3) |
512
516
  | `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
@@ -839,7 +843,10 @@ The old `free-search:` section of `~/.dsh/settings.yaml` is **not** imported by
839
843
  # config of that entry in profiles/<profile>/cordis.patch.yml:
840
844
  provider: bing # ddg / ddg-lite / bing / searxng / anysearch / exa / tavily / keenable / firecrawl / parallel / perplexity / serpbase / serply / deepseek-official / deepseek-tools / you / baidu / kimi / aliyun / doubao / zhihu_global / zhihu_site / openai / gemini / claude / auto / multi
841
845
  fallbackOn: [quota, auth, bot-wall, transient, invalid-response, unknown] # failure classes allowed to trigger fallback; [] = abort on any failure (default: all)
842
- lang: zh # search language pools / localization (zh / en / ru …; no longer rewritten by the settings page)
846
+ lang: zh # search language pools / localization (zh / en / ru …; no longer rewritten by the settings page)
847
+ # lang drives Bing's mkt/Accept-Language, the Wikipedia subdomain (ja → ja.wikipedia.org) and the geocoding language;
848
+ # text this plugin renders itself only exists in Chinese and English, so other languages (ja/ru/de…) get English rather than a wall of Chinese (#92).
849
+ # web_fetch (fs-quality-fetch) sends the same Accept-Language instead of a fixed Chinese one (#92).
843
850
  uiLang: zh # settings UI language (zh / en); empty = follow lang
844
851
  bingMarket: zh-CN # Bing market; empty = automatic (no mkt sent)
845
852
  fetchProviderTakeover: true # false = keep the fetchProvider: http you pinned yourself
@@ -1021,7 +1028,7 @@ Restart `dsh web` after switching to apply changes.
1021
1028
 
1022
1029
  #### Offline self-check assertions (`tools/`)
1023
1030
 
1024
- **Twenty-three** zero-dependency assertion scripts ship with the repo (**550 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1031
+ **Twenty-four** zero-dependency assertion scripts ship with the repo (**558 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1025
1032
 
1026
1033
  | Script | Covers | Run (count) |
1027
1034
  |---|---|---|
@@ -1041,6 +1048,7 @@ Restart `dsh web` after switching to apply changes.
1041
1048
  | `assert-killtree-win32.mjs` | Windows process-tree termination (#74): no longer relies on `taskkill` | `node tools/assert-killtree-win32.mjs` (8) |
1042
1049
  | `assert-killtree-portable.mjs` | portable `killTree` contract | `node tools/assert-killtree-portable.mjs` (5) |
1043
1050
  | `assert-parallel-mcp.mjs` | Parallel MCP engine: the 25 s timeout / caller abort covers the **body read**, shared SSE parser (notifications, multiline frames), six error paths, REST precise time filtering | `node tools/assert-parallel-mcp.mjs` (15) |
1051
+ | `assert-output-language.mjs` | language branches (#92): `searchLanguage` passes zh/en/ja/ru/de/es/fr/ko through and falls back to en, `outputLanguage` only returns zh/en, weather text is English for ja, and both confidence and failure notes follow the language | `node tools/assert-output-language.mjs` (8) |
1044
1052
  | `assert-uncertainty.mjs` | output contract: 0/1 source is low, two sources or a single site is medium, three distinct domains is high, time filter without dates, failure notes, aggregator caveat | `node tools/assert-uncertainty.mjs` (8) |
1045
1053
  | `assert-multikey.mjs` | multi-key fields: a single key is unchanged, comma/semicolon/newline separate keys, blank entries are dropped, empty input yields none | `node tools/assert-multikey.mjs` (3) |
1046
1054
  | `assert-firecrawl-keyless.mjs` | Firecrawl keyless egress refusal: only a 403 with the VPN/proxy wording counts, plain 403 and 401/429/500 do not, and the cooldown starts inactive | `node tools/assert-firecrawl-keyless.mjs` (5) |
package/lib/client.js CHANGED
@@ -424,9 +424,9 @@ window.__ModuleLoader__.load({
424
424
  starCta: "Give a star",
425
425
  },
426
426
  };
427
- const tt = (lang) => I18N[lang === "en" ? "en" : "zh"];
427
+ const tt = (lang) => I18N[String(lang ?? "").trim().toLowerCase() === "zh" ? "zh" : "en"];
428
428
  // 当前插件版本(与 lib/index.js 的 PLUGIN_VERSION 保持一致;跟随上游 v0.7.5)
429
- const PLUGIN_VERSION = "0.9.11";
429
+ const PLUGIN_VERSION = "0.9.13";
430
430
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
431
431
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
432
432
  const NAV_ITEMS = [
@@ -1127,7 +1127,7 @@ window.__ModuleLoader__.load({
1127
1127
 
1128
1128
  if (state.status === "loading") return null;
1129
1129
  const ready = state.status === "ready";
1130
- const t = tt(uiLang || (lang === "en" ? "en" : "zh"));
1130
+ const t = tt(uiLang || (String(lang ?? "").trim().toLowerCase() === "zh" ? "zh" : "en"));
1131
1131
  const navLabels = {
1132
1132
  engines: t.navEngines,
1133
1133
  fallback: t.navFallback,
@@ -2157,7 +2157,7 @@ react_jsx_runtime.jsx("div", {
2157
2157
  .map((e) => ({
2158
2158
  id: e.id,
2159
2159
  label: `${e.label}${e.badge === "AUTO" ? " · 智能路由" : e.badge === "MULTI" ? " · 并发合并" : e.badge === "FREE" ? " · 免费" : " · API Key"}`,
2160
- detail: e.id === current ? (view?.value?.lang === "en" ? "current" : "当前") : undefined,
2160
+ detail: e.id === current ? (String(view?.value?.lang ?? "").trim().toLowerCase() === "zh" ? "当前" : "current") : undefined,
2161
2161
  active: e.id === current,
2162
2162
  }));
2163
2163
  },
@@ -274,11 +274,11 @@ export function httpsGetFollow(url, { headers = {}, timeoutMs = 20000, signal }
274
274
  }
275
275
 
276
276
  // 完整浏览器请求头(Chrome 128 形态):部分反爬站(如百度系)对精简头直接 403,完整头可通过。
277
+ // Accept-Language 不在这里:它跟随 lang(#92),由调用方逐次传入,否则日语环境抓到的仍是中文版页面。
277
278
  // 注意:声明了 Accept-Encoding 就必须解压(httpsGetFollow 已支持 gzip/br/deflate)。
278
279
  const BROWSERISH = {
279
280
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
280
281
  Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
281
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
282
282
  "Accept-Encoding": "gzip, deflate, br",
283
283
  "sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
284
284
  "sec-ch-ua-mobile": "?0",
@@ -290,7 +290,11 @@ const BROWSERISH = {
290
290
  "Upgrade-Insecure-Requests": "1",
291
291
  };
292
292
 
293
- export function createFetchProvider({ resolveApiKey, logger }) {
293
+ /** 请求头:Accept-Language 跟随调用方(#92),其余固定为浏览器形态。 */
294
+ export function browserishHeaders(acceptLanguage = "en-US,en;q=0.9") {
295
+ return { ...BROWSERISH, "Accept-Language": String(acceptLanguage ?? "").trim() || "en-US,en;q=0.9" };
296
+ }
297
+ export function createFetchProvider({ resolveApiKey, logger, acceptLanguage = () => "en-US,en;q=0.9" }) {
294
298
  return {
295
299
  id: "fs-quality-fetch",
296
300
  /** 廉价本地可用性检查(seam 契约要求,禁止网络调用)。 */
@@ -302,7 +306,7 @@ export function createFetchProvider({ resolveApiKey, logger }) {
302
306
 
303
307
  // T1:直连(文本类内容;二进制交给后层——exa 取正文,PDF 等仍由 firecrawl 处理)
304
308
  try {
305
- const r = await httpsGetFollow(url, { headers: BROWSERISH, signal });
309
+ const r = await httpsGetFollow(url, { headers: browserishHeaders(acceptLanguage()), signal });
306
310
  if (r.status < 400 && TEXTUAL.test(r.contentType) && r.text.length >= T1_MIN_CHARS) {
307
311
  return { url: r.url, statusCode: r.status, body: { kind: "html", content: r.text }, truncated: false };
308
312
  }
package/lib/index.js CHANGED
@@ -76,7 +76,19 @@ export function isFirecrawlKeylessBlocked(now = Date.now(), proxy = proxyFingerp
76
76
  // 只做启发式提示,不改变结果本身;agent 可以据此决定是否二次核对。
77
77
  const UNCERTAINTY_AGGREGATORS = /(^|\.)(zhihu|sohu|sina|163|qq|toutiao|baijiahao|csdn|jianshu|medium|substack|reddit|quora|stackexchange)\./i;
78
78
 
79
- export function assessUncertainty({ sources = [], timeRange = false, note = "" } = {}) {
79
+ // 置信度说明的文案表:只有 zh / en 两套,其它语言回退 en(#92)。
80
+ const UNCERTAINTY_NOTES = {
81
+ empty: { zh: "没有返回结果", en: "no results returned" },
82
+ single: { zh: "只有 1 个来源", en: "only one source" },
83
+ sameSite: { zh: "所有结果来自同一站点", en: "all results come from a single site" },
84
+ two: { zh: "只有 2 个来源", en: "only two sources" },
85
+ noDates: { zh: "带时间过滤但结果没有发布时间", en: "time filter applied but the results carry no publish dates" },
86
+ partial: { zh: "部分引擎失败,结果可能不完整", en: "some engines failed; the result may be incomplete" },
87
+ aggregator: { zh: "包含聚合站内容,建议二次核对", en: "includes aggregator content; worth a second look" },
88
+ };
89
+
90
+ export function assessUncertainty({ sources = [], timeRange = false, note: rawNote = "", lang } = {}) {
91
+ const note = (key) => UNCERTAINTY_NOTES[key][outputLanguage(lang) === "zh" ? "zh" : "en"];
80
92
  const list = Array.isArray(sources) ? sources : [];
81
93
  const notes = [];
82
94
  const domains = new Set();
@@ -88,27 +100,27 @@ export function assessUncertainty({ sources = [], timeRange = false, note = "" }
88
100
  let level = "high";
89
101
  if (list.length === 0) {
90
102
  level = "low";
91
- notes.push("没有返回结果");
103
+ notes.push(note("empty"));
92
104
  } else if (list.length === 1) {
93
105
  level = "low";
94
- notes.push("只有 1 个来源");
106
+ notes.push(note("single"));
95
107
  } else if (domains.size === 1) {
96
108
  level = "medium";
97
- notes.push("所有结果来自同一站点");
109
+ notes.push(note("sameSite"));
98
110
  } else if (list.length === 2) {
99
111
  level = "medium";
100
- notes.push("只有 2 个来源");
112
+ notes.push(note("two"));
101
113
  }
102
114
  if (timeRange && list.every((source) => !source.publishedAt)) {
103
115
  if (level === "high") level = "medium";
104
- notes.push("带时间过滤但结果没有发布时间");
116
+ notes.push(note("noDates"));
105
117
  }
106
- if (note && /fail|error|fallback|skipped|failed/i.test(note)) {
118
+ if (rawNote && /fail|error|fallback|skipped|failed/i.test(rawNote)) {
107
119
  level = "low";
108
- notes.push("部分引擎失败,结果可能不完整");
120
+ notes.push(note("partial"));
109
121
  }
110
122
  if ([...domains].some((domain) => UNCERTAINTY_AGGREGATORS.test(domain))) {
111
- notes.push("包含聚合站内容,建议二次核对");
123
+ notes.push(note("aggregator"));
112
124
  if (level === "high") level = "medium";
113
125
  }
114
126
  return { level, notes };
@@ -150,10 +162,46 @@ const ZHIHU_MCP_URL = "https://developer.zhihu.com/api/mcp/v1";
150
162
  const USER_AGENT =
151
163
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36";
152
164
  const ACCEPT_LANG = "zh-CN,zh;q=0.9,en;q=0.8";
165
+ // 当前请求生效的 Accept-Language:由 lang(或显式 bingMarket)决定,搜索前设置(#92)。
166
+ let activeAcceptLanguage = ACCEPT_LANG;
167
+ /** 由配置推导 Accept-Language:显式 bingMarket 优先,否则跟随 lang(未知回退 en)。 */
168
+ export function acceptLanguageFor(cfg) {
169
+ const market = cfg?.bingMarket;
170
+ if (market && MARKET_TO_LANG[market]) return MARKET_TO_LANG[market];
171
+ return LANG_PROFILES[searchLanguage(configLanguage(cfg))].acceptLang;
172
+ }
173
+
174
+ export function setActiveAcceptLanguage(value) {
175
+ if (typeof value === "string" && value.trim() !== "") activeAcceptLanguage = value.trim();
176
+ }
153
177
 
154
178
  // 语言 → Bing 本地化档案:{ market, acceptLang }。
155
179
  // lang 字段(设置页可切换)驱动 Bing 的 mkt + Accept-Language,让非中文用户
156
180
  // 也能拿到本地化结果(俄语搜俄文等)。bingMarket 显式设置时优先于映射。
181
+ // #92:区分「搜索语言」与「输出语言」。
182
+ // - searchLanguage:交给 provider 的参数(Wikipedia 主机、geocoding、Accept-Language)——支持的语言原样透传,未知回退 en;
183
+ // - outputLanguage:我们自己渲染的文案(天气、置信度说明)——只有 zh/en 两套文案,其它语言回退 en,
184
+ // 否则日语/俄语用户会在回答前拿到一整段中文。
185
+ export function searchLanguage(lang) {
186
+ const tag = String(lang ?? "").trim().toLowerCase();
187
+ return Object.prototype.hasOwnProperty.call(LANG_PROFILES, tag) ? tag : "en";
188
+ }
189
+
190
+ /**
191
+ * 配置里生效的语言标签:未设置时按 schema 默认 zh(#92)。
192
+ * searchLanguage() 只负责「未知值回退 en」,两者不要混用。
193
+ */
194
+ export function configLanguage(cfg) {
195
+ const value = cfg?.lang;
196
+ if (value === undefined || value === null) return "zh";
197
+ const tag = String(value).trim().toLowerCase();
198
+ return tag === "" ? "zh" : tag;
199
+ }
200
+
201
+
202
+ export function outputLanguage(lang) {
203
+ return searchLanguage(lang) === "zh" ? "zh" : "en";
204
+ }
157
205
  const LANG_PROFILES = {
158
206
  zh: { market: "zh-CN", acceptLang: "zh-CN,zh;q=0.9,en;q=0.8" },
159
207
  en: { market: "en-US", acceptLang: "en-US,en;q=0.9" },
@@ -351,7 +399,7 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
351
399
  }
352
400
 
353
401
  // 当前插件版本(发布时与 package.json 同步;跟随上游 v0.7.5,不在 PR 里 bump)
354
- const PLUGIN_VERSION = "0.9.11";
402
+ const PLUGIN_VERSION = "0.9.13";
355
403
  // 检查更新的 npm registry 元数据地址(dsh-free-search 是 npmjs 上的公开包)
356
404
  const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-free-search/latest";
357
405
  const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-free-search";
@@ -571,7 +619,7 @@ async function fetchHtml(url, signal, acceptLang) {
571
619
  const onAbort = () => controller.abort();
572
620
  signal?.addEventListener("abort", onAbort);
573
621
  response = await fetch(url, {
574
- headers: { "user-agent": USER_AGENT, "accept-language": acceptLang ?? ACCEPT_LANG },
622
+ headers: { "user-agent": USER_AGENT, "accept-language": acceptLang ?? activeAcceptLanguage },
575
623
  signal: controller.signal,
576
624
  redirect: "follow",
577
625
  });
@@ -713,13 +761,13 @@ function extractBingUrl(href) {
713
761
  async function searchBing(query, maxResults, options, signal) {
714
762
  // mkt:仅显式 bingMarket 才发。默认不发——mkt=zh-CN 在部分地区/线路会返回空 SERP 容器
715
763
  // (#71:海外 IP + mkt=zh-CN → b_algo=0),Bing 会按 Accept-Language 自行本地化。
716
- const profile = LANG_PROFILES[options?.lang] ?? LANG_PROFILES.zh;
764
+ const profile = LANG_PROFILES[searchLanguage(configLanguage(options))];
717
765
  const params = new URLSearchParams({ q: query });
718
766
  if (options?.bingMarket) params.set("mkt", options.bingMarket);
719
767
  // Accept-Language:显式 bingMarket 时按 market 反推(避免中文 header 污染),否则用 lang 档案
720
768
  const acceptLang = options?.bingMarket
721
- ? (MARKET_TO_LANG[options.bingMarket] ?? ACCEPT_LANG)
722
- : (profile.acceptLang ?? ACCEPT_LANG);
769
+ ? (MARKET_TO_LANG[options.bingMarket] ?? activeAcceptLanguage)
770
+ : (profile.acceptLang ?? activeAcceptLanguage);
723
771
  const adlt = options?.safeSearch ?? "off";
724
772
  if (adlt === "off") params.set("adlt", "off");
725
773
  else if (adlt === "moderate") params.set("adlt", "moderate");
@@ -826,7 +874,19 @@ const EXA_MCP_URL = "https://mcp.exa.ai/mcp";
826
874
  // AnySearch: 免费匿名额度(无 key),可选 Bearer key 提额;结构化 JSON 结果
827
875
  // 401/403:本进程忽略该 key 值(不删除存储),改回匿名免费;不自动清空用户配置
828
876
  let ignoredAnysearchKey = "";
829
- const ANYSEARCH_KEY_INVALID_NOTE = "AnySearch key 无效,本次已忽略该 key,改回免费匿名";
877
+ // 当前请求生效的输出语言(zh / en),由 lang 推导;只有我们自己渲染的文案用它(#92)。
878
+ let activeOutputLanguage = "zh";
879
+ export function setActiveOutputLanguage(value) {
880
+ activeOutputLanguage = String(value ?? "").trim().toLowerCase() === "zh" ? "zh" : "en";
881
+ }
882
+ export function getActiveOutputLanguage() {
883
+ return activeOutputLanguage;
884
+ }
885
+ const ANYSEARCH_KEY_INVALID_NOTE_ZH = "AnySearch key 无效,本次已忽略该 key,改回免费匿名档";
886
+ const ANYSEARCH_KEY_INVALID_NOTE_EN = "AnySearch key was rejected; ignored it and used the anonymous tier";
887
+ function anysearchKeyNote() {
888
+ return activeOutputLanguage === "zh" ? ANYSEARCH_KEY_INVALID_NOTE_ZH : ANYSEARCH_KEY_INVALID_NOTE_EN;
889
+ }
830
890
 
831
891
  async function searchAnysearch(query, maxResults, signal, apiKey) {
832
892
  const trimmedKey = typeof apiKey === "string" ? apiKey.trim() : "";
@@ -864,7 +924,7 @@ async function searchAnysearch(query, maxResults, signal, apiKey) {
864
924
  signal?.removeEventListener("abort", onAbort);
865
925
  }
866
926
  if (response.status === 401 || response.status === 403) {
867
- throw new Error(keyRejected ? `${ANYSEARCH_KEY_INVALID_NOTE} (HTTP ${response.status})` : `AnySearch API error (HTTP ${response.status})`);
927
+ throw new Error(keyRejected ? `${anysearchKeyNote()} (HTTP ${response.status})` : `AnySearch API error (HTTP ${response.status})`);
868
928
  }
869
929
  if (!response.ok) throw new Error(`AnySearch API error (HTTP ${response.status})`);
870
930
  const data = await response.json();
@@ -879,7 +939,7 @@ async function searchAnysearch(query, maxResults, signal, apiKey) {
879
939
  ...(r.snippet ? { snippet: String(r.snippet).slice(0, 300) } : {}),
880
940
  })),
881
941
  truncated: false,
882
- ...(keyRejected || keyIgnoredSticky ? { content: ANYSEARCH_KEY_INVALID_NOTE } : {}),
942
+ ...(keyRejected || keyIgnoredSticky ? { content: anysearchKeyNote() } : {}),
883
943
  };
884
944
  }
885
945
 
@@ -1111,7 +1171,7 @@ async function searchStackOverflow(query, maxResults, signal) {
1111
1171
  }
1112
1172
 
1113
1173
  async function searchWikipedia(query, maxResults, signal, lang) {
1114
- const host = lang === "en" ? "en.wikipedia.org" : "zh.wikipedia.org";
1174
+ const host = `${searchLanguage(lang)}.wikipedia.org`;
1115
1175
  const response = await fetch(
1116
1176
  `https://${host}/w/api.php?action=query&list=search&srsearch=${encodeURIComponent(query)}&format=json&srlimit=${maxResults ?? 5}`,
1117
1177
  {
@@ -1284,7 +1344,7 @@ async function fetchVideoHtml(url, signal, extraHeaders) {
1284
1344
  response = await fetch(url, {
1285
1345
  headers: {
1286
1346
  "user-agent": USER_AGENT,
1287
- "accept-language": ACCEPT_LANG,
1347
+ "accept-language": activeAcceptLanguage,
1288
1348
  accept: "text/html,application/xhtml+xml,application/json;q=0.9,*/*;q=0.8",
1289
1349
  ...(extraHeaders ?? {}),
1290
1350
  },
@@ -1342,7 +1402,7 @@ function sliceBalancedObject(text, start) {
1342
1402
  // json 字段 murl(真实播放地址) / vt(标题) / du(时长) / purl(详情页)(字段语义以实测为准)。
1343
1403
  async function searchBingVideos(query, maxResults, options, signal) {
1344
1404
  const params = new URLSearchParams({ q: query, count: String(Math.max(Number(maxResults) || 10, 1)), first: "1", mmasync: "1" });
1345
- const market = options?.bingMarket ?? (LANG_PROFILES[options?.lang] ?? LANG_PROFILES.zh).market;
1405
+ const market = options?.bingMarket ?? LANG_PROFILES[searchLanguage(configLanguage(options))].market;
1346
1406
  if (market) params.set("mkt", market);
1347
1407
  const html = await fetchVideoHtml(`${BING_VIDEOS_ASYNC_URL}?${params}`, signal);
1348
1408
  if (/captcha|unusual traffic|robot check/i.test(html.slice(0, 5000))) {
@@ -3780,6 +3840,9 @@ function apply(ctx, config) {
3780
3840
  const cfg = current();
3781
3841
  // #72:本次请求生效的域名黑名单(模块级活动值;各结果咽喉点过滤读取它)
3782
3842
  setActiveBlockedDomains(cfg.blockedDomains);
3843
+ // #92:Accept-Language 跟随 lang(显式 bingMarket 优先),不再固定中文
3844
+ setActiveAcceptLanguage(acceptLanguageFor(cfg));
3845
+ setActiveOutputLanguage(outputLanguage(configLanguage(cfg)));
3783
3846
  const disabledEngines = normalizeDisabledEngines(cfg.disabledEngines);
3784
3847
  const fallbackOnSet = new Set(normalizeFallbackOn(cfg.fallbackOn));
3785
3848
  const disabledSet = new Set(disabledEngines);
@@ -4325,7 +4388,12 @@ function apply(ctx, config) {
4325
4388
  // web_fetch 质量链接管:注册 fs-quality-fetch(直连 → exa contents → firecrawl → crawl4ai),
4326
4389
  // 未设置 fetchProviderId、或仍是出厂默认 http 时接管;已被显式指向其他 provider 时不抢占。
4327
4390
  // 与 web_search 的接管规则同构:运行时兜底,不依赖 bundle patch 是否落地。
4328
- const fetchProvider = createFetchProvider({ resolveApiKey, logger });
4391
+ const fetchProvider = createFetchProvider({
4392
+ resolveApiKey,
4393
+ logger,
4394
+ // #92:web_fetch 不经过 searchOnce,所以这里按当前配置现算,而不是复用上次搜索留下的值。
4395
+ acceptLanguage: () => acceptLanguageFor(current()),
4396
+ });
4329
4397
  registerOnce(() => ctx.web.registerFetchProvider(fetchProvider), fetchProvider, "fetch provider");
4330
4398
 
4331
4399
  // 接管必须先等 settings 服务就绪:rc.2 起 provider 选择是 config 的 volatile ref,
@@ -5003,7 +5071,7 @@ function apply(ctx, config) {
5003
5071
  );
5004
5072
  }
5005
5073
  const limit = Math.min(args.maxResults ?? 5, 10);
5006
- let result = await searchPlatform(platform, args.query, limit, undefined, current().lang);
5074
+ let result = await searchPlatform(platform, args.query, limit, undefined, configLanguage(current()));
5007
5075
  if (platform === "vimeo" && (result.sources ?? []).length === 0) {
5008
5076
  // Vimeo 搜索页有时不返回结果:退回网页搜索(site: 过滤)
5009
5077
  try {
@@ -5148,7 +5216,7 @@ function apply(ctx, config) {
5148
5216
  output: {
5149
5217
  schema: WEATHER_OUTPUT_SCHEMA,
5150
5218
  render(args, value) {
5151
- const lang = current().lang === "en" ? "en" : "zh";
5219
+ const lang = outputLanguage(configLanguage(current()));
5152
5220
  const c = value.current ?? {};
5153
5221
  const lines = [];
5154
5222
  lines.push(lang === "en" ? `Weather for ${value.location}:` : `${value.location} 天气:`);
@@ -5168,7 +5236,8 @@ function apply(ctx, config) {
5168
5236
  },
5169
5237
  },
5170
5238
  async execute(args) {
5171
- const lang = current().lang === "en" ? "en" : "zh";
5239
+ // 天气正文只提供 zh/en(回退 en),地理编码用真实搜索语言(ja 就查日文地名)。
5240
+ const lang = searchLanguage(configLanguage(current()));
5172
5241
  const location = String(args.location ?? "").trim();
5173
5242
  if (!location) throw new Error("weather: location is required");
5174
5243
  return sanitizeWeatherResult(await fetchWeather(location, args.days, lang, undefined));
@@ -5277,6 +5346,7 @@ function apply(ctx, config) {
5277
5346
  sources: result.sources ?? [],
5278
5347
  timeRange: Boolean(request.timeRange),
5279
5348
  note: typeof result.content === "string" ? result.content : "",
5349
+ lang: configLanguage(current()),
5280
5350
  }),
5281
5351
  },
5282
5352
  };
@@ -5376,6 +5446,7 @@ function apply(ctx, config) {
5376
5446
  uncertainty: assessUncertainty({
5377
5447
  sources: toolResult.sources ?? [],
5378
5448
  note: typeof toolResult.content === "string" ? toolResult.content : "",
5449
+ lang: configLanguage(current()),
5379
5450
  }),
5380
5451
  },
5381
5452
  };
package/lib/weather.js CHANGED
@@ -38,14 +38,20 @@ const WMO_CODES = {
38
38
  96: ["雷暴伴小冰雹", "Thunderstorm with slight hail"],
39
39
  99: ["雷暴伴大冰雹", "Thunderstorm with heavy hail"],
40
40
  };
41
- function wmoText(code, lang) {
41
+ /** 天气文案只有 zh / en 两套;其它语言(ja/ru/…)走英文,避免整段中文(#92)。 */
42
+ export function textLanguage(lang) {
43
+ return String(lang ?? "").trim().toLowerCase() === "zh" ? "zh" : "en";
44
+ }
45
+
46
+ export function wmoText(code, lang) {
47
+ const textLang = textLanguage(lang);
42
48
  const hit = WMO_CODES[code];
43
- if (!hit) return lang === "en" ? "Unknown" : "未知";
44
- return (lang === "en" ? hit[1] : hit[0]) + ` (WMO ${code})`;
49
+ if (!hit) return textLang === "zh" ? "未知" : "Unknown";
50
+ return (textLang === "zh" ? hit[0] : hit[1]) + ` (WMO ${code})`;
45
51
  }
46
52
 
47
- export async function geocodeLocation(name, signal) {
48
- const params = new URLSearchParams({ name, count: "1", language: "zh", format: "json" });
53
+ export async function geocodeLocation(name, signal, language = "en") {
54
+ const params = new URLSearchParams({ name, count: "1", language: String(language ?? "en") || "en", format: "json" });
49
55
  const response = await fetch(`${OPEN_METEO_GEOCODING_URL}?${params}`, {
50
56
  method: "GET",
51
57
  redirect: "error",
@@ -66,7 +72,7 @@ export async function geocodeLocation(name, signal) {
66
72
  }
67
73
 
68
74
  export async function fetchWeather(location, days, lang, signal) {
69
- const geo = await geocodeLocation(location, signal);
75
+ const geo = await geocodeLocation(location, signal, lang);
70
76
  if (!geo) throw new Error(`could not geocode location "${location}" — try a nearby larger city`);
71
77
  const params = new URLSearchParams({
72
78
  latitude: String(geo.latitude),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "Free web search for DeepSeek Harness: 27 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/You.com/Baidu/Kimi/Aliyun/Doubao with key; OpenAI/Gemini/Claude model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + editable zh/en language pools + multi mode (parallel full language-pool merge) + multi_search cross-source tool + failure-aware fallback (quota/auth cooldown, transient retry, fallbackOn) + time filtering + platform search + domain blocklist (blockedDomains) + web_fetch, with web settings UI.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",