dsh-provider-pro
No description
- Stars
- 0
- Language
- TypeScript
- Created
- Aug 20, 2026
- Updated
- Sep 4, 2026
Introduction
dsh-provider-pro
DeepSeek Harness 插件:为自定义供应方(llm-pi-ai 手动添加的 provider)补上两个 DSH 官方渠道才有的能力,开箱即用、零逐模型配置。
A DeepSeek Harness plugin that gives custom providers (hand-added via the
llm-pi-ai provider) two capabilities that official channels already have —
out of the box, with no per-model configuration.
兼容性:需要 DSH Desktop 2.0+(客户端 RPC 走
ctx.remote.settings)。 已对照 DSH Desktop 2.0.4(harness0.1.2-alpha.1、cordis4.0.1)逐面核验: settings 服务与 RPC、settings.section槽、ModuleLoader bundle 协议、设计令牌、 pi-ai 推理词典语义。 Requires DSH Desktop 2.0+ (the client half talks toctx.remote.settings); verified surface-by-surface against DSH Desktop 2.0.4 (harness 0.1.2-alpha.1, cordis 4.0.1).
中文
功能
- 自定义 User-Agent — 为每个自定义供应方设置请求 UA(覆盖内置 attribution 头), 应对按 UA 限流、或禁止非官方终端应用访问的供应方。
- 推理等级切换 — 与官方渠道一样的思考等级下拉。数据层自动完成:
Host 半自动为每个缺少
reasoningEfforts的自定义模型写入五档词典 (off→null,low/medium/high/max→ 同名值), 对话模型选择器随即出现推理等级行;defaultEffort不写 → 初始档位为 Default(请求不带思考参数,由供应方 自行决定)。切换发生在聊天里,无需设置。 - 图片输入声明 — 每个模型卡片内提供「支持图片输入」复选框,
勾选即写入
input: [text, image],DSH 随即允许向该模型附加图片。 - 供应商探测与测活(内置)— 每个模型旁提供两个按钮:
- 能力获取(0 消耗):调
/v1/models拉取contextWindow/maxTokens, 自动回填缺失字段(手工值不覆盖),并更新测活状态; - 深度探测(兜底,有消耗):host 半通过 DSH 的 LLM 运行时发送带 1×1 PNG 的极小请求,检测端点可达性、首 token 延迟、上游是否接受图片。 供应商卡片头显示 可达/不可达/未测 徽章,模型行显示对应状态点。
- 能力获取(0 消耗):调
安装
# 方式一:git 安装(需要一次构建许可,见下)
dsh plugin --profile web add github:Mortal520/dsh-provider-pro
# 方式二:本地仓库 / tarball(免构建许可)
dsh plugin --profile web add ./dsh-provider-pro
dsh plugin --profile web add ./dsh-provider-pro-0.3.0.tgz # 先 pnpm pack
git 安装注意:pnpm ≥10 默认拒绝运行 git 依赖的构建脚本。首次
add报错时, 把 pnpm 提示的那个包 key 写进 profile 的pnpm-workspace.yaml:allowBuilds: dsh-provider-pro: true然后重跑
add。这是对包内代码在你机器上执行的一次性授权——只允许可信来源, 并建议锁定提交(github:Mortal520/dsh-provider-pro#<sha>)。为避免该步骤,本仓库已提交构建产物
lib/,也可直接用 tarball/本地路径安装。
安装后重启 dsh web 生效。
用法(设置 → 模型增强)
在「模型」下方新增的原生设置页(与官方页同款令牌样式):
- 总开关「为全部自定义模型启用推理等级切换」(默认开):控制功能 2。 关闭时,自动补全的档位会被移除、回到供应方默认;你在别处手动设过的等级不受影响。
- 每个供应方一张 User-Agent 卡:填写后保存,发往该供应方 baseURL 前缀的请求 带上此 UA;留空保存即清除覆盖。
平台红线(第三方插件无法突破)
对话模型选择器内部的档位名是 dsh-llm-pi-ai 硬编码英文
(Off / Minimal / … / Max,reasoningInfo() 在 dsh-llm-pi-ai/lib/index.js 写死),
第三方插件无法为其改语言,defaultEffort 也不接受中文名值。中文能力只覆盖本插件的
设置页。若需要选择器内中文化,只能改 dsh-llm-pi-ai 本体。
实现原理(给维护者)
- 推理等级(数据层):完整
reasoningEfforts词典 → pi-airesolveModelReasoning→ 模型reasoning = { thinkingLevelMap 全 5 档 }→ ModelSelect 的 Effort 行天然出现;defaultEffort留空 → 选择器自动前置「Default」并默认选中。 - 总开关:
llm-pi-ai用户层顶层的dshProviderProAutoReasoning(缺省 = 开), Host 补档器每次扫描前检查该标志;客户端点开关一次性写入 标志 + 移除字节级相同的自动补档词典。 - UA:pi-ai 会过滤用户
headers里任意大小写的 user-agent、再追加 attribution 头 (requestHeaders()),改settings.headers是死路。Host 半在宿主进程对globalThis.fetch做一次 URL 前缀匹配的最小补丁:仅当请求 URL 命中某供应方 baseURL、 且该供应方配置了userAgent(存于llm-pi-ai.providers.<route>.userAgent, schema 非严格保字段、适配器不读)时替换(而非追加)User-Agent。 - 区块:
settings.section槽,id: provider-pro、order: 15(官方「模型」=10)。
构建与验证
pnpm install
pnpm run check # 类型检查 + 构建 + 离线产物校验
pnpm run smoke # Host 行为冒烟(fetch 补丁 / 补档器 / 总开关)
lib/ 是发布产物,已提交进仓库(git 安装免重建即可用)。
已知限制
- 选择器内档位名 =
dsh-llm-pi-ai硬编码英文,无法中文化(见「平台红线」)。 - 补档器只在
llm-pi-ainamespace 内、手声明models[]的条目生效; 不触碰modelOverrides与官方渠道(catalog)。
English
Features
- Custom User-Agent — set a request-level UA per custom provider (overrides DSH's built-in attribution header). Handles providers that rate-limit by UA or reject non-official terminal apps.
- Reasoning-level switching — the same reasoning picker as the official
channels (off / low / medium / high / max). Fully data-driven, no per-model
setup: the host fills a five-level
reasoningEffortsdictionary for every hand-declared custom model that lacks one and keepsdefaultEffortunset, so the picker preselects Default (no thinking parameter is sent; the provider decides). Switch levels any time in chat. - Image-input declaration — each model card shows a "Support image input"
checkbox; checking it writes
input: [text, image]so DSH allows image attachments for that model. - Built-in probe & liveness — each model row shows two buttons:
- Capabilities (zero-cost): calls
/v1/modelsto fetchcontextWindow/maxTokensand backfills missing fields (hand-set values are never overwritten). - Deep probe (fallback, token-cost): the host sends a minimal request carrying a 1×1 PNG through DSH's LLM runtime to measure first-token latency, total time, and whether the upstream accepts images. Provider card headers show an up/down/untested badge and each model row a matching status dot, aggregated from the latest results.
- Capabilities (zero-cost): calls
Install
# git install (needs one build allow, see note)
dsh plugin --profile web add github:Mortal520/dsh-provider-pro
# or a local checkout / tarball (no build permission needed)
dsh plugin --profile web add ./dsh-provider-pro
dsh plugin --profile web add ./dsh-provider-pro-0.3.0.tgz # after pnpm pack
git installs run the package's
preparescript. pnpm ≥10 blocks that until you allow it: copy the package key pnpm prints into the profile'spnpm-workspace.yaml(allowBuilds: dsh-provider-pro: true) and re-runadd. Only allow packages you trust — and preferably pin a commit (github:Mortal520/dsh-provider-pro#<sha>).To avoid that step entirely, this repo commits its built
lib/, and tarball/local installs need no build permission at all.
Restart dsh web after installing.
Usage (Settings → 模型增强)
A native settings section right below the official 模型 page:
- Master switch "Enable reasoning-level switching for all custom models" (on by default) — controls feature 2. Turning it off strips only the auto-filled dictionaries (byte-identical ones) and leaves any level you set manually untouched.
- One User-Agent card per provider — save to apply the UA to requests whose URL starts with that provider's baseURL; empty + save clears it.
Platform red line
Effort-level names inside the model picker are hardcoded English in
dsh-llm-pi-ai and cannot be localized by a third-party plugin; our Chinese
labels cover this plugin's own settings section only. In-picker Chinese
requires patching dsh-llm-pi-ai itself.
Build & verify
pnpm install
pnpm run check # typecheck + build + offline artifact validation
pnpm run smoke # host smoke tests (fetch patch / filler / master switch)
lib/ is the build artifact and is committed, so a git install works without
building.
Known limitations
- In-picker effort names are English-only (see platform red line).
- The filler only touches hand-declared
models[]under thellm-pi-ainamespace; it never touchesmodelOverridesor catalog models.