dsh-notify-tray 0.1.11 → 0.1.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.
- package/README.en.md +9 -9
- package/README.md +9 -9
- package/README.zh-CN.md +9 -9
- package/assets/mascot-peeking.prompt.txt +6 -6
- package/assets/notify-icon.png +0 -0
- package/assets/tray-darwin.js +283 -283
- package/cordis.patch.yml +6 -6
- package/lib/ToastActivator.cs +33 -0
- package/lib/catalog.js +448 -448
- package/lib/client.js +65 -132
- package/lib/format.js +284 -284
- package/lib/host/context.js +11 -3
- package/lib/host/notify.js +26 -21
- package/lib/host/routes.js +9 -42
- package/lib/host/spend.js +190 -190
- package/lib/host/tray.js +120 -120
- package/lib/icon.js +159 -159
- package/lib/index.js +2 -7
- package/lib/ledger.js +285 -285
- package/lib/models-dev.json +2684 -2684
- package/lib/notices.js +3 -4
- package/lib/pricing.js +302 -302
- package/lib/quota.js +290 -290
- package/lib/system.js +11 -22
- package/lib/tracker.js +250 -250
- package/lib/tray/index.js +142 -142
- package/lib/tray/linux.js +393 -393
- package/lib/voice.js +76 -76
- package/lib/whale.js +396 -396
- package/lib/windows-toast.js +92 -0
- package/locale/en.json +7 -7
- package/locale/zh.json +7 -7
- package/package.json +2 -1
package/lib/catalog.js
CHANGED
|
@@ -1,448 +1,448 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plan + price catalog: the subscriptions and API list prices of the
|
|
3
|
-
* providers people plug into DeepSeek Harness, plus which quota endpoint
|
|
4
|
-
* each one exposes to an API key.
|
|
5
|
-
*
|
|
6
|
-
* Pure data + helpers, no DSH imports (shared by the host, the browser half
|
|
7
|
-
* through `GET notify-tray/catalog`, and the tests). Prices are per million
|
|
8
|
-
* tokens in the row's own currency. Plan prices are list prices at the time
|
|
9
|
-
* of writing — the settings page lets the user overwrite every figure.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/** DSH provider route names (pi-ai ids and the built-in DeepSeek routes) → catalog provider id. */
|
|
13
|
-
const ROUTE_MAP = {
|
|
14
|
-
deepseek: 'deepseek',
|
|
15
|
-
'deepseek-account': 'deepseek',
|
|
16
|
-
'deepseek-api-key': 'deepseek',
|
|
17
|
-
'deepseek-official': 'deepseek',
|
|
18
|
-
'kimi-coding': 'kimi',
|
|
19
|
-
moonshotai: 'kimi',
|
|
20
|
-
'moonshotai-cn': 'kimi',
|
|
21
|
-
zai: 'glm',
|
|
22
|
-
'zai-coding-cn': 'glm',
|
|
23
|
-
opencode: 'opencode',
|
|
24
|
-
'opencode-go': 'opencode',
|
|
25
|
-
xiaomi: 'mimo',
|
|
26
|
-
'xiaomi-token-plan-cn': 'mimo',
|
|
27
|
-
'xiaomi-token-plan-sgp': 'mimo',
|
|
28
|
-
'xiaomi-token-plan-ams': 'mimo',
|
|
29
|
-
google: 'gemini',
|
|
30
|
-
'google-vertex': 'gemini',
|
|
31
|
-
xai: 'grok',
|
|
32
|
-
anthropic: 'claude',
|
|
33
|
-
openai: 'gpt',
|
|
34
|
-
'openai-codex': 'gpt',
|
|
35
|
-
minimax: 'minimax',
|
|
36
|
-
'minimax-cn': 'minimax',
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const PERIOD_LABEL = { month: '月', year: '年', week: '周', once: '次', free: '' }
|
|
40
|
-
const SYMBOL = { CNY: '¥', USD: '$' }
|
|
41
|
-
|
|
42
|
-
const P = (input, cacheRead, output, name, extra = {}) => ({ input, cacheRead, output, name, ...extra })
|
|
43
|
-
const plan = (id, name, price, currency, period, quotaText, extra = {}) => ({ id, name, price, currency, period, quotaText, ...extra })
|
|
44
|
-
|
|
45
|
-
export const PROVIDERS = [
|
|
46
|
-
{
|
|
47
|
-
id: 'deepseek',
|
|
48
|
-
name: 'DeepSeek',
|
|
49
|
-
home: 'CNY',
|
|
50
|
-
pricingUrl: 'https://api-docs.deepseek.com/zh-cn/quick_start/pricing',
|
|
51
|
-
consoleUrl: 'https://platform.deepseek.com/usage',
|
|
52
|
-
prices: {
|
|
53
|
-
// 高峰价(北京时间工作日 9–12、14–18 点);空闲时段减半。
|
|
54
|
-
'deepseek-flash': P(2, 0.04, 8, 'DeepSeek V4.1 Flash', { currency: 'CNY' }),
|
|
55
|
-
'deepseek-v4.1-flash': P(2, 0.04, 8, 'DeepSeek V4.1 Flash', { currency: 'CNY' }),
|
|
56
|
-
'deepseek-v4-flash': P(2, 0.04, 8, 'DeepSeek V4 Flash', { currency: 'CNY' }),
|
|
57
|
-
'deepseek-v4-pro': P(9, 0.3, 27, 'DeepSeek V4 Pro', { currency: 'CNY' }),
|
|
58
|
-
'deepseek-chat': P(2, 0.04, 8, 'deepseek-chat', { currency: 'CNY' }),
|
|
59
|
-
'deepseek-reasoner': P(9, 0.3, 27, 'deepseek-reasoner', { currency: 'CNY' }),
|
|
60
|
-
},
|
|
61
|
-
plans: [
|
|
62
|
-
plan('payg', '按量付费(充值余额)', 0, 'CNY', 'free', '按 token 计费,高峰 / 空闲时段价格不同;余额用完即止'),
|
|
63
|
-
],
|
|
64
|
-
quota: { kind: 'deepseek-balance', url: 'https://api.deepseek.com/user/balance', auth: 'bearer' },
|
|
65
|
-
keyEnv: 'DEEPSEEK_API_KEY',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
id: 'kimi',
|
|
69
|
-
name: 'Kimi(月之暗面)',
|
|
70
|
-
home: 'CNY',
|
|
71
|
-
pricingUrl: 'https://www.kimi.com/help/membership/membership-pricing',
|
|
72
|
-
consoleUrl: 'https://www.kimi.com/code/console',
|
|
73
|
-
prices: {
|
|
74
|
-
'kimi-k3.1-pro': P(13, 1.3, 68, 'Kimi K3.1 Pro', { currency: 'CNY' }),
|
|
75
|
-
'kimi-k3.1-pro-highspeed': P(26, 1.3, 136, 'Kimi K3.1 Pro HighSpeed', { currency: 'CNY' }),
|
|
76
|
-
'kimi-k3': P(20, 2, 100, 'Kimi K3', { currency: 'CNY' }),
|
|
77
|
-
'kimi-k2.7-code': P(6.5, 1.3, 27, 'Kimi K2.7 Code', { currency: 'CNY' }),
|
|
78
|
-
'kimi-k2.7-code-highspeed': P(13, 2.6, 54, 'Kimi K2.7 Code HighSpeed', { currency: 'CNY' }),
|
|
79
|
-
'kimi-for-coding': P(6.5, 1.3, 27, 'Kimi For Coding', { currency: 'CNY' }),
|
|
80
|
-
},
|
|
81
|
-
plans: [
|
|
82
|
-
plan('cn-go', 'Kimi 会员 Go', 49, 'CNY', 'month', '不含 Kimi Code;年付 ¥468'),
|
|
83
|
-
plan('cn-plus', 'Kimi 会员 Plus(含 Kimi Code)', 99, 'CNY', 'month', 'Kimi Code 5 小时滚动窗口 + 月度共享额度池;年付 ¥948'),
|
|
84
|
-
plan('cn-pro', 'Kimi 会员 Pro', 199, 'CNY', 'month', 'Agent 额度 2 倍;含 1M 上下文与 HighSpeed;年付 ¥1908'),
|
|
85
|
-
plan('cn-max', 'Kimi 会员 Max', 699, 'CNY', 'month', 'Agent 额度 5 倍;年付 ¥6708'),
|
|
86
|
-
plan('cn-ultra', 'Kimi 会员 Ultra', 1399, 'CNY', 'month', 'Agent 额度 10 倍;年付 ¥13428'),
|
|
87
|
-
plan('intl-plus', 'Kimi Plus(国际)', 19, 'USD', 'month', 'Kimi Code 5 小时滚动窗口 + 月度共享额度池;年付 $180'),
|
|
88
|
-
plan('intl-pro', 'Kimi Pro(国际)', 39, 'USD', 'month', 'Agent 额度 2 倍;年付 $372'),
|
|
89
|
-
plan('intl-max', 'Kimi Max(国际)', 99, 'USD', 'month', 'Agent 额度 5 倍;年付 $948'),
|
|
90
|
-
plan('intl-ultra', 'Kimi Ultra(国际)', 199, 'USD', 'month', 'Agent 额度 10 倍;年付 $1908'),
|
|
91
|
-
plan('legacy', '旧版 Kimi Code(Andante / Moderato / Allegretto / Allegro / Vivace)', 0, 'CNY', 'month', '每 5 小时滚动窗口 + 每 7 天周额度;价格请手填'),
|
|
92
|
-
plan('payg', 'Moonshot 开放平台 按量付费', 0, 'CNY', 'free', '按 token 计费', { quotaApi: { kind: 'moonshot-balance', url: 'https://api.moonshot.cn/v1/users/me/balance', auth: 'bearer' } }),
|
|
93
|
-
],
|
|
94
|
-
// Kimi Code's usage endpoint takes the Kimi Code OAuth access token (~/.kimi/credentials/kimi-code.json), not a Moonshot API key.
|
|
95
|
-
quota: { kind: 'kimi-usage', url: 'https://api.kimi.com/coding/v1/usages', auth: 'bearer' },
|
|
96
|
-
keyEnv: 'KIMI_CODE_TOKEN',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: 'glm',
|
|
100
|
-
name: 'GLM(智谱 / Z.ai)',
|
|
101
|
-
home: 'CNY',
|
|
102
|
-
pricingUrl: 'https://docs.bigmodel.cn/cn/coding-plan/overview',
|
|
103
|
-
consoleUrl: 'https://bigmodel.cn/usercenter/resourcepack',
|
|
104
|
-
prices: {
|
|
105
|
-
'glm-5.3': P(8, 2, 28, 'GLM-5.3', { currency: 'CNY' }),
|
|
106
|
-
'glm-5.3-flash': P(0.8, 0.23, 2.8, 'GLM-5.3-Flash', { currency: 'CNY' }),
|
|
107
|
-
'glm-5.3-flashx': P(2, 0.57, 7, 'GLM-5.3-FlashX', { currency: 'CNY' }),
|
|
108
|
-
'glm-5.2': P(8, 2, 28, 'GLM-5.2', { currency: 'CNY' }),
|
|
109
|
-
'glm-4.7': P(0.6, 0.11, 2.2, 'GLM-4.7', { currency: 'USD' }),
|
|
110
|
-
},
|
|
111
|
-
plans: [
|
|
112
|
-
plan('lite-cny', 'GLM Coding Plan · Lite', 118, 'CNY', 'month', '每 5 小时 2000 积分 / 每周 10000 积分'),
|
|
113
|
-
plan('pro-cny', 'GLM Coding Plan · Pro', 538, 'CNY', 'month', '每 5 小时 12000 积分 / 每周 60000 积分'),
|
|
114
|
-
plan('max-cny', 'GLM Coding Plan · Max', 1078, 'CNY', 'month', '每 5 小时 28000 积分 / 每周 140000 积分'),
|
|
115
|
-
plan('lite-usd', 'GLM Coding Plan · Lite(Z.ai)', 18, 'USD', 'month', '2000 credits / 5 h · 10000 credits / week', { quotaApi: { kind: 'zai-quota', url: 'https://api.z.ai/api/monitor/usage/quota/limit', auth: 'bearer' } }),
|
|
116
|
-
plan('pro-usd', 'GLM Coding Plan · Pro(Z.ai)', 80, 'USD', 'month', '12000 credits / 5 h · 60000 credits / week', { quotaApi: { kind: 'zai-quota', url: 'https://api.z.ai/api/monitor/usage/quota/limit', auth: 'bearer' } }),
|
|
117
|
-
plan('max-usd', 'GLM Coding Plan · Max(Z.ai)', 168, 'USD', 'month', '28000 credits / 5 h · 140000 credits / week', { quotaApi: { kind: 'zai-quota', url: 'https://api.z.ai/api/monitor/usage/quota/limit', auth: 'bearer' } }),
|
|
118
|
-
plan('payg', '按量付费', 0, 'CNY', 'free', '按 token 计费'),
|
|
119
|
-
],
|
|
120
|
-
quota: { kind: 'zai-quota', url: 'https://open.bigmodel.cn/api/monitor/usage/quota/limit', auth: 'bearer' },
|
|
121
|
-
keyEnv: 'ZAI_API_KEY',
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: 'opencode',
|
|
125
|
-
name: 'OpenCode(Zen / Go)',
|
|
126
|
-
home: 'USD',
|
|
127
|
-
pricingUrl: 'https://opencode.ai/docs/zen/',
|
|
128
|
-
consoleUrl: 'https://opencode.ai/console',
|
|
129
|
-
prices: {
|
|
130
|
-
'claude-opus-5-5': P(4, 0.2, 20, 'Claude Opus 5.5 (Zen)', { currency: 'USD' }),
|
|
131
|
-
'gpt-6.1-sol': P(2, 0.1, 10, 'GPT 6.1 Sol (Zen)', { currency: 'USD' }),
|
|
132
|
-
'kimi-k3.1-pro': P(2, 0.2, 10, 'Kimi K3.1 Pro (Zen / Go)', { currency: 'USD' }),
|
|
133
|
-
'glm-5.3': P(1.4, 0.26, 4.4, 'GLM 5.3 (Zen / Go)', { currency: 'USD' }),
|
|
134
|
-
'glm-5.3-flash': P(0.15, 0.03, 0.5, 'GLM 5.3 Flash (Zen / Go)', { currency: 'USD' }),
|
|
135
|
-
'minimax-m3': P(0.3, 0.06, 1.2, 'MiniMax M3 (Zen / Go)', { currency: 'USD' }),
|
|
136
|
-
'deepseek-v4.1-flash': P(0.3, 0.006, 1.2, 'DeepSeek V4.1 Flash (Zen / Go)', { currency: 'USD' }),
|
|
137
|
-
},
|
|
138
|
-
plans: [
|
|
139
|
-
plan('go', 'OpenCode Go', 10, 'USD', 'month', '按模型的月度美元额度(如 Kimi K3.1 Pro $15、GLM-5.3-Flash $60、DeepSeek V4.1 Flash $80);5 小时窗口 = 月额度 20%,每周 = 50%'),
|
|
140
|
-
plan('go-plus', 'OpenCode Go Plus', 40, 'USD', 'month', '更高的月度额度(如 Kimi K3.1 Pro $60、GLM-5.3-Flash $180)'),
|
|
141
|
-
plan('zen', 'OpenCode Zen / Console 按量付费', 0, 'USD', 'free', '预充值,按各模型目录价计费'),
|
|
142
|
-
],
|
|
143
|
-
quota: undefined,
|
|
144
|
-
keyEnv: 'OPENCODE_API_KEY',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: 'mimo',
|
|
148
|
-
name: 'MiMo(小米)',
|
|
149
|
-
home: 'CNY',
|
|
150
|
-
pricingUrl: 'https://mimo.mi.com/docs/zh-CN/tokenplan/Token%20Plan/subscription',
|
|
151
|
-
consoleUrl: 'https://platform.xiaomimimo.com/',
|
|
152
|
-
prices: {
|
|
153
|
-
'mimo-v2.6-pro': P(3, 0.025, 6, 'MiMo-V2.6-Pro', { currency: 'CNY' }),
|
|
154
|
-
'mimo-v2.6-flash': P(1, 0.02, 2, 'MiMo-V2.6-Flash', { currency: 'CNY' }),
|
|
155
|
-
'mimo-v2.6-pro-ultraspeed': P(30, 0.25, 60, 'MiMo-V2.6-Pro UltraSpeed', { currency: 'CNY' }),
|
|
156
|
-
'mimo-v2.5-pro': P(3, 0.025, 6, 'MiMo-V2.5-Pro', { currency: 'CNY' }),
|
|
157
|
-
'mimo-v2.5': P(1, 0.02, 2, 'MiMo-V2.5', { currency: 'CNY' }),
|
|
158
|
-
},
|
|
159
|
-
plans: [
|
|
160
|
-
plan('lite', 'MiMo Token Plan · Lite', 39, 'CNY', 'month', '每月 41 亿 Credits(≈ 200 轮);$6/月;夜间 0–8 点 0.8 倍计费'),
|
|
161
|
-
plan('standard', 'MiMo Token Plan · Standard', 99, 'CNY', 'month', '每月 110 亿 Credits(≈ 1600 轮);$16/月'),
|
|
162
|
-
plan('pro', 'MiMo Token Plan · Pro', 329, 'CNY', 'month', '每月 380 亿 Credits(≈ 5600 轮);$50/月'),
|
|
163
|
-
plan('max', 'MiMo Token Plan · Max', 659, 'CNY', 'month', '每月 820 亿 Credits(≈ 12800 轮);$100/月;耗尽即停'),
|
|
164
|
-
plan('payg', '按量付费', 0, 'CNY', 'free', '按 token 计费'),
|
|
165
|
-
],
|
|
166
|
-
// The Token Plan usage API only answers to a console session cookie, not a tp-… key.
|
|
167
|
-
quota: undefined,
|
|
168
|
-
keyEnv: 'XIAOMI_API_KEY',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
id: 'gemini',
|
|
172
|
-
name: 'Gemini(Google)',
|
|
173
|
-
home: 'USD',
|
|
174
|
-
pricingUrl: 'https://ai.google.dev/gemini-api/docs/pricing',
|
|
175
|
-
consoleUrl: 'https://aistudio.google.com/usage',
|
|
176
|
-
prices: {
|
|
177
|
-
'gemini-4-argon': P(2, 0.1, 10, 'Gemini 4 Argon', { currency: 'USD' }),
|
|
178
|
-
'gemini-3.1-pro-preview': P(2, 0.2, 12, 'Gemini 3.1 Pro', { currency: 'USD' }),
|
|
179
|
-
'gemini-3.8-flash': P(0.75, 0.075, 3.75, 'Gemini 3.8 Flash', { currency: 'USD' }),
|
|
180
|
-
'gemini-3.5-flash-lite': P(0.3, 0.03, 2.5, 'Gemini 3.5 Flash-Lite', { currency: 'USD' }),
|
|
181
|
-
'gemini-3-flash-preview': P(0.5, 0.05, 3, 'Gemini 3 Flash', { currency: 'USD' }),
|
|
182
|
-
'gemini-2.5-pro': P(1.25, 0.125, 10, 'Gemini 2.5 Pro', { currency: 'USD' }),
|
|
183
|
-
'gemini-2.5-flash': P(0.3, 0.03, 2.5, 'Gemini 2.5 Flash', { currency: 'USD' }),
|
|
184
|
-
},
|
|
185
|
-
plans: [
|
|
186
|
-
plan('ai-plus', 'Google AI Plus', 7.99, 'USD', 'month', 'Gemini 用量 2 倍;5 小时滚动上限 + 周上限'),
|
|
187
|
-
plan('ai-pro', 'Google AI Pro', 19.99, 'USD', 'month', '用量 4 倍;Gemini 4 Argon / 3.1 Pro;AI Studio 更高限额'),
|
|
188
|
-
plan('ai-ultra', 'Google AI Ultra', 99.99, 'USD', 'month', '最高 20 倍;顶配 $200/月'),
|
|
189
|
-
plan('payg', 'Gemini API 按量付费', 0, 'USD', 'free', '按 token 计费(有免费层)'),
|
|
190
|
-
],
|
|
191
|
-
quota: undefined,
|
|
192
|
-
keyEnv: 'GEMINI_API_KEY',
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
id: 'grok',
|
|
196
|
-
name: 'Grok(xAI)',
|
|
197
|
-
home: 'USD',
|
|
198
|
-
pricingUrl: 'https://docs.x.ai/developers/pricing',
|
|
199
|
-
consoleUrl: 'https://console.x.ai/',
|
|
200
|
-
prices: {
|
|
201
|
-
'grok-4.7': P(2, 0.5, 6, 'Grok 4.7', { currency: 'USD' }),
|
|
202
|
-
'grok-4.6': P(2, 0.5, 6, 'Grok 4.6', { currency: 'USD' }),
|
|
203
|
-
'grok-4.5': P(2, 0.3, 6, 'Grok 4.5', { currency: 'USD' }),
|
|
204
|
-
'grok-4.3': P(1.25, 0.2, 2.5, 'Grok 4.3', { currency: 'USD' }),
|
|
205
|
-
'grok-build-0.1': P(1, 0.2, 2, 'Grok Build 0.1', { currency: 'USD' }),
|
|
206
|
-
},
|
|
207
|
-
plans: [
|
|
208
|
-
plan('supergrok-lite', 'SuperGrok Lite', 10, 'USD', 'month', '入门档'),
|
|
209
|
-
plan('supergrok', 'SuperGrok', 30, 'USD', 'month', '标准档(X Premium+ $40 含同级权益)'),
|
|
210
|
-
plan('supergrok-plus', 'SuperGrok Plus', 100, 'USD', 'month', '更大用量池'),
|
|
211
|
-
plan('supergrok-heavy', 'SuperGrok Heavy', 300, 'USD', 'month', '最高额度 + Heavy 模型'),
|
|
212
|
-
plan('payg', 'xAI API 按量付费', 0, 'USD', 'free', '预充值,按 token 计费'),
|
|
213
|
-
],
|
|
214
|
-
quota: { kind: 'xai-key', url: 'https://api.x.ai/v1/api-key', auth: 'bearer' },
|
|
215
|
-
keyEnv: 'XAI_API_KEY',
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: 'claude',
|
|
219
|
-
name: 'Claude(Anthropic)',
|
|
220
|
-
home: 'USD',
|
|
221
|
-
pricingUrl: 'https://www.anthropic.com/pricing',
|
|
222
|
-
consoleUrl: 'https://platform.claude.com/usage',
|
|
223
|
-
prices: {
|
|
224
|
-
'claude-fable-5-1': P(10, 0.25, 50, 'Claude Fable 5.1', { currency: 'USD', cacheWrite: 12.5 }),
|
|
225
|
-
'claude-fable-5': P(10, 1, 50, 'Claude Fable 5', { currency: 'USD', cacheWrite: 12.5 }),
|
|
226
|
-
'claude-opus-5-5': P(4, 0.2, 20, 'Claude Opus 5.5', { currency: 'USD', cacheWrite: 5 }),
|
|
227
|
-
'claude-opus-4-5': P(5, 0.5, 25, 'Claude Opus 4.5', { currency: 'USD', cacheWrite: 6.25 }),
|
|
228
|
-
'claude-sonnet-5-5': P(2, 0.1, 10, 'Claude Sonnet 5.5', { currency: 'USD', cacheWrite: 2.5 }),
|
|
229
|
-
'claude-haiku-5-5': P(0.1, 0.01, 0.5, 'Claude Haiku 5.5', { currency: 'USD', cacheWrite: 0.125 }),
|
|
230
|
-
'claude-haiku-4-5': P(1, 0.1, 5, 'Claude Haiku 4.5', { currency: 'USD', cacheWrite: 1.25 }),
|
|
231
|
-
},
|
|
232
|
-
plans: [
|
|
233
|
-
plan('pro', 'Claude Pro', 20, 'USD', 'month', '含 Claude Code;每 5 小时滚动额度 + 周上限;年付 $17/月'),
|
|
234
|
-
plan('max-5x', 'Claude Max 5x', 100, 'USD', 'month', 'Pro 的 5 倍(每 5 小时)+ 周上限'),
|
|
235
|
-
plan('max-20x', 'Claude Max 20x', 200, 'USD', 'month', 'Pro 的 20 倍(每 5 小时)+ 周上限'),
|
|
236
|
-
plan('team', 'Claude Team(标准席位)', 25, 'USD', 'month', '每席位;年付 $20/席位'),
|
|
237
|
-
plan('payg', 'Anthropic API 按量付费', 0, 'USD', 'free', '预充值,按 token 计费'),
|
|
238
|
-
],
|
|
239
|
-
quota: undefined,
|
|
240
|
-
keyEnv: 'ANTHROPIC_API_KEY',
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
id: 'gpt',
|
|
244
|
-
name: 'GPT(OpenAI)',
|
|
245
|
-
home: 'USD',
|
|
246
|
-
pricingUrl: 'https://developers.openai.com/api/docs/pricing',
|
|
247
|
-
consoleUrl: 'https://platform.openai.com/usage',
|
|
248
|
-
prices: {
|
|
249
|
-
'gpt-6-astra': P(10, 1, 50, 'GPT-6 Astra', { currency: 'USD', cacheWrite: 12.5 }),
|
|
250
|
-
'gpt-6.1-sol': P(2, 0.1, 10, 'GPT-6.1 Sol', { currency: 'USD', cacheWrite: 2.5 }),
|
|
251
|
-
'gpt-6-sol': P(2, 0.2, 10, 'GPT-6 Sol', { currency: 'USD' }),
|
|
252
|
-
'gpt-6-luna': P(0.1, 0.01, 0.5, 'GPT-6 Luna', { currency: 'USD', cacheWrite: 0.125 }),
|
|
253
|
-
'gpt-5.6-sol': P(4, 0.4, 20, 'GPT-5.6 Sol', { currency: 'USD' }),
|
|
254
|
-
'gpt-4.1': P(2, 0.5, 8, 'GPT-4.1', { currency: 'USD' }),
|
|
255
|
-
},
|
|
256
|
-
plans: [
|
|
257
|
-
plan('go', 'ChatGPT Go', 8, 'USD', 'month', '轻量档,Codex 额度有限'),
|
|
258
|
-
plan('plus', 'ChatGPT Plus', 20, 'USD', 'month', '含 Codex:每 5 小时约 15–160 条(GPT-6.1 Sol)+ 周上限'),
|
|
259
|
-
plan('pro-5x', 'ChatGPT Pro(5x)', 100, 'USD', 'month', 'Codex 用量约 Plus 的 5 倍'),
|
|
260
|
-
plan('pro-20x', 'ChatGPT Pro(20x)', 200, 'USD', 'month', 'Codex 用量约 Plus 的 20 倍'),
|
|
261
|
-
plan('business', 'ChatGPT Business', 25, 'USD', 'month', '每席位(至少 2 个);年付 $20/席位'),
|
|
262
|
-
plan('payg', 'OpenAI API 按量付费', 0, 'USD', 'free', '预充值,按 token 计费'),
|
|
263
|
-
],
|
|
264
|
-
quota: undefined,
|
|
265
|
-
keyEnv: 'OPENAI_API_KEY',
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
id: 'minimax',
|
|
269
|
-
name: 'MiniMax',
|
|
270
|
-
home: 'CNY',
|
|
271
|
-
pricingUrl: 'https://platform.minimax.cn/docs/m-plan/monthly-offer',
|
|
272
|
-
consoleUrl: 'https://platform.minimax.io/console/usage',
|
|
273
|
-
prices: {
|
|
274
|
-
'MiniMax-M3.1-Flash': P(1, 0.1, 4, 'MiniMax M3.1 Flash', { currency: 'CNY' }),
|
|
275
|
-
'MiniMax-M3': P(2.1, 0.42, 8.4, 'MiniMax M3', { currency: 'CNY' }),
|
|
276
|
-
'MiniMax-M2.7': P(2.1, 0.42, 8.4, 'MiniMax M2.7', { currency: 'CNY' }),
|
|
277
|
-
'minimax-m3.1-flash': P(0.15, 0.015, 0.6, 'MiniMax M3.1 Flash', { currency: 'USD' }),
|
|
278
|
-
'minimax-m3': P(0.3, 0.06, 1.2, 'MiniMax M3', { currency: 'USD' }),
|
|
279
|
-
},
|
|
280
|
-
plans: [
|
|
281
|
-
plan('m-go-cn', 'MiniMax M Plan · Go(国内)', 49, 'CNY', 'month', '基础额度 1 倍;M3.1 Flash;5 小时窗口 + 周窗口'),
|
|
282
|
-
plan('m-explore-cn', 'MiniMax M Plan · Explore(国内)', 119, 'CNY', 'month', 'Go 的 3 倍;含 H3 视频'),
|
|
283
|
-
plan('m-build-cn', 'MiniMax M Plan · Build(国内)', 469, 'CNY', 'month', 'Go 的 7.5 倍;超出可买 Credits 包'),
|
|
284
|
-
plan('m-go', 'MiniMax M Plan · Go(国际)', 22, 'USD', 'month', '基础额度 1 倍;5 小时窗口 + 周窗口', { quotaApi: { kind: 'minimax-remains', url: 'https://api.minimax.io/v1/coding_plan/remains', auth: 'bearer' } }),
|
|
285
|
-
plan('m-explore', 'MiniMax M Plan · Explore(国际)', 55, 'USD', 'month', 'Go 的 3 倍', { quotaApi: { kind: 'minimax-remains', url: 'https://api.minimax.io/v1/coding_plan/remains', auth: 'bearer' } }),
|
|
286
|
-
plan('m-build', 'MiniMax M Plan · Build(国际)', 132, 'USD', 'month', 'Go 的 7.5 倍', { quotaApi: { kind: 'minimax-remains', url: 'https://api.minimax.io/v1/coding_plan/remains', auth: 'bearer' } }),
|
|
287
|
-
plan('legacy', '旧版 Coding Plan / Token Plan(Starter / Plus / Max / Ultra)', 0, 'USD', 'month', '已停售;价格请手填'),
|
|
288
|
-
plan('payg', '按量付费', 0, 'CNY', 'free', '按 token 计费'),
|
|
289
|
-
],
|
|
290
|
-
// Subscription key (sk-cp-…); some accounts only answer to the console session.
|
|
291
|
-
quota: { kind: 'minimax-remains', url: 'https://api.minimaxi.com/v1/coding_plan/remains', auth: 'bearer' },
|
|
292
|
-
keyEnv: 'MINIMAX_API_KEY',
|
|
293
|
-
},
|
|
294
|
-
]
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* DeepSeek's list prices are peak prices (Beijing time, weekdays 9–12 and
|
|
298
|
-
* 14–18); outside those hours the API bills `factor` of them.
|
|
299
|
-
*/
|
|
300
|
-
export const DEEPSEEK_OFF_PEAK = { factor: 0.5, peakHours: [[9, 12], [14, 18]], utcOffsetHours: 8 }
|
|
301
|
-
|
|
302
|
-
/** Is `time` in DeepSeek's off-peak window (weekends count as off-peak; public holidays are not known)? */
|
|
303
|
-
export function isDeepseekOffPeak(time = Date.now()) {
|
|
304
|
-
const beijing = new Date(time + DEEPSEEK_OFF_PEAK.utcOffsetHours * 3_600_000)
|
|
305
|
-
const weekday = beijing.getUTCDay()
|
|
306
|
-
if (weekday === 0 || weekday === 6) return true
|
|
307
|
-
const hour = beijing.getUTCHours() + beijing.getUTCMinutes() / 60
|
|
308
|
-
return !DEEPSEEK_OFF_PEAK.peakHours.some(([from, to]) => hour >= from && hour < to)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/** Catalog provider for an id (`custom` and `none` have no catalog entry). */
|
|
312
|
-
export function providerOf(id) {
|
|
313
|
-
return PROVIDERS.find(p => p.id === id)
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/** Catalog provider id for a DSH route name, or undefined for hand-declared routes. */
|
|
317
|
-
export function providerForRoute(route) {
|
|
318
|
-
if (!route) return undefined
|
|
319
|
-
return ROUTE_MAP[route] ?? (providerOf(route) ? route : undefined)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/** The preset plan `planId` of `providerId`, if any. */
|
|
323
|
-
export function planOf(providerId, planId) {
|
|
324
|
-
return providerOf(providerId)?.plans.find(p => p.id === planId)
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Static fallback price for a model: the route's catalog provider first, then
|
|
329
|
-
* any provider listing that model id (exact, then prefix).
|
|
330
|
-
*/
|
|
331
|
-
/**
|
|
332
|
-
* Cache writes cost more than plain input at some providers; a static row
|
|
333
|
-
* without its own `cacheWrite` is priced at input × this. Anthropic bills
|
|
334
|
-
* 5-minute cache writes at 1.25× input.
|
|
335
|
-
*/
|
|
336
|
-
const CACHE_WRITE_FACTOR = { claude: 1.25 }
|
|
337
|
-
const cacheWriteOf = (row, id) => row.cacheWrite ?? Math.round(row.input * (CACHE_WRITE_FACTOR[id] ?? 1) * 1e6) / 1e6
|
|
338
|
-
|
|
339
|
-
export function staticPriceFor(route, model) {
|
|
340
|
-
if (!model) return undefined
|
|
341
|
-
const preferred = providerForRoute(route)
|
|
342
|
-
const order = [preferred, ...PROVIDERS.map(p => p.id).filter(id => id !== preferred)].filter(Boolean)
|
|
343
|
-
for (const id of order) {
|
|
344
|
-
const table = providerOf(id)?.prices
|
|
345
|
-
if (!table) continue
|
|
346
|
-
const hit = table[model] ?? table[model.toLowerCase()]
|
|
347
|
-
if (hit) return { ...hit, cacheWrite: cacheWriteOf(hit, id), provider: id }
|
|
348
|
-
}
|
|
349
|
-
for (const id of order) {
|
|
350
|
-
const table = providerOf(id)?.prices
|
|
351
|
-
if (!table) continue
|
|
352
|
-
const key = Object.keys(table).filter(k => model.startsWith(k)).sort((a, b) => b.length - a.length)[0]
|
|
353
|
-
if (key) return { ...table[key], cacheWrite: cacheWriteOf(table[key], id), provider: id }
|
|
354
|
-
}
|
|
355
|
-
return undefined
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/** The quota endpoint for a plan choice: a typed override URL wins, then the plan's, then the provider's. */
|
|
359
|
-
export function quotaSpecFor(providerId, planId, overrideUrl) {
|
|
360
|
-
const provider = providerOf(providerId)
|
|
361
|
-
const preset = planOf(providerId, planId)
|
|
362
|
-
const base = preset?.quotaApi ?? provider?.quota
|
|
363
|
-
const url = (overrideUrl ?? '').trim()
|
|
364
|
-
if (url) return { kind: base?.kind ?? kindForUrl(url), url, auth: base?.auth ?? 'bearer' }
|
|
365
|
-
return base ? { ...base } : undefined
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/** Guess a parser from a hand-typed URL's host. */
|
|
369
|
-
export function kindForUrl(url) {
|
|
370
|
-
try {
|
|
371
|
-
const host = new URL(url).host
|
|
372
|
-
if (host.endsWith('deepseek.com')) return 'deepseek-balance'
|
|
373
|
-
if (host.endsWith('moonshot.cn') || host.endsWith('moonshot.ai')) return 'moonshot-balance'
|
|
374
|
-
if (host.endsWith('kimi.com')) return 'kimi-usage'
|
|
375
|
-
if (host.endsWith('z.ai') || host.endsWith('bigmodel.cn')) return 'zai-quota'
|
|
376
|
-
if (host.endsWith('minimaxi.com') || host.endsWith('minimax.io')) return 'minimax-remains'
|
|
377
|
-
if (host.endsWith('x.ai')) return 'xai-key'
|
|
378
|
-
} catch {}
|
|
379
|
-
return 'generic'
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export function priceText(price, currency, period) {
|
|
383
|
-
if (typeof price !== 'number') return undefined
|
|
384
|
-
const symbol = SYMBOL[currency] ?? `${currency ?? ''} `
|
|
385
|
-
if (period === 'free' || price === 0) return period === 'free' ? '按量付费' : `${symbol}0`
|
|
386
|
-
const unit = PERIOD_LABEL[period] ?? ''
|
|
387
|
-
return `${symbol}${Number.isInteger(price) ? price : price.toFixed(2)}${unit ? `/${unit}` : ''}`
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* The plan as the tray and the settings page see it: preset merged with the
|
|
392
|
-
* user's overrides and the latest quota reading.
|
|
393
|
-
*/
|
|
394
|
-
export function planView(cfg, quota) {
|
|
395
|
-
const providerId = cfg.planProvider ?? 'none'
|
|
396
|
-
if (providerId === 'none') return undefined
|
|
397
|
-
const provider = providerOf(providerId)
|
|
398
|
-
const preset = planOf(providerId, cfg.planId)
|
|
399
|
-
const name = cfg.planName?.trim() || preset?.name || (providerId === 'custom' ? '自定义套餐' : provider?.name)
|
|
400
|
-
const price = typeof cfg.planPrice === 'number' ? cfg.planPrice : preset?.price
|
|
401
|
-
const currency = cfg.planCurrency ?? preset?.currency ?? 'CNY'
|
|
402
|
-
const period = typeof cfg.planPrice === 'number' ? (cfg.planPeriod ?? 'month') : (preset?.period ?? cfg.planPeriod ?? 'month')
|
|
403
|
-
const spec = quotaSpecFor(providerId, cfg.planId, cfg.planQuotaUrl)
|
|
404
|
-
const fetched = quota?.ok ? quota.data : undefined
|
|
405
|
-
const balance = typeof cfg.planBalance === 'number' ? cfg.planBalance : fetched?.balance
|
|
406
|
-
const balanceCurrency = typeof cfg.planBalance === 'number' ? currency : (fetched?.currency ?? currency)
|
|
407
|
-
const manualRemaining = cfg.planRemaining?.trim() || undefined
|
|
408
|
-
const remaining = manualRemaining ?? (fetched?.percent !== undefined ? `${fetched.percent}%` : fetched?.remaining !== undefined ? String(fetched.remaining) : undefined)
|
|
409
|
-
return {
|
|
410
|
-
providerId,
|
|
411
|
-
providerName: provider?.name ?? (providerId === 'custom' ? '自定义' : providerId),
|
|
412
|
-
planId: preset?.id ?? cfg.planId ?? '',
|
|
413
|
-
name,
|
|
414
|
-
price,
|
|
415
|
-
currency,
|
|
416
|
-
period,
|
|
417
|
-
priceText: priceText(price, currency, period),
|
|
418
|
-
quotaText: cfg.planQuota?.trim() || preset?.quotaText || undefined,
|
|
419
|
-
balance,
|
|
420
|
-
balanceCurrency,
|
|
421
|
-
remaining,
|
|
422
|
-
remainingSource: manualRemaining ? 'manual' : fetched ? 'api' : undefined,
|
|
423
|
-
resetAt: cfg.planResetAt?.trim() || fetched?.resetAt,
|
|
424
|
-
lines: fetched?.lines ?? [],
|
|
425
|
-
fetch: quota ? { ok: quota.ok, at: quota.at, error: quota.ok ? undefined : quota.error, attempts: quota.attempts } : undefined,
|
|
426
|
-
canFetch: Boolean(spec),
|
|
427
|
-
fetchKind: spec?.kind,
|
|
428
|
-
fetchUrl: spec?.url,
|
|
429
|
-
apiKeyEnv: cfg.planApiKeyEnv?.trim() || undefined,
|
|
430
|
-
suggestedKeyEnv: provider?.keyEnv,
|
|
431
|
-
links: { pricing: provider?.pricingUrl, console: provider?.consoleUrl },
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/** JSON-safe catalog for the browser half. */
|
|
436
|
-
export function publicCatalog() {
|
|
437
|
-
return PROVIDERS.map(p => ({
|
|
438
|
-
id: p.id,
|
|
439
|
-
name: p.name,
|
|
440
|
-
home: p.home,
|
|
441
|
-
pricingUrl: p.pricingUrl,
|
|
442
|
-
consoleUrl: p.consoleUrl,
|
|
443
|
-
keyEnv: p.keyEnv,
|
|
444
|
-
quota: p.quota ? { kind: p.quota.kind, url: p.quota.url } : undefined,
|
|
445
|
-
prices: Object.entries(p.prices).map(([model, row]) => ({ model, ...row })),
|
|
446
|
-
plans: p.plans.map(x => ({ ...x, quotaApi: x.quotaApi ? { kind: x.quotaApi.kind, url: x.quotaApi.url } : undefined })),
|
|
447
|
-
}))
|
|
448
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Plan + price catalog: the subscriptions and API list prices of the
|
|
3
|
+
* providers people plug into DeepSeek Harness, plus which quota endpoint
|
|
4
|
+
* each one exposes to an API key.
|
|
5
|
+
*
|
|
6
|
+
* Pure data + helpers, no DSH imports (shared by the host, the browser half
|
|
7
|
+
* through `GET notify-tray/catalog`, and the tests). Prices are per million
|
|
8
|
+
* tokens in the row's own currency. Plan prices are list prices at the time
|
|
9
|
+
* of writing — the settings page lets the user overwrite every figure.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** DSH provider route names (pi-ai ids and the built-in DeepSeek routes) → catalog provider id. */
|
|
13
|
+
const ROUTE_MAP = {
|
|
14
|
+
deepseek: 'deepseek',
|
|
15
|
+
'deepseek-account': 'deepseek',
|
|
16
|
+
'deepseek-api-key': 'deepseek',
|
|
17
|
+
'deepseek-official': 'deepseek',
|
|
18
|
+
'kimi-coding': 'kimi',
|
|
19
|
+
moonshotai: 'kimi',
|
|
20
|
+
'moonshotai-cn': 'kimi',
|
|
21
|
+
zai: 'glm',
|
|
22
|
+
'zai-coding-cn': 'glm',
|
|
23
|
+
opencode: 'opencode',
|
|
24
|
+
'opencode-go': 'opencode',
|
|
25
|
+
xiaomi: 'mimo',
|
|
26
|
+
'xiaomi-token-plan-cn': 'mimo',
|
|
27
|
+
'xiaomi-token-plan-sgp': 'mimo',
|
|
28
|
+
'xiaomi-token-plan-ams': 'mimo',
|
|
29
|
+
google: 'gemini',
|
|
30
|
+
'google-vertex': 'gemini',
|
|
31
|
+
xai: 'grok',
|
|
32
|
+
anthropic: 'claude',
|
|
33
|
+
openai: 'gpt',
|
|
34
|
+
'openai-codex': 'gpt',
|
|
35
|
+
minimax: 'minimax',
|
|
36
|
+
'minimax-cn': 'minimax',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const PERIOD_LABEL = { month: '月', year: '年', week: '周', once: '次', free: '' }
|
|
40
|
+
const SYMBOL = { CNY: '¥', USD: '$' }
|
|
41
|
+
|
|
42
|
+
const P = (input, cacheRead, output, name, extra = {}) => ({ input, cacheRead, output, name, ...extra })
|
|
43
|
+
const plan = (id, name, price, currency, period, quotaText, extra = {}) => ({ id, name, price, currency, period, quotaText, ...extra })
|
|
44
|
+
|
|
45
|
+
export const PROVIDERS = [
|
|
46
|
+
{
|
|
47
|
+
id: 'deepseek',
|
|
48
|
+
name: 'DeepSeek',
|
|
49
|
+
home: 'CNY',
|
|
50
|
+
pricingUrl: 'https://api-docs.deepseek.com/zh-cn/quick_start/pricing',
|
|
51
|
+
consoleUrl: 'https://platform.deepseek.com/usage',
|
|
52
|
+
prices: {
|
|
53
|
+
// 高峰价(北京时间工作日 9–12、14–18 点);空闲时段减半。
|
|
54
|
+
'deepseek-flash': P(2, 0.04, 8, 'DeepSeek V4.1 Flash', { currency: 'CNY' }),
|
|
55
|
+
'deepseek-v4.1-flash': P(2, 0.04, 8, 'DeepSeek V4.1 Flash', { currency: 'CNY' }),
|
|
56
|
+
'deepseek-v4-flash': P(2, 0.04, 8, 'DeepSeek V4 Flash', { currency: 'CNY' }),
|
|
57
|
+
'deepseek-v4-pro': P(9, 0.3, 27, 'DeepSeek V4 Pro', { currency: 'CNY' }),
|
|
58
|
+
'deepseek-chat': P(2, 0.04, 8, 'deepseek-chat', { currency: 'CNY' }),
|
|
59
|
+
'deepseek-reasoner': P(9, 0.3, 27, 'deepseek-reasoner', { currency: 'CNY' }),
|
|
60
|
+
},
|
|
61
|
+
plans: [
|
|
62
|
+
plan('payg', '按量付费(充值余额)', 0, 'CNY', 'free', '按 token 计费,高峰 / 空闲时段价格不同;余额用完即止'),
|
|
63
|
+
],
|
|
64
|
+
quota: { kind: 'deepseek-balance', url: 'https://api.deepseek.com/user/balance', auth: 'bearer' },
|
|
65
|
+
keyEnv: 'DEEPSEEK_API_KEY',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'kimi',
|
|
69
|
+
name: 'Kimi(月之暗面)',
|
|
70
|
+
home: 'CNY',
|
|
71
|
+
pricingUrl: 'https://www.kimi.com/help/membership/membership-pricing',
|
|
72
|
+
consoleUrl: 'https://www.kimi.com/code/console',
|
|
73
|
+
prices: {
|
|
74
|
+
'kimi-k3.1-pro': P(13, 1.3, 68, 'Kimi K3.1 Pro', { currency: 'CNY' }),
|
|
75
|
+
'kimi-k3.1-pro-highspeed': P(26, 1.3, 136, 'Kimi K3.1 Pro HighSpeed', { currency: 'CNY' }),
|
|
76
|
+
'kimi-k3': P(20, 2, 100, 'Kimi K3', { currency: 'CNY' }),
|
|
77
|
+
'kimi-k2.7-code': P(6.5, 1.3, 27, 'Kimi K2.7 Code', { currency: 'CNY' }),
|
|
78
|
+
'kimi-k2.7-code-highspeed': P(13, 2.6, 54, 'Kimi K2.7 Code HighSpeed', { currency: 'CNY' }),
|
|
79
|
+
'kimi-for-coding': P(6.5, 1.3, 27, 'Kimi For Coding', { currency: 'CNY' }),
|
|
80
|
+
},
|
|
81
|
+
plans: [
|
|
82
|
+
plan('cn-go', 'Kimi 会员 Go', 49, 'CNY', 'month', '不含 Kimi Code;年付 ¥468'),
|
|
83
|
+
plan('cn-plus', 'Kimi 会员 Plus(含 Kimi Code)', 99, 'CNY', 'month', 'Kimi Code 5 小时滚动窗口 + 月度共享额度池;年付 ¥948'),
|
|
84
|
+
plan('cn-pro', 'Kimi 会员 Pro', 199, 'CNY', 'month', 'Agent 额度 2 倍;含 1M 上下文与 HighSpeed;年付 ¥1908'),
|
|
85
|
+
plan('cn-max', 'Kimi 会员 Max', 699, 'CNY', 'month', 'Agent 额度 5 倍;年付 ¥6708'),
|
|
86
|
+
plan('cn-ultra', 'Kimi 会员 Ultra', 1399, 'CNY', 'month', 'Agent 额度 10 倍;年付 ¥13428'),
|
|
87
|
+
plan('intl-plus', 'Kimi Plus(国际)', 19, 'USD', 'month', 'Kimi Code 5 小时滚动窗口 + 月度共享额度池;年付 $180'),
|
|
88
|
+
plan('intl-pro', 'Kimi Pro(国际)', 39, 'USD', 'month', 'Agent 额度 2 倍;年付 $372'),
|
|
89
|
+
plan('intl-max', 'Kimi Max(国际)', 99, 'USD', 'month', 'Agent 额度 5 倍;年付 $948'),
|
|
90
|
+
plan('intl-ultra', 'Kimi Ultra(国际)', 199, 'USD', 'month', 'Agent 额度 10 倍;年付 $1908'),
|
|
91
|
+
plan('legacy', '旧版 Kimi Code(Andante / Moderato / Allegretto / Allegro / Vivace)', 0, 'CNY', 'month', '每 5 小时滚动窗口 + 每 7 天周额度;价格请手填'),
|
|
92
|
+
plan('payg', 'Moonshot 开放平台 按量付费', 0, 'CNY', 'free', '按 token 计费', { quotaApi: { kind: 'moonshot-balance', url: 'https://api.moonshot.cn/v1/users/me/balance', auth: 'bearer' } }),
|
|
93
|
+
],
|
|
94
|
+
// Kimi Code's usage endpoint takes the Kimi Code OAuth access token (~/.kimi/credentials/kimi-code.json), not a Moonshot API key.
|
|
95
|
+
quota: { kind: 'kimi-usage', url: 'https://api.kimi.com/coding/v1/usages', auth: 'bearer' },
|
|
96
|
+
keyEnv: 'KIMI_CODE_TOKEN',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'glm',
|
|
100
|
+
name: 'GLM(智谱 / Z.ai)',
|
|
101
|
+
home: 'CNY',
|
|
102
|
+
pricingUrl: 'https://docs.bigmodel.cn/cn/coding-plan/overview',
|
|
103
|
+
consoleUrl: 'https://bigmodel.cn/usercenter/resourcepack',
|
|
104
|
+
prices: {
|
|
105
|
+
'glm-5.3': P(8, 2, 28, 'GLM-5.3', { currency: 'CNY' }),
|
|
106
|
+
'glm-5.3-flash': P(0.8, 0.23, 2.8, 'GLM-5.3-Flash', { currency: 'CNY' }),
|
|
107
|
+
'glm-5.3-flashx': P(2, 0.57, 7, 'GLM-5.3-FlashX', { currency: 'CNY' }),
|
|
108
|
+
'glm-5.2': P(8, 2, 28, 'GLM-5.2', { currency: 'CNY' }),
|
|
109
|
+
'glm-4.7': P(0.6, 0.11, 2.2, 'GLM-4.7', { currency: 'USD' }),
|
|
110
|
+
},
|
|
111
|
+
plans: [
|
|
112
|
+
plan('lite-cny', 'GLM Coding Plan · Lite', 118, 'CNY', 'month', '每 5 小时 2000 积分 / 每周 10000 积分'),
|
|
113
|
+
plan('pro-cny', 'GLM Coding Plan · Pro', 538, 'CNY', 'month', '每 5 小时 12000 积分 / 每周 60000 积分'),
|
|
114
|
+
plan('max-cny', 'GLM Coding Plan · Max', 1078, 'CNY', 'month', '每 5 小时 28000 积分 / 每周 140000 积分'),
|
|
115
|
+
plan('lite-usd', 'GLM Coding Plan · Lite(Z.ai)', 18, 'USD', 'month', '2000 credits / 5 h · 10000 credits / week', { quotaApi: { kind: 'zai-quota', url: 'https://api.z.ai/api/monitor/usage/quota/limit', auth: 'bearer' } }),
|
|
116
|
+
plan('pro-usd', 'GLM Coding Plan · Pro(Z.ai)', 80, 'USD', 'month', '12000 credits / 5 h · 60000 credits / week', { quotaApi: { kind: 'zai-quota', url: 'https://api.z.ai/api/monitor/usage/quota/limit', auth: 'bearer' } }),
|
|
117
|
+
plan('max-usd', 'GLM Coding Plan · Max(Z.ai)', 168, 'USD', 'month', '28000 credits / 5 h · 140000 credits / week', { quotaApi: { kind: 'zai-quota', url: 'https://api.z.ai/api/monitor/usage/quota/limit', auth: 'bearer' } }),
|
|
118
|
+
plan('payg', '按量付费', 0, 'CNY', 'free', '按 token 计费'),
|
|
119
|
+
],
|
|
120
|
+
quota: { kind: 'zai-quota', url: 'https://open.bigmodel.cn/api/monitor/usage/quota/limit', auth: 'bearer' },
|
|
121
|
+
keyEnv: 'ZAI_API_KEY',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'opencode',
|
|
125
|
+
name: 'OpenCode(Zen / Go)',
|
|
126
|
+
home: 'USD',
|
|
127
|
+
pricingUrl: 'https://opencode.ai/docs/zen/',
|
|
128
|
+
consoleUrl: 'https://opencode.ai/console',
|
|
129
|
+
prices: {
|
|
130
|
+
'claude-opus-5-5': P(4, 0.2, 20, 'Claude Opus 5.5 (Zen)', { currency: 'USD' }),
|
|
131
|
+
'gpt-6.1-sol': P(2, 0.1, 10, 'GPT 6.1 Sol (Zen)', { currency: 'USD' }),
|
|
132
|
+
'kimi-k3.1-pro': P(2, 0.2, 10, 'Kimi K3.1 Pro (Zen / Go)', { currency: 'USD' }),
|
|
133
|
+
'glm-5.3': P(1.4, 0.26, 4.4, 'GLM 5.3 (Zen / Go)', { currency: 'USD' }),
|
|
134
|
+
'glm-5.3-flash': P(0.15, 0.03, 0.5, 'GLM 5.3 Flash (Zen / Go)', { currency: 'USD' }),
|
|
135
|
+
'minimax-m3': P(0.3, 0.06, 1.2, 'MiniMax M3 (Zen / Go)', { currency: 'USD' }),
|
|
136
|
+
'deepseek-v4.1-flash': P(0.3, 0.006, 1.2, 'DeepSeek V4.1 Flash (Zen / Go)', { currency: 'USD' }),
|
|
137
|
+
},
|
|
138
|
+
plans: [
|
|
139
|
+
plan('go', 'OpenCode Go', 10, 'USD', 'month', '按模型的月度美元额度(如 Kimi K3.1 Pro $15、GLM-5.3-Flash $60、DeepSeek V4.1 Flash $80);5 小时窗口 = 月额度 20%,每周 = 50%'),
|
|
140
|
+
plan('go-plus', 'OpenCode Go Plus', 40, 'USD', 'month', '更高的月度额度(如 Kimi K3.1 Pro $60、GLM-5.3-Flash $180)'),
|
|
141
|
+
plan('zen', 'OpenCode Zen / Console 按量付费', 0, 'USD', 'free', '预充值,按各模型目录价计费'),
|
|
142
|
+
],
|
|
143
|
+
quota: undefined,
|
|
144
|
+
keyEnv: 'OPENCODE_API_KEY',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 'mimo',
|
|
148
|
+
name: 'MiMo(小米)',
|
|
149
|
+
home: 'CNY',
|
|
150
|
+
pricingUrl: 'https://mimo.mi.com/docs/zh-CN/tokenplan/Token%20Plan/subscription',
|
|
151
|
+
consoleUrl: 'https://platform.xiaomimimo.com/',
|
|
152
|
+
prices: {
|
|
153
|
+
'mimo-v2.6-pro': P(3, 0.025, 6, 'MiMo-V2.6-Pro', { currency: 'CNY' }),
|
|
154
|
+
'mimo-v2.6-flash': P(1, 0.02, 2, 'MiMo-V2.6-Flash', { currency: 'CNY' }),
|
|
155
|
+
'mimo-v2.6-pro-ultraspeed': P(30, 0.25, 60, 'MiMo-V2.6-Pro UltraSpeed', { currency: 'CNY' }),
|
|
156
|
+
'mimo-v2.5-pro': P(3, 0.025, 6, 'MiMo-V2.5-Pro', { currency: 'CNY' }),
|
|
157
|
+
'mimo-v2.5': P(1, 0.02, 2, 'MiMo-V2.5', { currency: 'CNY' }),
|
|
158
|
+
},
|
|
159
|
+
plans: [
|
|
160
|
+
plan('lite', 'MiMo Token Plan · Lite', 39, 'CNY', 'month', '每月 41 亿 Credits(≈ 200 轮);$6/月;夜间 0–8 点 0.8 倍计费'),
|
|
161
|
+
plan('standard', 'MiMo Token Plan · Standard', 99, 'CNY', 'month', '每月 110 亿 Credits(≈ 1600 轮);$16/月'),
|
|
162
|
+
plan('pro', 'MiMo Token Plan · Pro', 329, 'CNY', 'month', '每月 380 亿 Credits(≈ 5600 轮);$50/月'),
|
|
163
|
+
plan('max', 'MiMo Token Plan · Max', 659, 'CNY', 'month', '每月 820 亿 Credits(≈ 12800 轮);$100/月;耗尽即停'),
|
|
164
|
+
plan('payg', '按量付费', 0, 'CNY', 'free', '按 token 计费'),
|
|
165
|
+
],
|
|
166
|
+
// The Token Plan usage API only answers to a console session cookie, not a tp-… key.
|
|
167
|
+
quota: undefined,
|
|
168
|
+
keyEnv: 'XIAOMI_API_KEY',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: 'gemini',
|
|
172
|
+
name: 'Gemini(Google)',
|
|
173
|
+
home: 'USD',
|
|
174
|
+
pricingUrl: 'https://ai.google.dev/gemini-api/docs/pricing',
|
|
175
|
+
consoleUrl: 'https://aistudio.google.com/usage',
|
|
176
|
+
prices: {
|
|
177
|
+
'gemini-4-argon': P(2, 0.1, 10, 'Gemini 4 Argon', { currency: 'USD' }),
|
|
178
|
+
'gemini-3.1-pro-preview': P(2, 0.2, 12, 'Gemini 3.1 Pro', { currency: 'USD' }),
|
|
179
|
+
'gemini-3.8-flash': P(0.75, 0.075, 3.75, 'Gemini 3.8 Flash', { currency: 'USD' }),
|
|
180
|
+
'gemini-3.5-flash-lite': P(0.3, 0.03, 2.5, 'Gemini 3.5 Flash-Lite', { currency: 'USD' }),
|
|
181
|
+
'gemini-3-flash-preview': P(0.5, 0.05, 3, 'Gemini 3 Flash', { currency: 'USD' }),
|
|
182
|
+
'gemini-2.5-pro': P(1.25, 0.125, 10, 'Gemini 2.5 Pro', { currency: 'USD' }),
|
|
183
|
+
'gemini-2.5-flash': P(0.3, 0.03, 2.5, 'Gemini 2.5 Flash', { currency: 'USD' }),
|
|
184
|
+
},
|
|
185
|
+
plans: [
|
|
186
|
+
plan('ai-plus', 'Google AI Plus', 7.99, 'USD', 'month', 'Gemini 用量 2 倍;5 小时滚动上限 + 周上限'),
|
|
187
|
+
plan('ai-pro', 'Google AI Pro', 19.99, 'USD', 'month', '用量 4 倍;Gemini 4 Argon / 3.1 Pro;AI Studio 更高限额'),
|
|
188
|
+
plan('ai-ultra', 'Google AI Ultra', 99.99, 'USD', 'month', '最高 20 倍;顶配 $200/月'),
|
|
189
|
+
plan('payg', 'Gemini API 按量付费', 0, 'USD', 'free', '按 token 计费(有免费层)'),
|
|
190
|
+
],
|
|
191
|
+
quota: undefined,
|
|
192
|
+
keyEnv: 'GEMINI_API_KEY',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'grok',
|
|
196
|
+
name: 'Grok(xAI)',
|
|
197
|
+
home: 'USD',
|
|
198
|
+
pricingUrl: 'https://docs.x.ai/developers/pricing',
|
|
199
|
+
consoleUrl: 'https://console.x.ai/',
|
|
200
|
+
prices: {
|
|
201
|
+
'grok-4.7': P(2, 0.5, 6, 'Grok 4.7', { currency: 'USD' }),
|
|
202
|
+
'grok-4.6': P(2, 0.5, 6, 'Grok 4.6', { currency: 'USD' }),
|
|
203
|
+
'grok-4.5': P(2, 0.3, 6, 'Grok 4.5', { currency: 'USD' }),
|
|
204
|
+
'grok-4.3': P(1.25, 0.2, 2.5, 'Grok 4.3', { currency: 'USD' }),
|
|
205
|
+
'grok-build-0.1': P(1, 0.2, 2, 'Grok Build 0.1', { currency: 'USD' }),
|
|
206
|
+
},
|
|
207
|
+
plans: [
|
|
208
|
+
plan('supergrok-lite', 'SuperGrok Lite', 10, 'USD', 'month', '入门档'),
|
|
209
|
+
plan('supergrok', 'SuperGrok', 30, 'USD', 'month', '标准档(X Premium+ $40 含同级权益)'),
|
|
210
|
+
plan('supergrok-plus', 'SuperGrok Plus', 100, 'USD', 'month', '更大用量池'),
|
|
211
|
+
plan('supergrok-heavy', 'SuperGrok Heavy', 300, 'USD', 'month', '最高额度 + Heavy 模型'),
|
|
212
|
+
plan('payg', 'xAI API 按量付费', 0, 'USD', 'free', '预充值,按 token 计费'),
|
|
213
|
+
],
|
|
214
|
+
quota: { kind: 'xai-key', url: 'https://api.x.ai/v1/api-key', auth: 'bearer' },
|
|
215
|
+
keyEnv: 'XAI_API_KEY',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: 'claude',
|
|
219
|
+
name: 'Claude(Anthropic)',
|
|
220
|
+
home: 'USD',
|
|
221
|
+
pricingUrl: 'https://www.anthropic.com/pricing',
|
|
222
|
+
consoleUrl: 'https://platform.claude.com/usage',
|
|
223
|
+
prices: {
|
|
224
|
+
'claude-fable-5-1': P(10, 0.25, 50, 'Claude Fable 5.1', { currency: 'USD', cacheWrite: 12.5 }),
|
|
225
|
+
'claude-fable-5': P(10, 1, 50, 'Claude Fable 5', { currency: 'USD', cacheWrite: 12.5 }),
|
|
226
|
+
'claude-opus-5-5': P(4, 0.2, 20, 'Claude Opus 5.5', { currency: 'USD', cacheWrite: 5 }),
|
|
227
|
+
'claude-opus-4-5': P(5, 0.5, 25, 'Claude Opus 4.5', { currency: 'USD', cacheWrite: 6.25 }),
|
|
228
|
+
'claude-sonnet-5-5': P(2, 0.1, 10, 'Claude Sonnet 5.5', { currency: 'USD', cacheWrite: 2.5 }),
|
|
229
|
+
'claude-haiku-5-5': P(0.1, 0.01, 0.5, 'Claude Haiku 5.5', { currency: 'USD', cacheWrite: 0.125 }),
|
|
230
|
+
'claude-haiku-4-5': P(1, 0.1, 5, 'Claude Haiku 4.5', { currency: 'USD', cacheWrite: 1.25 }),
|
|
231
|
+
},
|
|
232
|
+
plans: [
|
|
233
|
+
plan('pro', 'Claude Pro', 20, 'USD', 'month', '含 Claude Code;每 5 小时滚动额度 + 周上限;年付 $17/月'),
|
|
234
|
+
plan('max-5x', 'Claude Max 5x', 100, 'USD', 'month', 'Pro 的 5 倍(每 5 小时)+ 周上限'),
|
|
235
|
+
plan('max-20x', 'Claude Max 20x', 200, 'USD', 'month', 'Pro 的 20 倍(每 5 小时)+ 周上限'),
|
|
236
|
+
plan('team', 'Claude Team(标准席位)', 25, 'USD', 'month', '每席位;年付 $20/席位'),
|
|
237
|
+
plan('payg', 'Anthropic API 按量付费', 0, 'USD', 'free', '预充值,按 token 计费'),
|
|
238
|
+
],
|
|
239
|
+
quota: undefined,
|
|
240
|
+
keyEnv: 'ANTHROPIC_API_KEY',
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: 'gpt',
|
|
244
|
+
name: 'GPT(OpenAI)',
|
|
245
|
+
home: 'USD',
|
|
246
|
+
pricingUrl: 'https://developers.openai.com/api/docs/pricing',
|
|
247
|
+
consoleUrl: 'https://platform.openai.com/usage',
|
|
248
|
+
prices: {
|
|
249
|
+
'gpt-6-astra': P(10, 1, 50, 'GPT-6 Astra', { currency: 'USD', cacheWrite: 12.5 }),
|
|
250
|
+
'gpt-6.1-sol': P(2, 0.1, 10, 'GPT-6.1 Sol', { currency: 'USD', cacheWrite: 2.5 }),
|
|
251
|
+
'gpt-6-sol': P(2, 0.2, 10, 'GPT-6 Sol', { currency: 'USD' }),
|
|
252
|
+
'gpt-6-luna': P(0.1, 0.01, 0.5, 'GPT-6 Luna', { currency: 'USD', cacheWrite: 0.125 }),
|
|
253
|
+
'gpt-5.6-sol': P(4, 0.4, 20, 'GPT-5.6 Sol', { currency: 'USD' }),
|
|
254
|
+
'gpt-4.1': P(2, 0.5, 8, 'GPT-4.1', { currency: 'USD' }),
|
|
255
|
+
},
|
|
256
|
+
plans: [
|
|
257
|
+
plan('go', 'ChatGPT Go', 8, 'USD', 'month', '轻量档,Codex 额度有限'),
|
|
258
|
+
plan('plus', 'ChatGPT Plus', 20, 'USD', 'month', '含 Codex:每 5 小时约 15–160 条(GPT-6.1 Sol)+ 周上限'),
|
|
259
|
+
plan('pro-5x', 'ChatGPT Pro(5x)', 100, 'USD', 'month', 'Codex 用量约 Plus 的 5 倍'),
|
|
260
|
+
plan('pro-20x', 'ChatGPT Pro(20x)', 200, 'USD', 'month', 'Codex 用量约 Plus 的 20 倍'),
|
|
261
|
+
plan('business', 'ChatGPT Business', 25, 'USD', 'month', '每席位(至少 2 个);年付 $20/席位'),
|
|
262
|
+
plan('payg', 'OpenAI API 按量付费', 0, 'USD', 'free', '预充值,按 token 计费'),
|
|
263
|
+
],
|
|
264
|
+
quota: undefined,
|
|
265
|
+
keyEnv: 'OPENAI_API_KEY',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: 'minimax',
|
|
269
|
+
name: 'MiniMax',
|
|
270
|
+
home: 'CNY',
|
|
271
|
+
pricingUrl: 'https://platform.minimax.cn/docs/m-plan/monthly-offer',
|
|
272
|
+
consoleUrl: 'https://platform.minimax.io/console/usage',
|
|
273
|
+
prices: {
|
|
274
|
+
'MiniMax-M3.1-Flash': P(1, 0.1, 4, 'MiniMax M3.1 Flash', { currency: 'CNY' }),
|
|
275
|
+
'MiniMax-M3': P(2.1, 0.42, 8.4, 'MiniMax M3', { currency: 'CNY' }),
|
|
276
|
+
'MiniMax-M2.7': P(2.1, 0.42, 8.4, 'MiniMax M2.7', { currency: 'CNY' }),
|
|
277
|
+
'minimax-m3.1-flash': P(0.15, 0.015, 0.6, 'MiniMax M3.1 Flash', { currency: 'USD' }),
|
|
278
|
+
'minimax-m3': P(0.3, 0.06, 1.2, 'MiniMax M3', { currency: 'USD' }),
|
|
279
|
+
},
|
|
280
|
+
plans: [
|
|
281
|
+
plan('m-go-cn', 'MiniMax M Plan · Go(国内)', 49, 'CNY', 'month', '基础额度 1 倍;M3.1 Flash;5 小时窗口 + 周窗口'),
|
|
282
|
+
plan('m-explore-cn', 'MiniMax M Plan · Explore(国内)', 119, 'CNY', 'month', 'Go 的 3 倍;含 H3 视频'),
|
|
283
|
+
plan('m-build-cn', 'MiniMax M Plan · Build(国内)', 469, 'CNY', 'month', 'Go 的 7.5 倍;超出可买 Credits 包'),
|
|
284
|
+
plan('m-go', 'MiniMax M Plan · Go(国际)', 22, 'USD', 'month', '基础额度 1 倍;5 小时窗口 + 周窗口', { quotaApi: { kind: 'minimax-remains', url: 'https://api.minimax.io/v1/coding_plan/remains', auth: 'bearer' } }),
|
|
285
|
+
plan('m-explore', 'MiniMax M Plan · Explore(国际)', 55, 'USD', 'month', 'Go 的 3 倍', { quotaApi: { kind: 'minimax-remains', url: 'https://api.minimax.io/v1/coding_plan/remains', auth: 'bearer' } }),
|
|
286
|
+
plan('m-build', 'MiniMax M Plan · Build(国际)', 132, 'USD', 'month', 'Go 的 7.5 倍', { quotaApi: { kind: 'minimax-remains', url: 'https://api.minimax.io/v1/coding_plan/remains', auth: 'bearer' } }),
|
|
287
|
+
plan('legacy', '旧版 Coding Plan / Token Plan(Starter / Plus / Max / Ultra)', 0, 'USD', 'month', '已停售;价格请手填'),
|
|
288
|
+
plan('payg', '按量付费', 0, 'CNY', 'free', '按 token 计费'),
|
|
289
|
+
],
|
|
290
|
+
// Subscription key (sk-cp-…); some accounts only answer to the console session.
|
|
291
|
+
quota: { kind: 'minimax-remains', url: 'https://api.minimaxi.com/v1/coding_plan/remains', auth: 'bearer' },
|
|
292
|
+
keyEnv: 'MINIMAX_API_KEY',
|
|
293
|
+
},
|
|
294
|
+
]
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* DeepSeek's list prices are peak prices (Beijing time, weekdays 9–12 and
|
|
298
|
+
* 14–18); outside those hours the API bills `factor` of them.
|
|
299
|
+
*/
|
|
300
|
+
export const DEEPSEEK_OFF_PEAK = { factor: 0.5, peakHours: [[9, 12], [14, 18]], utcOffsetHours: 8 }
|
|
301
|
+
|
|
302
|
+
/** Is `time` in DeepSeek's off-peak window (weekends count as off-peak; public holidays are not known)? */
|
|
303
|
+
export function isDeepseekOffPeak(time = Date.now()) {
|
|
304
|
+
const beijing = new Date(time + DEEPSEEK_OFF_PEAK.utcOffsetHours * 3_600_000)
|
|
305
|
+
const weekday = beijing.getUTCDay()
|
|
306
|
+
if (weekday === 0 || weekday === 6) return true
|
|
307
|
+
const hour = beijing.getUTCHours() + beijing.getUTCMinutes() / 60
|
|
308
|
+
return !DEEPSEEK_OFF_PEAK.peakHours.some(([from, to]) => hour >= from && hour < to)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Catalog provider for an id (`custom` and `none` have no catalog entry). */
|
|
312
|
+
export function providerOf(id) {
|
|
313
|
+
return PROVIDERS.find(p => p.id === id)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Catalog provider id for a DSH route name, or undefined for hand-declared routes. */
|
|
317
|
+
export function providerForRoute(route) {
|
|
318
|
+
if (!route) return undefined
|
|
319
|
+
return ROUTE_MAP[route] ?? (providerOf(route) ? route : undefined)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** The preset plan `planId` of `providerId`, if any. */
|
|
323
|
+
export function planOf(providerId, planId) {
|
|
324
|
+
return providerOf(providerId)?.plans.find(p => p.id === planId)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Static fallback price for a model: the route's catalog provider first, then
|
|
329
|
+
* any provider listing that model id (exact, then prefix).
|
|
330
|
+
*/
|
|
331
|
+
/**
|
|
332
|
+
* Cache writes cost more than plain input at some providers; a static row
|
|
333
|
+
* without its own `cacheWrite` is priced at input × this. Anthropic bills
|
|
334
|
+
* 5-minute cache writes at 1.25× input.
|
|
335
|
+
*/
|
|
336
|
+
const CACHE_WRITE_FACTOR = { claude: 1.25 }
|
|
337
|
+
const cacheWriteOf = (row, id) => row.cacheWrite ?? Math.round(row.input * (CACHE_WRITE_FACTOR[id] ?? 1) * 1e6) / 1e6
|
|
338
|
+
|
|
339
|
+
export function staticPriceFor(route, model) {
|
|
340
|
+
if (!model) return undefined
|
|
341
|
+
const preferred = providerForRoute(route)
|
|
342
|
+
const order = [preferred, ...PROVIDERS.map(p => p.id).filter(id => id !== preferred)].filter(Boolean)
|
|
343
|
+
for (const id of order) {
|
|
344
|
+
const table = providerOf(id)?.prices
|
|
345
|
+
if (!table) continue
|
|
346
|
+
const hit = table[model] ?? table[model.toLowerCase()]
|
|
347
|
+
if (hit) return { ...hit, cacheWrite: cacheWriteOf(hit, id), provider: id }
|
|
348
|
+
}
|
|
349
|
+
for (const id of order) {
|
|
350
|
+
const table = providerOf(id)?.prices
|
|
351
|
+
if (!table) continue
|
|
352
|
+
const key = Object.keys(table).filter(k => model.startsWith(k)).sort((a, b) => b.length - a.length)[0]
|
|
353
|
+
if (key) return { ...table[key], cacheWrite: cacheWriteOf(table[key], id), provider: id }
|
|
354
|
+
}
|
|
355
|
+
return undefined
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** The quota endpoint for a plan choice: a typed override URL wins, then the plan's, then the provider's. */
|
|
359
|
+
export function quotaSpecFor(providerId, planId, overrideUrl) {
|
|
360
|
+
const provider = providerOf(providerId)
|
|
361
|
+
const preset = planOf(providerId, planId)
|
|
362
|
+
const base = preset?.quotaApi ?? provider?.quota
|
|
363
|
+
const url = (overrideUrl ?? '').trim()
|
|
364
|
+
if (url) return { kind: base?.kind ?? kindForUrl(url), url, auth: base?.auth ?? 'bearer' }
|
|
365
|
+
return base ? { ...base } : undefined
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Guess a parser from a hand-typed URL's host. */
|
|
369
|
+
export function kindForUrl(url) {
|
|
370
|
+
try {
|
|
371
|
+
const host = new URL(url).host
|
|
372
|
+
if (host.endsWith('deepseek.com')) return 'deepseek-balance'
|
|
373
|
+
if (host.endsWith('moonshot.cn') || host.endsWith('moonshot.ai')) return 'moonshot-balance'
|
|
374
|
+
if (host.endsWith('kimi.com')) return 'kimi-usage'
|
|
375
|
+
if (host.endsWith('z.ai') || host.endsWith('bigmodel.cn')) return 'zai-quota'
|
|
376
|
+
if (host.endsWith('minimaxi.com') || host.endsWith('minimax.io')) return 'minimax-remains'
|
|
377
|
+
if (host.endsWith('x.ai')) return 'xai-key'
|
|
378
|
+
} catch {}
|
|
379
|
+
return 'generic'
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export function priceText(price, currency, period) {
|
|
383
|
+
if (typeof price !== 'number') return undefined
|
|
384
|
+
const symbol = SYMBOL[currency] ?? `${currency ?? ''} `
|
|
385
|
+
if (period === 'free' || price === 0) return period === 'free' ? '按量付费' : `${symbol}0`
|
|
386
|
+
const unit = PERIOD_LABEL[period] ?? ''
|
|
387
|
+
return `${symbol}${Number.isInteger(price) ? price : price.toFixed(2)}${unit ? `/${unit}` : ''}`
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The plan as the tray and the settings page see it: preset merged with the
|
|
392
|
+
* user's overrides and the latest quota reading.
|
|
393
|
+
*/
|
|
394
|
+
export function planView(cfg, quota) {
|
|
395
|
+
const providerId = cfg.planProvider ?? 'none'
|
|
396
|
+
if (providerId === 'none') return undefined
|
|
397
|
+
const provider = providerOf(providerId)
|
|
398
|
+
const preset = planOf(providerId, cfg.planId)
|
|
399
|
+
const name = cfg.planName?.trim() || preset?.name || (providerId === 'custom' ? '自定义套餐' : provider?.name)
|
|
400
|
+
const price = typeof cfg.planPrice === 'number' ? cfg.planPrice : preset?.price
|
|
401
|
+
const currency = cfg.planCurrency ?? preset?.currency ?? 'CNY'
|
|
402
|
+
const period = typeof cfg.planPrice === 'number' ? (cfg.planPeriod ?? 'month') : (preset?.period ?? cfg.planPeriod ?? 'month')
|
|
403
|
+
const spec = quotaSpecFor(providerId, cfg.planId, cfg.planQuotaUrl)
|
|
404
|
+
const fetched = quota?.ok ? quota.data : undefined
|
|
405
|
+
const balance = typeof cfg.planBalance === 'number' ? cfg.planBalance : fetched?.balance
|
|
406
|
+
const balanceCurrency = typeof cfg.planBalance === 'number' ? currency : (fetched?.currency ?? currency)
|
|
407
|
+
const manualRemaining = cfg.planRemaining?.trim() || undefined
|
|
408
|
+
const remaining = manualRemaining ?? (fetched?.percent !== undefined ? `${fetched.percent}%` : fetched?.remaining !== undefined ? String(fetched.remaining) : undefined)
|
|
409
|
+
return {
|
|
410
|
+
providerId,
|
|
411
|
+
providerName: provider?.name ?? (providerId === 'custom' ? '自定义' : providerId),
|
|
412
|
+
planId: preset?.id ?? cfg.planId ?? '',
|
|
413
|
+
name,
|
|
414
|
+
price,
|
|
415
|
+
currency,
|
|
416
|
+
period,
|
|
417
|
+
priceText: priceText(price, currency, period),
|
|
418
|
+
quotaText: cfg.planQuota?.trim() || preset?.quotaText || undefined,
|
|
419
|
+
balance,
|
|
420
|
+
balanceCurrency,
|
|
421
|
+
remaining,
|
|
422
|
+
remainingSource: manualRemaining ? 'manual' : fetched ? 'api' : undefined,
|
|
423
|
+
resetAt: cfg.planResetAt?.trim() || fetched?.resetAt,
|
|
424
|
+
lines: fetched?.lines ?? [],
|
|
425
|
+
fetch: quota ? { ok: quota.ok, at: quota.at, error: quota.ok ? undefined : quota.error, attempts: quota.attempts } : undefined,
|
|
426
|
+
canFetch: Boolean(spec),
|
|
427
|
+
fetchKind: spec?.kind,
|
|
428
|
+
fetchUrl: spec?.url,
|
|
429
|
+
apiKeyEnv: cfg.planApiKeyEnv?.trim() || undefined,
|
|
430
|
+
suggestedKeyEnv: provider?.keyEnv,
|
|
431
|
+
links: { pricing: provider?.pricingUrl, console: provider?.consoleUrl },
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** JSON-safe catalog for the browser half. */
|
|
436
|
+
export function publicCatalog() {
|
|
437
|
+
return PROVIDERS.map(p => ({
|
|
438
|
+
id: p.id,
|
|
439
|
+
name: p.name,
|
|
440
|
+
home: p.home,
|
|
441
|
+
pricingUrl: p.pricingUrl,
|
|
442
|
+
consoleUrl: p.consoleUrl,
|
|
443
|
+
keyEnv: p.keyEnv,
|
|
444
|
+
quota: p.quota ? { kind: p.quota.kind, url: p.quota.url } : undefined,
|
|
445
|
+
prices: Object.entries(p.prices).map(([model, row]) => ({ model, ...row })),
|
|
446
|
+
plans: p.plans.map(x => ({ ...x, quotaApi: x.quotaApi ? { kind: x.quotaApi.kind, url: x.quotaApi.url } : undefined })),
|
|
447
|
+
}))
|
|
448
|
+
}
|