dsh-tokenlens 1.3.6 → 1.3.8

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/CHANGELOG.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  **版本记录约定**:同一发布日只保留一个章节,标题取当日**最后一个**已发布版本号;当日多次发布的改动合并到该章节,并在标题下注明当日实际发布过的版本号(npm 上仍可安装这些独立版本)。若当日已有发布,后续小改动不再单独增加版本号,而是并入下一篇日志。这样日志按天规整、不出现同日多个小版本。
6
6
 
7
- ## 1.3.6 — 2026-11-02
7
+ ## 1.3.8 — 2026-11-02
8
8
 
9
- (当日已发布版本:v1.3.5 / v1.3.6)
9
+ (当日已发布版本:v1.3.5 / v1.3.6 / v1.3.7 / v1.3.8)
10
10
 
11
11
  - feat(ui): 供应商管理页可为 **Open Design** 填写「工作区 ID」并持久化到插件配置——此前 workspaceId 只能在 profile patch 或 `OPENDESIGN_WORKSPACE_ID` 里设置,用推理 Key 配好供应商后额度卡片仍报错却无处可改
12
12
  - feat(ui): Open Design 额度失败时的引导——详情弹窗的错误条说明「额度查询需要工作区 ID 与 Control Key(不是推理 Key)」,并提供「去配置」按钮直接跳到供应商管理页
@@ -14,6 +14,7 @@
14
14
  - feat(wire): `providers[]` 仅对声明了 workspace 的适配器(Open Design)下发 `workspaceId` 字段;其余供应商不下发,客户端据此决定是否渲染输入框(旧 Host 无此字段 ⇒ 不渲染,自然降级)
15
15
  - feat(ui): Open Design 缺配置时 chip 不再按 `missing-key` 静默隐藏,而是显示「待配置」并可点进详情看引导——否则用户既看不到提示也没有入口
16
16
  - fix(tool): Agent 工具 `tokenlens_usage` 的 `updateCheck` 动作此前虽在枚举里却会落到用量读取分支,返回当前供应商的用量或错误;现在正确执行更新检查并返回 `UpdateInfo`
17
+ - docs: 中英 README 补充 **workspace ID 与 Control Key 到底在哪里取**——控制台的「套餐与余额」页没有独立的 ID 字段,workspace ID 取自地址栏的 `?workspaceId=`(成员邀请预览页也会显示「工作空间 ID」),而 `~/.amr/config.json` 只存 `controlKey` / `runtimeKey` / `apiUrl` / `linkUrl`、不含 workspace ID;Control Key 是桌面端 / `vela login` 写入该文件的 `profiles.prod.controlKey`,用推理 Key 冒充会得到 401
17
18
  - 测试:280 → 286(workspace ID 校验/持久化/清空、管理页字段渲染与保存、缺 workspaceId 的 Host 报错与引导按钮、待配置 chip、工具 updateCheck 分发)
18
19
 
19
20
  ## 1.3.4 — 2026-11-01
package/PROTOCOL.md CHANGED
@@ -112,6 +112,15 @@ A `windows` snapshot may also carry a non-null `balance` (Open Design reports
112
112
  allowance windows and a wallet independently); the Client renders it as one extra
113
113
  row at the end of the capacity card and appends the amount to the chip tooltip.
114
114
 
115
+ `open-design` needs two credentials that the API-keys page does not provide: a
116
+ **workspace id** (the console URL's `?workspaceId=` value) and a **Control Key**
117
+ (the `profiles.prod.controlKey` the desktop app / `vela login` writes to
118
+ `~/.amr/config.json`). The inference key from the Cloud API Keys page answers
119
+ HTTP 401 on the billing endpoints. Missing either value is a `missing-key` error;
120
+ the workspace id may be set from the management page (persisted in
121
+ `providers.json`, v1.3.5) and the Control Key comes from `OPENDESIGN_CONTROL_KEY`,
122
+ `VELA_CONTROL_KEY`, the credential store, or that page's key field.
123
+
115
124
  Rules:
116
125
 
117
126
  - `percent` is clamped to `0..100`; an unknown percentage is `null` (render "—"), never a fake 0.
package/README.en.md CHANGED
@@ -109,6 +109,11 @@ Credentials come from DSH itself: providers configured in DSH inherit their `api
109
109
 
110
110
  Open Design (OpenDesign) is the exception: its read-only billing API needs a **workspace ID** plus a **Control Key** (`OPENDESIGN_CONTROL_KEY` or `VELA_CONTROL_KEY`), which is *not* the inference API key from the Cloud API Keys page. Set the workspace ID right on the provider management page's Open Design card (v1.3.5, stored in the plugin's own config and kept across restarts), under `providers.open-design.workspaceId`, or via `OPENDESIGN_WORKSPACE_ID`; provide the Control Key through the environment, DSH credentials, or the management page's key field. When either is missing the detail dialog names the missing piece and offers a 「去配置 / Configure」 button instead of a generic missing-key error.
111
111
 
112
+ **Where the two values come from.** Neither is on the Cloud API Keys page.
113
+
114
+ - *Workspace ID* — the console has **no dedicated field for it**; it appears in the address bar: open 套餐与余额 or 成员 and read `open-design.ai/cloud/dashboard?workspaceId=<the id>`. A member-invite preview page also lists it as 「工作空间 ID」. `~/.amr/config.json` stores only the keys/URLs, not the workspace id.
115
+ - *Control Key* — a session credential that the Open Design desktop app / `vela` CLI writes to `~/.amr/config.json` when you sign in (`profiles.prod.controlKey`). Sign in once with the desktop app, or run `vela login` and approve the browser prompt, then copy that value (or point the plugin at it). Pasting the inference key instead makes the quota call answer HTTP 401.
116
+
112
117
  See the [Chinese README](README.md) for the full configuration reference, preview and provider tables.
113
118
 
114
119
  ## Supported providers and harnesses
package/README.md CHANGED
@@ -195,6 +195,47 @@ dsh plugin --profile <profile> remove dsh-tokenlens
195
195
  - **Open Design(OpenDesign)** 的额度查询需要 OpenDesign Cloud 的 **workspace ID + Control Key**(`OPENDESIGN_CONTROL_KEY` 或 `VELA_CONTROL_KEY`),**不是** Cloud API Keys 页的推理 Key(推理 Key 只能调用模型)。workspace ID 可直接在[供应商管理页](#供应商管理)的 Open Design 卡片里填写(v1.3.5,保存在插件自己的配置里,重启后仍在),或写在 provider 配置里,或用 `OPENDESIGN_WORKSPACE_ID` 环境变量;Control Key 通过环境变量 / DSH 凭据 / 管理页的 Key 输入框提供。
196
196
  - 配置不全时,详情弹窗会说明缺哪一项并提供「去配置」按钮,而不是只显示一个笼统的「没有找到该供应商的 API Key」。
197
197
 
198
+ ### 拿到 Open Design 的 workspace ID 与 Control Key
199
+
200
+ 这两样都**不在** Cloud 控制台的 API Keys 页面(那里只有推理 Key)。具体步骤:
201
+
202
+ **1. workspace ID**
203
+
204
+ 这个控制台**没有单独一栏显示工作区 ID**(截图里的「套餐与余额」页只有额度、余额、充值),它只出现在两处:
205
+
206
+ - **地址栏**:在 Cloud 控制台里点进「套餐与余额」或「成员」等任意页面,地址会变成 `open-design.ai/cloud/dashboard?workspaceId=<这一串>`——`workspaceId=` 后面、`&` 之前的整段就是。这是最可靠的取法。
207
+ - **成员邀请预览页**:生成一条成员邀请并打开它,确认页会把「工作空间 ID」作为一条信息列出来。
208
+ - 装了桌面端的话,本机 `~/.amr/config.json` 只保存 `controlKey` / `runtimeKey` / `apiUrl` / `linkUrl`,**不含** workspace ID,别在这里找。
209
+
210
+ **2. Control Key**
211
+
212
+ Control Key 是 **Open Design 桌面端/CLI 登录时写入本机的会话凭据**,不是控制台上可以生成的一串字。它由桌面客户端或 `vela` CLI 在登录后写进 `~/.amr/config.json`:
213
+
214
+ ```jsonc
215
+ // ~/.amr/config.json(Windows: C:\Users\<你>\.amr\config.json)
216
+ {
217
+ "profiles": {
218
+ "prod": {
219
+ "controlKey": "……", // ← 这就是额度查询要的 Control Key
220
+ "runtimeKey": "……"
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ 取得它的方式(任选一种):
227
+
228
+ - **桌面端登录一次**:安装并启动 Open Design 桌面端 → 登录 Cloud 账号。客户端完成登录后会在本机写入 `~/.amr/config.json`(同时 CLI 也已就位)。
229
+ - **CLI 登录**:在装有 `vela` 命令的机器上执行 `vela login`,按终端提示打开激活链接、在浏览器里确认("Approve CLI login"),完成后同样写入 `~/.amr/config.json`。
230
+ - 已有 `~/.amr/config.json` 的话直接打开取 `profiles.prod.controlKey` 即可。
231
+
232
+ 拿到后两种放法:
233
+
234
+ - 写进 `$DSH_HOME/.credentials.yaml` 的 `refs:` 下:`OPENDESIGN_CONTROL_KEY: <control key>`(或环境变量 `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY`);
235
+ - workspace ID 在插件的[供应商管理页](#供应商管理) Open Design 卡片里填写,或用 `OPENDESIGN_WORKSPACE_ID` 环境变量。
236
+
237
+ > 这也解释了最容易踩的坑:**用推理 Key 填 Control Key** 会让额度查询返回 401。插件已经区分这两种凭据,缺哪一项都会指名道姓地提示。
238
+
198
239
  解析顺序(先命中先用):DSH 凭据服务 → 环境变量 → `$DSH_HOME/.credentials.yaml` → OpenCode CLI 的 `auth.json`(仅默认的 `OPENCODE_GO_API_KEY` 引用)。
199
240
 
200
241
  凭据只在 Host 进程内解析,**不会**下发到浏览器、**不会**写入日志或诊断输出(诊断只显示来源与引用名,不显示明文)。
package/index.js CHANGED
@@ -76,7 +76,7 @@ export const inject = []
76
76
  export const PLUGIN_NAME = 'dsh-tokenlens'
77
77
 
78
78
  /** Plugin version; mirrors package.json (kept here so diagnostics need no fs read). */
79
- export const PLUGIN_VERSION = '1.3.6'
79
+ export const PLUGIN_VERSION = '1.3.8'
80
80
 
81
81
  /** Documented defaults; every field of the raw row config is optional. */
82
82
  const DEFAULTS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tokenlens",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "type": "module",
5
5
  "description": "dsh-TokenLens (词元透镜) — provider-aware plan capacity plus local token statistics (today/7d/30d/all-time, by harness/provider/model/workspace) for DSH.",
6
6
  "license": "MIT",