@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.
- package/README.en.md +30 -12
- package/README.md +52 -23
- package/lib/client.js +5 -5
- package/lib/index.js +2566 -407
- package/lib/types/aggregate.d.ts +46 -14
- package/lib/types/balance.d.ts +23 -2
- package/lib/types/builtin-catalog.d.ts +5 -0
- package/lib/types/client/PeakScheduleEditor.d.ts +9 -0
- package/lib/types/client/TaskQueuePanel.d.ts +5 -1
- package/lib/types/client/TokenPanel.d.ts +2 -0
- package/lib/types/client/UsageBilling.d.ts +2 -0
- package/lib/types/client/UsageBillingMainPanel.d.ts +7 -0
- package/lib/types/client/UsageBillingPanelIcon.d.ts +5 -0
- package/lib/types/client/api/balance.d.ts +1 -1
- package/lib/types/client/api/task-queue.d.ts +4 -0
- package/lib/types/client/api/usage-stats.d.ts +16 -2
- package/lib/types/client/constants.d.ts +9 -0
- package/lib/types/client/domain/channel-visibility.d.ts +68 -0
- package/lib/types/client/domain/floating-model.d.ts +31 -0
- package/lib/types/client/domain/types.d.ts +37 -1
- package/lib/types/client/footer-lane.d.ts +114 -0
- package/lib/types/client/live-cost.d.ts +10 -3
- package/lib/types/client/locales.d.ts +2 -1
- package/lib/types/client/panel-capability.d.ts +12 -0
- package/lib/types/client/peak-alert.d.ts +2 -1
- package/lib/types/client/peak-schedule-locales.d.ts +48 -0
- package/lib/types/client/price-drafts.d.ts +19 -0
- package/lib/types/client/price-picker.d.ts +17 -0
- package/lib/types/client/pricing.d.ts +22 -12
- package/lib/types/client/provider-display.d.ts +0 -2
- package/lib/types/client/queue-eligibility.d.ts +45 -0
- package/lib/types/client/round-chart.d.ts +5 -1
- package/lib/types/client/scheduled-band.d.ts +23 -0
- package/lib/types/client/task-queue-quick.d.ts +1 -1
- package/lib/types/client/usage-billing-settings.d.ts +62 -9
- package/lib/types/client/usage-command.d.ts +10 -5
- package/lib/types/config.d.ts +2 -0
- package/lib/types/guard.d.ts +30 -3
- package/lib/types/peak-ledger.d.ts +21 -0
- package/lib/types/peak-schedule-history.d.ts +7 -0
- package/lib/types/peak-schedule-models.d.ts +21 -0
- package/lib/types/peak-schedule-store.d.ts +10 -0
- package/lib/types/peak-schedule.d.ts +67 -0
- package/lib/types/pricing-shared.d.ts +81 -1
- package/lib/types/reconcile.d.ts +11 -2
- package/lib/types/routes/balance.d.ts +6 -3
- package/lib/types/routes/peak-schedule.d.ts +12 -0
- package/lib/types/routes/pricing-models.d.ts +11 -0
- package/lib/types/task-queue-band.d.ts +80 -0
- package/lib/types/task-queue-shared.d.ts +57 -0
- package/lib/types/task-queue.d.ts +110 -3
- package/package.json +75 -64
|
@@ -41,18 +41,40 @@ export declare const FLOAT_WINDOW_STORAGE_KEY = "dsh.ui-usage-billing.float";
|
|
|
41
41
|
export declare function loadFloatWindowPrefs(): FloatWindowPrefs;
|
|
42
42
|
/** 写入浮窗偏好。失败静默(展示偏好非关键)。 */
|
|
43
43
|
export declare function saveFloatWindowPrefs(prefs: FloatWindowPrefs): void;
|
|
44
|
+
/** 仪表盘入口的挂载位置:底部触发器 / 左侧主面板 / 两者同时显示(issue #144)。 */
|
|
45
|
+
export type BillingDisplayPlacement = 'footer' | 'left' | 'both';
|
|
46
|
+
/** 默认保持既有底部入口,升级后不改变用户界面。 */
|
|
47
|
+
export declare const DEFAULT_BILLING_DISPLAY_PLACEMENT: BillingDisplayPlacement;
|
|
48
|
+
export declare const BILLING_DISPLAY_PLACEMENT_STORAGE_KEY = "dsh.ui-usage-billing.display-placement";
|
|
49
|
+
export declare const BILLING_DISPLAY_PLACEMENT_EVENT = "dsh.ui-usage-billing.display-placement-changed";
|
|
50
|
+
/** 读取展示位置;缺失与非法值一律回退底部。 */
|
|
51
|
+
export declare function loadBillingDisplayPlacement(): BillingDisplayPlacement;
|
|
52
|
+
/** 写入并广播展示位置,apply 的槽位注册与各 React 树共用同一份偏好。 */
|
|
53
|
+
export declare function saveBillingDisplayPlacement(placement: BillingDisplayPlacement): void;
|
|
54
|
+
/** 同文档跨 React 树 + 跨标签页同步。 */
|
|
55
|
+
export declare function subscribeBillingDisplayPlacement(listener: () => void): () => void;
|
|
56
|
+
/** 宿主没有左侧双槽位时不得把唯一入口藏掉;设置里另行显示降级原因。 */
|
|
57
|
+
export declare function resolveBillingDisplayPlacement(placement: BillingDisplayPlacement, leftPanelAvailable: boolean): BillingDisplayPlacement;
|
|
44
58
|
/** 左下角计费卡的主指标视角。 */
|
|
45
59
|
export type BillingCardMetric = 'money' | 'tokens';
|
|
46
60
|
/** 计费卡主数字的统计范围(单值卡面,issue #47 反馈)。 */
|
|
47
61
|
export type BillingCardSpan = 'day' | 'week' | 'month';
|
|
48
|
-
/**
|
|
49
|
-
|
|
62
|
+
/**
|
|
63
|
+
* 侧栏入口显示模式(issue #108 / #148):
|
|
64
|
+
* - `auto`:按座位容量自动决定形态——放得下完整卡片就显示卡片,放不下收为图标钮(**默认**);
|
|
65
|
+
* - `full`:**无条件**显示完整卡片,不做邻居/容量判断(同槽邻居会被挤压,触发卡悬停提示写明挤了几个);
|
|
66
|
+
* - `compact`:36×36 图标钮;
|
|
67
|
+
* - `hidden`:不渲染(宿主没有恢复入口时降级为 `compact`)。
|
|
68
|
+
*
|
|
69
|
+
* `full` 是用户的显式意图,优先于「有邻居就收窄」的自动策略(issue #148)。
|
|
70
|
+
*/
|
|
71
|
+
export type BillingCardMode = 'auto' | 'full' | 'compact' | 'hidden';
|
|
50
72
|
/**
|
|
51
73
|
* 计费卡显示偏好:侧栏入口模式 + 卡面主数字与迷你柱的计价视角 + 主数字统计范围。
|
|
52
74
|
* 纯 client 偏好,存 localStorage(不依赖 node 半区接口/设置 schema)。
|
|
53
75
|
*/
|
|
54
76
|
export interface BillingCardPrefs {
|
|
55
|
-
/**
|
|
77
|
+
/** 侧栏入口模式(默认 `auto`:按座位容量自动决定;老偏好缺字段时按自动处理)。 */
|
|
56
78
|
mode: BillingCardMode;
|
|
57
79
|
/** 主指标:花费金额(CNY/USD 按币种)/ Token 消耗。 */
|
|
58
80
|
metric: BillingCardMetric;
|
|
@@ -61,7 +83,7 @@ export interface BillingCardPrefs {
|
|
|
61
83
|
/** 是否显示「今日环比」涨跌徽章(默认显示;issue #93:部分用户觉得红色横条太醒目)。 */
|
|
62
84
|
showDelta: boolean;
|
|
63
85
|
}
|
|
64
|
-
/**
|
|
86
|
+
/** 默认计费卡偏好:自动形态 + 花费金额 + 今日口径 + 显示环比徽章。 */
|
|
65
87
|
export declare const DEFAULT_BILLING_CARD_PREFS: BillingCardPrefs;
|
|
66
88
|
/** localStorage key(与 budget store 的 `dsh.ui-usage-billing.*` 命名空间一致)。 */
|
|
67
89
|
export declare const BILLING_CARD_STORAGE_KEY = "dsh.ui-usage-billing.card";
|
|
@@ -109,6 +131,25 @@ export declare const SITE_LIST_STORAGE_KEY = "dsh.ui-usage-billing.sites";
|
|
|
109
131
|
export declare function loadSiteListPrefs(): SiteListPrefs;
|
|
110
132
|
/** 写入站点列表偏好。失败静默(展示偏好非关键)。 */
|
|
111
133
|
export declare function saveSiteListPrefs(prefs: SiteListPrefs): void;
|
|
134
|
+
/**
|
|
135
|
+
* 通道可见性偏好(issue #126 需求):隐藏部分提供商 / 通道。
|
|
136
|
+
* 纯 client 偏好,存 localStorage(不依赖 node 半区接口/设置 schema)。
|
|
137
|
+
*
|
|
138
|
+
* 存**通道桶 key**(`site:<origin>` / `direct:<provider>` / `unknown`)而不是
|
|
139
|
+
* 显示名——显示名随界面语言变(中英),桶 key 稳定,偏好能跨语言沿用。
|
|
140
|
+
*/
|
|
141
|
+
export interface ChannelVisibilityPrefs {
|
|
142
|
+
/** 隐藏的通道桶 key 列表;空 = 全部显示。 */
|
|
143
|
+
hidden: readonly string[];
|
|
144
|
+
}
|
|
145
|
+
/** 默认通道可见性偏好:全部显示(保持历史行为)。 */
|
|
146
|
+
export declare const DEFAULT_CHANNEL_VISIBILITY_PREFS: ChannelVisibilityPrefs;
|
|
147
|
+
/** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
|
|
148
|
+
export declare const CHANNEL_VISIBILITY_STORAGE_KEY = "dsh.ui-usage-billing.channels";
|
|
149
|
+
/** 读取通道可见性偏好(含损坏/缺失回退到默认)。仅在浏览器半区调用。 */
|
|
150
|
+
export declare function loadChannelVisibilityPrefs(): ChannelVisibilityPrefs;
|
|
151
|
+
/** 写入通道可见性偏好。失败静默(展示偏好非关键)。 */
|
|
152
|
+
export declare function saveChannelVisibilityPrefs(prefs: ChannelVisibilityPrefs): void;
|
|
112
153
|
/**
|
|
113
154
|
* 即时代费条(平价消耗胶囊,composer dock 的 LiveCostBar)的显示偏好。
|
|
114
155
|
* 纯 client 偏好,存 localStorage(不依赖 node 半区接口/设置 schema);
|
|
@@ -234,8 +275,9 @@ export declare function loadPerfViewPrefs(): PerfViewPrefs;
|
|
|
234
275
|
export declare function savePerfViewPrefs(prefs: PerfViewPrefs): void;
|
|
235
276
|
/**
|
|
236
277
|
* 显示密度档位(v1.5 新增)。紧凑档减小行高/字号/内边距,舒适档加大;
|
|
237
|
-
* 默认档保持历史感官。client 端写到 `documentElement.dataset.
|
|
238
|
-
*
|
|
278
|
+
* 默认档保持历史感官。client 端写到 `documentElement.dataset.dshBillingDensity`
|
|
279
|
+
* (= `data-dsh-billing-density`,命名空间化防同名属性互相覆盖,issue #124),
|
|
280
|
+
* CSS `[data-dsh-billing-density="..."]` 选择器派生 `--ds-density-*` 变量。
|
|
239
281
|
*/
|
|
240
282
|
export type DensityPref = 'compact' | 'default' | 'comfortable';
|
|
241
283
|
/** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
|
|
@@ -250,9 +292,11 @@ export declare function loadDensity(): DensityPref;
|
|
|
250
292
|
* 失败静默(展示偏好非关键)。 */
|
|
251
293
|
export declare function saveDensity(density: DensityPref): void;
|
|
252
294
|
/**
|
|
253
|
-
* 动效强度档位(v1.5 新增)。`off`
|
|
254
|
-
* `subtle`
|
|
255
|
-
*
|
|
295
|
+
* 动效强度档位(v1.5 新增)。`off` 冻结本插件内的全部 transition+animation,
|
|
296
|
+
* `subtle` 保留 transition 微交互、把关键帧动画压成瞬时,`rich` 即默认(全开)。
|
|
297
|
+
* 写到 `documentElement.dataset.dshBillingMotion`(= `data-dsh-billing-motion`),
|
|
298
|
+
* 且压制规则只作用在本插件根容器 `.dsh-billing-root` 之内(issue #124:
|
|
299
|
+
* 此前通用属性 + 通配符会把宿主与第三方插件的动画一起压平)。
|
|
256
300
|
*/
|
|
257
301
|
export type MotionPref = 'off' | 'subtle' | 'rich';
|
|
258
302
|
/** localStorage key(与其他 `dsh.ui-usage-billing.*` 偏好同命名空间)。 */
|
|
@@ -279,6 +323,15 @@ export interface QuickQueuePrefs {
|
|
|
279
323
|
* touched the setting.
|
|
280
324
|
*/
|
|
281
325
|
showEntry: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Run a queued task inside the Session it was queued from (issue #118).
|
|
328
|
+
*
|
|
329
|
+
* Off keeps every task in its own Session. On prefers continuing in the
|
|
330
|
+
* source Session — same context, same workspace grouping — and falls back to
|
|
331
|
+
* a new Session when the source is gone, busy or archived. Default off: the
|
|
332
|
+
* isolated-Session design is the safe default.
|
|
333
|
+
*/
|
|
334
|
+
reuseSourceSession: boolean;
|
|
282
335
|
}
|
|
283
336
|
export declare const DEFAULT_QUICK_QUEUE_PREFS: QuickQueuePrefs;
|
|
284
337
|
export declare const QUICK_QUEUE_STORAGE_KEY = "dsh.ui-usage-billing.quick-queue";
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* - `label` / `description` 是**函数**:菜单每次打开都重新读取,切换语言立即生效,
|
|
11
11
|
* 无需重新注册。
|
|
12
12
|
*
|
|
13
|
-
* 取服务走 `ctx.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* 取服务走 `ctx.inject(['commandUi'])` 而非 apply 期的 `ctx.get`:该服务是宿主的
|
|
14
|
+
* Service,要等 inputTriggers / remote.commands 就绪才构造,晚于本插件 apply。
|
|
15
|
+
* 老宿主没有这个服务时注入分支永不执行,**不注册命令**、面板功能完全不受影响——
|
|
16
|
+
* 这是「服务缺席即降级、不得因此收窄兼容矩阵」的落点。
|
|
16
17
|
*/
|
|
17
18
|
import type { Context } from '@deepseek-ai/cordis';
|
|
18
19
|
/** 命令名(斜杠后不带斜杠):与宿主命令目录合并的键。 */
|
|
@@ -29,9 +30,13 @@ export interface UsageCommandOptions {
|
|
|
29
30
|
/**
|
|
30
31
|
* 注册 `/usage` 命令。
|
|
31
32
|
*
|
|
33
|
+
* commandUi 是宿主的 Service,构造前要等 inputTriggers / sessions / remote.commands
|
|
34
|
+
* 就绪——这些都晚于本插件 apply。因此在 apply 期用 `ctx.get` 一次性采样必然拿到
|
|
35
|
+
* undefined,命令永远注册不上;改为 `ctx.inject` 等它就位再注册。
|
|
36
|
+
*
|
|
32
37
|
* @param ctx - 客户端根 context。
|
|
33
38
|
* @param options - 打开回调与文案。
|
|
34
|
-
* @returns
|
|
39
|
+
* @returns 查询当前是否已注册的 getter(宿主无 commandUi 服务时恒为 false,属正常降级)。
|
|
35
40
|
*/
|
|
36
|
-
export declare function registerUsageCommand(ctx: Context, options: UsageCommandOptions): boolean;
|
|
41
|
+
export declare function registerUsageCommand(ctx: Context, options: UsageCommandOptions): () => boolean;
|
|
37
42
|
//# sourceMappingURL=usage-command.d.ts.map
|
package/lib/types/config.d.ts
CHANGED
|
@@ -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;
|
package/lib/types/guard.d.ts
CHANGED
|
@@ -34,10 +34,37 @@ export declare function normalizeTrustedHosts(hosts: readonly string[] | undefin
|
|
|
34
34
|
* 拒绝 `127.0.0.1.attacker.com` 这类以 `127.` 开头但解析到外部的 DNS rebinding 域名:
|
|
35
35
|
* 只用 `startsWith('127.')` 会被它穿透,必须精确匹配回环 IP 的字面量。 */
|
|
36
36
|
export declare function isLoopbackHost(req: IncomingMessage, trustedHosts?: ReadonlySet<string>): boolean;
|
|
37
|
-
/** 校验 Origin
|
|
37
|
+
/** 校验 Origin 头是否可信(写操作用,防止跨站表单/fetch 改写设置)。Origin 缺失
|
|
38
38
|
* (curl 或同源 fetch 不带)视为放行,交给下方的 Content-Type 校验兜底;Origin 存在
|
|
39
|
-
*
|
|
40
|
-
|
|
39
|
+
* 但主机既非回环、也不在 trustedHosts 里则拒绝——跨站脚本发起的写请求必带攻击者
|
|
40
|
+
* 域名的 Origin。
|
|
41
|
+
*
|
|
42
|
+
* 反向代理场景:浏览器把页面自身的地址写进 Origin(`https://dash.example.com`)。
|
|
43
|
+
* Host 头因为同一域名被 trustedHosts 放行,Origin 却是同一个非回环域名——只认回环
|
|
44
|
+
* 字面量会让「已显式信任的主机」在写操作上必然 403(读操作正常),表现为面板能
|
|
45
|
+
* 打开、点任何保存/入队都报 `forbidden: loopback only`。因此 Origin 与 Host 共用
|
|
46
|
+
* 同一份 trustedHosts:用户显式信任某个主机,就等于接受该主机的同源写请求。
|
|
47
|
+
* @param origin - 原始 Origin 头(可能缺失)。
|
|
48
|
+
* @param trustedHosts - 已归一化的可信主机名集合,与 {@link isLoopbackHost} 同口径。
|
|
49
|
+
*/
|
|
50
|
+
export declare function isLoopbackOrigin(origin: string | undefined, trustedHosts?: ReadonlySet<string>): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 路由准入声明(宿主 0.2.3-alpha.1 起必需)。
|
|
53
|
+
*
|
|
54
|
+
* 宿主把 Web 路由的 `auth` 默认值从「无鉴权」改成了 `'required'`:未通过宿主
|
|
55
|
+
* 连接层鉴权的请求在进入 handler **之前**就被拒(401/503),插件自带的守卫
|
|
56
|
+
* 根本没机会执行——面板会静默变成一片 0。本插件的端点只服务本机浏览器,安全
|
|
57
|
+
* 边界是 {@link guardLoopback}(peer 回环 socket + Host 头精确字面量 +
|
|
58
|
+
* trustedHosts 白名单 + Origin 校验),因此显式声明匿名准入。
|
|
59
|
+
*
|
|
60
|
+
* 宿主的可信主机栅栏仍然生效(Host 必须是回环/可信主机、Origin 必须同源),
|
|
61
|
+
* 这里只放宽「需要 peer 凭据」这一层,不放宽来源校验。
|
|
62
|
+
*
|
|
63
|
+
* 老宿主(≤0.2.2-rc.5)没有 `auth` 字段,多余字段被忽略,行为与从前一致。
|
|
64
|
+
*/
|
|
65
|
+
export declare const ANONYMOUS_ROUTE_AUTH: {
|
|
66
|
+
readonly auth: "anonymous";
|
|
67
|
+
};
|
|
41
68
|
/**
|
|
42
69
|
* 回环防护守卫:仅接受回环 GET 请求(peer socket 地址 + Host 头同时校验)。
|
|
43
70
|
* 不满足时返回 403 并结束响应;调用方在 handler 顶部调用,返回 false 即已拒绝。
|
|
@@ -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
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ProviderRouteView } from './aggregate.ts';
|
|
2
|
+
import { type ScheduleModel, type ScheduleNotice } from './peak-schedule.ts';
|
|
3
|
+
export interface ScheduleProfile extends ProviderRouteView {
|
|
4
|
+
displayName?: string;
|
|
5
|
+
models?: unknown[];
|
|
6
|
+
}
|
|
7
|
+
interface Llm {
|
|
8
|
+
listProviders?(): readonly {
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
}[];
|
|
12
|
+
listModels?(route: string): Promise<unknown[]>;
|
|
13
|
+
}
|
|
14
|
+
export declare function eligibleScheduleModel(key: string): boolean;
|
|
15
|
+
/** Cache only remote discovery. Route identity and locally declared models are refreshed every request. */
|
|
16
|
+
export declare function createScheduleModelDiscovery(now?: () => number, ttlMs?: number): (llm: Llm | undefined, profiles: Record<string, ScheduleProfile>, aliases: Readonly<Record<string, string>>) => Promise<{
|
|
17
|
+
models: ScheduleModel[];
|
|
18
|
+
notices: ScheduleNotice[];
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=peak-schedule-models.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ScheduleEdit, type ScheduleHistory, type ScheduleNotice } from './peak-schedule.ts';
|
|
2
|
+
export declare class ScheduleClockConflict extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare function openScheduleStore(path: string, eligible: (key: string) => boolean, now?: () => number): {
|
|
5
|
+
current: () => import("./peak-schedule.ts").PeakSchedule;
|
|
6
|
+
history: () => ScheduleHistory;
|
|
7
|
+
notices: () => ScheduleNotice[];
|
|
8
|
+
save(edit: ScheduleEdit, latestEventTime?: number): Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=peak-schedule-store.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** A source/model override. Omitted fields inherit that source's defaults. */
|
|
2
|
+
export interface PeakRule {
|
|
3
|
+
windows?: number[];
|
|
4
|
+
holidays?: string[];
|
|
5
|
+
weekendOffPeak?: boolean;
|
|
6
|
+
utcOffsetMinutes?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PeakSchedule {
|
|
9
|
+
version: 2;
|
|
10
|
+
models: Record<string, PeakRule>;
|
|
11
|
+
}
|
|
12
|
+
export interface ScheduleModel {
|
|
13
|
+
source: string;
|
|
14
|
+
model: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ScheduleEdit {
|
|
18
|
+
version: 3;
|
|
19
|
+
changes: Record<string, PeakRule | null>;
|
|
20
|
+
}
|
|
21
|
+
export type ScheduleResults = Record<string, 'accepted' | 'invalidRule' | 'unavailableModel'>;
|
|
22
|
+
export interface RevisionAudit {
|
|
23
|
+
source: 'local-api';
|
|
24
|
+
actor: 'unidentified';
|
|
25
|
+
}
|
|
26
|
+
export interface ScheduleRevision {
|
|
27
|
+
audit?: RevisionAudit;
|
|
28
|
+
effectiveFromMs: number;
|
|
29
|
+
changes: ScheduleEdit['changes'];
|
|
30
|
+
}
|
|
31
|
+
export interface ScheduleHistory {
|
|
32
|
+
version: 3;
|
|
33
|
+
revisions: ScheduleRevision[];
|
|
34
|
+
}
|
|
35
|
+
export type ScheduleNoticeCode = 'legacySchedule' | 'unreadableSchedule' | 'malformedSchedule' | 'malformedRevision' | 'malformedRule' | 'ineligibleModel' | 'discoveryFailed';
|
|
36
|
+
export interface ScheduleNotice {
|
|
37
|
+
code: ScheduleNoticeCode;
|
|
38
|
+
detail?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ScheduleSnapshot {
|
|
41
|
+
effectiveFromMs?: number;
|
|
42
|
+
results?: ScheduleResults;
|
|
43
|
+
config: PeakSchedule;
|
|
44
|
+
models: ScheduleModel[];
|
|
45
|
+
notices?: ScheduleNotice[];
|
|
46
|
+
}
|
|
47
|
+
export declare const emptySchedule: () => PeakSchedule;
|
|
48
|
+
export declare const scheduleKey: (source: string, model: string) => string;
|
|
49
|
+
export declare const accountRoute: (id: string) => boolean;
|
|
50
|
+
export declare function validSource(source: string): boolean;
|
|
51
|
+
export declare function parseRule(value: unknown): PeakRule;
|
|
52
|
+
export declare function parseSchedule(value: unknown, eligible: (model: string) => boolean): PeakSchedule;
|
|
53
|
+
export declare function modelFromScheduleKey(key: string): string;
|
|
54
|
+
export declare function partitionScheduleEdit(value: unknown, allowed: (key: string, model: string) => boolean): {
|
|
55
|
+
edit: ScheduleEdit;
|
|
56
|
+
results: ScheduleResults;
|
|
57
|
+
};
|
|
58
|
+
export declare function parseScheduleEdit(value: unknown): ScheduleEdit;
|
|
59
|
+
export declare function readScheduleHistory(value: unknown): {
|
|
60
|
+
history: ScheduleHistory;
|
|
61
|
+
notices: ScheduleNotice[];
|
|
62
|
+
};
|
|
63
|
+
export declare const TIER_BOUNDARY_MINUTES: readonly [540, 720, 840, 1080];
|
|
64
|
+
export declare const officialHolidays = "20260925 20260926 20260927 20261001 20261002 20261003 20261004 20261005 20261006 20261007";
|
|
65
|
+
export declare function effectiveRule(source: string, rule: PeakRule): Required<PeakRule>;
|
|
66
|
+
export declare function customTier(time: number, rule: Required<PeakRule>): 'peak' | 'offPeak';
|
|
67
|
+
//# sourceMappingURL=peak-schedule.d.ts.map
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* the built-in catalog). An absent field means the built-in value still
|
|
5
5
|
* applies — the dashboard degrades to the catalog, never to fabricated data.
|
|
6
6
|
*/
|
|
7
|
+
export interface PricingModel {
|
|
8
|
+
key: string;
|
|
9
|
+
name: string;
|
|
10
|
+
route: string;
|
|
11
|
+
channel: string;
|
|
12
|
+
origin: string;
|
|
13
|
+
}
|
|
7
14
|
/** One model's unit prices as reported by the router, in USD per 1M tokens. */
|
|
8
15
|
export interface LivePrice {
|
|
9
16
|
/** Uncached input price per 1M tokens. */
|
|
@@ -12,6 +19,12 @@ export interface LivePrice {
|
|
|
12
19
|
cacheHit: number;
|
|
13
20
|
/** Output price per 1M tokens. */
|
|
14
21
|
output: number;
|
|
22
|
+
/**
|
|
23
|
+
* 缓存写入单价(每百万 token,issue #123):厂商对「写入缓存」单独计价时给出
|
|
24
|
+
* (models.dev 原生 `cache_write`)。**缺省 = 按 `input` 价计**——上游未声明
|
|
25
|
+
* 时不猜(与 `cacheHit` 的声明优先口径一致)。
|
|
26
|
+
*/
|
|
27
|
+
cacheWrite?: number;
|
|
15
28
|
}
|
|
16
29
|
/** Response of `/api/billing/pricing` consumed by the dashboard. */
|
|
17
30
|
export interface LivePricing {
|
|
@@ -46,8 +59,65 @@ export interface ExtraModelPrice {
|
|
|
46
59
|
* `invalid` 表示上游返回 2xx 但响应结构偏离预期(接口改版/漂移),
|
|
47
60
|
* 与"网络不可达"(unreachable)区分,便于定位是上游变更还是网络问题。 */
|
|
48
61
|
export type BalanceError = 'unconfigured' | 'unauthorized' | 'unreachable' | 'invalid';
|
|
62
|
+
/** Metadata from the UI making the balance request, for the host login wallet service. */
|
|
63
|
+
export interface BalanceClientMetadata {
|
|
64
|
+
version: string;
|
|
65
|
+
locale: string;
|
|
66
|
+
timezoneOffsetSeconds: number;
|
|
67
|
+
}
|
|
68
|
+
export declare const BALANCE_CLIENT_HEADERS: {
|
|
69
|
+
readonly version: "x-dsh-billing-client-version";
|
|
70
|
+
readonly locale: "x-dsh-billing-client-locale";
|
|
71
|
+
readonly timezone: "x-dsh-billing-client-timezone-offset";
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 宿主内置的两条 DeepSeek 通道的路由 id(宿主包 `llm-deepseek-api-key` /
|
|
75
|
+
* `llm-deepseek-account` 注册,`0.1.2-alpha.1` ~ `0.2.3-alpha.3` 全程稳定):
|
|
76
|
+
*
|
|
77
|
+
* - `deepseek-official`:平台 API key 通道,花的是用户自己的 DeepSeek 平台
|
|
78
|
+
* 账户余额(凭据 ref 默认 `DEEPSEEK_API_KEY`);
|
|
79
|
+
* - `deepseek-account`:登录账号通道,花的是宿主登录钱包的余额。
|
|
80
|
+
*
|
|
81
|
+
* 两条通道都**不在 llm-pi-ai 路由表里**(插件自造的 `deepseek` 路由 id 与它们
|
|
82
|
+
* 不同)。钱包归属必须按宿主通道 id 认,否则内置通道的用量桶认不到任何钱包
|
|
83
|
+
* (issue #141:悬浮卡显示「余额不可确认」)。
|
|
84
|
+
*/
|
|
85
|
+
export declare const DEEPSEEK_PLATFORM_ROUTE = "deepseek-official";
|
|
86
|
+
export declare const DEEPSEEK_LOGIN_ROUTE = "deepseek-account";
|
|
87
|
+
/** Wire format shared by the aggregation buckets and their consumers. */
|
|
88
|
+
export type SiteKind = 'site' | 'direct' | 'unknown';
|
|
89
|
+
export interface SiteRef {
|
|
90
|
+
kind: SiteKind;
|
|
91
|
+
origin?: string;
|
|
92
|
+
provider: string;
|
|
93
|
+
}
|
|
94
|
+
export declare function siteBucketKey(ref: SiteRef): string;
|
|
95
|
+
type SiteKeyParts = {
|
|
96
|
+
kind: 'site';
|
|
97
|
+
origin: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: 'direct';
|
|
100
|
+
route: string;
|
|
101
|
+
} | {
|
|
102
|
+
kind: 'unknown';
|
|
103
|
+
};
|
|
104
|
+
export declare function siteKeyParts(siteKey: string): SiteKeyParts;
|
|
105
|
+
/** New servers declare coverage explicitly, including for errors. Legacy rows need an exact route or alias. */
|
|
106
|
+
export declare function balanceCoversSite(row: ProviderBalance, siteKey: string): boolean;
|
|
49
107
|
/** 一个提供方的账户余额(`/api/billing/balance` 的一行)。 */
|
|
50
108
|
export interface ProviderBalance {
|
|
109
|
+
/** Actual direct route ID (without `direct:`), including on failures. */
|
|
110
|
+
sourceRoute?: string;
|
|
111
|
+
/** Wallet type, independent of the queried route. */
|
|
112
|
+
walletKind?: 'api-key' | 'account' | 'relay';
|
|
113
|
+
/** Routes whose usage this wallet can cover. An explicit empty list means none. */
|
|
114
|
+
attributedRoutes?: readonly string[];
|
|
115
|
+
/** Explicitly verified same-wallet route IDs, separate from the actual queried route. */
|
|
116
|
+
sourceRouteAliases?: readonly string[];
|
|
117
|
+
/** Exact site origin where this is the uniquely identified wallet. */
|
|
118
|
+
sourceOrigin?: string;
|
|
119
|
+
/** 登录钱包缺席的具体原因(宿主没提供登录服务 / 缺元数据 / 未登录)。 */
|
|
120
|
+
accountState?: 'no-service' | 'no-metadata' | 'signed-out';
|
|
51
121
|
/** 提供方 id(小写,如 `deepseek`),与模型表 provider 匹配用。 */
|
|
52
122
|
provider: string;
|
|
53
123
|
/** 显示名(如 `DeepSeek`)。 */
|
|
@@ -56,6 +126,11 @@ export interface ProviderBalance {
|
|
|
56
126
|
currency?: string;
|
|
57
127
|
/** 总可用余额(含赠金与充值)。 */
|
|
58
128
|
totalBalance?: number;
|
|
129
|
+
/** 独立币种的钱包余额,不与主余额相加。 */
|
|
130
|
+
otherBalances?: readonly {
|
|
131
|
+
currency: string;
|
|
132
|
+
totalBalance: number;
|
|
133
|
+
}[];
|
|
59
134
|
/** 未过期赠金余额。 */
|
|
60
135
|
grantedBalance?: number;
|
|
61
136
|
/** 充值余额。 */
|
|
@@ -113,8 +188,10 @@ export interface SubscriptionWindow {
|
|
|
113
188
|
}
|
|
114
189
|
/** One provider's subscription plan quota row. */
|
|
115
190
|
export interface SubscriptionQuota {
|
|
116
|
-
/**
|
|
191
|
+
/** Exact provider route ID. */
|
|
117
192
|
provider: string;
|
|
193
|
+
/** Exact normalized origin when this is the only configured route at the site. */
|
|
194
|
+
origin?: string;
|
|
118
195
|
/** Human display name (e.g. Kimi For Coding). */
|
|
119
196
|
displayName: string;
|
|
120
197
|
/** Plan label; absent when the provider did not name one. */
|
|
@@ -145,6 +222,8 @@ export interface RelayQuota {
|
|
|
145
222
|
route: string;
|
|
146
223
|
/** 站点 origin(baseURL 归一化)。 */
|
|
147
224
|
origin: string;
|
|
225
|
+
/** More than one configured route shares this origin, even if only one was queried. */
|
|
226
|
+
sourceAmbiguous?: true;
|
|
148
227
|
/** 站点显示名。 */
|
|
149
228
|
displayName: string;
|
|
150
229
|
kind: RelayKind;
|
|
@@ -272,4 +351,5 @@ export interface DeclaredEndpointConfig {
|
|
|
272
351
|
/** 滚动额度窗口列表。 */
|
|
273
352
|
windows?: readonly DeclaredWindowConfig[];
|
|
274
353
|
}
|
|
354
|
+
export {};
|
|
275
355
|
//# sourceMappingURL=pricing-shared.d.ts.map
|
package/lib/types/reconcile.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* 纯函数:输入上一基准与本次余额查询结果,输出新基准与对账事件,可独立单测。
|
|
11
11
|
*/
|
|
12
|
+
import type { UsageStatsDocument } from './aggregate.ts';
|
|
12
13
|
/** 对账基准快照:上次余额查询时的官方账户状态,用于反推当日消费。 */
|
|
13
14
|
export interface BalanceRef {
|
|
14
15
|
/** 本地日期键(YYYY-MM-DD)。 */
|
|
@@ -23,7 +24,15 @@ export interface BalanceRef {
|
|
|
23
24
|
currency: string;
|
|
24
25
|
/** 打基准时刻(epoch ms)。 */
|
|
25
26
|
at: number;
|
|
27
|
+
source?: string;
|
|
28
|
+
costAtBaseline?: number;
|
|
26
29
|
}
|
|
30
|
+
/** The daily official aggregate also includes other deepseek-* routes, the official
|
|
31
|
+
* origin (possibly shared), and web search (estimated cost, separate credentials).
|
|
32
|
+
* Require complete site coverage and exclude unrelated routes before comparing. */
|
|
33
|
+
export declare function platformSpend(doc: UsageStatsDocument, day: string, providers: Readonly<Record<string, {
|
|
34
|
+
baseURL?: string;
|
|
35
|
+
}>>, allowDirect?: boolean): number | undefined;
|
|
27
36
|
/** 一次对账的结果类别。 */
|
|
28
37
|
export type ReconcileKind = 'baseline' | 'structure-reset' | 'flat' | 'ok' | 'drift';
|
|
29
38
|
/** 对账事件:`ok`/`drift`/`flat` 携带有意义的结果,`baseline`/`structure-reset` 仅为无消费的基准刷新。 */
|
|
@@ -52,9 +61,9 @@ interface BalanceSnapshot {
|
|
|
52
61
|
* @param todayOfficialCost - 本地账本当日的官方渠道费用(CNY)。
|
|
53
62
|
* @param dayKey - 本地日期键(YYYY-MM-DD)。
|
|
54
63
|
* @param nowMs - 当前时刻(epoch ms)。
|
|
55
|
-
* @returns 新基准与对账事件;余额不可用(无 totalBalance)时返回 `{ ref:
|
|
64
|
+
* @returns 新基准与对账事件;余额不可用(无 totalBalance)时返回 `{ ref: null, event: null }`。
|
|
56
65
|
*/
|
|
57
|
-
export declare function reconcileBalanceDelta(prevRef: BalanceRef | null, balance: BalanceSnapshot, todayOfficialCost: number, dayKey: string, nowMs: number): {
|
|
66
|
+
export declare function reconcileBalanceDelta(prevRef: BalanceRef | null, balance: BalanceSnapshot, todayOfficialCost: number, dayKey: string, nowMs: number, source?: string): {
|
|
58
67
|
ref: BalanceRef | null;
|
|
59
68
|
event: ReconcileEvent | null;
|
|
60
69
|
};
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* `cached()` 与 `refreshOnce()` 拿到结果。
|
|
13
13
|
*/
|
|
14
14
|
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
-
import type {
|
|
15
|
+
import type { IncomingMessage } from 'node:http';
|
|
16
|
+
import { type BalanceClientMetadata, type ProviderBalance } from '../pricing-shared.ts';
|
|
16
17
|
import type { ReconcileEvent } from '../reconcile.ts';
|
|
17
18
|
/** 余额响应体形状(来自装配器 `balanceCache.doc`)。 */
|
|
18
19
|
export interface BalanceDoc {
|
|
@@ -32,9 +33,9 @@ interface CachedBalance {
|
|
|
32
33
|
export interface BalanceDeps {
|
|
33
34
|
trustedHosts: ReadonlySet<string>;
|
|
34
35
|
/** 装配器内缓存 + 时间戳(`Date.now()`)。 */
|
|
35
|
-
cached: () => CachedBalance;
|
|
36
|
+
cached: (client?: BalanceClientMetadata) => CachedBalance;
|
|
36
37
|
/** in-flight 去重的刷新入口。 */
|
|
37
|
-
refreshOnce: () => Promise<void>;
|
|
38
|
+
refreshOnce: (client?: BalanceClientMetadata) => Promise<void>;
|
|
38
39
|
/** 5 分钟缓存间隔(毫秒)。 */
|
|
39
40
|
cacheMs: number;
|
|
40
41
|
/**
|
|
@@ -48,6 +49,8 @@ export interface BalanceDeps {
|
|
|
48
49
|
*/
|
|
49
50
|
responseBudgetMs: number;
|
|
50
51
|
}
|
|
52
|
+
/** Loopback callers can supply these advisory UI headers. */
|
|
53
|
+
export declare function readClientMetadata(headers: IncomingMessage['headers']): BalanceClientMetadata | undefined;
|
|
51
54
|
export declare function registerBalanceRoute(ctx: Context, deps: BalanceDeps): void;
|
|
52
55
|
export {};
|
|
53
56
|
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ScheduleSnapshot } from '../peak-schedule.ts';
|
|
3
|
+
export interface PeakScheduleDeps {
|
|
4
|
+
trustedHosts: ReadonlySet<string>;
|
|
5
|
+
read: () => Promise<ScheduleSnapshot>;
|
|
6
|
+
save: (raw: unknown) => Promise<ScheduleSnapshot>;
|
|
7
|
+
}
|
|
8
|
+
/** Domain validation failures are distinct from storage failures. */
|
|
9
|
+
export declare class PeakScheduleInputError extends Error {
|
|
10
|
+
}
|
|
11
|
+
export declare function registerPeakScheduleRoute(ctx: Context, deps: PeakScheduleDeps): void;
|
|
12
|
+
//# sourceMappingURL=peak-schedule.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { PricingModel } from '../pricing-shared.ts';
|
|
3
|
+
type PricingModelsResult = {
|
|
4
|
+
models: PricingModel[];
|
|
5
|
+
partial: boolean;
|
|
6
|
+
};
|
|
7
|
+
/** Static settings remain authoritative even when the registry is unavailable. */
|
|
8
|
+
export declare function configuredPricingModels(ctx: Context): Promise<PricingModelsResult>;
|
|
9
|
+
export declare function registerPricingModelsRoute(ctx: Context, trustedHosts: ReadonlySet<string>): void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=pricing-models.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 低谷队列的**按来源判档**(issue #143)。
|
|
3
|
+
*
|
|
4
|
+
* 背景:报告者实测发现两件事——①订阅通道(如 `dsh-opencode-go`)确实有峰谷
|
|
5
|
+
* 倍率(其模型目录里 `deepseek-v4.1-flash` / `deepseek-v4-pro` 在 UTC 周一至
|
|
6
|
+
* 周五 01:00–04:00 / 06:00–10:00 时 `factor: 2`,其余为 1,即北京时间
|
|
7
|
+
* 09:00–12:00 / 14:00–18:00 倍率 2);②插件的「按模型配峰谷时段」已经能让
|
|
8
|
+
* 订阅通道的模型进入配置(`eligibleScheduleModel` 只要求目录里有 offPeak 价),
|
|
9
|
+
* 但低谷队列此前**硬过滤官方路由**且用全局 `tierAt` 判档——用户配了、计费认了、
|
|
10
|
+
* 队列不认。
|
|
11
|
+
*
|
|
12
|
+
* 本模块把「某个来源 × 某个模型此刻处于哪一档」收敛成一处判定,供队列的
|
|
13
|
+
* 候选筛选、启动闸门与展示共用(**同一件事不许两处各写一套**)。
|
|
14
|
+
*
|
|
15
|
+
* 两条纪律:
|
|
16
|
+
* 1. **来源桶与聚合层同源**——`site:` / `direct:` 的映射由调用方注入(用
|
|
17
|
+
* `siteRefOf` + `siteBucketKey`),本模块不自己猜,避免队列与计费对同一
|
|
18
|
+
* 条路由得出两个来源桶。
|
|
19
|
+
* 2. **窗口语义分列**——官方按量通道的谷档省**现金**,订阅通道的谷段省**套餐
|
|
20
|
+
* 额度**(倍率 2→1)。两者窗口数值可能相同,但省的东西不同;界面必须分开
|
|
21
|
+
* 表述,混说就是假声明。
|
|
22
|
+
*/
|
|
23
|
+
import { type PeakRule, type PeakSchedule } from './peak-schedule.ts';
|
|
24
|
+
import { type PriceTierId } from './client/pricing.ts';
|
|
25
|
+
import type { TaskQueueSaving } from './task-queue-shared.ts';
|
|
26
|
+
/**
|
|
27
|
+
* 一条路由的通道属性。
|
|
28
|
+
*
|
|
29
|
+
* - `source`:来源桶键(`direct:<route>` / `site:<origin>`),与聚合层、峰谷
|
|
30
|
+
* 设置页同一套映射;
|
|
31
|
+
* - `saving`:该通道「省」什么——官方按量省现金,订阅通道省套餐额度。
|
|
32
|
+
*/
|
|
33
|
+
export interface RouteChannel {
|
|
34
|
+
readonly source: string;
|
|
35
|
+
readonly saving: TaskQueueSaving;
|
|
36
|
+
}
|
|
37
|
+
/** 判档所需的最小事实面。 */
|
|
38
|
+
export interface BandFacts {
|
|
39
|
+
/** 该路由的来源桶与「省什么」。 */
|
|
40
|
+
readonly channel: RouteChannel | undefined;
|
|
41
|
+
/** 用户配置的模型级规则(按 `scheduleKey(source, model)` 查)。 */
|
|
42
|
+
readonly schedule: PeakSchedule | undefined;
|
|
43
|
+
/** 目录键(归一后的模型 key),与峰谷设置页存规则的键一致。 */
|
|
44
|
+
readonly catalogKey: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 用户为该来源 × 模型配置的规则(未配置则 undefined)。
|
|
48
|
+
*
|
|
49
|
+
* @param facts - 判档事实。
|
|
50
|
+
* @returns 命中的规则,未命中时 undefined。
|
|
51
|
+
*/
|
|
52
|
+
export declare function ruleOf(facts: BandFacts): PeakRule | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* 某来源 × 某模型此刻处于哪一档。
|
|
55
|
+
*
|
|
56
|
+
* 判定顺序:
|
|
57
|
+
* 1. 用户配了该来源 × 模型的时段 → 用它(`effectiveRule` 补齐该来源的缺省:
|
|
58
|
+
* 窗口、周末、时区;官方来源另补中国法定节假日);
|
|
59
|
+
* 2. 未配 → 官方来源走全局 `tierAt`(含节假日),订阅来源走**同一组官方窗口
|
|
60
|
+
* 但不含中国节假日**——订阅厂商的倍率表里没有中国节假日这一项,套上去会
|
|
61
|
+
* 把本该计倍率的时段误判成低谷。
|
|
62
|
+
*
|
|
63
|
+
* @param facts - 判档事实。
|
|
64
|
+
* @param at - 判定时刻(epoch ms)。
|
|
65
|
+
* @returns `peak` / `offPeak`。
|
|
66
|
+
*/
|
|
67
|
+
export declare function tierOf(facts: BandFacts, at: number): PriceTierId;
|
|
68
|
+
/**
|
|
69
|
+
* 该来源 × 模型距离下一次档位切换还有多久(毫秒)。
|
|
70
|
+
*
|
|
71
|
+
* 复用客户端同源的倒计时实现(`scheduledCountdown`)——它已按「自定义规则」
|
|
72
|
+
* 算切换点(含周末与节假日例外),与面板里显示的倒计时是同一份逻辑,不会
|
|
73
|
+
* 出现「面板说还有 5 分钟、队列说还有 1 小时」的分裂。
|
|
74
|
+
*
|
|
75
|
+
* @param facts - 判档事实。
|
|
76
|
+
* @param at - 判定时刻(epoch ms)。
|
|
77
|
+
* @returns 距下次切换的毫秒数;无未来切换点时为 `Infinity`。
|
|
78
|
+
*/
|
|
79
|
+
export declare function nextSwitchMsOf(facts: BandFacts, at: number): number;
|
|
80
|
+
//# sourceMappingURL=task-queue-band.d.ts.map
|