dsh-opencode-go 0.1.24 → 0.2.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.
- package/README.en.md +59 -7
- package/README.md +164 -79
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/assets/icon.png +0 -0
- package/docs/advanced.en.md +15 -22
- package/docs/advanced.md +15 -22
- package/docs/assets/logo-dark.png +0 -0
- package/docs/assets/logo-light.png +0 -0
- package/docs/development.md +47 -119
- package/docs/independent-package.md +4 -2
- package/docs/usage-analytics.en.md +108 -0
- package/docs/usage-analytics.md +108 -0
- package/docs/verification.md +25 -928
- package/lib/client.js +3430 -2473
- package/lib/index.js +2650 -2440
- package/lib/types/accounts.d.ts +96 -31
- package/lib/types/adapter.d.ts +45 -48
- package/lib/types/analytics.d.ts +345 -0
- package/lib/types/catalog.d.ts +112 -6
- package/lib/types/client/AnalyticsDialog.d.ts +25 -0
- package/lib/types/client/Section.d.ts +51 -7
- package/lib/types/client/UsagePill.d.ts +6 -4
- package/lib/types/client/controller.d.ts +176 -0
- package/lib/types/client/index.d.ts +9 -12
- package/lib/types/client/{locales.d.ts → presentation.d.ts} +124 -0
- package/lib/types/config.d.ts +9 -14
- package/lib/types/contracts.d.ts +283 -0
- package/lib/types/conversion.d.ts +147 -0
- package/lib/types/index.d.ts +7 -39
- package/lib/types/sdk-types.d.ts +5 -54
- package/lib/types/transport.d.ts +63 -0
- package/lib/vendor-licenses.txt +36 -36
- package/package.json +76 -77
- package/docs/fork-review-2026-09-25.md +0 -191
- package/docs/native-call-comparison-v020-rc2.md +0 -116
- package/lib/types/account-manager.d.ts +0 -25
- package/lib/types/account-operations.d.ts +0 -31
- package/lib/types/account-policy.d.ts +0 -16
- package/lib/types/account-recovery.d.ts +0 -2
- package/lib/types/account-selection.d.ts +0 -30
- package/lib/types/account-service.d.ts +0 -12
- package/lib/types/accounts-contract.d.ts +0 -38
- package/lib/types/call-trace.d.ts +0 -54
- package/lib/types/catalog-manager.d.ts +0 -20
- package/lib/types/client/AccountsCard.d.ts +0 -19
- package/lib/types/client/ModelEditor.d.ts +0 -20
- package/lib/types/client/accounts-controller.d.ts +0 -71
- package/lib/types/client/hint-mark.d.ts +0 -17
- package/lib/types/client/host-compat.d.ts +0 -7
- package/lib/types/client/host-primitives.d.ts +0 -11
- package/lib/types/client/section-controller.d.ts +0 -202
- package/lib/types/client/settings.d.ts +0 -18
- package/lib/types/client/staged-form.d.ts +0 -201
- package/lib/types/client/usage.d.ts +0 -4
- package/lib/types/config-contract.d.ts +0 -70
- package/lib/types/conversion/config.d.ts +0 -4
- package/lib/types/conversion/context.d.ts +0 -56
- package/lib/types/conversion/image-offload.d.ts +0 -13
- package/lib/types/conversion/image-pool.d.ts +0 -24
- package/lib/types/conversion/index.d.ts +0 -5
- package/lib/types/conversion/replay.d.ts +0 -66
- package/lib/types/conversion/stream.d.ts +0 -44
- package/lib/types/gateway-diagnostics.d.ts +0 -23
- package/lib/types/gateway-error.d.ts +0 -2
- package/lib/types/gateway-url.d.ts +0 -6
- package/lib/types/google-fetch.d.ts +0 -6
- package/lib/types/host-settings.d.ts +0 -11
- package/lib/types/json-response.d.ts +0 -14
- package/lib/types/metadata-cache.d.ts +0 -12
- package/lib/types/model-metadata.d.ts +0 -21
- package/lib/types/models-contract.d.ts +0 -66
- package/lib/types/models.d.ts +0 -13
- package/lib/types/protocol-contract.d.ts +0 -5
- package/lib/types/protocol-policy.d.ts +0 -4
- package/lib/types/provider-identity.d.ts +0 -4
- package/lib/types/proxy-url.d.ts +0 -2
- package/lib/types/proxy.d.ts +0 -11
- package/lib/types/reasoning.d.ts +0 -40
- package/lib/types/remote-contract.d.ts +0 -3
- package/lib/types/remotes.d.ts +0 -3
- package/lib/types/request-budget.d.ts +0 -12
- package/lib/types/request-control.d.ts +0 -2
- package/lib/types/settings-bridge.d.ts +0 -22
- package/lib/types/usage-contract.d.ts +0 -35
- package/lib/types/usage-display.d.ts +0 -4
- package/lib/types/usage.d.ts +0 -27
- /package/lib/types/{google-generative-ai.d.ts → google.d.ts} +0 -0
package/README.en.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.png">
|
|
4
|
+
<img src="docs/assets/logo-light.png" alt="DSH-OCGO" width="480">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
<h1 align="center">dsh-opencode-go</h1>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="README.md">简体中文</a>
|
|
12
|
+
</p>
|
|
4
13
|
|
|
5
14
|
**OpenCode Go subscription usage and multiple-account management** for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), with convenient access to quotas, reset times, and account switching.
|
|
6
15
|
|
|
@@ -28,6 +37,20 @@ Under **Settings → OpenCode Go → Advanced settings → Usage display**, choo
|
|
|
28
37
|
| Always | Also show configured OpenCode Go account usage while using other models |
|
|
29
38
|
| Off | Hide the conversation pill and stop its polling |
|
|
30
39
|
|
|
40
|
+
## Usage analytics
|
|
41
|
+
|
|
42
|
+
Open **Usage analytics** at the bottom of the conversation usage panel, or under **Settings → OpenCode Go → Usage analytics**. Both open the same dashboard. It covers **this plugin's route**, including closed sessions, totals input, output, and cache tokens per model, and estimates cost with the Go plan's models.dev prices.
|
|
43
|
+
|
|
44
|
+
- Ranges: today, 7 days, 30 days, and 90 days. Opening scans local sessions without uploading their contents; closing the dialog stops the request. Model and pricing metadata may refresh from [models.dev](https://models.dev/api.json), without sending it conversation content, account keys or per-request analytics. Normal inference sends request content to your configured model gateway, which also serves quota queries; there is no additional telemetry or analytics service.
|
|
45
|
+
- Cost uses the request start time. DeepSeek V4.1 Flash and V4 Pro are charged at twice the off-peak rate during the official peak window (01:00–04:00 and 06:00–10:00 UTC, Monday through Friday).
|
|
46
|
+
- Each model row shows only the display name and usage figures. Official quota percentages remain authoritative; the estimate is not an invoice.
|
|
47
|
+
- A scan stops at 500 sessions, 500,000 events, or 12 seconds by default and says so, including why. **Scan more history** raises the session cap to 2,000; the choice is remembered locally. Session folds are reused in memory for at most five seconds and scanned again after a restart; no fold cache is written to disk.
|
|
48
|
+
- DSH's native OpenCode Go route is excluded; pre-0.1.16 legacy route records are admitted by request time. A Host without `sessionQuery` shows an unavailable state.
|
|
49
|
+
|
|
50
|
+
**Themes**: switch between **Silent Black, Graphite (default), Sea Salt, and Warm Sand** under **Settings → OpenCode Go → Usage analytics**; the four previews show each palette directly. Themes follow DSH's light/dark mode and are stored locally. The pill popover and the dashboard no longer carry their own switch. The pill no longer carries the `Go ·` prefix; with multiple accounts it shows the active account's full name, truncated with an ellipsis when long, with the complete name kept in the button title and the expanded panel.
|
|
51
|
+
|
|
52
|
+
See [usage analytics notes](docs/usage-analytics.en.md) for the exact accounting rules and limits.
|
|
53
|
+
|
|
31
54
|
## Manage multiple accounts
|
|
32
55
|
|
|
33
56
|
Open **Settings → OpenCode Go → Accounts** to manage accounts:
|
|
@@ -39,13 +62,15 @@ Open **Settings → OpenCode Go → Accounts** to manage accounts:
|
|
|
39
62
|
- Drag a row's handle to reorder accounts. The first row becomes current, and the order determines automatic fallback priority.
|
|
40
63
|
- Click **Switch** in the conversation usage panel to move the selected account first for subsequent requests in this profile. The other accounts keep their relative order.
|
|
41
64
|
|
|
42
|
-
With **Automatic fallback** enabled,
|
|
65
|
+
With **Automatic fallback** enabled, HTTP 401/403/429 or exhausted quota causes the plugin to try other accounts in order before output begins. A fallback account that starts producing output moves first and becomes current, and the usage panel shows a switch notice. Requests that have already produced output, recorded token usage, or been canceled are not automatically resent through another account.
|
|
66
|
+
|
|
67
|
+
Gateway-rejected keys cool down in memory for five minutes. Account commands write credentials and settings through one serial host queue.
|
|
43
68
|
|
|
44
69
|
Keys are saved through DSH's credential service. Settings never displays an already saved key.
|
|
45
70
|
|
|
46
71
|
## Install and get started
|
|
47
72
|
|
|
48
|
-
Requires DSH `0.1
|
|
73
|
+
Requires DSH `0.2.1-rc.5` or later. See [development](docs/development.md) for the current validation workflow.
|
|
49
74
|
|
|
50
75
|
### Install from DSH
|
|
51
76
|
|
|
@@ -71,7 +96,7 @@ Start or restart `dsh web` after command-line installation. Web and Headless use
|
|
|
71
96
|
|
|
72
97
|
### Get started
|
|
73
98
|
|
|
74
|
-
1. Open **Settings → OpenCode Go**, enter your OpenCode Go subscription API key and
|
|
99
|
+
1. Open **Settings → OpenCode Go → Accounts**, click **Add account**, enter a name and your OpenCode Go subscription API key, and confirm.
|
|
75
100
|
2. Select a model under **DSH OpenCode Go** in the conversation model picker.
|
|
76
101
|
3. Start chatting and check usage beside the input. With multiple accounts, open the panel to switch.
|
|
77
102
|
|
|
@@ -117,13 +142,13 @@ Restart `dsh web` and reload the page afterward. For desktop DSH, quit and reope
|
|
|
117
142
|
|
|
118
143
|
**Why is usage hidden?** Auto mode shows it only for **DSH OpenCode Go** models. Check that the plugin is enabled, a key is configured, and the display mode is appropriate. Choose Always to show usage with other providers.
|
|
119
144
|
|
|
120
|
-
**What if usage queries or account additions fail?** Retry in the usage panel or refresh usage in the account card.
|
|
145
|
+
**What if usage queries or account additions fail?** Retry in the usage panel or refresh usage in the account card. Account actions run in a serial host queue; unsuccessful operations can be retried. See [account operations and saving](docs/advanced.en.md#account-operations-and-saving).
|
|
121
146
|
|
|
122
147
|
**What if a long conversation keeps returning 400?** Check the output allowance and context window in the error, then run `/compact` or lower that model's **Max output** before retrying. Explicit context overflow is passed to DSH's recovery mechanism; an unexplained 400 keeps its classification and includes troubleshooting guidance. Failed attempts without measured tokens omit zero usage so they do not report an empty context.
|
|
123
148
|
|
|
124
149
|
**Why does an old conversation need its model selected again?** When upgrading from `0.1.16` or earlier, select **DSH OpenCode Go** again in existing conversations or Agent presets. Manual configurations use `provider: dsh-opencode-go`.
|
|
125
150
|
|
|
126
|
-
**Which
|
|
151
|
+
**Which host is targeted?** The development baseline is DSH `0.2.1-rc.5`. Developer messages, dynamic tool additions/removals, and deferred tool loading are explicitly rejected; see [development and testing](docs/development.md).
|
|
127
152
|
|
|
128
153
|
Uninstall:
|
|
129
154
|
|
|
@@ -131,9 +156,36 @@ Uninstall:
|
|
|
131
156
|
dsh plugin --profile web remove dsh-opencode-go
|
|
132
157
|
```
|
|
133
158
|
|
|
159
|
+
## Architecture and verification
|
|
160
|
+
|
|
161
|
+
The source contains 17 implementation modules:
|
|
162
|
+
|
|
163
|
+
| Domain | Modules |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| Plugin composition, settings and contracts | `index.ts`, `config.ts`, `contracts.ts` |
|
|
166
|
+
| Requests, model catalog and protocol conversion | `adapter.ts`, `catalog.ts`, `conversion.ts`, `google.ts`, `sdk-types.ts` |
|
|
167
|
+
| Accounts, official quota, local analytics and transport | `accounts.ts`, `analytics.ts`, `transport.ts` |
|
|
168
|
+
| Browser registration and typed state | `client/index.ts`, `client/controller.ts` |
|
|
169
|
+
| Settings, account/model controls, usage, themes and copy | `client/Section.tsx`, `client/UsagePill.tsx`, `client/AnalyticsDialog.tsx`, `client/presentation.ts` |
|
|
170
|
+
|
|
171
|
+
The browser uses DSH's `configForms`; capacities remain typed objects while editing. Images use per-request count and encoded-byte budgets, with at most four preparations per request. The package keeps its `.` and `./client` exports. Development dependencies pin DSH `0.2.1-rc.5` and Cordis `4.0.5`; runtime Cordis requires `~4.0.5`.
|
|
172
|
+
|
|
173
|
+
Use Node.js `^22.19.0 || >=24.0.0`:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
npm ci
|
|
177
|
+
npm test
|
|
178
|
+
npm run typecheck
|
|
179
|
+
npm run check:dist
|
|
180
|
+
npm run verify
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Twelve test files cover host services, accounts, catalog, protocols, analytics, transport and browser interactions. After changing source, run `npm run compile` to rebuild `lib/`. `verify` runs type checks, artifact comparison, the full test suite and the package-loading smoke. See [development](docs/development.md) for separate installed-consumer and Headless checks.
|
|
184
|
+
|
|
134
185
|
## More documentation
|
|
135
186
|
|
|
136
187
|
- [Advanced guide: Headless, proxies, manual configuration, and error diagnostics](docs/advanced.en.md)
|
|
188
|
+
- [Usage analytics: accounting, pricing, scan limits, and privacy](docs/usage-analytics.en.md)
|
|
137
189
|
- [Development and testing](docs/development.md)
|
|
138
190
|
- [Verification notes](docs/verification.md)
|
|
139
191
|
- [Issues and suggestions](https://github.com/Duskriver/dsh-opencode-go/issues)
|
package/README.md
CHANGED
|
@@ -1,140 +1,225 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.png">
|
|
4
|
+
<img src="docs/assets/logo-light.png" alt="DSH-OCGO" width="480">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
<h1 align="center">dsh-opencode-go</h1>
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="README.en.md">English</a> · <a href="#常见问题-faq">常见问题</a> · <a href="docs/advanced.md">高级指南</a> · <a href="docs/development.md">开发与测试</a>
|
|
12
|
+
</p>
|
|
6
13
|
|
|
7
|
-
DSH
|
|
14
|
+
为 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) 量身打造的 **OpenCode Go 专属接入与多账号管理插件**。
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
- **多个账号集中管理**:查看各账号额度和 Key 状态,拖动排序,在会话中手动切换,也可开启自动使用备用账号。
|
|
11
|
-
- **模型与设置更直观**:搜索和筛选模型,调整显示、容量与思考预算;高级设置按用途分组,提供提示与恢复默认操作。
|
|
16
|
+
DSH 原生支持接入 OpenCode Go,但原生模式无法满足复杂的生产与日常开发需求(如多账号无感容灾、会话级 Prompt 缓存绑定、会话内实时额度透视等)。本插件基于 Cordis 微内核架构,在提供完整模型协议转换的同时,带来了流畅的客户端 UI 与企业级容灾体验。
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
---
|
|
14
19
|
|
|
15
|
-
##
|
|
20
|
+
## ✨ 核心特性
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
- 🛡️ **多账号无感容灾**:支持最多 20 个账号集中管理与拖拽排序。当主账号额度耗尽或 Key 失效时,**在输出前自动尝试备用账号**,成功后自动扶正,告别“聊到一半额度没了”的打断感。
|
|
23
|
+
- ⚡ **会话级 Prompt 缓存绑定**:严格遵循网关协议注入专有 `x-opencode-session` 路由头,稳定复用网关上下文缓存,显著降低响应首字延迟。
|
|
24
|
+
- 📊 **会话内额度实时透视**:在聊天输入框旁常驻“用量胶囊”,直观展示 5 小时滚动、每周、每月的额度百分比及重置时间倒计时;支持休眠节能与静默刷新。
|
|
25
|
+
- 💰 **本地用量看板**:在本地扫描会话历史,按模型与峰谷时段统计 Token 消耗与估算开销,不上传统计所用的会话内容;模型和价格元数据从 models.dev 联网刷新。
|
|
26
|
+
- 🎛️ **模型与热配置**:无需重启 DSH!随时在线调整模型上下文窗口、最大输出上限、思考预算(Thinking Budget),并支持 HTTP/HTTPS/SOCKS5 代理。
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🚀 快速开始
|
|
31
|
+
|
|
32
|
+
适用于 DSH `0.2.1-rc.5` 及以上版本;开发与验证方式见[开发说明](docs/development.md)。
|
|
33
|
+
|
|
34
|
+
### 1. 安装插件
|
|
35
|
+
|
|
36
|
+
#### 方式 A:在 DSH 界面中一键安装(推荐)
|
|
37
|
+
1. 打开 DSH,进入 **插件 → 添加插件**。
|
|
38
|
+
2. 输入 `dsh-opencode-go`(或填入仓库地址 `https://github.com/Duskriver/dsh-opencode-go`),点击 **安装**。
|
|
39
|
+
3. 安装完成后点击 **立即启用**。
|
|
20
40
|
|
|
21
|
-
|
|
41
|
+

|
|
22
42
|
|
|
23
|
-
|
|
43
|
+
#### 方式 B:命令行安装
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile web add dsh-opencode-go
|
|
46
|
+
```
|
|
47
|
+
*命令行安装后请重启 `dsh web`。Headless 用户请使用 `--profile headless`。*
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| 关闭 | 隐藏会话用量胶囊并停止其轮询 |
|
|
49
|
+
### 2. 配置与使用
|
|
50
|
+
1. 打开 **设置 → OpenCode Go → 账号**,点击添加,填写账号名称与 OpenCode Go API Key 后确认。
|
|
51
|
+
2. 在任意会话的模型选择器中,选择 **DSH OpenCode Go** 目录下的模型。
|
|
52
|
+
3. 开始对话,输入区右下角即可看到实时的用量胶囊。
|
|
30
53
|
|
|
31
|
-
|
|
54
|
+
---
|
|
32
55
|
|
|
33
|
-
|
|
56
|
+
## 💡 深度功能与运行机制
|
|
57
|
+
|
|
58
|
+
### 1. 多账号管理与无感容灾(Auto-failover)
|
|
59
|
+
|
|
60
|
+
在 **设置 → OpenCode Go → 账号** 中集中管理你的所有账号:
|
|
34
61
|
|
|
35
62
|

|
|
36
63
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
64
|
+
- **拖拽排序即优先级**:列表第一项为当前主账号;鼠标拖拽左侧手柄调整顺序,这个顺序也是自动尝试备用账号的优先次序。
|
|
65
|
+
- **出词前无感切换**:开启“自动使用备用账号”后,若当前账号在发出请求后遇到了 **401/403 鉴权失败、429 限流或 Quota 额度耗尽**:
|
|
66
|
+
- 插件会在**开始向你输出文字前**,静默挑出下一个备用账号重新发送请求。
|
|
67
|
+
- 成功出词的备用账号会自动移至首位成为新主账号,并在会话面板给出切换提示。
|
|
68
|
+
- *防御机制*:若模型已经开始吐字或已产生计费,插件不会切换,避免拼接乱码或重复扣费。
|
|
69
|
+
- **防雪崩冷却黑名单**:被网关拒绝的 Key 会进入 5 分钟的内存冷却名单,避免短时间内反复向已失效的账号发起无意义的重试。
|
|
70
|
+
- **凭据安全隔离**:Key 直接存储至 DSH 底层凭据系统,前端界面永远不会回显明文密钥。
|
|
41
71
|
|
|
42
|
-
|
|
72
|
+
### 2. 会话内订阅额度透视(UsagePill)
|
|
43
73
|
|
|
44
|
-
|
|
74
|
+
在聊天输入区旁,常驻有直观的“用量胶囊”。点击即可展开完整的用量卡片:
|
|
45
75
|
|
|
46
|
-
|
|
76
|
+

|
|
47
77
|
|
|
48
|
-
|
|
78
|
+
- **三窗口精准监控**:
|
|
79
|
+
- 🟢 **5 小时滚动配额**:短周期高频使用的健康度。
|
|
80
|
+
- 🟡 **每周配额**:本周累计使用进度。
|
|
81
|
+
- 🔴 **每月配额**:月度套餐消耗百分比。
|
|
82
|
+
每个窗口均显示精确的重置倒计时;进度条会随着接近上限变黄,耗尽时变红。
|
|
83
|
+
- **节能与防抖机制**:默认每分钟静默刷新;当页面切入后台或浏览器最小化时**自动暂停轮询**,切换回前台时即时刷新。
|
|
84
|
+
- **账号全名与快速切换**:多账号时直接显示当前账号全名(名字过长以省略号截断),展开面板点击“切换”即可直接提拔目标账号为主账号。
|
|
85
|
+
- **显示模式**(在 **高级设置 → 额度显示** 中配置):
|
|
86
|
+
- **自动(默认)**:仅在使用 DSH OpenCode Go 模型时显示。
|
|
87
|
+
- **常驻**:切换到其他厂商模型时,仍然保持胶囊显示。
|
|
88
|
+
- **关闭**:隐藏胶囊并停止后台用量轮询。
|
|
49
89
|
|
|
50
|
-
###
|
|
90
|
+
### 3. 用量与开销看板(Analytics)
|
|
51
91
|
|
|
52
|
-
|
|
53
|
-
2. 输入 `dsh-opencode-go`,点击 **安装**。
|
|
54
|
-
3. 安装完成后点击 **立即启用**。
|
|
92
|
+
点击用量面板底部的 **用量统计**,或进入 **设置 → OpenCode Go → 用量统计** 即可唤出看板:
|
|
55
93
|
|
|
56
|
-
|
|
94
|
+
- **本地扫描与缓存**:直接调用 DSH 宿主 `sessionQuery` 扫描本地历史会话,统计本插件产生的 Token 消耗,不会为统计上传会话内容。模型和价格元数据会从 models.dev 联网刷新。会话折叠结果仅在内存中最多复用 5 秒,重启后重新扫描,不写入磁盘缓存。
|
|
95
|
+
- **峰谷电价式开销估算**:使用从 models.dev 获取的模型价格;自动识别 DeepSeek V4.1 Flash / V4 Pro 等模型的官方峰时时段(UTC 周一至周五 01:00–04:00、06:00–10:00)并按双倍费率估算金额。
|
|
96
|
+
- **四款专属主题**:支持在 **寂静黑 / 石墨(默认)/ 海盐青 / 暖砂** 之间切换,自动适配系统的亮色/暗色模式。
|
|
57
97
|
|
|
58
|
-
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🛠️ 架构设计与工作原理
|
|
101
|
+
|
|
102
|
+
源码按领域收敛为 17 个实现模块,宿主与浏览器通过 DSH Typert RPC 通讯:
|
|
59
103
|
|
|
60
104
|
```text
|
|
61
|
-
|
|
105
|
+
src/
|
|
106
|
+
├── index.ts + config.ts 插件挂载、configure 设置与热更新
|
|
107
|
+
├── contracts.ts 浏览器可用的配置、模型与 RPC 契约
|
|
108
|
+
├── adapter.ts 请求执行、会话头、容灾与冷却
|
|
109
|
+
├── catalog.ts 模型目录与公共元数据缓存
|
|
110
|
+
├── conversion.ts 上下文、单次请求图片预算、回放与流转换
|
|
111
|
+
├── google.ts + sdk-types.ts Google SDK 接入与公开类型
|
|
112
|
+
├── accounts.ts 串行账号命令、凭据写入与官方配额
|
|
113
|
+
├── analytics.ts 本地统计、内存会话缓存与计价
|
|
114
|
+
├── transport.ts HTTP/HTTPS/SOCKS5、超时与脱敏错误
|
|
115
|
+
└── client/
|
|
116
|
+
├── index.ts + controller.ts configForms 接入、类型化草稿与账号操作
|
|
117
|
+
├── Section.tsx 设置页、账号卡片、模型编辑器与主题选择
|
|
118
|
+
├── UsagePill.tsx 会话额度胶囊
|
|
119
|
+
├── AnalyticsDialog.tsx 用量与费用看板
|
|
120
|
+
└── presentation.ts 多语言、主题与显示格式
|
|
62
121
|
```
|
|
63
122
|
|
|
64
|
-
|
|
123
|
+
账号操作在内存串行队列中直接更新凭据与设置。模型容量草稿始终保留为对象;图片按单次请求限制数量、编码字节及最多四路并行准备。宿主仅使用 DSH `0.2.1-rc.5` 起提供的设置与图片卸载接口。包的 `.` 与 `./client` 导出路径保持不变。
|
|
65
124
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```
|
|
125
|
+
### 为什么必须要携带 `x-opencode-session`?
|
|
126
|
+
OpenCode Go 网关具有会话粘性路由与上下文缓存共享能力。插件会自动将你的 DSH 对话 ID 经过单向哈希(保留可读字符并在需要时转为安全散列),以稳定的形式放入 `x-opencode-session` 请求头中。这样不仅能让多轮对话始终落在同一推理节点上,还能最大化命中网关的 Prompt Cache,显著节省思考与生成时间。
|
|
69
127
|
|
|
70
|
-
|
|
128
|
+
---
|
|
71
129
|
|
|
72
|
-
|
|
130
|
+
## ⚙️ 模型自定义与高级配置
|
|
73
131
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
3. 开始对话,在输入区旁查看用量;有多个账号时可展开面板切换。
|
|
132
|
+
### 模型参数覆盖
|
|
133
|
+
进入 **设置 → OpenCode Go → 可用模型**:
|
|
77
134
|
|
|
78
|
-
|
|
135
|
+

|
|
79
136
|
|
|
80
|
-
|
|
137
|
+
- **显示开关**:自由隐藏不常用的模型,净化聊天选择器。
|
|
138
|
+
- **容量与上下文覆盖**:可手动指定上下文窗口(Context Window)与单次最大输出 Token。
|
|
139
|
+
- **思考预算(Thinking Budget)**:对支持深度思考的模型,可自定义思考强度等级或 Token 预算。
|
|
140
|
+
- *特别规则*:`deepseek-v4.1-flash` 默认自动配置 **64k (65,536 tokens)** 输出预算,并将该上限通知 DSH 宿主,用于计算上下文压缩时机。
|
|
81
141
|
|
|
82
|
-
###
|
|
142
|
+
### 分组高级设置
|
|
143
|
+
支持在 **设置 → OpenCode Go → 高级设置** 中按需微调:
|
|
83
144
|
|
|
84
|
-
|
|
145
|
+

|
|
85
146
|
|
|
86
|
-
|
|
147
|
+
- **网络代理**:支持填入 HTTP、HTTPS 或 SOCKS5 代理地址(如 `socks5://127.0.0.1:1080`),保存后即时应用于对话、用量查询与模型刷新。
|
|
148
|
+
- **超时控制**:分别支持配置请求准备超时(`requestPreparationTimeoutMs`)、整轮请求超时(`requestTimeoutMs`)以及流空闲看门狗阈值(`streamIdleTimeoutMs`)。
|
|
149
|
+
- **一键恢复默认**:点击每张卡片的“全部恢复默认”可一键清空自定义覆盖,不影响已保存的账号 Key。
|
|
87
150
|
|
|
88
|
-
|
|
89
|
-
- 选中模型可查看目录提供的上下文窗口、最大输出和输入模态,容量覆盖保存后生效,留空使用默认值。
|
|
90
|
-
- 支持思考的模型提供相应开关、强度或 token 预算选项;预算式模型还可添加自定义预算并保存。
|
|
151
|
+
---
|
|
91
152
|
|
|
92
|
-
|
|
153
|
+
## ❓ 常见问题 (FAQ)
|
|
93
154
|
|
|
94
|
-
|
|
155
|
+
<details>
|
|
156
|
+
<summary><strong>Q: 为什么聊天输入区没有出现用量胶囊?</strong></summary>
|
|
95
157
|
|
|
96
|
-
|
|
158
|
+
1. 检查当前会话选中的模型是否为 **DSH OpenCode Go** 分组下的模型。默认“自动”模式仅在选择本插件模型时展示;若希望在使用其他模型时也看到配额,可在 **高级设置 → 额度显示** 中切为“常驻”。
|
|
159
|
+
2. 检查是否已在设置中填入有效 API Key 且插件已处于启用状态。
|
|
160
|
+
</details>
|
|
97
161
|
|
|
98
|
-
|
|
162
|
+
<details>
|
|
163
|
+
<summary><strong>Q: 为什么长会话中偶尔会报 400 错误?</strong></summary>
|
|
99
164
|
|
|
100
|
-
|
|
165
|
+
通常是因为单次上下文加输出预算超过了模型允许的 Context Window。建议:
|
|
166
|
+
1. 在会话中执行 `/compact` 指令压缩历史消息。
|
|
167
|
+
2. 或在 **可用模型** 设置中,适度调低该模型的“最大输出”上限。
|
|
168
|
+
明确的上下文超限错误会被插件捕获并交由 DSH 原生恢复机制处理。
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
<details>
|
|
172
|
+
<summary><strong>Q: 升级插件后,旧会话找不到模型怎么办?</strong></summary>
|
|
173
|
+
|
|
174
|
+
从 `0.1.16` 及更早版本升级时,底层 Provider ID 进行了规范化统一。只需在旧会话或 Agent 配置的模型下拉框中,重新选择一次 **DSH OpenCode Go** 下的模型即可。
|
|
175
|
+
</details>
|
|
101
176
|
|
|
102
|
-
|
|
177
|
+
<details>
|
|
178
|
+
<summary><strong>Q: 插件在执行过程中会自动将我的数据上传到第三方吗?</strong></summary>
|
|
103
179
|
|
|
104
|
-
|
|
180
|
+
正常对话会把请求内容发送到你配置的模型网关(默认为 OpenCode Go 官方网关),额度查询也会访问该网关。插件还会从 [models.dev](https://models.dev/api.json) 下载公开的模型能力与价格元数据。
|
|
105
181
|
|
|
106
|
-
|
|
182
|
+
用量统计在本地读取会话记录,不会把会话正文、账号密钥或逐条统计记录发送给 models.dev,也没有额外的遥测或分析服务。因此,本地统计不等于插件完全不联网。
|
|
183
|
+
</details>
|
|
107
184
|
|
|
108
|
-
|
|
185
|
+
---
|
|
109
186
|
|
|
110
|
-
|
|
187
|
+
## 📦 更新与卸载
|
|
111
188
|
|
|
189
|
+
### 更新插件
|
|
112
190
|
```sh
|
|
113
191
|
dsh plugin --profile web update dsh-opencode-go --latest
|
|
114
192
|
```
|
|
193
|
+
更新后重启 `dsh web` 并刷新浏览器页面(桌面客户端请完全退出后重新打开)。
|
|
115
194
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
**查询失败或添加账号中断怎么办?** 用量查询可在面板中重试,或在账号卡片中刷新额度。未成功保存 Key 的新增账号可补填 Key 或删除;账号操作的恢复机制见[高级使用指南](docs/advanced.md#账号操作与保存)。
|
|
121
|
-
|
|
122
|
-
**长会话持续报 400 怎么办?** 检查错误中的输出预算与上下文窗口,可执行 `/compact` 或调低该模型的「最大输出」后重试。明确的上下文超限会交给 DSH 的恢复机制;原因不明的 400 会保留原分类并给出排查建议。失败且未取得 token 用量时,插件不发送全零用量,避免将上下文占用误报为 0%。
|
|
195
|
+
### 卸载插件
|
|
196
|
+
```sh
|
|
197
|
+
dsh plugin --profile web remove dsh-opencode-go
|
|
198
|
+
```
|
|
123
199
|
|
|
124
|
-
|
|
200
|
+
---
|
|
125
201
|
|
|
126
|
-
|
|
202
|
+
## 🧪 开发与验证
|
|
127
203
|
|
|
128
|
-
|
|
204
|
+
使用 Node.js `^22.19.0 || >=24.0.0`,开发依赖锁定 DSH `0.2.1-rc.5`、Cordis `4.0.5`;宿主 Cordis 要求 `~4.0.5`。
|
|
129
205
|
|
|
130
206
|
```sh
|
|
131
|
-
|
|
207
|
+
npm ci
|
|
208
|
+
npm test
|
|
209
|
+
npm run typecheck
|
|
210
|
+
npm run check:dist
|
|
211
|
+
npm run verify
|
|
132
212
|
```
|
|
133
213
|
|
|
134
|
-
|
|
214
|
+
测试按 12 个领域文件覆盖宿主、协议转换、账号、统计、传输和前端。修改源码后先运行 `npm run compile` 更新 `lib/`;`verify` 包含类型检查、产物一致性、全量测试与包加载冒烟。独立安装和 Headless 验证见[开发说明](docs/development.md)。
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 📚 更多文档与链接
|
|
135
219
|
|
|
136
|
-
- [
|
|
137
|
-
- [
|
|
138
|
-
- [
|
|
139
|
-
- [
|
|
140
|
-
- [
|
|
220
|
+
- 📖 [高级使用指南(Headless 部署、代理策略与错误排查)](docs/advanced.md)
|
|
221
|
+
- 📊 [用量看板统计说明(计价口径与扫描策略)](docs/usage-analytics.md)
|
|
222
|
+
- 🛠️ [开发与贡献指南](docs/development.md)
|
|
223
|
+
- 🧪 [验收范围与验证记录](docs/verification.md)
|
|
224
|
+
- 🐛 [提交 Issue 与建议](https://github.com/Duskriver/dsh-opencode-go/issues)
|
|
225
|
+
- 📄 [MIT 开源许可证](LICENSE)
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
The initial adapter, settings UI, and `src/conversion
|
|
3
|
+
The initial adapter, settings UI, and `src/conversion.ts` were derived from DeepSeek Harness, copyright (c) 2026 DeepSeek, under the MIT license included in LICENSE. The original DeepSeek copyright notice is retained for these derived portions. The conversion code is maintained in this package because the published DSH pi-ai package does not export its conversion helpers.
|
|
4
4
|
|
|
5
5
|
Original additions and subsequent modifications made in this project are copyright (c) 2026 dsh-opencode-go contributors and are also licensed under MIT. LICENSE records both the upstream attribution and this project's contributor attribution.
|
|
6
6
|
|
package/assets/icon.png
ADDED
|
Binary file
|
package/docs/advanced.en.md
CHANGED
|
@@ -89,7 +89,7 @@ Keep the options you need and supply the corresponding keys through DSH credenti
|
|
|
89
89
|
|
|
90
90
|
| Option | Purpose |
|
|
91
91
|
| --- | --- |
|
|
92
|
-
| `baseURL` |
|
|
92
|
+
| `baseURL` | OpenCode Go gateway address; defaults to `https://opencode.ai/inference/go/v1`, with official inference endpoints selected by model protocol |
|
|
93
93
|
| `usageDisplay` | Usage display mode: `auto`, `always`, or `off` |
|
|
94
94
|
| `proxyURL` | Network proxy; an empty string uses the default network settings |
|
|
95
95
|
| `refreshMinutes` | Model catalog cache lifetime; defaults to 60 minutes, with manual refresh available in Settings |
|
|
@@ -101,37 +101,30 @@ Keep the options you need and supply the corresponding keys through DSH credenti
|
|
|
101
101
|
| `requestPreparationTimeoutMs` | Deadline for discovery and each attempt's credential/image preparation; defaults to 60000 milliseconds |
|
|
102
102
|
| `requestTimeoutMs` | Whole dispatch deadline, including discovery, account fallback and streaming; defaults to 1800000 milliseconds. Prepared calls start this timer at dispatch |
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
The default official gateway lists models at `GET https://opencode.ai/inference/go/v1/models` and reads usage at `GET https://opencode.ai/inference/go/v1/usage`. Inference follows each model's declared protocol and the [official endpoint documentation](https://opencode.ai/v2/docs/console/go/#endpoints). The following paths share the prefix `https://opencode.ai/inference/go`:
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
| Model protocol | Inference path |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| OpenAI Chat Completions, such as GLM-5.3-Flash | `/openai/v1/chat/completions` |
|
|
109
|
+
| OpenAI Responses, such as Grok 4.7 and GPT 6 Luna | `/openai/v1/responses` |
|
|
110
|
+
| Anthropic Messages, such as Claude Haiku 5.5 | `/anthropic/v1/messages` |
|
|
111
|
+
| Google, such as Gemini 4 Argon Contributor | `/google/v1beta/models/{model}:streamGenerateContent` |
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
The legacy official base `https://opencode.ai/zen/go/v1` migrates automatically, and settings writes store the new address. There is no need to change the gateway for each model. Custom gateways keep the configured `baseURL` prefix and let each protocol SDK append its resource path; official protocol segments are not added automatically. A working listing does not verify every inference route.
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
Usage failures retain the HTTP status and show a redacted summary when the upstream provides a readable reason. HTTP 403 includes a reminder to check the API key and Go subscription permissions. “Key saved” only confirms local credential storage; check the subscription for the account or workspace that owns the key, along with the gateway and proxy settings.
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
export DSH_OPENCODE_GO_DEBUG_DIR=/tmp/dsh-opencode-go-debug
|
|
118
|
-
dsh web
|
|
119
|
-
```
|
|
117
|
+
Image offloading keeps the original attachment and replaces the old image in the request with a text placeholder. Raising the limit does not automatically restore previously offloaded images.
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
Image count overflow is detected before attachment reads. Each request prepares at most four images concurrently and stops when known encoded bytes exceed its payload budget. There is no plugin-wide image queue or shared payload pool.
|
|
122
120
|
|
|
123
|
-
```powershell
|
|
124
|
-
$env:DSH_OPENCODE_GO_DEBUG_DIR = "$env:TEMP\dsh-opencode-go-debug"
|
|
125
|
-
dsh web
|
|
126
|
-
```
|
|
127
121
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
DSH debug logs contain a call ID and each attempt's stage timings, HTTP status, upstream request ID, time to first output and error code, including stream failures after HTTP 200. Image attempts also report aggregate queue waiting and peak resource occupancy. Error files carry the same call ID and attempt number for correlation. These summaries exclude prompts, keys, proxy addresses and raw session IDs.
|
|
122
|
+
A cold catalog outage reports `DISCOVERY_FAILED`; a warm catalog retains previously verified models. Only an explicit empty gateway listing clears membership. A partially malformed listing keeps its valid models and reports the ignored row count in settings and logs. Ordinary advanced form settings commit in one revision-checked batch. Credentials use a separate service; failed credential drafts remain, and retry submits only uncommitted parts.
|
|
131
123
|
|
|
124
|
+
Request failures retain HTTP classification, redacted upstream summaries and applicable context-capacity hints. The plugin no longer writes internal diagnostic files or per-call traces.
|
|
132
125
|
|
|
133
126
|
## Account operations and saving
|
|
134
127
|
|
|
135
|
-
|
|
128
|
+
Account operations run in a host-owned memory queue, with credential writes completed before settings updates. Closing the page does not cancel a storage write already in progress. There is no transaction journal or startup recovery loop; retry an unsuccessful operation from the accounts card.
|
|
136
129
|
|
|
137
130
|
Reset all to defaults in advanced settings removes overrides at the current layer and restores inherited values; save to apply the reset. It does not remove accounts or keys, or clear model limit overrides.
|
package/docs/advanced.md
CHANGED
|
@@ -87,7 +87,7 @@ socks5://127.0.0.1:1080
|
|
|
87
87
|
|
|
88
88
|
| 配置项 | 用途 |
|
|
89
89
|
| --- | --- |
|
|
90
|
-
| `baseURL` |
|
|
90
|
+
| `baseURL` | OpenCode Go 网关地址,默认 `https://opencode.ai/inference/go/v1`;官方网关自动按模型协议选择推理端点 |
|
|
91
91
|
| `usageDisplay` | 额度显示模式:`auto`、`always` 或 `off` |
|
|
92
92
|
| `proxyURL` | 网络代理;空字符串使用默认网络设置 |
|
|
93
93
|
| `refreshMinutes` | 模型目录缓存时长,默认 60 分钟;设置页可随时手动刷新 |
|
|
@@ -99,37 +99,30 @@ socks5://127.0.0.1:1080
|
|
|
99
99
|
| `requestPreparationTimeoutMs` | 目录查询及每次尝试的凭据、图片准备时限,默认 60000 毫秒 |
|
|
100
100
|
| `requestTimeoutMs` | 一次发送的完整时限,包含目录查询、账号切换和流式输出,默认 1800000 毫秒;预先准备的调用从发送时计时 |
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
默认官方网关使用 `GET https://opencode.ai/inference/go/v1/models` 读取模型列表,使用 `GET https://opencode.ai/inference/go/v1/usage` 查询额度。推理端点按模型目录声明的协议选择,与[官方文档](https://opencode.ai/v2/docs/console/go/#endpoints)一致,以下路径均以 `https://opencode.ai/inference/go` 为前缀:
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
| 模型协议 | 推理路径 |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| OpenAI Chat Completions(如 GLM-5.3-Flash) | `/openai/v1/chat/completions` |
|
|
107
|
+
| OpenAI Responses(如 Grok 4.7、GPT 6 Luna) | `/openai/v1/responses` |
|
|
108
|
+
| Anthropic Messages(如 Claude Haiku 5.5) | `/anthropic/v1/messages` |
|
|
109
|
+
| Google(如 Gemini 4 Argon Contributor) | `/google/v1beta/models/{model}:streamGenerateContent` |
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
读取旧官方地址 `https://opencode.ai/zen/go/v1` 时,插件会自动迁移,保存设置时也会写入新地址。无需为每个模型手动修改网关。自定义网关继续使用填写的 `baseURL` 作为请求前缀,由各协议 SDK 拼接资源路径;不会自动添加官方网关的协议分段。列表可访问不代表所有推理接口都可用。
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
额度查询失败时,面板会保留 HTTP 状态码,并在上游提供可读原因时显示脱敏后的摘要。HTTP 403 会提示检查 API Key 和 Go 订阅权限;账号显示“已配置 key”仅代表本地保存了凭据。可同时核对 Key 所属账号或 workspace 的订阅状态,以及网关与代理配置。
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
export DSH_OPENCODE_GO_DEBUG_DIR=/tmp/dsh-opencode-go-debug
|
|
116
|
-
dsh web
|
|
117
|
-
```
|
|
115
|
+
图片卸载会保留原始附件,并将请求中的旧图片替换为文字占位;调高上限不会自动恢复已卸载的历史图片。
|
|
118
116
|
|
|
119
|
-
|
|
117
|
+
图片数量超限会在附件读取前检测。每个请求最多并发准备 4 张图片,并在已知编码大小超过单次请求预算时停止;插件不再维护全局图片队列或共享内存池。
|
|
120
118
|
|
|
121
|
-
```powershell
|
|
122
|
-
$env:DSH_OPENCODE_GO_DEBUG_DIR = "$env:TEMP\dsh-opencode-go-debug"
|
|
123
|
-
dsh web
|
|
124
|
-
```
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
DSH debug 日志另有每次发送的调用编号,以及各次尝试的阶段耗时、HTTP 状态、上游请求编号、首次输出等待时间与错误码,包含 HTTP 200 后的流中断;图片请求还记录排队累计等待与资源占用峰值。错误文件带有相同调用编号与尝试序号,便于关联排查。这些摘要不记录提示词、Key、代理地址或原始会话编号。
|
|
120
|
+
首次查询目录失败会报告 `DISCOVERY_FAILED`;已有目录时保留之前确认过的模型。网关明确返回空列表才会清空目录。列表中仅部分行格式错误时,仍可使用有效模型,设置页与日志会提示被忽略的行数。高级表单的普通配置项一次提交并检查版本;凭据由独立服务保存,凭据保存失败时保留其草稿,重试只提交未成功的部分。
|
|
129
121
|
|
|
122
|
+
请求失败时,错误信息仍包含 HTTP 分类、脱敏后的上游摘要,以及适用的上下文容量提示。插件不再输出内部诊断文件或逐调用追踪。
|
|
130
123
|
|
|
131
124
|
## 账号操作与保存
|
|
132
125
|
|
|
133
|
-
|
|
126
|
+
账号操作按宿主内存队列顺序执行,凭据写入完成后再更新设置。页面中断不会取消已经开始的存储写入;进程重启后没有事务日志或自动恢复循环,未成功的操作可从账号卡片重新执行。
|
|
134
127
|
|
|
135
128
|
高级设置的“全部恢复默认”会清除当前层的自定义覆盖,恢复继承值;需要保存后才生效。它不删除账号或 Key,也不清除模型容量覆盖。
|
|
Binary file
|
|
Binary file
|