dsh-web-search-plugin 0.6.0 → 0.7.1

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/cordis.patch.yml CHANGED
@@ -5,27 +5,40 @@
5
5
  #
6
6
  # `searchProvider` and the upstream `fetchProvider` are restated in full
7
7
  # because a Cordis patch replaces the targeted row's whole `config`. The
8
- # profile's own cordis.patch.yml still wins if it later overrides `web`. The
9
- # seam id is `dsh-web-search`; the backend (DeepSeek / Tavily / Brave) is the
10
- # plugin's own `provider` setting.
11
- # The settings page can independently override searchProvider to
12
- # deepseek-search-api and fetchProvider to deepseek-fetch-api on rc.2 Hosts.
13
- # Keep these defaults for existing profiles; API choices are opt-in.
8
+ # profile's own cordis.patch.yml still wins if it later overrides `web`.
9
+ #
10
+ # Defaults mirror the Harness `0.2.2` defaults: the in-box `deepseek-search-api`
11
+ # provider searches, and `http` fetches from this device. Selecting any engine
12
+ # this bundle serves (legacy Messages, Tavily, Brave, Serper, …) switches
13
+ # `searchProvider` back to `dsh-web-search`, this bundle's own seam id, and
14
+ # leaves the backend to the plugin's `provider` setting.
15
+ #
16
+ # `deepseek-search-api` needs the in-box `web-deepseek-api` layer, which the
17
+ # Harness ships from `0.2.1-rc.2` on. A profile without it must pick another
18
+ # engine on the settings page.
14
19
  - id: web
15
20
  name: '@deepseek-ai/dsh-web'
16
21
  config:
17
- searchProvider: dsh-web-search
22
+ searchProvider: deepseek-search-api
18
23
  fetchProvider: http
19
24
 
20
- # This bundle selects its own `dsh-web-search` seam provider and configures
21
- # DeepSeek through that provider. Disable the in-box DeepSeek host plugin so
22
- # the profile has one active DeepSeek configuration surface. Its provider id
23
- # is `deepseek-official`, distinct from this bundle's `dsh-web-search` id.
25
+ # Disable the in-box legacy DeepSeek search plugin so the profile has one
26
+ # active legacy Messages configuration surface: this bundle's `dsh-web-search`
27
+ # provider with its `deepseek-official` backend. That provider id is distinct
28
+ # from the in-box `deepseek-official` one.
24
29
  - id: web-search-deepseek
25
30
  disabled: true
26
31
 
32
+ # Disable the in-box "Web search & fetch" settings page. Its two seams (`web`
33
+ # and `web-deepseek-api`) are exactly what this bundle's own page edits, and
34
+ # showing both leaves the user with two entry points for one configuration.
35
+ # This row is inserted by `@deepseek-ai/dsh-web-app`; the bundle layer is
36
+ # applied after it, so the disable lands on an existing row.
37
+ - id: ui-settings-web-search
38
+ disabled: true
39
+
27
40
  - insert:
28
41
  - id: dsh-web-search-plugin
29
42
  name: dsh-web-search-plugin
30
43
  config:
31
- provider: deepseek-official
44
+ provider: deepseek-search-api
package/lib/client.js CHANGED
@@ -33,26 +33,74 @@ window.__ModuleLoader__.load({
33
33
  const API_SEARCH = "deepseek-search-api";
34
34
  const API_FETCH = "deepseek-fetch-api";
35
35
  const API_FIELDS = { webApiKey: "apiKey", webApiKeyEnv: "apiKeyEnv", webApiBaseURL: "baseURL", webApiCount: "count" };
36
+ /**
37
+ * The same card fields against the per-capability `web-deepseek-api`
38
+ * schema that replaced `apiKey` / `apiKeyEnv` / `baseURL` in DSH
39
+ * `0.2.2-rc.2`. One card field can feed several keys: the card keeps a
40
+ * single credential and endpoint for Search and Fetch, so a write fans
41
+ * out to both capabilities and a read takes the first present key.
42
+ */
43
+ const API_FIELDS_SPLIT = {
44
+ webApiKeyEnv: ["searchApiKeyEnv", "fetchApiKeyEnv"],
45
+ webApiBaseURL: ["searchBaseURL", "fetchBaseURL"],
46
+ webApiCount: ["count"],
47
+ webApiSearchBilling: ["searchBilling"],
48
+ webApiFetchBilling: ["fetchBilling"]
49
+ };
50
+ /**
51
+ * Which `web-deepseek-api` schema the Host serves.
52
+ * `searchBilling` carries a schema default, so a ready section always
53
+ * answers it; the pre-rc.2 schema has no such field.
54
+ * @param snapshot - the `web-deepseek-api` config-form snapshot.
55
+ * @returns true for the per-capability schema.
56
+ */
57
+ function splitApiSchema(snapshot) {
58
+ const value = snapshot?.value;
59
+ return value !== void 0 && value !== null && Object.hasOwn(value, "searchBilling");
60
+ }
36
61
  /** Combine public ConfigForms; save parameters before switching providers.
37
62
  * Each namespace has its own revision. Refusal retains the page's draft;
38
63
  * previously accepted namespaces are not rolled back over concurrent edits.
39
64
  */
40
65
  function combinedScope(forms) {
41
66
  const plugin = forms.get(NS), web = forms.get("web"), api = forms.get(API_NS);
42
- const merge = (p, w, a) => {
67
+ /** Namespace keys one card field addresses on the schema in force. */
68
+ const apiKeys = (field, split) => split
69
+ ? API_FIELDS_SPLIT[field] ?? []
70
+ : API_FIELDS[field] === void 0 ? [] : [API_FIELDS[field]];
71
+ const apiFieldNames = (split) => Object.keys(split ? API_FIELDS_SPLIT : API_FIELDS);
72
+ const merge = (p, w, a, split) => {
43
73
  const value = { ...p, fetchProvider: w?.fetchProvider ?? "http" };
44
74
  if (w?.searchProvider === API_SEARCH) value.provider = API_SEARCH;
45
- for (const [field, key] of Object.entries(API_FIELDS)) if (a && Object.hasOwn(a, key)) value[field] = a[key];
75
+ for (const field of apiFieldNames(split)) {
76
+ for (const key of apiKeys(field, split)) {
77
+ if (a === void 0 || !Object.hasOwn(a, key)) continue;
78
+ value[field] = a[key];
79
+ break;
80
+ }
81
+ }
46
82
  return value;
47
83
  };
84
+ const mergeUser = (p, w, a, split) => {
85
+ const user = { ...p.user };
86
+ for (const field of apiFieldNames(split)) {
87
+ const key = apiKeys(field, split).find((candidate) => Object.hasOwn(a.user ?? {}, candidate));
88
+ if (key !== void 0) user[field] = a.user[key];
89
+ }
90
+ if (Object.hasOwn(w.user ?? {}, "fetchProvider")) user.fetchProvider = w.user.fetchProvider;
91
+ if (w.user?.searchProvider === API_SEARCH) user.provider = API_SEARCH;
92
+ return user;
93
+ };
48
94
  return {
49
95
  getSnapshot() {
50
96
  const p = plugin.getSnapshot(), w = web.getSnapshot(), a = api.getSnapshot();
51
- return { ...p, value: merge(p.value, w.value, a.value), base: merge(p.base, w.base, a.base),
52
- user: { ...p.user, ...Object.fromEntries(Object.entries(API_FIELDS).filter(([, key]) => Object.hasOwn(a.user ?? {}, key)).map(([field, key]) => [field, a.user[key]])), ...(Object.hasOwn(w.user ?? {}, "fetchProvider") ? { fetchProvider: w.user.fetchProvider } : {}), ...(w.user?.searchProvider === API_SEARCH ? { provider: API_SEARCH } : {}) },
97
+ const split = splitApiSchema(a);
98
+ return { ...p, value: merge(p.value, w.value, a.value, split), base: merge(p.base, w.base, a.base, split),
99
+ user: mergeUser(p, w, a, split),
53
100
  revision: { plugin: p.revision, api: a.revision, web: w.revision },
54
101
  apiAvailable: a.status === "ready" && w.status === "ready",
55
102
  apiWritable: a.writable && w.writable,
103
+ apiSplit: split,
56
104
  selectionAvailable: w.status === "ready", selectionWritable: w.writable,
57
105
  searchProvider: w.value?.searchProvider };
58
106
  },
@@ -61,11 +109,14 @@ window.__ModuleLoader__.load({
61
109
  return () => stops.forEach(stop => stop());
62
110
  },
63
111
  async mutate(ops, revisions) {
112
+ const split = splitApiSchema(api.getSnapshot());
64
113
  const groups = { plugin: [], api: [], web: [] };
65
114
  for (const op of ops) {
66
115
  const field = op.path[0];
67
- if (API_FIELDS[field]) groups.api.push({ ...op, path: [API_FIELDS[field]] });
68
- else if (field === "fetchProvider") groups.web.push(op);
116
+ const keys = apiKeys(field, split);
117
+ if (keys.length > 0) {
118
+ for (const key of keys) groups.api.push({ ...op, path: [key] });
119
+ } else if (field === "fetchProvider") groups.web.push(op);
69
120
  else if (field === "provider") {
70
121
  if (op.op === "set" && op.value === API_SEARCH) groups.web.push({ op: "set", path: ["searchProvider"], value: API_SEARCH });
71
122
  else {
@@ -84,10 +135,11 @@ window.__ModuleLoader__.load({
84
135
  return true;
85
136
  },
86
137
  canWrite(plan) {
138
+ const split = splitApiSchema(api.getSnapshot());
87
139
  return plan.every(item => {
88
140
  const field = item.field;
89
141
  if ([API_SEARCH, API_FETCH].includes(item.op?.value) && (api.getSnapshot().status !== "ready" || !api.getSnapshot().writable)) return false;
90
- const scope = API_FIELDS[field] ? api : field === "fetchProvider" ? web : plugin;
142
+ const scope = apiKeys(field, split).length > 0 ? api : field === "fetchProvider" ? web : plugin;
91
143
  return scope.getSnapshot().status === "ready" && scope.getSnapshot().writable
92
144
  && (field !== "provider" || (web.getSnapshot().status === "ready" && web.getSnapshot().writable));
93
145
  });
@@ -225,29 +277,40 @@ window.__ModuleLoader__.load({
225
277
 
226
278
  /** Locale bundles for the card. */
227
279
  const en = {
228
- nav: "Web search",
229
- provider: "Search engine",
280
+ nav: "Web search & fetch",
281
+ provider: "Web search provider",
230
282
  providerTavily: "Tavily",
231
283
  providerBrave: "Brave Search",
232
- providerDeepseek: "DeepSeek Messages search (default)",
284
+ providerDeepseek: "DeepSeek (legacy)",
233
285
  providerApi: "DeepSeek Search API",
234
- searchHeading: "Search engines",
235
- fetchHeading: "Web retrieval",
236
- fetchProvider: "Retrieval method",
237
- fetchHttp: "Local HTTP (default)",
286
+ searchHeading: "Web search",
287
+ fetchHeading: "Web fetch",
288
+ fetchProvider: "Web fetch provider",
289
+ fetchHttp: "Local fetch",
238
290
  fetchApi: "DeepSeek Fetch API",
239
291
  fetchOther: "Current custom provider: ",
240
- fetchHttpHint: "Retrieve pages from this device. No DeepSeek Fetch API fee; returned content still uses conversation tokens.",
241
- apiHint: "Direct API requests, without an auxiliary model call. Search and Fetch are billed per successful request; reading results still uses conversation tokens.",
242
- messagesHint: "Uses an auxiliary Messages model request in addition to retrieval. Choose Search API to avoid that model call.",
292
+ fetchHttpHint: "Free, and reaches your intranet and this machine. Cannot render pages that need JavaScript or a sign-in, and cannot read PDFs. Returned content still uses conversation tokens.",
293
+ apiHint: "Direct API requests, without an auxiliary model call. Reading results still uses conversation tokens.",
294
+ providerDeepseekHint: "Slower: every search spends extra model tokens. Needs a DeepSeek account or API key.",
295
+ providerApiHint: "Costs money, paid by the account or API key chosen under Billing.",
296
+ providerFetchApiHint: "Cannot reach your intranet or this machine. Costs money, paid by the account or API key chosen under Billing.",
297
+ providerSearxngHint: "DuckDuckGo has no official search API. Point SearXNG at an instance that includes DuckDuckGo (most public ones do), or self-host one.",
298
+ advanced: "Advanced settings",
243
299
  apiBase: "DeepSeek Search / Fetch API base URL",
244
300
  apiCount: "Results per search",
245
- apiCountHint: "1–50 results per query; the tool's own result limit still applies. This does not limit requests or spending.",
246
- apiBilling: "API guide and billing ↗",
301
+ apiCountHint: "Results returned per search, 1–50, default 10.",
302
+ apiBillingMode: "Billing",
303
+ apiBillingAuto: "Automatic",
304
+ apiBillingAccount: "Signed-in DeepSeek account",
305
+ apiBillingApiKey: "DeepSeek API key",
306
+ apiBillingHint: "Follows the conversation's DeepSeek account or API key; with other models, uses the API key first, then the signed-in account.",
307
+ apiBillingAccountHint: "Requires signing in to DeepSeek.",
308
+ apiBillingApiKeyHint: "Uses the API key from the Models page; set one first.",
309
+ apiBilling: "Search & Fetch guide ↗",
247
310
  credentialConflict: "Two different keys target the same credential reference. Use one key or separate references.",
248
311
  invalidApiCount: "Enter a whole number from 1 to 50, or leave blank for the default.",
249
- apiBaseHint: "Include the API prefix, e.g. https://api.deepseek.com/v1/tools. Shared by Search and Fetch; separate from the Messages endpoint.",
250
- apiRefHint: "Credential shared by DeepSeek Search API and Fetch API. Account sessions may use an authorized account token.",
312
+ apiBaseHint: "Include the API prefix, e.g. https://api.deepseek.com/v1/tools. Written to both Search and Fetch; separate from the Messages endpoint.",
313
+ apiRefHint: "Credential used when Billing is API key. Written to both Search and Fetch.",
251
314
  apiShared: "Uses the DeepSeek API configuration in the search section above.",
252
315
  apiUnavailable: "The Host must serve web and web-deepseek-api to enable the new APIs (DSH 0.2.1-rc.2 or compatible).",
253
316
  searchInactive: "Another search provider is selected in the Host. Choose an engine here to use this page's configuration.",
@@ -292,20 +355,17 @@ window.__ModuleLoader__.load({
292
355
  proxy: "Proxy",
293
356
  proxyPlaceholder: "Leave blank to inherit the DSH proxy settings.",
294
357
  deepseekApiKeyEnv: "Credential reference",
295
- deepseekApiKeyEnvHint: "Name of the credential/env var resolved for DeepSeek search.",
296
- deepseekBaseURL: "Endpoint",
297
- deepseekBaseURLHint: "Leave blank to use the DeepSeek Anthropic-compatible API default.",
358
+ deepseekApiKeyEnvHint: "Models on the DeepSeek account route use the signed-in account; every other request uses this API key (DEEPSEEK_API_KEY), shared with the Models page by default.",
359
+ deepseekBaseURL: "Base URL",
360
+ deepseekBaseURLHint: "Include the API prefix; leave blank to use the official endpoint. The program appends /messages.",
298
361
  model: "Model",
299
362
  modelHint: "Anthropic-format model name for the search request.",
300
363
  maxTokens: "Max tokens",
301
364
  maxTokensHint: "Upper bound on generated tokens for the search request.",
302
- maxUses: "Max uses",
303
- maxUsesHint: "Maximum web_search server-tool uses per request.",
304
- expand: "Show settings",
305
- collapse: "Hide settings",
365
+ maxUses: "Max searches per request",
366
+ maxUsesHint: "Upper bound on server-side searches each Messages request may run; a positive integer, default 5.",
306
367
  getKey: "Get API key",
307
368
  ddgDisabled: "DuckDuckGo — use via SearXNG",
308
- ddgHint: "DuckDuckGo has no official search API. Pick SearXNG and point it at an instance that includes DuckDuckGo (most public ones do), or self-host one.",
309
369
  save: "Save",
310
370
  saving: "Saving…",
311
371
  discard: "Discard",
@@ -344,32 +404,43 @@ window.__ModuleLoader__.load({
344
404
  };
345
405
  /** Simplified Chinese copy. */
346
406
  const zh = {
347
- nav: "网页搜索",
348
- provider: "搜索引擎",
407
+ nav: "网页搜索与获取",
408
+ provider: "网页搜索提供方",
349
409
  providerTavily: "Tavily",
350
410
  providerBrave: "Brave Search",
351
- providerDeepseek: "DeepSeek Messages 搜索(默认)",
411
+ providerDeepseek: "DeepSeek(旧版)",
352
412
  providerApi: "DeepSeek Search API",
353
- searchHeading: "搜索引擎",
354
- fetchHeading: "网页抓取",
355
- fetchProvider: "抓取方式",
356
- fetchHttp: "本地 HTTP(默认)",
413
+ searchHeading: "网页搜索",
414
+ fetchHeading: "网页获取",
415
+ fetchProvider: "网页获取提供方",
416
+ fetchHttp: "本机直接获取",
357
417
  fetchApi: "DeepSeek Fetch API",
358
418
  fetchOther: "当前自定义提供方:",
359
- fetchHttpHint: "由当前设备直接读取网页,无 DeepSeek Fetch 接口费;返回内容仍占用主会话 token。",
360
- apiHint: "直接请求 API,不调用辅助模型。Search 与 Fetch 按成功请求计费,主模型阅读结果仍消耗 token。",
361
- messagesHint: "搜索会额外发起 Messages 模型请求;选择 Search API 可省去该辅助模型调用。",
419
+ fetchHttpHint: "免费,可访问内网和本机。不支持需要 JavaScript 或登录的页面,也不支持 PDF。返回内容仍占用主会话 token。",
420
+ apiHint: "直接请求 API,不调用辅助模型。主模型阅读结果仍消耗 token。",
421
+ providerDeepseekHint: "速度较慢,每次搜索都会额外消耗模型 token。需要 DeepSeek 账号或 API Key。",
422
+ providerApiHint: "会产生费用,由「计费方式」选定的账号或 API Key 支付。",
423
+ providerFetchApiHint: "无法访问内网和本机。会产生费用,由「计费方式」选定的账号或 API Key 支付。",
424
+ providerSearxngHint: "DuckDuckGo 没有官方搜索 API。请把 SearXNG 指向一个聚合了 DuckDuckGo 的实例(多数公共实例都有),或自建一个。",
425
+ advanced: "高级设置",
362
426
  apiBase: "DeepSeek Search / Fetch API 基础地址",
363
427
  apiCount: "每次搜索结果数",
364
- apiCountHint: "每个查询返回 1–50 条,仍受工具自身结果上限约束;这不是请求次数或费用上限。",
365
- apiBilling: "API 使用与计费说明 ↗",
428
+ apiCountHint: "每次搜索返回的结果条数,1–50,默认 10。",
429
+ apiBillingMode: "计费方式",
430
+ apiBillingAuto: "自动",
431
+ apiBillingAccount: "已登录的 DeepSeek 账号",
432
+ apiBillingApiKey: "DeepSeek API Key",
433
+ apiBillingHint: "跟随当前会话的 DeepSeek 账号或 API Key;会话用其他模型时,优先用 API Key,没有则用已登录账号。",
434
+ apiBillingAccountHint: "需要先登录 DeepSeek 账号。",
435
+ apiBillingApiKeyHint: "使用「模型」页配置的 API Key,需要先配置。",
436
+ apiBilling: "网页搜索与获取指南 ↗",
366
437
  credentialConflict: "两个不同密钥使用了同一凭据引用。请使用同一密钥,或分别设置引用名。",
367
438
  invalidApiCount: "请输入 1–50 的整数;留空表示使用默认值。",
368
- apiBaseHint: "填写含 API 前缀的地址,如 https://api.deepseek.com/v1/tools。Search 与 Fetch 共用,与 Messages 地址分别保存。",
369
- apiRefHint: "DeepSeek Search API 与 Fetch API 共用的凭据;账号会话可使用经授权的账号令牌。",
370
- apiShared: "使用上方搜索引擎区域中的 DeepSeek API 配置。",
439
+ apiBaseHint: "填写含 API 前缀的地址,如 https://api.deepseek.com/v1/tools。同时写入 Search 与 Fetch,与 Messages 地址分别保存。",
440
+ apiRefHint: "「计费方式」为 API Key 时使用的凭据;同时写入 Search 与 Fetch。",
441
+ apiShared: "使用上方网页搜索区域中的 DeepSeek API 配置。",
371
442
  apiUnavailable: "新版 API 需要 Host 提供 web 与 web-deepseek-api 配置(DSH 0.2.1-rc.2 或兼容版本)。",
372
- searchInactive: "Host 当前选择了其他搜索提供方;请在此选择引擎以启用本页面的配置。",
443
+ searchInactive: "Host 当前选择了其他搜索提供方;请在此选择搜索引擎以启用本页面的配置。",
373
444
  partialFailed: "保存失败,部分设置可能已保存。草稿已保留,请核对后重试。",
374
445
  mode: "认证模式",
375
446
  modeKeyless: "Keyless(免费、限流)",
@@ -411,20 +482,17 @@ window.__ModuleLoader__.load({
411
482
  proxy: "代理",
412
483
  proxyPlaceholder: "留空继承 DSH 全局代理设置",
413
484
  deepseekApiKeyEnv: "凭据引用名",
414
- deepseekApiKeyEnvHint: "DeepSeek 搜索解析的凭据/环境变量名。",
415
- deepseekBaseURL: "接口地址",
416
- deepseekBaseURLHint: "留空则使用 DeepSeek Anthropic 兼容 API 默认地址。",
485
+ deepseekApiKeyEnvHint: "账号模型发起的请求使用已登录账号;其他请求使用此 API Key(DEEPSEEK_API_KEY),默认与「模型」页共用。",
486
+ deepseekBaseURL: "Base URL",
487
+ deepseekBaseURLHint: "填写含 API 前缀的地址;留空时使用官方地址;程序追加 /messages。",
417
488
  model: "模型",
418
489
  modelHint: "搜索请求使用的 Anthropic 格式模型名。",
419
490
  maxTokens: "最大 token",
420
491
  maxTokensHint: "搜索请求生成 token 的上限。",
421
- maxUses: "最大调用次数",
422
- maxUsesHint: "每次请求 web_search 服务端工具的最大调用次数。",
423
- expand: "展开设置",
424
- collapse: "收起设置",
492
+ maxUses: "单次请求最多搜索次数",
493
+ maxUsesHint: "每次 Messages 请求允许的服务端搜索次数上限,须为正整数,默认 5。",
425
494
  getKey: "获取 API key",
426
495
  ddgDisabled: "DuckDuckGo — 请经 SearXNG 使用",
427
- ddgHint: "DuckDuckGo 没有官方搜索 API。请选择 SearXNG,并填入一个聚合了 DuckDuckGo 的实例地址(多数公共实例都有),或自建一个。",
428
496
  save: "保存",
429
497
  saving: "保存中…",
430
498
  discard: "放弃修改",
@@ -534,6 +602,8 @@ window.__ModuleLoader__.load({
534
602
  credentialField("webApiKeyEnv"),
535
603
  textField("webApiBaseURL"),
536
604
  numberField("webApiCount", { min: 1, max: 50, strict: true }),
605
+ choiceField("webApiSearchBilling"),
606
+ choiceField("webApiFetchBilling"),
537
607
  choiceField("provider"),
538
608
  choiceField("tavilyMode"),
539
609
  numberField("maxResults", { min: 1, max: MAX_RESULTS_CAP }),
@@ -609,6 +679,7 @@ window.__ModuleLoader__.load({
609
679
  failed: this.failed,
610
680
  apiAvailable: snapshot.apiAvailable,
611
681
  apiWritable: snapshot.apiWritable,
682
+ apiSplit: snapshot.apiSplit === true,
612
683
  selectionAvailable: snapshot.selectionAvailable,
613
684
  selectionWritable: snapshot.selectionWritable,
614
685
  searchInactive: snapshot.searchProvider && !["dsh-web-search", API_SEARCH].includes(snapshot.searchProvider),
@@ -892,6 +963,8 @@ window.__ModuleLoader__.load({
892
963
  webApiKeyEnv: this.form.field("webApiKeyEnv"),
893
964
  webApiBaseURL: this.form.field("webApiBaseURL"),
894
965
  webApiCount: this.form.field("webApiCount"),
966
+ webApiSearchBilling: this.form.field("webApiSearchBilling"),
967
+ webApiFetchBilling: this.form.field("webApiFetchBilling"),
895
968
  webApiKeyConfigured: this.form.apiCredential.configured,
896
969
  webApiKeyWritable: this.form.apiCredential.writable,
897
970
  provider: this.form.field("provider"),
@@ -1238,15 +1311,21 @@ window.__ModuleLoader__.load({
1238
1311
  const tavily = provider === "tavily";
1239
1312
  const restMeta = builtinRest(provider);
1240
1313
  const keyed = state.tavilyMode.text === "keyed";
1314
+ /** One line under the selector describing the provider in force. */
1315
+ const providerHint = provider === API_SEARCH ? t("providerApiHint")
1316
+ : provider === "deepseek-official" ? t("providerDeepseekHint")
1317
+ : provider === "searxng" ? t("providerSearxngHint")
1318
+ : "";
1241
1319
  const keyHint = state.apiKeyConfigured ? t("apiKeyHint") : t("apiKeyHint") + " " + t("apiKeyUnavailableHint");
1242
1320
  const toastText = toastCopy(t, state.toastKey);
1243
1321
  const toastTone = ["failed", "invalid", "credentialConflict"].includes(state.toastKey) ? "error" : state.toastKey === "nothing" ? "info" : "success";
1322
+ const isApiField = (field) => Object.hasOwn(API_FIELDS, field) || Object.hasOwn(API_FIELDS_SPLIT, field);
1244
1323
  const row = (field, label, hint, children) => fieldRow(label, hint, children, {
1245
1324
  t,
1246
1325
  overridden: state[field]?.overridden === true,
1247
1326
  invalid: state[field]?.invalid === true,
1248
1327
  errorKey: field.endsWith("ApiKeyEnv") || field === "apiKeyEnv" ? "invalidCredentialRef" : field === "webApiCount" ? "invalidApiCount" : "invalidNumber",
1249
- disabled: disabled || (API_FIELDS[field] ? !state.apiWritable : field === "fetchProvider" || field === "provider" ? !state.selectionWritable : false),
1328
+ disabled: disabled || (isApiField(field) ? !state.apiWritable : field === "fetchProvider" || field === "provider" ? !state.selectionWritable : false),
1250
1329
  onReset: () => actions.resetField(field)
1251
1330
  });
1252
1331
  const maxResultsWrite = numberField("maxResults", { min: 1, max: MAX_RESULTS_CAP }).parse(String(state.maxResults.text ?? "").trim());
@@ -1262,16 +1341,44 @@ window.__ModuleLoader__.load({
1262
1341
  return react.createElement("option", { value: n, key: n }, n);
1263
1342
  })
1264
1343
  }));
1344
+ /**
1345
+ * The `web-deepseek-api` rows the card owns. `0.2.2-rc.2` replaced
1346
+ * the literal key and shared endpoint with a per-capability split
1347
+ * plus a billing choice, so the literal-key row disappears there and
1348
+ * the credential reference takes its place.
1349
+ */
1265
1350
  const apiConfig = () => react.createElement("div", { className: "dshws_form" },
1266
- pair(
1351
+ state.apiSplit ? null : pair(
1267
1352
  fieldRow(t("apiKey"), t("apiKeyHint"), secretInput({ id: "ws-api-key", value: state.webApiKey.text, disabled: disabled || !state.apiWritable || !state.webApiKeyWritable, placeholder: state.webApiKeyConfigured ? t("apiKeySet") : t("apiKeyUnset"), onChange: e => actions.edit("webApiKey", e.target.value) })),
1268
1353
  row("webApiKeyEnv", t("apiKeyEnv"), t("apiRefHint"), textInput({ id: "ws-api-keyref", value: state.webApiKeyEnv.text, disabled: disabled || !state.apiWritable, onChange: e => actions.edit("webApiKeyEnv", e.target.value) }))
1269
1354
  ),
1355
+ state.apiSplit ? row("webApiKeyEnv", t("apiKeyEnv"), t("apiRefHint"), textInput({ id: "ws-api-keyref", value: state.webApiKeyEnv.text, disabled: disabled || !state.apiWritable, onChange: e => actions.edit("webApiKeyEnv", e.target.value) })) : null,
1270
1356
  row("webApiBaseURL", t("apiBase"), t("apiBaseHint"), textInput({ id: "ws-api-base", value: state.webApiBaseURL.text, disabled: disabled || !state.apiWritable, onChange: e => actions.edit("webApiBaseURL", e.target.value) })),
1271
1357
  keyConsoleLink(t, "deepseek-official"),
1272
1358
  react.createElement("p", { className: "dshws_field_hint" }, t("apiHint")),
1273
1359
  react.createElement("a", { href: "https://api-docs.deepseek.com/zh-cn/guides/search/", target: "_blank", rel: "noopener noreferrer", className: "dshws_field_hint", style: { padding: "6px 0 10px" } }, t("apiBilling"))
1274
1360
  );
1361
+ /**
1362
+ * One capability's billing choice. Present only where the Host
1363
+ * serves the split schema; the pre-rc.2 schema resolves credentials
1364
+ * on its own, so the row would address a field that does not exist.
1365
+ * @param field - `webApiSearchBilling` or `webApiFetchBilling`.
1366
+ */
1367
+ /** Hint under a billing select: the official page explains each choice inline. */
1368
+ const billingHint = (value) => value === "account" ? t("apiBillingAccountHint")
1369
+ : value === "api-key" ? t("apiBillingApiKeyHint")
1370
+ : t("apiBillingHint");
1371
+ const billingRow = (field) => row(field, t("apiBillingMode"), billingHint(state[field]?.text || "auto"), selectInput({
1372
+ id: "ws-" + field,
1373
+ value: state[field]?.text || "auto",
1374
+ disabled: disabled || !state.apiWritable,
1375
+ onChange: (e) => actions.edit(field, e.target.value),
1376
+ children: [
1377
+ react.createElement("option", { value: "auto", key: "auto" }, t("apiBillingAuto")),
1378
+ react.createElement("option", { value: "account", key: "account" }, t("apiBillingAccount")),
1379
+ react.createElement("option", { value: "api-key", key: "api-key" }, t("apiBillingApiKey"))
1380
+ ]
1381
+ }));
1275
1382
  return react.createElement("div", { className: "dshws_form" },
1276
1383
  react.createElement("div", { className: "dshws_card_header" },
1277
1384
  react.createElement("div", { className: "dshws_card_headText" },
@@ -1290,7 +1397,7 @@ window.__ModuleLoader__.load({
1290
1397
  ...BUILTIN_REST_PROVIDERS.map((entry) => react.createElement("option", { value: entry.id, key: entry.id }, entry.name)),
1291
1398
  react.createElement("option", { value: "__ddg__", key: "ddg", disabled: true }, t("ddgDisabled"))
1292
1399
  ] }),
1293
- react.createElement("p", { className: "dshws_field_hint", style: { padding: "4px 0 0" } }, t("ddgHint"))),
1400
+ providerHint === "" ? null : react.createElement("p", { className: "dshws_field_hint", style: { padding: "4px 0 0" } }, providerHint)),
1294
1401
  tavily ? row("tavilyMode", t("mode"), null, selectInput({ id: "ws-mode", value: state.tavilyMode.text, disabled, onChange: (e) => actions.edit("tavilyMode", e.target.value), children: [
1295
1402
  react.createElement("option", { value: "keyless", key: "keyless" }, t("modeKeyless")),
1296
1403
  react.createElement("option", { value: "keyed", key: "keyed" }, t("modeKeyed"))
@@ -1298,7 +1405,7 @@ window.__ModuleLoader__.load({
1298
1405
  ),
1299
1406
  apiSearch ? apiConfig() : null,
1300
1407
  apiSearch ? row("webApiCount", t("apiCount"), t("apiCountHint"), numberInput({ id: "ws-api-count", value: state.webApiCount.text, min: 1, max: 50, disabled: disabled || !state.apiWritable, onChange: e => actions.edit("webApiCount", e.target.value) })) : null,
1301
- deepseek ? react.createElement("p", { className: "dshws_field_hint" }, t("messagesHint")) : null,
1408
+ apiSearch && state.apiSplit ? billingRow("webApiSearchBilling") : null,
1302
1409
  react.createElement(QuotaCard, { t, provider, keyed }),
1303
1410
  keyConsoleLink(t, provider, restMeta, keyed),
1304
1411
  deepseek ? pair(
@@ -1316,10 +1423,11 @@ window.__ModuleLoader__.load({
1316
1423
  deepseek ? row("deepseekBaseURL", t("deepseekBaseURL"), t("deepseekBaseURLHint"), textInput({ id: "ws-deepseek-base", value: state.deepseekBaseURL.text, disabled, onChange: (e) => actions.edit("deepseekBaseURL", e.target.value) })) : null,
1317
1424
  brave ? row("braveBaseURL", t("braveBaseURL"), t("braveBaseURLHint"), textInput({ id: "ws-brave-base", value: state.braveBaseURL.text, disabled, onChange: (e) => actions.edit("braveBaseURL", e.target.value) })) : null,
1318
1425
  tavily ? row("tavilyBaseURL", t("baseURL"), t("baseURLHint"), textInput({ id: "ws-tavily-base", value: state.tavilyBaseURL.text, disabled, onChange: (e) => actions.edit("tavilyBaseURL", e.target.value) })) : null,
1319
- deepseek ? row("deepseekModel", t("model"), t("modelHint"), textInput({ id: "ws-model", value: state.deepseekModel.text, disabled, onChange: (e) => actions.edit("deepseekModel", e.target.value) })) : null,
1320
- deepseek ? pair(
1321
- row("deepseekMaxTokens", t("maxTokens"), t("maxTokensHint"), numberInput({ id: "ws-maxtokens", value: state.deepseekMaxTokens.text, disabled, onChange: (e) => actions.edit("deepseekMaxTokens", e.target.value), className: state.deepseekMaxTokens.invalid ? "dshws_input_invalid" : void 0 })),
1322
- row("deepseekMaxUses", t("maxUses"), t("maxUsesHint"), numberInput({ id: "ws-maxuses", value: state.deepseekMaxUses.text, disabled, onChange: (e) => actions.edit("deepseekMaxUses", e.target.value), className: state.deepseekMaxUses.invalid ? "dshws_input_invalid" : void 0 }))
1426
+ deepseek ? row("deepseekMaxUses", t("maxUses"), t("maxUsesHint"), numberInput({ id: "ws-maxuses", value: state.deepseekMaxUses.text, disabled, onChange: (e) => actions.edit("deepseekMaxUses", e.target.value), className: state.deepseekMaxUses.invalid ? "dshws_input_invalid" : void 0 })) : null,
1427
+ deepseek ? react.createElement("details", { className: "dshws_form" },
1428
+ react.createElement("summary", { className: "dshws_field_hint", style: { cursor: "pointer", padding: "8px 0" } }, t("advanced")),
1429
+ row("deepseekModel", t("model"), t("modelHint"), textInput({ id: "ws-model", value: state.deepseekModel.text, disabled, onChange: (e) => actions.edit("deepseekModel", e.target.value) })),
1430
+ row("deepseekMaxTokens", t("maxTokens"), t("maxTokensHint"), numberInput({ id: "ws-maxtokens", value: state.deepseekMaxTokens.text, disabled, onChange: (e) => actions.edit("deepseekMaxTokens", e.target.value), className: state.deepseekMaxTokens.invalid ? "dshws_input_invalid" : void 0 }))
1323
1431
  ) : null,
1324
1432
  tavily ? pair(
1325
1433
  row("tavilySearchDepth", t("searchDepth"), null, selectInput({ id: "ws-depth", value: state.tavilySearchDepth.text, disabled, onChange: (e) => actions.edit("tavilySearchDepth", e.target.value), children: [
@@ -1370,7 +1478,9 @@ window.__ModuleLoader__.load({
1370
1478
  !["http", API_FETCH].includes(fetchProvider) ? react.createElement("option", { value: fetchProvider, key: fetchProvider }, t("fetchOther") + fetchProvider) : null
1371
1479
  ] })),
1372
1480
  fetchProvider === "http" ? react.createElement("p", { className: "dshws_field_hint" }, t("fetchHttpHint")) : null,
1481
+ apiFetch ? react.createElement("p", { className: "dshws_field_hint" }, t("providerFetchApiHint")) : null,
1373
1482
  apiFetch ? (apiSearch ? react.createElement("p", { className: "dshws_field_hint" }, t("apiShared")) : apiConfig()) : null,
1483
+ apiFetch && state.apiSplit ? billingRow("webApiFetchBilling") : null,
1374
1484
  react.createElement("div", { style: { borderTop: "1px solid var(--dsw-alias-border-l2)", justifyContent: "flex-end", alignItems: "center", gap: "8px", padding: "12px 0 4px", display: "flex" } },
1375
1485
  react.createElement("button", {
1376
1486
  type: "button",
package/lib/deepseek.js CHANGED
@@ -22,7 +22,7 @@
22
22
  import { resolveSupplierConfig } from "./config.js";
23
23
  import { WebError } from "@deepseek-ai/dsh-web";
24
24
  import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
25
- import { MAX_RESULTS_CAP, USER_AGENT, abortable, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
25
+ import { apiKeyReady, MAX_RESULTS_CAP, USER_AGENT, abortable, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
26
26
 
27
27
  /** Default endpoint: DeepSeek's Anthropic-compatible API (`/messages` appended). */
28
28
  export const DEEPSEEK_DEFAULT_BASE_URL = "https://api.deepseek.com/anthropic/v1";
@@ -95,6 +95,21 @@ export class DeepSeekSearchProvider {
95
95
  && Number.isInteger(options.maxUses) && options.maxUses > 0;
96
96
  }
97
97
 
98
+ /** Use the pending model route, rather than the previous session request. */
99
+ async ready(llmProvider) {
100
+ const options = this.resolveOptions();
101
+ if (llmProvider === ACCOUNT_PROVIDER && options.resolveAccountToken !== void 0) {
102
+ try {
103
+ const endpoint = `${options.baseURL.replace(/\/+$/u, "")}/messages`;
104
+ const token = await options.resolveAccountToken(endpoint, llmProvider);
105
+ if ((token?.length ?? 0) > 0) return true;
106
+ } catch {
107
+ return false;
108
+ }
109
+ }
110
+ return await apiKeyReady(options);
111
+ }
112
+
98
113
  async search(request, signal) {
99
114
  const options = this.resolveOptions();
100
115
  throwIfSearchAborted(signal);
@@ -190,8 +205,8 @@ export function resolveDeepseekOptions(ctx, config) {
190
205
  }),
191
206
  // Only a DeepSeek-account session may spend account quota; every other
192
207
  // session falls back to the API key resolved above.
193
- resolveAccountToken: async (endpoint) => {
194
- if (ctx.get("agents")?.currentInitiator()?.session.requestContext()?.provider !== ACCOUNT_PROVIDER) return void 0;
208
+ resolveAccountToken: async (endpoint, llmProvider = ctx.get("agents")?.currentInitiator()?.session.requestContext()?.provider) => {
209
+ if (llmProvider !== ACCOUNT_PROVIDER) return void 0;
195
210
  return await ctx.get("deepseekAccount")?.resolveToken(endpoint);
196
211
  },
197
212
  recordRequest: (request) => {
package/lib/index.js CHANGED
@@ -68,8 +68,14 @@ const Config = z.object({
68
68
  scavioCountry: z.string().volatile(),
69
69
  scavioSearchLang: z.string().volatile(),
70
70
  // 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(),
71
+ /**
72
+ * Active backend. `deepseek-search-api` (default) leaves search to the
73
+ * in-box `web-deepseek-api` provider, matching the Harness default;
74
+ * `deepseek-official` is the legacy Messages backend, and `tavily`,
75
+ * `brave`, `serper`, `serpapi`, `exa`, `searxng`, `scavio`, `firecrawl`
76
+ * are served by this plugin.
77
+ */
78
+ provider: z.string().default("deepseek-search-api").volatile(),
73
79
  /** Tavily auth mode: `keyless` (default) or `keyed`. */
74
80
  mode: z.string().default("keyless").volatile(),
75
81
  /** Literal Tavily API key; prefer {@link apiKeyEnv}. */
@@ -151,10 +157,17 @@ const Config = z.object({
151
157
  /**
152
158
  * One seam-facing provider whose `id` stays `dsh-web-search`. The active
153
159
  * backend is read from the live settings section on every `available` /
154
- * `search` call, so a card save takes effect on the next search.
160
+ * `ready` / `search` call, so a card save takes effect on the next search.
155
161
  */
156
162
  class PluginSearchProvider {
157
163
  id = SEARCH_PROVIDER_ID;
164
+ /** Display name a provider picker shows instead of the raw registration id. */
165
+ title = "网页搜索(本插件)";
166
+ /** What this provider covers, for pickers that render a description. */
167
+ description = {
168
+ en: "DeepSeek (legacy) plus Tavily, Brave, Serper, SerpApi, Exa, SearXNG, Scavio and Firecrawl, configured on this plugin's web search page.",
169
+ zh: "支持 DeepSeek(旧版)与 Tavily、Brave、Serper、SerpApi、Exa、SearXNG、Scavio、Firecrawl,在本插件的网页搜索设置页配置。"
170
+ };
158
171
 
159
172
  constructor(resolveOptions, usage) {
160
173
  this.resolveOptions = resolveOptions;
@@ -172,6 +185,10 @@ class PluginSearchProvider {
172
185
  return this.backend().available();
173
186
  }
174
187
 
188
+ async ready(llmProvider) {
189
+ return await this.backend().ready(llmProvider);
190
+ }
191
+
175
192
  async search(request, signal) {
176
193
  return this.backend().search(request, signal);
177
194
  }
package/lib/rest.js CHANGED
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { WebError } from "@deepseek-ai/dsh-web";
19
19
  import { ProxyAgent } from "undici";
20
- import { MAX_RESULTS_CAP, USER_AGENT, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
20
+ import { apiKeyReady, MAX_RESULTS_CAP, USER_AGENT, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
21
21
 
22
22
  /** Acceptable auth templates (superset includes `query` for SerpApi). */
23
23
  const AUTH_TYPES = new Set(["bearer", "header", "none", "query"]);
@@ -163,6 +163,12 @@ export class RestSearchProvider {
163
163
  return (options.apiKey?.length ?? 0) > 0 || options.resolveApiKey !== void 0;
164
164
  }
165
165
 
166
+ /** New Hosts gate tools on credential presence; keyless engines stay ready. */
167
+ async ready() {
168
+ const options = this.resolveOptions();
169
+ return (options.auth?.type ?? "none") === "none" || await apiKeyReady(options);
170
+ }
171
+
166
172
  async search(request, signal) {
167
173
  const options = this.resolveOptions();
168
174
  throwIfSearchAborted(signal);
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.0";
10
+ export const USER_AGENT = "dsh-web-search-plugin/0.7.1";
11
11
  /** Shared cap: Tavily `max_results` and Brave `count` both accept 1..20. */
12
12
  export const MAX_RESULTS_CAP = 20;
13
13
 
@@ -25,6 +25,15 @@ export function resolveSecret(ctx, config) {
25
25
  return {
26
26
  ...literal === void 0 ? {} : { apiKey: literal },
27
27
  apiKeyEnv,
28
+ // Inspect presence only; resolving a stored secret belongs to search().
29
+ apiKeyReady: async () => {
30
+ if (literal !== void 0) return true;
31
+ const credentials = ctx.get("credentials");
32
+ if (credentials !== void 0 && (await credentials.describe(apiKeyEnv)).configured) return true;
33
+ const ambient = launchEnvironmentOf(ctx).get(apiKeyEnv);
34
+ if (ambient !== void 0 && ambient.value.length > 0) return true;
35
+ return (process.env[apiKeyEnv]?.length ?? 0) > 0;
36
+ },
28
37
  resolveApiKey: async () => {
29
38
  const credentials = ctx.get("credentials");
30
39
  if (credentials !== void 0) {
@@ -39,6 +48,19 @@ export function resolveSecret(ctx, config) {
39
48
  };
40
49
  }
41
50
 
51
+ /** Check configured key presence without retaining a secret or contacting an endpoint. */
52
+ export async function apiKeyReady(options) {
53
+ try {
54
+ if ((options.apiKey?.length ?? 0) > 0) return true;
55
+ if (options.apiKeyReady !== void 0) return await options.apiKeyReady();
56
+ // Directly constructed providers may supply only a local credential resolver.
57
+ return ((await options.resolveApiKey?.())?.length ?? 0) > 0;
58
+ } catch {
59
+ // Execution also fails when the credential plane cannot be read.
60
+ return false;
61
+ }
62
+ }
63
+
42
64
  /** Race a same-process asynchronous preflight against caller cancellation. */
43
65
  export function abortable(operation, signal) {
44
66
  if (signal === void 0) return operation;