dsh-opencode-routing 0.0.0-stage → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
1
+ # OpenCode providers (Go + free) plus the merged accounts plugin.
2
+ #
3
+ # `opencode-go` keeps the installed pi-ai catalog protocol per model, but lists
4
+ # only the models the live endpoint serves today.
5
+ #
6
+ # `opencode-free` carries the free models: they are not in the shipped catalog,
7
+ # so they need a hand-declared protocol, and a static `x-opencode-session`
8
+ # header stands in for the per-session header the catalog provider adds.
9
+ #
10
+ # The insert is ONE entry: `dsh-opencode-routing` mounts the account pool /
11
+ # quota router and the usage dashboard together. `usage:` and `router:` hold the
12
+ # keys those two halves interpret differently (each one owns a `path`).
13
+ - id: llm-pi-ai
14
+ name: '@deepseek-ai/dsh-llm-pi-ai'
15
+ config:
16
+ providers:
17
+ opencode-go:
18
+ apiKeyEnv: OPENCODE_API_KEY
19
+ models:
20
+ - id: deepseek-v4.1-flash
21
+ - id: deepseek-v4-pro
22
+ - id: glm-5.2
23
+ - id: glm-5.3
24
+ - id: glm-5.3-flash
25
+ - id: grok-4.7
26
+ - id: gpt-5.6-luna
27
+ - id: gpt-6-luna
28
+ - id: claude-haiku-5-5
29
+ - id: hy3
30
+ - id: hy4-preview
31
+ - id: kimi-k2.7-code
32
+ - id: kimi-k3
33
+ - id: longcat-2.0
34
+ - id: mimo-v2.6-flash
35
+ - id: mimo-v2.6-pro
36
+ - id: minimax-m3
37
+ - id: muse-spark-1.2-contributor
38
+ - id: muse-spark-1.3-contributor
39
+ - id: qwen3.7-plus
40
+ - id: qwen3.8-flash
41
+ - id: qwen3.8-max
42
+ opencode-free:
43
+ displayName: OpenCode Go (Free)
44
+ api: openai-completions
45
+ baseURL: https://opencode.ai/inference/go/openai/v1
46
+ apiKeyEnv: OPENCODE_API_KEY
47
+ headers:
48
+ x-opencode-session: dsh-opencode-free
49
+ models:
50
+ - id: beam-free
51
+ name: Beam Free
52
+ contextWindow: 1048576
53
+ maxTokens: 131072
54
+ input: [text]
55
+ reasoningEfforts:
56
+ low: low
57
+ medium: medium
58
+ high: high
59
+ xhigh: xhigh
60
+ max: max
61
+ - id: iceman-contributor-free
62
+ name: Iceman Contributor Free
63
+ contextWindow: 262144
64
+ maxTokens: 131072
65
+ input: [text]
66
+ reasoningEfforts: false
67
+
68
+ - insert:
69
+ - id: opencode-router
70
+ name: 'dsh-opencode-routing'
71
+ config:
72
+ usageUrl: https://opencode.ai/inference/go/v1/usage
73
+ apiKeyRef: OPENCODE_API_KEY
74
+ usage:
75
+ path: /opencode-usage
76
+ plan: go
77
+ refreshSeconds: 60
78
+ router:
79
+ path: /opencode-quota-router
80
+ probeIntervalMs: 1800000
81
+ routes:
82
+ - primary:
83
+ provider: opencode-go
84
+ model: deepseek-v4.1-flash
85
+ fallback:
86
+ provider: deepseek-account
87
+ model: deepseek-flash
88
+ - primary:
89
+ provider: opencode-go
90
+ model: deepseek-v4-pro
91
+ fallback:
92
+ provider: deepseek-account
93
+ model: deepseek-v4-pro
package/icon.svg ADDED
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Per-model quota router">
2
+ <circle cx="32" cy="32" r="28" fill="none" stroke="#2f6fed" stroke-width="4" opacity="0.28"/>
3
+ <path d="M14 40a18 18 0 0 1 36 0" fill="none" stroke="#2f6fed" stroke-width="5" stroke-linecap="round"/>
4
+ <path d="M32 40 42 22" fill="none" stroke="#2f6fed" stroke-width="5" stroke-linecap="round"/>
5
+ <circle cx="32" cy="40" r="4.5" fill="#2f6fed"/>
6
+ <path d="M20 50h12m0 0-4-4m4 4-4 4" fill="none" stroke="#16a34a" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/>
7
+ <path d="M44 50H32m0 0 4-4m-4 4 4 4" fill="none" stroke="#f59e0b" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/>
8
+ </svg>
package/index.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * One package, one settings page: the account pool + quota router and the usage
3
+ * dashboard are mounted as two child plugins, so each keeps its own required
4
+ * dependencies (`llm` for routing, `webServer` for the JSON endpoints) while the
5
+ * profile only inserts a single entry.
6
+ */
7
+ import * as router from './router.js'
8
+ import * as usage from './usage.js'
9
+
10
+ export const name = 'opencode-router'
11
+ export const inject = []
12
+
13
+ /** Top-level keys apply to both children; `usage:` / `router:` objects override
14
+ * them per child (both plugins have a `path`, so the split is required). */
15
+ function partition(config) {
16
+ const base = config ?? {}
17
+ const usageConfig = { ...base, ...(base.usage ?? {}) }
18
+ const routerConfig = { ...base, ...(base.router ?? {}) }
19
+ delete usageConfig.usage
20
+ delete usageConfig.router
21
+ delete routerConfig.usage
22
+ delete routerConfig.router
23
+ return { usageConfig, routerConfig }
24
+ }
25
+
26
+ export function apply(ctx, config = {}) {
27
+ const { usageConfig, routerConfig } = partition(config)
28
+ ctx.plugin({ name: 'opencode-router:usage', inject: usage.inject, apply: usage.apply }, usageConfig)
29
+ ctx.plugin({ name: 'opencode-router:router', inject: router.inject, apply: router.apply }, routerConfig)
30
+ }
31
+
32
+ export { isChinaHoliday, peakMultiplier, peakSnapshot } from './usage.js'
33
+ export { isExhausted, retryAfter, nextProbeAt, maskKey } from './router.js'
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "OpenCode Router & Usage",
4
+ "description": "One plugin for all of OpenCode: an account pool (add a key with a note, automatic A-to-B failover, switch / disable / re-key / delete), per-account 5-hour, weekly and monthly allowance, per-model spend with capability tags (image, video, text-only, tool calls, context size), and a live \"OpenCode vs. official API\" cost comparison."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "OpenCode 路由与用量",
4
+ "description": "一个插件管完 OpenCode:账户池(填密钥+备注即可添加,自动 A→B 轮替,可切换/停用/改密钥/删除)、按账户的 5 小时 / 本周 / 本月额度、按模型的用量与能力标签(图像/视频/纯文本、工具调用、上下文长度),以及「走 OpenCode 还是官方直连更划算」的实时换算。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "dsh-opencode-routing",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.1.0",
4
+ "type": "module",
5
+ "description": "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.",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./client": "./client.js",
9
+ "./locale/*.json": "./locale/*.json",
10
+ "./icon": "./icon.svg"
11
+ },
12
+ "files": [
13
+ "index.js",
14
+ "router.js",
15
+ "usage.js",
16
+ "client.js",
17
+ "cordis.patch.yml",
18
+ "README.md",
19
+ "test.mjs",
20
+ "locale/*.json",
21
+ "icon.svg"
22
+ ],
23
+ "dsh": {
24
+ "bundle": {
25
+ "patch": "./cordis.patch.yml"
26
+ },
27
+ "client": {
28
+ "platform": "web",
29
+ "immediately": true,
30
+ "inject": [
31
+ "@deepseek-ai/dsh-client-ui-settings"
32
+ ]
33
+ }
34
+ },
35
+ "license": "MIT",
36
+ "keywords": [
37
+ "dsh",
38
+ "dsh-plugin",
39
+ "deepseek-harness",
40
+ "opencode",
41
+ "usage",
42
+ "multi-account",
43
+ "quota",
44
+ "router",
45
+ "billing"
46
+ ],
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/2869949486/dsh-opencode-routing.git"
50
+ },
51
+ "homepage": "https://github.com/2869949486/dsh-opencode-routing#readme",
52
+ "bugs": {
53
+ "url": "https://github.com/2869949486/dsh-opencode-routing/issues"
54
+ },
55
+ "engines": {
56
+ "dsh": "^0.2.0-rc.1"
57
+ }
58
+ }