返回目录
模型与 MCP 插件

dsh-provider-pro

Mortal520/dsh-provider-pro

该仓库暂未提供项目说明。

Stars
0
Forks
0
Issues
0
更新
8 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:Mortal520/dsh-provider-pro

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-provider-pro

English · 中文

给 DeepSeek Harness 里手动添加的自定义供应方(`llm-pi-ai⟫T⟫)补上官方渠道默认就有的三件事:请求级 User-Agent、供应方自己声明的模型能力、以及一次可复现的实测结论。

0.9.16 只有一条规则:上游优先,沉默则保留本地。 供应方在 `/models⟫T⟫ 里声明了上下文窗口、输出上限、推理梯、输入模态中的任何一个,就按它写;没声明、没这个模型、没这个字段,就一个字节都不动。


中文

为什么需要它

官方渠道的模型目录自带容量、推理档位与图片能力;手加的自定义供应方只有你得自己填的空行。原生能读一次模型列表(「获取可用模型」),但只覆盖你手动挑选的新条目,也不会替你判断一个中转网关到底认不认 `developer⟫T⟫ 角色、接不接受图片。这个插件补的就是这两块:声明同步(把供应方说的写下来)与 实测(把供应方没说的测出来)。

功能

  1. 请求级 User-Agent — 每个供应方一张卡,填了就发,留空保存即清除。发往该供应方 baseURL 前缀的请求会替换(不是追加)User-Agent⟫T⟫,内置 attribution 头随之让位。用于按 UA 限流、或只放行官方终端的网关。值存在插件自有设置项userAgents.⟫T⟫,不进 pi-ai 的 provider 行。

  2. 能力声明同步(上游优先) — 供应方被添加或修改时,向该 baseURL 读一次 `GET {base}/models⟫T⟫,把供应方自己声明的值写到模型上:

    • 上下文窗口 / 输出上限:context_length⟫T⟫、max_completion_tokens⟫T⟫(也认 context_window⟫T⟫、max_input_tokens⟫T⟫、max_output_tokens⟫T⟫、limit.*⟫T⟫ 等写法);
    • 推理梯:reasoning.supported_efforts⟫T⟫,与 DSH 七档取交集、映射别名、补off⟫T⟫。只给 `supports_reasoning: true⟫T⟫ 而没有档位列表时,仅在本地完全没有档位的情况下补 DSH 全档;
    • 输入模态:architecture.input_modalities⟫T⟫ 或顶层input_modalities⟫T⟫(supports_images: true⟫T⟫ 等同)。声明含 image 写['text', 'image']⟫T⟫,只给 text 就写 `['text']⟫T⟫。
    • 覆盖规则:上游有值即覆盖——手写字典、手填数字、原生页关掉的图片一并覆盖;上游沉默则保留本地值。`compat⟫T⟫ 不在声明范围内,只由探测实测驱动。
    • 触发:provider 或本插件设置条目变更后去抖 500ms 触发一次;设置页的「获取能力声明」绕一次 60s listing 缓存强制拉取(只读,不做推理实测)。所有写入都由总开关授权。
  3. 探测(实测,不猜) — 「一键探测」跑全部,单模型行内的「探测」强制重测这一个。一次探测做三件事:

    • 容量:复用那次 `/models⟫T⟫ 读取的声明,显示在结论行(写入由声明同步负责);
    • 角色兼容:pi-ai 的 openai-completions 层默认对推理模型发 developer⟫T⟫ 角色,部分中转直接拒(例如 1214)。发一条极小请求实测,被拒而system⟫T⟫ 可用时写 `compat.supportsDeveloperRole: false⟫T⟫,即刻修复;
    • 图片 + 延迟:通过 DSH 运行时发一条真的流式请求,带 1×1 PNG,报首 token 毫秒数与图片是否被接受。结论只测量不写回。
    • 预算:单模型 100s(客户端等 110s)。1M 上下文 + 强推理的模型首 token 就要十几秒,整轮超预算会判 `TIMEOUT⟫T⟫——那是预算用完,不是鉴权失败。
    • 卡片头徽章:可达 / 不可达 / 冷却中 / 未实测(形状 + 颜色双通道)。
  4. 宿主托管的批量探测 — 「一键探测」只提交一个任务,宿主侧并发执行:

    • 并发度 probeConcurrency⟫T⟫(1–8,默认 4,可在dsh-provider-pro⟫T⟫ 设置项调);
    • 关掉设置页、切走页面都继续跑;进度条常驻显示 已完成/总数 · 跳过 · 失败 · 耗时 · 正在探测的模型名,运行中按钮变「停止」;
    • 每个结论立刻写入 probeCache⟫T⟫ 并镜像进provider_pro⟫T⟫ 存储域(耐久真相),刷新、重启、中断都不丢,新进程启动时回填;
    • 再次点击跳过已测过的模型,中断即续跑;两处例外会重测:冷却已过期的裁决、以及「网关静默超时」这类方向性错误裁决(它记的是当次超时上限,不是模型能力)。
  5. 同步提示(toast) — 声明同步真的改动了模型时,窗口右下角弹一次「模型能力声明已同步 · 更新 N · 新增 M」(含上游声明的推理梯),卡片没打开也看得见。删除模型不弹——那不是本插件写的。

界面(设置 → 模型增强)

官方「模型」页下方的原生设置区,样式全部用宿主令牌(`--dsw-alias-*⟫T⟫),跟随主题与深色模式:

  • 页头:标题 + 「刷新」;下一行「获取能力声明」与它的结果状态;再下一行是总开关。
  • 总开关「供应商变更时自动获取模型能力声明」(默认开):关掉后零出站、零写回,手动「获取能力声明」也一并停用;「探测」仍可实测并显示结论。
  • 每个供应方一张卡:UA 单行(输入框 + 保存 + 条件出现的「清空」),下面只有带结论或正在探测的模型行。整份模型清单不在卡片里重复——原生「设置 → 模型」已经有。行内是容量徽标、状态点、强制重测按钮与完整结论。

安装

# git 安装(需要一次构建许可,见下)
dsh plugin --profile desktop add github:Mortal520/dsh-provider-pro

# 本地仓库 / tarball(免构建许可)
dsh plugin --profile desktop add ./dsh-provider-pro
dsh plugin --profile desktop add ./dsh-provider-pro-0.9.16.tgz   # 先 pnpm pack

装完重启 DSH Desktop(或 `dsh web⟫T⟫)生效。

git 安装会被 pnpm ≥10 的构建脚本策略拦一次:把 pnpm 提示的包 key 写进 profile 的 pnpm-workspace.yaml⟫T⟫(allowBuilds: { dsh-provider-pro: true }⟫T⟫),再重跑 add⟫T⟫。只对可信来源开放,并建议锁定提交(github:Mortal520/dsh-provider-pro#⟫T⟫)。仓库已提交构建产物 `lib/⟫T⟫,tarball 与本地路径安装都不需要这一步。

兼容性

  • 验证基线:DSH Desktop 2.0.23-next,内置 harness 0.2.2-rc.3,cordis 4.1.0(0.9.12 逐缝核对,0.9.16 在该宿主上以 `[active]⟫T⟫ fiber 运行)。
  • 最低要求:DSH Desktop 2.0.15(0.1.7-rc.2 设置模型:settings.yaml 退役、per-profile Cordis patch、只有 `.volatile()⟫T⟫ 字段可写)。
  • 依赖的六个缝:settings/document-updated⟫T⟫、settings 非 volatile 写入拒绝、storageDomain.defineDomain⟫T⟫、settings.section⟫T⟫ 的register({ id })⟫T⟫、mutate(ns, ops, expectedRevision)⟫T⟫、pi-aireasoningEfforts⟫T⟫。
  • 差异收敛:describe 的三种形状(裸数组 / namespaces⟫T⟫ 包装 /{ok, value}⟫T⟫ 信封)、CAS 重试、新旧两个 settings 事件名,全部收在 src/compat.ts⟫T⟫ 一个文件里。历史逐缝审计数据见CHANGELOG.md⟫T⟫。

实现原理(给维护者)

  • 声明写入只有一个写者:设置事件触发的声明 pass,读 60s listing 缓存(探测与同步共用)后一次性 CAS 写回。这个 pass 不联网;联网只发生在 `warmAllRoutes⟫T⟫,且被总开关前置拦截。四个字段共用一条规则:上游有值→写、与现值相等→跳过、沉默→保留。
  • 手动拉取:`declarationRequest⟫T⟫ 槽位触发一次绕缓存拉取,配 listing 代际守卫(强制刷新后迟到的旧响应直接丢弃,不写缓存),槽位消费一次。
  • UA:pi-ai 会剥掉用户 headers 里任意大小写的 user-agent 再追加 attribution,所以改 settings.headers⟫T⟫ 是死路。Host 半在宿主进程对globalThis.fetch⟫T⟫ 做一次 baseURL 前缀匹配的最小补丁,命中且该 route 配了覆盖值时替换 UA 头。
  • 区块与浮层:settings.section⟫T⟫,id: provider-pro⟫T⟫、order: 15⟫T⟫(官方「模型」为 10);toast 走shell.overlay⟫T⟫。
  • 状态归属:可变的探测队列、开关、UA 覆盖都在插件自有设置项 dsh-provider-pro⟫T⟫(volatile Config +provider_pro⟫T⟫ 存储域),不污染 pi-ai 的 provider 行;那里只写它自己的 schema 字段。

构建与验证

pnpm install
pnpm run check    # tsc + 构建 + 离线产物校验
pnpm run smoke    # Host 半行为冒烟(18 组)
pnpm run verify   # 以上 + pnpm pack

lib/⟫T⟫ 是发布产物,已提交进仓库。check⟫T⟫/`smoke⟫T⟫ 覆盖构建产物与 Host 半逻辑,不覆盖真实 profile 安装、客户端渲染与真实网关;改了探测或写入路径,请对实际网关再跑一次全量探测。

已知限制

  • 选择器内的档位名是 `dsh-llm-pi-ai⟫T⟫ 硬编码英文,第三方插件改不了(见「平台红线」)。
  • 只处理 llm-pi-ai⟫T⟫ namespace 下**手声明**的models[]⟫T⟫,不碰 `modelOverrides⟫T⟫ 与官方目录。
  • 供应方声明到什么程度,就照到什么程度。 只有 `reasoning.mandatory⟫T⟫ 的声明不产出档位;未知档位名丢弃不写。
  • 总开关同时授权手动「获取能力声明」:关掉后不拉取、不写回。探测可以照跑照显示,但容量不会因此落盘——写回永远走声明同步。
  • 容量回填与原生「获取可用模型」同源(都走 discoverModels⟫T⟫),差异只在「批量回填已存在的模型」:原生adoptPicked⟫T⟫ 对已存在的 id 保留旧条目、不合并新容量(`client.js:700⟫T⟫)。
  • 探测预算 100s/模型。超大上下文模型可能整轮超预算,结论是 `TIMEOUT⟫T⟫ 而不是能力缺失;重测或分批即可。

平台红线

对话模型选择器内部的档位名写死在 dsh-llm-pi-ai⟫T⟫ 的reasoningInfo()⟫T⟫ 里(Off / Minimal / … / Max),第三方插件无法为其改语言,defaultEffort⟫T⟫ 也不接受中文值。中文只覆盖本插件自己的设置页;要在选择器里中文化,只能改dsh-llm-pi-ai⟫T⟫ 本体。


English

English · 中文

A DeepSeek Harness plugin for custom providers hand-added through `llm-pi-ai⟫T⟫. It fills the three things official channels get for free: a request-level User-Agent, the model capabilities the vendor itself declares, and a reproducible measurement of what the vendor does not say.

0.9.16 has exactly one rule: the upstream wins, silence keeps the local value. If the vendor declares a context window, an output cap, a reasoning ladder or an input modality for a model, that value is written; if it declares nothing — no model, no field, empty list — nothing on the row is touched.

Why it exists

The official model catalog ships with capacity, reasoning levels and image support baked in; a hand-added provider is an empty row you fill in yourself. Native DSH can fetch a model list once ("Fetch available models"), but it only covers the rows you pick and never tells you whether a relay accepts the `developer⟫T⟫ message role or an image. This plugin covers both halves: declaration sync (write down what the vendor says) and probes (measure what it does not).

Features

  1. Request-level User-Agent — one card per provider; save to apply, empty + save clears it. Requests whose URL starts with that provider baseURL get a replaced (not appended) User-Agent⟫T⟫, so the built-in attribution header steps aside. For gateways that rate-limit by UA or only allow official terminals. Stored in the plugin entry (userAgents.⟫T⟫), never in the pi-ai provider row.

  2. Capability declaration sync (upstream first) — when a provider is added or changed the plugin reads `GET {base}/models⟫T⟫ once and writes what the vendor declares:

    • Context window / output cap: context_length⟫T⟫,max_completion_tokens⟫T⟫ (also context_window⟫T⟫,max_input_tokens⟫T⟫, max_output_tokens⟫T⟫,limit.*⟫T⟫);
    • Reasoning ladder: reasoning.supported_efforts⟫T⟫, intersected with the seven DSH levels, aliases mapped,off⟫T⟫ always included. A bare `supports_reasoning: true⟫T⟫ without a level list only fills a row that has no ladder at all;
    • Input modality: architecture.input_modalities⟫T⟫ or a top-levelinput_modalities⟫T⟫ (supports_images: true⟫T⟫ counts). Image listed →['text', 'image']⟫T⟫; text only → `['text']⟫T⟫.
    • Precedence: a declared value replaces anything on the row — a hand-written dictionary, a hand-typed number, an image toggle switched off in the native editor. A silent vendor keeps the local value. `compat⟫T⟫ is never declaration-driven; probes own it.
    • Triggers: provider or plugin-entry edits debounce for 500ms; the "Fetch capability declarations" button forces one cache-bypassing pull (read-only, no inference). Every write is authorized by the master switch.
  3. Probes (measure, do not guess) — "Probe all" runs the batch, the per-model "Probe" button force-measures one. One probe does three things:

    • Capacity: reuses the same `/models⟫T⟫ read and shows it on the verdict row (the write-back belongs to declaration sync);
    • Role compat: pi-ai's openai-completions layer sends the developer⟫T⟫ role by default, which some relays refuse (error 1214). A minimal request measures it; on refusal withsystem⟫T⟫ working, `compat.supportsDeveloperRole: false⟫T⟫ is written immediately;
    • Image + latency: a real streaming request carrying a 1×1 PNG through DSH's runtime reports first-token milliseconds and whether the image was accepted. Measured, never written back.
    • Budget: 100s per model (client waits 110s). A 1M-context reasoning model can spend a dozen seconds before its first token, and a run that exceeds the budget reports `TIMEOUT⟫T⟫ — a budget expiry, not an auth failure.
    • Card badge: reachable / unreachable / cooling down / not tested, colour and shape together.
  4. Host-owned batch probing — "Probe all" submits one job; the host runs it with a worker pool:

    • concurrency probeConcurrency⟫T⟫ (1-8, default 4, on thedsh-provider-pro⟫T⟫ entry);
    • closing the settings page does not stop it; a persistent bar shows done/total · skipped · failed · elapsed · models in flight, and the button becomes "Stop";
    • every finished verdict lands in probeCache⟫T⟫ and is mirrored into theprovider_pro⟫T⟫ storage domain (the durable truth), so reload, restart and interruption lose nothing; a fresh process repopulates from the domain;
    • a re-run skips models that already carry a verdict, so an interrupted run resumes. Two verdicts are re-measured: an expired cooldown, and transport-silence (that one records the header cap in force, not the model capability).
  5. Sync toast — when a sync actually changed declarations, a frame-wide toast says "Model capability declarations synced · N updated · M new" (reasoning ladders included), visible even when the card is closed. Deleting a model stays silent: that is not this plugin's write.

Usage (Settings → 模型增强)

A native settings section right below the official 模型 page; every control uses host tokens (`--dsw-alias-*⟫T⟫) and follows the theme:

  • Header: title + "Refresh"; the next line carries "Fetch capability declarations" and its result; the line below is the master switch.
  • Switch "Fetch model capability declarations automatically" (on by default): off means zero outbound calls and zero write-back, including the manual fetch. "Probe" still measures and displays.
  • One card per provider: a single User-Agent row (input + save + a conditional "Clear"), then only verdict-bearing or currently probing model rows. The full model inventory is not duplicated here — the native Settings → Models page already has it. Each row keeps the capacity chips, status dot, force-re-probe button and the full verdict.

Install

# git install (needs one build allow, see note)
dsh plugin --profile desktop add github:Mortal520/dsh-provider-pro

# local checkout / tarball (no build permission needed)
dsh plugin --profile desktop add ./dsh-provider-pro
dsh plugin --profile desktop add ./dsh-provider-pro-0.9.16.tgz   # after pnpm pack

Restart DSH Desktop (or `dsh web⟫T⟫) afterwards.

pnpm ≥10 blocks the build script of a git dependency once: copy the package key pnpm prints into the profile pnpm-workspace.yaml⟫T⟫ (allowBuilds: { dsh-provider-pro: true }⟫T⟫) and re-run add⟫T⟫. Only allow sources you trust, and preferably pin a commit (github:Mortal520/dsh-provider-pro#⟫T⟫). The repo commits its built `lib/⟫T⟫, so tarball and local-path installs skip that step entirely.

Compatibility

  • Verified baseline: DSH Desktop 2.0.23-next, bundled harness 0.2.2-rc.3, cordis 4.1.0 (seam-by-seam audit in 0.9.12; 0.9.16 runs there as an `[active]⟫T⟫ fiber).
  • Minimum: DSH Desktop 2.0.15 (the 0.1.7-rc.2 settings model: per-profile Cordis patches, only `.volatile()⟫T⟫ fields writable).
  • Six seams this plugin rides: settings/document-updated⟫T⟫, the non-volatile write refusal,storageDomain.defineDomain⟫T⟫, settings.section⟫T⟫ registration viaregister({ id })⟫T⟫, mutate(ns, ops, expectedRevision)⟫T⟫ and pi-aireasoningEfforts⟫T⟫.
  • Convergence, not branching: three describe shapes (bare array / namespaces⟫T⟫ wrapper /{ok, value}⟫T⟫ envelope), the shared CAS retry and the old/new settings event names all live in src/compat.ts⟫T⟫. The historical audit data sits inCHANGELOG.md⟫T⟫.

How it works (for maintainers)

  • One writer for declarations: the settings-triggered declaration pass reads the 60s listing cache (shared with probes) and writes the whole row back under CAS. That pass never touches the network; the network lives in `warmAllRoutes⟫T⟫, which the master switch gates before any route is touched. All four fields share one rule: declared → write, equal → skip, silent → keep.
  • Manual fetch: the `declarationRequest⟫T⟫ slot triggers one cache-bypassing pull, guarded by a listing epoch so a late response from the forced round is dropped instead of cached; the slot is consumed once.
  • UA: pi-ai strips any-cased user-agent from user headers and appends its attribution header, so settings.headers⟫T⟫ is a dead end. The host half patchesglobalThis.fetch⟫T⟫ once, matching a baseURL prefix and replacing the UA header only when that route has an override.
  • Slots and overlays: settings.section⟫T⟫ withid: provider-pro⟫T⟫, order: 15⟫T⟫ (official 模型 is 10); the toast ridesshell.overlay⟫T⟫.
  • State ownership: probe queue, switches and UA overrides live in the plugin entry (volatile Config + the `provider_pro⟫T⟫ storage domain), never as unknown fields on the pi-ai provider row.

Build & verify

pnpm install
pnpm run check    # tsc + build + offline artifact validation
pnpm run smoke    # host-half behaviour smoke (18 groups)
pnpm run verify   # the above plus pnpm pack

lib/⟫T⟫ is the published artifact and is committed.check⟫T⟫/`smoke⟫T⟫ cover the build output and the host half, not a real profile install, client rendering or a live gateway; after changing probe or write paths, run a full probe against your actual gateway.

Known limitations

  • Effort names inside the model picker are hardcoded English in `dsh-llm-pi-ai⟫T⟫; a third-party plugin cannot localize them (see the platform red line).
  • Only hand-declared models[]⟫T⟫ under thellm-pi-ai⟫T⟫ namespace; `modelOverrides⟫T⟫ and the official catalog are untouched.
  • As far as the vendor declares, that far we follow. A `reasoning.mandatory⟫T⟫-only block yields no ladder, and an unrecognised level name is dropped rather than written.
  • The master switch also authorizes the manual fetch: off means no pull and no write-back. Probes still run and display, but capacity never reaches the row that way — every write goes through declaration sync.
  • Capacity backfill shares its source with the native "Fetch available models" (both call discoverModels⟫T⟫); the plugin only adds bulk backfill for existing models, where nativeadoptPicked⟫T⟫ keeps the old entry and never merges newly discovered capacity (`client.js:700⟫T⟫).
  • Probes get 100s per model. A very large-context model can exhaust that budget and land on `TIMEOUT⟫T⟫ — a budget expiry, not a missing capability; re-measure or split the batch.

Platform red line

Effort-level names inside the model picker are hardcoded in reasoningInfo()⟫T⟫ (dsh-llm-pi-ai⟫T⟫) as English Off / Minimal / … / Max; defaultEffort⟫T⟫ rejects Chinese values too. A third-party plugin cannot localize them — our Chinese covers this plugin settings section only. In-picker Chinese would require patchingdsh-llm-pi-ai⟫T⟫ itself.


License

MIT · Changelog

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。