dsh-union-search 0.19.2 → 0.20.0-rc.2

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/lib/client.js CHANGED
@@ -711,6 +711,24 @@ const ENGINES = [
711
711
  noteZh: "免费可用:是;无 key:公网实例池免费;配 key:不需要(可自建实例);价格:免费",
712
712
  noteEn: "Free: yes; no-key: public instance pool; with-key: N/A (self-host optional); price: free"
713
713
  },
714
+ {
715
+ id: "so360",
716
+ label: "360 搜索 · 网页",
717
+ badge: "FREE",
718
+ link: "https://www.so.com",
719
+ price: "免费",
720
+ noteZh: "免费可用:是;无需 key;国内直连稳定(实测 10/10);落地 URL 取 data-mdurl;价格:免费",
721
+ noteEn: "Free: yes; no key; stable direct connect in CN; resolves real URLs via data-mdurl; price: free"
722
+ },
723
+ {
724
+ id: "so360-baike",
725
+ label: "360 搜索 · 百科",
726
+ badge: "FREE",
727
+ link: "https://baike.so.com",
728
+ price: "免费",
729
+ noteZh: "免费可用:是;无需 key;baike.so.com/doc 直链;价格:免费",
730
+ noteEn: "Free: yes; no key; direct baike.so.com/doc links; price: free"
731
+ },
714
732
  {
715
733
  id: "exa",
716
734
  label: "Exa",
package/lib/index.js CHANGED
@@ -427,6 +427,8 @@ const ZHIHU_MCP_URL = "https://developer.zhihu.com/api/mcp/v1";
427
427
  const ZHIPU_SEARCH_URL = "https://open.bigmodel.cn/api/paas/v4/web_search";
428
428
  const BOCHA_SEARCH_URL = "https://api.bochaai.com/v1/web-search";
429
429
  const METASO_SEARCH_URL = "https://metaso.cn/api/v1/search";
430
+ const SO360_WEB_URL = "https://www.so.com/s";
431
+ const SO360_BAIKE_URL = "https://baike.so.com/search/";
430
432
  const XAI_RESPONSES_URL = "https://api.x.ai/v1/responses";
431
433
  const GROK_DEFAULT_MODEL = "grok-4.2";
432
434
  const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36";
@@ -2098,6 +2100,79 @@ async function searchBaidu(query, maxResults, apiKey, timeRange, signal) {
2098
2100
  };
2099
2101
  }
2100
2102
 
2103
+ // src/engines/free/so360.ts
2104
+ function resListBlocks(html) {
2105
+ const re = /<li\b[^>]*class="[^"]*\bres-list\b[^"]*"/g;
2106
+ const starts = [];
2107
+ let m;
2108
+ while (m = re.exec(html)) starts.push(m.index);
2109
+ const out = [];
2110
+ for (let i = 0; i < starts.length; i++) out.push(html.slice(starts[i], i + 1 < starts.length ? starts[i + 1] : html.length));
2111
+ return out;
2112
+ }
2113
+ function pickUrl(block, baike = false) {
2114
+ const md = block.match(/data-mdurl="(https?:\/\/[^"]+)"/);
2115
+ if (md && !/so\.com\/link/.test(md[1])) return decodeEntities(md[1]);
2116
+ const href = block.match(/<h3[^>]*class="[^"]*res-title[\s\S]*?<a[^>]*href="(https?:\/\/[^"]+)"/);
2117
+ if (href && !/so\.com\/link/.test(href[1])) return decodeEntities(href[1]);
2118
+ if (baike) {
2119
+ const any = block.match(/<a[^>]*href="(https?:\/\/baike\.so\.com\/doc\/[^"]+)"/);
2120
+ if (any) return decodeEntities(any[1]);
2121
+ }
2122
+ return null;
2123
+ }
2124
+ function pickTitle(block) {
2125
+ const t = block.match(/<h3[^>]*class="[^"]*res-title[\s\S]*?<a[^>]*>([\s\S]*?)<\/a>/);
2126
+ return t ? stripTags(t[1]) : "";
2127
+ }
2128
+ function pickSnippet(block) {
2129
+ const desc = block.match(/<p[^>]*class="[^"]*\bres-desc\b[^>]*>([\s\S]*?)(?:<br|<\/p>)/);
2130
+ if (desc && stripTags(desc[1])) return stripTags(desc[1]);
2131
+ const sum = block.match(/<span[^>]*class="[^"]*res-list-summary[\s\S]*?<\/span>/);
2132
+ if (sum) return stripTags(sum[0]);
2133
+ return "";
2134
+ }
2135
+ function pickDate(block) {
2136
+ const d = block.match(/(\d{4}-\d{2}-\d{2})/);
2137
+ return d ? d[1] : void 0;
2138
+ }
2139
+ function extractSo360Web(html, baike = false) {
2140
+ const sources = [];
2141
+ for (const block of resListBlocks(html)) {
2142
+ const url = pickUrl(block, baike);
2143
+ if (!url) continue;
2144
+ const title = pickTitle(block);
2145
+ const snippet = pickSnippet(block);
2146
+ const publishedAt = pickDate(block);
2147
+ sources.push({
2148
+ url,
2149
+ ...title ? { title } : {},
2150
+ ...snippet ? { snippet } : {},
2151
+ ...publishedAt ? { publishedAt } : {}
2152
+ });
2153
+ }
2154
+ return sources;
2155
+ }
2156
+ async function searchSo360(query, maxResults, options, signal) {
2157
+ const params = new URLSearchParams({
2158
+ q: query,
2159
+ ie: "utf-8"
2160
+ });
2161
+ const sources = extractSo360Web(await fetchHtmlWithRetry(`${SO360_WEB_URL}?${params}`, signal));
2162
+ return guardRelevance(query, {
2163
+ sources: uniqueSources(sources, maxResults ?? 10),
2164
+ truncated: false
2165
+ });
2166
+ }
2167
+ async function searchSo360Baike(query, maxResults, options, signal) {
2168
+ const params = new URLSearchParams({ q: query });
2169
+ const sources = extractSo360Web(await fetchHtmlWithRetry(`${SO360_BAIKE_URL}?${params}`, signal), true).filter((s) => /baike\.so\.com\/doc\//.test(s.url));
2170
+ return {
2171
+ sources: uniqueSources(sources, maxResults ?? 10),
2172
+ truncated: false
2173
+ };
2174
+ }
2175
+
2101
2176
  // src/engines/keyed/kimi.ts
2102
2177
  async function searchKimi(query, maxResults, apiKey, timeRange, signal) {
2103
2178
  if (!apiKey) throw new Error("Kimi search requires MOONSHOT_API_KEY");
@@ -3553,7 +3628,8 @@ const FREE_ENGINES = [
3553
3628
  "ddg-lite",
3554
3629
  "bing",
3555
3630
  "searxng",
3556
- "anysearch"
3631
+ "anysearch",
3632
+ "so360"
3557
3633
  ];
3558
3634
  const ALL_ENGINES = [
3559
3635
  "ddg",
@@ -3584,7 +3660,9 @@ const ALL_ENGINES = [
3584
3660
  "openai",
3585
3661
  "gemini",
3586
3662
  "claude",
3587
- "grok"
3663
+ "grok",
3664
+ "so360",
3665
+ "so360-baike"
3588
3666
  ];
3589
3667
  const EXPLICIT_ONLY_ENGINES = [
3590
3668
  "openai",
@@ -3764,6 +3842,7 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
3764
3842
  const routeHead = /[\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/.test(String(query ?? "")) ? [
3765
3843
  "bing",
3766
3844
  "baidu",
3845
+ "so360",
3767
3846
  "aliyun",
3768
3847
  "anysearch"
3769
3848
  ] : [
@@ -5156,7 +5235,9 @@ function apply(ctx, config) {
5156
5235
  else if (engine === "anysearch") {
5157
5236
  const key = await resolveApiKey("ANYSEARCH_API_KEY", "anysearchApiKey");
5158
5237
  result = await searchAnysearch(request.query, request.maxResults, effSignal, key);
5159
- } else if (engine === "exa") {
5238
+ } else if (engine === "so360") result = await searchSo360(request.query, request.maxResults, cfg, effSignal);
5239
+ else if (engine === "so360-baike") result = await searchSo360Baike(request.query, request.maxResults, cfg, effSignal);
5240
+ else if (engine === "exa") {
5160
5241
  const key = await resolveApiKey("EXA_API_KEY", "exaApiKey");
5161
5242
  if (key) result = await searchExa(request.query, request.maxResults, key, timeRange, effSignal);
5162
5243
  else result = await searchExaMCP(request.query, request.maxResults, effSignal);
@@ -5767,6 +5848,8 @@ function apply(ctx, config) {
5767
5848
  const key = await resolveApiKey("ANYSEARCH_API_KEY", "anysearchApiKey");
5768
5849
  return await searchAnysearch(q, n, void 0, key);
5769
5850
  }
5851
+ case "so360": return await searchSo360(q, n, cfg);
5852
+ case "so360-baike": return await searchSo360Baike(q, n, cfg);
5770
5853
  case "exa": {
5771
5854
  const key = await resolveApiKey("EXA_API_KEY", "exaApiKey");
5772
5855
  if (key) return await searchExa(q, n, key, tr);
@@ -6740,4 +6823,4 @@ function apply(ctx, config) {
6740
6823
  });
6741
6824
  }
6742
6825
 
6743
- export { ALL_ENGINES, ANYSEARCH_URL, BING_URL, COOLDOWN_SESSION_MS, Config, DDG_HTML_URL, DDG_LITE_URL, DEEPSEEK_TOOLS_DEFAULT_ENDPOINT, DEFAULT_FALLBACK_ON, DEFAULT_FALLBACK_ORDER, EXA_MCP_URL, EXPLICIT_ONLY_ENGINES, FAILURE_CLASSES, FIRECRAWL_URL, FREE_ENGINES, GUIDANCE_SENT, HELP_TOPICS, KEENABLE_MCP_URL, KEENABLE_URL, OUR_LEGACY_PROVIDER_IDS, PARALLEL_URL, PLATFORMS, SEARXNG_INSTANCES, TAVILY_URL, TIME_ENGINES, TIME_RANGES, TOOL_TOPICS, UNION_SEARCH_NS, ZHIHU_MCP_URL, absolutizeRelativeLinks, advanceFetch, alpnHttpsAgent, apply, approximateTimeRange, assertFetchTargetAllowed, assertSchemasterySupportsVolatile, browserUpgradeNeeded, classifyFailure, classifyPin, cleanSnippet, computeTakeoverState, cutSafe, decodeEntities, dedupeSameBilling, detectSearxngLanguage, enabledEngines, engineCooldowns, extractBySelector, firstTouchGuidance, formatKeenableRelative, guardRelevance, hasCustomFallbackOrder, hostInAllowlist, htmlToMarkdownGfm, httpsFetchText, httpsLikeFetch, inject, isPrivateHost, isPrivateIpCase, looksRelevant, matchCookieEntry, name, normalizeDisabledEngines, normalizeFallbackOn, normalizeFallbackOrder, normalizeSearxngLang, parseCookieMap, parseFieldSpecs, parseTimeRange, providerTextFrom, queryOverlapTokens, resolveDeepSeekToolsEndpoint, resolveSearxngInstances, rollbackPinnedFields, routeEngines, searchAliyun, searchAnysearch, searchBaidu, searchBilibili, searchBing, searchBingVideos, searchClaude, searchDdgHtml, searchDdgLite, searchDdgVideos, searchDeepSeekOfficial, searchDeepSeekTools, searchDoubao, searchExa, searchExaMCP, searchFirecrawl, searchGemini, searchGithub, searchHackerNews, searchKeenable, searchKeenableMCP, searchKeenableREST, searchKimi, searchNpm, searchOpenai, searchParallel, searchPerplexity, searchPlatform, searchReddit, searchSearxng, searchSerpbase, searchSerply, searchStackOverflow, searchTavily, searchV2ex, searchVimeo, searchWikipedia, searchYoucom, searchYoutube, searchZhihuGlobal, searchZhihuSite, searxngFailureHint, searxngLanguage, smartTruncate, stripBoundaryTags, verifyInstalledVersion, wrapUntrustedBlock };
6826
+ export { ALL_ENGINES, ANYSEARCH_URL, BING_URL, COOLDOWN_SESSION_MS, Config, DDG_HTML_URL, DDG_LITE_URL, DEEPSEEK_TOOLS_DEFAULT_ENDPOINT, DEFAULT_FALLBACK_ON, DEFAULT_FALLBACK_ORDER, EXA_MCP_URL, EXPLICIT_ONLY_ENGINES, FAILURE_CLASSES, FIRECRAWL_URL, FREE_ENGINES, GUIDANCE_SENT, HELP_TOPICS, KEENABLE_MCP_URL, KEENABLE_URL, OUR_LEGACY_PROVIDER_IDS, PARALLEL_URL, PLATFORMS, SEARXNG_INSTANCES, TAVILY_URL, TIME_ENGINES, TIME_RANGES, TOOL_TOPICS, UNION_SEARCH_NS, ZHIHU_MCP_URL, absolutizeRelativeLinks, advanceFetch, alpnHttpsAgent, apply, approximateTimeRange, assertFetchTargetAllowed, assertSchemasterySupportsVolatile, browserUpgradeNeeded, classifyFailure, classifyPin, cleanSnippet, computeTakeoverState, cutSafe, decodeEntities, dedupeSameBilling, detectSearxngLanguage, enabledEngines, engineCooldowns, extractBySelector, extractSo360Web, firstTouchGuidance, formatKeenableRelative, guardRelevance, hasCustomFallbackOrder, hostInAllowlist, htmlToMarkdownGfm, httpsFetchText, httpsLikeFetch, inject, isPrivateHost, isPrivateIpCase, looksRelevant, matchCookieEntry, name, normalizeDisabledEngines, normalizeFallbackOn, normalizeFallbackOrder, normalizeSearxngLang, parseCookieMap, parseFieldSpecs, parseTimeRange, providerTextFrom, queryOverlapTokens, resolveDeepSeekToolsEndpoint, resolveSearxngInstances, rollbackPinnedFields, routeEngines, searchAliyun, searchAnysearch, searchBaidu, searchBilibili, searchBing, searchBingVideos, searchClaude, searchDdgHtml, searchDdgLite, searchDdgVideos, searchDeepSeekOfficial, searchDeepSeekTools, searchDoubao, searchExa, searchExaMCP, searchFirecrawl, searchGemini, searchGithub, searchHackerNews, searchKeenable, searchKeenableMCP, searchKeenableREST, searchKimi, searchNpm, searchOpenai, searchParallel, searchPerplexity, searchPlatform, searchReddit, searchSearxng, searchSerpbase, searchSerply, searchSo360, searchSo360Baike, searchStackOverflow, searchTavily, searchV2ex, searchVimeo, searchWikipedia, searchYoucom, searchYoutube, searchZhihuGlobal, searchZhihuSite, searxngFailureHint, searxngLanguage, smartTruncate, stripBoundaryTags, verifyInstalledVersion, wrapUntrustedBlock };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-union-search",
3
- "version": "0.19.2",
3
+ "version": "0.20.0-rc.2",
4
4
  "description": "Union web search for DeepSeek Harness (renamed from dsh-free-search): free keyless engines + many professional paid search APIs — 28 engines (Bing/DuckDuckGo/AnySearch/SearXNG multi-instance union/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Zhihu global/site via MCP and Perplexity/SerpBase/Serply/DeepSeek official/You.com/Baidu/Kimi/Aliyun/Doubao/Zhipu/Bocha/Metaso with key; OpenAI/Gemini/Claude/Grok model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + multi mode (parallel top-3 merge) + multi_search cross-source tool + failure-aware fallback + block system built-in search toggle + experimental free advance_fetch (no API key, no billing; host-twin GitHub-Flavored Markdown conversion + CSS selector/fields structured extraction) + time filtering + platform search + web_fetch, with web settings UI.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",