echo-xianyu/dsh-go-rotator

Plugin插件 Native原生 ⭐ 3 MIT Models & Routing模型与路由

DSH插件,用于切换opencode Go订阅

Project Overview项目介绍

dsh-go-rotator is a native DSH plugin built specifically for DeepSeek Harness to manage multiple OpenCode Go subscription API keys. To install the plugin, you first configure the opencode-go provider in your DSH_HOME/settings.yaml file, pointing the apiKeyEnv to GO_ROTATOR_ACTIVE_KEY that the plugin maintains. Then you can install the plugin via the DSH CLI using dsh plugin --profile <profile> add ./dsh-go-rotator-0.2.0.tgz, or link the source directory directly for local development. After installation, you can optionally update your cordis.patch.yml to route your default DSH model to the opencode-go provider. Once that configuration is complete, you can run DSH normally, and the plugin will automatically sync the active key to the environment variable with no extra manual steps.

This plugin is designed for DSH users that hold multiple OpenCode Go API keys to avoid running into rate limits or quota exhaustion during regular usage. It automatically distributes load across multiple keys by routing each request to an active key parsed from the environment variable on every individual request. When a request terminates with errors like RATE_LIMIT, QUOTA_EXCEEDED, AUTH or INVALID_CREDENTIAL, it puts the current key on cooldown and automatically rotates to the next available key. It also tracks cost based on token usage from completed requests, storing rolling window stats in the state file and long-term ledgers sorted by day, month, and year in a separate stats file.

dsh-go-rotator requires DSH version 0.1.0-rc.6 or newer, and it is released under the open source MIT license. All plugin data is stored within the plugin’s install directory under the data/ subfolder, so no absolute paths are required for any user configuration. API keys are only stored locally in the plugin’s state file, and are never printed to logs or shared anywhere outside of your local system. The state file uses an atomic tmp and rename write strategy, so it is safe for concurrent access across multiple DSH processes. First run automatically initializes all required data files, and there is no legacy path detection or migration logic for existing setups.

dsh-go-rotator 是专门为 DeepSeek Harness (DSH) 开发的原生插件,作用是为 OpenCode Go 订阅密钥提供多密钥管理、负载均衡与自动轮换功能。它支持按请求路由活跃密钥,遇到速率限制、配额耗尽、认证错误等情况时自动冷却当前密钥并切换到下一个可用密钥,配合 DSH 内置的重试机制可以实现服务的无感切换。

适合同时持有多个 OpenCode Go 订阅密钥的 DSH 用户使用,可以帮助用户分摊请求负载,避免单个密钥超配额中断服务,还能自动监控和管理各密钥的配额消耗。用户安装后只需要在 DSH 的 settings.yaml 配置文件中添加 opencode-go 提供源,将路由指向插件维护的环境变量,再把默认模型路由到该提供源即可启用密钥轮换功能。

本插件采用 MIT 许可证开源,要求 DSH 版本不低于 0.1.0-rc.6,所有数据都存储在插件安装目录下的 data 文件夹中,不需要用户手动配置绝对路径。密钥仅保存在本地状态文件中,不会被打印或记入日志,状态文件采用原子写入操作,支持多进程并发安全,端口被占用时还会自动递增端口号回退。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:echo-xianyu/dsh-go-rotator

把 echo-xianyu/dsh-go-rotator 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

🔑 dsh-go-rotator

License Version DSH Platform

OpenCode Go 订阅 key 轮换器 —— 为 DeepSeek Harness(dsh)提供多 key 负载均衡、自动轮换与配额管理。

✨ 特性

  • 按请求路由 —— provider 通过 apiKeyEnv 每请求解析活跃 key,多 key 自动分摊负载;
  • 自动轮换 —— 流以 RATE_LIMIT / QUOTA_EXCEEDED / AUTH / INVALID_CREDENTIAL 错误终止时冷却当前 key 并切换(env 即时生效,错误原样上抛,内置 llm-retry 用新 key 无感重试);
  • 成本记账 —— 正常完成的流按 token 估算成本:滚动窗口(5h/周/月)入状态文件,长期账本(日/月/年)入统计文件;
  • 配额看门狗 —— 定时抓取各 key 的 dashboard 真实配额(workspaceId + authCookie),越过阈值自动禁用该 key;
  • Web 设置界面 —— dsh web 客户端设置页 + 独立 HTTP API(默认 http://localhost:7777),供外部工具读写同一状态;
  • 自包含 —— 全部数据落在插件安装目录的 data/ 下,配置永远不需要绝对路径。

📦 安装

# 1. 配置 provider 路由($DSH_HOME/settings.yaml)
#    llm-pi-ai:
#      providers:
#        opencode-go:
#          displayName: OpenCode Go
#          api: openai-completions
#          baseURL: https://opencode.ai/zen/go/v1
#          apiKeyEnv: GO_ROTATOR_ACTIVE_KEY
#          models: [ ...opencode-go 模型... ]

# 2. 安装插件(tarball / 本地目录均可)
dsh plugin --profile <profile> add ./dsh-go-rotator-0.2.0.tgz
#    或开发期直接引用源码目录:
#    dsh plugin --profile <profile> add file:/path/to/dsh-go-rotator

# 3.(可选)把默认模型路由到 opencode-go
#    $DSH_HOME/cordis.patch.yml:
#    - id: agent-default-model
#      config:
#        provider: opencode-go
#        model: deepseek-v4-flash

# 4. 运行 —— 活跃 key 由插件启动时自动同步到 env,无需手动导出
dsh --profile <profile> "hello"

需要 dsh ≥ 0.1.0-rc.6。Release 资产(tgz / 源码 zip / 校验和)见页面右侧 Releases。

⚙️ 配置

profile cordis.patch.yml 或 --patch 覆盖行 go-rotator:

键 默认 说明
stateFile <插件目录>/data/opencode-go-rotator.json 状态文件(keys、冷却、轮换日志、用量窗口;支持 ~/ 与相对路径)
statsFile 状态文件中的 statsFile(默认 <插件目录>/data/opencode-go-rotator-stats.json) 长期账本
apiKeyEnv GO_ROTATOR_ACTIVE_KEY provider 每请求解析的 env 引用
cooldownMinutes 60 出错 key 的冷却分钟数
disableThresholdPercent 97 配额使用率阈值,越过即禁用该 key
rotateOnCodes RATE_LIMIT, QUOTA_EXCEEDED, AUTH, INVALID_CREDENTIAL 触发轮换的 LlmError 码
rotateDebounceMs 3000 并发失败时的轮换防抖
scrapeIntervalMs 300000 dashboard 配额抓取间隔;0 关闭
guiPort 7777 GUI/API 端口;0 关闭(被占用时自动 +1 回退)

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev OpenFlowFrames 下一个 Next dsh-telegram →