Web search and fetch provider for DeepSeek Harness and Pi: anonymous-first routing across Exa, Tavily, Parallel, Firecrawl and TinyFish, with opt-in billing, quota preflight and bounded cancellation.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:Luca4Don3/dsh-web-search
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
同时兼容 DSH 与 Pi 的网页搜索 / 网页抓取插件,一个仓库、一份内核、两套宿主适配。
| 能力 | DSH | Pi |
|---|---|---|
| 搜索 | 向 ctx.web 注册提供方 free-first |
注册模型工具 web_search |
| 抓取 | 向 ctx.web 注册提供方 local-first |
注册模型工具 web_fetch |
| 密钥菜单 | —(配置来自 Cordis 配置) | /web-search-auth 命令 |
匿名顺序为 Exa → Tavily → Parallel → Firecrawl → TinyFish(keyless)→ SearXNG(自建,配置后启用);计费顺序为 Exa → Tavily → Parallel → Firecrawl → SerpApi。默认禁止计费,只有显式授权且在匿名通道全部失败后才会尝试密钥通道。TinyFish 只有零凭据匿名通道。
结构
src/
├── search/ # 搜索内核:路由、协议、MCP 解析、脱敏、正文落盘
├── quota/ # 额度预检、冷却状态、私有持久化
├── auth/ # 凭据解析与系统密钥库(macOS Keychain / Linux secret-tool)
├── fetch/ # 抓取内核:SSRF 校验、有界响应、HTML→Markdown
├── shared/ # 两个内核共用的有界响应体读取
└── hosts/
├── dsh.ts # Cordis 插件:注册搜索与抓取提供方
├── pi.ts # Pi:web_search 工具 + /web-search-auth
└── pi-fetch.ts # Pi:web_fetch 工具
内核不 import 任何宿主 API,因此两个宿主共用同一套路由、额度、冷却与脱敏行为,也可以离线测试。
安装
从本地检出目录安装到 DSH 或 Pi 前,先用 Node.js 24 或更新版本准备运行依赖。
cd /absolute/path/to/dsh-web-search
npm ci --omit=dev --omit=peer --ignore-scripts --no-audit --no-fund
检出目录已包含 DSH 的编译产物和 Pi 的 TypeScript 入口。上述命令会把 @deepseek-ai/schemastery、undici 及其依赖装进该目录,宿主各自提供运行时接口。
DSH
将 my-profile 换成目标 DSH profile 名称,在上一步的目录中执行。
dsh plugin --profile my-profile add "link:$PWD"
cordis.patch.yml 会同时启用 free-first(搜索)与 local-first(抓取)。抓取提供方使用独立 id,因为官方插件已占用 http;若你已有自定义 fetchProvider,请保留你的选择。
安装、更新或重新启用之后必须完全退出 DSH 再启动:宿主只在启动时组合 profile,运行中的进程不会重新加载插件条目。报错与处理见「排障」。
顶层 engines.dsh 与 @deepseek-ai/dsh-web peer 精确枚举 0.2.2-rc.1 至 0.2.2-rc.5 及 0.2.3-alpha.2。DSH 安装器按该列表检查当前版本。Cordis peer ^4.0.5 || 4.2.0-alpha.1 覆盖 RC 宿主的 4.1.0 与 alpha 宿主的 4.2.0-alpha.1。运行时通过宿主注册搜索和抓取提供方,缺少必要接口时报告 WEB_SEARCH_UNSUPPORTED_HOST。开发锁文件固定 RC5 测试基线。
0.2.2-rc.1 至 0.2.2-rc.5 的既有支持来自 2026-11-19 的官方宿主矩阵。v0.3.5 在隔离的官方 0.2.2-rc.1、0.2.2-rc.5 和 0.2.3-alpha.2 运行时复验搜索/抓取就绪契约,并在后两套宿主验证本地链接。v0.3.6 只增加注册成功的启动日志与排障文档,不改变路由、费用授权、数据路径与宿主契约。
Pi
准备好依赖后,从同一个目录执行。
pi install "$PWD"
也可以在 Pi 的 settings.json 中指定同一个本地目录。
{
"packages": [
{ "source": "/absolute/path/to/dsh-web-search", "extensions": ["pi.ts"] }
]
}
从 Git 安装时,可以将 source 设为 git:github.com/Luca4Don3/dsh-web-search。
从旧版 pi-extensions/extensions/web-search 迁移
旧版扩展同样注册 web_search,两者同时启用会工具重名冲突。迁移步骤:
# 1. 确认旧版位置(Pi 会自动加载该目录下的扩展)
ls ~/.pi/agent/extensions/web-search
# 2. 移走旧版(保留备份便于回滚;不要直接删除)
# 必须移出 ~/.pi/agent/extensions/ —— Pi 会加载该目录下的每个子目录,
# 改名成 web-search.bak 仍在自动发现范围内,重名冲突不会解除。
mv ~/.pi/agent/extensions/web-search ~/.pi/agent/web-search.bak
# 3. 按上文准备本地依赖,再从新版检出目录安装
cd /absolute/path/to/dsh-web-search
pi install "$PWD"
# 4. 重启 Pi,确认只注册一份 web_search
若此前用 pi install 装过旧版,改用 pi remove ~/pi-extensions/extensions/web-search 卸载。
/web-search-auth 命令名保持不变,密钥配置与冷却状态无需迁移。
回滚:mv ~/.pi/agent/web-search.bak ~/.pi/agent/extensions/web-search。
备份目录只要仍在 ~/.pi/agent/extensions/ 之下就会被继续加载;
放到该目录的同级位置(如 ~/.pi/agent/)才能真正停用。
如果此前已按旧版说明放在 ~/.pi/agent/extensions/web-search.bak,
请补一步:mv ~/.pi/agent/extensions/web-search.bak ~/.pi/agent/web-search.bak。
安装后可用 /web-search-auth 管理密钥。环境变量优先于系统密钥库。
配置
DSH(Cordis 配置)
| 字段 | 默认值 | 含义 |
|---|---|---|
allowBillable |
false |
显式授权可能计费的通道 |
timeoutMs |
25000 |
单请求预算,毫秒 |
totalTimeoutMs |
90000 |
整次调用总预算,毫秒 |
maxResponseBytes |
5242880 |
解压后响应体上限 |
maxChars |
24000 |
模型可见正文字符预算 |
retries |
1 |
网络或服务端错误重试次数 |
cooldownOverrideMs |
未设置 | 冷却覆盖,0 禁用冷却 |
stateDirectory |
$DSH_HOME/config/web-search |
冷却与额度账本目录 |
cacheTtlMs |
0 |
成功结果内存缓存时长(毫秒,0 关闭) |
exaMonthlyBudgetUsd |
10 |
Exa 月度赠金额度(美元),用尽后跳过密钥通道 |
searxngUrl |
未设置 | 自建 SearXNG 根地址;留空则不启用该提供方 |
fetchTimeoutMs |
20000 |
抓取总预算,毫秒 |
fetchMaxResponseBytes |
5242880 |
抓取解压后响应体上限 |
fetchMaxChars |
24000 |
抓取正文上限 |
fetchMaxRedirects |
3 |
最大跳转次数 |
Pi(环境变量)
| 字段 | 默认值 | 含义 |
|---|---|---|
PI_WEB_SEARCH_ALLOW_BILLABLE |
false |
同 allowBillable,只接受 true / false |
PI_WEB_SEARCH_ALLOW_PAID |
未设置 | 旧开关别名,与上一项冲突时报错 |
PI_WEB_SEARCH_TIMEOUT_MS |
25000 |
单请求预算 |
PI_WEB_SEARCH_TOTAL_TIMEOUT_MS |
90000 |
整次调用预算 |
PI_WEB_SEARCH_MAX_RESPONSE_BYTES |
5242880 |
响应体上限 |
PI_WEB_SEARCH_RETRIES |
1 |
重试次数,0..3 |
PI_WEB_SEARCH_FREE_COOLDOWN_MS |
未设置 | 固定冷却覆盖 |
PI_WEB_SEARCH_CACHE_TTL_MS |
0 |
成功结果内存缓存时长(毫秒,0 关闭) |
PI_WEB_SEARCH_EXA_MONTHLY_USD |
10 |
Exa 月度赠金额度(美元),0 表示不限 |
SEARXNG_URL |
未设置 | 自建 SearXNG 根地址;留空则不启用该提供方 |
PI_WEB_FETCH_TIMEOUT_MS |
20000 |
抓取总预算 |
PI_WEB_FETCH_MAX_RESPONSE_BYTES |
5242880 |
抓取响应体上限 |
PI_WEB_FETCH_MAX_CHARS |
24000 |
抓取正文上限 |
PI_WEB_FETCH_MAX_REDIRECTS |
3 |
最大跳转次数 |
PI_WEB_FETCH_REMOTE_FALLBACK |
off |
远程回退;当前只接受 off,设为 jina 会在任何请求前明确报错 |
密钥:EXA_API_KEY、TAVILY_API_KEY、PARALLEL_API_KEY、FIRECRAWL_API_KEY、SERPAPI_API_KEY。TinyFish 始终 keyless,不读取 TINYFISH_API_KEY。
SearXNG(自建零成本兜底)
把 SEARXNG_URL(Pi)或 searxngUrl(DSH)指向自建实例根地址即可启用:
- 只走匿名通道,不读取任何密钥;
- 实例需要允许 JSON 输出(
search.formats包含json),否则请求返回 HTML,插件会报协议错误; - 未配置地址时该提供方既不出现在
auto路由里,也不能被显式选择(报INVALID_CONFIG); - 请求参数固定为
format=json&language=zh-CN&safesearch=0,不携带 Cookie 或认证头。
Exa 密钥通道($10 月度赠金)
Exa 的匿名通道是官方 MCP,受共享限流;配置 EXA_API_KEY 并显式授权计费后,密钥通道改走 REST /search 的 lite 档位:
- 密钥只放
x-api-key请求头,不进入 URL、查询串或正文; lite单价 $4/1k 请求(含前 10 条结果,带contents.highlights);Exa Starter 每月赠送 $10 额度(每月 1 日重置,无需绑定付款方式),约合 2,500 次搜索;auto/fast为 $7/1k(旧 MCP 通道的默认档位),本插件的密钥通道不再使用它们;- 额度耗尽时 Exa 返回 402,插件按
quota_exhausted冷却并回退到其他通道。
计费授权默认关闭:DSH 在 Cordis 配置里设置 allowBillable: true,Pi 设置 PI_WEB_SEARCH_ALLOW_BILLABLE=true。
在 DSH 插件页配置 Exa key
侧栏 插件 → 已安装插件 → dsh-web-search → 配置,在「网页搜索(Exa)」面板里粘贴 Exa API Key 并保存:
- 密钥写入 DSH 凭据域(
ctx.credentials),宿主侧插件在每次搜索时读取;不会写入cordis.patch.yml,也不会出现在日志里; - 环境变量
EXA_API_KEY仍然优先于凭据库; - 同一面板可「清除」已保存的密钥;
- 面板里的「启用计费通道(allowBillable)」开关会写入该插件条目的配置,打开后才会使用密钥通道(默认关闭);该字段是 volatile 配置,保存后立即生效,不需要重启宿主。
排障
configured web provider "free-first" is not registered
这是 DSH 内核(dsh-web)的报错:配置里的提供方 id 与宿主进程的注册表对不上,含义是当前宿主没有加载本插件,不是搜索服务本身故障。
常见原因:
- 插件在宿主启动之后才安装、更新或被重新启用 —— profile 已变,进程内仍是旧树;
- 插件条目在启动时加载失败 —— 到「设置 → 插件」查看
web-search条目的状态与诊断; - 插件被禁用,但补丁里的
searchProvider/fetchProvider仍指向free-first/local-first。
处理顺序:
- 完全退出 DSH(不是关闭窗口)再启动,然后重试;
- 在「设置 → 插件」确认
dsh-web-search已启用,且条目没有加载失败; - 只想先恢复搜索:在「设置 → 网页搜索」把提供方切回官方,不依赖本插件。
插件注册成功时会向宿主日志写入:
dsh-web-search: 已注册搜索提供方 free-first 与抓取提供方 local-first
宿主日志里没有这条,就说明该进程没有加载插件。反过来,出现这条日志但搜索仍失败时,下一步应看额度、冷却与网络错误码(WEB_SEARCH_* / WEB_FETCH_*),而不是插件的加载状态。
禁用本插件之前,请先把网页搜索提供方切回官方,否则会留下指向 free-first / local-first 的悬空配置;重新启用后同样需要重启宿主。
安全与限制
- 未授权计费时不读取任何服务商密钥、凭据库或额度接口。
- 授权后一次性解析全部所需密钥,并在正文、来源、details 与落盘内容中统一脱敏。
- 只能通过环境变量或系统密钥库注入密钥;不提供明文文件回退。
- 响应体按解压后字节计数上限,超限立即中止请求,不返回部分结果。
- 冷却状态只保存 HMAC 作用域与冷却元数据,目录
0700、文件0600。 - 搜索失败、超时或取消后也尝试保存已记录的冷却;收尾最多等待 250 毫秒,保存异常不替换原始搜索错误。
- 额度预检只回答「当前是否付得起」,不能证明账户免费,也不提供跨进程账单硬上限。
- 抓取拒绝私有段、回环、链路本地与云元数据地址,不执行网页脚本,不携带 Cookie。
- 搜索结果按 URL 去重后做域名多样化排序:同一站点最多两条先出现,其余按原顺序保留,不丢结果。
- 两个宿主的单元测试全部离线;这不等于真实桌面安装、真实密钥库写入或服务商网络验收。
开发验证
npm ci --ignore-scripts --no-audit --no-fund
npm run check # 严格类型检查
npm test # DSH 兼容层 + Pi + 抓取全部离线用例
npm run check:artifacts
npm pack --dry-run
Pi 用例通过 jiti 直接加载 src/ 下的源码,因此需要本机装有 Pi(提供 jiti 与 typebox)。CI 会先安装 @earendil-works/pi-coding-agent 再运行。
npm run test:hosts 默认使用锁定的开发基线 0.2.2-rc.5,包含官方 searchReady() 和 fetchReady() 契约。也可以传入其他官方隔离宿主的依赖目录。
npm run test:hosts -- /absolute/path/to/rc5/node_modules /absolute/path/to/alpha2/node_modules
npm run smoke 是手动匿名网络检查,不进入持续集成,不使用密钥或计费通道。
许可证
Links
More in this category
Tencent/BrowserSkill#dsh-plugin-browserskill★ 10915
BrowserSkill bridge for controlling visible Chrome and Edge Agent Windows from DeepSeek Harness, with native browser tools, accessibility and VOM observations, screenshots, owned multi-session control, and a live Web UI overlay.
DDDMUC/dsh-free-search★ 1897
Free web search for DSH with 42 engines: 6 keyless (DuckDuckGo, Bing, SearXNG, Degoog, AnySearch), 6 key-or-keyless tiers (Exa, Tavily, Keenable, Firecrawl, Parallel, You.com), 5 HTML search pages, and keyed providers from Brave and Baidu to Zhihu, OpenAI and Claude. Failure-classified failover with cooldown and key rotation, allowlist switching, an editable fallback chain, zh/en language pools, Multi concurrent merge, 12 MCP tools and a standalone stdio server, with per-engine keys in settings.
omdsh-dev/dsh-browser#packages/browser/bridge-browser★ 1178
Chrome sidebar extension that lets DSH operate your browser directly, no vision capabilities required.
liustack/modsearch★ 1071
Web search bridge for text-only agents: ask the web or X, get structured JSON evidence (search, fetch, citations).
Fisfzy/dsh-ego-browser★ 605
Drive a real Chrome/Chromium browser from DeepSeek Harness with 35 structured tools for navigation, snapshots, clicks, forms, JavaScript/CDP, screenshots, downloads and tabs; a live sidebar mirrors the page and accepts mouse and keyboard input. It ships a managed CDP runtime, keeps login state across calls, and can import cookies from your everyday Chrome through a companion extension.
regrevia/Envoy#dsh-envoy★ 315
Distill any link into Markdown, a wiki or a knowledge base. Installs per host: DSH -> envoy-dsh; Claude Code/Codex -> envoy@envoy. Douyin/Bilibili video, image posts, WeChat, Xiaohongshu, PDFs, podcasts. Video is read on its own timeline with keyframes and ASR transcripts locatable to \[mm:ss], so the context carries what was said and shown instead of the title and the recommendation rail. On 60 turns with vs without: ends normally with the gaps named 22% -> 92%, times out 68% -> 0% (the A/B is exploratory: different time caps, no human correctness review). On 123 live links 80% came back usable (93% of the pages that answered).
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.