dsh-free-search 0.9.11 → 0.9.12

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,9 @@ 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)。
309
311
  uiLang: zh # 设置页界面语言(zh / en);留空则跟随 lang
310
312
  bingMarket: zh-CN # Bing 市场;留空 = 自动(不发送 mkt)
311
313
  fetchProviderTakeover: true # false = 保留你显式 pin 的 fetchProvider: http
@@ -487,7 +489,7 @@ Search engine test:
487
489
 
488
490
  #### 离线自检断言(tools/)
489
491
 
490
- 仓库自带 **23 个**零依赖断言脚本(合计 **550 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
492
+ 仓库自带 **24 个**零依赖断言脚本(合计 **555 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
491
493
 
492
494
  | 脚本 | 覆盖 | 运行(项数) |
493
495
  |---|---|---|
@@ -507,6 +509,7 @@ Search engine test:
507
509
  | `assert-killtree-win32.mjs` | Windows 子进程树终止(#74):不再依赖 `taskkill` | `node tools/assert-killtree-win32.mjs`(8) |
508
510
  | `assert-killtree-portable.mjs` | 跨平台 `killTree` 便携版契约 | `node tools/assert-killtree-portable.mjs`(5) |
509
511
  | `assert-parallel-mcp.mjs` | Parallel MCP 引擎:25 s 超时/调用方取消覆盖**响应体读取**、共享 SSE 解析器(通知/多行帧)、6 类错误路径、REST 精确时间过滤 | `node tools/assert-parallel-mcp.mjs`(15) |
512
+ | `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`(5) |
510
513
  | `assert-uncertainty.mjs` | 输出契约:0/1 源为 low、2 源与同站为 medium、3 个不同域为 high、时间过滤无日期、失败备注、聚合站提示 | `node tools/assert-uncertainty.mjs`(8) |
511
514
  | `assert-multikey.mjs` | 多 key 字段:单 key 不变、逗号/分号/换行分隔、空白项丢弃、空输入为空数组 | `node tools/assert-multikey.mjs`(3) |
512
515
  | `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
@@ -839,7 +842,9 @@ The old `free-search:` section of `~/.dsh/settings.yaml` is **not** imported by
839
842
  # config of that entry in profiles/<profile>/cordis.patch.yml:
840
843
  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
844
  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)
845
+ lang: zh # search language pools / localization (zh / en / ru …; no longer rewritten by the settings page)
846
+ # lang drives Bing's mkt/Accept-Language, the Wikipedia subdomain (ja → ja.wikipedia.org) and the geocoding language;
847
+ # 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).
843
848
  uiLang: zh # settings UI language (zh / en); empty = follow lang
844
849
  bingMarket: zh-CN # Bing market; empty = automatic (no mkt sent)
845
850
  fetchProviderTakeover: true # false = keep the fetchProvider: http you pinned yourself
@@ -1021,7 +1026,7 @@ Restart `dsh web` after switching to apply changes.
1021
1026
 
1022
1027
  #### Offline self-check assertions (`tools/`)
1023
1028
 
1024
- **Twenty-three** zero-dependency assertion scripts ship with the repo (**550 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1029
+ **Twenty-four** zero-dependency assertion scripts ship with the repo (**555 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1025
1030
 
1026
1031
  | Script | Covers | Run (count) |
1027
1032
  |---|---|---|
@@ -1041,6 +1046,7 @@ Restart `dsh web` after switching to apply changes.
1041
1046
  | `assert-killtree-win32.mjs` | Windows process-tree termination (#74): no longer relies on `taskkill` | `node tools/assert-killtree-win32.mjs` (8) |
1042
1047
  | `assert-killtree-portable.mjs` | portable `killTree` contract | `node tools/assert-killtree-portable.mjs` (5) |
1043
1048
  | `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) |
1049
+ | `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` (5) |
1044
1050
  | `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
1051
  | `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
1052
  | `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.12";
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
  },
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,27 @@ 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
+ export function setActiveAcceptLanguage(value) {
168
+ if (typeof value === "string" && value.trim() !== "") activeAcceptLanguage = value.trim();
169
+ }
153
170
 
154
171
  // 语言 → Bing 本地化档案:{ market, acceptLang }。
155
172
  // lang 字段(设置页可切换)驱动 Bing 的 mkt + Accept-Language,让非中文用户
156
173
  // 也能拿到本地化结果(俄语搜俄文等)。bingMarket 显式设置时优先于映射。
174
+ // #92:区分「搜索语言」与「输出语言」。
175
+ // - searchLanguage:交给 provider 的参数(Wikipedia 主机、geocoding、Accept-Language)——支持的语言原样透传,未知回退 en;
176
+ // - outputLanguage:我们自己渲染的文案(天气、置信度说明)——只有 zh/en 两套文案,其它语言回退 en,
177
+ // 否则日语/俄语用户会在回答前拿到一整段中文。
178
+ export function searchLanguage(lang) {
179
+ const tag = String(lang ?? "").trim().toLowerCase();
180
+ return Object.prototype.hasOwnProperty.call(LANG_PROFILES, tag) ? tag : "en";
181
+ }
182
+
183
+ export function outputLanguage(lang) {
184
+ return searchLanguage(lang) === "zh" ? "zh" : "en";
185
+ }
157
186
  const LANG_PROFILES = {
158
187
  zh: { market: "zh-CN", acceptLang: "zh-CN,zh;q=0.9,en;q=0.8" },
159
188
  en: { market: "en-US", acceptLang: "en-US,en;q=0.9" },
@@ -351,7 +380,7 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
351
380
  }
352
381
 
353
382
  // 当前插件版本(发布时与 package.json 同步;跟随上游 v0.7.5,不在 PR 里 bump)
354
- const PLUGIN_VERSION = "0.9.11";
383
+ const PLUGIN_VERSION = "0.9.12";
355
384
  // 检查更新的 npm registry 元数据地址(dsh-free-search 是 npmjs 上的公开包)
356
385
  const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-free-search/latest";
357
386
  const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-free-search";
@@ -571,7 +600,7 @@ async function fetchHtml(url, signal, acceptLang) {
571
600
  const onAbort = () => controller.abort();
572
601
  signal?.addEventListener("abort", onAbort);
573
602
  response = await fetch(url, {
574
- headers: { "user-agent": USER_AGENT, "accept-language": acceptLang ?? ACCEPT_LANG },
603
+ headers: { "user-agent": USER_AGENT, "accept-language": acceptLang ?? activeAcceptLanguage },
575
604
  signal: controller.signal,
576
605
  redirect: "follow",
577
606
  });
@@ -826,7 +855,19 @@ const EXA_MCP_URL = "https://mcp.exa.ai/mcp";
826
855
  // AnySearch: 免费匿名额度(无 key),可选 Bearer key 提额;结构化 JSON 结果
827
856
  // 401/403:本进程忽略该 key 值(不删除存储),改回匿名免费;不自动清空用户配置
828
857
  let ignoredAnysearchKey = "";
829
- const ANYSEARCH_KEY_INVALID_NOTE = "AnySearch key 无效,本次已忽略该 key,改回免费匿名";
858
+ // 当前请求生效的输出语言(zh / en),由 lang 推导;只有我们自己渲染的文案用它(#92)。
859
+ let activeOutputLanguage = "zh";
860
+ export function setActiveOutputLanguage(value) {
861
+ activeOutputLanguage = String(value ?? "").trim().toLowerCase() === "zh" ? "zh" : "en";
862
+ }
863
+ export function getActiveOutputLanguage() {
864
+ return activeOutputLanguage;
865
+ }
866
+ const ANYSEARCH_KEY_INVALID_NOTE_ZH = "AnySearch key 无效,本次已忽略该 key,改回免费匿名档";
867
+ const ANYSEARCH_KEY_INVALID_NOTE_EN = "AnySearch key was rejected; ignored it and used the anonymous tier";
868
+ function anysearchKeyNote() {
869
+ return activeOutputLanguage === "zh" ? ANYSEARCH_KEY_INVALID_NOTE_ZH : ANYSEARCH_KEY_INVALID_NOTE_EN;
870
+ }
830
871
 
831
872
  async function searchAnysearch(query, maxResults, signal, apiKey) {
832
873
  const trimmedKey = typeof apiKey === "string" ? apiKey.trim() : "";
@@ -864,7 +905,7 @@ async function searchAnysearch(query, maxResults, signal, apiKey) {
864
905
  signal?.removeEventListener("abort", onAbort);
865
906
  }
866
907
  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})`);
908
+ throw new Error(keyRejected ? `${anysearchKeyNote()} (HTTP ${response.status})` : `AnySearch API error (HTTP ${response.status})`);
868
909
  }
869
910
  if (!response.ok) throw new Error(`AnySearch API error (HTTP ${response.status})`);
870
911
  const data = await response.json();
@@ -879,7 +920,7 @@ async function searchAnysearch(query, maxResults, signal, apiKey) {
879
920
  ...(r.snippet ? { snippet: String(r.snippet).slice(0, 300) } : {}),
880
921
  })),
881
922
  truncated: false,
882
- ...(keyRejected || keyIgnoredSticky ? { content: ANYSEARCH_KEY_INVALID_NOTE } : {}),
923
+ ...(keyRejected || keyIgnoredSticky ? { content: anysearchKeyNote() } : {}),
883
924
  };
884
925
  }
885
926
 
@@ -1111,7 +1152,7 @@ async function searchStackOverflow(query, maxResults, signal) {
1111
1152
  }
1112
1153
 
1113
1154
  async function searchWikipedia(query, maxResults, signal, lang) {
1114
- const host = lang === "en" ? "en.wikipedia.org" : "zh.wikipedia.org";
1155
+ const host = `${searchLanguage(lang)}.wikipedia.org`;
1115
1156
  const response = await fetch(
1116
1157
  `https://${host}/w/api.php?action=query&list=search&srsearch=${encodeURIComponent(query)}&format=json&srlimit=${maxResults ?? 5}`,
1117
1158
  {
@@ -1284,7 +1325,7 @@ async function fetchVideoHtml(url, signal, extraHeaders) {
1284
1325
  response = await fetch(url, {
1285
1326
  headers: {
1286
1327
  "user-agent": USER_AGENT,
1287
- "accept-language": ACCEPT_LANG,
1328
+ "accept-language": activeAcceptLanguage,
1288
1329
  accept: "text/html,application/xhtml+xml,application/json;q=0.9,*/*;q=0.8",
1289
1330
  ...(extraHeaders ?? {}),
1290
1331
  },
@@ -3780,6 +3821,11 @@ function apply(ctx, config) {
3780
3821
  const cfg = current();
3781
3822
  // #72:本次请求生效的域名黑名单(模块级活动值;各结果咽喉点过滤读取它)
3782
3823
  setActiveBlockedDomains(cfg.blockedDomains);
3824
+ // #92:Accept-Language 跟随 lang(显式 bingMarket 优先),不再固定中文
3825
+ setActiveAcceptLanguage(
3826
+ (cfg.bingMarket && MARKET_TO_LANG[cfg.bingMarket]) || LANG_PROFILES[searchLanguage(cfg.lang)].acceptLang
3827
+ );
3828
+ setActiveOutputLanguage(outputLanguage(cfg.lang));
3783
3829
  const disabledEngines = normalizeDisabledEngines(cfg.disabledEngines);
3784
3830
  const fallbackOnSet = new Set(normalizeFallbackOn(cfg.fallbackOn));
3785
3831
  const disabledSet = new Set(disabledEngines);
@@ -5148,7 +5194,7 @@ function apply(ctx, config) {
5148
5194
  output: {
5149
5195
  schema: WEATHER_OUTPUT_SCHEMA,
5150
5196
  render(args, value) {
5151
- const lang = current().lang === "en" ? "en" : "zh";
5197
+ const lang = outputLanguage(current().lang);
5152
5198
  const c = value.current ?? {};
5153
5199
  const lines = [];
5154
5200
  lines.push(lang === "en" ? `Weather for ${value.location}:` : `${value.location} 天气:`);
@@ -5168,7 +5214,8 @@ function apply(ctx, config) {
5168
5214
  },
5169
5215
  },
5170
5216
  async execute(args) {
5171
- const lang = current().lang === "en" ? "en" : "zh";
5217
+ // 天气正文只提供 zh/en(回退 en),地理编码用真实搜索语言(ja 就查日文地名)。
5218
+ const lang = searchLanguage(current().lang);
5172
5219
  const location = String(args.location ?? "").trim();
5173
5220
  if (!location) throw new Error("weather: location is required");
5174
5221
  return sanitizeWeatherResult(await fetchWeather(location, args.days, lang, undefined));
@@ -5277,6 +5324,7 @@ function apply(ctx, config) {
5277
5324
  sources: result.sources ?? [],
5278
5325
  timeRange: Boolean(request.timeRange),
5279
5326
  note: typeof result.content === "string" ? result.content : "",
5327
+ lang: current().lang,
5280
5328
  }),
5281
5329
  },
5282
5330
  };
@@ -5376,6 +5424,7 @@ function apply(ctx, config) {
5376
5424
  uncertainty: assessUncertainty({
5377
5425
  sources: toolResult.sources ?? [],
5378
5426
  note: typeof toolResult.content === "string" ? toolResult.content : "",
5427
+ lang: current().lang,
5379
5428
  }),
5380
5429
  },
5381
5430
  };
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.12",
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",