dsh-free-search 0.9.32 → 0.9.34

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
@@ -34,6 +34,7 @@ dsh 默认的搜索 provider 依赖 DeepSeek 官方 API key(`DEEPSEEK_API_KEY`
34
34
  - **按 key 冷却与诊断** —— 429 与额度错误按 key 分别冷却,同一引擎的其他 key 不受牵连;冷却状态写入磁盘,重启后仍在;失败信息和日志里的 key 一律打码;设置页底部的「诊断」按钮列出每个引擎当前为什么不可用、冷却还剩多久
35
35
  - **引擎白名单** —— 设置页「只使用勾选的引擎」开启后,只有勾选的引擎可用,升级新增的引擎默认不启用;配置里对应 `allowedEngines`(非空时等价于把其余引擎全部禁用)
36
36
  - **自带更新** —— 卡片底部显示当前版本和「检查更新」;npm 安装的版本可一键升级到 latest,本地 link 开发模式改为跳转 npm 页面并提示 git pull
37
+ - **截断安全** —— 标题和摘要按码点截断,搜索结果、工具输出和 web_fetch 正文在离开插件前统一清除孤立代理;含 emoji 的结果不会再让会话历史出现无法序列化的字符(#108)
37
38
  - **网页设置页** —— 引擎切换 + API key 配置(UI 中 key 脱敏显示"已配置")+ 中英文切换;入口在左侧「插件」页的组件行配置(`plugins.row.config`,DSH 0.1.7-rc.1+)。远程访问(VPS / 反向代理 / 自定义域名)下也能用:桥接接口沿用宿主的 Host 围栏,`--trusted-host` 与 `--public-url` 声明的地址会放行(#84)
38
39
  - **右侧浮动目录** —— 卡片右侧的页面留白里浮出「引擎 / 回退 / 语言池 / 搜索行为 / 抓取 / 性能 / 提示词管理」七个快捷跳转,滚动自动高亮当前项、点击平滑跳转;不占用正文宽度(正文布局与 0.9.6 一致),右侧留白不足时自动隐藏;每项都是真链接(`#/panel/plugins/dsh-free-search/<分区>`),可复制、可开新标签,见下方「分区链接契约」
39
40
 
@@ -538,7 +539,7 @@ Search engine test:
538
539
 
539
540
  #### 离线自检断言(tools/)
540
541
 
541
- 仓库自带 **43 个**零依赖断言脚本(合计 **753 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
542
+ 仓库自带 **44 个**零依赖断言脚本(合计 **762 项**),**不需要 API key、不联网、不需要测试框架**,Node ≥ 20 即可跑:
542
543
 
543
544
  | 脚本 | 覆盖 | 运行(项数) |
544
545
  |---|---|---|
@@ -578,6 +579,7 @@ Search engine test:
578
579
  | `assert-allowed-engines.mjs` | 引擎白名单(#106):条目归一化、空名单保持原状、非空时禁用其余全部(含未来新增)、显式禁用优先、错拼不锁死搜索、白名单内引擎可入链(HTML 家族 / 按次计费)、auto 只路由白名单、内置提示词只列白名单且回退为 none、schema 默认空 | `node tools/assert-allowed-engines.mjs`(9) |
579
580
  | `assert-updater.mjs` | 自带更新:版本比较、registry 探测(成功 / 非 200 / 网络失败返回 null)、安装模式识别(真实安装优先于 link)、客户端按钮与桥接、服务端两条路由与 pnpm 升级命令、卡片版本跟 package.json 一致 | `node tools/assert-updater.mjs`(9) |
580
581
  | `assert-inject.mjs` | 旧版 Cordis 兼容(#107):静态 inject 声明 web / settings / tools / systemPrompt、可选服务只走 `ctx.get`、回调上下文的属性读取都在 inject 里、动态依赖列表没有未知服务 | `node tools/assert-inject.mjs`(4) |
582
+ | `assert-safe-text.mjs` | UTF-16 截断安全(#108):孤立高低代理清理、有效代理对保留、码点截断不切开 emoji、`cleanSnippet` 300 边界落在整字符、结果/来源/错误脱敏、web_fetch 各层正文兜底、源码守卫 | `node tools/assert-safe-text.mjs`(9) |
581
583
  | `assert-degoog.mjs` | degoog 自建实例(#85):`/api/search` URL 规范化、查询编码、`time`/`lang` 参数、注册表位置、无需凭据 | `node tools/assert-degoog.mjs`(7) |
582
584
  | `assert-multikey.mjs` | 多 key 字段:单 key 不变、逗号/分号/换行分隔、空白项丢弃、空输入为空数组 | `node tools/assert-multikey.mjs`(3) |
583
585
  | `assert-firecrawl-keyless.mjs` | Firecrawl keyless 出口判定:403 + VPN/proxy 文案才算拒绝、普通 403 与 401/429/500 不算、冷却初始未触发 | `node tools/assert-firecrawl-keyless.mjs`(5) |
@@ -666,6 +668,7 @@ Adding a section takes three steps: put `data-dsh-section="<new id>"` on the con
666
668
  - **System Prompt Injection** — The agent is aware of the currently active engine and which engines require API keys; it is also told that all search output is **untrusted external data** and must never be executed as instructions
667
669
  - **Prompt-Injection Guard (untrusted-data boundary)** — Web-derived text from the plugin's own tools (`advanced_search` / `platform_search` / `free_search_test`) is wrapped in an explicit `<untrusted-web-content>` boundary (look-alike tags inside the text are stripped to prevent early closure); the core `web_search` / `web_fetch` tools carry DSH core's own notice (`External web content follows...`); every snippet is cleaned and capped at 300 characters
668
670
  - **Built-in updater** — the card footer shows the version and a Check update button; npm installs upgrade to latest in one click, while a local link install links to the npm page and points at git pull instead
671
+ - **Truncation safety** — titles and snippets are cut by code point, and search results, tool output and web_fetch bodies are stripped of lone surrogates before leaving the plugin; an emoji can no longer make history unserializable (#108)
669
672
  - **Result Caching** — Identical queries (same engine / time-filter args) hit an LRU cache (50 entries) for up to 5 minutes, protecting free engines from rate-limiting and saving paid quota; the TTL is configurable from 0-5 minutes in the settings UI (0 disables caching)
670
673
  - **Domain blocklist & safe search** — `blockedDomains` keeps matching domains out of every result; `safeSearch` (`off` / `moderate` / `strict`) adds a filter layer for Bing / DuckDuckGo
671
674
  - **Visual Badges** — Free engines feature a green `FREE` badge, while paid engines show an orange `API KEY` badge in the settings UI
@@ -1142,7 +1145,7 @@ Restart `dsh web` after switching to apply changes.
1142
1145
 
1143
1146
  #### Offline self-check assertions (`tools/`)
1144
1147
 
1145
- **Forty-three** zero-dependency assertion scripts ship with the repo (**753 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1148
+ **Forty-four** zero-dependency assertion scripts ship with the repo (**762 assertions** total): **no API keys, no network, no test framework**, Node ≥ 20:
1146
1149
 
1147
1150
  | Script | Covers | Run (count) |
1148
1151
  |---|---|---|
@@ -1182,6 +1185,7 @@ Restart `dsh web` after switching to apply changes.
1182
1185
  | `assert-allowed-engines.mjs` | Engine whitelist (#106): entries normalised, an empty list changes nothing, a non-empty list disables everything else (including future engines), explicit disables win, a typo does not brick search, whitelisted engines join the chain (HTML family / billed), Auto only routes allowed engines, the built-in prompt lists only them with a none fallback, and the schema defaults to empty | `node tools/assert-allowed-engines.mjs` (9) |
1183
1186
  | `assert-updater.mjs` | Built-in updater: version comparison, registry probe (success / non-200 / network failure yields null), install-mode detection (a real install beats a link), the client button and bridge helper, both server routes with the pnpm upgrade command, and the card version matching package.json | `node tools/assert-updater.mjs` (9) |
1184
1187
  | `assert-inject.mjs` | Older Cordis compatibility (#107): the static inject list declares web / settings / tools / systemPrompt, optional services are read through `ctx.get`, every property read on a callback context is declared, and dynamic dependency lists contain no unknown services | `node tools/assert-inject.mjs` (4) |
1188
+ | `assert-safe-text.mjs` | UTF-16 truncation safety (#108): lone high/low surrogates replaced, valid pairs kept, code-point slicing never splits an emoji, `cleanSnippet`'s 300 boundary lands on a whole character, results/sources/errors sanitized, every web_fetch tier covered, plus source guards | `node tools/assert-safe-text.mjs` (9) |
1185
1189
  | `assert-degoog.mjs` | degoog self-hosted instance (#85): `/api/search` URL normalisation, query encoding, `time`/`lang` parameters, registry placement, no credentials needed | `node tools/assert-degoog.mjs` (7) |
1186
1190
  | `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) |
1187
1191
  | `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
@@ -613,7 +613,7 @@ window.__ModuleLoader__.load({
613
613
  "cache_search",
614
614
  "domain_search",
615
615
  ];
616
- const PLUGIN_VERSION = "0.9.32";
616
+ const PLUGIN_VERSION = "0.9.34";
617
617
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
618
618
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
619
619
  const NAV_ITEMS = [
@@ -12,6 +12,7 @@ import { existsSync, mkdtempSync, rmSync } from "node:fs";
12
12
  import { tmpdir } from "node:os";
13
13
  import { join } from "node:path";
14
14
  import { callExa, callFirecrawl, callCrawl4ai } from "./fetch_upstream.js";
15
+ import { stripLoneSurrogates } from "./safe_text.js";
15
16
 
16
17
  const T1_MIN_CHARS = 300;
17
18
  const TEXTUAL = /text\/|json|xml|javascript|application\/json/i;
@@ -308,7 +309,7 @@ export function createFetchProvider({ resolveApiKey, logger, acceptLanguage = ()
308
309
  try {
309
310
  const r = await httpsGetFollow(url, { headers: browserishHeaders(acceptLanguage()), signal });
310
311
  if (r.status < 400 && TEXTUAL.test(r.contentType) && r.text.length >= T1_MIN_CHARS) {
311
- return { url: r.url, statusCode: r.status, body: { kind: "html", content: r.text }, truncated: false };
312
+ return { url: r.url, statusCode: r.status, body: { kind: "html", content: stripLoneSurrogates(r.text) }, truncated: false };
312
313
  }
313
314
  if (r.status >= 400) errors.push(`direct HTTP ${r.status}`);
314
315
  else errors.push(`direct: ${r.contentType || "unknown type"} ${r.text.length}B`);
@@ -320,7 +321,7 @@ export function createFetchProvider({ resolveApiKey, logger, acceptLanguage = ()
320
321
  try {
321
322
  const html = await browserDumpDom(browserPath, url, { signal });
322
323
  if (html && html.length >= T1_MIN_CHARS && !/403 Forbidden|\bcaptcha\b/i.test(html.slice(0, 3000))) {
323
- return { url, statusCode: 200, body: { kind: "html", content: html }, truncated: false };
324
+ return { url, statusCode: 200, body: { kind: "html", content: stripLoneSurrogates(html) }, truncated: false };
324
325
  }
325
326
  errors.push(html ? `browser: short or challenge page (${html.length}B)` : "browser: no output (timeout or launch failure)");
326
327
  } catch (e) {
@@ -333,7 +334,7 @@ export function createFetchProvider({ resolveApiKey, logger, acceptLanguage = ()
333
334
  if (exaKey) {
334
335
  try {
335
336
  const text = await callExa(url, exaKey, signal);
336
- if (text.trim().length >= T1_MIN_CHARS) return { url, statusCode: 200, body: { kind: "text", content: text }, truncated: false };
337
+ if (text.trim().length >= T1_MIN_CHARS) return { url, statusCode: 200, body: { kind: "text", content: stripLoneSurrogates(text) }, truncated: false };
337
338
  errors.push("exa: short content");
338
339
  } catch (e) { errors.push(`exa: ${e.message}`); }
339
340
  }
@@ -342,7 +343,7 @@ export function createFetchProvider({ resolveApiKey, logger, acceptLanguage = ()
342
343
  if (firecrawlKey) {
343
344
  try {
344
345
  const md = await callFirecrawl(url, firecrawlKey, signal);
345
- if (md.trim().length >= T1_MIN_CHARS) return { url, statusCode: 200, body: { kind: "text", content: md }, truncated: false };
346
+ if (md.trim().length >= T1_MIN_CHARS) return { url, statusCode: 200, body: { kind: "text", content: stripLoneSurrogates(md) }, truncated: false };
346
347
  errors.push("firecrawl: short content");
347
348
  } catch (e) { errors.push(`firecrawl: ${e.message}`); }
348
349
  }
@@ -351,7 +352,7 @@ export function createFetchProvider({ resolveApiKey, logger, acceptLanguage = ()
351
352
  if (crawl4aiKey) {
352
353
  try {
353
354
  const text = await callCrawl4ai(url, crawl4aiKey, signal);
354
- if (text.trim().length >= T1_MIN_CHARS) return { url, statusCode: 200, body: { kind: "text", content: text }, truncated: false };
355
+ if (text.trim().length >= T1_MIN_CHARS) return { url, statusCode: 200, body: { kind: "text", content: stripLoneSurrogates(text) }, truncated: false };
355
356
  errors.push("crawl4ai: short content");
356
357
  } catch (e) { errors.push(`crawl4ai: ${e.message}`); }
357
358
  }
package/lib/index.js CHANGED
@@ -16,6 +16,7 @@ import { selectEngines, planTopUp, resolveMinSources, describeTarget, credential
16
16
  import { promptLanguageOf, systemCopy, toolDescription, toolParam, localizedEffect, effectivePromptText, normalizePromptPages, PROMPT_SEGMENTS } from "./prompt_i18n.js";
17
17
  import { SERP_ENGINE_IDS, SERP_FAMILY, SERP_TIME_ENGINES, searchSerpEngine } from "./serp_engines.js";
18
18
  import { createCooldownStore, cooldownDelayFor, isRegionLocked, keyCooldownId, SESSION, SHORT_COOLDOWN_MS } from "./cooldown.js";
19
+ import { stripLoneSurrogates, truncateText, sanitizeSource, sanitizeSources, sanitizeSearchResult, sanitizeError } from "./safe_text.js";
19
20
  import { rememberSecret, redactSecrets, environmentSecrets } from "./redact.js";
20
21
  import { buildDoctorReport } from "./doctor.js";
21
22
  import { searchAgy, agyAvailable } from "./agy.js";
@@ -666,12 +667,13 @@ const SNIPPET_NOISE =
666
667
 
667
668
  function cleanSnippet(text, max = 300) {
668
669
  if (!text) return text;
669
- return String(text)
670
+ const cleaned = String(text)
670
671
  .replace(SNIPPET_NOISE, " ")
671
672
  .replace(/^\s*(#{1,6}\s*|\[\s*x?\s*\]\s*|-\s*\[\s*x?\s*\]\s*|>\s*)/gm, " ")
672
673
  .replace(/\s+/g, " ")
673
- .trim()
674
- .slice(0, max);
674
+ .trim();
675
+ // #108: cut by code point, never through a surrogate pair
676
+ return truncateText(cleaned, max);
675
677
  }
676
678
 
677
679
  // 各引擎的摘要展示上限:豆包搜索返回的是千字级 Summary(实测 1300-1800 字),放宽到 2000;
@@ -697,7 +699,10 @@ function stripBoundaryTags(text) {
697
699
  }
698
700
 
699
701
  function wrapUntrustedBlock(text) {
700
- return `${UNTRUSTED_BOUNDARY_OPEN}\n${stripBoundaryTags(text)}\n${UNTRUSTED_BOUNDARY_CLOSE}`;
702
+ // #108: engine text can carry a lone surrogate after UTF-16 truncation; strip it
703
+ // once here so every wrapped tool output is safe to put into session history.
704
+ const safe = stripLoneSurrogates(typeof text === "string" ? text : String(text ?? ""));
705
+ return `${UNTRUSTED_BOUNDARY_OPEN}\n${stripBoundaryTags(safe)}\n${UNTRUSTED_BOUNDARY_CLOSE}`;
701
706
  }
702
707
 
703
708
  function stripTags(html) {
@@ -732,7 +737,7 @@ function uniqueSources(sources, limit) {
732
737
  }
733
738
  if (out.length >= limit) break;
734
739
  }
735
- return out;
740
+ return out.map(sanitizeSource);
736
741
  }
737
742
 
738
743
  async function fetchHtml(url, signal, acceptLang) {
@@ -4462,17 +4467,23 @@ function apply(ctx, config) {
4462
4467
  },
4463
4468
  // 单 query 结果缓存:key=query+maxResults+timeRangeLabel+preferred,Map 天然 LRU
4464
4469
  async search(request, signal) {
4465
- // 轮换时机:首次失败后 keyRings 已经填充,此时再判断有几把 key。
4466
- for (let attempt = 0; attempt < 10; attempt++) {
4467
- try {
4468
- return await provider.searchOnce(request, signal);
4469
- } catch (error) {
4470
- const keys = maxKeyRingLength();
4471
- if (keys <= 1 || attempt >= keys - 1 || !isKeyRotationCandidate(error)) throw error;
4472
- logger.warn(`free-search: retrying with the next API key (${error?.message ?? error})`);
4470
+ // #108: every result and error leaving the provider must be valid Unicode —
4471
+ // a lone surrogate in the history rejects every later request upstream.
4472
+ try {
4473
+ // 轮换时机:首次失败后 keyRings 已经填充,此时再判断有几把 key。
4474
+ for (let attempt = 0; attempt < 10; attempt++) {
4475
+ try {
4476
+ return sanitizeSearchResult(await provider.searchOnce(request, signal));
4477
+ } catch (error) {
4478
+ const keys = maxKeyRingLength();
4479
+ if (keys <= 1 || attempt >= keys - 1 || !isKeyRotationCandidate(error)) throw error;
4480
+ logger.warn(`free-search: retrying with the next API key (${error?.message ?? error})`);
4481
+ }
4473
4482
  }
4483
+ throw new Error("all search engines failed");
4484
+ } catch (error) {
4485
+ throw sanitizeError(error);
4474
4486
  }
4475
- throw new Error("all search engines failed");
4476
4487
  },
4477
4488
  async searchOnce(request, signal) {
4478
4489
  // 公共咽喉校验:web_search / advanced_search / raw-search 三条路径都经过这里
@@ -5590,8 +5601,9 @@ function apply(ctx, config) {
5590
5601
 
5591
5602
  return {
5592
5603
  provider: "multi_search",
5593
- content: `Note: ${notes.join("; ")}`,
5594
- sources: finalSources,
5604
+ // #108: the multi tool bypasses provider.search, so sanitize here as well
5605
+ content: stripLoneSurrogates(`Note: ${notes.join("; ")}`),
5606
+ sources: sanitizeSources(finalSources),
5595
5607
  truncated: false,
5596
5608
  };
5597
5609
  };
@@ -6227,6 +6239,7 @@ export {
6227
6239
  hasCustomFallbackOrder,
6228
6240
  normalizeDisabledEngines,
6229
6241
  normalizeAllowedEngines,
6242
+ cleanSnippet,
6230
6243
  compareVersions,
6231
6244
  detectInstallMode,
6232
6245
  fetchLatestVersion,
@@ -0,0 +1,67 @@
1
+ /**
2
+ * UTF-16 safety for tool results (#108).
3
+ *
4
+ * `String.prototype.slice` cuts on code units. A cut inside a surrogate pair
5
+ * leaves a lone surrogate, which is valid JavaScript but not valid Unicode:
6
+ * serialized as an unpaired \ud83d it makes the upstream Messages endpoint
7
+ * reject the whole request, and because the poisoned text is stored in the
8
+ * session history every later turn fails too.
9
+ */
10
+
11
+ const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
12
+
13
+ export function stripLoneSurrogates(text) {
14
+ if (typeof text !== "string" || text.length === 0) return text;
15
+ return text.replace(LONE_SURROGATE, "\uFFFD");
16
+ }
17
+
18
+ /** Cut by code point so a surrogate pair is never split. */
19
+ export function sliceByCodePoint(text, max) {
20
+ if (typeof text !== "string") return text;
21
+ const limit = Math.floor(Number(max));
22
+ if (!Number.isFinite(limit) || limit < 0) return text;
23
+ const chars = Array.from(text);
24
+ if (chars.length <= limit) return text;
25
+ return chars.slice(0, limit).join("");
26
+ }
27
+
28
+ /** Strip stray surrogates first, then cut by code point. */
29
+ export function truncateText(text, max) {
30
+ const safe = stripLoneSurrogates(typeof text === "string" ? text : String(text));
31
+ return sliceByCodePoint(safe, max);
32
+ }
33
+
34
+ export function sanitizeSource(source) {
35
+ if (source === null || typeof source !== "object") return source;
36
+ const out = { ...source };
37
+ for (const key of ["title", "url", "snippet", "content"]) {
38
+ if (typeof out[key] === "string") out[key] = stripLoneSurrogates(out[key]);
39
+ }
40
+ return out;
41
+ }
42
+
43
+ export function sanitizeSources(sources) {
44
+ return Array.isArray(sources) ? sources.map(sanitizeSource) : sources;
45
+ }
46
+
47
+ /** Sanitize a search result (sources + the note that accompanies them). */
48
+ export function sanitizeSearchResult(result) {
49
+ if (result === null || typeof result !== "object") return result;
50
+ const out = { ...result };
51
+ if (Array.isArray(out.sources)) out.sources = sanitizeSources(out.sources);
52
+ for (const key of ["content", "note", "provider", "engine"]) {
53
+ if (typeof out[key] === "string") out[key] = stripLoneSurrogates(out[key]);
54
+ }
55
+ return out;
56
+ }
57
+
58
+ /** Keep an error's message and stack free of lone surrogates. */
59
+ export function sanitizeError(error) {
60
+ if (!(error instanceof Error)) return error;
61
+ const message = stripLoneSurrogates(error.message);
62
+ if (message === error.message) return error;
63
+ const wrapped = new Error(message);
64
+ wrapped.name = error.name;
65
+ if (typeof error.stack === "string") wrapped.stack = stripLoneSurrogates(error.stack);
66
+ return wrapped;
67
+ }
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import { normalizeUrlForDedupe } from "./url_norm.js";
20
+ import { truncateText, stripLoneSurrogates, sliceByCodePoint } from "./safe_text.js";
20
21
 
21
22
  export const SERP_UA =
22
23
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
@@ -84,12 +85,14 @@ export function stripTags(html) {
84
85
  }
85
86
 
86
87
  function cleanTitle(title) {
87
- return stripTags(title).replace(/^[\s\-–—|·•]+|[\s\-–—|·•]+$/g, "").slice(0, 240);
88
+ return truncateText(stripTags(title).replace(/^[\s\-–—|·•]+|[\s\-–—|·•]+$/g, ""), 240);
88
89
  }
89
90
 
90
91
  function cleanSnippet(snippet) {
91
92
  const text = stripTags(snippet);
92
- return text.length > 400 ? `${text.slice(0, 400)}…` : text;
93
+ const safe = stripLoneSurrogates(text);
94
+ const cut = sliceByCodePoint(safe, 400);
95
+ return cut.length < safe.length ? `${cut}…` : cut;
93
96
  }
94
97
 
95
98
  function unescapeAttr(value) {
package/lib/vertical.js CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { defineTool } from "@deepseek-ai/dsh-tools";
6
6
  import { httpsJson, htmlToText } from "./fetch_upstream.js";
7
+ import { stripLoneSurrogates } from "./safe_text.js";
7
8
  import { promptLanguageOf, toolDescription, toolParam, localizedEffect } from "./prompt_i18n.js";
8
9
 
9
10
  const UA = { "User-Agent": "dsh-free-search/0.8 (plugin)", Accept: "application/json" };
@@ -686,7 +687,10 @@ export function registerDomainSearchTool(ctx, { wrapUntrustedBlock, getConfig =
686
687
  },
687
688
  },
688
689
  render(_args, value) {
689
- if (value.error) return [{ type: "text", text: `domain_search (${value.engine}) failed: ${value.error}` }];
690
+ if (value.error) {
691
+ const message = stripLoneSurrogates(String(value.error));
692
+ return [{ type: "text", text: `domain_search (${value.engine}) failed: ${message}` }];
693
+ }
690
694
  const lines = value.sources.map((s, i) => `- [${i + 1}] ${s.title} — ${s.url}${s.publishedAt ? ` _(${s.publishedAt})_` : ""}${s.snippet ? `\n ${s.snippet}` : ""}`);
691
695
  return [{ type: "text", text: wrapUntrustedBlock(`domain_search ${value.engine} — ${value.query}:\n${lines.join("\n") || "No results."}`) }];
692
696
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.32",
3
+ "version": "0.9.34",
4
4
  "description": "Free web search for DeepSeek Harness: 27 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/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",
@@ -113,11 +113,13 @@
113
113
  "platform": "web"
114
114
  },
115
115
  "engines": {
116
- "dsh": ">=0.1.7-rc.1"
116
+ "dsh": ">=0.2.1-rc.2 <0.4.0-0"
117
117
  },
118
118
  "compatibility": {
119
119
  "dshReleases": {
120
- "0.1.7-rc.1": "compatible"
120
+ "0.2.1-rc.2": "compatible",
121
+ "0.2.1-rc.5": "compatible",
122
+ "0.2.2-rc.1": "compatible"
121
123
  }
122
124
  }
123
125
  }