@kenz1117/dsh-ui-usage-billing 1.2.1 → 1.2.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/lib/index.js CHANGED
@@ -243,15 +243,24 @@ const WEEKEND_OFFPEAK_START_MS = Date.parse("2026-08-22T16:00:00Z");
243
243
  * 1/0.02/4(峰 = 谷 × 2)。目录条目写现行(新)价;分界前的历史事件由
244
244
  * {@link computeCostAt} 按 {@link FLASH_REPRICED_OFFPEAK} 回算旧价,与
245
245
  * {@link PEAK_ERA_START_MS} 同一「按事件时刻分段适用规则」口径。
246
+ * pro 例外:V4 Pro 的路由计费分界是 {@link PRO_OFFLINE_MS}(官方把原定
247
+ * 09-10 的路由时点推迟到 09-14 12:00),不在本分界切换。
246
248
  */
247
249
  const FLASH_REPRICE_MS = Date.parse("2026-09-10T04:00:00Z");
248
250
  /**
251
+ * V4 Pro 下线路由分界(UTC 2026-09-14T04:00:00Z,即北京时间 2026-09-14
252
+ * 12:00):官方价目页注释明确,此后至 V4.1 Pro 上线前,`deepseek-v4-pro`
253
+ * 的请求全部路由至 V4.1 Flash 并按其单价计费——此前的请求仍按 V4 Pro
254
+ * 峰谷刊例计费(官方原定 09-10 路由,后推迟到 09-14)。
255
+ */
256
+ const PRO_OFFLINE_MS = Date.parse("2026-09-14T04:00:00Z");
257
+ /**
249
258
  * flash 系调价前的官方谷档价(CNY / 1M tokens):{@link FLASH_REPRICE_MS}
250
259
  * 之前的 flash / flash-vision-exp 事件按此回算(峰档 = 谷档 × 2)。pro 的
251
- * 同表条目是 V4 Pro 峰谷时代刊例(谷 4.5/0.15/13.5):官方公告自
252
- * {@link FLASH_REPRICE_MS} V4 Pro 请求全部路由至 V4.1 Flash 并按其单价
253
- * 计费(V4.1 Pro 上线前),故分界前回算 V4 Pro 刊例、分界后走目录的 Flash 价。
254
- * 用户价 = 实付价,与 legacy 口径相同地跳过本表。
260
+ * 同表条目是 V4 Pro 峰谷时代刊例(谷 4.5/0.15/13.5):官方自
261
+ * {@link PRO_OFFLINE_MS} 起(原定 09-10,后推迟)把 V4 Pro 请求全部路由至
262
+ * V4.1 Flash 并按其单价计费(V4.1 Pro 上线前),故分界前回算 V4 Pro 刊例、
263
+ * 分界后走目录的 Flash 价。用户价 = 实付价,与 legacy 口径相同地跳过本表。
255
264
  */
256
265
  const FLASH_PRE_REPRICE_BAND = {
257
266
  input: 1.5,
@@ -336,7 +345,7 @@ const GEMINI_PEAK_HOURS = "Standard / Flex";
336
345
  const MODEL_CATALOG = [
337
346
  {
338
347
  key: "flash",
339
- name: "DeepSeek V4 Flash",
348
+ name: "DeepSeek V4.1 Flash",
340
349
  provider: "DeepSeek",
341
350
  colorVar: "dsw-static-blue-500",
342
351
  price: {
@@ -357,6 +366,7 @@ const MODEL_CATALOG = [
357
366
  name: "DeepSeek V4 Flash Vision (Exp)",
358
367
  provider: "DeepSeek",
359
368
  colorVar: "dsw-static-blue-500",
369
+ retired: true,
360
370
  price: {
361
371
  currency: "CNY",
362
372
  input: 2,
@@ -1423,6 +1433,7 @@ const MODEL_KEY_ALIASES = {
1423
1433
  "deepseek-v4-flash-vision-exp": "flash-vision-exp",
1424
1434
  "deepseek-v4.1-flash": "flash",
1425
1435
  "deepseek-v4.1-flash-expires-on-0910": "flash",
1436
+ "deepseek-flash": "flash",
1426
1437
  "deepseek-v4-pro": "pro",
1427
1438
  "glm-5.2": "glm",
1428
1439
  "glm-4.5-air": "glm-4.5-air",
@@ -1760,7 +1771,7 @@ function computeCostAt(entry, buckets, timeMs, peakShare = DEFAULT_PEAK_SHARE) {
1760
1771
  const priced = applyPromo(entry, timeMs);
1761
1772
  const legacy = timeMs < PEAK_ERA_START_MS && entry.userPriced !== true ? LEGACY_DEEPSEEK_BANDS[entry.key] : void 0;
1762
1773
  if (legacy !== void 0) return priceBandCost(legacy, buckets, "CNY");
1763
- const repriced = timeMs < FLASH_REPRICE_MS && entry.userPriced !== true ? FLASH_REPRICED_OFFPEAK[entry.key] : void 0;
1774
+ const repriced = timeMs < (entry.key === "pro" ? PRO_OFFLINE_MS : FLASH_REPRICE_MS) && entry.userPriced !== true ? FLASH_REPRICED_OFFPEAK[entry.key] : void 0;
1764
1775
  if (repriced !== void 0) return priceBandCost((timeMs < WEEKEND_OFFPEAK_START_MS ? tariffV1At(timeMs) : tierAt(timeMs)) === "peak" ? {
1765
1776
  input: repriced.input * 2,
1766
1777
  cacheHit: repriced.cacheHit * 2,
@@ -2500,7 +2511,7 @@ function createUsageAggregator(persistence, options = {}) {
2500
2511
  id,
2501
2512
  ...cwd === void 0 ? {} : { cwd },
2502
2513
  ...stamp === null ? {} : { stamp },
2503
- foldVersion: 13,
2514
+ foldVersion: 14,
2504
2515
  fingerprint: foldFingerprint,
2505
2516
  fold: serializeFold(fold)
2506
2517
  };
@@ -2597,7 +2608,7 @@ function createUsageAggregator(persistence, options = {}) {
2597
2608
  try {
2598
2609
  const cwd = meta.cwd;
2599
2610
  const ledgerRow = ledger.get(id);
2600
- if (ledgerRow !== void 0 && ledgerRow.stamp !== void 0 && stamp !== null && ledgerRow.stamp === stamp && (ledgerRow.foldVersion ?? 1) === 13 && ledgerRow.fingerprint === foldFingerprint) {
2611
+ if (ledgerRow !== void 0 && ledgerRow.stamp !== void 0 && stamp !== null && ledgerRow.stamp === stamp && (ledgerRow.foldVersion ?? 1) === 14 && ledgerRow.fingerprint === foldFingerprint) {
2601
2612
  const fold = deserializeFold(ledgerRow.fold);
2602
2613
  folds.push({
2603
2614
  id,
@@ -2679,7 +2690,7 @@ function createUsageAggregator(persistence, options = {}) {
2679
2690
  for (const entry of ledger.values()) {
2680
2691
  if (included.has(entry.id)) continue;
2681
2692
  try {
2682
- const stale = (entry.foldVersion ?? 1) < 13 || entry.fingerprint !== foldFingerprint;
2693
+ const stale = (entry.foldVersion ?? 1) < 14 || entry.fingerprint !== foldFingerprint;
2683
2694
  folds.push({
2684
2695
  id: entry.id,
2685
2696
  ...entry.cwd === void 0 ? {} : { cwd: entry.cwd },
@@ -491,7 +491,7 @@ export interface UsageLedgerDocument {
491
491
  * 会话费用只剩最近一段,issue #29)。
492
492
  * 持久账本行据此区分新旧算法:日志已删/不可读而只能沿用旧行时,UI 标注置信度提示。
493
493
  */
494
- export declare const FOLD_VERSION = 13;
494
+ export declare const FOLD_VERSION = 14;
495
495
  /**
496
496
  * 一次性账本迁移:id 唯一,apply 在加载边界对原始文档执行,已应用过的跳过。
497
497
  * 未来账本/schema 字段变更(重命名、拆桶、语义调整)时,在此追加一条迁移并
@@ -159,8 +159,17 @@ export declare const WEEKEND_OFFPEAK_START_MS: number;
159
159
  * 1/0.02/4(峰 = 谷 × 2)。目录条目写现行(新)价;分界前的历史事件由
160
160
  * {@link computeCostAt} 按 {@link FLASH_REPRICED_OFFPEAK} 回算旧价,与
161
161
  * {@link PEAK_ERA_START_MS} 同一「按事件时刻分段适用规则」口径。
162
+ * pro 例外:V4 Pro 的路由计费分界是 {@link PRO_OFFLINE_MS}(官方把原定
163
+ * 09-10 的路由时点推迟到 09-14 12:00),不在本分界切换。
162
164
  */
163
165
  export declare const FLASH_REPRICE_MS: number;
166
+ /**
167
+ * V4 Pro 下线路由分界(UTC 2026-09-14T04:00:00Z,即北京时间 2026-09-14
168
+ * 12:00):官方价目页注释明确,此后至 V4.1 Pro 上线前,`deepseek-v4-pro`
169
+ * 的请求全部路由至 V4.1 Flash 并按其单价计费——此前的请求仍按 V4 Pro
170
+ * 峰谷刊例计费(官方原定 09-10 路由,后推迟到 09-14)。
171
+ */
172
+ export declare const PRO_OFFLINE_MS: number;
164
173
  /** 计费时段档位:高峰 / 空闲(官方 DeepSeek 刊例价:高峰 = 空闲 × 2)。 */
165
174
  export type PriceTierId = 'peak' | 'offPeak';
166
175
  /** 成本显示币种:人民币(国内模型直价)/ 美元(国外模型直价或换算显示)。 */
@@ -306,6 +315,11 @@ export interface ModelEntry {
306
315
  uncatalogued?: boolean;
307
316
  /** 该条目当前按用户自定义单价计价(设置面板可维护);费率表标注「自定义」。 */
308
317
  userPriced?: boolean;
318
+ /**
319
+ * 厂商已下线的模型(请求由继任型号服务、按继任单价计):不进费率表面板,
320
+ * 目录条目与历史回算保留——存量用量仍按原键计价与显示,删条目会破坏历史计算。
321
+ */
322
+ retired?: boolean;
309
323
  }
310
324
  export declare const MODEL_CATALOG: readonly ModelEntry[];
311
325
  /**
@@ -353,7 +367,9 @@ export declare function applyPromo(entry: ModelEntry, nowMs: number): ModelEntry
353
367
  * 会把费率表撑爆;它们只作为目录外模型的计价回退源(见 {@link livePriceOf} /
354
368
  * {@link modelOf})。探活模型在此逐个对价:内置已有的跳过去重;目录外但
355
369
  * models.dev 有价的按归一化 id 复用其 USD 价;两者皆无的标 `uncatalogued`。
356
- * 内置条目按 nowMs 折算限时促销(生效中的条目显示折后单价,过期自动恢复刊例价)。
370
+ * 内置条目按 nowMs 折算限时促销(生效中的条目显示折后单价,过期自动恢复刊例价),
371
+ * 应用路由分界期的现行价覆盖(V4 Pro 见 {@link applyRoutingDisplay}),并滤除
372
+ * 已下线条目(retired:官方下线的型号不进面板,目录与历史回算保留)。
357
373
  * @param nowMs - 促销判定时刻;缺省当前时刻。
358
374
  */
359
375
  export declare function catalogEntries(nowMs?: number): readonly ModelEntry[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kenz1117/dsh-ui-usage-billing",
3
3
  "description": "Usage billing dashboard for DeepSeek Harness: sidebar cost metrics plus a full dashboard modal, priced from a current multi-provider catalog with real usage aggregated from session logs.",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "deepseek",