@chenlongapps/opencode-token-usage 0.4.4 → 0.4.6
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.md +6 -2
- package/README.zh-CN.md +6 -2
- package/dist/context-sources.js +4 -1
- package/dist/prices.generated.d.ts +95 -8
- package/dist/prices.generated.js +13 -6
- package/dist/pricing.d.ts +1 -1
- package/docs/pricing.md +4 -2
- package/docs/verification.md +48 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Alternatively, add the package to your project's `opencode.json` or `opencode.js
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
> [!NOTE]
|
|
37
|
-
> Requires Node.js 22
|
|
37
|
+
> Requires Node.js 22+ (see the OpenTUI engine note under [Development](#development)). OpenCode 2.0.9 and 2.0.10 have been verified in earlier releases. The current SDK 2.0.24 build has been verified on OpenCode 2.0.11, 2.0.22, and 2.0.24.
|
|
38
38
|
|
|
39
39
|
Restart OpenCode after installation. The panel appears in the native sidebar when `session.sidebar` is set to `auto` and the terminal is wide enough. OpenCode hides the sidebar in subagent views, so the plugin keeps one live summary line above the composer with Context, Total, Cost, and TPS. Click the line to open the full statistics in a centered dialog. Press Escape or click **esc** to close it; closing the dialog does not interrupt the subagent.
|
|
40
40
|
|
|
@@ -99,7 +99,11 @@ npm run build
|
|
|
99
99
|
npm run test:smoke
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
The
|
|
102
|
+
The OpenCode SDK packages are pinned to `2.0.24`, with OpenTUI `0.5.14`. Clean installation, typecheck, tests, build, and real-host smoke have passed on Node.js 22. OpenTUI declares Node.js `>=26.4.0` for its native Node runtime, so npm reports `EBADENGINE` on Node 22; `engine-strict` installations require a Node version meeting that dependency's engine requirement. The plugin's TUI runs inside OpenCode, not as a standalone Node 22 renderer. This upgrade keeps the project's Node.js 22+ minimum unchanged.
|
|
103
|
+
|
|
104
|
+
The [price update workflow](.github/workflows/update-prices.yml) checks models.dev every day at 22:00 UTC (or on demand via **Run workflow** on `main`). No snapshot diff means no release. Changes within the reviewed first-party source allowlist pass typecheck, tests, build, and pack validation, then automatically bump the patch version (for example, `0.4.4` → `0.4.5`), commit only `src/prices.generated.ts`, `package.json`, and `package-lock.json`, and atomically push `main` and its version tag. The workflow creates a GitHub Release and explicitly dispatches [`publish.yml`](.github/workflows/publish.yml) on that tag to publish via npm Trusted Publishing/OIDC; no long-lived npm token is needed. GitHub Actions must be allowed to push to `main` and create tags, and npm must trust `publish.yml` with permission to run `npm publish`.
|
|
105
|
+
|
|
106
|
+
Failed validation never bumps the version. An unfinished tagged price release is retried with the same version before checking new prices; registry outages are not treated as missing versions. Publishing skips versions already on npm, prevents moving `latest` backwards, and verifies registry visibility after publication. Manufacturer/source allowlist additions, aliases, and manually verified price exceptions still require human review. See the [release guide](docs/releasing.md) for setup and retries.
|
|
103
107
|
|
|
104
108
|
For a manual refresh, run `npm run prices:update` in a networked environment, review the generated diff and exceptions, then run the checks above. Builds and plugin refreshes do not contact models.dev.
|
|
105
109
|
|
package/README.zh-CN.md
CHANGED
|
@@ -34,7 +34,7 @@ opencode plugin add @chenlongapps/opencode-token-usage
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
> [!NOTE]
|
|
37
|
-
> 需要 Node.js 22
|
|
37
|
+
> 需要 Node.js 22+(见[开发](#开发)中的 OpenTUI 引擎说明)。此前发布已验证 OpenCode 2.0.9 和 2.0.10;当前 SDK 2.0.24 构建已在 OpenCode 2.0.11、2.0.22 和 2.0.24 上验证。
|
|
38
38
|
|
|
39
39
|
安装后重启 OpenCode。终端足够宽且 `session.sidebar` 设为 `auto` 时,面板会显示在原生侧边栏中。OpenCode 在子代理视图中隐藏侧边栏,因此插件会在输入区上方保留一行实时摘要,显示 Context、Total、Cost 和 TPS。点击摘要可在居中弹窗中查看完整统计;按 Escape 或点击 **esc** 即可关闭,关闭弹窗不会中断子代理。
|
|
40
40
|
|
|
@@ -99,7 +99,11 @@ npm run build
|
|
|
99
99
|
npm run test:smoke
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
OpenCode SDK 包精确锁定为 `2.0.24`,OpenTUI 为 `0.5.14`。Node.js 22 下已通过干净安装、类型检查、测试、构建和真实宿主 smoke。OpenTUI 为其原生 Node 运行时声明 Node.js `>=26.4.0`,因此 Node 22 安装时 npm 会输出 `EBADENGINE`;启用 `engine-strict` 时须使用满足该依赖引擎要求的 Node 版本。插件的 TUI 在 OpenCode 内运行,并非独立的 Node 22 渲染器。本次升级保持项目 Node.js 22+ 的最低要求不变。
|
|
103
|
+
|
|
104
|
+
[价格更新工作流](.github/workflows/update-prices.yml) 每天 UTC 22:00 检查 models.dev,也可在 `main` 上通过 **Run workflow** 手动触发。快照无变化就不发布。经审核的原厂来源白名单内有变化时,先通过类型检查、测试、构建和打包检查,再自动升级 patch 版本(例如 `0.4.4` → `0.4.5`),只提交 `src/prices.generated.ts`、`package.json` 和 `package-lock.json`,并原子推送 `main` 与版本标签。工作流创建 GitHub Release,显式触发该标签上的 [`publish.yml`](.github/workflows/publish.yml),通过 npm Trusted Publishing/OIDC 发布,无需长期 npm token。仓库必须允许 GitHub Actions 推送 `main` 和创建标签;npm 必须信任 `publish.yml` 并允许执行 `npm publish`。
|
|
105
|
+
|
|
106
|
+
验证失败不会升版本。已打标签但未完成的自动价格发布会优先重试同一版本,再检查新价格;registry 故障不会被当作版本不存在。发布时跳过 npm 已有版本、防止 `latest` 倒退,并在发布后核验 registry 中的版本。新增原厂/来源白名单、别名及人工核实的价格例外仍需人工审核。配置和重试方法见[发布说明](docs/releasing.md)。
|
|
103
107
|
|
|
104
108
|
手动更新时,在联网的维护环境运行 `npm run prices:update`,审阅生成文件及例外差异,再执行上述检查。构建和插件刷新不会请求 models.dev。
|
|
105
109
|
|
package/dist/context-sources.js
CHANGED
|
@@ -57,7 +57,10 @@ export function estimateContextSources(request, mcpServers = [], capturedAt = Da
|
|
|
57
57
|
}
|
|
58
58
|
if (part.type === "media") {
|
|
59
59
|
// Media payload sizes do not translate to provider token counts.
|
|
60
|
-
|
|
60
|
+
// Older hosts expose mediaType directly; SDK 2.0.24 wraps it in an asset.
|
|
61
|
+
const mediaType = part.media?.mediaType
|
|
62
|
+
?? ("mediaType" in part && typeof part.mediaType === "string" ? part.mediaType : "");
|
|
63
|
+
tokens.Other += estimate(part.filename ?? mediaType);
|
|
61
64
|
continue;
|
|
62
65
|
}
|
|
63
66
|
if (part.type === "tool-call") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
2
|
-
readonly verified: "2026-10-
|
|
2
|
+
readonly verified: "2026-10-08";
|
|
3
3
|
readonly source: "https://models.dev/api.json";
|
|
4
4
|
readonly entries: readonly [{
|
|
5
5
|
readonly providerID: "ai21";
|
|
@@ -92,8 +92,8 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
92
92
|
readonly providerID: "alibaba";
|
|
93
93
|
readonly id: "qwen-vl-ocr";
|
|
94
94
|
readonly prices: readonly [{
|
|
95
|
-
readonly input: 0.
|
|
96
|
-
readonly output: 0.
|
|
95
|
+
readonly input: 0.07;
|
|
96
|
+
readonly output: 0.16;
|
|
97
97
|
}];
|
|
98
98
|
readonly released: "2024-10-28";
|
|
99
99
|
}, {
|
|
@@ -550,6 +550,29 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
550
550
|
};
|
|
551
551
|
}];
|
|
552
552
|
readonly released: "2025-10-15";
|
|
553
|
+
}, {
|
|
554
|
+
readonly providerID: "anthropic";
|
|
555
|
+
readonly id: "claude-haiku-5-5";
|
|
556
|
+
readonly prices: readonly [{
|
|
557
|
+
readonly input: 0.1;
|
|
558
|
+
readonly output: 0.5;
|
|
559
|
+
readonly cache: {
|
|
560
|
+
readonly read: 0.01;
|
|
561
|
+
readonly write: 0.125;
|
|
562
|
+
};
|
|
563
|
+
}, {
|
|
564
|
+
readonly input: 0.5;
|
|
565
|
+
readonly output: 2.5;
|
|
566
|
+
readonly cache: {
|
|
567
|
+
readonly read: 0.05;
|
|
568
|
+
readonly write: 0.625;
|
|
569
|
+
};
|
|
570
|
+
readonly tier: {
|
|
571
|
+
readonly type: "context";
|
|
572
|
+
readonly size: 100000;
|
|
573
|
+
};
|
|
574
|
+
}];
|
|
575
|
+
readonly released: "2026-10-07";
|
|
553
576
|
}, {
|
|
554
577
|
readonly providerID: "anthropic";
|
|
555
578
|
readonly id: "claude-opus-4-5";
|
|
@@ -728,7 +751,7 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
728
751
|
readonly input: 2;
|
|
729
752
|
readonly output: 10;
|
|
730
753
|
readonly cache: {
|
|
731
|
-
readonly read: 0.
|
|
754
|
+
readonly read: 0.1;
|
|
732
755
|
readonly write: 2.5;
|
|
733
756
|
};
|
|
734
757
|
}];
|
|
@@ -869,10 +892,10 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
869
892
|
readonly providerID: "deepseek";
|
|
870
893
|
readonly id: "deepseek-v4-pro";
|
|
871
894
|
readonly prices: readonly [{
|
|
872
|
-
readonly input: 0.
|
|
873
|
-
readonly output:
|
|
895
|
+
readonly input: 0.66;
|
|
896
|
+
readonly output: 1.98;
|
|
874
897
|
readonly cache: {
|
|
875
|
-
readonly read: 0.
|
|
898
|
+
readonly read: 0.022;
|
|
876
899
|
};
|
|
877
900
|
}];
|
|
878
901
|
readonly released: "2026-08-12";
|
|
@@ -1266,7 +1289,7 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1266
1289
|
readonly input: 0.6;
|
|
1267
1290
|
readonly output: 2.4;
|
|
1268
1291
|
readonly cache: {
|
|
1269
|
-
readonly read: 0.
|
|
1292
|
+
readonly read: 0.03;
|
|
1270
1293
|
readonly write: 0.375;
|
|
1271
1294
|
};
|
|
1272
1295
|
}];
|
|
@@ -1316,6 +1339,17 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1316
1339
|
};
|
|
1317
1340
|
}];
|
|
1318
1341
|
readonly released: "2026-06-01";
|
|
1342
|
+
}, {
|
|
1343
|
+
readonly providerID: "mistral";
|
|
1344
|
+
readonly id: "codestral-2508";
|
|
1345
|
+
readonly prices: readonly [{
|
|
1346
|
+
readonly input: 0.3;
|
|
1347
|
+
readonly output: 0.9;
|
|
1348
|
+
readonly cache: {
|
|
1349
|
+
readonly read: 0.03;
|
|
1350
|
+
};
|
|
1351
|
+
}];
|
|
1352
|
+
readonly released: "2025-07-30";
|
|
1319
1353
|
}, {
|
|
1320
1354
|
readonly providerID: "mistral";
|
|
1321
1355
|
readonly id: "codestral-latest";
|
|
@@ -1391,6 +1425,28 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1391
1425
|
readonly output: 5;
|
|
1392
1426
|
}];
|
|
1393
1427
|
readonly released: "2025-03-17";
|
|
1428
|
+
}, {
|
|
1429
|
+
readonly providerID: "mistral";
|
|
1430
|
+
readonly id: "ministral-14b-2512";
|
|
1431
|
+
readonly prices: readonly [{
|
|
1432
|
+
readonly input: 0.2;
|
|
1433
|
+
readonly output: 0.2;
|
|
1434
|
+
readonly cache: {
|
|
1435
|
+
readonly read: 0.02;
|
|
1436
|
+
};
|
|
1437
|
+
}];
|
|
1438
|
+
readonly released: "2025-12-02";
|
|
1439
|
+
}, {
|
|
1440
|
+
readonly providerID: "mistral";
|
|
1441
|
+
readonly id: "ministral-3b-2512";
|
|
1442
|
+
readonly prices: readonly [{
|
|
1443
|
+
readonly input: 0.1;
|
|
1444
|
+
readonly output: 0.1;
|
|
1445
|
+
readonly cache: {
|
|
1446
|
+
readonly read: 0.01;
|
|
1447
|
+
};
|
|
1448
|
+
}];
|
|
1449
|
+
readonly released: "2025-12-02";
|
|
1394
1450
|
}, {
|
|
1395
1451
|
readonly providerID: "mistral";
|
|
1396
1452
|
readonly id: "ministral-3b-latest";
|
|
@@ -1399,6 +1455,17 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1399
1455
|
readonly output: 0.04;
|
|
1400
1456
|
}];
|
|
1401
1457
|
readonly released: "2024-10-01";
|
|
1458
|
+
}, {
|
|
1459
|
+
readonly providerID: "mistral";
|
|
1460
|
+
readonly id: "ministral-8b-2512";
|
|
1461
|
+
readonly prices: readonly [{
|
|
1462
|
+
readonly input: 0.15;
|
|
1463
|
+
readonly output: 0.15;
|
|
1464
|
+
readonly cache: {
|
|
1465
|
+
readonly read: 0.015;
|
|
1466
|
+
};
|
|
1467
|
+
}];
|
|
1468
|
+
readonly released: "2025-12-02";
|
|
1402
1469
|
}, {
|
|
1403
1470
|
readonly providerID: "mistral";
|
|
1404
1471
|
readonly id: "ministral-8b-latest";
|
|
@@ -1426,6 +1493,17 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1426
1493
|
};
|
|
1427
1494
|
}];
|
|
1428
1495
|
readonly released: "2024-11-01";
|
|
1496
|
+
}, {
|
|
1497
|
+
readonly providerID: "mistral";
|
|
1498
|
+
readonly id: "mistral-large-4";
|
|
1499
|
+
readonly prices: readonly [{
|
|
1500
|
+
readonly input: 0.68;
|
|
1501
|
+
readonly output: 2.09;
|
|
1502
|
+
readonly cache: {
|
|
1503
|
+
readonly read: 0.07;
|
|
1504
|
+
};
|
|
1505
|
+
}];
|
|
1506
|
+
readonly released: "2026-10-06";
|
|
1429
1507
|
}, {
|
|
1430
1508
|
readonly providerID: "mistral";
|
|
1431
1509
|
readonly id: "mistral-large-latest";
|
|
@@ -1561,6 +1639,14 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1561
1639
|
readonly output: 6;
|
|
1562
1640
|
}];
|
|
1563
1641
|
readonly released: "2024-11-01";
|
|
1642
|
+
}, {
|
|
1643
|
+
readonly providerID: "mistral";
|
|
1644
|
+
readonly id: "voxtral-small-2507";
|
|
1645
|
+
readonly prices: readonly [{
|
|
1646
|
+
readonly input: 0.1;
|
|
1647
|
+
readonly output: 0.4;
|
|
1648
|
+
}];
|
|
1649
|
+
readonly released: "2025-07-15";
|
|
1564
1650
|
}, {
|
|
1565
1651
|
readonly providerID: "mistral";
|
|
1566
1652
|
readonly id: "voxtral-small-latest";
|
|
@@ -1610,6 +1696,7 @@ export declare const GENERATED_PRICE_SNAPSHOT: {
|
|
|
1610
1696
|
readonly output: 15;
|
|
1611
1697
|
readonly cache: {
|
|
1612
1698
|
readonly read: 0.3;
|
|
1699
|
+
readonly write: 3;
|
|
1613
1700
|
};
|
|
1614
1701
|
}];
|
|
1615
1702
|
readonly released: "2026-07-16";
|
package/dist/prices.generated.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const GENERATED_PRICE_SNAPSHOT = {
|
|
2
|
-
verified: "2026-10-
|
|
2
|
+
verified: "2026-10-08",
|
|
3
3
|
source: "https://models.dev/api.json",
|
|
4
4
|
entries: [
|
|
5
5
|
{ "providerID": "ai21", "id": "jamba-large", "prices": [{ "input": 2, "output": 8 }], "released": "2025-07-01" },
|
|
@@ -13,7 +13,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
13
13
|
{ "providerID": "alibaba", "id": "qwen-plus-character-ja", "prices": [{ "input": 0.5, "output": 1.4 }] },
|
|
14
14
|
{ "providerID": "alibaba", "id": "qwen-turbo", "prices": [{ "input": 0.05, "output": 0.2, "reasoning": 0.5 }], "released": "2024-11-01" },
|
|
15
15
|
{ "providerID": "alibaba", "id": "qwen-vl-max", "prices": [{ "input": 0.8, "output": 3.2 }], "released": "2024-04-08" },
|
|
16
|
-
{ "providerID": "alibaba", "id": "qwen-vl-ocr", "prices": [{ "input": 0.
|
|
16
|
+
{ "providerID": "alibaba", "id": "qwen-vl-ocr", "prices": [{ "input": 0.07, "output": 0.16 }], "released": "2024-10-28" },
|
|
17
17
|
{ "providerID": "alibaba", "id": "qwen-vl-plus", "prices": [{ "input": 0.21, "output": 0.63 }], "released": "2024-01-25" },
|
|
18
18
|
{ "providerID": "alibaba", "id": "qwen2-5-14b-instruct", "prices": [{ "input": 0.35, "output": 1.4 }] },
|
|
19
19
|
{ "providerID": "alibaba", "id": "qwen2-5-32b-instruct", "prices": [{ "input": 0.7, "output": 2.8 }] },
|
|
@@ -58,6 +58,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
58
58
|
{ "providerID": "anthropic", "id": "claude-fable-5-1", "prices": [{ "input": 10, "output": 50, "cache": { "read": 0.25, "write": 12.5 } }], "released": "2026-09-01" },
|
|
59
59
|
{ "providerID": "anthropic", "id": "claude-haiku-4-5", "prices": [{ "input": 1, "output": 5, "cache": { "read": 0.1, "write": 1.25 } }], "released": "2025-10-15" },
|
|
60
60
|
{ "providerID": "anthropic", "id": "claude-haiku-4-5-20251001", "prices": [{ "input": 1, "output": 5, "cache": { "read": 0.1, "write": 1.25 } }], "released": "2025-10-15" },
|
|
61
|
+
{ "providerID": "anthropic", "id": "claude-haiku-5-5", "prices": [{ "input": 0.1, "output": 0.5, "cache": { "read": 0.01, "write": 0.125 } }, { "input": 0.5, "output": 2.5, "cache": { "read": 0.05, "write": 0.625 }, "tier": { "type": "context", "size": 100000 } }], "released": "2026-10-07" },
|
|
61
62
|
{ "providerID": "anthropic", "id": "claude-opus-4-5", "prices": [{ "input": 5, "output": 25, "cache": { "read": 0.5, "write": 6.25 } }], "released": "2025-11-24" },
|
|
62
63
|
{ "providerID": "anthropic", "id": "claude-opus-4-5-20251101", "prices": [{ "input": 5, "output": 25, "cache": { "read": 0.5, "write": 6.25 } }], "released": "2025-11-24" },
|
|
63
64
|
{ "providerID": "anthropic", "id": "claude-opus-4-6", "prices": [{ "input": 5, "output": 25, "cache": { "read": 0.5, "write": 6.25 } }], "released": "2026-02-04" },
|
|
@@ -72,7 +73,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
72
73
|
{ "providerID": "anthropic", "id": "claude-sonnet-4-5-20250929", "prices": [{ "input": 3, "output": 15, "cache": { "read": 0.3, "write": 3.75 } }], "released": "2025-09-29" },
|
|
73
74
|
{ "providerID": "anthropic", "id": "claude-sonnet-4-6", "prices": [{ "input": 3, "output": 15, "cache": { "read": 0.3, "write": 3.75 } }], "released": "2026-02-17" },
|
|
74
75
|
{ "providerID": "anthropic", "id": "claude-sonnet-5", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.2, "write": 2.5 } }], "released": "2026-06-29" },
|
|
75
|
-
{ "providerID": "anthropic", "id": "claude-sonnet-5-5", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.
|
|
76
|
+
{ "providerID": "anthropic", "id": "claude-sonnet-5-5", "prices": [{ "input": 2, "output": 10, "cache": { "read": 0.1, "write": 2.5 } }], "released": "2026-09-28" },
|
|
76
77
|
{ "providerID": "arcee", "id": "trinity-large-thinking", "prices": [{ "input": 0.25, "output": 0.8, "cache": { "read": 0.06 } }], "released": "2026-04-01" },
|
|
77
78
|
{ "providerID": "cohere", "id": "command-a-03-2025", "prices": [{ "input": 2.5, "output": 10 }], "released": "2025-03-13" },
|
|
78
79
|
{ "providerID": "cohere", "id": "command-a-plus-05-2026", "prices": [{ "input": 2.5, "output": 10 }], "released": "2026-05-20" },
|
|
@@ -88,7 +89,7 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
88
89
|
{ "providerID": "deepseek", "id": "deepseek-flash", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.003 } }], "released": "2026-09-10" },
|
|
89
90
|
{ "providerID": "deepseek", "id": "deepseek-v4-flash", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.003 } }], "released": "2026-09-10" },
|
|
90
91
|
{ "providerID": "deepseek", "id": "deepseek-v4-flash-vision-exp", "prices": [{ "input": 0.15, "output": 0.6, "cache": { "read": 0.003 } }], "released": "2026-09-10" },
|
|
91
|
-
{ "providerID": "deepseek", "id": "deepseek-v4-pro", "prices": [{ "input": 0.
|
|
92
|
+
{ "providerID": "deepseek", "id": "deepseek-v4-pro", "prices": [{ "input": 0.66, "output": 1.98, "cache": { "read": 0.022 } }], "released": "2026-08-12" },
|
|
92
93
|
{ "providerID": "google", "id": "deep-research-max-preview-04-2026", "prices": [{ "input": 2, "output": 12, "cache": { "read": 0.2 } }, { "input": 4, "output": 18, "cache": { "read": 0.4 }, "tier": { "type": "context", "size": 200000 } }], "released": "2026-04-21" },
|
|
93
94
|
{ "providerID": "google", "id": "deep-research-preview-04-2026", "prices": [{ "input": 2, "output": 12, "cache": { "read": 0.2 } }, { "input": 4, "output": 18, "cache": { "read": 0.4 }, "tier": { "type": "context", "size": 200000 } }], "released": "2026-04-21" },
|
|
94
95
|
{ "providerID": "google", "id": "gemini-2.5-computer-use-preview-10-2025", "prices": [{ "input": 1.25, "output": 10 }, { "input": 2.5, "output": 15, "tier": { "type": "context", "size": 200000 } }], "released": "2025-10-07" },
|
|
@@ -119,10 +120,11 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
119
120
|
{ "providerID": "minimax", "id": "minimax-m2", "prices": [{ "input": 0.3, "output": 1.2 }], "released": "2025-10-27" },
|
|
120
121
|
{ "providerID": "minimax", "id": "minimax-m2.1", "prices": [{ "input": 0.3, "output": 1.2, "cache": { "read": 0.03, "write": 0.375 } }], "released": "2025-12-23" },
|
|
121
122
|
{ "providerID": "minimax", "id": "minimax-m2.5", "prices": [{ "input": 0.3, "output": 1.2, "cache": { "read": 0.03, "write": 0.375 } }], "released": "2026-02-12" },
|
|
122
|
-
{ "providerID": "minimax", "id": "minimax-m2.5-highspeed", "prices": [{ "input": 0.6, "output": 2.4, "cache": { "read": 0.
|
|
123
|
+
{ "providerID": "minimax", "id": "minimax-m2.5-highspeed", "prices": [{ "input": 0.6, "output": 2.4, "cache": { "read": 0.03, "write": 0.375 } }], "released": "2026-02-13" },
|
|
123
124
|
{ "providerID": "minimax", "id": "minimax-m2.7", "prices": [{ "input": 0.3, "output": 1.2, "cache": { "read": 0.06, "write": 0.375 } }], "released": "2026-03-18" },
|
|
124
125
|
{ "providerID": "minimax", "id": "minimax-m2.7-highspeed", "prices": [{ "input": 0.6, "output": 2.4, "cache": { "read": 0.06, "write": 0.375 } }], "released": "2026-03-18" },
|
|
125
126
|
{ "providerID": "minimax", "id": "minimax-m3", "prices": [{ "input": 0.3, "output": 1.2, "cache": { "read": 0.06 } }, { "input": 0.6, "output": 2.4, "cache": { "read": 0.12 }, "tier": { "type": "context", "size": 512000 } }], "released": "2026-06-01" },
|
|
127
|
+
{ "providerID": "mistral", "id": "codestral-2508", "prices": [{ "input": 0.3, "output": 0.9, "cache": { "read": 0.03 } }], "released": "2025-07-30" },
|
|
126
128
|
{ "providerID": "mistral", "id": "codestral-latest", "prices": [{ "input": 0.3, "output": 0.9, "cache": { "read": 0.03 } }], "released": "2024-05-29" },
|
|
127
129
|
{ "providerID": "mistral", "id": "devstral-2512", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-12-09" },
|
|
128
130
|
{ "providerID": "mistral", "id": "devstral-latest", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-12-09" },
|
|
@@ -132,10 +134,14 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
132
134
|
{ "providerID": "mistral", "id": "devstral-small-2507", "prices": [{ "input": 0.1, "output": 0.3 }], "released": "2025-07-10" },
|
|
133
135
|
{ "providerID": "mistral", "id": "labs-devstral-small-2512", "prices": [{ "input": 0, "output": 0 }], "released": "2025-12-09" },
|
|
134
136
|
{ "providerID": "mistral", "id": "magistral-medium-latest", "prices": [{ "input": 2, "output": 5 }], "released": "2025-03-17" },
|
|
137
|
+
{ "providerID": "mistral", "id": "ministral-14b-2512", "prices": [{ "input": 0.2, "output": 0.2, "cache": { "read": 0.02 } }], "released": "2025-12-02" },
|
|
138
|
+
{ "providerID": "mistral", "id": "ministral-3b-2512", "prices": [{ "input": 0.1, "output": 0.1, "cache": { "read": 0.01 } }], "released": "2025-12-02" },
|
|
135
139
|
{ "providerID": "mistral", "id": "ministral-3b-latest", "prices": [{ "input": 0.04, "output": 0.04 }], "released": "2024-10-01" },
|
|
140
|
+
{ "providerID": "mistral", "id": "ministral-8b-2512", "prices": [{ "input": 0.15, "output": 0.15, "cache": { "read": 0.015 } }], "released": "2025-12-02" },
|
|
136
141
|
{ "providerID": "mistral", "id": "ministral-8b-latest", "prices": [{ "input": 0.1, "output": 0.1 }], "released": "2024-10-01" },
|
|
137
142
|
{ "providerID": "mistral", "id": "mistral-large-2411", "prices": [{ "input": 2, "output": 6 }], "released": "2024-11-18" },
|
|
138
143
|
{ "providerID": "mistral", "id": "mistral-large-2512", "prices": [{ "input": 0.5, "output": 1.5, "cache": { "read": 0.05 } }], "released": "2024-11-01" },
|
|
144
|
+
{ "providerID": "mistral", "id": "mistral-large-4", "prices": [{ "input": 0.68, "output": 2.09, "cache": { "read": 0.07 } }], "released": "2026-10-06" },
|
|
139
145
|
{ "providerID": "mistral", "id": "mistral-large-latest", "prices": [{ "input": 0.5, "output": 1.5, "cache": { "read": 0.05 } }], "released": "2024-11-01" },
|
|
140
146
|
{ "providerID": "mistral", "id": "mistral-medium-2505", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-05-07" },
|
|
141
147
|
{ "providerID": "mistral", "id": "mistral-medium-2508", "prices": [{ "input": 0.4, "output": 2 }], "released": "2025-08-12" },
|
|
@@ -151,11 +157,12 @@ export const GENERATED_PRICE_SNAPSHOT = {
|
|
|
151
157
|
{ "providerID": "mistral", "id": "open-mixtral-8x7b", "prices": [{ "input": 0.7, "output": 0.7 }], "released": "2023-12-11" },
|
|
152
158
|
{ "providerID": "mistral", "id": "pixtral-12b", "prices": [{ "input": 0.15, "output": 0.15 }], "released": "2024-09-01" },
|
|
153
159
|
{ "providerID": "mistral", "id": "pixtral-large-latest", "prices": [{ "input": 2, "output": 6 }], "released": "2024-11-01" },
|
|
160
|
+
{ "providerID": "mistral", "id": "voxtral-small-2507", "prices": [{ "input": 0.1, "output": 0.4 }], "released": "2025-07-15" },
|
|
154
161
|
{ "providerID": "mistral", "id": "voxtral-small-latest", "prices": [{ "input": 0.1, "output": 0.3 }], "released": "2025-07-15" },
|
|
155
162
|
{ "providerID": "moonshotai", "id": "kimi-k2.6", "prices": [{ "input": 0.95, "output": 4, "cache": { "read": 0.16 } }], "released": "2026-04-21" },
|
|
156
163
|
{ "providerID": "moonshotai", "id": "kimi-k2.7-code", "prices": [{ "input": 0.95, "output": 4, "cache": { "read": 0.19 } }], "released": "2026-06-12" },
|
|
157
164
|
{ "providerID": "moonshotai", "id": "kimi-k2.7-code-highspeed", "prices": [{ "input": 1.9, "output": 8, "cache": { "read": 0.38 } }], "released": "2026-06-12" },
|
|
158
|
-
{ "providerID": "moonshotai", "id": "kimi-k3", "prices": [{ "input": 3, "output": 15, "cache": { "read": 0.3 } }], "released": "2026-07-16" },
|
|
165
|
+
{ "providerID": "moonshotai", "id": "kimi-k3", "prices": [{ "input": 3, "output": 15, "cache": { "read": 0.3, "write": 3 } }], "released": "2026-07-16" },
|
|
159
166
|
{ "providerID": "nvidia", "id": "nvidia/llama-3.1-nemotron-70b-instruct", "prices": [{ "input": 0, "output": 0 }], "released": "2025-04-15" },
|
|
160
167
|
{ "providerID": "nvidia", "id": "nvidia/llama-3.1-nemotron-nano-8b-v1", "prices": [{ "input": 0, "output": 0 }], "released": "2025-03-18" },
|
|
161
168
|
{ "providerID": "nvidia", "id": "nvidia/llama-3.1-nemotron-nano-vl-8b-v1", "prices": [{ "input": 0, "output": 0 }], "released": "2025-04-10" },
|
package/dist/pricing.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface OfficialPriceEntry {
|
|
|
14
14
|
/** Checked-in data: updating prices is explicit, not a network request at
|
|
15
15
|
* startup, during a refresh, or during an npm build. */
|
|
16
16
|
export declare const OFFICIAL_PRICE_SNAPSHOT: {
|
|
17
|
-
verified: "2026-10-
|
|
17
|
+
verified: "2026-10-08";
|
|
18
18
|
source: "https://models.dev/api.json";
|
|
19
19
|
entries: OfficialPriceEntry[];
|
|
20
20
|
};
|
package/docs/pricing.md
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
## 更新方式
|
|
6
6
|
|
|
7
|
-
GitHub Actions [价格更新工作流](../.github/workflows/update-prices.yml) 每天 UTC
|
|
7
|
+
GitHub Actions [价格更新工作流](../.github/workflows/update-prices.yml) 每天 UTC 22:00 从 models.dev 检查一次,也可从 Actions 页面在 `main` 上手动触发。生成快照没有差异就结束,不会因检查日期或 API 中未导入的元数据变化发布新版本。白名单内的快照有变化(包含新增、移除和重新定价)时,先运行类型检查、测试、构建和 `npm pack --dry-run`,全部通过后自动升级 patch 版本,只提交 `src/prices.generated.ts`、`package.json`、`package-lock.json`,原子推送 `main` 与版本标签,再创建 GitHub Release 并显式触发 `publish.yml` 自动发布 npm。
|
|
8
|
+
|
|
9
|
+
验证失败不升版本;并发修改 `main` 会令原子推送失败,不覆盖他人提交或留下孤立的远端标签。已推送但 npm 未完成的自动价格版本会先重试原标签,不再递增版本。npm 查询只有明确的 404 才视为版本不存在,网络错误会停止流程。工作流摘要记录快照条数与新增/移除/变化数量;最终 npm 结果见发布工作流。仓库推送权限与 npm Trusted Publishing 配置见[发布说明](releasing.md)。
|
|
8
10
|
|
|
9
11
|
本地手动更新可在联网的维护环境中运行:
|
|
10
12
|
|
|
@@ -15,7 +17,7 @@ npm test
|
|
|
15
17
|
npm run build
|
|
16
18
|
```
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
本地更新时,审阅生成文件与 `overrides.ts` 的差异后提交。更新脚本只请求 `https://models.dev/api.json`,从人工确认的**原厂 Provider + 自家模型系列**提取公开的文本模型价格;原厂平台上托管的其他厂商模型、OpenRouter 等网关报价、地域性/订阅制费率不作为回退价格来源。自动化不修改来源白名单、别名或人工例外。API 不标注模型的真实厂商,因此新增原厂或新系列需要维护者先审核并扩充 `ORIGINAL_PROVIDERS`,不能按相似名称自动猜测。
|
|
19
21
|
|
|
20
22
|
`src/prices.generated.ts` 是随 npm 包发布的离线快照:插件启动、刷新、构建、打包和测试均不请求 models.dev。`src/aliases.ts` 只记录无法按已知包装形式解决的厂商 slug 与精确模型 ID 差异;`src/overrides.ts` 只记录有原厂来源的缺失 SKU、已核实的例外费率及无法直接使用的 API 字段。普通价格变动通过重新生成快照维护,不往别名或例外表中增加常规型号。
|
|
21
23
|
|
package/docs/verification.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# 验证记录
|
|
2
2
|
|
|
3
|
+
## 2026-10-07 · SDK 2.0.24 升级
|
|
4
|
+
|
|
5
|
+
环境:macOS、Node.js v22.23.2、npm 10.9.8,插件包仍为 0.4.4。`@opencode/plugin`、`@opencode/client`、`@opencode/schema` 和 `@opencode/theme` 从 2.0.11 同步精确升级到 2.0.24;锁文件中的全部七个 OpenCode 包均为 2.0.24。OpenTUI 从 0.5.10 同步到 SDK 与 theme 配套的 0.5.14,没有追随独立发布的 0.5.15。未修改价格快照、未升插件包版本、未提交或推送、未实际发布 npm。
|
|
6
|
+
|
|
7
|
+
| 检查 | 结果 |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `npm ci --no-audit --no-fund` | Node 22 下通过,保留 OpenTUI 引擎警告 |
|
|
10
|
+
| `npm run typecheck` | 通过 |
|
|
11
|
+
| `npm test` | 103 项通过,新增两项媒体封装与旧宿主兼容回归测试 |
|
|
12
|
+
| `npm run build` | 通过 |
|
|
13
|
+
| `npm pack --dry-run` | 通过,完整执行 `prepack` 构建,包含 37 个发布文件 |
|
|
14
|
+
| `npm run test:smoke`,默认宿主 2.0.24 | 完整通过,打包、隔离安装、真实服务端与 TUI |
|
|
15
|
+
| `OPENCODE_BIN=… npm run test:smoke`,独立宿主 2.0.22 | 完整通过 |
|
|
16
|
+
| `OPENCODE_BIN=… npm run test:smoke`,独立宿主 2.0.11 | 完整通过 |
|
|
17
|
+
|
|
18
|
+
新版 `@opencode/ai` 将请求媒体从平铺的 `mediaType` / `data` 改为 `media` asset。上下文来源估算现在优先读取 `part.media.mediaType`,同时兼容旧宿主的 `part.mediaType`;有文件名时仍优先按文件名估算,缺少标签时不伪造媒体 token。新增测试覆盖 bytes、base64 和 URL 负载不会计入文本 token,以及旧格式与缺失标签。插件入口、请求钩子、RPC、客户端分页及 TUI 插槽无需迁移,实测五类 token、上下文和计费口径不变。
|
|
19
|
+
|
|
20
|
+
OpenTUI 0.5.14 的原生 Node 运行时声明 Node `>=26.4.0` / Bun `>=1.3.0`。本轮 Node 22 干净安装和打包安装均报告 `EBADENGINE`,未强制绕过或隐藏警告;类型检查、测试与构建不运行原生 Node TUI,真实终端验证使用 OpenCode 自带运行时。因此保留项目 Node 22+ 要求,但不宣称独立 Node 22 原生 TUI 渲染受支持;启用 npm `engine-strict` 时仍须满足该依赖的 Node 引擎要求。
|
|
21
|
+
|
|
22
|
+
三版宿主均保留并通过原有完整断言:空会话、切换到生成中的会话、实时 TPS / TTFT、完成后精确吞吐、`/usage` 的紧凑/详细模式与 100 / 48 列布局、子代理全树累计和浮窗、按消息模型计费、模型切换与原厂价格回退、删除会话清理 RPC,以及真实分叉和 compaction。分叉继承 ID 仍带 `_序号` 后缀,用量只归原来源但占用分叉本地 Context;真实 compaction 仍为 `status === "completed"`,完整升序历史保留压缩前消息,压缩边界后的新 assistant 恢复 Context。全树 Total 5,080、费用 `$0.00504`、上下文上限 128,000 → 32,000 和回退费用 `$0.000149` 均未变化。
|
|
23
|
+
|
|
24
|
+
旧版宿主使用校验 npm SHA-512 完整性的官方 `@opencode/cli-darwin-arm64` 独立二进制,未修改日常 OpenCode 安装、用户配置或调用付费模型。当前 SDK 的已验证宿主列表更新为 2.0.11、2.0.22、2.0.24;2.0.9 / 2.0.10 未在本轮复测,保留下方历史记录,不据 smoke 可运行范围扩展兼容声明。
|
|
25
|
+
|
|
26
|
+
验证产物:
|
|
27
|
+
- OpenCode 2.0.24:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-gka7v0`。
|
|
28
|
+
- OpenCode 2.0.22:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-RpSxaf`。
|
|
29
|
+
- OpenCode 2.0.11:`/private/var/folders/rw/bmx6c8hd737brl55m0_ff_b80000gn/T/opencode/token-usage-smoke-NQbaNC`。
|
|
30
|
+
|
|
31
|
+
## 2026-10-05 · 自动价格 patch 与 npm 发布链路(本地验证)
|
|
32
|
+
|
|
33
|
+
环境:macOS、Node.js v22.23.2、插件包仍为 0.4.4,SDK 仍锁定 2.0.11。本轮只修改价格更新与发布自动化、测试和文档,未更新真实价格快照、未推送提交或标签、未创建 GitHub Release,也未实际发布 npm。
|
|
34
|
+
|
|
35
|
+
| 检查 | 结果 |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `npm run typecheck` | 通过 |
|
|
38
|
+
| `npm test` | 101 项通过,新增 16 项价格刷新/发布回归验证 |
|
|
39
|
+
| `npm run build` | 通过 |
|
|
40
|
+
| `npm pack --dry-run` | 通过,执行真实 `prepack` 构建 |
|
|
41
|
+
| `npm publish --dry-run` | 通过,完整执行类型检查、101 项测试与构建;未写入 registry |
|
|
42
|
+
| GitHub 工作流 | 通过 actionlint 1.7.12、YAML 解析和 bash 语法检查;检查工具来自官方发行且校验 SHA-256 |
|
|
43
|
+
| npm 只读查询 | 当前 `0.4.4` 已存在;发布状态为 `published=true`,价格恢复状态为 `retry=false` |
|
|
44
|
+
|
|
45
|
+
发布测试在临时仓库和本地 bare remote 中实际运行 `npm version patch`、受限提交、带注释标签及 `git push --atomic`,验证 `0.4.4 → 0.4.5` 的两个 package 文件同步、仅提交三个允许文件、版本钩子不执行,以及并发更新 `main` 时不覆盖远端提交或留下孤立标签。另覆盖未完成价格版本按原标签重试、禁止每日任务发布未完成的手动版本、已占用版本/标签、registry 故障与错误响应、锁文件不一致、`latest` 倒退和发布可见性延迟。
|
|
46
|
+
|
|
47
|
+
价格刷新覆盖无变化时跨日期保持字节不变、忽略未导入的上游元数据,以及新增、移除、零价、缓存、Reasoning 和档位差异。独立临时副本将全部生成模型的已有费率改为另一组数字,重新运行价格与用量测试,确认正常调价不再被写死的旧费率断言拦住;算法固定夹具和人工价格例外的精确断言仍保留。
|
|
48
|
+
|
|
49
|
+
真实 GitHub 定时任务、机器人推送/Release/dispatch 和 npm OIDC 写入尚未执行;需将这些变更提交到默认分支,并满足发布说明中的权限及 Trusted Publisher 配置后,在实际工作流中验证。此次未重新运行 OpenCode TUI smoke,之前已验证的宿主结果保留在下方。
|
|
50
|
+
|
|
3
51
|
## 2026-10-02 · smoke 宿主版本策略与兼容性
|
|
4
52
|
|
|
5
53
|
环境:macOS、Node.js v22.23.2、插件包 0.4.3。OpenCode SDK 仍精确锁定 2.0.11,未随本机 CLI 升级;本机默认宿主为 Homebrew 安装的 OpenCode 2.0.22。旧版基准使用校验 npm SHA-512 完整性的官方 `@opencode/cli-darwin-arm64@2.0.11` 独立二进制,没有降级或修改日常安装。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenlongapps/opencode-token-usage",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Session-tree token usage, live performance, context window and estimated cost for OpenCode 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -59,20 +59,20 @@
|
|
|
59
59
|
"registry": "https://registry.npmjs.org/"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@opencode/plugin": "2.0.
|
|
62
|
+
"@opencode/plugin": "2.0.24"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@opentui/core": "0.5.
|
|
66
|
-
"@opentui/solid": "0.5.
|
|
65
|
+
"@opentui/core": "0.5.14",
|
|
66
|
+
"@opentui/solid": "0.5.14",
|
|
67
67
|
"solid-js": ">=1.9.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@babel/core": "^7.28.0",
|
|
71
|
-
"@opencode/client": "2.0.
|
|
72
|
-
"@opencode/schema": "2.0.
|
|
73
|
-
"@opencode/theme": "2.0.
|
|
74
|
-
"@opentui/core": "0.5.
|
|
75
|
-
"@opentui/solid": "0.5.
|
|
71
|
+
"@opencode/client": "2.0.24",
|
|
72
|
+
"@opencode/schema": "2.0.24",
|
|
73
|
+
"@opencode/theme": "2.0.24",
|
|
74
|
+
"@opentui/core": "0.5.14",
|
|
75
|
+
"@opentui/solid": "0.5.14",
|
|
76
76
|
"@types/node": "^22.0.0",
|
|
77
77
|
"@xterm/headless": "6.0.0",
|
|
78
78
|
"babel-preset-solid": "1.9.12",
|