dsh-cost-meter 1.9.3 → 1.9.4
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/LICENSE +21 -21
- package/README.md +575 -574
- package/README.zh-CN.md +579 -578
- package/docs/display-settings.md +15 -1
- package/docs/opendesign-billing.md +10 -4
- package/docs/update-notes-1.9.4.md +71 -0
- package/lib/client.codex.js +1 -1
- package/lib/client.display.js +2 -2
- package/lib/client.js +5 -5
- package/lib/client.peak.js +3 -0
- package/lib/client.pricing.js +14 -11
- package/lib/codex-subscription-compat.js +23 -2
- package/lib/index.js +27 -22
- package/lib/model-statistics.js +34 -0
- package/lib/opendesign.js +16 -5
- package/lib/store.js +22 -5
- package/lib/typert.host.js +6 -1
- package/package.json +194 -193
package/docs/display-settings.md
CHANGED
|
@@ -6,10 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
右侧直接展示简洁、标准和紧凑三种样式的小预览,复用实际预算与多时段额度的进度卡片。小预览标记为样式示例,未配置的额度使用本地示例数值。紧凑样式将多时段额度排成两列,预算卡片保持完整。点击峰谷条可切换细条或分段样式;点击“今日金额 · 模型数”可调整模型卡片的展开、周期、摘要、位置、行数、Token 和费用占比条。预算、余额、会话费用和额度条的选项各自放在对应组件旁。金额格式、换算和语言集中在下方。宽窗口将样式缩略图横向排列,窄窗口再改为竖向;右侧面板在空间不足时排到预览下方。放大预览中按 Escape 返回。
|
|
8
8
|
|
|
9
|
-
侧栏预览和真实侧栏共用完整的呈现函数与当前缓存数据,包含余额错误状态、Go
|
|
9
|
+
侧栏预览和真实侧栏共用完整的呈现函数与当前缓存数据,包含余额错误状态、Go 与预算合并卡、独立显示的预算、今日用量和峰谷条、模型花费卡片。选择框使用独立覆盖层,不改变组件 DOM 层级和紧凑布局。打开时最多读取三个宿主表面的背景、圆角、字体等六项外观属性;主题属性变化时更新。共用插件组件、DSH 图标和主题变量,跟随这些外观的皮肤修改;其他插件的独立控件不重复挂载。
|
|
10
10
|
|
|
11
11
|
两种数据来源共用实际展示组件。示例状态只传给预览,不写入配置、余额、额度或账本,也不会启用账户查询或 Codex 探测。预览不复制会话内容,不遍历整页 DOM,不创建 iframe,不解码图片,不订阅会话投影。选择框只测量当前预览内最多 32 个标记节点,使用一个局部尺寸监听器;关闭时清理尺寸与主题监听器。异常组件由预览内部的错误边界隔离,仍可使用详细显示选项。
|
|
12
12
|
|
|
13
13
|
预算显示和预算统计分别控制。隐藏预算卡片不会关闭预算统计;隐藏峰谷条不会关闭峰谷计价;显示 Go 占位不会启用账户查询。
|
|
14
14
|
|
|
15
15
|
原生图标的来源和许可证见仓库根目录 THIRD_PARTY_NOTICES.md。
|
|
16
|
+
|
|
17
|
+
侧栏区域上方直接提供预算、今日用量、峰谷时段和模型花费四个显示开关,不必先选中组件。今日用量单行与“今日金额 · 模型数”摘要分别控制;关闭其中一个不影响其他组件,没有其他组件时也可以只显示峰谷条。隐藏侧栏今日用量不会隐藏概览里的今日费用,预算详细信息开关也不影响今日用量。所有组件关闭时不保留空白区域。
|
|
18
|
+
|
|
19
|
+
选择套餐进度条后,可以在同一面板选择 MiniMax 等账户、调整该账户的显示位置和侧栏开关。切换账户只切换编辑对象,不启用额度查询;进度条方向统一应用于所有套餐。需要修改凭据或查询参数时,点击“账户与额度设置”直接展开并定位到所选账户。
|
|
20
|
+
|
|
21
|
+
价格 → 模型定价中,每个模型下方的“计入统计”可展开三个独立开关:今日费用、月度与累计、预算。开关按渠道和模型保存,只改变对应汇总,不删除原始调用或重新定价。重新勾选可恢复统计。今日模型花费摘要跟随今日费用的选择;月度与累计、预算各用自己的选择。
|
|
22
|
+
|
|
23
|
+
模型定价以固定排序的紧凑列表展示,宽窗口中三项单价按列对齐,窄窗口在模型名下方排列。切换价格来源时模型保留原位置;选择自定义后,只定位一次到自定义编辑区的开头。保存价格或修改币种时不重新滚动。
|
|
24
|
+
|
|
25
|
+
峰谷时段新增“进度条”样式,显示当前计价时段已过的比例。峰时使用橙色,平价、周末和节假日使用 DSH 主题蓝色。标准侧栏显示完整信息,简洁侧栏使用两行,紧凑侧栏使用单行;可选择倒计时、切换时间或同时显示两者,悬停查看完整说明。周末和节假日会显示下一次切换的星期或日期,进度从连续谷价时段真正开始的时刻计算。
|
|
26
|
+
|
|
27
|
+
选中峰谷时段后,右侧以三张紧凑的实际效果卡片展示进度条、细条和分段样式,复用侧栏呈现函数,包含当前时段文字、橙蓝轨道和倒计时。蓝色边框和“已选”标明当前选择,样式说明放在悬停提示中,点击后立即更新左侧预览。右侧收窄并减少内边距和重复说明;桌面设置保持左侧预览、右侧调整,与其他组件使用相同的窄屏换行条件。显示时间的完整选项放在右侧卡片下方。预览中超长的时段文字以省略号收起,保留可见轨道,悬停或键盘聚焦可读取完整说明。样式示例只渲染峰谷组件,不挂载余额、额度和模型卡片,也不会把示例开关写入配置。
|
|
28
|
+
|
|
29
|
+
已开启峰谷计价且未隐藏峰谷显示的用户,更新后首次进入会看到一次介绍和三种布局预览。可以使用新进度条,也可以保留原样;关闭或选择后不再重复提示。原细条和分段样式保留。介绍中的预览只读取配置和本机时间,不查询余额、不发送模型请求、不改变计价或历史记录。新界面按需加载,页面隐藏时停止刷新,关闭组件时清理定时器和监听器。
|
|
@@ -24,6 +24,8 @@ OpenDesign uses shared subscription allowances and can fall back to its wallet;
|
|
|
24
24
|
3. Configure a **Control Key** in the credential editor, or supply `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY` to the DSH host. An inference key from the Cloud API Keys page is a different credential and cannot be used for this query. The existing OpenDesign/Vela login keeps control credentials in its own profile; the plugin does not read or rewrite that profile automatically.
|
|
25
25
|
4. Enable the card and refresh. Select its location to also show it in the sidebar or quota strip.
|
|
26
26
|
|
|
27
|
+
The credential editor saves to `OPENDESIGN_CONTROL_KEY` in the DSH credential store. Both it and the `VELA_CONTROL_KEY` alias are reflected in the configured/source indicator. Clearing the editor removes the primary stored key; an alias or host environment value can remain active. Legacy OpenDesign config keys also use the existing startup migration. This repairs the missing editor mapping reported and located by @unifilitence in [#317](https://github.com/Han-1413141/dsh-cost-meter/issues/317).
|
|
28
|
+
|
|
27
29
|
The host issues only these authenticated GET requests to the fixed official HTTPS origin:
|
|
28
30
|
|
|
29
31
|
```text
|
|
@@ -34,7 +36,7 @@ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance
|
|
|
34
36
|
#### Endpoint permissions and 401 troubleshooting
|
|
35
37
|
|
|
36
38
|
- `/billing/preflight` and `/wallet/balance` run in parallel with `Authorization: Bearer ...` and `x-vela-workspace-id`. The plugin no longer queries the browser-session-only `coding-plan-usage` route. Preflight nests the quota windows under `codingPlan`; both layers' workspace and member identities are validated before unwrapping.
|
|
37
|
-
- The wallet endpoint remains an independent query with its `billingScopeVersion: 2` contract. A valid wallet response is authoritative. When it cannot be read, a validated preflight result may display its `balanceUsd` as a fallback. Failure on one side preserves the other; no missing value becomes a fabricated zero. The
|
|
39
|
+
- The wallet endpoint remains an independent query with its `billingScopeVersion: 2` contract. A valid wallet response is authoritative. When it cannot be read, a validated preflight result may display its `balanceUsd` as a fallback, including when no subscription is active. Failure on one side preserves the other; no missing value becomes a fabricated zero. The failing side and reason appear in the settings card, sidebar/strip tooltip and manual-refresh result. A fallback balance is labelled as coming from `billing/preflight`.
|
|
38
40
|
- The workspace ID is `items[].workspaceId` from `GET https://amr-api.open-design.ai/api/v1/workspaces`, not `profiles.prod.user.id` from `~/.amr/config.json`.
|
|
39
41
|
- For a 401/403, check that the Control Key is current, belongs to the selected workspace and can read that workspace. An inference key or a user ID in the workspace field will not work. If the account rejects preflight too, use the OpenDesign Cloud console to check quota; a readable wallet is still shown separately.
|
|
40
42
|
|
|
@@ -44,7 +46,7 @@ Each returned allowance window has its own used percentage and reset time. Simul
|
|
|
44
46
|
|
|
45
47
|
### Evidence and limits
|
|
46
48
|
|
|
47
|
-
The public catalog was fetched without authentication. The
|
|
49
|
+
The public catalog was fetched without authentication; all 35 prices still matched the bundled catalog on 2026-10-18. The credential RPC is covered through save, read, clear, migration, aliases, workspace/key changes during an in-flight read, both wire codecs and ledger redaction. With host dependencies available, the same test also exercises the real DSH local credential provider in an isolated profile. Authenticated HTTP responses remain synthetic, including large credit counts, zero balances, mismatched identities, independent failures, no-subscription fallback balances, and price-refresh persistence. **No live account query or paid model request was made.**
|
|
48
50
|
|
|
49
51
|
Endpoint provenance: the official Cloud bundles `cloud-root-B21Emo2w.js` and `pricing-refund-policy-BDFJHl33.js` served on 2026-10-15; the [workspace-wallet contract](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/packages/contracts/src/api/collab.ts) and [Vela billing adapter](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/apps/daemon/src/integrations/vela-billing.ts) at the inspected commit. The exact `billing/preflight` shape (`codingPlan`-nested windows, `workspaceMemberId`, `balanceUsd`) comes from @yunjuanhuakai's [#274 comment](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566); the 401 reproduction and attached report come from @codeforker654's [comment](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870). The [official guide](https://open-design.ai/zh/model-credits/) explicitly lists DSH as a supported API client; the issue has a usable integration request. Its short promotional wording alone does not establish advertising or spam.
|
|
50
52
|
|
|
@@ -70,6 +72,8 @@ OpenDesign 的 API 与客户端共用套餐,套餐用尽后可以继续扣钱
|
|
|
70
72
|
3. 在凭据编辑器中配置 **Control Key**,或向 DSH 宿主提供 `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY`。Cloud API Keys 页生成的推理密钥与查询凭据不同,不能混用。已有 OpenDesign/Vela 登录将控制端凭据保存在其自身配置中,本插件不会自动读取或修改那个配置。
|
|
71
73
|
4. 开启并刷新,可选择在侧栏或额度横条显示。
|
|
72
74
|
|
|
75
|
+
凭据编辑器会把密钥保存到 DSH 凭据库的 `OPENDESIGN_CONTROL_KEY`。该名称与 `VELA_CONTROL_KEY` 别名都会反映到“已配置/来源”状态。清除只移除编辑器保存的首选密钥;别名或宿主环境变量仍可能生效。旧配置中的 OpenDesign 密钥也会参与既有的启动迁移。这修复了 @unifilitence 在 [#317](https://github.com/Han-1413141/dsh-cost-meter/issues/317) 报告并定位的凭据映射遗漏。
|
|
76
|
+
|
|
73
77
|
查询只访问以下固定官方 HTTPS GET 端点,并在凭据/工作区校验之后才发起:
|
|
74
78
|
|
|
75
79
|
```text
|
|
@@ -80,7 +84,7 @@ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance
|
|
|
80
84
|
#### 端点权限与 401 排查
|
|
81
85
|
|
|
82
86
|
- `/billing/preflight` 和 `/wallet/balance` 使用 `Authorization: Bearer ...` 与 `x-vela-workspace-id` 并行读取,不再请求需要浏览器会话的 `coding-plan-usage`。preflight 把窗口放在 `codingPlan` 内;解析前会核对内外两层工作区和成员身份。
|
|
83
|
-
- 钱包保留独立查询,按 `billingScopeVersion: 2` 契约校验。成功读取的钱包金额优先;钱包不可读时,经校验的 preflight 响应可提供 `balanceUsd`
|
|
87
|
+
- 钱包保留独立查询,按 `billingScopeVersion: 2` 契约校验。成功读取的钱包金额优先;钱包不可读时,经校验的 preflight 响应可提供 `balanceUsd` 作为余额,包括没有生效套餐的情况。一侧失败保留另一侧,缺失数据不会变成零。设置卡片、侧栏/横条提示和手动刷新结果都会显示失败的一侧与原因;备用余额会注明来自 `billing/preflight`。
|
|
84
88
|
- 工作区 ID 来自 `GET https://amr-api.open-design.ai/api/v1/workspaces` 的 `items[].workspaceId`,不能填 `~/.amr/config.json` 中的 `profiles.prod.user.id`。
|
|
85
89
|
- 遇到 401/403,检查 Control Key 是否有效、是否属于所填工作区、是否有读取权限。推理 API Key 不能代替 Control Key,用户 ID 不能代替工作区 ID。如果该账户连 preflight 也拒绝,可在 OpenDesign Cloud 控制台查看额度;可读的钱包仍单独显示。
|
|
86
90
|
|
|
@@ -88,6 +92,8 @@ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance
|
|
|
88
92
|
|
|
89
93
|
所有实际返回的窗口分别显示已用百分比和重置时间,不相加、不标成无限。钱包作为独立的美元等值额度显示,真实零余额保留。额度与钱包独立查询:一侧失败时另一侧仍照常显示;`eligible: false`/空窗口回执会明确报告为**无生效订阅**,不再与凭据失效混为一谈。认证失败、缺失回执或身份不匹配不显示虚构的零额度,两侧都失败时才显示错误/不可用状态。工作区配置跨重启保留,改变后清理原查询缓存。
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
2026-10-18 直接读取官方公开价表,35 个模型的价格与内置目录一致。凭据 RPC 验证覆盖保存、读取、清除、迁移、别名、查询期间切换工作区/密钥、双端 codec 和账本脱敏;具备宿主依赖时,同一测试还会在隔离配置中使用真实 DSH 本地凭据库。认证 HTTP 响应使用模拟数据,覆盖大整数、零余额、串工作区/成员、单侧失败、无订阅时保留备用余额、价格持久化等情况。**没有真实 OpenDesign 账户查询,没有调用付费模型。**
|
|
96
|
+
|
|
97
|
+
本次还核对了官方 [preflight 类型契约](https://github.com/nexu-io/open-design/blob/78d5637cb49da07e81314d1544b5fc6d37c95084/packages/contracts/src/api/collab.ts)与 [Vela 解析器](https://github.com/nexu-io/open-design/blob/78d5637cb49da07e81314d1544b5fc6d37c95084/apps/daemon/src/integrations/vela-billing.ts),检查工作区、成员、窗口和钱包字段。
|
|
92
98
|
|
|
93
99
|
端点来源:官方 Cloud bundle `cloud-root-B21Emo2w.js` 与 `pricing-refund-policy-BDFJHl33.js`(2026-10-15 读取);[工作区钱包契约](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/packages/contracts/src/api/collab.ts)与 [Vela 计费适配器](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/apps/daemon/src/integrations/vela-billing.ts)(上述 commit)。`billing/preflight` 的准确回执形状(`codingPlan` 内嵌窗口、`workspaceMemberId`、`balanceUsd`)来自 @yunjuanhuakai 的 [#274 评论](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236591566);401 复现与附件来自 @codeforker654 的 [评论](https://github.com/Han-1413141/dsh-cost-meter/issues/274#issuecomment-6236228870)。官方明确支持 DSH,说明这条 issue 有可执行的接入需求;仅凭“便宜、可能流行”的一句话,不能认定为广告。
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# v1.9.4
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
本版将本地 `1.9.4-preview.6` 的定价、显示和统计改动,以及已合并的 OpenDesign / Codex 修复一起正式发布。
|
|
6
|
+
|
|
7
|
+
### 定价列表与模型统计
|
|
8
|
+
|
|
9
|
+
- **设置 → 费用 → 价格 → 模型定价**改为固定顺序的紧凑列表。输入、缓存读取和输出单价对齐显示,详细编辑按需展开;切换自动匹配、自定义或指定价格表时,模型保留原位置。
|
|
10
|
+
- 选择自定义价格后,只滚动一次到编辑区开头并聚焦首个价格字段。自动保存、修改单价或切换币种时不重新滚动、不抢焦点。
|
|
11
|
+
- 每个渠道下的模型可以分别选择是否计入**今日费用、月度与累计费用、预算**。取消勾选仅影响对应汇总,保留原始调用、历史金额和价格记录;重新勾选即可恢复。不同汇总选择了不同模型时,金额也会不同。
|
|
12
|
+
|
|
13
|
+
### 显示设置与峰谷时段
|
|
14
|
+
|
|
15
|
+
- 预算、今日用量、峰谷时段和模型花费可以独立显示,不再互相依赖。修复只开启峰谷、套餐、自定义余额或网关额度时侧栏未挂载的问题。
|
|
16
|
+
- 常用显示开关直接放在显示页。套餐的显示位置和账户选择在同一面板调整,凭据与查询参数仍在额度页,可从显示页直接跳转到对应账户。
|
|
17
|
+
- 峰谷时段新增**进度条**样式,显示当前计价时段的时间进度;可选择倒计时、切换时间或同时显示。原细条和分段样式保留,首次介绍可以关闭或选择保留原样。
|
|
18
|
+
- 显示预览与真实侧栏共用组件,支持当前缓存或示例数据。预览不启用账户查询、不调用模型、不写入示例账单。
|
|
19
|
+
|
|
20
|
+
### OpenDesign 与 Codex
|
|
21
|
+
|
|
22
|
+
- 修复 OpenDesign Control Key 无法保存和旧配置密钥未迁移的问题;正确显示 `VELA_CONTROL_KEY` 等有效凭据来源。
|
|
23
|
+
- 额度或钱包一侧失败时,保留可用数据并在设置卡片、侧栏提示和手动刷新结果中显示原因。无生效套餐时仍可显示经过校验的 preflight 余额;工作区或成员身份不一致时不混用数据。
|
|
24
|
+
- Codex 额度支持订阅插件的 **5 小时 / 7 天**双窗口,提供自动检测、订阅插件、connect 三种来源选择。切换来源后,旧请求不会覆盖新来源;订阅查询使用宿主 Connection RPC。
|
|
25
|
+
- Codex 兼容页签和提示跟随订阅插件的实际启用状态。仅安装但停用、依赖未就绪或已卸载时隐藏;历史归类仍需主动执行。
|
|
26
|
+
|
|
27
|
+
### 更新与验证
|
|
28
|
+
|
|
29
|
+
完全退出 DSH(包括托盘)后重新打开,加载新的宿主代码与前端模块。从 npm 更新:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
dsh plugin --profile desktop add dsh-cost-meter@1.9.4
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
桌面端应使用应用自带的 CLI,具体路径见 [Desktop 安装说明](install-troubleshooting.md#desktop-安装与更新)。Web 用户将 profile 改为 `web`。
|
|
36
|
+
|
|
37
|
+
本版不自动重算历史费用。合并后的完整回归、真实浏览器中的显示设置、定价列表顺序和自定义编辑定位检查通过。OpenDesign 另已通过真实 DSH 本地凭据库验证;认证查询使用模拟响应,没有使用真实 OpenDesign 账户或调用付费模型。
|
|
38
|
+
|
|
39
|
+
感谢 [@lewispumpkin 在 PR #316](https://github.com/Han-1413141/dsh-cost-meter/pull/316) 贡献 Codex 双窗口与来源选择接入;感谢 [@unifilitence 在 issue #317](https://github.com/Han-1413141/dsh-cost-meter/issues/317) 报告并定位 OpenDesign 凭据保存映射遗漏。
|
|
40
|
+
|
|
41
|
+
## English
|
|
42
|
+
|
|
43
|
+
This release ships the pricing, display and statistics changes previewed in `1.9.4-preview.6`, together with the merged OpenDesign and Codex fixes.
|
|
44
|
+
|
|
45
|
+
### Pricing and per-model statistics
|
|
46
|
+
|
|
47
|
+
- **Settings → Cost → Prices → Model pricing** uses one compact list with a stable model order and aligned input, cache-read and output rates. Editors expand on demand; changing a price source keeps the model in place.
|
|
48
|
+
- Selecting a custom price scrolls once to the editor and focuses its first field. Autosave, price edits and currency changes preserve scroll position and focus.
|
|
49
|
+
- Each channel/model can independently participate in **today's costs, monthly/all-time totals and budgets**. Exclusions affect only the selected summary; original calls, historical amounts and prices remain. Re-enable a model to restore its contribution. Summaries with different model selections can show different amounts.
|
|
50
|
+
|
|
51
|
+
### Display and peak/off-peak hours
|
|
52
|
+
|
|
53
|
+
- Budget, today's usage, peak/off-peak hours and model costs can appear independently. Fixed the sidebar failing to mount when only peak hours, plan quotas, a custom balance or gateway quota is enabled.
|
|
54
|
+
- Common switches are available directly in Display. Plan placement and account selection share one inspector, with a link to that account's credentials and query settings in Quotas.
|
|
55
|
+
- A new **progress** style shows elapsed time in the current pricing period, with countdown, switch time or both. Existing thin and segmented styles remain available. The one-time introduction can be dismissed without changing the style.
|
|
56
|
+
- Display previews share the real sidebar components and can use cached or sample data. Sample previews do not start account queries, call models or write example bills.
|
|
57
|
+
|
|
58
|
+
### OpenDesign and Codex
|
|
59
|
+
|
|
60
|
+
- Fixed saving the OpenDesign Control Key and migrating legacy keys. Credential indicators now recognize valid aliases such as `VELA_CONTROL_KEY`.
|
|
61
|
+
- Partial quota/wallet failures preserve usable data and display the reason. A validated preflight balance remains available without an active subscription; mismatched workspace/member identities are rejected.
|
|
62
|
+
- Codex quota supports the subscription plugin's **5-hour and 7-day** windows and selectable auto/subscription/connect sources. Late requests cannot overwrite a newly selected source. Subscription queries use the host Connection RPC.
|
|
63
|
+
- Codex compatibility controls follow the subscription plugin's active runtime status. Inactive, unavailable or removed peers no longer leave a visible compatibility tab. Historical reclassification remains an explicit action.
|
|
64
|
+
|
|
65
|
+
### Updating and validation
|
|
66
|
+
|
|
67
|
+
Fully quit DSH, including its tray process, and reopen it after updating. Use the application's own CLI for the Desktop profile; see [Desktop installation](install-troubleshooting.md#desktop-安装与更新). This release does not automatically reprice historical calls.
|
|
68
|
+
|
|
69
|
+
The integrated regression suite and real-browser display/pricing checks passed. OpenDesign credentials were also tested with the real DSH local credential provider; authenticated HTTP responses were simulated, without a live OpenDesign account or paid model call.
|
|
70
|
+
|
|
71
|
+
Thanks to [@lewispumpkin for PR #316](https://github.com/Han-1413141/dsh-cost-meter/pull/316), which contributed Codex quota windows and source selection, and [@unifilitence for issue #317](https://github.com/Han-1413141/dsh-cost-meter/issues/317), which reported and located the missing OpenDesign credential mapping.
|
package/lib/client.codex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.codex.js",factory:A=>{const k=A("react"),{createElement:e,useState:C,useEffect:g,useRef:h}=k,D="cm-stat-dialog cm-codex-compat-dialog";if(typeof document<"u"){const t=document.createElement("style");t.textContent=".cm-codex-compat-dialog{width:min(560px,94vw)}.cm-codex-compat{display:flex;flex-direction:column;gap:8px;font-size:13px}.cm-codex-compat :is(h3,p){margin:0}.cm-codex-compat h3{font-size:14px;font-weight:600}",t.textContent+='@media (max-width:1023px){.cm-codex-compat-dialog{width:calc(100vw - 32px)}.cm-codex-compat{padding:0 2px}}body[data-dsh-pocket-layout="mobile"] .cm-codex-compat-dialog{width:calc(100vw - 32px)}',document.head.appendChild(t)}const v="dsh-cost-meter:codex-compat-prompt-dismissed",b=new Set;let w=!1;function I(){if(w)return!0;try{return window.localStorage.getItem(v)==="1"}catch{return!1}}function _(){w=!0;try{window.localStorage.setItem(v,"1")}catch{}for(const t of b)t(!0)}function N(){const[t,y]=C(!1),[s,d]=C(null),c=h(!1);return[t,s,l=>{c.current||(c.current=!0,y(!0),d(null),Promise.resolve().then(l).catch(n=>d(n?.message??String(n))).finally(()=>{c.current=!1,y(!1)}))}]}function P(t){const s=t.state?.codexCompat,d=t.api,c=t.locale==="en",a=(f,L)=>c?L:f,l=h(null),[n,m,o]=N(),[i,r]=C(I),p=s?.promptDue===!0&&!i;if(g(()=>(b.add(r),()=>b.delete(r)),[]),g(()=>{p&&l.current&&!l.current.open&&l.current.showModal()},[p]),!p)return null;const u=s.usage??{},x=()=>{l.current?.close(),r(!0),_(),Promise.resolve().then(()=>d.dismissCodexCompat()).catch(()=>{})};return e("dialog",{ref:l,className:D,"aria-label":a("兼容修复","Compatibility fix"),onCancel:f=>{f.preventDefault(),x()}},e("header",{className:"cm-stat-dialog-head"},a("兼容修复","Compatibility fix"),e("button",{type:"button",className:"cm-btn","aria-label":a("关闭","Close"),onClick:x},"×")),e("div",{className:"cm-stat-dialog-body"},e("p",null,a("检测到 dsh-codex-subscription {version}。Codex 订阅用量不计入 API 费用;为兼容本插件,新产生的 Codex 用量已自动归类为 Plan。是否将历史 codex 类模型的计费统一归类为 Plan(订阅额度,不计入 API 费用)?","Detected dsh-codex-subscription {version}. Codex subscription usage is not billed as API usage; for compatibility this plugin now defaults new Codex usage to Plan. Reclassify the billing of historical codex-class models as Plan (subscription quota, excluded from API usage)?").replace("{version}","v"+(s.version??""))),u.calls>0?e("p",{className:"cm-note"},a("历史 Codex 用量:{calls} 次调用 · {cost} · {days} 天","Historical Codex usage: {calls} calls · {cost} · {days} days").replace("{calls}",u.calls).replace("{cost}","$"+Number(u.cost??0).toFixed(2)).replace("{days}",u.days)):null,m?e("div",{className:"cm-msg err"},a("失败:","Failed: ")+m):null,e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn",onClick:x},a("保持现状","Keep status quo")),e("button",{type:"button",className:"cm-btn primary",disabled:n,onClick:()=>o(d.applyCodexCompatHistory)},a("统一归类为 Plan","Reclassify as Plan"))),e("p",{className:"cm-note"},a("之后可在 设置 → 费用 → Codex 订阅兼容 中处理。","You can change this later in Settings → Cost → Codex subscription compatibility."))))}function S(t){const s=t.state?.codexCompat,[d,c,a]=N();if(s?.installed!==!0)return null;const l=t.api,n=t.t,m=t.locale==="en",o=(u,x)=>m?x:u,i=s.usage??{},r=s.historyAppliedAt>0,p=s.planClass==="plan"?n("billingClassPlan"):s.planClass==="api"?n("billingClassApi"):n("billingClassAuto");return e("div",{className:"cm-codex-compat"},e("h3",null,o("Codex 订阅兼容","Codex subscription compatibility")),e("p",null,o("检测版本:{version}","Detected version: {version}").replace("{version}","v"+(s.version??""))),e("p",null,o("当前计费方式:{planClass}","Current billing class: {planClass}").replace("{planClass}",p)),e("p",null,o("历史用量:{calls} 次调用 · {cost} · {tokens} tokens · {days} 天","Historical usage: {calls} calls · {cost} · {tokens} tokens · {days} days").replace("{calls}",i.calls).replace("{cost}","$"+Number(i.cost??0).toFixed(2)).replace("{tokens}",Number(i.tokens??0).toLocaleString(m?"en-US":"zh-CN")).replace("{days}",i.days)),c?e("div",{className:"cm-msg err",role:"alert"},o("失败:","Failed: ")+c):null,r?e("p",{className:"cm-note"},o("已归类于 {time}","Reclassified at {time}").replace("{time}",new Date(s.historyAppliedAt).toLocaleString())):e("p",null,o("历史用量未归类。","Historical usage is not reclassified yet.")),!r&&i.providers?.length?e("p",{className:"cm-note"},o("来源:{providers}","Sources: {providers}").replace("{providers}",i.providers.join(", "))):null,r?null:e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn primary",disabled:d,onClick:()=>a(l.applyCodexCompatHistory)},o("统一归类为 Plan","Reclassify as Plan"))),!r&&s.promptDismissed===!0?e("p",{className:"cm-note"},o("此前选择保持现状,可随时统一归类。","You chose Keep status quo earlier; you can reclassify anytime.")):null)}function E(){return t=>e(t.view==="prompt"?P:S,t)}return{mount:E,CodexCompatPrompt:P,CodexCompatPanel:S}}});
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-cost-meter",chunk:"client.codex.js",factory:A=>{const k=A("react"),{createElement:e,useState:C,useEffect:g,useRef:h}=k,D="cm-stat-dialog cm-codex-compat-dialog";if(typeof document<"u"){const t=document.createElement("style");t.textContent=".cm-codex-compat-dialog{width:min(560px,94vw)}.cm-codex-compat{display:flex;flex-direction:column;gap:8px;font-size:13px}.cm-codex-compat :is(h3,p){margin:0}.cm-codex-compat h3{font-size:14px;font-weight:600}",t.textContent+='@media (max-width:1023px){.cm-codex-compat-dialog{width:calc(100vw - 32px)}.cm-codex-compat{padding:0 2px}}body[data-dsh-pocket-layout="mobile"] .cm-codex-compat-dialog{width:calc(100vw - 32px)}',document.head.appendChild(t)}const v="dsh-cost-meter:codex-compat-prompt-dismissed",b=new Set;let w=!1;function I(){if(w)return!0;try{return window.localStorage.getItem(v)==="1"}catch{return!1}}function _(){w=!0;try{window.localStorage.setItem(v,"1")}catch{}for(const t of b)t(!0)}function N(){const[t,y]=C(!1),[s,d]=C(null),c=h(!1);return[t,s,l=>{c.current||(c.current=!0,y(!0),d(null),Promise.resolve().then(l).catch(n=>d(n?.message??String(n))).finally(()=>{c.current=!1,y(!1)}))}]}function P(t){const s=t.state?.codexCompat,d=t.api,c=t.locale==="en",a=(f,L)=>c?L:f,l=h(null),[n,m,o]=N(),[i,r]=C(I),p=s?.enabled===!0&&s?.promptDue===!0&&!i;if(g(()=>(b.add(r),()=>b.delete(r)),[]),g(()=>{p&&l.current&&!l.current.open&&l.current.showModal()},[p]),!p)return null;const u=s.usage??{},x=()=>{l.current?.close(),r(!0),_(),Promise.resolve().then(()=>d.dismissCodexCompat()).catch(()=>{})};return e("dialog",{ref:l,className:D,"aria-label":a("兼容修复","Compatibility fix"),onCancel:f=>{f.preventDefault(),x()}},e("header",{className:"cm-stat-dialog-head"},a("兼容修复","Compatibility fix"),e("button",{type:"button",className:"cm-btn","aria-label":a("关闭","Close"),onClick:x},"×")),e("div",{className:"cm-stat-dialog-body"},e("p",null,a("检测到 dsh-codex-subscription {version}。Codex 订阅用量不计入 API 费用;为兼容本插件,新产生的 Codex 用量已自动归类为 Plan。是否将历史 codex 类模型的计费统一归类为 Plan(订阅额度,不计入 API 费用)?","Detected dsh-codex-subscription {version}. Codex subscription usage is not billed as API usage; for compatibility this plugin now defaults new Codex usage to Plan. Reclassify the billing of historical codex-class models as Plan (subscription quota, excluded from API usage)?").replace("{version}","v"+(s.version??""))),u.calls>0?e("p",{className:"cm-note"},a("历史 Codex 用量:{calls} 次调用 · {cost} · {days} 天","Historical Codex usage: {calls} calls · {cost} · {days} days").replace("{calls}",u.calls).replace("{cost}","$"+Number(u.cost??0).toFixed(2)).replace("{days}",u.days)):null,m?e("div",{className:"cm-msg err"},a("失败:","Failed: ")+m):null,e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn",onClick:x},a("保持现状","Keep status quo")),e("button",{type:"button",className:"cm-btn primary",disabled:n,onClick:()=>o(d.applyCodexCompatHistory)},a("统一归类为 Plan","Reclassify as Plan"))),e("p",{className:"cm-note"},a("之后可在 设置 → 费用 → Codex 订阅兼容 中处理。","You can change this later in Settings → Cost → Codex subscription compatibility."))))}function S(t){const s=t.state?.codexCompat,[d,c,a]=N();if(s?.installed!==!0||s?.enabled!==!0)return null;const l=t.api,n=t.t,m=t.locale==="en",o=(u,x)=>m?x:u,i=s.usage??{},r=s.historyAppliedAt>0,p=s.planClass==="plan"?n("billingClassPlan"):s.planClass==="api"?n("billingClassApi"):n("billingClassAuto");return e("div",{className:"cm-codex-compat"},e("h3",null,o("Codex 订阅兼容","Codex subscription compatibility")),e("p",null,o("检测版本:{version}","Detected version: {version}").replace("{version}","v"+(s.version??""))),e("p",null,o("当前计费方式:{planClass}","Current billing class: {planClass}").replace("{planClass}",p)),e("p",null,o("历史用量:{calls} 次调用 · {cost} · {tokens} tokens · {days} 天","Historical usage: {calls} calls · {cost} · {tokens} tokens · {days} days").replace("{calls}",i.calls).replace("{cost}","$"+Number(i.cost??0).toFixed(2)).replace("{tokens}",Number(i.tokens??0).toLocaleString(m?"en-US":"zh-CN")).replace("{days}",i.days)),c?e("div",{className:"cm-msg err",role:"alert"},o("失败:","Failed: ")+c):null,r?e("p",{className:"cm-note"},o("已归类于 {time}","Reclassified at {time}").replace("{time}",new Date(s.historyAppliedAt).toLocaleString())):e("p",null,o("历史用量未归类。","Historical usage is not reclassified yet.")),!r&&i.providers?.length?e("p",{className:"cm-note"},o("来源:{providers}","Sources: {providers}").replace("{providers}",i.providers.join(", "))):null,r?null:e("div",{className:"cm-buttons"},e("button",{type:"button",className:"cm-btn primary",disabled:d,onClick:()=>a(l.applyCodexCompatHistory)},o("统一归类为 Plan","Reclassify as Plan"))),!r&&s.promptDismissed===!0?e("p",{className:"cm-note"},o("此前选择保持现状,可随时统一归类。","You chose Keep status quo earlier; you can reclassify anytime.")):null)}function E(){return t=>e(t.view==="prompt"?P:S,t)}return{mount:E,CodexCompatPrompt:P,CodexCompatPanel:S}}});
|