@leo000001/opencode-quota-sidebar 3.0.0 → 3.0.2
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/CHANGELOG.md +14 -2
- package/CONTRIBUTING.md +4 -1
- package/README.md +210 -514
- package/README.zh-CN.md +337 -0
- package/SECURITY.md +2 -2
- package/assets/OpenCode-Quota-Sidebar.png +0 -0
- package/dist/cost.d.ts +3 -3
- package/dist/cost.js +258 -169
- package/dist/format.d.ts +4 -0
- package/dist/format.js +24 -10
- package/dist/providers/common.d.ts +6 -0
- package/dist/providers/common.js +32 -12
- package/dist/providers/core/anthropic.d.ts +1 -1
- package/dist/providers/core/anthropic.js +43 -39
- package/dist/providers/core/kimi_for_coding.d.ts +1 -1
- package/dist/providers/core/kimi_for_coding.js +44 -64
- package/dist/providers/core/minimax_cn_coding_plan.d.ts +2 -0
- package/dist/providers/core/minimax_cn_coding_plan.js +214 -0
- package/dist/providers/core/zhipu_coding_plan.d.ts +1 -1
- package/dist/providers/core/zhipu_coding_plan.js +41 -61
- package/dist/providers/index.d.ts +3 -3
- package/dist/providers/index.js +5 -5
- package/dist/providers/third_party/rightcode.d.ts +1 -1
- package/dist/providers/third_party/rightcode.js +41 -61
- package/dist/providers/third_party/xyai.d.ts +2 -0
- package/dist/providers/third_party/{xyai_vibe.js → xyai.js} +113 -79
- package/dist/quota.d.ts +2 -2
- package/dist/quota.js +24 -18
- package/dist/quota_render.d.ts +1 -1
- package/dist/quota_render.js +23 -17
- package/dist/storage_parse.js +1 -0
- package/dist/title.js +7 -7
- package/dist/title_apply.js +18 -1
- package/dist/tui.tsx +133 -36
- package/dist/tui_helpers.d.ts +16 -0
- package/dist/tui_helpers.js +146 -0
- package/dist/types.d.ts +2 -0
- package/package.json +9 -2
- package/quota-sidebar.config.example.json +45 -45
- package/dist/providers/third_party/buzz.d.ts +0 -2
- package/dist/providers/third_party/buzz.js +0 -156
- package/dist/providers/third_party/xyai_vibe.d.ts +0 -2
package/dist/cost.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { asNumber, isRecord } from
|
|
1
|
+
import { asNumber, isRecord } from "./helpers.js";
|
|
2
2
|
export const API_COST_ENABLED_PROVIDERS = new Set([
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"openai",
|
|
4
|
+
"anthropic",
|
|
5
|
+
"kimi-for-coding",
|
|
6
|
+
"zhipu",
|
|
7
|
+
"minimax-cn-coding-plan",
|
|
7
8
|
]);
|
|
8
9
|
const MODEL_COST_RATE_ALIASES = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"zhipuai-coding-plan:glm-5.1": ["zhipu:glm-5"],
|
|
11
|
+
"zhipuai-coding-plan:glm-5.1-thinking": ["zhipu:glm-5"],
|
|
12
|
+
"zhipu:glm-5.1": ["zhipu:glm-5"],
|
|
13
|
+
"zhipu:glm-5.1-thinking": ["zhipu:glm-5"],
|
|
13
14
|
};
|
|
14
15
|
function moonshotCanonicalModelID(modelID) {
|
|
15
|
-
const stripped = modelID.replace(/^moonshotai[/:]/i,
|
|
16
|
+
const stripped = modelID.replace(/^moonshotai[/:]/i, "");
|
|
16
17
|
switch (stripped) {
|
|
17
|
-
case
|
|
18
|
-
case
|
|
19
|
-
return
|
|
18
|
+
case "k2p5":
|
|
19
|
+
case "kimi-k2-5":
|
|
20
|
+
return "kimi-k2.5";
|
|
20
21
|
default:
|
|
21
22
|
return stripped;
|
|
22
23
|
}
|
|
@@ -29,7 +30,7 @@ function moonshotModelAliases(modelID, options) {
|
|
|
29
30
|
if (!aliases.includes(value))
|
|
30
31
|
aliases.push(value);
|
|
31
32
|
};
|
|
32
|
-
const stripped = modelID.replace(/^moonshotai[/:]/i,
|
|
33
|
+
const stripped = modelID.replace(/^moonshotai[/:]/i, "");
|
|
33
34
|
const canonical = moonshotCanonicalModelID(modelID);
|
|
34
35
|
if (!options?.canonicalProviderKeys)
|
|
35
36
|
push(modelID);
|
|
@@ -38,6 +39,30 @@ function moonshotModelAliases(modelID, options) {
|
|
|
38
39
|
push(canonical);
|
|
39
40
|
return aliases;
|
|
40
41
|
}
|
|
42
|
+
function minimaxModelAliases(modelID) {
|
|
43
|
+
const aliases = [];
|
|
44
|
+
const push = (value) => {
|
|
45
|
+
if (!value)
|
|
46
|
+
return;
|
|
47
|
+
if (!aliases.includes(value))
|
|
48
|
+
aliases.push(value);
|
|
49
|
+
};
|
|
50
|
+
push(modelID);
|
|
51
|
+
push(modelID.toLowerCase());
|
|
52
|
+
const stripped = modelID.replace(/^(?:minimax|minimax-cn-coding-plan)[/:]/i, "");
|
|
53
|
+
push(stripped);
|
|
54
|
+
push(stripped.toLowerCase());
|
|
55
|
+
if (/^minimax-/i.test(stripped)) {
|
|
56
|
+
const suffix = stripped.slice("minimax-".length);
|
|
57
|
+
push(`MiniMax-${suffix}`);
|
|
58
|
+
push(`minimax-${suffix.toLowerCase()}`);
|
|
59
|
+
}
|
|
60
|
+
if (/^m2(?:[.-]\d+)?(?:-highspeed)?$/i.test(stripped)) {
|
|
61
|
+
push(`MiniMax-${stripped}`);
|
|
62
|
+
push(`minimax-${stripped.toLowerCase()}`);
|
|
63
|
+
}
|
|
64
|
+
return aliases;
|
|
65
|
+
}
|
|
41
66
|
function zhipuModelAliases(modelID) {
|
|
42
67
|
const aliases = [];
|
|
43
68
|
const queue = [];
|
|
@@ -52,19 +77,19 @@ function zhipuModelAliases(modelID) {
|
|
|
52
77
|
push(modelID);
|
|
53
78
|
for (let index = 0; index < queue.length; index++) {
|
|
54
79
|
const stem = queue[index];
|
|
55
|
-
const withoutProviderPrefix = stem.replace(/^(?:zhipu|z-ai|bigmodel|zhipuai-coding-plan)[/:]/,
|
|
80
|
+
const withoutProviderPrefix = stem.replace(/^(?:zhipu|z-ai|bigmodel|zhipuai-coding-plan)[/:]/, "");
|
|
56
81
|
push(withoutProviderPrefix);
|
|
57
82
|
push(`zhipu/${withoutProviderPrefix}`);
|
|
58
|
-
const withoutBillingSuffix = withoutProviderPrefix.replace(/-billing$/,
|
|
83
|
+
const withoutBillingSuffix = withoutProviderPrefix.replace(/-billing$/, "");
|
|
59
84
|
push(withoutBillingSuffix);
|
|
60
85
|
push(`zhipu/${withoutBillingSuffix}`);
|
|
61
|
-
const withoutThinkingSuffix = withoutBillingSuffix.replace(/-thinking$/,
|
|
86
|
+
const withoutThinkingSuffix = withoutBillingSuffix.replace(/-thinking$/, "");
|
|
62
87
|
push(withoutThinkingSuffix);
|
|
63
88
|
push(`zhipu/${withoutThinkingSuffix}`);
|
|
64
|
-
const dotted = withoutThinkingSuffix.replace(/(\d)-(\d)(?=-|$)/g,
|
|
89
|
+
const dotted = withoutThinkingSuffix.replace(/(\d)-(\d)(?=-|$)/g, "$1.$2");
|
|
65
90
|
push(dotted);
|
|
66
91
|
push(`zhipu/${dotted}`);
|
|
67
|
-
const hyphenated = withoutThinkingSuffix.replace(/(\d)\.(\d)(?=-|$)/g,
|
|
92
|
+
const hyphenated = withoutThinkingSuffix.replace(/(\d)\.(\d)(?=-|$)/g, "$1-$2");
|
|
68
93
|
push(hyphenated);
|
|
69
94
|
push(`zhipu/${hyphenated}`);
|
|
70
95
|
}
|
|
@@ -85,81 +110,89 @@ function anthropicModelAliases(modelID) {
|
|
|
85
110
|
for (let index = 0; index < queue.length; index++) {
|
|
86
111
|
const stem = queue[index];
|
|
87
112
|
const withoutProviderPrefix = stem
|
|
88
|
-
.replace(/^(?:[a-z]+\.)*anthropic\./,
|
|
89
|
-
.replace(/^anthropic[/.]/,
|
|
113
|
+
.replace(/^(?:[a-z]+\.)*anthropic\./, "")
|
|
114
|
+
.replace(/^anthropic[/.]/, "");
|
|
90
115
|
push(withoutProviderPrefix);
|
|
91
116
|
push(`anthropic/${withoutProviderPrefix}`);
|
|
92
|
-
const withoutVersionSuffix = withoutProviderPrefix.replace(/-v\d+(?::\d+)?$/,
|
|
117
|
+
const withoutVersionSuffix = withoutProviderPrefix.replace(/-v\d+(?::\d+)?$/, "");
|
|
93
118
|
push(withoutVersionSuffix);
|
|
94
119
|
push(`anthropic/${withoutVersionSuffix}`);
|
|
95
|
-
const atDate = withoutVersionSuffix.replace(/@(\d{8})$/,
|
|
120
|
+
const atDate = withoutVersionSuffix.replace(/@(\d{8})$/, "-$1");
|
|
96
121
|
push(atDate);
|
|
97
122
|
push(`anthropic/${atDate}`);
|
|
98
|
-
const withAtDate = withoutVersionSuffix.replace(/-(\d{8})$/,
|
|
123
|
+
const withAtDate = withoutVersionSuffix.replace(/-(\d{8})$/, "@$1");
|
|
99
124
|
push(withAtDate);
|
|
100
125
|
push(`anthropic/${withAtDate}`);
|
|
101
|
-
const withoutThinkingSuffix = withoutVersionSuffix.replace(/-thinking$/,
|
|
126
|
+
const withoutThinkingSuffix = withoutVersionSuffix.replace(/-thinking$/, "");
|
|
102
127
|
push(withoutThinkingSuffix);
|
|
103
128
|
push(`anthropic/${withoutThinkingSuffix}`);
|
|
104
|
-
const withoutLatestSuffix = withoutThinkingSuffix.replace(/-latest$/,
|
|
129
|
+
const withoutLatestSuffix = withoutThinkingSuffix.replace(/-latest$/, "");
|
|
105
130
|
push(withoutLatestSuffix);
|
|
106
131
|
push(`anthropic/${withoutLatestSuffix}`);
|
|
107
132
|
const withoutDateSuffix = withoutLatestSuffix
|
|
108
|
-
.replace(/-\d{8}$/,
|
|
109
|
-
.replace(/@\d{8}$/,
|
|
133
|
+
.replace(/-\d{8}$/, "")
|
|
134
|
+
.replace(/@\d{8}$/, "");
|
|
110
135
|
push(withoutDateSuffix);
|
|
111
136
|
push(`anthropic/${withoutDateSuffix}`);
|
|
112
|
-
const dotted = withoutDateSuffix.replace(/(\d)-(\d)(?=-|$)/g,
|
|
137
|
+
const dotted = withoutDateSuffix.replace(/(\d)-(\d)(?=-|$)/g, "$1.$2");
|
|
113
138
|
push(dotted);
|
|
114
139
|
push(`anthropic/${dotted}`);
|
|
115
|
-
const hyphenated = withoutDateSuffix.replace(/(\d)\.(\d)(?=-|$)/g,
|
|
140
|
+
const hyphenated = withoutDateSuffix.replace(/(\d)\.(\d)(?=-|$)/g, "$1-$2");
|
|
116
141
|
push(hyphenated);
|
|
117
142
|
push(`anthropic/${hyphenated}`);
|
|
118
143
|
}
|
|
119
144
|
return aliases;
|
|
120
145
|
}
|
|
121
146
|
function normalizeKnownProviderID(providerID) {
|
|
122
|
-
if (providerID.startsWith(
|
|
123
|
-
return
|
|
147
|
+
if (providerID.startsWith("github-copilot"))
|
|
148
|
+
return "github-copilot";
|
|
124
149
|
return providerID;
|
|
125
150
|
}
|
|
126
151
|
function isCanonicalZhipuProviderID(providerID) {
|
|
127
|
-
return (providerID ===
|
|
128
|
-
providerID ===
|
|
129
|
-
providerID ===
|
|
130
|
-
providerID ===
|
|
152
|
+
return (providerID === "zhipu" ||
|
|
153
|
+
providerID === "bigmodel" ||
|
|
154
|
+
providerID === "z-ai" ||
|
|
155
|
+
providerID === "zhipuai-coding-plan");
|
|
156
|
+
}
|
|
157
|
+
function isCanonicalMiniMaxProviderID(providerID) {
|
|
158
|
+
return providerID === "minimax" || providerID === "minimax-cn-coding-plan";
|
|
131
159
|
}
|
|
132
160
|
export function canonicalPricingProviderID(providerID) {
|
|
133
161
|
const normalized = normalizeKnownProviderID(providerID);
|
|
134
162
|
const lowered = normalized.toLowerCase();
|
|
163
|
+
if (isCanonicalMiniMaxProviderID(lowered)) {
|
|
164
|
+
return "minimax";
|
|
165
|
+
}
|
|
135
166
|
if (isCanonicalZhipuProviderID(lowered)) {
|
|
136
|
-
return
|
|
167
|
+
return "zhipu";
|
|
137
168
|
}
|
|
138
|
-
if (lowered ===
|
|
139
|
-
return
|
|
140
|
-
if (lowered.includes(
|
|
141
|
-
return
|
|
169
|
+
if (lowered === "kimi-for-coding")
|
|
170
|
+
return "moonshotai";
|
|
171
|
+
if (lowered.includes("anthropic") || lowered.includes("claude")) {
|
|
172
|
+
return "anthropic";
|
|
142
173
|
}
|
|
143
|
-
if (lowered.includes(
|
|
144
|
-
return
|
|
145
|
-
if (lowered.includes(
|
|
146
|
-
return
|
|
174
|
+
if (lowered.includes("openai") || lowered.endsWith("-oai"))
|
|
175
|
+
return "openai";
|
|
176
|
+
if (lowered.includes("copilot"))
|
|
177
|
+
return "github-copilot";
|
|
147
178
|
return normalized;
|
|
148
179
|
}
|
|
149
180
|
export function canonicalApiCostProviderID(providerID) {
|
|
150
181
|
const normalized = normalizeKnownProviderID(providerID);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (lowered
|
|
155
|
-
return
|
|
156
|
-
if (lowered.includes(
|
|
157
|
-
return
|
|
158
|
-
if (lowered.includes(
|
|
159
|
-
return
|
|
182
|
+
const lowered = normalized.toLowerCase();
|
|
183
|
+
if (API_COST_ENABLED_PROVIDERS.has(lowered))
|
|
184
|
+
return lowered;
|
|
185
|
+
if (lowered === "minimax")
|
|
186
|
+
return "minimax-cn-coding-plan";
|
|
187
|
+
if (lowered.includes("copilot"))
|
|
188
|
+
return "github-copilot";
|
|
189
|
+
if (lowered.includes("openai") || lowered.endsWith("-oai"))
|
|
190
|
+
return "openai";
|
|
191
|
+
if (lowered.includes("anthropic") || lowered.includes("claude")) {
|
|
192
|
+
return "anthropic";
|
|
160
193
|
}
|
|
161
194
|
if (isCanonicalZhipuProviderID(lowered)) {
|
|
162
|
-
return
|
|
195
|
+
return "zhipu";
|
|
163
196
|
}
|
|
164
197
|
return normalized;
|
|
165
198
|
}
|
|
@@ -200,194 +233,248 @@ function moonshotPricing(input, output, cacheRead) {
|
|
|
200
233
|
cacheWrite: 0,
|
|
201
234
|
};
|
|
202
235
|
}
|
|
236
|
+
function minimaxPricing(input, output, cacheRead, cacheWrite) {
|
|
237
|
+
return {
|
|
238
|
+
input,
|
|
239
|
+
output,
|
|
240
|
+
cacheRead,
|
|
241
|
+
cacheWrite,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
203
244
|
const BUNDLED_CANONICAL_PRICE_ENTRIES = [
|
|
204
245
|
{
|
|
205
|
-
provider:
|
|
206
|
-
model:
|
|
246
|
+
provider: "anthropic",
|
|
247
|
+
model: "claude-opus-4-6",
|
|
207
248
|
rates: anthropicPricing(5, 25),
|
|
208
|
-
source:
|
|
209
|
-
sourceURL:
|
|
249
|
+
source: "official-doc",
|
|
250
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
210
251
|
},
|
|
211
252
|
{
|
|
212
|
-
provider:
|
|
213
|
-
model:
|
|
253
|
+
provider: "anthropic",
|
|
254
|
+
model: "claude-opus-4-5",
|
|
214
255
|
rates: anthropicPricing(5, 25),
|
|
215
|
-
source:
|
|
216
|
-
sourceURL:
|
|
256
|
+
source: "official-doc",
|
|
257
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
217
258
|
},
|
|
218
259
|
{
|
|
219
|
-
provider:
|
|
220
|
-
model:
|
|
260
|
+
provider: "anthropic",
|
|
261
|
+
model: "claude-opus-4-1",
|
|
221
262
|
rates: anthropicPricing(15, 75),
|
|
222
|
-
source:
|
|
223
|
-
sourceURL:
|
|
263
|
+
source: "official-doc",
|
|
264
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
224
265
|
},
|
|
225
266
|
{
|
|
226
|
-
provider:
|
|
227
|
-
model:
|
|
267
|
+
provider: "anthropic",
|
|
268
|
+
model: "claude-opus-4",
|
|
228
269
|
rates: anthropicPricing(15, 75),
|
|
229
|
-
source:
|
|
230
|
-
sourceURL:
|
|
270
|
+
source: "official-doc",
|
|
271
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
231
272
|
},
|
|
232
273
|
{
|
|
233
|
-
provider:
|
|
234
|
-
model:
|
|
274
|
+
provider: "anthropic",
|
|
275
|
+
model: "claude-sonnet-4-6",
|
|
235
276
|
rates: anthropicPricing(3, 15),
|
|
236
|
-
source:
|
|
237
|
-
sourceURL:
|
|
277
|
+
source: "official-doc",
|
|
278
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
238
279
|
},
|
|
239
280
|
{
|
|
240
|
-
provider:
|
|
241
|
-
model:
|
|
281
|
+
provider: "anthropic",
|
|
282
|
+
model: "claude-sonnet-4-5",
|
|
242
283
|
rates: anthropicPricing(3, 15, {
|
|
243
284
|
longContextInput: 6,
|
|
244
285
|
longContextOutput: 22.5,
|
|
245
286
|
}),
|
|
246
|
-
source:
|
|
247
|
-
sourceURL:
|
|
287
|
+
source: "official-doc",
|
|
288
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
248
289
|
},
|
|
249
290
|
{
|
|
250
|
-
provider:
|
|
251
|
-
model:
|
|
291
|
+
provider: "anthropic",
|
|
292
|
+
model: "claude-sonnet-4",
|
|
252
293
|
rates: anthropicPricing(3, 15, {
|
|
253
294
|
longContextInput: 6,
|
|
254
295
|
longContextOutput: 22.5,
|
|
255
296
|
}),
|
|
256
|
-
source:
|
|
257
|
-
sourceURL:
|
|
297
|
+
source: "official-doc",
|
|
298
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
258
299
|
},
|
|
259
300
|
{
|
|
260
|
-
provider:
|
|
261
|
-
model:
|
|
301
|
+
provider: "anthropic",
|
|
302
|
+
model: "claude-3-7-sonnet",
|
|
262
303
|
rates: anthropicPricing(3, 15),
|
|
263
|
-
source:
|
|
264
|
-
sourceURL:
|
|
304
|
+
source: "official-doc",
|
|
305
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
265
306
|
},
|
|
266
307
|
{
|
|
267
|
-
provider:
|
|
268
|
-
model:
|
|
308
|
+
provider: "anthropic",
|
|
309
|
+
model: "claude-3-5-sonnet",
|
|
269
310
|
rates: anthropicPricing(3, 15),
|
|
270
|
-
source:
|
|
271
|
-
sourceURL:
|
|
311
|
+
source: "official-doc",
|
|
312
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
272
313
|
},
|
|
273
314
|
{
|
|
274
|
-
provider:
|
|
275
|
-
model:
|
|
315
|
+
provider: "anthropic",
|
|
316
|
+
model: "claude-haiku-4-5",
|
|
276
317
|
rates: anthropicPricing(1, 5),
|
|
277
|
-
source:
|
|
278
|
-
sourceURL:
|
|
318
|
+
source: "official-doc",
|
|
319
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
279
320
|
},
|
|
280
321
|
{
|
|
281
|
-
provider:
|
|
282
|
-
model:
|
|
322
|
+
provider: "anthropic",
|
|
323
|
+
model: "claude-3-5-haiku",
|
|
283
324
|
rates: anthropicPricing(0.8, 4),
|
|
284
|
-
source:
|
|
285
|
-
sourceURL:
|
|
325
|
+
source: "official-doc",
|
|
326
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
286
327
|
},
|
|
287
328
|
{
|
|
288
|
-
provider:
|
|
289
|
-
model:
|
|
329
|
+
provider: "anthropic",
|
|
330
|
+
model: "claude-3-opus",
|
|
290
331
|
rates: anthropicPricing(15, 75),
|
|
291
|
-
source:
|
|
292
|
-
sourceURL:
|
|
332
|
+
source: "official-doc",
|
|
333
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
293
334
|
},
|
|
294
335
|
{
|
|
295
|
-
provider:
|
|
296
|
-
model:
|
|
336
|
+
provider: "anthropic",
|
|
337
|
+
model: "claude-3-haiku",
|
|
297
338
|
rates: anthropicPricing(0.25, 1.25),
|
|
298
|
-
source:
|
|
299
|
-
sourceURL:
|
|
339
|
+
source: "official-doc",
|
|
340
|
+
sourceURL: "https://docs.anthropic.com/en/docs/about-claude/pricing",
|
|
300
341
|
},
|
|
301
342
|
{
|
|
302
|
-
provider:
|
|
303
|
-
model:
|
|
343
|
+
provider: "zhipu",
|
|
344
|
+
model: "glm-5",
|
|
304
345
|
rates: zhipuPricing(1, 3.2, 0.2),
|
|
305
|
-
source:
|
|
306
|
-
sourceURL:
|
|
346
|
+
source: "official-doc",
|
|
347
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
307
348
|
},
|
|
308
349
|
{
|
|
309
|
-
provider:
|
|
310
|
-
model:
|
|
350
|
+
provider: "zhipu",
|
|
351
|
+
model: "glm-4.7",
|
|
311
352
|
rates: zhipuPricing(0.6, 2.2, 0.11),
|
|
312
|
-
source:
|
|
313
|
-
sourceURL:
|
|
353
|
+
source: "official-doc",
|
|
354
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
314
355
|
},
|
|
315
356
|
{
|
|
316
|
-
provider:
|
|
317
|
-
model:
|
|
357
|
+
provider: "zhipu",
|
|
358
|
+
model: "glm-4.6",
|
|
318
359
|
rates: zhipuPricing(0.6, 2.2, 0.11),
|
|
319
|
-
source:
|
|
320
|
-
sourceURL:
|
|
360
|
+
source: "official-doc",
|
|
361
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
321
362
|
},
|
|
322
363
|
{
|
|
323
|
-
provider:
|
|
324
|
-
model:
|
|
364
|
+
provider: "zhipu",
|
|
365
|
+
model: "glm-4.6v",
|
|
325
366
|
rates: zhipuPricing(0.3, 0.9, 0.05),
|
|
326
|
-
source:
|
|
327
|
-
sourceURL:
|
|
367
|
+
source: "official-doc",
|
|
368
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
328
369
|
},
|
|
329
370
|
{
|
|
330
|
-
provider:
|
|
331
|
-
model:
|
|
371
|
+
provider: "zhipu",
|
|
372
|
+
model: "glm-4.5",
|
|
332
373
|
rates: zhipuPricing(0.6, 2.2, 0.11),
|
|
333
|
-
source:
|
|
334
|
-
sourceURL:
|
|
374
|
+
source: "official-doc",
|
|
375
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
335
376
|
},
|
|
336
377
|
{
|
|
337
|
-
provider:
|
|
338
|
-
model:
|
|
378
|
+
provider: "zhipu",
|
|
379
|
+
model: "glm-4.5-air",
|
|
339
380
|
rates: zhipuPricing(0.2, 1.1, 0.03),
|
|
340
|
-
source:
|
|
341
|
-
sourceURL:
|
|
381
|
+
source: "official-doc",
|
|
382
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
342
383
|
},
|
|
343
384
|
{
|
|
344
|
-
provider:
|
|
345
|
-
model:
|
|
385
|
+
provider: "zhipu",
|
|
386
|
+
model: "glm-4.5v",
|
|
346
387
|
rates: zhipuPricing(0.6, 1.8, 0.11),
|
|
347
|
-
source:
|
|
348
|
-
sourceURL:
|
|
388
|
+
source: "official-doc",
|
|
389
|
+
sourceURL: "https://docs.z.ai/guides/overview/pricing",
|
|
349
390
|
},
|
|
350
391
|
{
|
|
351
|
-
provider:
|
|
352
|
-
model:
|
|
392
|
+
provider: "moonshotai",
|
|
393
|
+
model: "kimi-k2.5",
|
|
353
394
|
rates: moonshotPricing(0.6, 3, 0.1),
|
|
354
|
-
source:
|
|
355
|
-
sourceURL:
|
|
395
|
+
source: "official-doc",
|
|
396
|
+
sourceURL: "https://platform.moonshot.ai/docs/pricing/chat",
|
|
356
397
|
},
|
|
357
398
|
{
|
|
358
|
-
provider:
|
|
359
|
-
model:
|
|
399
|
+
provider: "moonshotai",
|
|
400
|
+
model: "kimi-k2-thinking",
|
|
360
401
|
rates: moonshotPricing(0.6, 2.5, 0.15),
|
|
361
|
-
source:
|
|
362
|
-
sourceURL:
|
|
402
|
+
source: "official-doc",
|
|
403
|
+
sourceURL: "https://platform.moonshot.ai/docs/pricing/chat",
|
|
363
404
|
},
|
|
364
405
|
{
|
|
365
|
-
provider:
|
|
366
|
-
model:
|
|
406
|
+
provider: "moonshotai",
|
|
407
|
+
model: "kimi-k2-0711-preview",
|
|
367
408
|
rates: moonshotPricing(0.6, 2.5, 0.15),
|
|
368
|
-
source:
|
|
369
|
-
sourceURL:
|
|
409
|
+
source: "official-doc",
|
|
410
|
+
sourceURL: "https://platform.moonshot.ai/docs/pricing/chat",
|
|
370
411
|
},
|
|
371
412
|
{
|
|
372
|
-
provider:
|
|
373
|
-
model:
|
|
413
|
+
provider: "moonshotai",
|
|
414
|
+
model: "kimi-k2-0905-preview",
|
|
374
415
|
rates: moonshotPricing(0.6, 2.5, 0.15),
|
|
375
|
-
source:
|
|
376
|
-
sourceURL:
|
|
416
|
+
source: "official-doc",
|
|
417
|
+
sourceURL: "https://platform.moonshot.ai/docs/pricing/chat",
|
|
377
418
|
},
|
|
378
419
|
{
|
|
379
|
-
provider:
|
|
380
|
-
model:
|
|
420
|
+
provider: "moonshotai",
|
|
421
|
+
model: "kimi-k2-turbo-preview",
|
|
381
422
|
rates: moonshotPricing(2.4, 10, 0.6),
|
|
382
|
-
source:
|
|
383
|
-
sourceURL:
|
|
423
|
+
source: "official-doc",
|
|
424
|
+
sourceURL: "https://platform.moonshot.ai/docs/pricing/chat",
|
|
384
425
|
},
|
|
385
426
|
{
|
|
386
|
-
provider:
|
|
387
|
-
model:
|
|
427
|
+
provider: "moonshotai",
|
|
428
|
+
model: "kimi-k2-thinking-turbo",
|
|
388
429
|
rates: moonshotPricing(1.15, 8, 0.15),
|
|
389
|
-
source:
|
|
390
|
-
sourceURL:
|
|
430
|
+
source: "official-doc",
|
|
431
|
+
sourceURL: "https://platform.moonshot.ai/docs/pricing/chat",
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
provider: "minimax",
|
|
435
|
+
model: "MiniMax-M2.7",
|
|
436
|
+
// OpenCode sources provider pricing from models.dev. The bundled MiniMax
|
|
437
|
+
// fallback mirrors those USD-denominated entries rather than the CN RMB
|
|
438
|
+
// docs so API-equivalent cost stays on the same currency basis as the rest
|
|
439
|
+
// of the sidebar/report output.
|
|
440
|
+
rates: minimaxPricing(0.3, 1.2, 0.06, 0.375),
|
|
441
|
+
source: "runtime",
|
|
442
|
+
sourceURL: "https://github.com/anomalyco/models.dev/blob/dev/providers/minimax/models/MiniMax-M2.7.toml",
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
provider: "minimax",
|
|
446
|
+
model: "MiniMax-M2.7-highspeed",
|
|
447
|
+
rates: minimaxPricing(0.6, 2.4, 0.06, 0.375),
|
|
448
|
+
source: "runtime",
|
|
449
|
+
sourceURL: "https://github.com/anomalyco/models.dev/blob/dev/providers/minimax/models/MiniMax-M2.7-highspeed.toml",
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
provider: "minimax",
|
|
453
|
+
model: "MiniMax-M2.5",
|
|
454
|
+
rates: minimaxPricing(0.3, 1.2, 0.03, 0.375),
|
|
455
|
+
source: "runtime",
|
|
456
|
+
sourceURL: "https://github.com/anomalyco/models.dev/blob/dev/providers/minimax/models/MiniMax-M2.5.toml",
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
provider: "minimax",
|
|
460
|
+
model: "MiniMax-M2.5-highspeed",
|
|
461
|
+
rates: minimaxPricing(0.6, 2.4, 0.06, 0.375),
|
|
462
|
+
source: "runtime",
|
|
463
|
+
sourceURL: "https://github.com/anomalyco/models.dev/blob/dev/providers/minimax/models/MiniMax-M2.5-highspeed.toml",
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
provider: "minimax",
|
|
467
|
+
model: "MiniMax-M2.1",
|
|
468
|
+
rates: minimaxPricing(0.3, 1.2, 0.03, 0.375),
|
|
469
|
+
source: "runtime",
|
|
470
|
+
sourceURL: "https://github.com/anomalyco/models.dev/blob/dev/providers/minimax/models/MiniMax-M2.1.toml",
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
provider: "minimax",
|
|
474
|
+
model: "MiniMax-M2",
|
|
475
|
+
rates: minimaxPricing(0.3, 1.2, 0, 0),
|
|
476
|
+
source: "runtime",
|
|
477
|
+
sourceURL: "https://github.com/anomalyco/models.dev/blob/dev/providers/minimax/models/MiniMax-M2.toml",
|
|
391
478
|
},
|
|
392
479
|
];
|
|
393
480
|
export function modelCostKey(providerID, modelID) {
|
|
@@ -400,13 +487,15 @@ export function modelCostLookupKeys(providerID, modelID) {
|
|
|
400
487
|
if (!keys.includes(key))
|
|
401
488
|
keys.push(key);
|
|
402
489
|
};
|
|
403
|
-
const modelIDsFor = (options) => canonicalProviderID ===
|
|
490
|
+
const modelIDsFor = (options) => canonicalProviderID === "anthropic"
|
|
404
491
|
? anthropicModelAliases(modelID)
|
|
405
|
-
: canonicalProviderID ===
|
|
492
|
+
: canonicalProviderID === "zhipu"
|
|
406
493
|
? zhipuModelAliases(modelID)
|
|
407
|
-
: canonicalProviderID ===
|
|
494
|
+
: canonicalProviderID === "moonshotai"
|
|
408
495
|
? moonshotModelAliases(modelID, options)
|
|
409
|
-
:
|
|
496
|
+
: canonicalProviderID === "minimax"
|
|
497
|
+
? minimaxModelAliases(modelID)
|
|
498
|
+
: [modelID];
|
|
410
499
|
for (const candidateModelID of modelIDsFor()) {
|
|
411
500
|
push(modelCostKey(providerID, candidateModelID));
|
|
412
501
|
}
|
|
@@ -452,9 +541,9 @@ export function parseModelCostRates(value) {
|
|
|
452
541
|
if (!isRecord(value))
|
|
453
542
|
return undefined;
|
|
454
543
|
const readRate = (input) => {
|
|
455
|
-
if (typeof input ===
|
|
544
|
+
if (typeof input === "number")
|
|
456
545
|
return input;
|
|
457
|
-
if (typeof input ===
|
|
546
|
+
if (typeof input === "string") {
|
|
458
547
|
const parsed = Number(input);
|
|
459
548
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
460
549
|
}
|
|
@@ -506,12 +595,12 @@ export function guessModelCostDivisor(rates) {
|
|
|
506
595
|
}
|
|
507
596
|
export function cacheCoverageModeFromRates(rates) {
|
|
508
597
|
if (!rates)
|
|
509
|
-
return
|
|
598
|
+
return "none";
|
|
510
599
|
if (rates.cacheWrite > 0)
|
|
511
|
-
return
|
|
600
|
+
return "read-write";
|
|
512
601
|
if (rates.cacheRead > 0)
|
|
513
|
-
return
|
|
514
|
-
return
|
|
602
|
+
return "read-only";
|
|
603
|
+
return "none";
|
|
515
604
|
}
|
|
516
605
|
export function calcEquivalentApiCostForMessage(message, rates) {
|
|
517
606
|
const effectiveRates = message.tokens.input + message.tokens.cache.read > 200_000 &&
|
package/dist/format.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export declare function renderSidebarUsageLines(usage: UsageSummary, config: Quo
|
|
|
27
27
|
showCost?: boolean;
|
|
28
28
|
}): string[];
|
|
29
29
|
export declare function renderSidebarQuotaLines(quotas: QuotaSnapshot[], config: QuotaSidebarConfig): string[];
|
|
30
|
+
export declare function renderSidebarQuotaLineGroups(quotas: QuotaSnapshot[], config: QuotaSidebarConfig): {
|
|
31
|
+
quota: QuotaSnapshot;
|
|
32
|
+
lines: string[];
|
|
33
|
+
}[];
|
|
30
34
|
export declare function renderMarkdownReport(period: string, usage: UsageSummary, quotas: QuotaSnapshot[], options?: {
|
|
31
35
|
showCost?: boolean;
|
|
32
36
|
}): string;
|