dsh-union-search 0.10.15 → 0.10.17

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.
Files changed (2) hide show
  1. package/lib/index.js +23 -11
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -241,7 +241,7 @@ function routeEngines(query, { timeRange, disabledEngines = [], fallbackOrder =
241
241
  }
242
242
 
243
243
  // 当前插件版本(发布时与 package.json 同步)
244
- const PLUGIN_VERSION = "0.10.10";
244
+ const PLUGIN_VERSION = "0.10.17";
245
245
  // 检查更新的 npm registry 元数据地址(dsh-union-search 是 npmjs 上的公开包,0.10.15 起统一裸名)
246
246
  const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-union-search/latest";
247
247
  const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-union-search";
@@ -4769,6 +4769,10 @@ function apply(ctx, config) {
4769
4769
 
4770
4770
  ctx.inject(["webServer", "settings"], (sctx) => {
4771
4771
  sctx.effect(() => {
4772
+ // [0.10.17] settings guaranteed available here, initial takeover fires in inject
4773
+ try { applySearchTakeover(); } catch (e) {
4774
+ sctx.logger.warn("union-search: takeover in inject failed (non-fatal): " + (e && e.message || e));
4775
+ }
4772
4776
  const disposers = makeBridgeRoutes(
4773
4777
  sctx.settings,
4774
4778
  (request) => provider.search(request, undefined),
@@ -4847,16 +4851,20 @@ function apply(ctx, config) {
4847
4851
  const signature = JSON.stringify(ops);
4848
4852
  if (signature === lastPinnedSignature) return;
4849
4853
  lastPinnedSignature = signature;
4850
- let pinned = Promise.reject(new Error("settings service unavailable"));
4851
- try {
4852
- const settingsSvc = ctx.get("settings");
4853
- if (settingsSvc && typeof settingsSvc.mutate === "function") {
4854
- pinned = Promise.resolve(settingsSvc.mutate("web", ops));
4855
- }
4856
- } catch {
4857
- // 落到统一 catch
4854
+ // 守卫:settings 可能尚未挂载(apply 期),early-return 避免创建 rejected Promise 哨兵
4855
+ let settingsSvc;
4856
+ try { settingsSvc = ctx.get("settings"); } catch { settingsSvc = null; }
4857
+ if (!settingsSvc || typeof settingsSvc.mutate !== "function") {
4858
+ lastPinnedSignature = "";
4859
+ logger.warn(
4860
+ `union-search: settings service not ready, searchProvider takeover deferred; ` +
4861
+ `will retry on next config change. If web_search reports WEB_PROVIDER_AMBIGUOUS, ` +
4862
+ `add to the profile's cordis.patch.yml:\n` +
4863
+ `- id: web\n config:\n searchProvider: ${provider.id}\n fetchProvider: http`
4864
+ );
4865
+ return;
4858
4866
  }
4859
- pinned
4867
+ Promise.resolve(settingsSvc.mutate("web", ops))
4860
4868
  .then(() => {
4861
4869
  logger.info(`union-search: pinned web entry config ${ops.map((o) => `${o.path.join(".")}=${o.value}`).join(", ")}`);
4862
4870
  })
@@ -4877,7 +4885,11 @@ function apply(ctx, config) {
4877
4885
  : `union-search: taking over from the default provider "${previous}" as "${provider.id}"`
4878
4886
  );
4879
4887
  };
4880
- applySearchTakeover();
4888
+ // [0.10.17] fallback: if inject does not fire (no webServer), try here.
4889
+ // Safe: applySearchTakeover early-returns if settings unavailable (0.10.16 guard).
4890
+ try { applySearchTakeover(); } catch (e) {
4891
+ logger.warn(`union-search: initial takeover error (non-fatal): ${e?.message ?? e}`);
4892
+ }
4881
4893
 
4882
4894
  // 单引擎测试执行器:设置卡「测试引擎」按钮与全引擎测试(runEngineTests)共用
4883
4895
  const runEngineTest = async (engine, query, timeRange, maxResults = 2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-union-search",
3
- "version": "0.10.15",
3
+ "version": "0.10.17",
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",