@kenz1117/dsh-ui-usage-billing 1.8.5 → 1.8.7

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
@@ -529,8 +529,16 @@ function extraModelByKey() {
529
529
  * - 剥离组织前缀(`deepseek/deepseek-v4-flash` → `deepseek-v4-flash`);
530
530
  * - 剥离尾部纯数字段(`deepseek-v4-flash-202605` / `-0731` → `deepseek-v4-flash`,
531
531
  * 覆盖 TokenHub / 官方按日期滚动的快照 id);
532
+ * - 剥离冒号分段:中转站路由前缀(`cn:deepseek-v4.1-flash` → `deepseek-v4.1-flash`)与
533
+ * 变体后缀(`deepseek-v4.1-flash:fast` → `deepseek-v4.1-flash`)——中转站
534
+ * 常按线路给模型加前缀(cn:/us:),网关常加变体后缀(:free / :1017),
535
+ * 这些形态此前一律落「未收录」记 0(issue #125);
532
536
  * - 两者组合派生。目录键本身(如 `mistral-large-2512`、`command-a-03-2025`)
533
537
  * 在直接查就已命中,永不进入派生分支,不受剥段影响。
538
+ *
539
+ * 口径纪律:候选必须**原样**命中目录键(精确别名或归一化索引)才算数——剥段
540
+ * 只是找同一模型的另一种写法,不做「相近即认」的模糊猜测;剥完仍未命中就
541
+ * 保持原 id(回退 other,不计费)。
534
542
  */
535
543
  function derivedKeyCandidates(id) {
536
544
  const out = [];
@@ -552,6 +560,19 @@ function derivedKeyCandidates(id) {
552
560
  push(bare);
553
561
  stripTrailingDigits(bare);
554
562
  }
563
+ const segments = id.split(/[::]/u);
564
+ if (segments.length > 1) {
565
+ for (let i = 1; i < segments.length; i += 1) {
566
+ const tail = segments.slice(i).join(":");
567
+ push(tail);
568
+ stripTrailingDigits(tail);
569
+ }
570
+ for (let i = 0; i < segments.length - 1; i += 1) {
571
+ const head = segments.slice(i, segments.length - 1).join(":");
572
+ push(head);
573
+ stripTrailingDigits(head);
574
+ }
575
+ }
555
576
  stripTrailingDigits(id);
556
577
  return out;
557
578
  }
@@ -823,6 +844,18 @@ function formatTokens(value) {
823
844
  * 价源 = 腾讯云 TokenHub「模型价格」页(2026-11-04 更新)的官方 CN 价。
824
845
  * Hy4 preview 条目与其价格一律不动——同 id 不同模型的收录不构成调价。
825
846
  *
847
+ * 2026-11-16 扩容:补录腾讯混元 TokenHub 新上架的 **Hy4 flash**(官方 id
848
+ * `hy4-flash`,刊例价 ¥0.5 / ¥0.02(缓存命中)/ ¥2 每百万 token;官方价目页
849
+ * 2026-11-16 更新)。价源 = 腾讯云 TokenHub「模型价格」页的官方 CN 价
850
+ * (models.dev 实时目录尚无该模型条目,国内厂商按官方 CN 价优先的价源口径取
851
+ * 官方价,不做 USD 折算)。官方同期挂出限时折扣:**自该说明发布之日起至
852
+ * 2026-11-30 12:00:00(北京时间)按目录价格的 50% 结算** —— 刊例价留在 price
853
+ * 表,折扣按 promo 建模(只在计价/显示出口折算)。折扣起点取官方价目页
854
+ * 「最近更新时间」2026-11-16 12:15:30(北京时间)——这是本仓能取证的该说明上线
855
+ * 时刻,官方未给出更早的明确日期,故不向前追溯(promo 起点规则同 Hy4)。
856
+ * 本批只加新条目:既有 Hy4 / Hy4 preview 条目的价格与折扣窗口一律不动
857
+ * (本次官方价目页上 Hy4 仍是 ¥6/¥0.3/¥18,与目录现状逐字一致,不构成调价)。
858
+ *
826
859
  * Time-of-day billing (peak/off-peak) is now real: DeepSeek V4 officially
827
860
  * splits peak (09:00-12:00 / 14:00-18:00 Beijing) at 2x the off-peak rate
828
861
  * from 2026-08-17, and Gemini's Flex tier discounts spare-capacity traffic.
@@ -1637,6 +1670,24 @@ const BUILTIN_MODEL_CATALOG = [
1637
1670
  note: "限时 5 折至 2026-12-31"
1638
1671
  }
1639
1672
  },
1673
+ {
1674
+ key: "hunyuan-hy4-flash",
1675
+ name: "混元 Hy4 flash",
1676
+ provider: "腾讯混元",
1677
+ colorVar: "dsw-static-amber-400",
1678
+ price: {
1679
+ currency: "CNY",
1680
+ input: .5,
1681
+ cacheHit: .02,
1682
+ output: 2
1683
+ },
1684
+ promo: {
1685
+ factor: .5,
1686
+ startsAtMs: Date.UTC(2026, 10, 16, 4, 15, 30),
1687
+ endsAtMs: Date.UTC(2026, 10, 30, 4, 0, 0),
1688
+ note: "限时 5 折至 2026-11-30 12:00"
1689
+ }
1690
+ },
1640
1691
  {
1641
1692
  key: "hy-mt2-pro",
1642
1693
  name: "混元 MT2-Pro",
@@ -4116,6 +4167,7 @@ const BUILTIN_MODEL_KEY_ALIASES = {
4116
4167
  "deepseek-v4-flash": "flash",
4117
4168
  "deepseek-v4-flash-vision-exp": "flash-vision-exp",
4118
4169
  "deepseek-v4.1-flash": "flash",
4170
+ "deepseek-v4.1": "flash",
4119
4171
  "deepseek-v4.1-flash-expires-on-0910": "flash",
4120
4172
  "deepseek-flash": "flash",
4121
4173
  "deepseek-v4.1-flash-1017": "flash",
@@ -4177,6 +4229,8 @@ const BUILTIN_MODEL_KEY_ALIASES = {
4177
4229
  "hunyuan-hy4": "hunyuan-hy4",
4178
4230
  "hy4-preview": "hunyuan-hy4-preview",
4179
4231
  "hunyuan-hy4-preview": "hunyuan-hy4-preview",
4232
+ "hy4-flash": "hunyuan-hy4-flash",
4233
+ "hunyuan-hy4-flash": "hunyuan-hy4-flash",
4180
4234
  "longcat-2.0": "longcat-2.0",
4181
4235
  "longcat-2": "longcat-2.0",
4182
4236
  "minicpm-v-4.5": "minicpm-v-4.5",
@@ -5939,6 +5993,7 @@ function createUsageAggregator(persistence, options = {}) {
5939
5993
  byDayModels: toModelDayRecord(byDayModels),
5940
5994
  ...byDayModelsSite.size === 0 ? {} : { byDayModelsSite: toModelDaySiteRecord(byDayModelsSite) },
5941
5995
  bySession: sessionRows.slice(0, 100),
5996
+ bySessionTotal: sessionRows.length,
5942
5997
  byTurn: turnRows.slice(0, 200),
5943
5998
  byWorkspace: workspaces.slice(0, 100),
5944
5999
  ...byTier.size === 0 ? {} : { byTier: {
@@ -324,6 +324,12 @@ export interface UsageStatsDocument {
324
324
  byTool?: Record<string, number>;
325
325
  /** 会话明细:按费用倒序,封顶 {@link SESSION_ROW_LIMIT} 行;旧快照可能缺失。 */
326
326
  bySession: SessionUsageRow[];
327
+ /**
328
+ * 会话总数(未封顶):`bySession` 只带花费前 {@link SESSION_ROW_LIMIT} 行,
329
+ * 真实总数此前从未下发——会话数超过封顶时面板只能说「共 100 个会话」,是错的。
330
+ * 旧快照缺该字段,客户端回退按明细行数。
331
+ */
332
+ bySessionTotal?: number;
327
333
  /** 每轮费用明细:按起始时间倒序,封顶 {@link TURN_ROW_LIMIT} 行;旧快照可能缺失。 */
328
334
  byTurn?: TurnUsageRow[];
329
335
  /** 工作区聚合:按 cwd 末级目录归并,按费用倒序;旧快照可能缺失。 */
@@ -71,6 +71,8 @@ export declare function TokenPanel(props: {
71
71
  models?: readonly TrendSeriesModel[];
72
72
  /** 金额格式化(跟随仪表盘币种切换):费用构成区块展示用。 */
73
73
  money: (cny: number) => string;
74
+ /** 通道桶 key → 通道显示名(issue #126:模型行标注提供方)。 */
75
+ channelName?: (siteKey: string) => string;
74
76
  t: (key: UsageBillingKey) => string;
75
77
  }): React.ReactNode;
76
78
  export {};
@@ -15,6 +15,15 @@ export declare const STATS_REFRESH_INTERVAL_MS = 30000;
15
15
  /** 弹窗关闭后的统计刷新间隔(毫秒):侧栏触发器只需大致最新值,降到 5 分钟
16
16
  * 省宿主聚合(每轮都是折叠 + 五个端点的串行响应)。 */
17
17
  export declare const STATS_REFRESH_CLOSED_MS = 300000;
18
+ /**
19
+ * 插件自有 DOM 根容器标记(issue #124):动效压制规则只在本插件根容器内生效。
20
+ *
21
+ * 此前「动效强度」开关把 data-motion 写在 <html> 上,配 `*` 通配符 + !important,
22
+ * 会把宿主与第三方插件的全部动画一起压平(报告者实测右键菜单动画消失)。改为
23
+ * 给每个自有根容器挂这个类,压制规则收进根容器内,宿主与其他插件不受影响。
24
+ * 新增挂载点时记得一并打标——漏标只会让该处动画不再被压制,不会外溢。
25
+ */
26
+ export declare const BILLING_ROOT_CLASS = "dsh-billing-root";
18
27
  /** Empty snapshot: shown before (or without) real host data — zeros, never fabricated samples. */
19
28
  export declare const EMPTY_STATS: UsageStats;
20
29
  /**
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 通道可见性(issue #126 需求):按**通道桶**隐藏部分提供商 / 通道。
3
+ *
4
+ * 报告者场景:通道一多(官方、直连、几个中转、未知路由)时账单列表很长,希望
5
+ * 在设置里勾掉不常看的几个,只留常看的通道。
6
+ *
7
+ * 口径与边界(写死在这里,避免各视图各算一套):
8
+ * - **过滤粒度 = 通道桶 key**(`site:<origin>` / `direct:<provider>` / `unknown`),
9
+ * 不是显示名——显示名随界面语言变(中英),桶 key 稳定,偏好能跨语言沿用。
10
+ * - **只扣可归属的用量**:隐藏通道的用量从 total / byDay / byDayModels /
11
+ * byModel / bySite / byDayModelsSite 中扣除;**无法归属通道的用量保留**
12
+ * (旧格式会话的账本行没有三维维度,无从判断属于哪个通道——宁可多算,
13
+ * 不可静默丢数)。
14
+ * - **无通道维度的维度保持全量口径**:会话 / 工具 / 角色 / 工作区 / 性能 /
15
+ * 峰谷等没有通道切分,隐藏通道不影响它们;界面需注明这一口径差。
16
+ * - 三维数据缺失(旧快照)时**整体不生效**:没有可归属数据就无从过滤,
17
+ * 此时按未过滤渲染,而不是把用量显示成 0。
18
+ */
19
+ import type { UsageStats } from './types.ts';
20
+ /** 一个通道桶的用量汇总(全量日期)。 */
21
+ export interface ChannelUsage {
22
+ /** 通道桶 key(`site:<origin>` / `direct:<provider>` / `unknown`)。 */
23
+ siteKey: string;
24
+ calls: number;
25
+ input: number;
26
+ output: number;
27
+ cacheHit: number;
28
+ cacheMiss: number;
29
+ cost: number;
30
+ }
31
+ /**
32
+ * 汇总各通道桶的用量(全量日期,按费用降序;同费用按桶 key 稳定排序)。
33
+ * @param stats - usage-stats 文档(读 byDayModelsSite 三维格)。
34
+ * @returns 每个通道桶一行;无三维数据时返回空数组。
35
+ */
36
+ export declare function channelUsageOf(stats: UsageStats): readonly ChannelUsage[];
37
+ /**
38
+ * 按显示名归并的通道分组(同名多桶合并:直连与官方同名的两个桶归一行)。
39
+ */
40
+ export interface ChannelGroup {
41
+ /** 显示名(界面语言下的通道名;未知路由由渲染层兜底文案)。 */
42
+ name: string;
43
+ /** 组内全部通道桶 key —— 隐藏任一即整组隐藏(用户看到的是「这个名字」)。 */
44
+ siteKeys: readonly string[];
45
+ calls: number;
46
+ /** 组内 token 合计(输入 + 输出)。 */
47
+ tokens: number;
48
+ cost: number;
49
+ }
50
+ /**
51
+ * 把通道桶按显示名归并成组(同名多桶合并),按费用降序。
52
+ * @param rows - 通道桶用量(channelUsageOf 的产物)。
53
+ * @param nameOf - 桶 key → 显示名的解析函数(界面语言相关)。
54
+ * @returns 通道分组列表。
55
+ */
56
+ export declare function groupChannelsByName(rows: readonly ChannelUsage[], nameOf: (siteKey: string) => string): readonly ChannelGroup[];
57
+ /**
58
+ * 按隐藏通道过滤统计文档。
59
+ *
60
+ * 扣除隐藏通道在 total / byDay / byDayModels / byModel / bySite /
61
+ * byDayModelsSite 中的用量;无通道维度的维度(会话 / 工具 / 角色 / 工作区 /
62
+ * 性能 / 峰谷 / reasoning / 官方口径)保持全量。三维数据缺失时整体原样返回。
63
+ * @param stats - 原始统计文档。
64
+ * @param hidden - 隐藏的通道桶 key 集合。
65
+ * @returns 过滤后的统计文档(未命中任何隐藏通道时返回原对象引用)。
66
+ */
67
+ export declare function filterStatsByChannels(stats: UsageStats, hidden: ReadonlySet<string>): UsageStats;
68
+ //# sourceMappingURL=channel-visibility.d.ts.map
@@ -190,6 +190,12 @@ export interface UsageStats {
190
190
  lowBalanceThreshold?: number;
191
191
  /** 会话明细(按费用倒序,服务端已封顶);旧快照可能缺失。 */
192
192
  bySession?: readonly SessionBillingRow[];
193
+ /**
194
+ * 会话总数(未封顶):`bySession` 只带花费前 N 行,真实总数此前从未下发——
195
+ * 会话数超过封顶时面板只能说「共 100 个会话」,是错的。缺省回退按明细行数
196
+ * (旧快照没有该字段)。
197
+ */
198
+ bySessionTotal?: number;
193
199
  total: {
194
200
  calls: number;
195
201
  input: number;
@@ -1,5 +1,5 @@
1
1
  /** Locale dictionaries for the usage billing surface. */
2
- export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
2
+ export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
3
3
  export declare const NS = "usageBilling";
4
4
  export declare const zh: Record<UsageBillingKey, string>;
5
5
  export declare const en: Record<UsageBillingKey, string>;
@@ -431,8 +431,6 @@ export declare function applyPromo(entry: ModelEntry, nowMs: number): ModelEntry
431
431
  * @param nowMs - 促销判定时刻;缺省当前时刻。
432
432
  */
433
433
  export declare function catalogEntries(nowMs?: number): readonly ModelEntry[];
434
- /** Resolve a price-table row by its CSS variable name (theme token or fallback color). */
435
- export declare function resolveToken(name: string): string;
436
434
  /**
437
435
  * Estimate the CNY cost of one model's token usage, mixing the peak and
438
436
  * off-peak bands by the given peak share (flat-priced models cost the same in
@@ -15,8 +15,6 @@ type ProviderLang = 'zh' | 'en';
15
15
  * @returns 本地化后的显示名。
16
16
  */
17
17
  export declare function localizeProviderName(name: string, lang: ProviderLang): string;
18
- /** 判断一个厂商显示名是否包含中文(用于测试/守卫:保证映射覆盖完整)。 */
19
- export declare function hasCjk(name: string): boolean;
20
18
  /**
21
19
  * 站点桶 key(`site:<origin>` / `direct:<provider>` / `unknown`)→ 通道显示名。
22
20
  * @param siteKey - 聚合文档 bySite 的桶 key。
@@ -5,6 +5,9 @@
5
5
  * maximum. Turns flagged by {@link flagAnomalies} get a warning outline and a
6
6
  * corner marker; hover shows the turn's model, cost, and window time. Styling
7
7
  * lives in the billing CSS module (`.rounds*`).
8
+ *
9
+ * 入参按服务端口径是**倒序**(`byTurn` 按 startedAt 倒序下发,最新在前),
10
+ * 组件内部排成升序再取末尾 N 轮——展示的是「最新 N 轮、最新在右」。
8
11
  */
9
12
  import type { AnomalyFlag } from './anomaly.ts';
10
13
  import { type CostCurrency } from './pricing.ts';
@@ -23,7 +26,7 @@ export interface RoundChartRow {
23
26
  }
24
27
  /**
25
28
  * Render the per-turn cost bars.
26
- * @param props.rounds - turns, most recent last (ascending startedAt); oldest beyond the limit are dropped.
29
+ * @param props.rounds - 逐轮行(服务端按 startedAt 倒序下发;组件内部排升序后取最新 N 轮)。
27
30
  * @param props.flags - spike flags matched by sessionId+turn.
28
31
  * @param props.currency - display currency for the amount labels.
29
32
  * @param props.t - locale function for the model label.
@@ -109,6 +109,25 @@ export declare const SITE_LIST_STORAGE_KEY = "dsh.ui-usage-billing.sites";
109
109
  export declare function loadSiteListPrefs(): SiteListPrefs;
110
110
  /** 写入站点列表偏好。失败静默(展示偏好非关键)。 */
111
111
  export declare function saveSiteListPrefs(prefs: SiteListPrefs): void;
112
+ /**
113
+ * 通道可见性偏好(issue #126 需求):隐藏部分提供商 / 通道。
114
+ * 纯 client 偏好,存 localStorage(不依赖 node 半区接口/设置 schema)。
115
+ *
116
+ * 存**通道桶 key**(`site:<origin>` / `direct:<provider>` / `unknown`)而不是
117
+ * 显示名——显示名随界面语言变(中英),桶 key 稳定,偏好能跨语言沿用。
118
+ */
119
+ export interface ChannelVisibilityPrefs {
120
+ /** 隐藏的通道桶 key 列表;空 = 全部显示。 */
121
+ hidden: readonly string[];
122
+ }
123
+ /** 默认通道可见性偏好:全部显示(保持历史行为)。 */
124
+ export declare const DEFAULT_CHANNEL_VISIBILITY_PREFS: ChannelVisibilityPrefs;
125
+ /** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
126
+ export declare const CHANNEL_VISIBILITY_STORAGE_KEY = "dsh.ui-usage-billing.channels";
127
+ /** 读取通道可见性偏好(含损坏/缺失回退到默认)。仅在浏览器半区调用。 */
128
+ export declare function loadChannelVisibilityPrefs(): ChannelVisibilityPrefs;
129
+ /** 写入通道可见性偏好。失败静默(展示偏好非关键)。 */
130
+ export declare function saveChannelVisibilityPrefs(prefs: ChannelVisibilityPrefs): void;
112
131
  /**
113
132
  * 即时代费条(平价消耗胶囊,composer dock 的 LiveCostBar)的显示偏好。
114
133
  * 纯 client 偏好,存 localStorage(不依赖 node 半区接口/设置 schema);
@@ -234,8 +253,9 @@ export declare function loadPerfViewPrefs(): PerfViewPrefs;
234
253
  export declare function savePerfViewPrefs(prefs: PerfViewPrefs): void;
235
254
  /**
236
255
  * 显示密度档位(v1.5 新增)。紧凑档减小行高/字号/内边距,舒适档加大;
237
- * 默认档保持历史感官。client 端写到 `documentElement.dataset.density`,
238
- * CSS `[data-density="..."]` 选择器派生 `--ds-density-*` 变量。
256
+ * 默认档保持历史感官。client 端写到 `documentElement.dataset.dshBillingDensity`
257
+ * (= `data-dsh-billing-density`,命名空间化防同名属性互相覆盖,issue #124),
258
+ * CSS `[data-dsh-billing-density="..."]` 选择器派生 `--ds-density-*` 变量。
239
259
  */
240
260
  export type DensityPref = 'compact' | 'default' | 'comfortable';
241
261
  /** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
@@ -250,9 +270,11 @@ export declare function loadDensity(): DensityPref;
250
270
  * 失败静默(展示偏好非关键)。 */
251
271
  export declare function saveDensity(density: DensityPref): void;
252
272
  /**
253
- * 动效强度档位(v1.5 新增)。`off` 冻结全部 transition+animation,
254
- * `subtle` 抑制 240ms 以上的入场/计数动画但保留 160ms 微交互,
255
- * `rich` 即默认(全开)。写到 `documentElement.dataset.motion`。
273
+ * 动效强度档位(v1.5 新增)。`off` 冻结本插件内的全部 transition+animation,
274
+ * `subtle` 保留 transition 微交互、把关键帧动画压成瞬时,`rich` 即默认(全开)。
275
+ * 写到 `documentElement.dataset.dshBillingMotion`(= `data-dsh-billing-motion`),
276
+ * 且压制规则只作用在本插件根容器 `.dsh-billing-root` 之内(issue #124:
277
+ * 此前通用属性 + 通配符会把宿主与第三方插件的动画一起压平)。
256
278
  */
257
279
  export type MotionPref = 'off' | 'subtle' | 'rich';
258
280
  /** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
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.8.5",
4
+ "version": "1.8.7",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "deepseek",