DSH Hub

alaxrpg/dsh-adaptive-model-router

dsh-adaptive-model-router

UIWeb UI0 GitHub stars· updated 2026-08-26

Adaptive model discovery, evaluation, tiering, and subagent routing for DeepSeek Harness

Install

npx @deepseek-ai/dsh plugin --profile web add github:alaxrpg/dsh-adaptive-model-router#v0.2.1

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

dsh-adaptive-model-router DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/dsh-adaptive-model-router.svg)](https://dshhub.dev/plugins/dsh-adaptive-model-router)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from alaxrpg/dsh-adaptive-model-router, cleaned of badges and images.

DSH Adaptive Model Router

dsh-adaptive-model-router 是 DeepSeek Harness 的 Cordis/Loader 插件。它发现多个 Provider 的模型,综合元数据、外部评价和可选的受限真实探测生成评分,把候选模型分入 easynormalhard,再由 adaptive_subagent 为每次子任务选择模型。

这不是 Codex plugin。项目没有 .codex-plugin/plugin.json、Codex marketplace 条目、Codex skill 或 Codex hook,也不使用 plugin-creator

设计边界

  • 模型发现优先使用用户定义的模型清单:插件 Provider 配置中的 models 显式列表 > DSH settings 中该 Provider 路由(如 llm-pi-ai.providers.<route>.models)用户定义的模型;两者都没有时才回退端点发现(ctx.llm.discoverModels(...),再退 OpenAI-compatible /models)。
  • 端点 /models 只提供目录,不能证明能力;只有用户未定义任何模型清单时它才作为候选来源。
  • 未知或不能可靠映射的模型保持 unrated,不会按模型名称猜测能力。
  • 人工配置始终优先于自动策略;刷新只写插件数据目录,不反写 settings.yaml
  • 真实探测默认开启,并受到模型数、请求数、Token、超时和月预算硬限制;未知模型价格按 estimatedCostUsd: 0.01 USD/请求预留。
  • 刷新失败保留 last-known-good;新策略只影响之后启动的子代理。
  • 默认拒绝公网评价源或 Provider URL 跳转到 loopback、私网、链路本地和云元数据地址。需要本机 Provider 时必须显式允许。

运行要求

  • Node.js 20 或更高版本。
  • 已能启动的 DeepSeek Harness profile。
  • Harness 组合中已有 llmtoolssubagents 以及对应的子代理 Provider。
  • Provider 凭据继续由 DSH settings/credentials 服务管理;不要把 API Key 写进本插件配置。

安装与接入

开发目录中安装依赖、运行测试并生成 npm tarball:

npm install
npm test
npm pack

在 DSH profile 项目目录中安装刚生成的 tarball(路径按实际位置替换):

cd "$DSH_PROFILE_DIR"
npm install /absolute/path/to/dsh-adaptive-model-router-0.1.2.tgz
node -e "import('dsh-adaptive-model-router').then(m => console.log(m.name, typeof m.apply))"

最后一条命令应输出 adaptive-model-router function,说明 Loader 所用的包名可被 Node 正常 import。

从 GitHub 安装

也可以直接从 GitHub 安装(推荐固定到 tag,保证可复现):

dsh plugin --profile web add github:alaxrpg/dsh-adaptive-model-router#v0.2.1

不固定 ref(github:alaxrpg/dsh-adaptive-model-router)时拉取默认分支最新提交。peerDependencies 使用 >=0.1.1-rc.2 下界宽范围:独立安装时 pnpm 自动解析到最新可用版本;未来 @deepseek-ai 正式版发布后 pnpm update 即可跟进,无需再整组修改插件。

把插件 patch 作为当前 profile 的最后一层 overlay 合并。参考 examples/cordis.patch.yml

- insert:
    - id: adaptive-model-router
      name: 'dsh-adaptive-model-router'
      config:
        dataDir: !!js dshHomePath('adaptive-model-router')

Cordis 通过命名导出的 apply(ctx, config) 加载插件。插件依赖相关 Harness 服务,并通过 ctx.tools.register(...) 注册 adaptive_subagent;卸载 Cordis fiber 时,工具注册、定时器和在途请求都会释放。

config.dataDir 表示插件的最终数据目录,不是共享根目录;因此上述 dshHomePath('adaptive-model-router') 实际写入 $DSH_HOME/adaptive-model-router/,不会再追加一层同名目录。未显式配置时,DSH_DATA_DIR 仍按 DSH 共享数据根目录处理。

不要直接用示例覆盖 $DSH_HOME/settings.yaml。请只把 examples/settings.yaml 中的 adaptive-model-router: 节合并到已有设置;首次接入前先保留原文件副本。

配置

可视化配置

在 DSH Web profile 中,插件在官方「设置 → 插件配置」页注册一张可折叠卡片——不再提供独立配置页,全部配置都在这张卡片内完成:

  • 常用区直接可见:启用状态、难度模式、默认档位、Provider 列表(启用开关、档位模式与模型、锁定、回退模型、别名、新增/删除)。
  • 刷新周期、路由回退、全局档位、分档阈值、评价权重、真实模型评价、外部评价源和 Provider discovery 非敏感连接参数等收在「高级设置」折叠区,默认隐藏,点击展开。
  • 卡片底部提供「手动刷新评分」按钮:立即执行一次完整的发现 → 评分 → 分档流程(等同一次刷新任务,不受 refresh.enabled 开关影响),完成后用最新评分与自动档位刷新显示。手动刷新与周期刷新共用 refresh.timeoutSeconds 超时,进行中的请求会去重复用,插件禁用或无已启用 Provider 时返回明确错误而不动缓存。

卡片通过插件自己的同源 API 读写:GET/PUT /api/adaptive-model-router/configPOST /api/adaptive-model-router/refresh。保存时卡片回传 API 返回的 revision,并依据 API 返回的 editable 状态启用编辑;过期 revision 会被拒绝(409)。提交后通过运行时 settings 热重载路由。

安全边界:

Related plugins