@kenz1117/dsh-ui-usage-billing 1.8.11 → 1.8.13

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 (34) hide show
  1. package/README.en.md +24 -7
  2. package/README.md +23 -8
  3. package/lib/client.js +5 -5
  4. package/lib/index.js +1449 -381
  5. package/lib/types/aggregate.d.ts +22 -13
  6. package/lib/types/balance.d.ts +23 -2
  7. package/lib/types/client/PeakScheduleEditor.d.ts +9 -0
  8. package/lib/types/client/api/balance.d.ts +1 -1
  9. package/lib/types/client/domain/floating-model.d.ts +31 -0
  10. package/lib/types/client/domain/types.d.ts +10 -1
  11. package/lib/types/client/live-cost.d.ts +10 -3
  12. package/lib/types/client/locales.d.ts +2 -1
  13. package/lib/types/client/peak-alert.d.ts +2 -1
  14. package/lib/types/client/peak-schedule-locales.d.ts +48 -0
  15. package/lib/types/client/price-drafts.d.ts +19 -0
  16. package/lib/types/client/price-picker.d.ts +17 -0
  17. package/lib/types/client/pricing.d.ts +8 -9
  18. package/lib/types/client/queue-eligibility.d.ts +30 -0
  19. package/lib/types/client/round-chart.d.ts +1 -0
  20. package/lib/types/client/scheduled-band.d.ts +23 -0
  21. package/lib/types/client/task-queue-quick.d.ts +1 -1
  22. package/lib/types/config.d.ts +2 -0
  23. package/lib/types/peak-ledger.d.ts +21 -0
  24. package/lib/types/peak-schedule-history.d.ts +7 -0
  25. package/lib/types/peak-schedule-models.d.ts +21 -0
  26. package/lib/types/peak-schedule-store.d.ts +10 -0
  27. package/lib/types/peak-schedule.d.ts +67 -0
  28. package/lib/types/pricing-shared.d.ts +75 -1
  29. package/lib/types/reconcile.d.ts +11 -2
  30. package/lib/types/routes/balance.d.ts +6 -3
  31. package/lib/types/routes/peak-schedule.d.ts +12 -0
  32. package/lib/types/routes/pricing-models.d.ts +11 -0
  33. package/lib/types/task-queue-shared.d.ts +12 -0
  34. package/package.json +1 -1
@@ -10,10 +10,14 @@
10
10
  * zero while their tokens still count. Pure functions only: the persistence
11
11
  * handle is injected, so the fold is unit-testable without a host.
12
12
  */
13
+ import { type PeakSchedule, type ScheduleHistory } from './peak-schedule.ts';
13
14
  import type { SessionEvent, SessionHeader, SessionId, SessionLogOffset as SessionLogOffsetT } from '@deepseek-ai/dsh-session/types';
14
15
  import type { TokenUsage } from '@deepseek-ai/dsh-llm';
15
16
  import { resolveCatalogKey } from './client/pricing.ts';
17
+ import type { TokenUsageBuckets } from './client/pricing.ts';
16
18
  import { BUILTIN_MODEL_KEY_ALIASES } from './builtin-catalog.ts';
19
+ import { type SiteRef } from './pricing-shared.ts';
20
+ export { siteBucketKey, type SiteRef, type SiteKind } from './pricing-shared.ts';
17
21
  /** 会话日志偏移:宿主 0.1.2-alpha.4 前的 dsh-session/types 不导出 SessionLogOffset
18
22
  * 值,具名导入让这些宿主装载即崩(v1.4.19~v1.4.22 实测,alpha.3 真机复现);
19
23
  * namespace 导入不做具名导出校验,缺导出时退化为恒等——偏移类型是
@@ -79,16 +83,6 @@ export interface ProviderRouteView {
79
83
  /** 该路由配置的端点地址;无值 = 直连厂商(非中转站)。 */
80
84
  baseURL?: string;
81
85
  }
82
- /** 站点归属分类:site=中转站(有 baseURL origin);direct=直连;unknown=未知路由(配置已删)。 */
83
- export type SiteKind = 'site' | 'direct' | 'unknown';
84
- /** 一个 provider 路由归类后的站点引用。 */
85
- export interface SiteRef {
86
- kind: SiteKind;
87
- /** 站点归一化 origin(仅 site)。 */
88
- origin?: string;
89
- /** 原 provider 路由名。 */
90
- provider: string;
91
- }
92
86
  /** 由 baseURL 归一化出站点 origin(协议 + 主机 + 端口);解析失败回退原值。 */
93
87
  export declare function siteOriginOf(baseURL: string): string;
94
88
  /**
@@ -110,8 +104,6 @@ export declare function siteOriginOf(baseURL: string): string;
110
104
  export declare function siteRefOf(provider: string, routes: Readonly<Record<string, ProviderRouteView>>, opts?: {
111
105
  subscription?: boolean;
112
106
  }): SiteRef;
113
- /** 站点桶的稳定 key:`site:<origin>` 与 `direct:<provider>` 分开,`unknown` 单一桶。 */
114
- export declare function siteBucketKey(ref: SiteRef): string;
115
107
  /**
116
108
  * 站点桶按范围求和(usage_stats 工具的 bySite/relay 口径):bySite 全量累计;
117
109
  * relay 只计中转站桶(`site:<origin>` 键)——`direct:*` 与 `unknown` 不计入,
@@ -130,6 +122,8 @@ export declare function sumSiteBuckets(bySite: Readonly<Record<string, {
130
122
  };
131
123
  /** Aggregation tuning options. */
132
124
  export interface AggregateOptions {
125
+ resolvePeakSchedule?: () => PeakSchedule;
126
+ resolvePeakHistory?: () => ScheduleHistory;
133
127
  /** 订阅制 provider id 列表;缺省按订阅卡同款 id 判定(`isSubscriptionProviderId`)。 */
134
128
  subscriptionProviders?: readonly string[];
135
129
  /**
@@ -191,6 +185,11 @@ export interface AggregateOptions {
191
185
  export declare const DEFAULT_MAX_CACHE_SESSIONS = 400;
192
186
  /** One model's aggregated usage plus estimated cost in CNY. */
193
187
  export interface ModelUsage {
188
+ /** Unpriced day/model/site cells only. Excludes free calls and separates account tokens. */
189
+ pendingPrice?: {
190
+ scheduled?: Required<TokenUsageBuckets>;
191
+ native?: Required<TokenUsageBuckets>;
192
+ };
194
193
  calls: number;
195
194
  input: number;
196
195
  output: number;
@@ -206,6 +205,8 @@ export interface ModelUsage {
206
205
  reasoning: number;
207
206
  /** 该模型本次统计的所有调用是否都走订阅通道(coding/token plan);混合通道不置位。 */
208
207
  plan?: boolean;
208
+ /** 模型 × 日期 × 站点格混有订阅和其他调用时,记录可确认的订阅次数。 */
209
+ planCalls?: number;
209
210
  /** 走官方渠道的调用数(DeepSeek 官方直连;其余为三方)。 */
210
211
  officialCalls: number;
211
212
  /** 走官方渠道的费用(CNY);三方费用 = cost - officialCost。 */
@@ -293,6 +294,7 @@ export interface UsagePersistence {
293
294
  }
294
295
  /** The usage-stats document served to the billing dashboard. */
295
296
  export interface UsageStatsDocument {
297
+ peakSchedule?: PeakSchedule;
296
298
  version: number;
297
299
  updatedAt: number;
298
300
  source: 'session-logs';
@@ -464,6 +466,9 @@ export declare function subParentOf(meta: SessionHeader): string | undefined;
464
466
  export declare function foldSubagentFamilies(rows: SessionUsageRow[]): void;
465
467
  /** 每轮费用明细行:仪表盘「每轮费用」图的数据源。 */
466
468
  export interface TurnUsageRow {
469
+ unpricedSource?: string | null;
470
+ scheduleSource?: string;
471
+ scheduleTier?: 'peak' | 'offPeak';
467
472
  /** 会话 id(字符串形式):不同会话的轮次号相互独立,展示时需区分。 */
468
473
  sessionId: string;
469
474
  /** 会话内轮次号。 */
@@ -647,6 +652,8 @@ export interface UsageLedgerSession {
647
652
  * 更早写入的行(配置不参与复用判定);与当前指纹不一致的行不复用、全量重折。
648
653
  */
649
654
  fingerprint?: string;
655
+ /** Schedule prefix through this fold's latest event. */
656
+ scheduleFingerprint?: string;
650
657
  /**
651
658
  * 该行最近一次折叠落盘的时刻(epoch 毫秒)。多实例共享同一账本文件时,
652
659
  * save 侧按它做行级合并(后折覆盖先折),防止整份覆盖式落盘丢掉另一实例
@@ -765,7 +772,7 @@ export declare function foldSession(events: readonly {
765
772
  time: number;
766
773
  data: unknown;
767
774
  seq?: number;
768
- }[], subscriptionProviders: SubscriptionMatcher, officialProviderIds?: ReadonlySet<string>, routes?: Readonly<Record<string, ProviderRouteView>>, searchCallEstimateCny?: number, seedLength?: number, routeAliases?: Readonly<Record<string, string>>): SessionFold;
775
+ }[], subscriptionProviders: SubscriptionMatcher, officialProviderIds?: ReadonlySet<string>, routes?: Readonly<Record<string, ProviderRouteView>>, searchCallEstimateCny?: number, seedLength?: number, routeAliases?: Readonly<Record<string, string>>, history?: ScheduleHistory): SessionFold;
769
776
  /**
770
777
  * 增量聚合器:按会话缓存折叠结果,用日志文件的 mtime+size 作失效键——
771
778
  * 日志没动的会话直接复用,只有写过的会话重新折叠;整份文档另有短 TTL
@@ -777,6 +784,8 @@ export interface UsageAggregator {
777
784
  /** Aggregate current usage, reusing cached per-session folds when their logs are untouched.
778
785
  * 并发调用共享同一次进行中的折叠(in-flight 去重),不会多倍全量重读。 */
779
786
  aggregate(): Promise<UsageStatsDocument>;
787
+ /** Publish a schedule change between folds using the latest timestamp already folded. */
788
+ withPeakScheduleChange<T>(save: (latestEventTime: number) => Promise<T>): Promise<T>;
780
789
  /**
781
790
  * 按会话 id 取该会话的完整累计用量。doc 的 `byTurn` 封顶(最近 200 轮),
782
791
  * 用户回到旧会话续聊时其轮次已被挤出,从 doc 反推会低估——这里直接读该
@@ -13,7 +13,14 @@
13
13
  * provider's key once and every surface reuses it.
14
14
  */
15
15
  import type { Context } from '@deepseek-ai/cordis';
16
- import type { CustomBalanceConfig, CustomBalanceExtract, ProviderBalance } from './pricing-shared.ts';
16
+ import { type BalanceClientMetadata, type CustomBalanceConfig, type CustomBalanceExtract, type ProviderBalance } from './pricing-shared.ts';
17
+ /**
18
+ * 宿主内置平台通道(路由 id `deepseek-official`)的默认凭据 ref——宿主包
19
+ * `llm-deepseek-api-key` 的 `apiKeyEnv` 默认值(`0.1.2-alpha.1` ~ `0.2.3-alpha.3`)。
20
+ * 内置通道不在 llm-pi-ai 路由表里,只能按这个约定 ref 找回它的 key。
21
+ */
22
+ export declare const DEEPSEEK_PLATFORM_KEY_REF = "DEEPSEEK_API_KEY";
23
+ export declare function apiBalanceSource(row: ProviderBalance): string | undefined;
17
24
  /**
18
25
  * 从 TokenDance 余额响应提取剩余余额并换算为元。导出供测试:纯函数。
19
26
  * 优先用服务端现成的 `balance.balance`(= credits - credits_used);缺失时
@@ -22,6 +29,17 @@ import type { CustomBalanceConfig, CustomBalanceExtract, ProviderBalance } from
22
29
  * @returns 剩余余额(元);提取不到返回 undefined。
23
30
  */
24
31
  export declare function pickTokenDanceBalanceCny(data: unknown): number | undefined;
32
+ /**
33
+ * 余额查询的额外口径(插件配置进不来时的唯一入口)。
34
+ */
35
+ export interface BalanceQueryOptions {
36
+ /**
37
+ * 额外的凭据候选(按路由 id):插件配置里的 `balanceApiKeyEnv` 之类。排在路由
38
+ * 约定名之前——宿主内置通道的 key 由宿主自己存(默认 ref 固定),插件配置的
39
+ * ref 只是后备。
40
+ */
41
+ extraKeyRefs?: Readonly<Record<string, readonly string[]>>;
42
+ }
25
43
  /**
26
44
  * Query every configured provider's account balance. A provider is queried only
27
45
  * when its llm-pi-ai route has a key: an explicit `apiKeyEnv`, or — on hosts
@@ -30,11 +48,14 @@ export declare function pickTokenDanceBalanceCny(data: unknown): number | undefi
30
48
  * dashboard shows a stable state instead of dropping the row.
31
49
  * @param ctx - host context carrying the credentials seam.
32
50
  * @param providers - the llm-pi-ai providers dict (`<route> → { apiKeyEnv? }`).
51
+ * @param client - UI metadata for the host login wallet service.
52
+ * @param options - extra credential candidates per route (plugin config).
33
53
  * @returns the balance rows (one per provider).
34
54
  */
35
55
  export declare function queryBalances(ctx: Context, providers: Readonly<Record<string, {
36
56
  apiKeyEnv?: string;
37
- }>>): Promise<readonly ProviderBalance[]>;
57
+ baseURL?: string;
58
+ }>>, client?: BalanceClientMetadata, options?: BalanceQueryOptions): Promise<readonly ProviderBalance[]>;
38
59
  /**
39
60
  * 按 extract 规则从响应 JSON 求值。导出供测试:纯函数。
40
61
  * @param rule - 提取规则(const / path / add / subtract / divide)。
@@ -0,0 +1,9 @@
1
+ import { type ScheduleSnapshot } from '../peak-schedule.ts';
2
+ import type { UsageBillingKey } from './locales.ts';
3
+ type Translate = (key: UsageBillingKey) => string;
4
+ export declare function PeakScheduleEditor({ t, onSaved }: {
5
+ t: Translate;
6
+ onSaved?: (snapshot: ScheduleSnapshot) => void;
7
+ }): import("react").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=PeakScheduleEditor.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * GET /api/billing/balance:余额 + 对账提示(同一响应体)。30s 轮询单端点
3
3
  * 比拆成两个端点更省(余额查询本身已有熔断与重试),失败回退空值。
4
4
  */
5
- import type { ProviderBalance, ReconcileNotice } from '../../pricing-shared.ts';
5
+ import { type ProviderBalance, type ReconcileNotice } from '../../pricing-shared.ts';
6
6
  /** Path to the account-balance endpoint served by this plugin's node half. */
7
7
  export declare const BALANCE_PATH = "/api/billing/balance";
8
8
  /** 余额文档(服务端响应体的白名单切片)。 */
@@ -0,0 +1,31 @@
1
+ import { type ProviderBalance, type RelayQuota, type SubscriptionQuota } from '../../pricing-shared.ts';
2
+ import type { BillingCardSpan } from '../usage-billing-settings.ts';
3
+ import type { UsageBillingKey } from '../locales.ts';
4
+ import type { UsageStats } from './types.ts';
5
+ type ModelStats = Pick<UsageStats, 'byDayModels' | 'byDayModelsSite' | 'byModel'>;
6
+ interface Lead {
7
+ name: string;
8
+ cost: number;
9
+ calls: number;
10
+ sources: Set<string>;
11
+ unattributedCalls: number;
12
+ }
13
+ /** Rank metered models on the same day/model costs as the dashboard, including custom prices. */
14
+ export declare function floatingLeads(stats: ModelStats, span: BillingCardSpan, today: string): {
15
+ paid: Lead | undefined;
16
+ plan: Lead | undefined;
17
+ };
18
+ export declare function floatingStatus(leads: ReturnType<typeof floatingLeads>, balances: readonly ProviderBalance[], relays: readonly RelayQuota[], quotas: readonly SubscriptionQuota[], threshold: number, t: (key: UsageBillingKey) => string): {
19
+ direct: {
20
+ name: string;
21
+ text: string;
22
+ low: boolean;
23
+ } | undefined;
24
+ sub: {
25
+ name: string;
26
+ text: string;
27
+ low: boolean;
28
+ } | undefined;
29
+ };
30
+ export {};
31
+ //# sourceMappingURL=floating-model.d.ts.map
@@ -137,7 +137,7 @@ export interface ProviderBillingGroup {
137
137
  /** 归并到该厂商的订阅额度卡片。 */
138
138
  subscriptions: readonly SubscriptionQuota[];
139
139
  /** 该厂商余额(同厂商只显示一次)。 */
140
- balance: ProviderBalance | undefined;
140
+ balances: readonly ProviderBalance[];
141
141
  /** 健康点状态:按厂商名与 health 的在线/失效列表匹配。 */
142
142
  dot: string | undefined;
143
143
  /** 入口种类;纯订阅/余额组无入口为 vendor。 */
@@ -166,6 +166,7 @@ export interface UsageBillingInjected {
166
166
  }
167
167
  /** Usage stats structure from `.dsh-usage-stats.json`. */
168
168
  export interface UsageStats {
169
+ peakSchedule?: import('../../peak-schedule.ts').PeakSchedule;
169
170
  /** 服务端聚合时间戳(毫秒);旧快照可能缺失。 */
170
171
  updatedAt?: number;
171
172
  /**
@@ -262,6 +263,8 @@ export interface UsageStats {
262
263
  cost: number;
263
264
  /** 该格全部调用都走订阅通道(聚合侧按三维格置位);旧快照缺失,回退全局口径。 */
264
265
  plan?: boolean;
266
+ /** 混合格中可确认的订阅调用次数(费用仅来自非订阅调用)。 */
267
+ planCalls?: number;
265
268
  }>>>;
266
269
  /**
267
270
  * 峰谷分桶(全量逐调用真实判档):1.0.8 起服务端按调用时刻精确归桶,
@@ -284,6 +287,8 @@ export interface UsageStats {
284
287
  sessionId: string;
285
288
  turn: number;
286
289
  model: string;
290
+ scheduleSource?: string;
291
+ scheduleTier?: 'peak' | 'offPeak';
287
292
  input: number;
288
293
  output: number;
289
294
  cacheHit: number;
@@ -313,6 +318,10 @@ export interface UsageStats {
313
318
  }>;
314
319
  /** 不可计价模型 id(未收录/无价,费用按 0 计);旧快照可能缺失。 */
315
320
  unpricedModels?: readonly string[];
321
+ /** Client-only catalog estimate for usage not covered by a user price. */
322
+ estimatedUnpricedTotal?: number;
323
+ /** Display-only: models with usage estimated from a sole, unverified source price. */
324
+ sourceEstimatedModels?: readonly string[];
316
325
  /** 联网搜索请求的单次费用估算(人民币元,配置回显);0 或缺省 = 未启用估算。 */
317
326
  searchCallEstimateCny?: number;
318
327
  /** 按角色费用归因(估算口径:输出实测,输入按消息长度摊分);旧快照可能缺失。 */
@@ -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' | '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' | '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';
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' | 'cardMode' | 'cardModeFull' | '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' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queueNoWorkspace' | 'queueNoOfficialRoute' | 'queueNoOfficialModel' | '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>;
@@ -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.
@@ -395,8 +390,12 @@ export declare function modelKeyAliases(): Readonly<Record<string, string>>;
395
390
  */
396
391
  export declare function canonModelId(id: string): string;
397
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;
398
395
  /** Lookup a model by its stats key; falls back to the generic `other` entry. */
399
- export declare function modelOf(key: string): ModelEntry;
396
+ export declare function modelOf(key: string, { includeUserPrice }?: {
397
+ includeUserPrice?: boolean | undefined;
398
+ }): ModelEntry;
400
399
  /**
401
400
  * 模型是否可计价:内置目录、models.dev 补充、或 dsh-spend 官方价兜底命中。
402
401
  * 聚合层的计价闸门(目录外模型不产生费用,避免兜底档误估)。
@@ -465,7 +464,7 @@ export declare function computeCost(entry: ModelEntry, buckets: TokenUsageBucket
465
464
  * @param peakShare - fallback mix used only when `timeMs` is missing.
466
465
  * @returns the estimated cost in CNY(USD 计价模型已按当前汇率折算)。
467
466
  */
468
- 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;
469
468
  /** 人民币 → 美元(显示换算用):用当前生效汇率(实时优先,缺失回退内置),
470
469
  * 与计价链路的 `currentRate()` 同口径,避免实时汇率生效时 USD 显示与计价不一致。 */
471
470
  export declare function cnyToUsd(cny: number): number;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 队列候选为空时的原因分层(issue #143)。
3
+ *
4
+ * 面板(队列 Tab)与会话入队入口共用这一份判定与文案来源:只说「模型不
5
+ * 支持」用户无从下手,必须分清「宿主没有官方通道」与「官方通道里没有可用
6
+ * 模型」——两者的下一步动作完全不同(配 API Key 通道 vs 看模型清单)。
7
+ */
8
+ import type { TaskQueueBlockedReason } from '../task-queue-shared.ts';
9
+ import type { UsageBillingKey } from './locales.ts';
10
+ /** 判定所需的最小事实面(面板快照与会话入队读到的都是它的子集)。 */
11
+ export interface QueueEligibilityFacts {
12
+ /** 宿主登记的工作区。 */
13
+ readonly workspaces: readonly {
14
+ readonly path: string;
15
+ }[];
16
+ /** 官方峰谷候选模型。 */
17
+ readonly models: readonly {
18
+ readonly provider: string;
19
+ readonly id: string;
20
+ }[];
21
+ /** 服务端给出的根因(models 为空时才有值)。 */
22
+ readonly blockedReason?: TaskQueueBlockedReason | undefined;
23
+ }
24
+ /**
25
+ * 候选/工作区缺失时的提示键;一切就绪时返回 undefined。
26
+ * @param facts - 快照里的工作区、候选与根因。
27
+ * @returns 对应的文案键,或 undefined(无需提示)。
28
+ */
29
+ export declare function queueBlockedKey(facts: QueueEligibilityFacts): UsageBillingKey | undefined;
30
+ //# sourceMappingURL=queue-eligibility.d.ts.map
@@ -13,6 +13,7 @@ import type { AnomalyFlag } from './anomaly.ts';
13
13
  import { type CostCurrency } from './pricing.ts';
14
14
  /** 每轮费用图的一行(TurnUsageRow 的展示子集)。 */
15
15
  export interface RoundChartRow {
16
+ scheduleTier?: 'peak' | 'offPeak';
16
17
  sessionId: string;
17
18
  turn: number;
18
19
  model: string;
@@ -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;
@@ -46,6 +46,8 @@ export interface UsageBillingConfig {
46
46
  ledgerPath?: string;
47
47
  /** 余额差对账基准的持久化路径;默认 `<harness home>/.dsh-usage-reconcile.json`。 */
48
48
  reconcilePath?: string;
49
+ /** Independent per-source peak schedules (defaults to the host profile directory). */
50
+ peakSchedulePath?: string;
49
51
  /** 低谷任务队列的持久化路径;默认 `<harness home>/.dsh-usage-task-queue.json`。
50
52
  * 文件包含待执行 Prompt,以 0600 写入;测试可注入临时路径隔离真实队列。 */
51
53
  taskQueuePath?: string;
@@ -0,0 +1,21 @@
1
+ import { type ModelEntry, type TokenUsageBuckets } from './client/pricing.ts';
2
+ import type { indexPeakHistory } from './peak-schedule-history.ts';
3
+ export type PeakIndex = ReturnType<typeof indexPeakHistory>;
4
+ export declare function scheduleTier(schedule: PeakIndex, source: string | undefined, entry: ModelEntry, model: string, time: number): "peak" | "offPeak" | undefined;
5
+ /** Old site buckets lack raw provider ids. Only trust the historical routing fingerprint
6
+ * when its (unescaped) alias/origin fields can be decoded without ambiguity. */
7
+ export declare function legacyScheduleSource(fingerprint: string | undefined): (site: string) => boolean;
8
+ export declare const tokenFields: readonly ["input", "output", "cacheHit", "cacheMiss", "cacheWrite"];
9
+ export declare const emptyTokens: () => Required<TokenUsageBuckets>;
10
+ export declare function addTokens(target: Required<TokenUsageBuckets>, cell: TokenUsageBuckets, sign?: number): void;
11
+ export declare const emptyPrice: () => {
12
+ cost: number;
13
+ inputCost: number;
14
+ outputCost: number;
15
+ peakCost: number;
16
+ offCost: number;
17
+ };
18
+ export type LedgerPrice = ReturnType<typeof emptyPrice>;
19
+ export declare function addPrice(target: LedgerPrice, price: LedgerPrice): void;
20
+ export declare function priceLedgerTokens(entry: ModelEntry, cell: TokenUsageBuckets, day: string, schedule?: PeakIndex, source?: string): LedgerPrice;
21
+ //# sourceMappingURL=peak-ledger.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { type PeakRule, type ScheduleHistory } from './peak-schedule.ts';
2
+ /** A future revision does not change the fingerprint of any earlier fold. */
3
+ export declare function indexPeakHistory(history?: ScheduleHistory): {
4
+ rule(source: string, model: string, time: number): Required<PeakRule> | undefined;
5
+ fingerprint: (time: number) => string | undefined;
6
+ } | undefined;
7
+ //# sourceMappingURL=peak-schedule-history.d.ts.map