dsh-web-search-plugin 0.5.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@
4
4
 
5
5
  ## [未发布]
6
6
 
7
+ ## [0.5.1] - 2026-10-10
8
+
9
+ ### 新增
10
+
11
+ - 自定义网页搜索图标:采用与官方图标协调的蓝绿渐变和地球放大镜造型,通过包元数据提供给插件列表、详情及包含的组件。
12
+
13
+ ### 变更
14
+
15
+ - DeepSeek 官方搜索默认模型更新为 `deepseek-flash`,同步 Host 配置、后端回退、设置卡和中英文 README;保留用户显式配置的模型名。
16
+ - 供应商专用配置统一增加前缀:Tavily 使用 `tavily*`,DeepSeek 搜索选项使用 `deepseek*`,Brave 使用 `brave*`;Scavio 的地区与语言选项独立为 `scavioCountry`、`scavioSearchLang`。通用的 `provider`、`maxResults` 保持不变。
17
+ - 保留旧字段兼容读取;新字段优先,包括显式空字符串和 `false`。设置卡保存新名称,恢复默认时处理当前 Profile 的旧别名,并保留另一引擎依赖的旧共享地区或语言值。
18
+ - 设置卡隐藏 API 协议版本输入框,保留 `deepseekApiVersion` 高级配置与旧 `apiVersion` 兼容。
19
+
20
+ ### 文档
21
+
22
+ - README 提供英文主版与独立中文版,补充插件优势、设置卡配置步骤和配置范围;优先建议在卡片中选择 DeepSeek(官方),需要恢复 Harness 内置插件时再关闭整个组合包。
23
+
7
24
  ## [0.5.0] - 2026-10-09
8
25
 
9
26
  ### 新增
@@ -12,7 +29,7 @@
12
29
  - DeepSeek 后端支持账号令牌认证:会话 provider 为 `deepseek-account` 时通过 `deepseekAccount.resolveToken()` 获取令牌并以 `x-dsh-auth-token` 发送,未授权时回落到 `DEEPSEEK_API_KEY`。
13
30
  - 有会话发起者时,DeepSeek 搜索在派发前记录脱敏请求到会话事件 `web/deepseek-search-llm-request`,与官方 provider 行为一致。
14
31
  - 插件列表页与详情页的标题、描述随界面语言切换:`locale/en.json` 与 `locale/zh.json`,经 `"./locale/*.json"` 导出(与官方 bundle 同一机制)。卡片内文案由 `lib/client.js` 的 `zh` / `en` 字典提供。
15
- - README 面向开源使用者整理:删除仅适用于本机的排查笔记与旧个人包迁移章节,修正与实现脱节的仓库布局与安装说明。
32
+ - README 整理:修正与实现脱节的仓库布局与安装说明。
16
33
 
17
34
  ### 移除
18
35
 
package/README.md CHANGED
@@ -1,207 +1,322 @@
1
1
  # dsh-web-search-plugin
2
2
 
3
- 面向 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) web 能力接缝(`ctx.web`)的统一网页搜索插件,内置 **DeepSeek(官方,默认)/ Tavily / [Brave Search](https://brave.com/search/api/) / Serper / SerpApi / Exa / SearXNG / Scavio / Firecrawl 九个后端**。本包只向接缝注册 **一个** `WebSearchProvider`,稳定 id 为 `dsh-web-search`。在 **设置 → 网页搜索** 里切换引擎即可,不必再改 `web.searchProvider`。
4
-
5
- - **DeepSeek(官方,默认)** — 走 DeepSeek 的 Anthropic 兼容 Messages API(原生 `web_search_20250305` 工具,支持账号令牌或 `DEEPSEEK_API_KEY`),一次搜索消耗一个模型轮次。
6
- - **Tavily** — `keyless`(免费、限流、无需账号)或 `keyed`(`TAVILY_API_KEY`,Bearer token)。keyed 会在设置卡显示额度进度条。
7
- - **Brave Search** — `GET https://api.search.brave.com/res/v1/web/search`,请求头 `X-Subscription-Token`(凭据名 `BRAVE_API_KEY`)。一次搜索就是一次 HTTP 请求,不走模型轮次;设置卡按响应头展示 Capacity / 月配额。
8
- - **Serper** — Google 结果(`POST /search`,头 `X-API-KEY`,凭据名 `SERPER_API_KEY`)。
9
- - **SerpApi** — `GET /search.json`,key 走 query(`api_key=`),凭据名 `SERPAPI_API_KEY`。
10
- - **Exa** — 语义/神经搜索(`POST /search`,Bearer,凭据名 `EXA_API_KEY`),请求 `contents.highlights` 作为结果摘要。
11
- - **SearXNG** — 自建/协议免 key 的元搜索(`GET /search?format=json`),可填自托管实例地址;实例须启用 JSON 输出。
12
- - **Scavio** — Google SERP(`POST /api/v2/google`,Bearer,凭据名 `SCAVIO_API_KEY`),响应与 SerpApi 同构。
13
- - **Firecrawl** — 网页搜索(`POST /v2/search`,Bearer,凭据名 `FIRECRAWL_API_KEY`),`sources: ["web"]`;当前请求没有启用整页抓取。
14
- - **DuckDuckGo** — 无官方搜索 API,不提供独立后端;下拉中以禁用项提示:选 SearXNG 并指向聚合了 DuckDuckGo 的实例即可。
15
- - **官方 key 跳转** — 需要 key 的内置 provider 在设置卡带「获取 API key ↗」一键跳官方控制台;免 key 的(SearXNG / Tavily keyless)不渲染。
16
- - **会话事件** — 有会话发起者时,DeepSeek 在派发前记录脱敏模型请求到 `web/deepseek-search-llm-request`;REST 后端不追加自定义事件。
17
-
18
- ## 特性
19
-
20
- - 与官方 `@deepseek-ai/dsh-web-search-deepseek` 相同的提供方约定:`inject: ['web']` + 全`volatile()` 配置字段 + `ctx.web.registerSearchProvider`。
21
- - 自定义配置卡片位于 **设置 → 网页搜索**。
22
- - **默认引擎为 DeepSeek(官方)**:新装 / 未显式改动时,搜索直接走 `deepseek-official`,不再依赖 keyless 的 Tavily。
23
- - **9 个后端**中,8 个纯 REST 后端由**静态元数据表 + 通用后端**驱动;只有 DeepSeek 官方走模型轮次。新增内置 REST 引擎还需同步配置字段和客户端引擎列表。
24
- - Tavily keyless 无需密钥即可用;Brave 需要订阅 token(若本机已有 `BRAVE_API_KEY` 凭据,可直接复用)。
25
- - Tavily keyed / Brave 在设置卡展示额度进度条(DeepSeek 官方与 Tavily keyless / 其余 REST 后端不展示)。
26
- - 各引擎结果都规范化为接缝的 `WebSearchResult`(可选 `content` + `sources[]`),按 URL 去重。
27
- - 配置由当前 Profile 的插件配置保存,全部字段声明为 `volatile()`:改引擎或端点后无需重启插件即可生效。
28
- - 插件列表页与详情页的标题、描述随界面语言切换(`locale/*.json`);卡片内文案自带中英字典。
29
- - 错误映射为 `WEB_PROVIDER_ERROR` / `WEB_ABORTED` / `WEB_PROVIDER_CREDENTIAL_MISSING`。
30
-
31
- ## 运行要求
32
-
33
- - DeepSeek Harness `0.2.0-rc.2` 或兼容的 `0.2.x` 版本
34
- - Node.js `^22.19.0` 或 `>=24.0.0`
35
- - pnpm,用于通过 `dsh plugin` 把插件装进 profile
36
-
37
- ## 安装
38
-
39
- 本包是 **bundle**:`dsh.bundle.patch` + `cordis.patch.yml` 会插入 Host 行、把 `web.searchProvider` 设为 `dsh-web-search`,并禁用内置 `web-search-deepseek` Host 插件,使此 profile 的 DeepSeek 搜索由本插件统一配置。本插件注册到接缝的 id 是 `dsh-web-search`;`deepseek-official` 是内部引擎选项,和内置插件注册的 id 不同。没有 bundle 声明时,`dsh plugin add` 只写入依赖,插件不会挂载。
40
-
41
- ### 从 npm 安装
3
+ English | [中文](./README.zh.md)
4
+
5
+ A web search plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) that gives your agent more search options through Harness's existing `web_search` tool. Choose from **nine providers** and manage engines, API keys, and search options in **Settings → Web search**.
6
+
7
+ ## Why use this plugin?
8
+
9
+ - **Avoid an extra DeepSeek model call for search.** The eight third-party backends call search APIs directly instead of DeepSeek's official model-backed search endpoint. This avoids the additional DeepSeek model token usage for that search request. (Your conversation and the model's processing of search results still use tokens, and search providers may charge their own fees or credits.)
10
+ - **Configure everything in a settings card.** Switch engines, enter keys, and adjust result limits in **Settings → Web search**, then save. Changes take effect on the next search without restarting the plugin or editing YAML.
11
+ - **Choose the search service that fits your needs.** Use Google results through Serper, semantic search through Exa, or a self-hosted SearXNG instance. Tavily's keyless mode lets you try search without an account or API key.
12
+ - **Return to built-in search with one switch.** Turn off the entire `dsh-web-search-plugin` bundle in the sidebar's **Plugins** page to remove its search overrides and restore Harness's built-in DeepSeek search under the standard profile configuration. See [Disable or uninstall](#disable-or-uninstall).
13
+
14
+ **The default engine is still DeepSeek (official).** To avoid the extra official search model call, select a third-party engine in the settings card after installation and save your changes. Selecting DeepSeek (official) uses the official search API and may incur model invocation charges.
15
+
16
+ ## Supported providers
17
+
18
+ - **DeepSeek (official, default)** — Uses DeepSeek's Anthropic-compatible Messages API with the native search tool type `web_search_20250305`. Supports account tokens or `DEEPSEEK_API_KEY`. Each search sends a model request and may incur model invocation charges.
19
+ - **Tavily** — Supports `keyless` access (free, rate-limited, no account required) or `keyed` access (`TAVILY_API_KEY`, Bearer token). The settings card shows a quota bar in keyed mode.
20
+ - **Brave Search** — Calls `GET https://api.search.brave.com/res/v1/web/search` with the `X-Subscription-Token` header (credential name: `BRAVE_API_KEY`). Each search is one HTTP request and does not consume a model turn. The settings card displays Capacity and monthly quota from response headers.
21
+ - **Serper** — Google results via `POST /search`, using the `X-API-KEY` header (credential name: `SERPER_API_KEY`).
22
+ - **SerpApi** — Calls `GET /search.json` with the key in the query string (`api_key=`; credential name: `SERPAPI_API_KEY`).
23
+ - **Exa** — Semantic/neural search via `POST /search` with Bearer authentication (credential name: `EXA_API_KEY`). Requests `contents.highlights` for result summaries.
24
+ - **SearXNG** — Metasearch with no API key required by the protocol. Calls `GET /search?format=json` and supports a self-hosted instance URL. The instance must enable JSON output.
25
+ - **Scavio** — Google SERP via `POST /api/v2/google` with Bearer authentication (credential name: `SCAVIO_API_KEY`). Uses the same response structure as SerpApi.
26
+ - **Firecrawl** — Web search via `POST /v2/search` with Bearer authentication (credential name: `FIRECRAWL_API_KEY`) and `sources: ["web"]`. Full-page scraping is not enabled in the current request.
27
+
28
+ For DuckDuckGo results, choose a SearXNG instance that aggregates DuckDuckGo. DuckDuckGo appears only as a disabled hint in the engine selector.
29
+
30
+ ## Requirements
31
+
32
+ - DeepSeek Harness `0.2.0-rc.2` or a compatible `0.2.x` release
33
+ - Node.js `^22.19.0` or `>=24.0.0`
34
+ - pnpm, used by `dsh plugin` to install the plugin into a profile
35
+
36
+ ## Installation
37
+
38
+ ### Install from npm
42
39
 
43
40
  ```powershell
44
41
  dsh plugin --profile web add dsh-web-search-plugin
45
42
  ```
46
43
 
47
- > 从源码仓库本地安装(含 Windows 跨盘注意事项)见 [开发 → 本地安装与验证](#本地安装与验证)。
44
+ After installation, configure the plugin in the Harness Web UI:
45
+
46
+ 1. Open **Settings → Web search** and find the plugin's settings card. The sidebar's **Plugins** page controls whether the bundle is enabled; engine settings live in this card.
47
+ 2. Choose a search engine. For direct API search without an extra DeepSeek model call, select Tavily, Brave, Serper, SerpApi, Exa, SearXNG, Scavio, or Firecrawl.
48
+ 3. Enter the engine's API key if required. Engines that require a key show “Get API key ↗”, which opens the official dashboard. For Tavily without a key, choose `keyless`; for SearXNG, set an instance URL with JSON search enabled. These two keyless options do not show a key dashboard link. Existing credentials can be reused, such as `BRAVE_API_KEY` for Brave.
49
+ 4. Adjust the result limit and other options, then click **Save**. The next search uses the saved engine and settings.
50
+
51
+ > For installation from a local source checkout, including Windows cross-drive considerations, see [Development → Local installation and verification](#local-installation-and-verification).
48
52
 
49
- ## 配置
53
+ ## Configuration
50
54
 
51
- 设置卡编辑的是 `dsh-web-search-plugin` 命名空间。设置卡中的 API key 输入框把密钥写入凭据服务;若直接在插件配置中填写 `*ApiKey` 字段,则该字面量保存在插件配置中。建议使用设置卡或凭据引用名,避免在配置文件中保存密钥。
55
+ For normal use, configure the plugin in **Settings → Web search**. The card shows options for the selected engine and saves ordinary settings to the current profile's `dsh-web-search-plugin` configuration. The tables below describe the underlying configuration, including advanced fields hidden from the card; not every field is shown at once.
52
56
 
53
- | 键 | 默认值 | 含义 |
57
+ ### General settings
58
+
59
+ | Key | Default | Meaning and scope |
54
60
  |---|---|---|
55
- | `provider` | `deepseek-official` | `tavily`、`brave`、`deepseek-official`、`serper`、`serpapi`、`exa`、`searxng`、`scavio` 或 `firecrawl` |
56
- | `mode` | `keyless` | 仅 Tavily:`keyless` 或 `keyed` |
57
- | `apiKey` | — | Tavily API key 配置字面量;设置卡的 key 输入框写入凭据服务 |
58
- | `apiKeyEnv` | `TAVILY_API_KEY` | keyed Tavily 使用的凭据/环境变量名 |
59
- | `baseURL` | 空 | Tavily REST 基址;留空时依次使用 `TAVILY_BASE_URL` 和 `https://api.tavily.com`,再拼 `/search` |
60
- | `maxResults` | `8` | 插件返回的源数量上限,与调用方的 `request.maxResults` 取较小值。设置卡为 1–20 下拉;SearXNG 不支持请求级数量参数,只在收到结果后截取 |
61
- | `searchDepth` | `basic` | 仅 Tavily:`basic` 或 `advanced` |
62
- | `includeAnswer` | `true` | 仅 Tavily:请求生成摘要,写入结果 `content` |
63
- | `topic` | `general` | 仅 Tavily:`general` 或 `news` |
64
- | `deepseekApiKey` | — | DeepSeek API key 配置字面量;设置卡的 key 输入框写入凭据服务 |
65
- | `deepseekApiKeyEnv` | `DEEPSEEK_API_KEY` | DeepSeek 使用的凭据/环境变量名 |
66
- | `deepseekBaseURL` | 空 | DeepSeek Anthropic 兼容 Messages 基址;留空时依次使用 `DEEPSEEK_SEARCH_BASE_URL` 和 `https://api.deepseek.com/anthropic/v1`,再拼 `/messages` |
67
- | `model` | `deepseek-v4-flash` | Anthropic 格式模型名 |
68
- | `apiVersion` | `2023-06-01` | `anthropic-version` 请求头 |
69
- | `maxTokens` | `4096` | Messages 请求生成 token 上限 |
70
- | `maxUses` | `5` | 每次请求 `web_search` 工具的最大调用次数 |
71
- | `braveApiKey` | — | Brave 订阅 token 配置字面量;设置卡的 key 输入框写入凭据服务 |
72
- | `braveApiKeyEnv` | `BRAVE_API_KEY` | Brave 使用的凭据/环境变量名 |
73
- | `braveBaseURL` | `https://api.search.brave.com/res/v1/web/search` | Brave 网页搜索接口 |
74
- | `country` | — | Brave 的 `country`(ISO 两位码,如 `cn`);留空使用 Brave 默认 |
75
- | `searchLang` | — | Brave 的 `search_lang`(如 `zh-hans`);留空使用 Brave 默认 |
76
- | `freshness` | — | Brave 的 `freshness`:`pd` / `pw` / `pm` / `py` |
77
- | `proxy` | — | Brave 使用的 HTTP(S) 代理覆盖;留空继承 DSH 的全局 `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY` 策略 |
78
- | `serperApiKey` / `serperApiKeyEnv` / `serperBaseURL` | — / `SERPER_API_KEY` / `https://google.serper.dev` | Serper 的配置字面量 key / 凭据引用名 / REST 基址 |
79
- | `serpapiApiKey` / `serpapiApiKeyEnv` / `serpapiBaseURL` | — / `SERPAPI_API_KEY` / `https://serpapi.com` | SerpApi 的配置字面量 key / 凭据引用名 / REST 基址 |
80
- | `exaApiKey` / `exaApiKeyEnv` / `exaBaseURL` | — / `EXA_API_KEY` / `https://api.exa.ai` | Exa 的配置字面量 key / 凭据引用名 / REST 基址 |
81
- | `searxngBaseURL` | `https://searx.be` | SearXNG 实例基址;可改为自托管地址 |
82
- | `scavioApiKey` / `scavioApiKeyEnv` / `scavioBaseURL` | — / `SCAVIO_API_KEY` / `https://api.scavio.dev` | Scavio 的配置字面量 key / 凭据引用名 / REST 基址 |
83
- | `firecrawlApiKey` / `firecrawlApiKeyEnv` / `firecrawlBaseURL` | — / `FIRECRAWL_API_KEY` / `https://api.firecrawl.dev` | Firecrawl 的配置字面量 key / 凭据引用名 / REST 基址 |
84
-
85
- ## 未纳入的服务
86
-
87
- 以下服务**不内置**(在引擎下拉中不会出现,也不提供后端):
88
-
89
- | 服务 | 不做的原因 |
90
- |---|---|
91
- | **TinyFish** | 免费额度极小(每分钟 5 次);其 Search + Fetch 形态超出"纯 REST 搜索"边界,仅搜索部分价值低 |
92
- | **Google CSE** | 官方已对新用户关闭注册,并将于 2027-01-01 停用 |
93
- | **SERPJET** | 官网当前不可访问,暂不接入 |
94
- | **DuckDuckGo** | 无官方搜索 API(HTML/社区库抓取不符合元数据表"纯 REST"边界)。下拉中有禁用提示,指引经 SearXNG 使用 |
95
-
96
- 环境变量:启动时 `DSH_WEB_SEARCH_PROVIDER=dsh-web-search` 会选中本接缝 id。`baseURL` 留空时,Tavily 基址回退 `TAVILY_BASE_URL`;`deepseekBaseURL` 留空时回退 `DEEPSEEK_SEARCH_BASE_URL`。
97
-
98
- ## 额度
99
-
100
- - **Tavily keyless / DeepSeek 官方**:不展示额度条。前者是免费限流、没有账户配额;后者按次扣费、没有月度限额。
101
- - **Tavily keyed**:搜索时请求 `include_usage`,在内存中累加当前凭据的 credits。Host 定时调用 `GET /usage`,设置卡也可手动刷新;手动刷新之间至少间隔 10 秒,自动对账不受此限制。用 `account.current_plan` / `plan_limit` 做限额,用量取当前凭据的本地累计与远端的较大值;换 key 时清空旧账户用量并立即重新对账。旧 Tavily 额度不再持久化到磁盘。
102
- - **Brave**:没有 usage / 花费接口。控制台 **Capacity** 就是响应头里的每秒窗口(例如 50 次/秒)。月限额 `0` 表示不限请求次数,不是额度用完。计费 credits 只能看 [Brave API 控制台](https://api-dashboard.search.brave.com/)。
103
- - 浏览器只读 `GET /dsh-web-search/usage`(不直打上游)。进度条:剩余超过 20% 为绿色,不超过 20% 为黄色,不超过 10% 为红色。
104
-
105
- ## 卸载
106
-
107
- 若要改用 DSH 内置的 DeepSeek host 插件,先卸载本插件及其 bundle patch:
61
+ | `provider` | `deepseek-official` | Active engine: `deepseek-official`, `tavily`, `brave`, `serper`, `serpapi`, `exa`, `searxng`, `scavio`, or `firecrawl`. Each request uses only the selected engine, with no automatic failover to another engine on error. Unknown values fall back to official DeepSeek |
62
+ | `maxResults` | `8` | Maximum returned sources for all engines, from 1–20, also capped by the caller's `request.maxResults`. SearXNG and Scavio send no request-level count parameter; their results are truncated after retrieval and URL deduplication. The upstream response determines how many results are actually available |
108
63
 
109
- ```powershell
110
- dsh plugin --profile web remove dsh-web-search-plugin
111
- ```
64
+ ### Keys and credential references
65
+
66
+ **The card's “API Key” input differs from the literal configuration fields below.** When you enter and save a new key, the card writes it under the current engine's credential reference rather than storing the plaintext key in plugin configuration. It also sets the corresponding literal field to an empty string so an old configuration key cannot override the new credential. Leaving the input blank preserves the existing key; it does not delete it. Use Harness's credential management capabilities to delete a credential.
67
+
68
+ | Engine | Literal configuration field | Credential reference field | Default reference |
69
+ |---|---|---|---|
70
+ | DeepSeek (API key authentication) | `deepseekApiKey` | `deepseekApiKeyEnv` | `DEEPSEEK_API_KEY` |
71
+ | Tavily (`keyed` only) | `tavilyApiKey` | `tavilyApiKeyEnv` | `TAVILY_API_KEY` |
72
+ | Brave | `braveApiKey` | `braveApiKeyEnv` | `BRAVE_API_KEY` |
73
+ | Serper | `serperApiKey` | `serperApiKeyEnv` | `SERPER_API_KEY` |
74
+ | SerpApi | `serpapiApiKey` | `serpapiApiKeyEnv` | `SERPAPI_API_KEY` |
75
+ | Exa | `exaApiKey` | `exaApiKeyEnv` | `EXA_API_KEY` |
76
+ | Scavio | `scavioApiKey` | `scavioApiKeyEnv` | `SCAVIO_API_KEY` |
77
+ | Firecrawl | `firecrawlApiKey` | `firecrawlApiKeyEnv` | `FIRECRAWL_API_KEY` |
78
+
79
+ All literal fields default to an empty string. A manually configured nonempty literal key takes priority. Otherwise, the plugin resolves the reference through **the credentials service → the Harness launching environment → process environment variables**, in that order. `*ApiKeyEnv` holds a reference name, not the key itself; the card requires names matching `[A-Za-z_][A-Za-z0-9_]*`.
112
80
 
113
- 随后检查 profile 中实际生效的 `web.searchProvider`;若曾手工覆盖为 `dsh-web-search`,将该覆盖改回 `deepseek-official`。
81
+ Official DeepSeek account sessions (provider: `deepseek-account`) first try an account token authorized for the endpoint by the account service. If no token is obtained, search uses the API key path above. Tavily `keyless` and SearXNG search requests require no API key. Configuring a Tavily key does not automatically select `keyed`; choose that mode explicitly. The current SearXNG backend has no instance-token or custom authentication-header setting.
114
82
 
115
- ## 工作方式
83
+ Credential writes and profile configuration saves happen in separate steps. Failed saves retain the draft, but successfully written credentials are not automatically rolled back. Prefer the card for everyday key management to avoid storing plaintext literals in configuration files.
116
84
 
117
- - **DeepSeek** — `POST {deepseekBaseURL}/messages`,工具 `web_search_20250305`。会话运行在 DeepSeek 官方账号路由(provider 为 `deepseek-account`)且账号服务允许该端点时,用账号令牌发 `x-dsh-auth-token`;否则回落到 API key(`x-api-key` / `authorization: Bearer`,凭据名 `DEEPSEEK_API_KEY`)。有会话发起者时,在派发前把脱敏请求记录为会话事件 `web/deepseek-search-llm-request`。
118
- - **纯 REST 类(Tavily / Brave / Serper / SerpApi / Exa / SearXNG / Scavio / Firecrawl)** — 由静态元数据表(`lib/providers.js`)+ 通用后端(`lib/rest.js`)驱动。请求方法 / 路径 / 查询字段名 / 鉴权(bearer / header / none / query)/ 固定参数 / 响应形态由表中的行决定。
119
- - **Tavily** — `POST {baseURL}/search`。keyless 发送 `x-tavily-access-mode: keyless`;keyed 发送 `authorization: Bearer <key>`,并带 `include_usage` 回传 credits。
120
- - **Brave** — `GET {braveBaseURL}?q=&count=`,请求头 `x-subscription-token`。不向 session 追加自定义事件。
121
- - **其余六种 REST 引擎** — 按各自表的 `method` / `auth` / `params` 约定请求。
122
- - 非 2xx 映射为 `WEB_PROVIDER_ERROR`;调用方取消映射为 `WEB_ABORTED`。
85
+ ### Endpoints
123
86
 
124
- ## 仓库布局
87
+ The table lists the addresses used when no custom endpoint or environment override is provided. Normally, you do not need to enter an endpoint. Tavily and DeepSeek also support endpoint overrides through the launching environment.
125
88
 
89
+ | Key | Default address | Address rules |
90
+ |---|---|---|
91
+ | `deepseekBaseURL` | `https://api.deepseek.com/anthropic/v1` | DeepSeek Anthropic-compatible Messages base: nonempty configuration → `DEEPSEEK_SEARCH_BASE_URL` in the launching environment → default address; appends `/messages` |
92
+ | `tavilyBaseURL` | `https://api.tavily.com` | Tavily base: nonempty configuration → `TAVILY_BASE_URL` in the launching environment → default address; appends `/search` |
93
+ | `braveBaseURL` | `https://api.search.brave.com/res/v1/web/search` | Full web search endpoint; no path is appended |
94
+ | `serperBaseURL` | `https://google.serper.dev` | Appends `/search` |
95
+ | `serpapiBaseURL` | `https://serpapi.com` | Appends `/search.json` |
96
+ | `exaBaseURL` | `https://api.exa.ai` | Appends `/search` |
97
+ | `searxngBaseURL` | `https://searx.be` | Appends `/search?format=json` with the search query; the instance must allow JSON search. The default address is not guaranteed to work; a self-hosted instance can be used |
98
+ | `scavioBaseURL` | `https://api.scavio.dev` | Appends `/api/v2/google` |
99
+ | `firecrawlBaseURL` | `https://api.firecrawl.dev` | Appends `/v2/search` |
100
+
101
+ Changing an engine's address does not change its request method, authentication, or response parsing. Custom endpoints must implement the corresponding engine's protocol; replacing a URL alone cannot connect an arbitrary search API. Except for Brave, omit the automatically appended paths listed above when entering a base URL. Engines other than Tavily and DeepSeek fall back to their built-in address when the effective address setting is empty, with no additional dedicated environment variable fallback.
102
+
103
+ Clearing a text input or using “Restore default” in the card normally removes the current profile's override and uses the inherited or default value. This differs from manually writing an empty string into configuration. Endpoint fallbacks are evaluated against the effective configuration value.
104
+
105
+ ### Provider-specific options
106
+
107
+ <table>
108
+ <thead>
109
+ <tr><th>Provider</th><th>Key</th><th>Default</th><th>Meaning and scope</th></tr>
110
+ </thead>
111
+ <tbody>
112
+ <tr>
113
+ <td rowspan="4"><strong>DeepSeek (official)</strong></td>
114
+ <td><code>deepseekModel</code></td>
115
+ <td><code>deepseek-flash</code></td>
116
+ <td>Model used only for the DeepSeek search request; does not change the conversation's chat model. Must be supported by the target endpoint</td>
117
+ </tr>
118
+ <tr>
119
+ <td><code>deepseekApiVersion</code></td>
120
+ <td><code>2023-06-01</code></td>
121
+ <td>Value of the <code>anthropic-version</code> header. Hidden from the settings card and retained as advanced configuration; normally leave at the default</td>
122
+ </tr>
123
+ <tr>
124
+ <td><code>deepseekMaxTokens</code></td>
125
+ <td><code>4096</code></td>
126
+ <td>Maximum generated tokens for one DeepSeek Messages search request, a positive integer; not a conversation-wide token limit</td>
127
+ </tr>
128
+ <tr>
129
+ <td><code>deepseekMaxUses</code></td>
130
+ <td><code>5</code></td>
131
+ <td>Maximum native <code>web_search</code> tool uses within one DeepSeek Messages request, a positive integer; not an engine retry count or result count</td>
132
+ </tr>
133
+ <tr>
134
+ <td rowspan="4"><strong>Tavily</strong></td>
135
+ <td><code>tavilyMode</code></td>
136
+ <td><code>keyless</code></td>
137
+ <td>Tavily only: keyless access (<code>keyless</code>) or API key access (<code>keyed</code>); does not control authentication for other engines</td>
138
+ </tr>
139
+ <tr>
140
+ <td><code>tavilySearchDepth</code></td>
141
+ <td><code>basic</code></td>
142
+ <td>Tavily only: <code>basic</code> or <code>advanced</code>, sent as <code>search_depth</code></td>
143
+ </tr>
144
+ <tr>
145
+ <td><code>tavilyIncludeAnswer</code></td>
146
+ <td><code>true</code></td>
147
+ <td>Tavily only: requests <code>include_answer: true</code> when enabled. The current shared REST backend omits the parameter when disabled; if upstream still returns an answer, it can still become result <code>content</code>. This does not guarantee removal of all answer text</td>
148
+ </tr>
149
+ <tr>
150
+ <td><code>tavilyTopic</code></td>
151
+ <td><code>general</code></td>
152
+ <td>Tavily only: <code>general</code> or <code>news</code></td>
153
+ </tr>
154
+ <tr>
155
+ <td rowspan="4"><strong>Brave</strong></td>
156
+ <td><code>braveCountry</code></td>
157
+ <td>Empty string</td>
158
+ <td>Brave only: sent as <code>country</code> (two-letter country code, such as <code>cn</code>); omitted when the effective value is empty</td>
159
+ </tr>
160
+ <tr>
161
+ <td><code>braveSearchLang</code></td>
162
+ <td>Empty string</td>
163
+ <td>Brave only: sent as <code>search_lang</code> (such as <code>zh-hans</code>); omitted when the effective value is empty</td>
164
+ </tr>
165
+ <tr>
166
+ <td><code>braveFreshness</code></td>
167
+ <td>Empty string</td>
168
+ <td>Brave only: <code>pd</code> / <code>pw</code> / <code>pm</code> / <code>py</code> for the past day / week / month / year. Empty means no time filter</td>
169
+ </tr>
170
+ <tr>
171
+ <td><code>braveProxy</code></td>
172
+ <td>Empty string</td>
173
+ <td>Explicit HTTP(S) proxy override for Brave only. If empty, no separate proxy is set and Harness's global network policy applies. Other engines do not use this field</td>
174
+ </tr>
175
+ <tr>
176
+ <td rowspan="2"><strong>Scavio</strong></td>
177
+ <td><code>scavioCountry</code></td>
178
+ <td>Empty string</td>
179
+ <td>Scavio only: sent as <code>gl</code>, using a country/region code accepted by that service; omitted when the effective value is empty</td>
180
+ </tr>
181
+ <tr>
182
+ <td><code>scavioSearchLang</code></td>
183
+ <td>Empty string</td>
184
+ <td>Scavio only: sent as <code>hl</code>, using a language code accepted by that service; omitted when the effective value is empty. New settings are independent of Brave</td>
185
+ </tr>
186
+ </tbody>
187
+ </table>
188
+
189
+ The startup environment variable `DSH_WEB_SEARCH_PROVIDER=dsh-web-search` selects Harness's registered search provider ID, not this plugin's `provider` engine option. Installing the bundle normally selects the provider already, so this variable is not required.
190
+
191
+ ## Quotas
192
+
193
+ - **DeepSeek (official)**: No quota bar. Search still makes a model request, with usage subject to your account or API billing.
194
+ - **Tavily keyless**: No quota bar; access is free and rate-limited.
195
+ - **Tavily keyed**: Requests `include_usage` during searches and accumulates credits for the current credential in memory. The Host periodically calls `GET /usage`, and the settings card supports manual refresh. Manual refreshes must be at least 10 seconds apart; automatic reconciliation is not subject to this limit. The quota comes from `account.current_plan` / `plan_limit`; usage is the larger of the local total for the current credential and the remote value. Changing keys clears the previous account's usage and triggers immediate reconciliation. Tavily quota data is no longer persisted to disk.
196
+ - **Brave**: No usage/spending endpoint. Dashboard **Capacity** represents the per-second window from response headers (for example, 50 requests/second). A monthly limit of `0` means unlimited requests, not an exhausted quota. Billing credits are available only in the [Brave API dashboard](https://api-dashboard.search.brave.com/).
197
+ - The browser reads only `GET /dsh-web-search/usage` and does not call upstream services directly. Quota bars are green when more than 20% remains, yellow at 20% or less, and red at 10% or less.
198
+
199
+ ## Disable or uninstall
200
+
201
+ ### Switch to DeepSeek (official) first
202
+
203
+ If you only want to use official search again, select **DeepSeek (official)** in **Settings → Web search** and save. There is no need to disable or uninstall this plugin. The next search uses the official search API through this plugin and may still incur model invocation charges.
204
+
205
+ ### Disable and restore built-in search
206
+
207
+ Use the following steps when you want to stop using this plugin and restore Harness's original search plugin. Selecting this plugin's DeepSeek engine and restoring the original plugin are separate operations.
208
+
209
+ Open **Plugins** in the sidebar and turn off the **entire `dsh-web-search-plugin` bundle**. Under the standard Harness profile configuration, this removes the bundle's search-provider override and its override disabling the built-in DeepSeek plugin, restoring built-in search without uninstalling the package. You can turn the bundle back on later.
210
+
211
+ Use the bundle's main switch: disabling only an individual component inside the bundle leaves its other configuration overrides in place. Profiles with configuration hot reload apply the change immediately; otherwise, restart Harness.
212
+
213
+ If you manually set `web.searchProvider: dsh-web-search`, `DSH_WEB_SEARCH_PROVIDER=dsh-web-search`, or a separate override disabling the built-in DeepSeek plugin, also remove or revert those overrides. The bundle switch does not undo settings you added separately.
214
+
215
+ ### Uninstall the package
216
+
217
+ To remove the installed package as well, run:
218
+
219
+ ```powershell
220
+ dsh plugin --profile web remove dsh-web-search-plugin
126
221
  ```
127
- lib/index.js Host 插件:volatile Config、按元数据分发提供方、额度路由
128
- lib/providers.js 静态元数据表:8 个 REST provider(另加 deepseek.js 的 DeepSeek,共9 个后端)的请求/鉴权/响应/官方跳转(纯数据,无定制代码)
129
- lib/rest.js 通用 REST 后端:按元数据驱动请求构造与响应规范化(含 Tavily / Brave 的额度与限流 hook)
130
- lib/deepseek.js DeepSeek 后端(Anthropic Messages + web_search_20250305 + 账号令牌)
131
- lib/tavily.js Tavily 专用后端与选项解析(当前分发使用 rest 通用后端)
132
- lib/brave.js Brave 专用后端与选项解析(当前分发使用 rest 通用后端)
133
- lib/usage.js Tavily/Brave 用量本地缓存与 /usage 对账
134
- lib/shared.js 中止 / 凭据解析辅助
135
- lib/client.js 浏览器 bundle:设置分区 + 引擎切换 + 官方 key 跳转 + 额度条
136
- locale/en.json 插件列表页 / 详情页的英文标题与描述
137
- locale/zh.json 同上,中文
138
- cordis.patch.yml Bundle patch:插入 Host 行、设 searchProvider、禁用内置 deepseek
222
+
223
+ The same checks for manually added overrides apply after uninstallation. If you explicitly selected `dsh-web-search`, remove that override to use the profile default, or set `web.searchProvider` back to `deepseek-official`.
224
+
225
+ ## How it works
226
+
227
+ The plugin registers a single `WebSearchProvider` with the stable ID `dsh-web-search` through `ctx.web`, following the same provider contract as `@deepseek-ai/dsh-web-search-deepseek` (`inject: ['web']` and `ctx.web.registerSearchProvider`). Switching internal engines does not require changing `web.searchProvider`. Results are normalized to `WebSearchResult` (optional `content` and `sources[]`) and deduplicated by URL. All configuration fields use `volatile()`, so saved settings are read without restarting the plugin.
228
+
229
+ This package is a **bundle**. The `dsh.bundle.patch` declaration points to `cordis.patch.yml`, which adds the Host entry, selects `dsh-web-search`, and disables the built-in `web-search-deepseek` Host plugin while the bundle is enabled. The plugin's internal `deepseek-official` engine option is distinct from its registered `dsh-web-search` ID. Disabling the entire bundle removes this patch layer; disabling only its Host entry does not. Without a bundle declaration, `dsh plugin add` only adds the dependency and does not mount the plugin.
230
+
231
+ - **DeepSeek** — Calls `POST {deepseekBaseURL}/messages` with the `web_search_20250305` tool. If the session uses the official DeepSeek account route (provider: `deepseek-account`) and the account service allows the endpoint, the request uses an account token in `x-dsh-auth-token`. Otherwise, it falls back to an API key (`x-api-key` / `authorization: Bearer`, credential name: `DEEPSEEK_API_KEY`). When a session initiator is available, a redacted request is recorded as the session event `web/deepseek-search-llm-request` before dispatch.
232
+ - **REST backends (Tavily / Brave / Serper / SerpApi / Exa / SearXNG / Scavio / Firecrawl)** — Driven by a static metadata table (`lib/providers.js`) and a shared backend (`lib/rest.js`). Table rows define the request method, path, query field names, authentication (`bearer` / `header` / `none` / `query`), fixed parameters, and response shape. REST backends do not append custom session events.
233
+ - **Tavily** — Calls `POST {tavilyBaseURL}/search`. Keyless mode sends `x-tavily-access-mode: keyless`; keyed mode sends `authorization: Bearer <key>` and requests `include_usage` for credits.
234
+ - **Brave** — Calls `GET {braveBaseURL}?q=&count=` with the `x-subscription-token` header. Does not append custom session events.
235
+ - **The other six REST engines** — Follow their metadata entries' `method`, `auth`, and `params` definitions.
236
+ - Non-2xx responses map to `WEB_PROVIDER_ERROR`; caller cancellation maps to `WEB_ABORTED`; missing credentials map to `WEB_PROVIDER_CREDENTIAL_MISSING`.
237
+
238
+ ## Repository layout
239
+
240
+ ```text
241
+ lib/config.js Supplier field naming and legacy configuration resolution
242
+ lib/index.js Host plugin: volatile Config, metadata-based provider dispatch, quota routes
243
+ lib/deepseek.js DeepSeek backend: Anthropic Messages, web_search_20250305, account tokens
244
+ lib/providers.js Static metadata: requests/auth/responses/API key links for 8 REST providers (plus DeepSeek in deepseek.js, for 9 backends total)
245
+ lib/rest.js Shared REST backend: metadata-driven requests and response normalization, including Tavily/Brave quota and rate-limit hooks
246
+ lib/tavily.js Dedicated Tavily backend and option parsing (current dispatch uses the shared REST backend)
247
+ lib/brave.js Dedicated Brave backend and option parsing (current dispatch uses the shared REST backend)
248
+ lib/usage.js Local Tavily/Brave usage cache and /usage reconciliation
249
+ lib/shared.js Cancellation and credential resolution helpers
250
+ lib/client.js Browser bundle: settings section, engine switching, API key links, quota bars
251
+ locale/en.json English titles and descriptions for plugin list/detail pages
252
+ locale/zh.json Chinese titles and descriptions for the same pages
253
+ cordis.patch.yml Bundle patch: adds Host entry, sets searchProvider, disables built-in DeepSeek
139
254
  ```
140
255
 
141
- ## 开发
256
+ ## Development
142
257
 
143
- ### 本地安装与验证
258
+ ### Local installation and verification
144
259
 
145
- 改源码后本机验证,把仓库装进某个 profile(以 `web` 为例)。**同盘**可以直接用相对路径:
260
+ After editing the source, install the checkout into a profile (using `web` as the example) for local verification. If the checkout and profile are on the **same drive**, you can use a relative path:
146
261
 
147
262
  ```powershell
148
263
  dsh plugin --profile web add ".\dsh-web-search-plugin"
149
264
  ```
150
265
 
151
- **Windows 跨盘不要 `dsh plugin add` 绝对路径。** Profile 与仓库不在同一盘时,它会写成 `link:` 或 `file:` 加绝对盘符;pnpm 会把盘符当成相对路径,junction 指向一个不存在的目录。做法是先把仓库快照到与 profile **同盘**,再用相对 `file:`:
266
+ **On Windows, do not pass an absolute path to `dsh plugin add` across drives.** If the profile and checkout are on different drives, the dependency is written as `link:` or `file:` with an absolute drive letter. pnpm treats the drive letter as a relative path, leaving the junction pointing to a nonexistent directory. Copy a snapshot of the checkout onto the **same drive** as the profile, then use a relative `file:` reference:
152
267
 
153
268
  ```powershell
154
269
  $dst = "$env:USERPROFILE\.dsh\profiles\web\.local\dsh-web-search-plugin"
155
- robocopy "<仓库路径>" $dst /E /XD node_modules .git .github .snapshots .workbuddy docs /NFL /NDL /NJH /NJS
270
+ robocopy "<repository-path>" $dst /E /XD node_modules .git .github .snapshots .workbuddy docs /NFL /NDL /NJH /NJS
156
271
  ```
157
272
 
158
- 在 profile 的 `package.json` 里:
273
+ In the profile's `package.json`:
159
274
 
160
275
  ```json
161
276
  "dsh-web-search-plugin": "file:.local/dsh-web-search-plugin"
162
277
  ```
163
278
 
164
- 并保证 `dsh.profile.bundles` 含本包,然后:
279
+ Ensure that `dsh.profile.bundles` includes this package, then run:
165
280
 
166
281
  ```powershell
167
282
  dsh plugin --profile web install
168
283
  ```
169
284
 
170
- `file:` 是快照:改完仓库后要再 robocopy + `install` 并重启 DSH。改了 `package.json` 的 `files` 字段时,pnpm 可能认为快照未变化而跳过更新,需要先删掉 `node_modules/dsh-web-search-plugin` 再装。
285
+ `file:` is a snapshot: after source changes, copy the files again with robocopy, run `install`, and restart DSH. If you change the package's `files` field, pnpm may consider the snapshot unchanged and skip the update; remove `node_modules/dsh-web-search-plugin` before reinstalling in that case.
171
286
 
172
- 用 `dsh --profile web --dump-config` 确认:组成树里应有 `dsh-web-search-plugin` 行,且 `web.searchProvider` 为 `dsh-web-search`。
287
+ Use `dsh --profile web --dump-config` to verify that the composition tree includes `dsh-web-search-plugin` and that `web.searchProvider` is `dsh-web-search`.
173
288
 
174
- ### 语法检查
289
+ ### Syntax checks
175
290
 
176
291
  ```powershell
177
292
  npm run check
178
293
  npm test
179
294
  ```
180
295
 
181
- 客户端 bundle 必须保持 `window.__ModuleLoader__.load({ id, factory })` 线格式 — 由 `dsh-client-modules` 加载,不是打包器。必须同时导出 `apply` 和 `inject`(`slots`、`locale`、`remote`、`remote.credentials`、`configForms`)。
296
+ The client bundle must retain the `window.__ModuleLoader__.load({ id, factory })` wire format: it is loaded by `dsh-client-modules`, not a bundler. It must export both `apply` and `inject` (`slots`, `locale`, `remote`, `remote.credentials`, `configForms`).
182
297
 
183
- 配置卡片的宿主就是**设置 → 网页搜索**(`settings.section`,`id: "web-search"`),数据来自 `ctx.configForms.get("dsh-web-search-plugin")`,并通过 `configForms.whileServed([namespace], register)` 条件注册:Host 未下发该命名空间时不留痕迹。
298
+ The configuration card is hosted in **Settings → Web search** (`settings.section`, `id: "web-search"`). Its data comes from `ctx.configForms.get("dsh-web-search-plugin")`, and registration is conditional through `configForms.whileServed([namespace], register)`. When the Host does not serve this namespace, the card is not registered.
184
299
 
185
- 本插件不在插件详情页(`plugins.bundle.config`)显示配置。
300
+ The plugin does not show configuration on the plugin detail page (`plugins.bundle.config`).
186
301
 
187
- ## 本地化
302
+ ## Localization
188
303
 
189
- 插件列表页与详情页的标题和描述走 `locale/<lang>.json`,随界面语言切换:
304
+ Plugin list and detail page titles and descriptions use `locale/<lang>.json` and follow the interface language:
190
305
 
191
- ```
306
+ ```text
192
307
  locale/en.json {"meta": {"title": "Web search", "description": "…"}}
193
308
  locale/zh.json {"meta": {"title": "网页搜索", "description": "…"}}
194
309
  ```
195
310
 
196
- 卡片内的文案由 `lib/client.js` 的 `zh` / `en` 两份字典提供,改动时须保持键名对齐。
311
+ Settings card text comes from the `zh` and `en` dictionaries in `lib/client.js`. Keep their keys aligned when editing them.
197
312
 
198
- ## 发布
313
+ ## Publishing
199
314
 
200
- 发布由 GitHub Actions(`.github/workflows/publish.yml`)自动完成:**推送与 `package.json` 版本一致的 `v*` 标签**会带 provenance 发到 npm。向 `main` 的普通推送不会发布。
315
+ GitHub Actions (`.github/workflows/publish.yml`) handles publishing automatically. **Pushing a `v*` tag that matches the version in `package.json`** publishes to npm with provenance. Ordinary pushes to `main` do not publish a package.
201
316
 
202
- 1. 确认 `package.json` 的 `version` 与即将推送的标签一致,并在 `CHANGELOG.md` 中为该版本填写非空的 `## [版本号]` 章节。
203
- 2. 在 GitHub **Settings → Secrets and variables → Actions** 里配置有 publish 权限的 npm automation token(仓库密钥 `NPM_TOKEN`),并允许 Actions 运行。
204
- 3. 打标签并推送:
317
+ 1. Check that `package.json`'s `version` matches the tag you will push, and add a nonempty `## [version]` section for that version in `CHANGELOG.md`.
318
+ 2. Configure an npm automation token with publishing permissions as the repository secret `NPM_TOKEN` under GitHub **Settings → Secrets and variables → Actions**, and enable Actions.
319
+ 3. Tag and push:
205
320
 
206
321
  ```powershell
207
322
  $version = node -p "require('./package.json').version"
@@ -209,12 +324,12 @@ locale/zh.json {"meta": {"title": "网页搜索", "description": "…"}}
209
324
  git push origin "v$version"
210
325
  ```
211
326
 
212
- 工作流会先核对标签与 `package.json` 的 `version`,确认 `CHANGELOG.md` 中对应版本的发布说明非空,再执行 `npm publish --provenance --access public`。
327
+ The workflow checks that the tag matches `package.json`'s `version` and that the corresponding release notes in `CHANGELOG.md` are nonempty, then runs `npm publish --provenance --access public`.
213
328
 
214
- ## 参与贡献
329
+ ## Contributing
215
330
 
216
- 欢迎提 issue 和 pull request,见 [issue tracker](https://github.com/X-C1811/dsh-web-search-plugin/issues)。还可以在同一接缝 id 下继续加搜索后端。
331
+ Issues and pull requests are welcome. See the [issue tracker](https://github.com/X-C1811/dsh-web-search-plugin/issues). Additional search backends can be added under the same registered provider ID.
217
332
 
218
- ## 许可证
333
+ ## License
219
334
 
220
335
  [MIT](LICENSE)