@kenz1117/dsh-ui-usage-billing 1.8.3-alpha.2 → 1.8.3-alpha.21

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.
Files changed (52) hide show
  1. package/README.en.md +30 -12
  2. package/README.md +52 -23
  3. package/lib/client.js +5 -5
  4. package/lib/index.js +2566 -407
  5. package/lib/types/aggregate.d.ts +46 -14
  6. package/lib/types/balance.d.ts +23 -2
  7. package/lib/types/builtin-catalog.d.ts +5 -0
  8. package/lib/types/client/PeakScheduleEditor.d.ts +9 -0
  9. package/lib/types/client/TaskQueuePanel.d.ts +5 -1
  10. package/lib/types/client/TokenPanel.d.ts +2 -0
  11. package/lib/types/client/UsageBilling.d.ts +2 -0
  12. package/lib/types/client/UsageBillingMainPanel.d.ts +7 -0
  13. package/lib/types/client/UsageBillingPanelIcon.d.ts +5 -0
  14. package/lib/types/client/api/balance.d.ts +1 -1
  15. package/lib/types/client/api/task-queue.d.ts +4 -0
  16. package/lib/types/client/api/usage-stats.d.ts +16 -2
  17. package/lib/types/client/constants.d.ts +9 -0
  18. package/lib/types/client/domain/channel-visibility.d.ts +68 -0
  19. package/lib/types/client/domain/floating-model.d.ts +31 -0
  20. package/lib/types/client/domain/types.d.ts +37 -1
  21. package/lib/types/client/footer-lane.d.ts +114 -0
  22. package/lib/types/client/live-cost.d.ts +10 -3
  23. package/lib/types/client/locales.d.ts +2 -1
  24. package/lib/types/client/panel-capability.d.ts +12 -0
  25. package/lib/types/client/peak-alert.d.ts +2 -1
  26. package/lib/types/client/peak-schedule-locales.d.ts +48 -0
  27. package/lib/types/client/price-drafts.d.ts +19 -0
  28. package/lib/types/client/price-picker.d.ts +17 -0
  29. package/lib/types/client/pricing.d.ts +22 -12
  30. package/lib/types/client/provider-display.d.ts +0 -2
  31. package/lib/types/client/queue-eligibility.d.ts +45 -0
  32. package/lib/types/client/round-chart.d.ts +5 -1
  33. package/lib/types/client/scheduled-band.d.ts +23 -0
  34. package/lib/types/client/task-queue-quick.d.ts +1 -1
  35. package/lib/types/client/usage-billing-settings.d.ts +62 -9
  36. package/lib/types/client/usage-command.d.ts +10 -5
  37. package/lib/types/config.d.ts +2 -0
  38. package/lib/types/guard.d.ts +30 -3
  39. package/lib/types/peak-ledger.d.ts +21 -0
  40. package/lib/types/peak-schedule-history.d.ts +7 -0
  41. package/lib/types/peak-schedule-models.d.ts +21 -0
  42. package/lib/types/peak-schedule-store.d.ts +10 -0
  43. package/lib/types/peak-schedule.d.ts +67 -0
  44. package/lib/types/pricing-shared.d.ts +81 -1
  45. package/lib/types/reconcile.d.ts +11 -2
  46. package/lib/types/routes/balance.d.ts +6 -3
  47. package/lib/types/routes/peak-schedule.d.ts +12 -0
  48. package/lib/types/routes/pricing-models.d.ts +11 -0
  49. package/lib/types/task-queue-band.d.ts +80 -0
  50. package/lib/types/task-queue-shared.d.ts +57 -0
  51. package/lib/types/task-queue.d.ts +110 -3
  52. package/package.json +75 -64
@@ -0,0 +1,114 @@
1
+ /**
2
+ * 侧栏 footer 同槽占位测量(社区约定 §20.4 / §25「卡片型占用者」)。
3
+ *
4
+ * 背景:宿主的 `sidebar.footer.action` 是一个**无 wrap 的横向 flex 行**
5
+ * (`.footerActions{display:flex}`,无 gap/padding)。本插件的触发卡是**宽卡**
6
+ * (`width:100%`),同槽有别的插件时会把它们推到面板右边界之外——用户看到的
7
+ * 现象是「别的插件像没加载」(社区 issue #237)。纵向栈(手机端侧栏浮层)
8
+ * 下宽卡则会把同列的其它入口挤到下方(§25.6)。
9
+ *
10
+ * 宿主**不**向占位者暴露同槽邻居信息:owner props 只有 `{ wide }`,register
11
+ * 选项里也没有「占用者」字段(对比 `sidebar.panellist.actions` 才带 entries)。
12
+ * 因此按社区约定 §20.4 的测量算法从 DOM 反推:
13
+ * - 向上找到「真正的行」:跳过 `display:contents` 的槽位外壳;
14
+ * - 数同排的可见占位者(展开 display:contents 的子项,排除自己与不可见元素);
15
+ * - 读行的 `flex-direction`(`column` = 纵向栈)。
16
+ *
17
+ * 判定分四档(issue #148;前两档沿用社区约定 §25 方案 A):
18
+ * - `full`(用户显式选择):**无条件宽卡**,不做邻居 / 容量判断——用户的显式
19
+ * 意图优先于自动收窄;代价(同槽邻居被挤压)由触发卡悬停提示写明;
20
+ * - `compact`:无条件 36×36 图标钮;
21
+ * - `auto`(默认):按**座位容量**决定(社区约定 §20 的容量公式)——横向行用
22
+ * 「行宽 − 容器内边距 − 邻居占位」算出留给宽卡的空间,放得下出宽卡、放不下
23
+ * 收成图标钮;纵向座位仍按 §25.6:「整行宽座」保留宽卡,窄竖条收成图标钮
24
+ * (issue #140)。
25
+ *
26
+ * 宽度测不到时(未布局 / 座位不可见)**fail-closed 先收窄**,等 `ResizeObserver`
27
+ * 拿到真实尺寸再切回宽卡——宁可短暂多一个图标钮,也不要先把邻居挤出面板。
28
+ *
29
+ * 本模块只做测量与判定,不碰宿主容器(不得注入 `flex-wrap` /
30
+ * `flex-direction` / `order`,见 §25 硬规则 2)。
31
+ */
32
+ import type { BillingCardMode } from './usage-billing-settings.ts';
33
+ /** 同槽占位事实。 */
34
+ export interface FooterLaneFacts {
35
+ /** 真正的行容器(最近的 flex 祖先);找不到时为 null(此时没有横向挤占问题)。 */
36
+ row: HTMLElement | null;
37
+ /** 行是纵向列(手机端侧栏浮层 / 皮肤改写的竖座)而非横向行。 */
38
+ stacked: boolean;
39
+ /**
40
+ * 纵向座位是「整行宽座」:客人被拉满整行宽度(`align-items` 拉伸)且座位
41
+ * 放得下宽卡。第三方皮肤(如 dsh-islands-ui 的工作区底部宽座)这样声明
42
+ * 「这里要放得下宽插件」;手机端的窄竖条不是(issue #140 现象二)。
43
+ */
44
+ wideSeat: boolean;
45
+ /** 同行可见占位者数量(不含自己)。 */
46
+ neighbors: number;
47
+ }
48
+ /** 触发卡形态:宽卡(独占一行)/ 图标钮(与邻居共存)。 */
49
+ export type TriggerForm = 'card' | 'icon';
50
+ /** 观察句柄。 */
51
+ export interface FooterLaneWatch {
52
+ /** 停止观察。 */
53
+ dispose(): void;
54
+ }
55
+ /**
56
+ * 测量同槽占位事实。
57
+ * @param self - 本插件在行内的元素(触发卡外壳)。
58
+ * @returns 行容器 / 是否纵向栈 / 是否宽座 / 邻居数量。
59
+ */
60
+ export declare function measureFooterLane(self: HTMLElement): FooterLaneFacts;
61
+ /**
62
+ * 横向座位放不放得下宽卡(社区约定 §20 的容量公式)。
63
+ *
64
+ * `available = 行宽 − 容器内边距 − 邻居数 × (占位 112 + 间距 4)`,
65
+ * `available ≥ 141` 才放得下宽卡(卡面在 ≤140px 时只剩仪表图标)。
66
+ * 等价于「行宽 ≥ 157 + 邻居数 × 116」:0 邻居 → 157px、1 邻居 → 273px、
67
+ * 2 邻居 → 389px、3 邻居 → 505px。
68
+ *
69
+ * 宽度测不到(未布局 / 座位不可见)时 **fail-closed 返回 false**:宁可先收成
70
+ * 图标钮,也不要先把邻居挤出面板;`ResizeObserver` 拿到真实尺寸后会重算并切回。
71
+ * 刻意不用 `offsetParent` 判可见性——`position:fixed` 的行 `offsetParent` 为
72
+ * null,但它是**有**布局盒的(宽度可测),不该被误判成测不到。
73
+ *
74
+ * @param facts - 同槽占位事实。
75
+ * @returns 放得下宽卡返回 true。
76
+ */
77
+ export declare function fitsWideCard(facts: FooterLaneFacts): boolean;
78
+ /**
79
+ * 由占位事实 + 用户选择的形态档判定触发卡形态。
80
+ *
81
+ * - `full`:**无条件宽卡**——用户的显式意图优先于自动收窄(issue #148);
82
+ * 代价(同槽邻居被挤压)由调用方用 `facts.neighbors` 写进悬停提示;
83
+ * - `compact`:无条件图标钮;
84
+ * - `auto`(默认):按座位容量判断——横向行用 §20 容量公式,纵向座位沿用
85
+ * §25.6(「整行宽座」保留宽卡,窄竖条收成图标钮);
86
+ * - `hidden`:入口整体不渲染,形态判定无意义(调用方提前返回 null),这里按
87
+ * `auto` 处理。
88
+ *
89
+ * @param facts - 同槽占位事实。
90
+ * @param mode - 侧栏入口形态档。
91
+ * @returns `icon` = 收成 36×36 图标钮;`card` = 保持宽卡。
92
+ */
93
+ export declare function resolveTriggerForm(facts: FooterLaneFacts, mode: BillingCardMode): TriggerForm;
94
+ /** 同槽占位状态:形态 + 邻居数(邻居数用于「强制宽卡挤压了几个」的提示)。 */
95
+ export interface FooterLaneState {
96
+ /** 触发卡形态(宽卡 / 图标钮)。 */
97
+ form: TriggerForm;
98
+ /** 同行可见占位者数量(不含自己)。 */
99
+ neighbors: number;
100
+ }
101
+ /**
102
+ * 观察同槽占位变化,形态变化时回调。
103
+ *
104
+ * 三路触发源缺一不可(§20.4):`ResizeObserver`(侧栏拖拽改宽 / 折叠)、
105
+ * `MutationObserver`(邻居插件注册、卸载、隐藏)、`window` `resize`。
106
+ * 只在**形态真的变了**时回调,避免自触发成环。
107
+ *
108
+ * @param self - 本插件在行内的元素。
109
+ * @param mode - 侧栏入口形态档(`full` / `compact` 会在判定里直接短路)。
110
+ * @param onState - 形态 / 邻居数变化回调。
111
+ * @returns 观察句柄。
112
+ */
113
+ export declare function watchFooterLane(self: HTMLElement, mode: BillingCardMode, onState: (state: FooterLaneState) => void): FooterLaneWatch;
114
+ //# sourceMappingURL=footer-lane.d.ts.map
@@ -19,6 +19,8 @@
19
19
  * visible without opening the dashboard.
20
20
  */
21
21
  import type { SessionId } from '@deepseek-ai/dsh-session/types';
22
+ import type { PeakSchedule } from '../peak-schedule.ts';
23
+ import { type ScheduledTurn } from './scheduled-band.ts';
22
24
  import type { LiveCostBarPrefs } from './usage-billing-settings.ts';
23
25
  import type { UsageBillingKey } from './locales.ts';
24
26
  /** The usage-stats shape the composer bar needs (a thin slice, not the whole doc). */
@@ -28,12 +30,12 @@ export interface LiveStats {
28
30
  cost: number;
29
31
  subCost?: number;
30
32
  }[];
31
- byTurn?: readonly {
33
+ byTurn?: readonly (ScheduledTurn & {
32
34
  sessionId: string;
33
35
  turn: number;
34
- model?: string;
35
36
  cost: number;
36
- }[];
37
+ })[];
38
+ peakSchedule?: PeakSchedule;
37
39
  }
38
40
  /** 订阅额度的薄切片(/api/billing/subscriptions 响应的行)。 */
39
41
  export interface QuotaSlice {
@@ -89,6 +91,11 @@ export declare function lowQuotaChips(quotas: readonly QuotaSlice[], threshold?:
89
91
  * @returns 该会话最近一轮的归因模型键;无轮次或轮行未带模型时 undefined。
90
92
  */
91
93
  export declare function sessionModelOf(stats: LiveStats | null, sessionId: string | undefined): string | undefined;
94
+ export declare function sessionTurnOf(stats: LiveStats | null, sessionId: string | undefined): (ScheduledTurn & {
95
+ sessionId: string;
96
+ turn: number;
97
+ cost: number;
98
+ }) | undefined;
92
99
  /** 胶囊位置偏好(设置 Tab 三选)。 */
93
100
  type CapsulePosition = LiveCostBarPrefs['position'];
94
101
  /** 胶囊条的宿主座位:above=input.dock(卡片上方);below=composer.dock(卡片下方)。 */
@@ -1,5 +1,6 @@
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' | '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' | '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' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
2
+ import { peakZh } from './peak-schedule-locales.ts';
3
+ export type UsageBillingKey = keyof typeof peakZh | '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' | 'walletLogin' | 'walletPlatform' | 'walletInvalid' | 'walletNoService' | 'walletNoMetadata' | 'walletSignedOut' | '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' | 'displayPlacement' | 'displayPlacementFooter' | 'displayPlacementLeft' | 'displayPlacementBoth' | 'displayPlacementHint' | 'displayPlacementFallback' | 'cardMode' | 'cardModeAuto' | 'cardModeAutoHint' | 'cardModeFull' | 'cardModeFullHint' | 'cardModeFullSqueezeHint' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'shortcutOpenDashboard' | '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' | 'priceSaved' | 'userPriceEditIdentity' | 'pricePicker' | 'priceModelsPartial' | 'priceModelsPending' | 'priceModelDefault' | 'priceIncomplete' | 'priceUnpriced' | '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' | 'popBalanceUnavailable' | 'popQuotaUnavailable' | 'popSourceUnknown' | 'popPartialSource' | 'popMultipleSources' | 'popUnknownUnit' | 'popDirectLead' | 'popSubLead' | 'sourceEstimate' | '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' | 'queueSavingCash' | 'queueSavingQuota' | 'queueSavingSchedule' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queueNoWorkspace' | 'queueNoOfficialRoute' | 'queueNoOfficialModel' | 'queueNoScheduledModel' | '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' | 'quickQueueModelNotEligible' | 'quickQueueWorkspaceUnknown' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
3
4
  export declare const NS = "usageBilling";
4
5
  export declare const zh: Record<UsageBillingKey, string>;
5
6
  export declare const en: Record<UsageBillingKey, string>;
@@ -0,0 +1,12 @@
1
+ /** 左侧主面板双槽位(main + sidebar.panellist)的运行时能力(issue #144)。 */
2
+ export interface BillingPanelCapability {
3
+ /** 两个宿主槽位是否同时可用。 */
4
+ available: () => boolean;
5
+ /** 订阅能力变化;组件挂载时另读 available() 取初值。 */
6
+ subscribe: (listener: () => void) => () => void;
7
+ setMain: (present: boolean) => void;
8
+ setNavigation: (present: boolean) => void;
9
+ }
10
+ /** 只有双槽位同时存在才允许隐藏底部入口,避免单侧能力造成不可恢复的空白。 */
11
+ export declare function createBillingPanelCapability(): BillingPanelCapability;
12
+ //# sourceMappingURL=panel-capability.d.ts.map
@@ -6,6 +6,7 @@
6
6
  * (默认关闭,用户到面板设置开启);「同一切换点只提醒一次」由 budget store 的
7
7
  * `lastTierSwitchAt` 承担(与原系统通知共用一份去重,避免一条切换提醒弹两次)。
8
8
  */
9
+ import { type EffectiveRule } from './scheduled-band.ts';
9
10
  import { type PriceTierId, type RateChannel } from './pricing.ts';
10
11
  /** 提醒模式:只提醒进入峰时 / 只提醒进入平价 / 峰与谷都提醒。 */
11
12
  export type PeakAlertMode = 'peak' | 'offPeak' | 'both';
@@ -55,5 +56,5 @@ export declare function savePeakAlertConfig(config: PeakAlertConfig): void;
55
56
  * @param channel - 当前会话模型的计费通道;none 直接返回 null。
56
57
  * @returns 命中(含即将进入的档位、切换时刻与通道),否则 null。
57
58
  */
58
- export declare function computePeakAlert(nowMs: number, config: PeakAlertConfig, lastAlertedAt: number, channel: RateChannel): PeakAlertHit | null;
59
+ export declare function computePeakAlert(nowMs: number, config: PeakAlertConfig, lastAlertedAt: number, channel: RateChannel, rule?: EffectiveRule): PeakAlertHit | null;
59
60
  //# sourceMappingURL=peak-alert.d.ts.map
@@ -0,0 +1,48 @@
1
+ export declare const peakZh: {
2
+ psPartial: string;
3
+ psProspective: string;
4
+ psEffectiveFrom: string;
5
+ psUnavailableModel: string;
6
+ psInvalidRequest: string;
7
+ psInvalidResponse: string;
8
+ psDenied: string;
9
+ psUnavailable: string;
10
+ psLegacy: string;
11
+ psUnreadable: string;
12
+ psMalformedSchedule: string;
13
+ psMalformedRevision: string;
14
+ psMalformedRule: string;
15
+ psIneligible: string;
16
+ psDiscovery: string;
17
+ psClockConflict: string;
18
+ psAddHoliday: string;
19
+ psRemoveHoliday: string;
20
+ psTitle: string;
21
+ psModel: string;
22
+ psEmpty: string;
23
+ psConfigured: string;
24
+ psWindows: string;
25
+ psInherit: string;
26
+ psCustom: string;
27
+ psOff: string;
28
+ psDates: string;
29
+ psDaily: string;
30
+ psWeekdays: string;
31
+ psHolidays: string;
32
+ psNoHolidays: string;
33
+ psZone: string;
34
+ psOffset: string;
35
+ psClear: string;
36
+ psSave: string;
37
+ psSaved: string;
38
+ psDirty: string;
39
+ psRetry: string;
40
+ psLoading: string;
41
+ psLoadError: string;
42
+ psSaveError: string;
43
+ psBadWindows: string;
44
+ psBadHolidays: string;
45
+ psBadOffset: string;
46
+ };
47
+ export declare const peakEn: Record<keyof typeof peakZh, string>;
48
+ //# sourceMappingURL=peak-schedule-locales.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { type UserPrice, type UserPriceEntry } from './pricing.ts';
2
+ type DraftBand = Record<'input' | 'cacheHit' | 'output', string>;
3
+ export interface PriceDraft {
4
+ id: number;
5
+ key: string;
6
+ origin: string;
7
+ currency: 'CNY' | 'USD';
8
+ main: DraftBand;
9
+ off: DraftBand;
10
+ locked: boolean;
11
+ saved?: UserPriceEntry;
12
+ }
13
+ export declare function newPriceDraft(id: number, key?: string, origin?: string, price?: UserPrice): PriceDraft;
14
+ export declare function validPriceText(raw: string): boolean;
15
+ export declare function samePrice(a: UserPriceEntry | undefined, b: UserPriceEntry | undefined): boolean;
16
+ /** Keep a saved row's last committed identity and prices whenever its draft cannot be applied. */
17
+ export declare function planPriceSave(drafts: PriceDraft[]): (UserPriceEntry | undefined)[];
18
+ export {};
19
+ //# sourceMappingURL=price-drafts.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { PricingModel } from '../pricing-shared.ts';
2
+ import type { UsageStats } from './domain/types.ts';
3
+ /** Only the editor polls discovery. Refresh failures never reset edited rows. */
4
+ export declare function useConfiguredPrices(active: boolean): {
5
+ models: PricingModel[];
6
+ partial: boolean;
7
+ pending: boolean;
8
+ };
9
+ export declare function priceIdentity(key: string, origin?: string): string;
10
+ export declare function priceOptions(configured: readonly PricingModel[], stats: UsageStats): {
11
+ id: string;
12
+ key: string;
13
+ channel: string;
14
+ origin: string;
15
+ name: string;
16
+ }[];
17
+ //# sourceMappingURL=price-picker.d.ts.map
@@ -103,13 +103,8 @@ export declare function userPriceOf(key: string, origin?: string): UserPrice | u
103
103
  * @param origin - 调用来源(中转站 origin);缺省仅查默认价。
104
104
  */
105
105
  export declare function userPriceEntryOf(key: string, origin?: string): UserPriceEntry | undefined;
106
- /**
107
- * 查一个模型的「带来源」用户价条目(无视来源值,取第一条命中模型名的
108
- * 带 origin 条目)。供 recost 在三维站点数据缺失时兜底:用户填了来源价
109
- * 就按它重估,而不是静默回退宿主原价(issue #18)。
110
- * @param key - 计费目录键。
111
- */
112
- export declare function userOriginPriceEntryOf(key: string): UserPriceEntry | undefined;
106
+ /** 查一个模型的所有来源价。旧快照只有恰好一条可选时才允许兜底(issue #18)。 */
107
+ export declare function userOriginPriceEntriesOf(key: string): UserPriceEntry[];
113
108
  /**
114
109
  * Apply the node half's live pricing snapshot. Absent fields keep the
115
110
  * built-in catalog and rate; callers never fabricate values.
@@ -252,6 +247,12 @@ export interface TokenUsageBuckets {
252
247
  cacheHit: number;
253
248
  /** Cache-miss input tokens (already included in `input` by some providers). */
254
249
  cacheMiss: number;
250
+ /**
251
+ * 显式缓存写入 token(issue #123):**已包含在 `cacheMiss` 内**的子集——
252
+ * 厂商对「写入缓存」单独计价时(OpenAI/Anthropic 恒为输入价 125%),
253
+ * 这部分按缓存写入价计,不再按普通输入价。
254
+ */
255
+ cacheWrite?: number;
255
256
  /** Output tokens. */
256
257
  output: number;
257
258
  }
@@ -263,6 +264,13 @@ export interface PriceBand {
263
264
  cacheHit: number;
264
265
  /** Cache-miss input price per 1M tokens (absent when folded into `input`). */
265
266
  cacheMiss?: number;
267
+ /**
268
+ * 缓存写入单价(每百万 token,issue #123):厂商对「把内容写入缓存」单独
269
+ * 计价时给出(models.dev 原生 `cache_write`:OpenAI/Anthropic 恒为输入价
270
+ * 125%)。**缺省 = 按 `input` 价计**——厂商不单列缓存写入费时(如 DeepSeek、
271
+ * 月之暗面)缓存写入本就按输入价出账,与旧口径一致。
272
+ */
273
+ cacheWrite?: number;
266
274
  /** Output price per 1M tokens. */
267
275
  output: number;
268
276
  }
@@ -293,7 +301,7 @@ export interface PricePromo {
293
301
  * 缓存 0.8 / 输入 0.8 / 输出 2/3)。缺省档位沿用 {@link factor};单档取值
294
302
  * 仅 [0,1) 区间有效(0 = 该档活动期免费),非法值回落 factor。
295
303
  */
296
- factors?: Partial<Record<'input' | 'cacheHit' | 'cacheMiss' | 'output', number>>;
304
+ factors?: Partial<Record<'input' | 'cacheHit' | 'cacheMiss' | 'cacheWrite' | 'output', number>>;
297
305
  /**
298
306
  * 截止时刻(epoch ms):该时刻及之后恢复刊例价。缺省表示厂商未公布截止日
299
307
  * 的长期活动(如「限时 5 折直至另行通知」),持续生效直至收到公告后补填。
@@ -382,8 +390,12 @@ export declare function modelKeyAliases(): Readonly<Record<string, string>>;
382
390
  */
383
391
  export declare function canonModelId(id: string): string;
384
392
  export declare function resolveCatalogKey(id: string): string;
393
+ /** Price to seed a new override; never promote the generic fallback to a real zero price. */
394
+ export declare function pickerPrice(key: string): ModelEntry['price'] | undefined;
385
395
  /** Lookup a model by its stats key; falls back to the generic `other` entry. */
386
- export declare function modelOf(key: string): ModelEntry;
396
+ export declare function modelOf(key: string, { includeUserPrice }?: {
397
+ includeUserPrice?: boolean | undefined;
398
+ }): ModelEntry;
387
399
  /**
388
400
  * 模型是否可计价:内置目录、models.dev 补充、或 dsh-spend 官方价兜底命中。
389
401
  * 聚合层的计价闸门(目录外模型不产生费用,避免兜底档误估)。
@@ -418,8 +430,6 @@ export declare function applyPromo(entry: ModelEntry, nowMs: number): ModelEntry
418
430
  * @param nowMs - 促销判定时刻;缺省当前时刻。
419
431
  */
420
432
  export declare function catalogEntries(nowMs?: number): readonly ModelEntry[];
421
- /** Resolve a price-table row by its CSS variable name (theme token or fallback color). */
422
- export declare function resolveToken(name: string): string;
423
433
  /**
424
434
  * Estimate the CNY cost of one model's token usage, mixing the peak and
425
435
  * off-peak bands by the given peak share (flat-priced models cost the same in
@@ -454,7 +464,7 @@ export declare function computeCost(entry: ModelEntry, buckets: TokenUsageBucket
454
464
  * @param peakShare - fallback mix used only when `timeMs` is missing.
455
465
  * @returns the estimated cost in CNY(USD 计价模型已按当前汇率折算)。
456
466
  */
457
- export declare function computeCostAt(entry: ModelEntry, buckets: TokenUsageBuckets, timeMs: number | null | undefined, peakShare?: number): number;
467
+ export declare function computeCostAt(entry: ModelEntry, buckets: TokenUsageBuckets, timeMs: number | null | undefined, peakShare?: number, tierOverride?: PriceTierId): number;
458
468
  /** 人民币 → 美元(显示换算用):用当前生效汇率(实时优先,缺失回退内置),
459
469
  * 与计价链路的 `currentRate()` 同口径,避免实时汇率生效时 USD 显示与计价不一致。 */
460
470
  export declare function cnyToUsd(cny: number): number;
@@ -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。
@@ -0,0 +1,45 @@
1
+ /**
2
+ * 队列候选为空时的原因分层(issue #143)。
3
+ *
4
+ * 面板(队列 Tab)与会话入队入口共用这一份判定与文案来源:只说「模型不
5
+ * 支持」用户无从下手,必须分清「宿主没有官方通道」与「官方通道里没有可用
6
+ * 模型」——两者的下一步动作完全不同(配 API Key 通道 vs 看模型清单)。
7
+ *
8
+ * 2026-12-04 扩展:订阅通道(其模型目录带峰谷倍率)也能进候选,于是根因多
9
+ * 了一种「有订阅通道但其模型没有峰谷价」——下一步是看该通道暴露了哪些模型,
10
+ * 与「配一条官方通道」不是同一件事。
11
+ */
12
+ import type { TaskQueueBlockedReason, TaskQueueSaving } from '../task-queue-shared.ts';
13
+ import type { UsageBillingKey } from './locales.ts';
14
+ /**
15
+ * 「省什么」的文案键(issue #143)。
16
+ *
17
+ * 三档对应插件**能核实**的通道性质:官方按量 / 中转站按量 → 省现金;已知
18
+ * 订阅套餐 → 省额度;其它来源 → 只声明按用户配置的时段排程,不猜省的是钱
19
+ * 还是额度。面板与队列文案共用这一份映射。
20
+ *
21
+ * @param saving - 候选模型的「省什么」属性。
22
+ * @returns 对应的文案键。
23
+ */
24
+ export declare function savingKey(saving: TaskQueueSaving): UsageBillingKey;
25
+ /** 判定所需的最小事实面(面板快照与会话入队读到的都是它的子集)。 */
26
+ export interface QueueEligibilityFacts {
27
+ /** 宿主登记的工作区。 */
28
+ readonly workspaces: readonly {
29
+ readonly path: string;
30
+ }[];
31
+ /** 峰谷候选模型。 */
32
+ readonly models: readonly {
33
+ readonly provider: string;
34
+ readonly id: string;
35
+ }[];
36
+ /** 服务端给出的根因(models 为空时才有值)。 */
37
+ readonly blockedReason?: TaskQueueBlockedReason | undefined;
38
+ }
39
+ /**
40
+ * 候选/工作区缺失时的提示键;一切就绪时返回 undefined。
41
+ * @param facts - 快照里的工作区、候选与根因。
42
+ * @returns 对应的文案键,或 undefined(无需提示)。
43
+ */
44
+ export declare function queueBlockedKey(facts: QueueEligibilityFacts): UsageBillingKey | undefined;
45
+ //# sourceMappingURL=queue-eligibility.d.ts.map
@@ -5,11 +5,15 @@
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';
11
14
  /** 每轮费用图的一行(TurnUsageRow 的展示子集)。 */
12
15
  export interface RoundChartRow {
16
+ scheduleTier?: 'peak' | 'offPeak';
13
17
  sessionId: string;
14
18
  turn: number;
15
19
  model: string;
@@ -23,7 +27,7 @@ export interface RoundChartRow {
23
27
  }
24
28
  /**
25
29
  * Render the per-turn cost bars.
26
- * @param props.rounds - turns, most recent last (ascending startedAt); oldest beyond the limit are dropped.
30
+ * @param props.rounds - 逐轮行(服务端按 startedAt 倒序下发;组件内部排升序后取最新 N 轮)。
27
31
  * @param props.flags - spike flags matched by sessionId+turn.
28
32
  * @param props.currency - display currency for the amount labels.
29
33
  * @param props.t - locale function for the model label.
@@ -0,0 +1,23 @@
1
+ import { type PeakRule, type PeakSchedule } from '../peak-schedule.ts';
2
+ import { type RateChannel } from './pricing.ts';
3
+ export interface ScheduledTurn {
4
+ model?: string;
5
+ scheduleSource?: string;
6
+ }
7
+ export type EffectiveRule = Required<PeakRule>;
8
+ /** Old snapshots omit schedules. Validate new ones before they reach render paths. */
9
+ export declare function scheduleFields(value: unknown): {
10
+ peakSchedule?: PeakSchedule;
11
+ };
12
+ export declare function ruleForTurn(turn?: ScheduledTurn, schedule?: PeakSchedule): EffectiveRule | undefined;
13
+ /** Only wall-clock boundaries can change a band. Infinity means no future transition. */
14
+ export declare function scheduledCountdown(now: number, channel: RateChannel, rule?: EffectiveRule): {
15
+ tier: import("./pricing.ts").PriceTierId;
16
+ nextSwitchInMs: number;
17
+ } | null;
18
+ /** Model-only pins/catalog rows may use a custom rule only for the current pair. */
19
+ export declare function modelBand(now: number, model: string, plan: boolean, current?: ScheduledTurn, schedule?: PeakSchedule): {
20
+ tier: import("./pricing.ts").PriceTierId;
21
+ nextSwitchInMs: number;
22
+ } | null;
23
+ //# sourceMappingURL=scheduled-band.d.ts.map
@@ -11,7 +11,7 @@ import type { InputActions, InputState } from '@deepseek-ai/dsh-client-ui-conver
11
11
  import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
12
12
  import type { SessionProjectionMap } from '@deepseek-ai/dsh-api-session-controller/client';
13
13
  import type { UsageBillingKey } from './locales.ts';
14
- type Translate = (key: UsageBillingKey) => string;
14
+ type Translate = (key: UsageBillingKey, params?: Record<string, unknown>) => string;
15
15
  type ProjectionKey = Extract<keyof SessionProjectionMap, string>;
16
16
  /** Optional selector shape: old hosts may omit the standard input kit. */
17
17
  type ReadInput = <S>(selector: (state: InputState) => S, eq?: (a: S, b: S) => boolean) => S | undefined;