dsh-free-search 0.9.85 → 0.9.86

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
@@ -652,7 +652,7 @@ npx -y -p dsh-free-search dsh-free-search-mcp
652
652
 
653
653
  #### 离线自检断言(tools/)
654
654
 
655
- 仓库自带 **106 个**零依赖断言脚本(合计 **1345 项**)
655
+ 仓库自带 **107 个**零依赖断言脚本(合计 **1352 项**)
656
656
 
657
657
  | 脚本 | 覆盖 | 运行(项数) |
658
658
  |---|---|---|
@@ -697,6 +697,7 @@ npx -y -p dsh-free-search dsh-free-search-mcp
697
697
  | `assert-upgrade-version.mjs` | 一键升级以实际安装结果为准(#163):读回 profile 里真正落下的版本、与 registry 比较、冷却拦截单独报 `upgrade-blocked`、成功路径报 installed 而非 latest、读不到安装状态时不算成功、界面 toast 用 installed、被拦截时用告警色并保留原文案 | `node tools/assert-upgrade-version.mjs`(8) |
698
698
  | `assert-search-proxy.mjs` | 搜索代理(#155)的规则层:http/https/socks5 地址解析、凭据百分号解码、无 scheme 视为 http、socks5h 交给代理解析、非法协议拒绝、`no_proxy` 优先于显式设置、空设置不接管环境变量代理、活动代理是配置层写入的模块状态、搜索路径不再直连全局 `fetch`、该设置只管引擎(天气/更新检查/抓取层保持平台 fetch)、界面中英双语文案、SOCKS5 由本仓库自己实现、重定向三档语义、abort/timeout 保持原生 error 名、HTTP/1.1 请求必须走我们自己的隧道 socket(`agent: false` 与 `https.request` 都会静默绕过代理)、新增依赖为零 | `node tools/assert-search-proxy.mjs`(18) |
699
699
  | `assert-proxy-tunnel.mjs` | 代理隧道实测(#155):本地 CONNECT 代理与手写 SOCKS5 服务端,验证方法/路径/body/host 透传、Basic 凭据解码、每次请求一条隧道且响应后关闭、`follow`/`manual`/`error` 三档重定向语义、303 把 POST 降为 GET、gzip 解压、CONNECT 407 明确报错、代理接受 CONNECT 后立刻断开时不回落直连、不可达代理快速失败、`no_proxy` 绕过隧道、SOCKS5 无认证与用户名密码两档、认证被拒与断线报错 | `node tools/assert-proxy-tunnel.mjs`(17) |
700
+ | `assert-proxy-wiring.mjs` | 搜索代理的接线回归(#155):绕过 `searchOnce` 的入口(`runEngineTest` / `runMultiSearch` / 设置页测试 bridge)自己写活动值、统一出口挂「现读配置」的兜底 resolver、活动值优先于 resolver、配置为空仍直连、resolver 抛错时降级为直连而不是崩溃、`proxyFetch` 在没人写过活动值时不忽略配置的代理 | `node tools/assert-proxy-wiring.mjs`(7) |
700
701
  | `assert-fetch-alpn.mjs` | #162:https 每一跳都声明 `ALPNProtocols: ["http/1.1"]`(只此一个,不带 h2——响应按 HTTP/1.1 解析)、http 目标不声明、按重定向目标的协议逐跳判断、browser 层被跳过时 errors 里写明原因、两个 HTML 返回点都经过瘦身 | `node tools/assert-fetch-alpn.mjs`(7) |
701
702
  | `assert-fetch-html-slim.mjs` | #161:`slimHtml()` 去掉 style/script/noscript/template/注释、只清超长 base64 `data:`(短图标保留)、普通页面逐字节不变、幂等、大小写与跨行标签、构造一个 260 KB 内联 CSS 的页面后同样 200,000 字符预算下正文确实在 | `node tools/assert-fetch-html-slim.mjs`(9) |
702
703
  | `assert-browser-path.mjs` | T1.5 浏览器路径(#160):留空仍走内置候选表、纯空格等同空值、自定义路径原样使用、路径不存在时不回落到其它浏览器、探测缓存随配置失效、provider 收到的是配置值而非硬编码、配置项默认空、设置页能完整读写、输入框只在 T1.5 开启时出现、中英文提示都写明不回落规则 | `node tools/assert-browser-path.mjs`(9) |
@@ -1443,7 +1444,7 @@ Restart `dsh web` after switching to apply changes.
1443
1444
 
1444
1445
  #### Offline self-check assertions (`tools/`)
1445
1446
 
1446
- **One hundred and six** zero-dependency assertion scripts ship with the repo (**1345 assertions** total)
1447
+ **One hundred and seven** zero-dependency assertion scripts ship with the repo (**1352 assertions** total)
1447
1448
 
1448
1449
  | Script | Covers | Run (count) |
1449
1450
  |---|---|---|
package/lib/client.js CHANGED
@@ -938,7 +938,7 @@ window.__ModuleLoader__.load({
938
938
  "cache_search",
939
939
  "domain_search",
940
940
  ];
941
- const PLUGIN_VERSION = "0.9.85";
941
+ const PLUGIN_VERSION = "0.9.86";
942
942
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
943
943
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
944
944
  const NAV_ITEMS = [
package/lib/index.js CHANGED
@@ -11,7 +11,7 @@ import { registerResearchTool } from "./research.js";
11
11
  import { registerDomainSearchTool } from "./vertical.js";
12
12
  import { PLATFORMS, searchPlatform, searchBingVideos, searchDdgVideos, searchYoutube, searchVimeo, xSearchPrompt, grokItemsFromStdout, xSourcesFromItems, searchGithub, searchV2ex, searchBilibili, searchReddit, searchHackerNews, searchStackOverflow, searchWikipedia, searchNpm } from "./platform_engines.js";
13
13
  import { createFetchProvider } from "./fetch_provider.js";
14
- import { setActiveSearchProxy } from "./proxy_fetch.js";
14
+ import { setActiveSearchProxy, setSearchProxyResolver } from "./proxy_fetch.js";
15
15
  import { fetchWeather, formatWeather, sanitizeWeatherResult, WEATHER_OUTPUT_SCHEMA } from "./weather.js";
16
16
  import { setActiveBlockedDomains, getActiveBlockedDomains, isDomainBlocked, applyBlockedFilterToResult } from "./domain_filter.js";
17
17
  import { stripTrackingParams, normalizeUrlForDedupe } from "./url_norm.js";
@@ -1657,6 +1657,11 @@ function apply(ctx, config) {
1657
1657
  }
1658
1658
  };
1659
1659
  const current = () => resolveConfig(config);
1660
+ // #155:给统一出口挂一个「现读配置」的兜底解析器。模块级活动值仍由各入口写入,
1661
+ // 但只要有任何一个入口漏写(runEngineTest 就漏过),这里也不会退回直连。
1662
+ setSearchProxyResolver(() => current().searchProxy);
1663
+ // 测试替身里的 ctx 可能没有 effect;宿主一定有。
1664
+ if (typeof ctx.effect === "function") ctx.effect(() => () => setSearchProxyResolver(null));
1660
1665
  const engineRuntime = createEngineRuntime();
1661
1666
  const engineConcurrency = (engine) =>
1662
1667
  SERP_FAMILY.has(engine) ? SERP_CONCURRENCY_LIMIT : ENGINE_CONCURRENCY_LIMIT;
@@ -2736,6 +2741,11 @@ function apply(ctx, config) {
2736
2741
  // #72:runEngineTest 也被 multi_search 工具 / 设置页 bridge 直接调用,
2737
2742
  // 不经过 provider.search,所以这里必须自行设置活动黑名单
2738
2743
  setActiveBlockedDomains(cfg.blockedDomains);
2744
+ // #155(回归):同一批入口也绕过了 searchOnce,代理的活动值同样要在这里写。
2745
+ // 漏了这一行,冷进程下 free_search_test / multi_search / 设置页「测试引擎」
2746
+ // 会退回直连:受限网络里全红(被误判成「代理没配好」),能直连的网络里则是
2747
+ // 假阳性——测试给了绿灯,但实际根本没走代理。
2748
+ setActiveSearchProxy(cfg.searchProxy);
2739
2749
  const q = query || "DeepSeek Harness";
2740
2750
  const n = Math.min(Math.max(Number(maxResults) || 2, 1), 20);
2741
2751
  const tr = parseTimeRange(timeRange);
@@ -2989,6 +2999,8 @@ function apply(ctx, config) {
2989
2999
  if (!query || !String(query).trim()) throw new Error("query is required");
2990
3000
  // #72:multi_search 工具直连本函数、不经过 provider.search,自行设置活动黑名单
2991
3001
  setActiveBlockedDomains(current().blockedDomains);
3002
+ // #155(回归):同理,代理也不能只指望 searchOnce 写。
3003
+ setActiveSearchProxy(current().searchProxy);
2992
3004
  const q = String(query).trim();
2993
3005
  const limit = multiResultLimit(maxResults, current().multiMaxResults);
2994
3006
  const disabled = new Set(effectiveDisabledEngines(current()));
@@ -30,15 +30,41 @@ const bareHost = (h) => String(h ?? "").toLowerCase().replace(/^\[/, "").replace
30
30
  * 空字符串 = 未配置,交给平台 fetch(它会跟随环境变量代理)。
31
31
  */
32
32
  let activeSearchProxy = "";
33
+ /**
34
+ * 兜底取值:没有任何入口写过活动值时,直接问配置。
35
+ *
36
+ * #155 回归的根本原因是「设置活动值」这件事需要每个入口各自记得做一次
37
+ * (searchOnce 记得、runEngineTest 忘过)。这类遗漏没法靠补一行彻底避免,
38
+ * 所以这里再挂一个 resolver:活动值为空时现读配置,入口忘了写也不会退回直连。
39
+ * 生产环境由 index.js 注册;单测直接 import 本模块时没有 resolver,
40
+ * 行为与之前完全一致。
41
+ */
42
+ let searchProxyResolver = null;
33
43
 
34
44
  /** 设置本进程当前使用的搜索代理;空值表示不由本模块接管。 */
35
45
  export function setActiveSearchProxy(value) {
36
46
  activeSearchProxy = typeof value === "string" ? value.trim() : "";
37
47
  }
38
48
 
49
+ /** 注册一个「当前配置里的搜索代理」解析器(启动时注册一次)。 */
50
+ export function setSearchProxyResolver(fn) {
51
+ searchProxyResolver = typeof fn === "function" ? fn : null;
52
+ }
53
+
39
54
  /** 读取当前生效的搜索代理(测试与诊断用)。 */
40
55
  export function getActiveSearchProxy() {
41
- return activeSearchProxy;
56
+ return activeSearchProxy !== "" ? activeSearchProxy : resolveConfiguredProxy();
57
+ }
58
+
59
+ /** 活动值优先,其次现读配置;都没有就是空串(交给平台 fetch)。 */
60
+ function resolveConfiguredProxy() {
61
+ if (searchProxyResolver === null) return "";
62
+ try {
63
+ const value = searchProxyResolver();
64
+ return typeof value === "string" ? value.trim() : "";
65
+ } catch {
66
+ return "";
67
+ }
42
68
  }
43
69
 
44
70
  /** 解析一段代理字符串;不合法返回 null。支持 scheme 省略(按 http 处理)。 */
@@ -448,7 +474,9 @@ export async function proxyFetch(url, init = {}) {
448
474
  const redirectMode = init.redirect ?? "follow";
449
475
  const maxRedirects = 20;
450
476
  const explicitProxy = init.proxy ?? null;
451
- const configuredProxy = init.searchProxy ?? activeSearchProxy;
477
+ // 活动值优先;它为空时问解析器(现读配置)。这样即便某个入口忘了
478
+ // setActiveSearchProxy,也不会静默退回直连。
479
+ const configuredProxy = init.searchProxy ?? (activeSearchProxy !== "" ? activeSearchProxy : resolveConfiguredProxy());
452
480
 
453
481
  if (explicitProxy === null && configuredProxy === "") {
454
482
  // 显式读 globalThis:测试会把 globalThis.fetch 换成替身,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.85",
3
+ "version": "0.9.86",
4
4
  "description": "Free web search for DeepSeek Harness: 42 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/Brave/Zhipu/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/Baidu/Kimi/Aliyun/Doubao/Google CSE/Metaso/Yandex/Yuanbao/SpecStream 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, plus a standalone stdio MCP server.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",