@kenz1117/dsh-ui-usage-billing 1.1.14 → 1.1.16

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
@@ -227,15 +227,24 @@ const WEEKEND_OFFPEAK_START_MS = Date.parse("2026-08-22T16:00:00Z");
227
227
  * 1/0.02/4(峰 = 谷 × 2)。目录条目写现行(新)价;分界前的历史事件由
228
228
  * {@link computeCostAt} 按 {@link FLASH_REPRICED_OFFPEAK} 回算旧价,与
229
229
  * {@link PEAK_ERA_START_MS} 同一「按事件时刻分段适用规则」口径。
230
+ * pro 例外:V4 Pro 的路由计费分界是 {@link PRO_OFFLINE_MS}(官方把原定
231
+ * 09-10 的路由时点推迟到 09-14 12:00),不在本分界切换。
230
232
  */
231
233
  const FLASH_REPRICE_MS = Date.parse("2026-09-10T04:00:00Z");
232
234
  /**
235
+ * V4 Pro 下线路由分界(UTC 2026-09-14T04:00:00Z,即北京时间 2026-09-14
236
+ * 12:00):官方价目页注释明确,此后至 V4.1 Pro 上线前,`deepseek-v4-pro`
237
+ * 的请求全部路由至 V4.1 Flash 并按其单价计费——此前的请求仍按 V4 Pro
238
+ * 峰谷刊例计费(官方原定 09-10 路由,后推迟到 09-14)。
239
+ */
240
+ const PRO_OFFLINE_MS = Date.parse("2026-09-14T04:00:00Z");
241
+ /**
233
242
  * flash 系调价前的官方谷档价(CNY / 1M tokens):{@link FLASH_REPRICE_MS}
234
243
  * 之前的 flash / flash-vision-exp 事件按此回算(峰档 = 谷档 × 2)。pro 的
235
- * 同表条目是 V4 Pro 峰谷时代刊例(谷 4.5/0.15/13.5):官方公告自
236
- * {@link FLASH_REPRICE_MS} 起 V4 Pro 请求全部路由至 V4.1 Flash 并按其单价
237
- * 计费(V4.1 Pro 上线前),故分界前回算 V4 Pro 刊例、分界后走目录的 Flash 价。
238
- * 用户价 = 实付价,与 legacy 口径相同地跳过本表。
244
+ * 同表条目是 V4 Pro 峰谷时代刊例(谷 4.5/0.15/13.5):官方自
245
+ * {@link PRO_OFFLINE_MS} 起(原定 09-10,后推迟)把 V4 Pro 请求全部路由至
246
+ * V4.1 Flash 并按其单价计费(V4.1 Pro 上线前),故分界前回算 V4 Pro 刊例、
247
+ * 分界后走目录的 Flash 价。用户价 = 实付价,与 legacy 口径相同地跳过本表。
239
248
  */
240
249
  const FLASH_PRE_REPRICE_BAND = {
241
250
  input: 1.5,
@@ -320,7 +329,7 @@ const GEMINI_PEAK_HOURS = "Standard / Flex";
320
329
  const MODEL_CATALOG = [
321
330
  {
322
331
  key: "flash",
323
- name: "DeepSeek V4 Flash",
332
+ name: "DeepSeek V4.1 Flash",
324
333
  provider: "DeepSeek",
325
334
  colorVar: "dsw-static-blue-500",
326
335
  price: {
@@ -341,6 +350,7 @@ const MODEL_CATALOG = [
341
350
  name: "DeepSeek V4 Flash Vision (Exp)",
342
351
  provider: "DeepSeek",
343
352
  colorVar: "dsw-static-blue-500",
353
+ retired: true,
344
354
  price: {
345
355
  currency: "CNY",
346
356
  input: 2,
@@ -1407,6 +1417,7 @@ const MODEL_KEY_ALIASES = {
1407
1417
  "deepseek-v4-flash-vision-exp": "flash-vision-exp",
1408
1418
  "deepseek-v4.1-flash": "flash",
1409
1419
  "deepseek-v4.1-flash-expires-on-0910": "flash",
1420
+ "deepseek-flash": "flash",
1410
1421
  "deepseek-v4-pro": "pro",
1411
1422
  "glm-5.2": "glm",
1412
1423
  "glm-4.5-air": "glm-4.5-air",
@@ -1691,7 +1702,7 @@ function computeCostAt(entry, buckets, timeMs, peakShare = DEFAULT_PEAK_SHARE) {
1691
1702
  const priced = applyPromo(entry, timeMs);
1692
1703
  const legacy = timeMs < PEAK_ERA_START_MS && entry.userPriced !== true ? LEGACY_DEEPSEEK_BANDS[entry.key] : void 0;
1693
1704
  if (legacy !== void 0) return priceBandCost(legacy, buckets, "CNY");
1694
- const repriced = timeMs < FLASH_REPRICE_MS && entry.userPriced !== true ? FLASH_REPRICED_OFFPEAK[entry.key] : void 0;
1705
+ const repriced = timeMs < (entry.key === "pro" ? PRO_OFFLINE_MS : FLASH_REPRICE_MS) && entry.userPriced !== true ? FLASH_REPRICED_OFFPEAK[entry.key] : void 0;
1695
1706
  if (repriced !== void 0) return priceBandCost((timeMs < WEEKEND_OFFPEAK_START_MS ? tariffV1At(timeMs) : tierAt(timeMs)) === "peak" ? {
1696
1707
  input: repriced.input * 2,
1697
1708
  cacheHit: repriced.cacheHit * 2,
@@ -2370,7 +2381,7 @@ function createUsageAggregator(persistence, options = {}) {
2370
2381
  id,
2371
2382
  ...cwd === void 0 ? {} : { cwd },
2372
2383
  ...stamp === null ? {} : { stamp },
2373
- foldVersion: 9,
2384
+ foldVersion: 10,
2374
2385
  fold: serializeFold(fold)
2375
2386
  };
2376
2387
  const row = ledger.get(id);
@@ -2460,7 +2471,7 @@ function createUsageAggregator(persistence, options = {}) {
2460
2471
  try {
2461
2472
  const cwd = meta.cwd;
2462
2473
  const ledgerRow = ledger.get(id);
2463
- if (ledgerRow !== void 0 && ledgerRow.stamp !== void 0 && stamp !== null && ledgerRow.stamp === stamp && (ledgerRow.foldVersion ?? 1) === 9) {
2474
+ if (ledgerRow !== void 0 && ledgerRow.stamp !== void 0 && stamp !== null && ledgerRow.stamp === stamp && (ledgerRow.foldVersion ?? 1) === 10) {
2464
2475
  const fold = deserializeFold(ledgerRow.fold);
2465
2476
  folds.push({
2466
2477
  id,
@@ -2543,7 +2554,7 @@ function createUsageAggregator(persistence, options = {}) {
2543
2554
  for (const entry of ledger.values()) {
2544
2555
  if (included.has(entry.id)) continue;
2545
2556
  try {
2546
- const stale = (entry.foldVersion ?? 1) < 9;
2557
+ const stale = (entry.foldVersion ?? 1) < 10;
2547
2558
  folds.push({
2548
2559
  id: entry.id,
2549
2560
  ...entry.cwd === void 0 ? {} : { cwd: entry.cwd },
@@ -434,8 +434,12 @@ export interface UsageLedgerDocument {
434
434
  * 9:V4.1 Flash 内测端点 id(expires-on-0910)收录进别名表——此前该 id 落目录兜底
435
435
  * 条目(Custom),费用按 0 计且把「主力消耗模型余额」挤成「未配置」(issue #40
436
436
  * 反馈);bump 让存量账单的内测用量按 flash 时间线重折归并。
437
+ * 10:官方把 V4 Pro 路由时点从 09-10 12:00 推迟到 09-14 12:00(价目页注释 (2)),
438
+ * pro 的回算分界改用 PRO_OFFLINE_MS——09-10 ~ 09-14 之间 V4 Pro 请求仍按 V4 Pro
439
+ * 刊例计费(v8 行按 Flash 价折算,低估);bump 全量重折。同时收录官方新规范名
440
+ * deepseek-flash → flash。
437
441
  */
438
- export declare const FOLD_VERSION = 9;
442
+ export declare const FOLD_VERSION = 10;
439
443
  /**
440
444
  * 一次性账本迁移:id 唯一,apply 在加载边界对原始文档执行,已应用过的跳过。
441
445
  * 未来账本/schema 字段变更(重命名、拆桶、语义调整)时,在此追加一条迁移并
@@ -117,8 +117,17 @@ export declare const WEEKEND_OFFPEAK_START_MS: number;
117
117
  * 1/0.02/4(峰 = 谷 × 2)。目录条目写现行(新)价;分界前的历史事件由
118
118
  * {@link computeCostAt} 按 {@link FLASH_REPRICED_OFFPEAK} 回算旧价,与
119
119
  * {@link PEAK_ERA_START_MS} 同一「按事件时刻分段适用规则」口径。
120
+ * pro 例外:V4 Pro 的路由计费分界是 {@link PRO_OFFLINE_MS}(官方把原定
121
+ * 09-10 的路由时点推迟到 09-14 12:00),不在本分界切换。
120
122
  */
121
123
  export declare const FLASH_REPRICE_MS: number;
124
+ /**
125
+ * V4 Pro 下线路由分界(UTC 2026-09-14T04:00:00Z,即北京时间 2026-09-14
126
+ * 12:00):官方价目页注释明确,此后至 V4.1 Pro 上线前,`deepseek-v4-pro`
127
+ * 的请求全部路由至 V4.1 Flash 并按其单价计费——此前的请求仍按 V4 Pro
128
+ * 峰谷刊例计费(官方原定 09-10 路由,后推迟到 09-14)。
129
+ */
130
+ export declare const PRO_OFFLINE_MS: number;
122
131
  /** 计费时段档位:高峰 / 空闲(官方 DeepSeek 刊例价:高峰 = 空闲 × 2)。 */
123
132
  export type PriceTierId = 'peak' | 'offPeak';
124
133
  /** 成本显示币种:人民币(国内模型直价)/ 美元(国外模型直价或换算显示)。 */
@@ -264,6 +273,11 @@ export interface ModelEntry {
264
273
  uncatalogued?: boolean;
265
274
  /** 该条目当前按用户自定义单价计价(设置面板可维护);费率表标注「自定义」。 */
266
275
  userPriced?: boolean;
276
+ /**
277
+ * 厂商已下线的模型(请求由继任型号服务、按继任单价计):不进费率表面板,
278
+ * 目录条目与历史回算保留——存量用量仍按原键计价与显示,删条目会破坏历史计算。
279
+ */
280
+ retired?: boolean;
267
281
  }
268
282
  export declare const MODEL_CATALOG: readonly ModelEntry[];
269
283
  /**
@@ -319,7 +333,9 @@ export declare function applyPromo(entry: ModelEntry, nowMs: number): ModelEntry
319
333
  * 会把费率表撑爆;它们只作为目录外模型的计价回退源(见 {@link livePriceOf} /
320
334
  * {@link modelOf})。探活模型在此逐个对价:内置已有的跳过去重;目录外但
321
335
  * models.dev 有价的按归一化 id 复用其 USD 价;两者皆无的标 `uncatalogued`。
322
- * 内置条目按 nowMs 折算限时促销(生效中的条目显示折后单价,过期自动恢复刊例价)。
336
+ * 内置条目按 nowMs 折算限时促销(生效中的条目显示折后单价,过期自动恢复刊例价),
337
+ * 应用路由分界期的现行价覆盖(V4 Pro 见 {@link applyRoutingDisplay}),并滤除
338
+ * 已下线条目(retired:官方下线的型号不进面板,目录与历史回算保留)。
323
339
  * @param nowMs - 促销判定时刻;缺省当前时刻。
324
340
  */
325
341
  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.1.14",
4
+ "version": "1.1.16",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },