dsh-thinking-levels 4.3.2 → 4.4.0

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.ja.md CHANGED
@@ -11,6 +11,17 @@
11
11
  - [Список изменений на русском](./CHANGELOG.ru.md)
12
12
  - [Changelog en español](./CHANGELOG.es.md)
13
13
 
14
+ ## [4.4.0] — 2026-10-19(issue まとめ対応:#2 #3 #4 #5)
15
+
16
+ ### 修正
17
+ - 能力カード(#2):`api` が openai-completions 以外のプロバイダーでは、Thinking / Supports-effort / thinkingFormat のコントロールを説明付きで無効化。無効な書き込みによる `card.writeError` を解消(ホストの Responses 互換ゲートはこれらのモデルレベルフィールドを提供しません)。
18
+ - 読み込みコスト(#4):`resolveModel` 広告を冪等化(WeakSet ガード)。従来は `llm/adapters-updated` ごとにラッパーが積まれ、解決ごとに全量 settings 読み出しが発生していました。readout は世代キャッシュ化し、設定コミットで無効化。takeover ミラーの再同期は関連 namespace のコミットのみに実行。
19
+ - 档位 chip(#5):レベルが `auto` のとき chip は **Auto** を維持し、そのステップの解決値は `→ <level>` の二次表示に降格(表示が上書きされる問題の解消)。
20
+
21
+ ### 追加
22
+ - `takeoverUi` 設定(既定 OFF、#3/#4):公式モデルポップアップを維持(検索・読み込みはネイティブ、`auto` はサーバー側広告で引き続き提供)。OFF の間は公式モデルのコンテキスト編集は設定カードに。ON で ModelPanel 引き継ぎを復元。変更後はリロードが必要。
23
+ - ModelPanel ポップアップの検索(#3):4 モデル超で表示、公式の規則に準拠。
24
+
14
25
  ## [4.3.1] — 2026-10-17(ホスト列挙の更新:0.2.1-rc.1 を追加)
15
26
 
16
27
  ### Fixed
@@ -19,21 +30,21 @@
19
30
  - devDependencies の `@deepseek-ai/dsh-client-*` を 0.2.0-rc.1 → 0.2.1-rc.1 に更新し、ビルドと全テスト(140 件)を対象ラインで検証。
20
31
  - README の互換記述(en/zh/ja/ko/de/es/fr/it/ru)を列挙に同期。動作変更なし。
21
32
 
22
- ## [4.3.0] — 2026-10-17
23
-
24
- ### 追加
25
- - 価格カタログ(src/price-catalog.ts):29 モデル x 地域。DeepSeek V4.1-Flash / V4-Flash / V4-Pro は公式のピーク/オフピーク2段(北京 09-12・14-18 がピーク、2026-08-17 施行)、GLM / Kimi / Qwen / Doubao / MiniMax / Ernie は一律価格。各項目は百万トークンあたりの3価格(非キャッシュ入力 / キャッシュヒット入力 / 出力)を保持し、asOf と出典を明記。海外(USD)枠は構造上予約するも公式確認まで意図的に空(数値の捏造なし)。
26
- - defaultPricing 設定(cn / global / custom / off、既定 off):カタログ外モデルは Flash 価格で估算せず「未計価」と表示。
27
- - 2026 国務院祝日/振替修正表(39 エントリ、dsh-session-guard と同源):振替出勤の週末は平日としてピーク判定、法定祝日は終日オフピーク。表外年は週末のみの劣化動作。
28
-
29
- ### 変更
30
- - プロジェクション stateVersion 1 -> 2:usage サンプルごとに確定時の計価レシートを state に永続化、同一 step 置換は記録値を減算(费率混在再計算と負値を排除)、会話/ターン集計は通貨別バケット。アップグレード直後に旧セッションは現行カタログで再折りたたみされ総額が一度変動、以降の設定変更は新規サンプルのみ影响。
31
- - 請求ポップオーバー:通貨別記号(¥ / $、不明は ISO コード)、flat/-null の正直な表示、「<model> で計価」はカタログ名から、混合通貨会話は合計せず通貨別行。
32
-
33
- ### 修正
34
- - settings.describe() の形状正規化(進程内配列 vs RPC エンベロープ {namespaces:[...]}):想定外形状は例外を投げず欠扱い(静默冻结クラスを解消)。
35
- - プロジェクション登録を try/catch で保護:請求单元的失败不再毒化插件整体或冷会话历史加载。
36
-
33
+ ## [4.3.0] — 2026-10-17
34
+
35
+ ### 追加
36
+ - 価格カタログ(src/price-catalog.ts):29 モデル x 地域。DeepSeek V4.1-Flash / V4-Flash / V4-Pro は公式のピーク/オフピーク2段(北京 09-12・14-18 がピーク、2026-08-17 施行)、GLM / Kimi / Qwen / Doubao / MiniMax / Ernie は一律価格。各項目は百万トークンあたりの3価格(非キャッシュ入力 / キャッシュヒット入力 / 出力)を保持し、asOf と出典を明記。海外(USD)枠は構造上予約するも公式確認まで意図的に空(数値の捏造なし)。
37
+ - defaultPricing 設定(cn / global / custom / off、既定 off):カタログ外モデルは Flash 価格で估算せず「未計価」と表示。
38
+ - 2026 国務院祝日/振替修正表(39 エントリ、dsh-session-guard と同源):振替出勤の週末は平日としてピーク判定、法定祝日は終日オフピーク。表外年は週末のみの劣化動作。
39
+
40
+ ### 変更
41
+ - プロジェクション stateVersion 1 -> 2:usage サンプルごとに確定時の計価レシートを state に永続化、同一 step 置換は記録値を減算(费率混在再計算と負値を排除)、会話/ターン集計は通貨別バケット。アップグレード直後に旧セッションは現行カタログで再折りたたみされ総額が一度変動、以降の設定変更は新規サンプルのみ影响。
42
+ - 請求ポップオーバー:通貨別記号(¥ / $、不明は ISO コード)、flat/-null の正直な表示、「<model> で計価」はカタログ名から、混合通貨会話は合計せず通貨別行。
43
+
44
+ ### 修正
45
+ - settings.describe() の形状正規化(進程内配列 vs RPC エンベロープ {namespaces:[...]}):想定外形状は例外を投げず欠扱い(静默冻结クラスを解消)。
46
+ - プロジェクション登録を try/catch で保護:請求单元的失败不再毒化插件整体或冷会话历史加载。
47
+
37
48
  ## [4.2.1] — 2026-10-12
38
49
 
39
50
  ### 変更 — stable への昇格(4.2.0-beta.29 からコード変更なし)
package/CHANGELOG.ko.md CHANGED
@@ -11,6 +11,17 @@
11
11
  - [Список изменений на русском](./CHANGELOG.ru.md)
12
12
  - [Changelog en español](./CHANGELOG.es.md)
13
13
 
14
+ ## [4.4.0] — 2026-10-19(issue 일괄 처리: #2 #3 #4 #5)
15
+
16
+ ### 수정
17
+ - 기능 카드(#2): `api`가 openai-completions이 아닌 제공자에서는 Thinking / Supports-effort / thinkingFormat 컨트롤을 안내 문구와 함께 비활성화 — 잘못된 쓰기로 인한 `card.writeError` 제거(호스트 Responses 호환 게이트는 이 모델 필드를 제공하지 않음).
18
+ - 로딩 비용(#4): `resolveModel` 광고를 멱등화(WeakSet 가드). 기존에는 `llm/adapters-updated`마다 래퍼가 중첩되어 해석마다 전체 settings 읽기가 발생. readout 세대 캐시화, 설정 커밋 시 무효화, takeover 미러 재동기는 관련 namespace에서만 실행.
19
+ - 단계 chip(#5): `auto` 선택 시 chip은 **Auto**를 유지하고 해당 스텝의 해석 값은 `→ <level>` 보조 표기로 격하.
20
+
21
+ ### 추가
22
+ - `takeoverUi` 설정(기본 OFF, #3/#4): 공식 모델 팝업 유지(검색·로딩은 네이티브, `auto`는 서버측 광고로 계속 제공). OFF일 때 공식 모델 컨텍스트 편집은 설정 카드로. ON이면 ModelPanel 인수 복원. 변경 후 새로고침 필요.
23
+ - ModelPanel 팝업 검색(#3): 4개 모델 초과 시 표시, 공식 규칙과 동일.
24
+
14
25
  ## [4.3.1] — 2026-10-17(호스트 열거 갱신: 0.2.1-rc.1 추가)
15
26
 
16
27
  ### Fixed
@@ -19,21 +30,21 @@
19
30
  - devDependencies `@deepseek-ai/dsh-client-*`를 0.2.0-rc.1 → 0.2.1-rc.1로 전환, 빌드·전체 테스트(140건) 대상 라인에서 검증.
20
31
  - README 호환 서술(en/zh/ja/ko/de/es/fr/it/ru)을 열거와 동기화. 동작 변경 없음.
21
32
 
22
- ## [4.3.0] — 2026-10-17
23
-
24
- ### 추가
25
- - 가격 카탈로그(src/price-catalog.ts): 29개 모델 x 지역 — DeepSeek V4.1-Flash / V4-Flash / V4-Pro는 공식 봉우/곡선 2단(베이징 09-12, 14-18 봉우리; 2026-08-17 시행), GLM / Kimi / Qwen / Doubao / MiniMax / Ernie는 평일 가격. 각 항목은 백만 토큰당 3개 슬롯(비캐시 입력 / 캐시 히트 입력 / 출력)과 asOf + 출처 표기를 가짐. 해외(USD) 항목은 구조만 확보, 공식 페이지 검증 전까지 의도적 비움(날조 없음).
26
- - defaultPricing 설정(cn / global / custom / off, 기본 off): 카탈로그 밖 모델은 더 이상 Flash 가격으로 추정하지 않고 "미과금"으로 표시.
27
- - 2026 국무원 공휴/보근 수정표(39항목, dsh-session-guard 와 동일 출처): 보근 주말은 평일처럼 봉우리의 대상, 법정 공휴는 종일 곡선. 표 밖 연도는 주말 규칙으로 축퇴.
28
-
29
- ### 변경
30
- - 프로젝션 stateVersion 1 -> 2: 사용 샘플에 절입 시점 계산 전표를 영속화, 동일 단계 교체는 기록값 차감(혼합 요율 재계산·음수 제거), 합계는 통화별 버킷. 업그레이드 후 옛 세션은 현재 카탈로그로 재절입되어 총액이 한 번 변동, 이후 설정 변경은 신규 샘플에만 반영.
31
- - 과금 팝오버: 통화별 기호(¥ / $, 미지는 ISO 코드), flat/null 정직한 표시, "모댔 기반 과금", 혼통화 세션은 합산 대신 통화별 행.
32
-
33
- ### 수정
34
- - settings.describe() 모양 정규화(프로세스 내 배열 vs RPC ​​{namespaces:[...]} 봉투): 이상 모양은 예외 대신 결측 처리(조용한 동결 classe 해소).
35
- - 프로젝션 등록 try/catch 보호: 과금 단위 실패가 플러그인 전체/콜드 세션 히스토리를 오염시키지 않음.
36
-
33
+ ## [4.3.0] — 2026-10-17
34
+
35
+ ### 추가
36
+ - 가격 카탈로그(src/price-catalog.ts): 29개 모델 x 지역 — DeepSeek V4.1-Flash / V4-Flash / V4-Pro는 공식 봉우/곡선 2단(베이징 09-12, 14-18 봉우리; 2026-08-17 시행), GLM / Kimi / Qwen / Doubao / MiniMax / Ernie는 평일 가격. 각 항목은 백만 토큰당 3개 슬롯(비캐시 입력 / 캐시 히트 입력 / 출력)과 asOf + 출처 표기를 가짐. 해외(USD) 항목은 구조만 확보, 공식 페이지 검증 전까지 의도적 비움(날조 없음).
37
+ - defaultPricing 설정(cn / global / custom / off, 기본 off): 카탈로그 밖 모델은 더 이상 Flash 가격으로 추정하지 않고 "미과금"으로 표시.
38
+ - 2026 국무원 공휴/보근 수정표(39항목, dsh-session-guard 와 동일 출처): 보근 주말은 평일처럼 봉우리의 대상, 법정 공휴는 종일 곡선. 표 밖 연도는 주말 규칙으로 축퇴.
39
+
40
+ ### 변경
41
+ - 프로젝션 stateVersion 1 -> 2: 사용 샘플에 절입 시점 계산 전표를 영속화, 동일 단계 교체는 기록값 차감(혼합 요율 재계산·음수 제거), 합계는 통화별 버킷. 업그레이드 후 옛 세션은 현재 카탈로그로 재절입되어 총액이 한 번 변동, 이후 설정 변경은 신규 샘플에만 반영.
42
+ - 과금 팝오버: 통화별 기호(¥ / $, 미지는 ISO 코드), flat/null 정직한 표시, "모댔 기반 과금", 혼통화 세션은 합산 대신 통화별 행.
43
+
44
+ ### 수정
45
+ - settings.describe() 모양 정규화(프로세스 내 배열 vs RPC ​​{namespaces:[...]} 봉투): 이상 모양은 예외 대신 결측 처리(조용한 동결 classe 해소).
46
+ - 프로젝션 등록 try/catch 보호: 과금 단위 실패가 플러그인 전체/콜드 세션 히스토리를 오염시키지 않음.
47
+
37
48
  ## [4.2.1] — 2026-10-12
38
49
 
39
50
  ### 변경 — 안정 버전 승격 (4.2.0-beta.29 이후 코드 변경 없음)
package/CHANGELOG.md CHANGED
@@ -1,8 +1,24 @@
1
1
  # Changelog
2
2
 
3
- ## 4.3.2 (2026-10-18)
3
+ ## [4.4.0] — 2026-10-19 (issue batch: #2 #3 #4 #5)
4
4
 
5
- - hosts: 追加 0.2.1-rc.2 声明面枚举(宿主 peer 逐包 npm 实测 rc.2 在版;不触 ctx.web provider 与 model.label 槽,代码零改动,纯元数据发版;农场 rc.2 格挂账待命)
5
+ ### Fixed
6
+ - Capability card (#2): providers whose `api` is not `openai-completions` (openai-responses family, anthropic-messages …) now grey out the Thinking / Supports-effort / thinkingFormat controls with an explanatory note instead of failing the whole providers write with a generic `card.writeError` — the host's Responses compat gate never offers those model-level fields.
7
+ - Load cost (#4): the `resolveModel` advertisement is idempotent again — repeated `llm/adapters-updated` used to STACK wrappers, each replaying a full settings readout (O(models × wrappers) on the model page). The readout is generation-cached (invalidated on settings commits) and the takeover mirror re-check only runs for namespaces that can move the judgment. Note: the 4.3.0 projection stateVersion bump keeps a ONE-TIME history re-fold on the first load after upgrading.
8
+ - Effort chip (#5): with the level set to `auto` the panel chip keeps showing **Auto** and demotes the step's resolved level to a secondary `→ <level>` hint, instead of being overwritten by the scheduler's wire value.
9
+
10
+ ### Added
11
+ - `takeoverUi` setting (default OFF, #3/#4): the composer keeps the official model popup — native search and loading, and the `auto` mask still arrives through the server-side advertisement; official-model context editing lives on the settings card while it is OFF. Flip it ON to restore the ModelPanel takeover. Reload the page after changing.
12
+ - ModelPanel popup search (#3): shown past four models, mirroring the shipped selector's rule.
13
+
14
+ ## 4.3.3 (2026-10-18)
15
+
16
+ - 计价目录化上线:price-catalog 41 条(国内 30 CNY 峰谷/平价 + 海外 11 USD:Claude 4 官方页一手、GPT 4/Gemini 3 Copilot 计费文档×公告交叉核实),注入型号按目录实价入账、目录外走 estimate 典型价兜底并标「未校准·仅供参考」(免费档调用=按标准价折算的花费/白嫖额度感知)。
17
+ - 凭证入账 stateVersion 2→3;设置卡目录外定价五档选择器(9 语);CATALOG_VERSION 1→2;golden 150/150 绿。
18
+
19
+ ## 4.3.2 (2026-10-18)
20
+
21
+ - hosts: 追加 0.2.1-rc.2 声明面枚举(宿主 peer 逐包 npm 实测 rc.2 在版;不触 ctx.web provider 与 model.label 槽,代码零改动,纯元数据发版;农场 rc.2 格挂账待命)
6
22
 
7
23
  All notable changes to `dsh-thinking-levels` are documented here.
8
24
 
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 drscrewdriver
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 drscrewdriver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -97,10 +97,16 @@ For hand-declared `llm-pi-ai` models, map each level to the exact value your gat
97
97
 
98
98
  The model panel's per-line effort `<select>` became a **segment slider**: click a line's effort chip (it shows the effective level, or *Provider default*) and a full-width slider expands under that line. The stop count adapts to what the model advertises — two-stop toggle-only models, the official `off/low/high/max` set, custom gateway wire values; `auto` (when the directory carries the mask) is pinned **leftmost**, then `off`/`on`, then the strength gradient, unknown wire values last.
99
99
 
100
+ Since 4.4.0 the selector's own effort chip shows the **user intent**, not the scheduler's resolved level: with the intent `auto` the main label stays **Auto** and the level actually sent in the last step is demoted to a secondary hint (`→ low`). Note: while the model-UI takeover below is off, the *official* selector's chip keeps showing the last resolved level — that is host projection semantics the plugin cannot restyle.
101
+
100
102
  Interaction follows the approved dsh-reasoning-effort visual baseline: the thumb follows the pointer continuously and **snaps on release** (one route write per gesture), the plain thumb is pure white in every theme, the thumb stays fully visible at both endpoints, and ←/→/Home/End step stop-by-stop. The select's *Provider default* reset survives as the ↺ button of the slider row.
101
103
 
102
104
  DeepSeek lines (the official route, or any gateway model whose id/name says deepseek) run the **whale-girl runner** as the thumb: an 8-frame side-run strip, ping-pong looped (720 ms per direction at rest, 420 ms while dragging), frozen under `prefers-reduced-motion`. Every other model gets the plain knob.
103
105
 
106
+ ## Model UI takeover (since 4.4.0)
107
+
108
+ New setting `takeoverUi` (default **off**): the plugin no longer replaces the composer's model popup — search, grouping and loading stay with the shipped selector, and the `auto` mask still arrives through the server-side advertisement; official-model context editing lives on the settings card. Turning it on restores the ModelPanel takeover (per-line editors + popup search). Reload the page after changing.
109
+
104
110
  The strip is community whale-girl artwork sourced from [HanaAyane/dsh-reasoning-effort](https://github.com/HanaAyane/dsh-reasoning-effort) (`assets/chibi-runner-strip.png`); regenerate the inlined asset with `python tools/whale-mascot.py`.
105
111
 
106
112
  ## Context-window presets
package/README.zh.md CHANGED
@@ -68,10 +68,16 @@
68
68
 
69
69
  模型面板里的逐行思考强度下拉框已改造为**分段滑块**:点击模型行的档位 chip(显示当前生效档位或「提供方默认」),该行下方展开全宽滑动条。分段数随模型广告的档位自适应——toggle 型只有两档、官方 `off/low/high/max`、网关自定义线上值均可;目录带 `auto` mask 时 **auto 恒在最左**,其后依次 off/on 与强度递增档,未知线上值排最末。
70
70
 
71
+ 选择器头的档位 chip(4.4.0 起)显示的是**用户意图**而非调度器的解析值:意图为 `auto` 时主标签保持 **Auto**,本步实际发出的档位降为次级标注(如 `→ low`)。注意:关闭模型界面接管时,官方选择器的 chip 仍显示本步解析值(宿主投影语义,插件不可代改)。
72
+
71
73
  交互对齐 dsh-reasoning-effort 已批准的视觉基线:滑钮拖动时连续跟手、**松手吸附**提交(每次手势只写一次路由);普通滑钮全主题纯白;两端刻度处滑钮完整可见;键盘 ←/→/Home/End 逐档移动。原「提供方默认」重置保留为滑块行的 ↺ 按钮。
72
74
 
73
75
  DeepSeek 行(官方路由,或 id/名称含 deepseek 的网关模型)滑钮为**鲸鱼娘奔跑立绘**:8 帧侧面奔跑 strip,乒乓循环(静止 720ms/单向,拖动中 420ms/单向),`prefers-reduced-motion` 下冻结;其他模型为普通白色圆钮。
74
76
 
77
+ ## 模型界面接管(4.4.0 起)
78
+
79
+ 新增设置项「模型界面接管」(`takeoverUi`,缺省关闭):关闭时不替换官方模型弹窗——搜索、分组、加载都由宿主原生选择器负责,`auto` 档位照常经服务端广告出现;官方模型的上下文编辑在设置卡内完成。开启时恢复本插件的 ModelPanel 接管(逐行上下文/档位编辑 + 弹窗搜索)。更改后需重载页面生效。
80
+
75
81
  立绘为社区鲸鱼娘二创,来源 [HanaAyane/dsh-reasoning-effort](https://github.com/HanaAyane/dsh-reasoning-effort)(`assets/chibi-runner-strip.png`);用 `python tools/whale-mascot.py` 可重新生成内联素材。
76
82
 
77
83
  ## 模型能力守卫(v0.5.0)
package/cordis.patch.yml CHANGED
@@ -1,3 +1,3 @@
1
- - insert:
2
- - id: dsh-thinking-levels
3
- name: dsh-thinking-levels
1
+ - insert:
2
+ - id: dsh-thinking-levels
3
+ name: dsh-thinking-levels
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-thinking-levels",
3
- "version": "4.3.2",
3
+ "version": "4.4.0",
4
4
  "main": "./lib/index.js",
5
5
  "description": "thinking-level (reasoning_effort) control — auto-adjust per tool round, with optional manual lock and per-tool timing telemetry.",
6
6
  "engines": {
@@ -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 2 即为此声明(宿主对旧 ver 行整行废弃重折)。
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 2 即为此声明(宿主对旧 ver 行整行废弃重折)。
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: 2,
413
+ stateVersion: 3,
407
414
  stateSchema,
408
415
  init,
409
416
  apply,