CTWCTW9999/dsh-agent-preset-router
Auto Mode for DeepSeek Harness: a flash-model router that auto-picks the best agent preset (standard/code/minimal/cordis) for each new session — judge and run, no confirmation
This is a DeepSeek Harness (DSH) plugin. Review its GitHub README, installation information, maintenance status, and public security signals here.
dsh-agent-preset-router
自动模式(Auto Mode)——为 DeepSeek Harness (DSH) 打造的 AI 预判层插件。
安装后会在预设列表里新增一个可选的 自动模式:新建会话并选择自动模式后,发送首条需求时,会先用 Flash 级模型判断这条需求适合哪个内置 Agent 预设——标准模式 / PTC 模式 / 极简模式 / 创造模式——判断完直接自动切换并执行,无需二次确认;输入框上方会短暂显示一条带动效的决策提示条,3 秒后自动消失。
你发送需求 ──► Flash 分类 ──► 自动切换 preset 并执行(无需确认)──► 决策提示条 3 秒后自动消失
为什么是"每次新建会话"? DSH 会在会话产生任何内容(第一次
turn/start)时固定该会话的 agent preset,同一条会话内发送之后再改 preset 会被平台锁定(agent-preset-locked)。所以自动模式是在每个新会话的首条消息上做路由:Flash 判断发生在任何内容发送之前,此时会话仍是空白态,可以切换 preset。路由自动完成后,会话就固定在你选中的预设上——和直接以该预设新建会话完全一致。
功能特性
- ✨ 可选自动模式 — 新建会话时在预设选择器中显示为「自动模式」,自带一套精简工具集作为兜底(路由不可用时也能正常干活)。
- 🤖 Flash 预判 — 用
deepseek-v4-flash分类器对请求打分,输出preset+reason+confidence,覆盖四个内置预设。 - ⚡ 判断即执行 — 分类完成后立即切换会话到选定预设并发送消息,全程无需确认;输入框上方弹出炫酷动效提示条(动态渐变弥散光),展示路由结果,3 秒后自动消失。
- 🛡️ 诚实兜底 — 分类器任何一步失败,都会回退到可配置的默认预设(默认 standard)并明确告知,而不是悄悄错配。
- 🔌 开箱即用,零配置 — 分类器优先复用会话自己的 provider/model(兜底到第一个已注册 provider)。
安装
需要已安装 DSH 的 Web 端。安装到你的 web profile——从 npm(发布后)或直接从 GitHub:
# npm(发布后)
dsh plugin --profile web add dsh-agent-preset-router
# 或直接从本仓库安装
dsh plugin --profile web add "https://github.com/CTWCTW9999/dsh-agent-preset-router"
(本地开发:dsh plugin --profile web add <本仓库路径>。)
重启 Web 端(或刷新 GUI 页面),让新的 bundle 行和预设被加载。
验证安装
- 新建会话的预设选择器中可以看到「自动模式」。
- 安装后的预设位于
$DSH_HOME/.agent-presets/auto,带.dsh-preset-owner.json属主标记(属于本插件)。
使用
- 新建一个会话。
- 选择 自动模式 作为该会话的预设。
- 输入需求并发送。
- 输入框上方出现动效提示条:先是「正在判断最适合的模式…」,随后显示「已自动选择 xxx —— 理由」,并自动切换会话预设、发送消息;提示条 3 秒后自动消失。
- 无需任何手动确认,会话已切换到选中的预设并开始执行。
斜杠命令(如
/help)不走路由,直接执行。
工作原理
| 层 | 文件 | 职责 |
|---|---|---|
| Host | lib/index.js | 把 auto 预设安装到用户预设根目录;暴露一个 HTTP RPC(POST /agent-preset-router/rpc,方法 classify),通过 ctx.llm 调用 Flash 分类器。 |
| Client | lib/client.js | 包装 api.sessions.prompt;对空白态自动模式会话,先调用 classify RPC,判断完成后自动调用 api.agentPresets.select 切换预设并转发 prompt,同时在输入区 dock(conversation.input.dock)渲染一条 3 秒自动消失的动效提示条。 |
| Preset | presets/auto/ | 自动模式的组合定义——一套精简、安全的工具集,作为选择自动模式时的会话预设(路由通常在首轮之前就切换到目标预设)。 |
影响设计的平台约束
- 预设锁定:
agentPresets.select只在空白会话上生效。路由必须在第一次session.prompt之前、在客户端完成——这就是 prompt 包装器的由来。 - 提示条只读:提示条纯展示、无按钮;判断完成即自动执行,提示条 3 秒后自动消失,不阻塞也不等待。
- RPC 分发是固定的:插件不能往协议里加 RPC 方法,所以分类走 HTTP 路由 + 同源校验。
- 注入契约:host 声明
inject: ['agents', 'llm'];client 注入connection、sessions、slots、locale。
配置
全部可选。在 profile 的 patch 层($DSH_HOME/profiles/web/cordis.patch.yml)里对插件行打配置:
- config:
classifier:
provider: leihuo # 默认:会话自己的 provider,否则第一个已注册的
model: deepseek-v4-flash
temperature: 0
maxTokens: 256
fallbackPreset: standard # 分类失败时使用的预设(standard|code|minimal|cordis)
id: agent-preset-router
| 键 | 默认值 | 含义 |
|---|---|---|
classifier.provider | 会话 provider → 第一个已注册 | 分类器使用的 LLM provider |
classifier.model | deepseek-v4-flash | 分类模型(使用默认值时会被会话模型覆盖) |
classifier.temperature | 0 | 采样温度 |
classifier.maxTokens | 256 | 分类 JSON 的最大输出 token 数 |
fallbackPreset | standard | 分类失败时的兜底预设 |
分类器提示词是严格 JSON 契约:{"preset","reason","confidence"},预设 id 限定四个内置值,输出中文理由,超时 30 秒。
安全说明
- classify 路由仅接受 POST,拒绝跨源请求,请求体上限 256 KiB。
- 分类器会把你的请求文本发送给配置的 LLM provider——与 DSH 本身相同的信任模型。
已知限制
- 路由作用于每个新会话的首条消息,不是同一会话内逐条路由(平台预设锁定)。
- 分类判断是启发式的;路由在发送前自动完成,无需确认。如需改用它,请新建会话重试,或直接以目标预设新建会话。
auto预设本身是精简兜底工具集;如果你希望自动模式作为最终预设时有更丰富的能力,可以扩展presets/auto/agent.cordis.yml(安装位置$DSH_HOME/.agent-presets/auto)。
开发
npm test # 运行全部三个测试(无需 DSH 环境)
npm pack # 打出可发布的 tarball
# 安装 tarball:dsh plugin --profile web add ./dsh-agent-preset-router-0.1.0.tgz
单独运行测试(无需 DSH 环境):
node test/host.test.mjs # parseClassification + 预设安装器
node test/rpc.test.mjs # classify RPC 处理器(桩 ctx)
node test/client.test.mjs # client bundle 加载 + prompt 包装 + HMR
发布
npm publish # 发布到 npm
# 发布后安装:dsh plugin --profile web add dsh-agent-preset-router
致谢
- 预设安装模式参考 QlzqQlzq/dsh-dual-agent-presets。
- 客户端插件形态参考 badai147/dsh-global-rules 与 ChuanTianML/prompt-for-me。
- 社区生态:awesome-dsh-plugin 注册表、dsh-market 插件市场,以及相关的路由/建议类插件 LeemanCheung/dsh-agent-preset-recommender、dylan121322/llm-adaptive、BruceLanLan/dsh-tier-router。
License
Security & install evidence
This score is based solely on public repository metadata and the install evidence registered here — it is not a code security audit.
From a public plugin catalog, linked to a public GitHub repository.
The repository declares the MIT license.
Code updates within the last 180 days.
No verifiable install metadata registered yet — please review the repository instructions manually.
The inspected package metadata declares no install lifecycle scripts.