dsh-web-search-plugin 0.6.1 → 0.8.0

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/deepseek.js CHANGED
@@ -4,11 +4,11 @@
4
4
  * and returns structured `web_search_tool_result` blocks; absence of those
5
5
  * blocks is an error rather than a prose-scraping fallback.
6
6
  *
7
- * This plugin implements DeepSeek as an internal backend so its configuration
8
- * can sit beside the REST engines. The bundle patch disables
9
- * the in-box `web-search-deepseek` host plugin so this bundle owns the selected
10
- * search provider and its configuration. The seam-facing id registered by this
11
- * plugin is `dsh-web-search`; `deepseek-official` is an internal backend choice.
7
+ * This backend is a compatibility path, not the default: the card's DeepSeek
8
+ * server-side search pins the in-box `deepseek-official` provider, and follow
9
+ * mode routes DeepSeek requests there too. It still serves profiles pinned to
10
+ * `dsh-web-search` with `provider: "deepseek-official"` from releases before
11
+ * `0.8.0`; the next card save moves them onto the in-box pin.
12
12
  *
13
13
  * Authentication follows the official provider: a search started from a
14
14
  * DeepSeek-account session authenticates with the account token
@@ -43,8 +43,8 @@ const DEFAULT_MAX_USES = 5;
43
43
 
44
44
  /**
45
45
  * Build a `url → cited_text` map from `text` blocks' `citations[]` (the snippet
46
- * source for Anthropic `web_search_result` items, which carry url/title but no
47
- * inline excerpt).
46
+ * source for a `web_search_result` item that carries no excerpt of its own;
47
+ * the excerpt then lives in a separate `text` block's citation).
48
48
  */
49
49
  function citationSnippets(blocks) {
50
50
  const map = /* @__PURE__ */ new Map();
@@ -55,7 +55,10 @@ function citationSnippets(blocks) {
55
55
  return map;
56
56
  }
57
57
 
58
- /** Map an Anthropic Messages response to a normalized search result. */
58
+ /**
59
+ * Map an Anthropic Messages response to a normalized search result. A result
60
+ * item's own `snippet` wins; the citation excerpt for its `url` is the fallback.
61
+ */
59
62
  function mapAnthropicResponse(response, maxResults) {
60
63
  const blocks = response.content ?? [];
61
64
  const resultBlocks = blocks.filter((block) => block.type === "web_search_tool_result");
@@ -66,7 +69,8 @@ function mapAnthropicResponse(response, maxResults) {
66
69
  for (const block of resultBlocks) for (const item of block.content ?? []) {
67
70
  if (item.type !== "web_search_result" || typeof item.url !== "string" || item.url.length === 0 || seen.has(item.url)) continue;
68
71
  seen.add(item.url);
69
- const snippet = snippets.get(item.url);
72
+ const own = typeof item.snippet === "string" && item.snippet.length > 0 ? item.snippet : void 0;
73
+ const snippet = own ?? snippets.get(item.url);
70
74
  sources.push({
71
75
  url: item.url,
72
76
  ...typeof item.title === "string" && item.title.length > 0 ? { title: item.title } : {},
@@ -115,10 +119,13 @@ export class DeepSeekSearchProvider {
115
119
  throwIfSearchAborted(signal);
116
120
  const endpoint = `${options.baseURL.replace(/\/+$/u, "")}/messages`;
117
121
  // An account-authorized search spends account quota and must not need a
118
- // stored API key; every other search resolves `DEEPSEEK_API_KEY`.
122
+ // stored API key; every other search resolves `DEEPSEEK_API_KEY`. The
123
+ // request names the route that serves this search (`llmProvider`), so the
124
+ // decision matches the readiness check instead of guessing the session's
125
+ // latest route.
119
126
  let accountToken;
120
127
  try {
121
- accountToken = await abortable(Promise.resolve().then(() => options.resolveAccountToken?.(endpoint)), signal);
128
+ accountToken = await abortable(Promise.resolve().then(() => options.resolveAccountToken?.(endpoint, request.llmProvider)), signal);
122
129
  } catch (error) {
123
130
  if (signal?.aborted === true || isAbortError(error)) throw searchAborted(signal, error);
124
131
  throw new WebError(`DeepSeek account token resolution failed: ${String(error)}`, "WEB_PROVIDER_ERROR", { cause: error });
@@ -203,8 +210,10 @@ export function resolveDeepseekOptions(ctx, config) {
203
210
  literal: config.deepseekApiKey,
204
211
  envName: config.deepseekApiKeyEnv ?? DEEPSEEK_DEFAULT_API_KEY_ENV
205
212
  }),
206
- // Only a DeepSeek-account session may spend account quota; every other
207
- // session falls back to the API key resolved above.
213
+ // Only a DeepSeek-account route may spend account quota; every other
214
+ // route falls back to the API key resolved above. The search passes the
215
+ // route that serves it; older hosts name no route, so the session's latest
216
+ // one stands in.
208
217
  resolveAccountToken: async (endpoint, llmProvider = ctx.get("agents")?.currentInitiator()?.session.requestContext()?.provider) => {
209
218
  if (llmProvider !== ACCOUNT_PROVIDER) return void 0;
210
219
  return await ctx.get("deepseekAccount")?.resolveToken(endpoint);
package/lib/index.js CHANGED
@@ -1,15 +1,17 @@
1
1
  /**
2
2
  * Web-search provider plugin for the DeepSeek Harness web capability seam
3
3
  * (`ctx.web`). Registers a single `WebSearchProvider` under the stable id
4
- * `dsh-web-search` and dispatches each search to one of nine backends
5
- * according to the `provider` setting — so switching backends does
6
- * not require a `web.searchProvider` patch change.
4
+ * `dsh-web-search` and dispatches each search to one of the eight third-party
5
+ * backends according to the `provider` setting — so switching backends does
6
+ * not require a `web.searchProvider` patch change. DeepSeek server-side search
7
+ * and follow mode are served by the in-box `deepseek-official` provider; the
8
+ * `deepseek-official` branch here only keeps profiles pinned to this id from
9
+ * releases before `0.8.0` working until their next card save.
7
10
  *
8
11
  * Tavily supports `keyless` (free, rate-limited) and `keyed` modes. Brave
9
12
  * always needs a subscription token (`BRAVE_API_KEY` by default). DeepSeek
10
13
  * uses the Anthropic-compatible Messages API native `web_search_20250305`
11
- * tool and authenticates with an account token or `DEEPSEEK_API_KEY` (the
12
- * in-box `web-search-deepseek` host plugin is disabled by the bundle patch).
14
+ * tool and authenticates with an account token or `DEEPSEEK_API_KEY`.
13
15
  *
14
16
  * DeepSeek records a secret-free model request as a session event before
15
17
  * dispatch; the REST backends do not write custom session events.
@@ -68,8 +70,14 @@ const Config = z.object({
68
70
  scavioCountry: z.string().volatile(),
69
71
  scavioSearchLang: z.string().volatile(),
70
72
  // Legacy fields remain accepted for existing profiles.
71
- /** Active backend: `deepseek-official` (default), `tavily`, `brave`, `serper`, `serpapi`, `exa`, `searxng`, `scavio`, or `firecrawl`. */
72
- provider: z.string().default("deepseek-official").volatile(),
73
+ /**
74
+ * Active backend. `deepseek-search-api` (default) leaves search to the
75
+ * in-box `web-deepseek-api` provider, matching the Harness default;
76
+ * `deepseek-official` is the DeepSeek server-side (Messages) backend, and `tavily`,
77
+ * `brave`, `serper`, `serpapi`, `exa`, `searxng`, `scavio`, `firecrawl`
78
+ * are served by this plugin.
79
+ */
80
+ provider: z.string().default("deepseek-search-api").volatile(),
73
81
  /** Tavily auth mode: `keyless` (default) or `keyed`. */
74
82
  mode: z.string().default("keyless").volatile(),
75
83
  /** Literal Tavily API key; prefer {@link apiKeyEnv}. */
@@ -155,6 +163,13 @@ const Config = z.object({
155
163
  */
156
164
  class PluginSearchProvider {
157
165
  id = SEARCH_PROVIDER_ID;
166
+ /** Display name a provider picker shows instead of the raw registration id. */
167
+ title = "网页搜索(本插件)";
168
+ /** What this provider covers, for pickers that render a description. */
169
+ description = {
170
+ en: "DeepSeek server-side search plus Tavily, Brave, Serper, SerpApi, Exa, SearXNG, Scavio and Firecrawl, configured on this plugin's web search page.",
171
+ zh: "支持 DeepSeek 服务端搜索与 Tavily、Brave、Serper、SerpApi、Exa、SearXNG、Scavio、Firecrawl,在本插件的网页搜索设置页配置。"
172
+ };
158
173
 
159
174
  constructor(resolveOptions, usage) {
160
175
  this.resolveOptions = resolveOptions;
@@ -323,6 +338,12 @@ function readSection(config) {
323
338
  deepseekApiKey: config.deepseekApiKey.get(),
324
339
  deepseekApiKeyEnv: config.deepseekApiKeyEnv.get(),
325
340
  deepseekBaseURL: config.deepseekBaseURL.get(),
341
+ // Prefixed fields win in `resolveSupplierConfig`; the unprefixed names
342
+ // below stay as the fallback older profiles wrote.
343
+ deepseekModel: config.deepseekModel.get(),
344
+ deepseekApiVersion: config.deepseekApiVersion.get(),
345
+ deepseekMaxTokens: config.deepseekMaxTokens.get(),
346
+ deepseekMaxUses: config.deepseekMaxUses.get(),
326
347
  model: config.model.get(),
327
348
  apiVersion: config.apiVersion.get(),
328
349
  maxTokens: config.maxTokens.get(),
package/lib/shared.js CHANGED
@@ -7,7 +7,7 @@ import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
7
7
  import { WebError } from "@deepseek-ai/dsh-web";
8
8
 
9
9
  /** Attribution header sent on every request. */
10
- export const USER_AGENT = "dsh-web-search-plugin/0.6.1";
10
+ export const USER_AGENT = "dsh-web-search-plugin/0.8.0";
11
11
  /** Shared cap: Tavily `max_results` and Brave `count` both accept 1..20. */
12
12
  export const MAX_RESULTS_CAP = 20;
13
13
 
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
- "title": "Web search",
4
- "description": "Search engines and web retrieval in one page: DeepSeek Search API, Messages, eight third-party engines, local HTTP and optional DeepSeek Fetch API.",
3
+ "title": "Web search & fetch",
4
+ "description": "Web search providers and web fetch in one page: follow the conversation model (default), DeepSeek Search API, DeepSeek server-side search, eight third-party engines, local fetch and optional DeepSeek Fetch API.",
5
5
  "detail": "assets/detail/en.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
- "title": "网页搜索",
4
- "description": "在一个页面独立配置搜索引擎与网页抓取:DeepSeek Search API、Messages、8 个第三方引擎、本地 HTTP 和可选 DeepSeek Fetch API。",
3
+ "title": "网页搜索与获取",
4
+ "description": "在一个页面独立配置网页搜索提供方与网页获取:跟随会话模型(默认)、DeepSeek Search API、DeepSeek 服务端搜索、8 个第三方引擎、本机直接获取和可选 DeepSeek Fetch API。",
5
5
  "detail": "assets/detail/zh.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-web-search-plugin",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "Web search and retrieval settings for DeepSeek Harness: DeepSeek Search API, Messages, eight search backends, local HTTP and DeepSeek Fetch API",
5
5
  "icon": "./assets/icon.svg",
6
6
  "keywords": [
@@ -63,12 +63,12 @@
63
63
  "undici": "^6.21.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@deepseek-ai/dsh-web": "^0.2.0-rc.2 || ^0.2.1-rc.2 || ^0.2.2-alpha.3",
67
- "@deepseek-ai/dsh-credentials": "^0.2.0-rc.2 || ^0.2.1-rc.2 || ^0.2.2-alpha.3",
68
- "@deepseek-ai/dsh-settings": "^0.2.0-rc.2 || ^0.2.1-rc.2 || ^0.2.2-alpha.3",
69
- "@deepseek-ai/dsh-launch-environment": "^0.2.0-rc.2 || ^0.2.1-rc.2 || ^0.2.2-alpha.3",
70
- "@deepseek-ai/schemastery": "~3.18.4 || ~3.18.6-alpha.2 || ~3.19.0",
71
- "@deepseek-ai/cordis": "~4.0.4 || ~4.0.6-alpha.2 || ~4.1.0"
66
+ "@deepseek-ai/dsh-web": "^0.2.2-rc.5",
67
+ "@deepseek-ai/dsh-credentials": "^0.2.2-rc.5",
68
+ "@deepseek-ai/dsh-settings": "^0.2.2-rc.5",
69
+ "@deepseek-ai/dsh-launch-environment": "^0.2.2-rc.5",
70
+ "@deepseek-ai/schemastery": "~3.19.0",
71
+ "@deepseek-ai/cordis": "~4.1.0"
72
72
  },
73
73
  "license": "MIT",
74
74
  "repository": {