前言¶
在使用 DeepSeek Harness(DSH)进行多轮对话时,开发者往往会遇到一个问题:某个会话中实际调用了哪些模型路由,以及是否有调用偏离了预期的策略。现有的 cost/context 插件只是在事后展示花费,无法在调用发生的瞬间对路由策略进行拦截或提示。dsh-plugin-safe-route 插件解决的就是这个问题:它通过一次命令就能告知当前会话使用的路由,并将超出允许列表的调用标记出来,帮助开发者在第一时间发现并纠正策略偏差。
插件定位¶
这是一个只读的路由检查审计插件,由 SSHOOTING 维护,分类为 admin-security。它的核心功能是在不读取任何会话内容、不发起网络请求的前提下,分析 DSH 会话中的 request/header 和 request/context 事件,提取 provider 和 model 名称,并与用户在配置文件中定义的 allow/deny 规则进行比对,最后给出一个评分和结论。
安装与启用¶
安装前请确保你的环境满足以下条件:
- Node.js 版本为
^22.19.0或>=24.0.0 - DSH 版本为
>=0.2.0-rc.2且小于0.3.0
在终端中执行以下命令完成安装:
dsh plugin --profile web add dsh-plugin-safe-route
安装完成后,需要重启 DSH 进程,插件才会生效。
配置路由规则¶
插件的配置通过编辑当前 profile 的 cordis.patch.yml 文件实现。插件会读取该配置中的 policy 字段,其中包含 allow 和 deny 两个列表。
默认情况下,插件会预设两个免费路由作为允许列表:
- id: dsh-plugin-safe-route
name: dsh-plugin-safe-route
config:
policy:
allow:
- provider: opencode-go
model: hy4-flash-free
- provider: opencode-go
model: longcat-2.5-free
deny:
- provider: opencode-go
model: hy4 # paid sibling — flag explicitly
配置项说明:
| Key | Type | Default | Meaning |
|---|---|---|---|
policy.allow |
{provider, model?}[] |
两个 opencode-go 免费路由 | 符合此规则的调用会被计为 ALLOWED。可以省略 model 或使用 * 来匹配整个 provider。 |
policy.deny |
{provider, model?}[] |
[] |
符合此规则的调用会被计为 DENIED。deny 优先级高于 allow。 |
如果 allow 为空或无效,插件会回退到默认的免费路由列表,避免配置错误导致检查失效。
使用方法¶
在任意 DSH 会话中,输入 /route-check 命令即可查看当前会话的路由审计结果。命令会输出一个紧凑的评分卡,包含允许/拒绝调用数量、总体评分以及建议的修复操作。
示例输出:
[route-check] 1/3 calls outside allowlist · score 67/100 · REVIEW
opencode-go/hy4-flash-free 2 call(s) ALLOWED
deepseek-official/deepseek-v4-pro 1 call(s) UNKNOWN
Fix: switch the default model to an allowed route, or update the allowlist in cordis.patch.yml.
如果需要机器可读的输出(用于 CI、脚本或仪表板),可以使用 /route-check --json。
评分规则¶
插件的评分计算方式如下:
score = round(100 × allowed calls / all observed model calls)- 空会话的评分为 100
verdict有三种状态:clean:没有违反策略的路由review:存在未在 allow/deny 中定义的路由(标记为UNKNOWN)violation:存在被显式拒绝的路由
隐私与安全¶
这是一个注重隐私的插件:
- 仅从
request/header和request/context事件中读取provider和model字符串 - 不读取 prompt、reasoning、tool 结果、文件内容或凭证
- 不发起网络请求,不进行遥测,不写入文件
- 展示的文本报告会经过脱敏过滤
兼容性¶
| Component | Supported |
|---|---|
| DSH | >=0.2.0-rc.2 <0.3.0 |
| Node.js | ^22.19.0 \|\| >=24.0.0 |
| Cordis | >=4.0.0 <5 |
| Surface | headless 和 web(仅命令注册) |
常见问题¶
| Symptom | Cause | Fix |
|---|---|---|
/route-check not found |
Bundle row not installed | Re-run dsh plugin --profile web add dsh-plugin-safe-route, then restart DSH. |
| Score is 100 but I used a paid model | The route isn’t in allow or deny |
Add an explicit deny rule for it. |
no model calls observed |
No request/* events in this session yet |
Use the session once, then re-run. |
| Wrong allowlist | Profile cordis.patch.yml overrides the bundle row |
The last write wins — edit the profile row, not the package. |
总结¶
dsh-plugin-safe-route 为 DSH 用户提供了一个轻量级、零数据泄露风险的路由审计能力。它不改变 DSH 的行为,只是通过一个命令将当前会话的路由使用情况呈现出来,帮助开发者快速识别策略偏差。如果你需要在团队中统一模型调用规范,这个插件可以作为日常检查的工具之一。
- 目录页:https://www.skillhub.cn/plugins/SSHOOTING/dsh-plugin-safe-route
- GitHub:https://github.com/SSHOOTING/dsh-plugin-safe-route