2869949486/dsh-opencode-routing ↗★ 0

dsh-opencode-routing

dsh plugin: OpenCode account pool with automatic A-to-B failover and quota routing, plus a per-account / per-model usage dashboard, in one Settings page.

パッケージ
dsh-opencode-routing
互換性
未検証
Harness ピア範囲
^0.2.0-rc.1
バージョン
2.6.0
ライセンス
MIT
最終更新
2026/11/04

インストール

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:2869949486/dsh-opencode-routing

ドキュメント

README 全文を読む ↗

Usage dashboard

The official /inference/go/v1/usage endpoint only returns rounded rolling / weekly / monthly percentages and no per-model breakdown, while the plan meters each model separately (5 h = 20 % of the monthly allowance, week = 50 %, month = 100 %). So the page shows two sets of numbers:

  • Official percentages (one line per account): straight from the API — real account usage, including other clients and other machines.
  • Per-model money (model table): a local estimate. It rescans $DSH_HOME/sessions for the last 40 days and only counts assistant/message events whose provider starts with opencode, priced at the public rates (including DeepSeek's 2× peak window). Usage from other tools has no local record.

"查看用量" opens a per-account dialog with the three windows, their reset times and the probe result (it probes that account only and never switches models).

The peak card reports both calendars side by side — the official API and OpenCode — with the current period and how long (in hours, one decimal) until it flips. Capability chips on the model cards carry a tooltip explaining what the tag means, the header links to the OpenCode Console subscription page, and a floating arrow returns to the top once you have scrolled down. Every price cell shows the cached-input, uncached-input and output line, so a cached hit (the green row) can be compared directly with what the official API would charge for the same tokens.

Prices are not hardcoded: the plugin reads OpenCode's public pricing table (pricingUrl, daily, cached in $DSH_HOME/opencode-routing-pricing.json) and takes the plan price, every per-model rate and every monthly allowance from it. POST /opencode-usage.json with {"action":"syncPricing"} forces a refresh; pricingSync: false keeps the built-in table instead. The dialog follows the harness appearance setting (light / dark / follow system) by sampling the painted page background, so it never lands dark-on-dark.

"编辑密钥" fetches the account's current key from GET /opencode-quota-router.json?key= and pre-fills the input (a local-only endpoint; the list snapshot only ever carries a mask). Model names follow vendor casing (deepseek-v4.1-flash → DeepSeek V4.1 Flash); vendors with a published brand mark render as an inline SVG, the rest keep a letter badge. "下次探测" is a real timer (30 minutes by default) and the page re-renders every second, so it counts down; opening the page only reads the snapshot and never triggers a probe.

"此刻用哪个更划算" is derived from the subscription leverage: Go charges $10 for $100 of list-priced allowance (≈ ¥710), so OpenCode always costs 10 % of the official price — 90 % cheaper. Real data never favours the official API.

The capability column comes from the same catalog endpoint (/inference/go/v1/models): modalities.input and capabilities are rendered as text / image / video / audio / PDF, tool calls, reasoning, plus context length. Zero-priced models show "无限" (unlimited).

Peak / off-peak and holidays

DeepSeek's off-peak window is everything outside Beijing time Mon–Fri 09:00–12:00 and 14:00–18:00 (lunch break, nights, weekends and statutory holidays included) at exactly half the peak price. OpenCode only treats UTC Mon–Fri 01–04 and 06–10 as peak and ignores Chinese statutory holidays (anomalyco/opencode#53071, maintainer: "Go pricing follows our own schedule, not DeepSeek's holiday calendar.").

The plugin ships the 2026–2031 Chinese statutory holiday table. It is only applied to the official side when holidayAware: true is set (usage.holidayAware); it defaults to off because OpenCode keeps charging peak on those days. The table lives in usage.js as HOLIDAYS, and isChinaHoliday() can be called on its own.

The subscription price and its allowance can be overridden with usage.planPriceUsd / usage.planAllowanceUsd; the discount on the page is derived from those two numbers, so a plan change from OpenCode is a config edit, not a patch.