dsh-thinking-levels 4.3.1 → 4.3.3
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 +25 -16
- package/README.de.md +1 -1
- package/README.es.md +1 -1
- package/README.fr.md +1 -1
- package/README.it.md +1 -1
- package/README.ja.md +1 -1
- package/README.ko.md +1 -1
- package/README.md +10 -10
- package/README.ru.md +1 -1
- package/README.zh.md +10 -10
- package/dsh.plugin.json +16 -16
- package/lib/billing-projection.d.ts +22 -8
- package/lib/billing-projection.js +16 -9
- package/lib/client.js +98 -3
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +7 -6
- package/lib/index.js +3 -3
- package/lib/price-catalog.d.ts +23 -9
- package/lib/price-catalog.js +92 -12
- package/package.json +135 -135
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
3
|
+
## 4.3.3 (2026-10-18)
|
|
4
|
+
|
|
5
|
+
- 计价目录化上线:price-catalog 41 条(国内 30 CNY 峰谷/平价 + 海外 11 USD:Claude 4 官方页一手、GPT 4/Gemini 3 Copilot 计费文档×公告交叉核实),注入型号按目录实价入账、目录外走 estimate 典型价兜底并标「未校准·仅供参考」(免费档调用=按标准价折算的花费/白嫖额度感知)。
|
|
6
|
+
- 凭证入账 stateVersion 2→3;设置卡目录外定价五档选择器(9 语);CATALOG_VERSION 1→2;golden 150/150 绿。
|
|
7
|
+
|
|
8
|
+
## 4.3.2 (2026-10-18)
|
|
9
|
+
|
|
10
|
+
- hosts: 追加 0.2.1-rc.2 声明面枚举(宿主 peer 逐包 npm 实测 rc.2 在版;不触 ctx.web provider 与 model.label 槽,代码零改动,纯元数据发版;农场 rc.2 格挂账待命)
|
|
2
11
|
|
|
3
12
|
All notable changes to `dsh-thinking-levels` are documented here.
|
|
4
13
|
|
|
@@ -19,22 +28,22 @@ All notable changes to `dsh-thinking-levels` are documented here.
|
|
|
19
28
|
- devDependencies `@deepseek-ai/dsh-client-*` moved 0.2.0-rc.1 → 0.2.1-rc.1; build and the full suite (140 tests) verified against the target line.
|
|
20
29
|
- README compatibility statements (en/zh/ja/ko/de/es/fr/it/ru) synced to the enumeration. No behaviour change in this release.
|
|
21
30
|
|
|
22
|
-
## [4.3.0] — 2026-10-17
|
|
23
|
-
|
|
24
|
-
### Added
|
|
25
|
-
- Price catalog (src/price-catalog.ts): 29 model entries x region — DeepSeek V4.1-Flash / V4-Flash / V4-Pro carry the official peak/off-peak pairs (Beijing 09-12 & 14-18 peak, schedule effective 2026-08-17); GLM / Kimi / Qwen / Doubao / MiniMax / Ernie carry flat CN rates. Every entry prices three slots per million tokens — non-cached input / cache-hit input / output — and ships asOf + source annotations. Overseas (USD) slots are structurally present but intentionally left empty until official pages can be re-verified: no fabricated numbers.
|
|
26
|
-
- defaultPricing setting (cn / global / custom / off, default off): models outside the catalog are no longer estimated at Flash rates — they render as unpriced instead.
|
|
27
|
-
- 2026 State Council holiday/make-up correction table (39 rows, shared provenance with dsh-session-guard): make-up-workday weekends count as workdays for peak gating; statutory holidays are off-peak all day. Unknown years degrade to natural-weekend rules.
|
|
28
|
-
|
|
29
|
-
### Changed
|
|
30
|
-
- Projection stateVersion 1 -> 2: each usage sample stores a pricing receipt settled at fold time; same-step replacement subtracts the recorded values (no mixed-rate recomputation, no negative ledgers); session/turn totals are bucketed per currency. After upgrading, old checkpoints are discarded and refolded against the CURRENT catalog — historical totals shift once; afterwards pricing edits only affect subsequent samples.
|
|
31
|
-
- Billing popover: currency-aware symbols (¥ / $, unknown currency falls back to its ISO code), honest chips for flat/null tiers, "priced as <model>" derived from the catalog label, and mixed-currency sessions list per-currency rows instead of a fake sum.
|
|
32
|
-
- matchedModel / unitPricePerM deprecated (dual-written for one more generation).
|
|
33
|
-
|
|
34
|
-
### Fixed
|
|
35
|
-
- settings.describe() shape normalization: in-process array vs RPC {namespaces:[...]} envelope — exotic shapes now read as absent instead of throwing into a swallowed catch (the silent-freeze failure class).
|
|
36
|
-
- Projection registration is try/catch-guarded: a billing-unit failure hides the billing section instead of poisoning the whole plugin fiber or cold session history.
|
|
37
|
-
|
|
31
|
+
## [4.3.0] — 2026-10-17
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- Price catalog (src/price-catalog.ts): 29 model entries x region — DeepSeek V4.1-Flash / V4-Flash / V4-Pro carry the official peak/off-peak pairs (Beijing 09-12 & 14-18 peak, schedule effective 2026-08-17); GLM / Kimi / Qwen / Doubao / MiniMax / Ernie carry flat CN rates. Every entry prices three slots per million tokens — non-cached input / cache-hit input / output — and ships asOf + source annotations. Overseas (USD) slots are structurally present but intentionally left empty until official pages can be re-verified: no fabricated numbers.
|
|
35
|
+
- defaultPricing setting (cn / global / custom / off, default off): models outside the catalog are no longer estimated at Flash rates — they render as unpriced instead.
|
|
36
|
+
- 2026 State Council holiday/make-up correction table (39 rows, shared provenance with dsh-session-guard): make-up-workday weekends count as workdays for peak gating; statutory holidays are off-peak all day. Unknown years degrade to natural-weekend rules.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- Projection stateVersion 1 -> 2: each usage sample stores a pricing receipt settled at fold time; same-step replacement subtracts the recorded values (no mixed-rate recomputation, no negative ledgers); session/turn totals are bucketed per currency. After upgrading, old checkpoints are discarded and refolded against the CURRENT catalog — historical totals shift once; afterwards pricing edits only affect subsequent samples.
|
|
40
|
+
- Billing popover: currency-aware symbols (¥ / $, unknown currency falls back to its ISO code), honest chips for flat/null tiers, "priced as <model>" derived from the catalog label, and mixed-currency sessions list per-currency rows instead of a fake sum.
|
|
41
|
+
- matchedModel / unitPricePerM deprecated (dual-written for one more generation).
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
- settings.describe() shape normalization: in-process array vs RPC {namespaces:[...]} envelope — exotic shapes now read as absent instead of throwing into a swallowed catch (the silent-freeze failure class).
|
|
45
|
+
- Projection registration is try/catch-guarded: a billing-unit failure hides the billing section instead of poisoning the whole plugin fiber or cold session history.
|
|
46
|
+
|
|
38
47
|
## [4.2.1] — 2026-10-12
|
|
39
48
|
|
|
40
49
|
### Changed — stable promotion (no code changes since 4.2.0-beta.29)
|
package/README.de.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
> **▼ Unterstützte DSH-Versionen**
|
|
23
23
|
>
|
|
24
|
-
> Diese Version (4.3.x) legt die DSH-Hosts per exakter 12-Glieder-Aufzählung fest: `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1` — jeder rc einzeln aufgelistet, keine Bereiche oder Carets; die stabile 0.2.1 ist erst mit ihrem Erscheinen deklariert.
|
|
24
|
+
> Diese Version (4.3.x) legt die DSH-Hosts per exakter 12-Glieder-Aufzählung fest: `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — jeder rc einzeln aufgelistet, keine Bereiche oder Carets; die stabile 0.2.1 ist erst mit ihrem Erscheinen deklariert.
|
|
25
25
|
>
|
|
26
26
|
> | DSH-Version | Status | Hinweise |
|
|
27
27
|
> | --- | --- | --- |
|
package/README.es.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
> **▼ Versiones de DSH admitidas**
|
|
23
23
|
>
|
|
24
|
-
> Esta versión (4.3.x) fija los hosts de DSH mediante una enumeración exacta de 12 términos `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1` — cada rc listado individualmente, sin rangos ni carets; la 0.2.1 estable no se declara hasta su publicación.
|
|
24
|
+
> Esta versión (4.3.x) fija los hosts de DSH mediante una enumeración exacta de 12 términos `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — cada rc listado individualmente, sin rangos ni carets; la 0.2.1 estable no se declara hasta su publicación.
|
|
25
25
|
>
|
|
26
26
|
> | Versión de DSH | Estado | Notas |
|
|
27
27
|
> | --- | --- | --- |
|
package/README.fr.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
> **▼ Prise en charge des versions de DSH**
|
|
23
23
|
>
|
|
24
|
-
> Cette version (4.3.x) fixe les hôtes DSH par une énumération exacte de
|
|
24
|
+
> Cette version (4.3.x) fixe les hôtes DSH par une énumération exacte de 13-termes `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — chaque rc listé individuellement, sans plages ni carets ; la 0.2.1 stable n'est pas déclarée avant sa sortie.
|
|
25
25
|
>
|
|
26
26
|
> | Version de DSH | Statut | Notes |
|
|
27
27
|
> | --- | --- | --- |
|
package/README.it.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
> **▼ Versioni di DSH supportate**
|
|
23
23
|
>
|
|
24
|
-
> Questa versione (4.3.x) fissa gli host DSH con un enumerazione esatta di
|
|
24
|
+
> Questa versione (4.3.x) fissa gli host DSH con un enumerazione esatta di 13-termini `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — ogni rc elencato singolarmente, senza range o caret; la 0.2.1 stabile non è dichiarata finché non esce.
|
|
25
25
|
>
|
|
26
26
|
> | Versione DSH | Stato | Note |
|
|
27
27
|
> | --- | --- | --- |
|
package/README.ja.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
> **互換性について:** `0.6.0` には日本語(`ja`)と韓国語(`ko`)の辞書と選択項目が含まれていますが、現在の公式 DSH は `LocaleRuntime` 経由で `zh` と `en` のみを提供しています。純正 DSH で `ja` または `ko` を選択すると `locale "<id>" is not registered` で失敗します。公式 DSH が対応 locale ID を追加するまで利用できません。上級ユーザーは DSH フォークを保守し、`packages/client/locale/src/locale-settings.ts` の `LOCALE_IDS` と `packages/client/locale/src/client/index.ts` の `LOCALES` ラベルを更新し、コア辞書とテストを追加して再ビルド・実行してください。このプラグインだけでは DSH のグローバル locale 一覧を拡張できません。
|
|
35
35
|
|
|
36
|
-
> **バージョン互換:** 本リリース(4.3.x)は **DSH ホストを厳密な 12 項列挙**で固定:`0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1`——rc ごとに単列、区間/caret 不使用。0.1.7-rc.1 の境界以降、DSH は命令的な設定登録(`settings.register` / `installSettingsSection`)とクライアントの `settingsScope` サービスおよびプラグイン別カードスロットを削除し、実行時に変更できる設定フィールドは schemastery スキーマで `.volatile()` 付きとし、設定フォームはホストがスキーマから自動生成(登録呼び出しもクライアント設定カードも不要)、プラグインは `loader/volatile-update` に従ってリクエストごとに最新値を読みます——4.0.x は 0.2.0-rc セグメントの同一宣言的表面を対象とします。0.1.7-rc.1〜<0.2.0 のホストでは 3.x ライン(3.4.3、npm dist-tag `dsh-0.1.7`)を、0.1.2–0.1.6 ホストではプラグイン 3.0.2 を使用してください。
|
|
36
|
+
> **バージョン互換:** 本リリース(4.3.x)は **DSH ホストを厳密な 12 項列挙**で固定:`0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2`——rc ごとに単列、区間/caret 不使用。0.1.7-rc.1 の境界以降、DSH は命令的な設定登録(`settings.register` / `installSettingsSection`)とクライアントの `settingsScope` サービスおよびプラグイン別カードスロットを削除し、実行時に変更できる設定フィールドは schemastery スキーマで `.volatile()` 付きとし、設定フォームはホストがスキーマから自動生成(登録呼び出しもクライアント設定カードも不要)、プラグインは `loader/volatile-update` に従ってリクエストごとに最新値を読みます——4.0.x は 0.2.0-rc セグメントの同一宣言的表面を対象とします。0.1.7-rc.1〜<0.2.0 のホストでは 3.x ライン(3.4.3、npm dist-tag `dsh-0.1.7`)を、0.1.2–0.1.6 ホストではプラグイン 3.0.2 を使用してください。
|
|
37
37
|
|
|
38
38
|
> **バージョン範囲ポリシー:** 各互換ラインはホストを自ラインのセグメントに厳密に固定します。0.1.x ホスト向けのラインは `>=0.1.x-rc.1 <0.1.(x+1)-0`(3.1.x:`>=0.1.7-rc.1 <0.1.8-0`;3.0.x:`>=0.1.5-alpha.1 <0.1.6-0`;2.0.x:`>=0.1.2-alpha.1 <0.1.3-0`;1.0.0-beta:`>=0.1.0-rc.8 <0.1.2-alpha.1`)、0.2.x セグメント向けのラインは `>=0.2.0-rc.1 <0.2.1-0`(4.0.x:`>=0.2.0-rc.1 <0.2.1-0`)に従います。どのラインも開放的な上限を宣言しません。互換性レゾルバが未対応の新ホストセグメントにプラグインラインを誤マッチすることはありません。0.4.0–0.6.0 は dsh peer 宣言を一切持たないためインストールしないでください。
|
|
39
39
|
|
package/README.ko.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
> **호환성 참고:** `0.6.0`에는 일본어(`ja`)와 한국어(`ko`) 사전 및 선택 항목이 포함되어 있지만, 현재 공식 DSH는 `LocaleRuntime`을 통해 `zh`와 `en`만 제공합니다. 순정 DSH에서 `ja` 또는 `ko`를 선택하면 `locale "<id>" is not registered` 오류가 발생합니다. 공식 DSH가 해당 locale ID를 추가할 때까지 사용할 수 없습니다. 고급 사용자는 DSH 포크를 유지하면서 `packages/client/locale/src/locale-settings.ts`의 `LOCALE_IDS`와 `packages/client/locale/src/client/index.ts`의 `LOCALES` 라벨을 업데이트하고 핵심 사전과 테스트를 추가한 뒤 다시 빌드하여 실행할 수 있습니다. 이 플러그인만으로는 DSH의 전역 locale 목록을 확장할 수 없습니다.
|
|
35
35
|
|
|
36
|
-
> **버전 호환:** 본 릴리스(4.3.x)는 **DSH 호스트를 12항 정확 열거**로 고정: `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1` — rc별 단독 열거, 구간/caret 미사용. 0.1.7-rc.1 경계 이후 DSH는 명령형 설정 등록(`settings.register` / `installSettingsSection`)과 클라이언트 `settingsScope` 서비스 및 플러그인별 카드 슬롯을 제거했고, 런타임 조정 가능한 설정 필드는 schemastery 스키마에 `.volatile()`로 표시되며, 설정 폼은 호스트가 스키마에서 자동 생성(등록 호출도 클라이언트 설정 카드도 없음)하고, 플러그인은 `loader/volatile-update`에 따라 요청마다 최신 값을 읽습니다——4.0.x은 0.2.0-rc 세그먼트의 동일한 선언적 표면을 대상으로 합니다. 0.1.7-rc.1~<0.2.0 호스트에서는 3.x 라인(3.4.3, npm dist-tag `dsh-0.1.7`)을, 0.1.2–0.1.6 호스트에서는 플러그인 3.0.2을 사용하세요.
|
|
36
|
+
> **버전 호환:** 본 릴리스(4.3.x)는 **DSH 호스트를 12항 정확 열거**로 고정: `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — rc별 단독 열거, 구간/caret 미사용. 0.1.7-rc.1 경계 이후 DSH는 명령형 설정 등록(`settings.register` / `installSettingsSection`)과 클라이언트 `settingsScope` 서비스 및 플러그인별 카드 슬롯을 제거했고, 런타임 조정 가능한 설정 필드는 schemastery 스키마에 `.volatile()`로 표시되며, 설정 폼은 호스트가 스키마에서 자동 생성(등록 호출도 클라이언트 설정 카드도 없음)하고, 플러그인은 `loader/volatile-update`에 따라 요청마다 최신 값을 읽습니다——4.0.x은 0.2.0-rc 세그먼트의 동일한 선언적 표면을 대상으로 합니다. 0.1.7-rc.1~<0.2.0 호스트에서는 3.x 라인(3.4.3, npm dist-tag `dsh-0.1.7`)을, 0.1.2–0.1.6 호스트에서는 플러그인 3.0.2을 사용하세요.
|
|
37
37
|
|
|
38
38
|
> **버전 범위 정책:** 각 호환 라인은 호스트를 자기 라인의 세그먼트에 엄격히 고정합니다. 0.1.x 호스트 대상 라인은 `>=0.1.x-rc.1 <0.1.(x+1)-0`(3.1.x: `>=0.1.7-rc.1 <0.1.8-0`; 3.0.x: `>=0.1.5-alpha.1 <0.1.6-0`; 2.0.x: `>=0.1.2-alpha.1 <0.1.3-0`; 1.0.0-beta: `>=0.1.0-rc.8 <0.1.2-alpha.1`)을, 0.2.x 세그먼트 대상 라인은 `>=0.2.0-rc.1 <0.2.1-0`(4.0.x: `>=0.2.0-rc.1 <0.2.1-0`)을 따릅니다. 어떤 라인도 열린 상한을 선언하지 않으므로, 호환성 리졸버가 플러그인 라인을 지원하지 않는 더 새 호스트 세그먼트에 잘못 매칭할 일이 없습니다. 0.4.0–0.6.0은 dsh peer 선언이 전혀 없으므로 설치하지 마세요.
|
|
39
39
|
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
> **▼ DSH version support**
|
|
35
35
|
>
|
|
36
|
-
> This release (4.3.x) pins DSH hosts by the exact
|
|
36
|
+
> This release (4.3.x) pins DSH hosts by the exact 13-term enumeration `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — each rc listed individually, no ranges or carets; 0.2.1 stable is not declared until it ships.
|
|
37
37
|
>
|
|
38
38
|
> | DSH version | Status | Notes |
|
|
39
39
|
> | --- | --- | --- |
|
|
@@ -263,15 +263,15 @@ npm test # vitest — 46 tests
|
|
|
263
263
|
|
|
264
264
|
Test coverage: level policy (manual pass-through incl. the extended levels, `on` clamping, auto scheduler, validation, simple-tool boundary), the model-capability guard (`reasoningEffortSupported`, `resolveEffortInjection` stripping/passthrough), session-event parsing (guards, window cap, malformed records), the config schema (defaults lockstep, out-of-band rejection, `models` overrides), and the official-compat sync (identification, explicit-value respect, identity idempotence, write-time schema gating).
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
## Pricing catalog (4.3.0+)
|
|
268
|
-
|
|
269
|
-
Billing samples are priced at fold time from a builtin catalog (src/price-catalog.ts): 29 model entries x region. DeepSeek V4.1-Flash / V4-Flash / V4-Pro carry the official peak/off-peak pairs (Beijing 09:00-12:00 and 14:00-18:00 on workdays are peak; the 2026 State Council holiday/make-up table is applied, with make-up-workday weekends counted as workdays); GLM / Kimi / Qwen / Doubao / MiniMax / Ernie carry flat CN rates. Each entry prices three slots per million tokens — non-cached input, cache-hit input and output — with asOf + source annotations; currency follows the entry (¥ CNY, $ USD, no FX conversion). Overseas (USD) catalog slots are intentionally empty until official pages can be re-verified.
|
|
270
|
-
|
|
271
|
-
Models outside the catalog fall to the defaultPricing setting (cn / global / custom / off, default off): "off" renders the billing popover as unpriced while token counters keep working — nothing is silently estimated any more.
|
|
272
|
-
|
|
273
|
-
Semantics note: a pricing or policy change only affects samples booked after the change; the first time you open an old session right after upgrading, its cumulative ledger is refolded once against the current catalog.
|
|
274
|
-
|
|
266
|
+
|
|
267
|
+
## Pricing catalog (4.3.0+)
|
|
268
|
+
|
|
269
|
+
Billing samples are priced at fold time from a builtin catalog (src/price-catalog.ts): 29 model entries x region. DeepSeek V4.1-Flash / V4-Flash / V4-Pro carry the official peak/off-peak pairs (Beijing 09:00-12:00 and 14:00-18:00 on workdays are peak; the 2026 State Council holiday/make-up table is applied, with make-up-workday weekends counted as workdays); GLM / Kimi / Qwen / Doubao / MiniMax / Ernie carry flat CN rates. Each entry prices three slots per million tokens — non-cached input, cache-hit input and output — with asOf + source annotations; currency follows the entry (¥ CNY, $ USD, no FX conversion). Overseas (USD) catalog slots are intentionally empty until official pages can be re-verified.
|
|
270
|
+
|
|
271
|
+
Models outside the catalog fall to the defaultPricing setting (cn / global / custom / off, default off): "off" renders the billing popover as unpriced while token counters keep working — nothing is silently estimated any more.
|
|
272
|
+
|
|
273
|
+
Semantics note: a pricing or policy change only affects samples booked after the change; the first time you open an old session right after upgrading, its cumulative ledger is refolded once against the current catalog.
|
|
274
|
+
|
|
275
275
|
## License
|
|
276
276
|
|
|
277
277
|
MIT
|
package/README.ru.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
> **▼ Поддерживаемые версии DSH**
|
|
23
23
|
>
|
|
24
|
-
> Этот релиз (4.3.x) фиксирует хосты DSH точным 12-значным перечислением `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1` — каждый rc перечислен отдельно, без диапазонов и carets; стабильная 0.2.1 не объявляется до её выхода.
|
|
24
|
+
> Этот релиз (4.3.x) фиксирует хосты DSH точным 12-значным перечислением `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2` — каждый rc перечислен отдельно, без диапазонов и carets; стабильная 0.2.1 не объявляется до её выхода.
|
|
25
25
|
>
|
|
26
26
|
> | Версия DSH | Статус | Примечания |
|
|
27
27
|
> | --- | --- | --- |
|
package/README.zh.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
> **兼容性说明:** `0.6.0` 已包含日本語(`ja`)和한국어(`ko`)字典及选择项,但当前官方 DSH 只通过 `LocaleRuntime` 提供 `zh` 和 `en`。在原版 DSH 中选择 `ja` 或 `ko` 会失败,并提示 `locale "<id>" is not registered`。需要等待官方 DSH 增加对应 locale ID 后才能正常使用。高级用户可以维护 DSH fork,在 `packages/client/locale/src/locale-settings.ts` 更新 `LOCALE_IDS`,在 `packages/client/locale/src/client/index.ts` 更新 `LOCALES` 标签,并补齐核心字典和测试,然后重新构建并运行 fork 版本。仅修改本插件无法扩展 DSH 的全局 locale 列表。
|
|
35
35
|
|
|
36
|
-
> **版本兼容:** 本版本(4.3.x)按 **DSH 宿主精确 12 档枚举**钉定:`0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1`——逐 rc 单列,不用区间/caret;0.2.1 稳定线发布前不声明。自 0.1.7-rc.1 边界起,DSH 移除了命令式设置注册(`settings.register` / `installSettingsSection`)与客户端 `settingsScope` 服务及每插件卡片槽位,运行时调整的配置字段在 schemastery schema 中标 `.volatile()`,设置表单由宿主按 schema 自动生成(无注册调用、无客户端设置卡片),插件按请求读取实时值(由 `loader/volatile-update` 驱动)——4.0.x 面向 0.2.0-rc 区段的同一声明式表面;0.1.7-rc.1 至 <0.2.0 的宿主请使用 3.x 线(3.4.3,npm dist-tag `dsh-0.1.7`),0.1.2–0.1.6 宿主请继续使用插件 3.0.2。
|
|
36
|
+
> **版本兼容:** 本版本(4.3.x)按 **DSH 宿主精确 12 档枚举**钉定:`0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2`——逐 rc 单列,不用区间/caret;0.2.1 稳定线发布前不声明。自 0.1.7-rc.1 边界起,DSH 移除了命令式设置注册(`settings.register` / `installSettingsSection`)与客户端 `settingsScope` 服务及每插件卡片槽位,运行时调整的配置字段在 schemastery schema 中标 `.volatile()`,设置表单由宿主按 schema 自动生成(无注册调用、无客户端设置卡片),插件按请求读取实时值(由 `loader/volatile-update` 驱动)——4.0.x 面向 0.2.0-rc 区段的同一声明式表面;0.1.7-rc.1 至 <0.2.0 的宿主请使用 3.x 线(3.4.3,npm dist-tag `dsh-0.1.7`),0.1.2–0.1.6 宿主请继续使用插件 3.0.2。
|
|
37
37
|
|
|
38
38
|
> **版本范围约定:** 每条兼容线都把宿主钉在本线自己的区段内。面向 0.1.x 宿主的线遵循 `>=0.1.x-rc.1 <0.1.(x+1)-0`(3.1.x:`>=0.1.7-rc.1 <0.1.8-0`;3.0.x:`>=0.1.5-alpha.1 <0.1.6-0`;2.0.x:`>=0.1.2-alpha.1 <0.1.3-0`;1.0.0-beta:`>=0.1.0-rc.8 <0.1.2-alpha.1`);面向 0.2.x 区段的线遵循 `>=0.2.0-rc.1 <0.2.1-0`(4.0.x:`>=0.2.0-rc.1 <0.2.1-0`)。任何线都不声明开放的上限,兼容性解析器因此绝不会把插件线匹配到它并未适配的更新宿主区段。0.4.0–0.6.0 完全没有声明 dsh peer 依赖,属于无兼容性标注版本——不要安装。自 4.2.x 多线时代起,4.x 线改用上述逐 rc 精确枚举钉定宿主,区间公式仅描述历史上的分区段线。
|
|
39
39
|
|
|
@@ -206,12 +206,12 @@ npm test # vitest — 65 个测试
|
|
|
206
206
|
|
|
207
207
|
## 许可
|
|
208
208
|
|
|
209
|
-
MIT
|
|
210
|
-
|
|
211
|
-
## 计价目录与账单(4.3.0+)
|
|
212
|
-
|
|
213
|
-
账单逐笔在折入时刻按内置目录(src/price-catalog.ts)计价:29 个模型条目 × 地区。DeepSeek V4.1-Flash / V4-Flash / V4-Pro 采用官方峰谷双行(北京工作日 09:00-12:00、14:00-18:00 为峰;套用 2026 国务院节假日/调休修正表,补班周末按工作日计);智谱 / Kimi / 通义千问 / 豆包 / MiniMax / 文心 为平价人民币档。每条目录含三价目位(每百万 token:非缓存输入 / 缓存命中输入 / 输出)并带复核日期与来源标注;币种随条目原样显示(¥ / $,不做汇率折算)。海外(USD)条目在核实通道到位前刻意留空。
|
|
214
|
-
|
|
215
|
-
目录外模型走 defaultPricing 设置(cn / global / custom / off,缺省 off):「off」时账单弹层显示"未计价",token 计数照常——不再拿单一型号价静默估算。
|
|
216
|
-
|
|
217
|
-
语义说明:改价/改策略只影响其后新记的账;升级后首次打开旧会话时,其累计账目会按当前目录一次性重折。
|
|
209
|
+
MIT
|
|
210
|
+
|
|
211
|
+
## 计价目录与账单(4.3.0+)
|
|
212
|
+
|
|
213
|
+
账单逐笔在折入时刻按内置目录(src/price-catalog.ts)计价:29 个模型条目 × 地区。DeepSeek V4.1-Flash / V4-Flash / V4-Pro 采用官方峰谷双行(北京工作日 09:00-12:00、14:00-18:00 为峰;套用 2026 国务院节假日/调休修正表,补班周末按工作日计);智谱 / Kimi / 通义千问 / 豆包 / MiniMax / 文心 为平价人民币档。每条目录含三价目位(每百万 token:非缓存输入 / 缓存命中输入 / 输出)并带复核日期与来源标注;币种随条目原样显示(¥ / $,不做汇率折算)。海外(USD)条目在核实通道到位前刻意留空。
|
|
214
|
+
|
|
215
|
+
目录外模型走 defaultPricing 设置(cn / global / custom / off,缺省 off):「off」时账单弹层显示"未计价",token 计数照常——不再拿单一型号价静默估算。
|
|
216
|
+
|
|
217
|
+
语义说明:改价/改策略只影响其后新记的账;升级后首次打开旧会话时,其累计账目会按当前目录一次性重折。
|
package/dsh.plugin.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "dsh-external/dsh-thinking-levels",
|
|
3
|
-
"version": "4.3.
|
|
4
|
-
"main": "./lib/index.js",
|
|
5
|
-
"description": "thinking-level (reasoning_effort) control — auto-adjust per tool round, with optional manual lock and per-tool timing telemetry.",
|
|
6
|
-
"engines": {
|
|
7
|
-
"dsh": "0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1"
|
|
8
|
-
},
|
|
9
|
-
"contributes": {
|
|
10
|
-
"tools": [],
|
|
11
|
-
"skills": []
|
|
12
|
-
},
|
|
13
|
-
"client": {
|
|
14
|
-
"main": "./lib/client.js"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "dsh-external/dsh-thinking-levels",
|
|
3
|
+
"version": "4.3.3",
|
|
4
|
+
"main": "./lib/index.js",
|
|
5
|
+
"description": "thinking-level (reasoning_effort) control — auto-adjust per tool round, with optional manual lock and per-tool timing telemetry.",
|
|
6
|
+
"engines": {
|
|
7
|
+
"dsh": "0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2"
|
|
8
|
+
},
|
|
9
|
+
"contributes": {
|
|
10
|
+
"tools": [],
|
|
11
|
+
"skills": []
|
|
12
|
+
},
|
|
13
|
+
"client": {
|
|
14
|
+
"main": "./lib/client.js"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
* 元只做记账。计价在**折入时刻**结算并作为凭证(`Sample.billed`)持久进 state:
|
|
12
12
|
* - 同 step 替换「减记录值、加新算值」——杜绝按新费率重算旧账的混口径负数路径;
|
|
13
13
|
* - 金额按币种分桶(CNY/USD),跨币种会话不再相加失真;
|
|
14
|
-
* - `view`
|
|
14
|
+
* - `view` 只读凭证不重算,设置改价不会漂移已展示的读数;
|
|
15
|
+
* - 目录外模型的兜底典型价估算带 `estimated` 凭证位(未校准仅供参考)。
|
|
15
16
|
* 语义边界:改价只影响在线增量新账;冷重放(checkpoint 废弃后整段重折)必然
|
|
16
|
-
* 按当前目录重算——stateVersion
|
|
17
|
+
* 按当前目录重算——stateVersion 3 即为此声明(宿主对旧 ver 行整行废弃重折,
|
|
18
|
+
* ver 2 凭证缺 estimated 字段,不可原样过新 schema)。
|
|
17
19
|
*
|
|
18
20
|
* 计价快照经 `buildBillingDefinition(getPricing)` 闭包注入,按事件时刻现读;
|
|
19
21
|
* **热路径绝不走 describeSettings**(宿主 describe 非轻量且会 emit 事件)。
|
|
@@ -38,12 +40,14 @@ export interface Billed {
|
|
|
38
40
|
tier: Tier | null;
|
|
39
41
|
source: PricingSource;
|
|
40
42
|
priced: boolean;
|
|
43
|
+
/** priced 且金额为兜底典型价估算(未校准,仅供参考)。 */
|
|
44
|
+
estimated: boolean;
|
|
41
45
|
catalogKey: string | null;
|
|
42
46
|
catalogLabel: string | null;
|
|
43
47
|
priceRow: PriceRow | null;
|
|
44
48
|
}
|
|
45
49
|
/** 目录外模型的兜底档位(设置面 defaultPricing 的值域)。 */
|
|
46
|
-
declare const POLICY_VALUES: readonly ["cn", "global", "custom", "off"];
|
|
50
|
+
declare const POLICY_VALUES: readonly ["estimate", "cn", "global", "custom", "off"];
|
|
47
51
|
/** 一个 usage 样本:state.last 只存最新一轮。 */
|
|
48
52
|
export interface Sample {
|
|
49
53
|
turn: number;
|
|
@@ -129,6 +133,7 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
129
133
|
flat: "flat";
|
|
130
134
|
}>>;
|
|
131
135
|
source: z.ZodEnum<{
|
|
136
|
+
estimate: "estimate";
|
|
132
137
|
cn: "cn";
|
|
133
138
|
global: "global";
|
|
134
139
|
custom: "custom";
|
|
@@ -136,6 +141,7 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
136
141
|
"catalog-miss": "catalog-miss";
|
|
137
142
|
}>;
|
|
138
143
|
priced: z.ZodBoolean;
|
|
144
|
+
estimated: z.ZodBoolean;
|
|
139
145
|
catalogKey: z.ZodNullable<z.ZodString>;
|
|
140
146
|
catalogLabel: z.ZodNullable<z.ZodString>;
|
|
141
147
|
priceRow: z.ZodNullable<z.ZodObject<{
|
|
@@ -206,8 +212,9 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
206
212
|
output: number;
|
|
207
213
|
currency: "CNY" | "USD";
|
|
208
214
|
tier: "peak" | "offPeak" | "flat" | null;
|
|
209
|
-
source: "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
215
|
+
source: "estimate" | "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
210
216
|
priced: boolean;
|
|
217
|
+
estimated: boolean;
|
|
211
218
|
catalogKey: string | null;
|
|
212
219
|
catalogLabel: string | null;
|
|
213
220
|
priceRow: {
|
|
@@ -282,8 +289,9 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
282
289
|
output: number;
|
|
283
290
|
currency: "CNY" | "USD";
|
|
284
291
|
tier: "peak" | "offPeak" | "flat" | null;
|
|
285
|
-
source: "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
292
|
+
source: "estimate" | "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
286
293
|
priced: boolean;
|
|
294
|
+
estimated: boolean;
|
|
287
295
|
catalogKey: string | null;
|
|
288
296
|
catalogLabel: string | null;
|
|
289
297
|
priceRow: {
|
|
@@ -357,8 +365,9 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
357
365
|
output: number;
|
|
358
366
|
currency: "CNY" | "USD";
|
|
359
367
|
tier: "peak" | "offPeak" | "flat" | null;
|
|
360
|
-
source: "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
368
|
+
source: "estimate" | "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
361
369
|
priced: boolean;
|
|
370
|
+
estimated: boolean;
|
|
362
371
|
catalogKey: string | null;
|
|
363
372
|
catalogLabel: string | null;
|
|
364
373
|
priceRow: {
|
|
@@ -451,12 +460,14 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
451
460
|
step: z.ZodNullable<z.ZodNumber>;
|
|
452
461
|
priced: z.ZodBoolean;
|
|
453
462
|
pricingSource: z.ZodNullable<z.ZodEnum<{
|
|
463
|
+
estimate: "estimate";
|
|
454
464
|
cn: "cn";
|
|
455
465
|
global: "global";
|
|
456
466
|
custom: "custom";
|
|
457
467
|
off: "off";
|
|
458
468
|
"catalog-miss": "catalog-miss";
|
|
459
469
|
}>>;
|
|
470
|
+
estimated: z.ZodBoolean;
|
|
460
471
|
catalogKey: z.ZodNullable<z.ZodString>;
|
|
461
472
|
catalogLabel: z.ZodNullable<z.ZodString>;
|
|
462
473
|
priceRow: z.ZodNullable<z.ZodObject<{
|
|
@@ -503,8 +514,9 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
503
514
|
output: number;
|
|
504
515
|
currency: "CNY" | "USD";
|
|
505
516
|
tier: "peak" | "offPeak" | "flat" | null;
|
|
506
|
-
source: "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
517
|
+
source: "estimate" | "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
507
518
|
priced: boolean;
|
|
519
|
+
estimated: boolean;
|
|
508
520
|
catalogKey: string | null;
|
|
509
521
|
catalogLabel: string | null;
|
|
510
522
|
priceRow: {
|
|
@@ -588,6 +600,7 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
588
600
|
step: null;
|
|
589
601
|
priced: boolean;
|
|
590
602
|
pricingSource: null;
|
|
603
|
+
estimated: boolean;
|
|
591
604
|
catalogKey: null;
|
|
592
605
|
catalogLabel: null;
|
|
593
606
|
priceRow: null;
|
|
@@ -631,7 +644,8 @@ export declare function buildBillingDefinition(getPricing: () => PricingSnapshot
|
|
|
631
644
|
turn: number;
|
|
632
645
|
step: number;
|
|
633
646
|
priced: boolean;
|
|
634
|
-
pricingSource: "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
647
|
+
pricingSource: "estimate" | "cn" | "global" | "custom" | "off" | "catalog-miss";
|
|
648
|
+
estimated: boolean;
|
|
635
649
|
catalogKey: string | null;
|
|
636
650
|
catalogLabel: string | null;
|
|
637
651
|
priceRow: ({
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
* 元只做记账。计价在**折入时刻**结算并作为凭证(`Sample.billed`)持久进 state:
|
|
12
12
|
* - 同 step 替换「减记录值、加新算值」——杜绝按新费率重算旧账的混口径负数路径;
|
|
13
13
|
* - 金额按币种分桶(CNY/USD),跨币种会话不再相加失真;
|
|
14
|
-
* - `view`
|
|
14
|
+
* - `view` 只读凭证不重算,设置改价不会漂移已展示的读数;
|
|
15
|
+
* - 目录外模型的兜底典型价估算带 `estimated` 凭证位(未校准仅供参考)。
|
|
15
16
|
* 语义边界:改价只影响在线增量新账;冷重放(checkpoint 废弃后整段重折)必然
|
|
16
|
-
* 按当前目录重算——stateVersion
|
|
17
|
+
* 按当前目录重算——stateVersion 3 即为此声明(宿主对旧 ver 行整行废弃重折,
|
|
18
|
+
* ver 2 凭证缺 estimated 字段,不可原样过新 schema)。
|
|
17
19
|
*
|
|
18
20
|
* 计价快照经 `buildBillingDefinition(getPricing)` 闭包注入,按事件时刻现读;
|
|
19
21
|
* **热路径绝不走 describeSettings**(宿主 describe 非轻量且会 emit 事件)。
|
|
@@ -30,7 +32,7 @@ import { resolveRate, } from "./price-catalog.js";
|
|
|
30
32
|
export { isPeakBeijing, HOLIDAY_TABLE_2026, HOLIDAY_TABLES } from "./price-catalog.js";
|
|
31
33
|
export { PRICE_CATALOG, CATALOG_VERSION } from "./price-catalog.js";
|
|
32
34
|
/** 目录外模型的兜底档位(设置面 defaultPricing 的值域)。 */
|
|
33
|
-
const POLICY_VALUES = ['cn', 'global', 'custom', 'off'];
|
|
35
|
+
const POLICY_VALUES = ['estimate', 'cn', 'global', 'custom', 'off'];
|
|
34
36
|
const round9 = (n) => Math.round(n * 1e9) / 1e9;
|
|
35
37
|
/** 写失效:发生过缓存写入(官方不报,恒 false,个别中转有值)。 */
|
|
36
38
|
export const isWriteMiss = (s) => s.cacheWriteTokens > 0;
|
|
@@ -57,7 +59,7 @@ export function billFor(sample, snapshot) {
|
|
|
57
59
|
return {
|
|
58
60
|
hit: 0, miss: 0, output: 0,
|
|
59
61
|
currency: resolved.currency ?? 'CNY',
|
|
60
|
-
tier: resolved.tier, source: resolved.source, priced: false,
|
|
62
|
+
tier: resolved.tier, source: resolved.source, priced: false, estimated: false,
|
|
61
63
|
catalogKey: resolved.entry?.key ?? null,
|
|
62
64
|
catalogLabel: resolved.entry?.label ?? null,
|
|
63
65
|
priceRow: null,
|
|
@@ -69,6 +71,7 @@ export function billFor(sample, snapshot) {
|
|
|
69
71
|
output: round9((sample.outputTokens * row.output) / 1e6),
|
|
70
72
|
currency: resolved.currency ?? 'CNY',
|
|
71
73
|
tier: resolved.tier, source: resolved.source, priced: true,
|
|
74
|
+
estimated: resolved.estimated,
|
|
72
75
|
catalogKey: resolved.entry?.key ?? null,
|
|
73
76
|
catalogLabel: resolved.entry?.label ?? null,
|
|
74
77
|
priceRow: { ...row },
|
|
@@ -80,8 +83,9 @@ const billedShape = z.object({
|
|
|
80
83
|
output: z.number(),
|
|
81
84
|
currency: z.enum(['CNY', 'USD']),
|
|
82
85
|
tier: z.enum(['peak', 'offPeak', 'flat']).nullable(),
|
|
83
|
-
source: z.enum(['cn', 'global', 'custom', 'off', 'catalog-miss']),
|
|
86
|
+
source: z.enum(['estimate', 'cn', 'global', 'custom', 'off', 'catalog-miss']),
|
|
84
87
|
priced: z.boolean(),
|
|
88
|
+
estimated: z.boolean(),
|
|
85
89
|
catalogKey: z.string().nullable(),
|
|
86
90
|
catalogLabel: z.string().nullable(),
|
|
87
91
|
priceRow: z.object({ inputMiss: z.number(), inputCacheHit: z.number(), output: z.number() }).nullable(),
|
|
@@ -189,7 +193,7 @@ export function buildBillingDefinition(getPricing) {
|
|
|
189
193
|
provider: sourceProvider ?? state.provider,
|
|
190
194
|
time: typeof event.time === 'number' ? event.time : Date.now(),
|
|
191
195
|
// 凭证在折入时刻结算(事件时刻的费率 + 当时的计价快照)
|
|
192
|
-
billed: { hit: 0, miss: 0, output: 0, currency: 'CNY', tier: null, source: 'off', priced: false, catalogKey: null, catalogLabel: null, priceRow: null },
|
|
196
|
+
billed: { hit: 0, miss: 0, output: 0, currency: 'CNY', tier: null, source: 'off', priced: false, estimated: false, catalogKey: null, catalogLabel: null, priceRow: null },
|
|
193
197
|
};
|
|
194
198
|
sample.billed = billFor(sample, getPricing());
|
|
195
199
|
const prev = state.last;
|
|
@@ -203,6 +207,7 @@ export function buildBillingDefinition(getPricing) {
|
|
|
203
207
|
prev.billed.hit === sample.billed.hit &&
|
|
204
208
|
prev.billed.miss === sample.billed.miss &&
|
|
205
209
|
prev.billed.output === sample.billed.output &&
|
|
210
|
+
prev.billed.estimated === sample.billed.estimated &&
|
|
206
211
|
prev.billed.currency === sample.billed.currency) {
|
|
207
212
|
return state;
|
|
208
213
|
}
|
|
@@ -297,7 +302,7 @@ export function buildBillingDefinition(getPricing) {
|
|
|
297
302
|
cacheReadTokens: 0, totalInputTokens: 0, outputTokens: 0, hitRate: null,
|
|
298
303
|
model: state.model, provider: state.provider, matchedModel: null, modelMatched: false,
|
|
299
304
|
tier: null, unitPricePerM: null, turn: null, step: null,
|
|
300
|
-
priced: false, pricingSource: null, catalogKey: null, catalogLabel: null, priceRow: null,
|
|
305
|
+
priced: false, pricingSource: null, estimated: false, catalogKey: null, catalogLabel: null, priceRow: null,
|
|
301
306
|
turnCost: 0, turnHitCost: 0, turnMissCost: 0, turnOutputCost: 0,
|
|
302
307
|
turnTokens: 0, turnCacheReadTokens: 0, turnInputTokens: 0, turnOutputTokens: 0,
|
|
303
308
|
sessionCacheHitCost: 0, sessionMissCost: 0, sessionOutputCost: 0,
|
|
@@ -332,6 +337,7 @@ export function buildBillingDefinition(getPricing) {
|
|
|
332
337
|
step: s.step,
|
|
333
338
|
priced: b.priced,
|
|
334
339
|
pricingSource: b.source,
|
|
340
|
+
estimated: b.estimated,
|
|
335
341
|
catalogKey: b.catalogKey,
|
|
336
342
|
catalogLabel: b.catalogLabel,
|
|
337
343
|
priceRow: b.priceRow,
|
|
@@ -376,7 +382,8 @@ export function buildBillingDefinition(getPricing) {
|
|
|
376
382
|
turn: z.number().int().nullable(),
|
|
377
383
|
step: z.number().int().nullable(),
|
|
378
384
|
priced: z.boolean(),
|
|
379
|
-
pricingSource: z.enum(['cn', 'global', 'custom', 'off', 'catalog-miss']).nullable(),
|
|
385
|
+
pricingSource: z.enum(['estimate', 'cn', 'global', 'custom', 'off', 'catalog-miss']).nullable(),
|
|
386
|
+
estimated: z.boolean(),
|
|
380
387
|
catalogKey: z.string().nullable(),
|
|
381
388
|
catalogLabel: z.string().nullable(),
|
|
382
389
|
priceRow: z.object({ inputMiss: z.number(), inputCacheHit: z.number(), output: z.number() }).nullable(),
|
|
@@ -403,7 +410,7 @@ export function buildBillingDefinition(getPricing) {
|
|
|
403
410
|
});
|
|
404
411
|
return {
|
|
405
412
|
key: 'tlCacheBilling',
|
|
406
|
-
stateVersion:
|
|
413
|
+
stateVersion: 3,
|
|
407
414
|
stateSchema,
|
|
408
415
|
init,
|
|
409
416
|
apply,
|