dsh-opencode-go 0.1.24 → 0.2.1
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 +66 -12
- package/README.md +172 -79
- package/THIRD_PARTY_NOTICES.md +6 -2
- package/assets/icon.png +0 -0
- package/docs/advanced.en.md +32 -35
- package/docs/advanced.md +33 -35
- package/docs/assets/logo-dark.png +0 -0
- package/docs/assets/logo-light.png +0 -0
- package/docs/assets/usage-history-desktop.jpg +0 -0
- package/docs/assets/usage-history-mobile.jpg +0 -0
- package/docs/assets/usage-history-models.jpg +0 -0
- package/docs/development.md +61 -119
- package/docs/independent-package.md +4 -2
- package/docs/usage-analytics.en.md +57 -0
- package/docs/usage-analytics.md +57 -0
- package/docs/verification.md +51 -917
- package/lib/build-info.json +1 -1
- package/lib/client.js +3429 -2618
- package/lib/free-http-worker.js +32 -0
- package/lib/index.js +5135 -3746
- package/lib/types/accounts.d.ts +96 -31
- package/lib/types/adapter.d.ts +63 -51
- package/lib/types/analytics.d.ts +35 -0
- package/lib/types/catalog.d.ts +109 -44
- package/lib/types/client/AnalyticsDialog.d.ts +18 -0
- package/lib/types/client/Section.d.ts +41 -7
- package/lib/types/client/UsagePill.d.ts +15 -6
- package/lib/types/client/controller.d.ts +178 -0
- package/lib/types/client/dashboard-copy.d.ts +58 -0
- package/lib/types/client/index.d.ts +18 -12
- package/lib/types/client/{locales.d.ts → presentation.d.ts} +97 -9
- package/lib/types/config.d.ts +14 -15
- package/lib/types/contracts.d.ts +338 -0
- package/lib/types/conversion.d.ts +155 -0
- package/lib/types/free-channel.d.ts +21 -0
- package/lib/types/free-http-worker.d.ts +1 -0
- package/lib/types/free-policy.d.ts +4 -0
- package/lib/types/free-protocol.d.ts +16 -0
- package/lib/types/free-runtime.d.ts +2 -0
- package/lib/types/free-socks-tunnel.d.ts +4 -0
- package/lib/types/free-transport.d.ts +19 -0
- package/lib/types/index.d.ts +8 -40
- package/lib/types/pricing.d.ts +29 -0
- package/lib/types/sdk-types.d.ts +1540 -2902
- package/lib/types/transport.d.ts +71 -0
- package/lib/vendor-licenses.txt +55 -31
- package/package.json +77 -78
- package/docs/assets/usage-panel.png +0 -0
- 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
|
@@ -6,10 +6,12 @@ The Host depends on DSH services through peer dependencies so Cordis service cla
|
|
|
6
6
|
|
|
7
7
|
The package's bundle keeps the configuration entry `id: opencode-go` so existing settings remain attached. Its LLM provider route is independently named `dsh-opencode-go`, shown as `DSH OpenCode Go`, and can coexist with the generic adapter's `opencode-go` route. The SDK retains its native `opencode-go` identity for transport behavior; replay metadata records the DSH route and an optional `sdkProvider` to restore the native identity. The original fork's `llm-opencode-go` row can be disabled by a profile patch. Plugin registration does not select the user's default model or replace another provider automatically. Saved session/preset provider selections must be updated explicitly.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The plugin owns request-history, stream and replay conversion in `src/conversion.ts`, with the upstream MIT license. It consumes only published host APIs from DSH `0.2.1-rc.5` and later. Protocol transport remains implemented by the pinned private pi-ai SDK, with Google adapter wrappers in `src/google.ts` and the request-local fetch binding in `src/transport.ts`.
|
|
10
10
|
|
|
11
11
|
The build uses esbuild and lightningcss, with Rollup to flatten the exported SDK declarations. The host bundles the required pi-ai implementation and only the OpenCode Go model catalog. DSH services, Undici, OpenAI and Anthropic SDKs stay external; DSH class identities remain shared. The browser factory follows DSH's `window.__ModuleLoader__.load` format, embeds CSS Modules, and allows only the declared platform module imports. A package-level builder is sufficient for this single external plugin; extracting a general DSH build-tool package would require a separate release and is not a prerequisite for installation.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The minimum supported Host is DSH `0.2.1-rc.5`, with Cordis `~4.0.5`. Development dependencies and the lockfile pin that DSH release, Cordis `4.0.5` and Schemastery `3.18.5`. Consumer installation uses the prebuilt artifacts and does not run a plugin build.
|
|
14
|
+
|
|
15
|
+
Verification uses 12 domain-focused Vitest files against published rc.5 APIs, separate host/client type checks, a byte-for-byte independent rebuild and Cordis's ordinary package resolver. Tests import the 17 current implementation modules directly. `npm run verify:installed -- /path/to/consumer` exercises a consumer's resolved package; `npm run verify:headless -- /path/to/consumer` additionally exercises the official CLI with a temporary profile and loopback gateway. The default `verify` includes the complete test suite. See [development](development.md) and [verification](verification.md) for commands and scope.
|
|
14
16
|
|
|
15
17
|
The initial source derives from the user's working copy of DeepSeek Harness on branch `oh-my-dsh`, whose HEAD was `2c8555b323f3b49eac743bafd527f9f3238bf548`, including the uncommitted OpenCode Go settings changes present when this project was created. Runtime conversion modules retain their published behavior. The original checkout is unchanged by this extraction.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Usage analytics notes
|
|
2
|
+
|
|
3
|
+
[Back to README](../README.en.md) · [简体中文](usage-analytics.md)
|
|
4
|
+
|
|
5
|
+
The dashboard shows official history for the workspace belonging to the selected OpenCode key. It can include calls from other clients and does not attribute calls to this plugin. Coverage of anonymous Free calls is not guaranteed.
|
|
6
|
+
|
|
7
|
+
## Entry points and accounts
|
|
8
|
+
|
|
9
|
+
Open it from the conversation's expanded usage pill or the sidebar dashboard button. Settings no longer include a usage analytics card or theme picker.
|
|
10
|
+
|
|
11
|
+
The dashboard has an independent viewing-account selector, defaulting to the account currently used for inference. Changing it only changes the dashboard scope; it does not switch the account for subsequent conversations or combine all saved accounts. The dashboard's five-hour, weekly and monthly quota windows follow the selected account and use official quota percentages.
|
|
12
|
+
|
|
13
|
+
## Official data source
|
|
14
|
+
|
|
15
|
+
The Host uses the selected account's key to request the official daily CSV:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
https://opencode.ai/console/api/v2/usage/export?range=7d|30d|90d
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Totals, daily charts and model detail all come from one CSV snapshot, avoiding differences between endpoints queried at different times. Ranges are today, 7 days, 30 days and 90 days; today filters the 7-day CSV to the current UTC date. All dates use UTC, with missing dates filled with zero to keep the daily series continuous. Official daily aggregates may be delayed, so refreshing may not immediately include a recently completed call.
|
|
22
|
+
|
|
23
|
+
The Host stores and uses keys. Normal reports send the browser only aggregate numbers and grouping fields such as provider, model and day, without conversation content, member fields or keys. An official CSV explicitly downloaded by the user may contain official member fields.
|
|
24
|
+
|
|
25
|
+
History queries require an official model gateway configuration before the Host sends a key to the `opencode.ai` Console. Third-party gateways show an unsupported state and their keys are not sent to Console. Queries retain the configured proxy path, cancellation, timeouts and response-size limits.
|
|
26
|
+
|
|
27
|
+
## Accounting
|
|
28
|
+
|
|
29
|
+
| Metric | Source |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| Requests | Sum of official CSV request counts |
|
|
32
|
+
| Input / output tokens | Official input and output fields, summed separately |
|
|
33
|
+
| Cache-read tokens | Sum of the official cache-read field |
|
|
34
|
+
| Cache-write tokens | Sum of official 5-minute and 1-hour cache-write fields |
|
|
35
|
+
| Total tokens | Input + output + cache read + both cache-write fields |
|
|
36
|
+
| Official usage amount | Exact sum of `cost_micro_cents`; `1 USD = 100,000,000 cost_micro_cents` |
|
|
37
|
+
| Model grouping | Provider + model; identical model names from different providers stay separate |
|
|
38
|
+
|
|
39
|
+
The amount comes directly from official records and is labeled **official usage amount**. It does not mean an additional charge beyond the Go subscription. The dashboard does not reprice history using the current model catalog or derive quota percentages from amounts.
|
|
40
|
+
|
|
41
|
+
Only source-supported metrics are shown. Local session coverage, summary-call counts, unsettled attempts and unattributed activity are not reported or filled with misleading zeros. UTC zero-filling only means the official CSV contains no records for that day.
|
|
42
|
+
|
|
43
|
+
## Presentation and refresh
|
|
44
|
+
|
|
45
|
+
- A wide-screen dialog becomes full-screen on narrow screens, with stacked daily token bars or daily request bars, model rankings and detail.
|
|
46
|
+
- Settings, the pill, expanded sidebar and dashboard share warm paper / charcoal surfaces and terracotta accents, following the Host's light/dark mode. There is no theme picker. Locally installed Anthropic Serif / Sans / Mono fonts are preferred, with system and CJK serif fallbacks. Settings recolor the Host's existing controls only within the plugin section.
|
|
47
|
+
- History queries run only when opening the dashboard, changing the viewing account or range, or refreshing manually. There is no background history polling; closing the dashboard cancels its active query.
|
|
48
|
+
- The Host caches official reports and CSVs for 30 seconds, isolated by credential, account, network configuration, range and UTC date. A forced manual refresh bypasses the cache.
|
|
49
|
+
- Authentication, permission, network and data-format errors show an explicit failure, without falling back to local session scans or fabricated zero usage.
|
|
50
|
+
|
|
51
|
+
The usage pill's existing quota refresh is independent of history queries.
|
|
52
|
+
|
|
53
|
+
## Verification
|
|
54
|
+
|
|
55
|
+
An existing manual check on 2026-11-06 used the current desktop key without Cookie or organization headers. All four official Console history endpoints returned HTTP 200, with matching 30-day totals of **7,064 requests, 1,105,009,939 tokens and 3,152,640,453 cost_micro_cents**. This established that the daily CSV supplies the dashboard data; it does not establish identical permissions for every account or complete anonymous Free coverage.
|
|
56
|
+
|
|
57
|
+
See [verification notes](verification.md) for this implementation's automated tests, build and UI checks. Unfinished checks are marked separately.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 用量统计说明
|
|
2
|
+
|
|
3
|
+
[返回 README](../README.md) · [English](usage-analytics.en.md)
|
|
4
|
+
|
|
5
|
+
用量看板展示所选 OpenCode Key 所属工作区的官方历史用量。数据可能包含其他客户端的调用,不能据此判断某次调用来自本插件;匿名 Free 调用的覆盖不作保证。
|
|
6
|
+
|
|
7
|
+
## 入口与账号
|
|
8
|
+
|
|
9
|
+
从对话用量胶囊展开后的看板按钮,或侧栏看板按钮打开。设置页不再提供用量统计卡片或主题选择器。
|
|
10
|
+
|
|
11
|
+
看板有独立的查看账号选择器,默认选择当前调用账号。切换查看账号只改变看板范围,不会切换后续对话使用的账号,也不会合并所有已保存账号。看板内的 5 小时、每周、每月额度窗口均跟随所选账号,百分比以官方额度接口为准。
|
|
12
|
+
|
|
13
|
+
## 官方数据来源
|
|
14
|
+
|
|
15
|
+
Host 使用所选账号的 Key 请求官方每日 CSV:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
https://opencode.ai/console/api/v2/usage/export?range=7d|30d|90d
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
一份报告的总计、每日图表与模型明细都从同一个 CSV 快照生成,避免多个接口在不同时间返回数据造成差异。支持今日、7 天、30 天、90 天;「今日」从 7 天 CSV 中筛选 UTC 当日。日期统一按 UTC,区间内缺少记录的日期补零,保持日序列连续。官方每日汇总可能延迟,刷新不保证立即看到刚结束的调用。
|
|
22
|
+
|
|
23
|
+
Key 由 Host 保存并使用。常规报告只向浏览器传递聚合数字,以及 provider、model、day 等分组字段,不含会话正文、成员字段或 Key。用户主动下载官方 CSV 时,文件可包含官方导出的成员字段。
|
|
24
|
+
|
|
25
|
+
只有官方模型网关配置支持历史查询,Host 才会将 Key 发给 `opencode.ai` Console。第三方网关配置显示不支持,不会把其 Key 发送到 Console。查询沿用已配置的代理路径,并保留取消、超时和响应体大小限制。
|
|
26
|
+
|
|
27
|
+
## 统计口径
|
|
28
|
+
|
|
29
|
+
| 项目 | 口径 |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| 请求数 | 汇总 CSV 的官方请求数 |
|
|
32
|
+
| 输入 / 输出 Token | 分别汇总官方输入、输出字段 |
|
|
33
|
+
| 缓存读 Token | 汇总官方 cache-read 字段 |
|
|
34
|
+
| 缓存写 Token | 合计官方 5 分钟与 1 小时 cache-write 字段 |
|
|
35
|
+
| 总 Token | 输入 + 输出 + 缓存读 + 两类缓存写 |
|
|
36
|
+
| 官方用量金额 | 精确累加 `cost_micro_cents`;`1 USD = 100,000,000 cost_micro_cents` |
|
|
37
|
+
| 模型分组 | 使用 provider + model;不同 provider 的同名模型分别统计 |
|
|
38
|
+
|
|
39
|
+
金额直接来自官方记录,称为「官方用量金额」,不等同于 Go 套餐之外的额外扣款。看板不使用当前模型价目表重算历史费用,也不根据金额反推订阅额度百分比。
|
|
40
|
+
|
|
41
|
+
只有来源能够支持的数据才会显示。看板不提供本地会话覆盖、摘要调用、未结算尝试或未归属活动等指标,也不会用零值代替这些未知数据。UTC 补零仅表示官方 CSV 在该日没有记录。
|
|
42
|
+
|
|
43
|
+
## 展示与刷新
|
|
44
|
+
|
|
45
|
+
- 看板在宽屏使用弹窗,窄屏使用全屏;提供 Token 堆叠日柱图或请求日柱图、模型排行与明细。
|
|
46
|
+
- 设置页、胶囊、展开侧栏和看板统一使用暖纸色 / 炭灰色与陶土色强调,跟随宿主明暗模式;不提供主题选择器。优先匹配本地 Anthropic Serif / Sans / Mono 字体,中文标题使用宋体等衬线回退。设置页中的宿主控件仅在插件区域内应用这套配色。
|
|
47
|
+
- 历史只在打开看板、切换查看账号、切换区间或手动刷新时查询,不后台轮询。关闭看板会取消正在进行的查询。
|
|
48
|
+
- Host 对官方报告与 CSV 使用 30 秒短缓存,按凭证、账号、网络配置、区间与 UTC 日期隔离;手动强制刷新绕过缓存。
|
|
49
|
+
- 鉴权、权限、网络或数据格式错误明确显示失败,不回退到本地会话扫描,也不显示伪造的零用量。
|
|
50
|
+
|
|
51
|
+
额度胶囊原有的额度刷新与历史查询相互独立。
|
|
52
|
+
|
|
53
|
+
## 验证
|
|
54
|
+
|
|
55
|
+
2026-11-06 的既有手工检查中,当前桌面 Key 在不携带 Cookie 或组织请求头的情况下可访问四个官方 Console 历史接口,均返回 HTTP 200;30 天汇总一致为 **7,064 次请求、1,105,009,939 Token、3,152,640,453 cost_micro_cents**。该检查确认每日 CSV 可提供看板所需数据,不代表所有账号均有相同权限或匿名 Free 历史一定完整。
|
|
56
|
+
|
|
57
|
+
本轮实现的自动测试、构建和界面验证结果见[验证记录](verification.md);尚未完成的项目单独标记。
|