dsh-web-search-plugin 0.6.0 → 0.6.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 +13 -0
- package/README.md +20 -2
- package/README.zh.md +20 -2
- package/assets/detail/en.md +30 -0
- package/assets/detail/images/overview.en.png +0 -0
- package/assets/detail/images/overview.en.svg +20 -0
- package/assets/detail/images/overview.zh.png +0 -0
- package/assets/detail/images/overview.zh.svg +20 -0
- package/assets/detail/zh.md +30 -0
- package/lib/deepseek.js +18 -3
- package/lib/index.js +5 -1
- package/lib/rest.js +7 -1
- package/lib/shared.js +23 -1
- package/locale/en.json +2 -1
- package/locale/zh.json +2 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
## [未发布]
|
|
6
6
|
|
|
7
|
+
## [0.6.1] - 2026-11-10
|
|
8
|
+
|
|
9
|
+
### 文档
|
|
10
|
+
|
|
11
|
+
- 插件详情页通过 `locale/zh.json` 和 `locale/en.json` 的 `meta.detail` 按界面语言展示独立介绍,包含随包提供的双语功能示意图、配置步骤、费用说明及帮助入口;旧版 Host 继续使用 README。
|
|
12
|
+
|
|
13
|
+
### 兼容性
|
|
14
|
+
|
|
15
|
+
- 接纳 DSH `0.2.2-rc.1` 与 `0.2.2-alpha.3`,扩展 Cordis / Schemastery peer 范围,同时保留已有旧版范围。
|
|
16
|
+
- 为插件搜索接缝补齐 `ready(llmProvider)`,按当前引擎检查凭据是否配置,保留 Tavily keyless 与 SearXNG 的免密钥模式;就绪检查不请求搜索端点、不读取托管 API key 的明文。
|
|
17
|
+
- DeepSeek Messages 的就绪检查使用本次模型路由和搜索端点判断账号令牌;账号凭据缺失时可使用 API key,账号读取失败时按实际调用行为报告未就绪。
|
|
18
|
+
- 补充所有 REST 引擎、凭据来源回退、密钥动态更新及 DeepSeek 账号路由的回归检查;更新中英文运行要求和验证边界。
|
|
19
|
+
|
|
7
20
|
## [0.6.0] - 2026-10-20
|
|
8
21
|
|
|
9
22
|
### 新增
|
package/README.md
CHANGED
|
@@ -30,8 +30,10 @@ For DuckDuckGo results, choose a SearXNG instance that aggregates DuckDuckGo. Du
|
|
|
30
30
|
|
|
31
31
|
## Requirements
|
|
32
32
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
33
|
+
- Isolated checks use the actual dependencies of DeepSeek Harness `0.2.2-rc.1`, `0.2.2-alpha.3`, and older `0.2.1-rc.5`, covering packed installation, the Host web seam, configuration changes, and credential readiness. Supplier HTTP responses are mocked; this does not verify live accounts or the Desktop settings UI end to end.
|
|
34
|
+
- New Search / Fetch options require the Host's `web` and `web-deepseek-api` configuration namespaces. The `0.2.0-rc.2` and `0.2.1-rc.2` peer ranges remain supported; unavailable API options are disabled.
|
|
35
|
+
- DSH `0.2.2` RC / alpha requires Node.js `>=24.9.0`. The plugin retains Node.js `^22.19.0` or `>=24.0.0` for older Hosts.
|
|
36
|
+
- Hosts with tool readiness checks hide the plugin's search tool when required credentials are missing. Tavily keyless and SearXNG remain usable without a key. DeepSeek Messages checks account credentials against the pending model route, rather than the preceding request's route; readiness does not validate keys over the network.
|
|
35
37
|
- pnpm, used by `dsh plugin` to install the plugin into a profile
|
|
36
38
|
|
|
37
39
|
## Installation
|
|
@@ -271,6 +273,16 @@ cordis.patch.yml Bundle patch: adds Host entry, sets searchProvider, disables
|
|
|
271
273
|
|
|
272
274
|
## Development
|
|
273
275
|
|
|
276
|
+
### Host compatibility checks
|
|
277
|
+
|
|
278
|
+
Run `test/host-compatibility.mjs` against a disposable directory with a `private: true` package manifest. Install the plugin's local `.tgz` and the target Host's Web, Settings, Credentials, Launch Environment, LLM, Cordis and Schemastery dependencies using `--strict-peer-deps --ignore-scripts`.
|
|
279
|
+
|
|
280
|
+
```powershell
|
|
281
|
+
node test/host-compatibility.mjs "<disposable-fixture-directory>"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The script uses real Cordis/Web modules and the packed plugin with fake credential services and supplier HTTP. It checks loading, search, result limits, cancellation, configuration changes, keyless modes, credential updates, account routing and disposal. It does not use an existing DSH profile or verify live suppliers or browser layout.
|
|
285
|
+
|
|
274
286
|
### Local installation and verification
|
|
275
287
|
|
|
276
288
|
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:
|
|
@@ -326,6 +338,12 @@ locale/zh.json {"meta": {"title": "网页搜索", "description": "…"}}
|
|
|
326
338
|
|
|
327
339
|
Settings card text comes from the `zh` and `en` dictionaries in `lib/client.js`. Keep their keys aligned when editing them.
|
|
328
340
|
|
|
341
|
+
### Plugin detail pages
|
|
342
|
+
|
|
343
|
+
DSH versions that support `meta.detail` select `assets/detail/*.md` through `locale/zh.json` or `locale/en.json` using the interface language, with images loaded from the installed package. The full README remains the usage and development reference. Other languages follow the Host language fallback chain; older Hosts continue to use the README.
|
|
344
|
+
|
|
345
|
+
Image paths are relative to the detail document. When updating these pages, keep the `meta.detail` targets and image paths valid, and use `npm pack --dry-run --json` to confirm that both Markdown and images are included.
|
|
346
|
+
|
|
329
347
|
## Publishing
|
|
330
348
|
|
|
331
349
|
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.
|
package/README.zh.md
CHANGED
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
|
|
31
31
|
## 运行要求
|
|
32
32
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
33
|
+
- 已在 DeepSeek Harness `0.2.2-rc.1`、`0.2.2-alpha.3` 和旧版 `0.2.1-rc.5` 的实际依赖上进行隔离验证,覆盖打包安装、Host 搜索接缝、配置切换与凭据就绪判断;供应商 HTTP 使用模拟响应,不代表真实账号联网或桌面设置页端到端验证。
|
|
34
|
+
- 新版 Search / Fetch 需要 Host 提供 `web` 与 `web-deepseek-api` 配置;保留 `0.2.0-rc.2`、`0.2.1-rc.2` 依赖范围,不可用的新版 API 选项会禁用。
|
|
35
|
+
- DSH `0.2.2` 的 RC / alpha 要求 Node.js `>=24.9.0`;插件在旧版 Host 上保留 Node.js `^22.19.0` 或 `>=24.0.0` 的运行范围。
|
|
36
|
+
- 支持工具就绪检查的 Host 会在缺少所需凭据时隐藏插件搜索工具;Tavily keyless 与 SearXNG 无需密钥。DeepSeek Messages 按本次模型路由判断账号令牌与 API key,不使用上一轮路由预判,也不联网校验密钥有效性。
|
|
35
37
|
- pnpm,用于通过 `dsh plugin` 把插件装进 profile
|
|
36
38
|
|
|
37
39
|
## 安装
|
|
@@ -271,6 +273,16 @@ cordis.patch.yml Bundle patch:插入 Host 行、设 searchProvider、禁用
|
|
|
271
273
|
|
|
272
274
|
## 开发
|
|
273
275
|
|
|
276
|
+
### Host 兼容性验证
|
|
277
|
+
|
|
278
|
+
`test/host-compatibility.mjs` 可对独立临时目录运行。该目录必须有标记为 `private: true` 的 `package.json`,安装本插件的本地 `.tgz` 及目标版本的 DSH Web、Settings、Credentials、Launch Environment、LLM、Cordis 和 Schemastery 依赖;安装时启用 `--strict-peer-deps --ignore-scripts`。
|
|
279
|
+
|
|
280
|
+
```powershell
|
|
281
|
+
node test/host-compatibility.mjs "<临时验证目录>"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
脚本使用真实 Cordis/Web 模块和打包后的插件,模拟凭据服务与供应商 HTTP,检查加载、搜索、结果上限、取消、配置切换、免密钥模式、凭据更新、账号路由及卸载。它不使用现有 DSH profile,不验证真实供应商或浏览器布局。
|
|
285
|
+
|
|
274
286
|
### 本地安装与验证
|
|
275
287
|
|
|
276
288
|
改源码后本机验证,把仓库装进某个 profile(以 `web` 为例)。**同盘**可以直接用相对路径:
|
|
@@ -326,6 +338,12 @@ locale/zh.json {"meta": {"title": "网页搜索", "description": "…"}}
|
|
|
326
338
|
|
|
327
339
|
卡片内的文案由 `lib/client.js` 的 `zh` / `en` 两份字典提供,改动时须保持键名对齐。
|
|
328
340
|
|
|
341
|
+
### 插件详情页
|
|
342
|
+
|
|
343
|
+
支持 `meta.detail` 的 DSH 会根据界面语言读取 `locale/zh.json` 或 `locale/en.json` 指定的 `assets/detail/*.md`,并加载文档旁的本地图片。完整 README 保留为使用与开发参考;未提供详情文档的语言按 Host 语言链回退,旧版 Host 继续读取 README。
|
|
344
|
+
|
|
345
|
+
详情文档中的图片相对于该文档解析。更新详情时,请保持 `meta.detail` 目标及图片路径有效,并通过 `npm pack --dry-run --json` 确认 Markdown 和图片均在安装包内。
|
|
346
|
+
|
|
329
347
|
## 发布
|
|
330
348
|
|
|
331
349
|
发布由 GitHub Actions(`.github/workflows/publish.yml`)自动完成:**推送与 `package.json` 版本一致的 `v*` 标签**会带 provenance 发到 npm。向 `main` 的普通推送不会发布。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Web search
|
|
2
|
+
|
|
3
|
+
Give your DeepSeek Harness agent more ways to search the web through the familiar `web_search` tool. Choose search and retrieval independently, then save both in one settings page.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Choose how to search
|
|
8
|
+
|
|
9
|
+
- **Call a search API directly**: DeepSeek Search API, Tavily, Brave Search, Serper, SerpApi, Exa, SearXNG, Scavio, or Firecrawl.
|
|
10
|
+
- **Keep the default**: DeepSeek Messages search, using an account token or API key.
|
|
11
|
+
- **Try without a key**: choose Tavily `keyless`, or a SearXNG instance with JSON output enabled. Public services may apply rate limits.
|
|
12
|
+
|
|
13
|
+
## Get started in three steps
|
|
14
|
+
|
|
15
|
+
1. Enable the plugin and open **Settings → Web search**.
|
|
16
|
+
2. Choose a search engine and supply credentials when needed. Under **Web retrieval**, independently choose local HTTP (the default) or DeepSeek Fetch API.
|
|
17
|
+
3. Click **Save**. The next search or retrieval uses the saved settings.
|
|
18
|
+
|
|
19
|
+
The default search engine is **DeepSeek Messages search**. Switch engines and save to call a search API directly. New API options are available only when the Host provides the required configuration.
|
|
20
|
+
|
|
21
|
+
## Costs and credentials
|
|
22
|
+
|
|
23
|
+
Direct search API calls do not make an additional DeepSeek search model request, but the search service may charge separately. Your conversation and the model reading search results still consume tokens. DeepSeek Messages search makes a model request and may incur model charges. Check the provider's terms for DeepSeek Fetch API charges.
|
|
24
|
+
|
|
25
|
+
Engines that require a key provide an API key link in settings. Enter your key and save; the plugin uses DSH credential management. Keyless access still has service limits.
|
|
26
|
+
|
|
27
|
+
## Guides and feedback
|
|
28
|
+
|
|
29
|
+
- [Full guide](https://github.com/X-C1811/dsh-web-search-plugin/blob/main/README.md)
|
|
30
|
+
- [Report an issue](https://github.com/X-C1811/dsh-web-search-plugin/issues)
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="960" height="460" viewBox="0 0 960 460" role="img" aria-labelledby="title desc" lang="en">
|
|
2
|
+
<title id="title">Choose search and retrieval independently</title><desc id="desc">Configure both in Settings → Web search. Saved settings apply to the next operation. Feature diagram · not a screenshot</desc>
|
|
3
|
+
<defs><linearGradient id="bg" x2="1" y2="1"><stop stop-color="#f1f8ff"/><stop offset="1" stop-color="#ecfaf4"/></linearGradient><linearGradient id="accent" x2="1" y2="1"><stop stop-color="#2563eb"/><stop offset="1" stop-color="#0d9488"/></linearGradient></defs>
|
|
4
|
+
<rect width="960" height="460" rx="24" fill="url(#bg)"/>
|
|
5
|
+
<g font-family="Segoe UI, Microsoft YaHei, Noto Sans CJK SC, sans-serif" fill="#163b46">
|
|
6
|
+
<rect x="32" y="32" width="7" height="54" rx="3.5" fill="url(#accent)"/>
|
|
7
|
+
<text x="56" y="57" font-size="28" font-weight="700">Choose search and retrieval independently</text><text x="56" y="85" font-size="16" fill="#506a75">Configure both in Settings → Web search</text>
|
|
8
|
+
<rect x="32" y="116" width="438" height="210" rx="18" fill="#fff" stroke="#d8e6ec"/>
|
|
9
|
+
<rect x="490" y="116" width="438" height="210" rx="18" fill="#fff" stroke="#d8e6ec"/>
|
|
10
|
+
<circle cx="65" cy="153" r="15" fill="#e8f1ff"/><text x="65" y="159" font-size="16" text-anchor="middle" font-weight="700" fill="#2563eb">1</text>
|
|
11
|
+
<text x="91" y="160" font-size="22" font-weight="600">Search engine</text><text x="56" y="191" font-size="15" fill="#607480">10 options · credentials when needed</text>
|
|
12
|
+
<rect x="56" y="214" width="390" height="38" rx="9" fill="#eef5ff"/><text x="72" y="239" font-size="17" fill="#245fa3">Direct search API</text>
|
|
13
|
+
<text x="56" y="291" font-size="17" >DeepSeek Messages search (default)</text>
|
|
14
|
+
<circle cx="523" cy="153" r="15" fill="#e4f7ef"/><text x="523" y="159" font-size="16" text-anchor="middle" font-weight="700" fill="#0d8477">2</text>
|
|
15
|
+
<text x="549" y="160" font-size="22" font-weight="600">Web retrieval</text><text x="514" y="191" font-size="15" fill="#607480">Independent of your search engine</text>
|
|
16
|
+
<rect x="514" y="214" width="390" height="38" rx="9" fill="#eaf8f2"/><text x="530" y="239" font-size="17" fill="#087b6d">Local HTTP (default)</text><text x="514" y="291" font-size="17" >DeepSeek Fetch API</text>
|
|
17
|
+
<path d="M251 326v21h458v-21M480 347v16" fill="none" stroke="#91b6b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
18
|
+
<rect x="414" y="363" width="132" height="44" rx="12" fill="url(#accent)"/><text x="480" y="391" font-size="18" fill="#fff" text-anchor="middle" font-weight="600">Save</text>
|
|
19
|
+
<text x="564" y="390" font-size="15" fill="#48626e">Saved settings apply to the next operation</text><text x="32" y="435" font-size="12" fill="#617d87">Feature diagram · not a screenshot</text>
|
|
20
|
+
</g></svg>
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="960" height="460" viewBox="0 0 960 460" role="img" aria-labelledby="title desc" lang="zh">
|
|
2
|
+
<title id="title">搜索与抓取,各自选择</title><desc id="desc">在「设置 → 网页搜索」中配置,统一保存. 下一次搜索或抓取使用已保存的设置. 功能示意 · 非实际界面截图</desc>
|
|
3
|
+
<defs><linearGradient id="bg" x2="1" y2="1"><stop stop-color="#f1f8ff"/><stop offset="1" stop-color="#ecfaf4"/></linearGradient><linearGradient id="accent" x2="1" y2="1"><stop stop-color="#2563eb"/><stop offset="1" stop-color="#0d9488"/></linearGradient></defs>
|
|
4
|
+
<rect width="960" height="460" rx="24" fill="url(#bg)"/>
|
|
5
|
+
<g font-family="Microsoft YaHei, sans-serif" fill="#163b46">
|
|
6
|
+
<rect x="32" y="32" width="7" height="54" rx="3.5" fill="url(#accent)"/>
|
|
7
|
+
<text x="56" y="57" font-size="28" font-weight="700">搜索与抓取,各自选择</text><text x="56" y="85" font-size="16" fill="#506a75">在「设置 → 网页搜索」中配置,统一保存</text>
|
|
8
|
+
<rect x="32" y="116" width="438" height="210" rx="18" fill="#fff" stroke="#d8e6ec"/>
|
|
9
|
+
<rect x="490" y="116" width="438" height="210" rx="18" fill="#fff" stroke="#d8e6ec"/>
|
|
10
|
+
<circle cx="65" cy="153" r="15" fill="#e8f1ff"/><text x="65" y="159" font-size="16" text-anchor="middle" font-weight="700" fill="#2563eb">1</text>
|
|
11
|
+
<text x="91" y="160" font-size="22" font-weight="600">搜索引擎</text><text x="56" y="191" font-size="15" fill="#607480">10 个选项 · 按需填写凭据</text>
|
|
12
|
+
<rect x="56" y="214" width="390" height="38" rx="9" fill="#eef5ff"/><text x="72" y="239" font-size="17" fill="#245fa3">直接调用搜索 API</text>
|
|
13
|
+
<text x="56" y="291" font-size="17" >DeepSeek Messages 搜索(默认)</text>
|
|
14
|
+
<circle cx="523" cy="153" r="15" fill="#e4f7ef"/><text x="523" y="159" font-size="16" text-anchor="middle" font-weight="700" fill="#0d8477">2</text>
|
|
15
|
+
<text x="549" y="160" font-size="22" font-weight="600">网页抓取</text><text x="514" y="191" font-size="15" fill="#607480">独立于搜索引擎</text>
|
|
16
|
+
<rect x="514" y="214" width="390" height="38" rx="9" fill="#eaf8f2"/><text x="530" y="239" font-size="17" fill="#087b6d">本地 HTTP(默认)</text><text x="514" y="291" font-size="17" >DeepSeek Fetch API</text>
|
|
17
|
+
<path d="M251 326v21h458v-21M480 347v16" fill="none" stroke="#91b6b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
18
|
+
<rect x="414" y="363" width="132" height="44" rx="12" fill="url(#accent)"/><text x="480" y="391" font-size="18" fill="#fff" text-anchor="middle" font-weight="600">保存</text>
|
|
19
|
+
<text x="564" y="390" font-size="15" fill="#48626e">下一次搜索或抓取使用已保存的设置</text><text x="32" y="435" font-size="12" fill="#617d87">功能示意 · 非实际界面截图</text>
|
|
20
|
+
</g></svg>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# 网页搜索
|
|
2
|
+
|
|
3
|
+
为 DeepSeek Harness 的 Agent 提供更多联网搜索选择,沿用熟悉的 `web_search` 工具。搜索引擎与网页抓取独立选择,在一个设置页面中统一保存。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## 选择适合你的搜索方式
|
|
8
|
+
|
|
9
|
+
- **直接调用搜索 API**:DeepSeek Search API、Tavily、Brave Search、Serper、SerpApi、Exa、SearXNG、Scavio、Firecrawl。
|
|
10
|
+
- **保留默认搜索方式**:DeepSeek Messages 搜索,支持账号令牌或 API key。
|
|
11
|
+
- **先体验免密钥搜索**:Tavily 选择 `keyless`,或使用支持 JSON 输出的 SearXNG 实例。公共服务可能限流。
|
|
12
|
+
|
|
13
|
+
## 三步开始
|
|
14
|
+
|
|
15
|
+
1. 启用本插件,打开 **设置 → 网页搜索**。
|
|
16
|
+
2. 选择搜索引擎,按需填写凭据;在 **网页抓取** 中独立选择本地 HTTP(默认)或 DeepSeek Fetch API。
|
|
17
|
+
3. 点击 **保存**,下一次搜索或抓取使用已保存的设置。
|
|
18
|
+
|
|
19
|
+
默认搜索引擎为 **DeepSeek Messages 搜索**。若要直接调用搜索 API,请主动切换引擎并保存;需要新版 API 的选项只在 Host 提供相应配置时可用。
|
|
20
|
+
|
|
21
|
+
## 费用与凭据
|
|
22
|
+
|
|
23
|
+
直接调用搜索 API 不会额外发起 DeepSeek 搜索模型请求,但搜索服务可能单独计费;对话及模型读取结果仍消耗 token。DeepSeek Messages 搜索会发起模型请求,可能产生相应费用。DeepSeek Fetch API 的服务费用以供应商说明为准。
|
|
24
|
+
|
|
25
|
+
需要密钥的引擎可通过设置页的入口获取 API key,填写后保存。插件沿用 DSH 凭据管理;免密钥模式不代表服务无限额。
|
|
26
|
+
|
|
27
|
+
## 使用说明与反馈
|
|
28
|
+
|
|
29
|
+
- [完整中文说明](https://github.com/X-C1811/dsh-web-search-plugin/blob/main/README.zh.md)
|
|
30
|
+
- [报告问题](https://github.com/X-C1811/dsh-web-search-plugin/issues)
|
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 (
|
|
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
|
@@ -151,7 +151,7 @@ const Config = z.object({
|
|
|
151
151
|
/**
|
|
152
152
|
* One seam-facing provider whose `id` stays `dsh-web-search`. The active
|
|
153
153
|
* backend is read from the live settings section on every `available` /
|
|
154
|
-
* `search` call, so a card save takes effect on the next search.
|
|
154
|
+
* `ready` / `search` call, so a card save takes effect on the next search.
|
|
155
155
|
*/
|
|
156
156
|
class PluginSearchProvider {
|
|
157
157
|
id = SEARCH_PROVIDER_ID;
|
|
@@ -172,6 +172,10 @@ class PluginSearchProvider {
|
|
|
172
172
|
return this.backend().available();
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
async ready(llmProvider) {
|
|
176
|
+
return await this.backend().ready(llmProvider);
|
|
177
|
+
}
|
|
178
|
+
|
|
175
179
|
async search(request, signal) {
|
|
176
180
|
return this.backend().search(request, signal);
|
|
177
181
|
}
|
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.
|
|
10
|
+
export const USER_AGENT = "dsh-web-search-plugin/0.6.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;
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
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."
|
|
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.",
|
|
5
|
+
"detail": "assets/detail/en.md"
|
|
5
6
|
}
|
|
6
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "网页搜索",
|
|
4
|
-
"description": "在一个页面独立配置搜索引擎与网页抓取:DeepSeek Search API、Messages、8 个第三方引擎、本地 HTTP 和可选 DeepSeek Fetch API。"
|
|
4
|
+
"description": "在一个页面独立配置搜索引擎与网页抓取:DeepSeek Search API、Messages、8 个第三方引擎、本地 HTTP 和可选 DeepSeek Fetch API。",
|
|
5
|
+
"detail": "assets/detail/zh.md"
|
|
5
6
|
}
|
|
6
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-web-search-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
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",
|
|
67
|
-
"@deepseek-ai/dsh-credentials": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
68
|
-
"@deepseek-ai/dsh-settings": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
69
|
-
"@deepseek-ai/dsh-launch-environment": "^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
70
|
-
"@deepseek-ai/schemastery": "~3.18.4",
|
|
71
|
-
"@deepseek-ai/cordis": "~4.0.4"
|
|
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"
|
|
72
72
|
},
|
|
73
73
|
"license": "MIT",
|
|
74
74
|
"repository": {
|