@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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { isRecord, swallow } from "../../helpers.js";
|
|
2
|
+
import { asNumber, configuredProviderEnabled, fetchWithTimeout, resolveApiKey, sanitizeBaseURL, toIso, } from "../common.js";
|
|
3
|
+
const MINIMAX_CN_QUOTA_URL = "https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains";
|
|
4
|
+
const MINIMAX_INTL_QUOTA_URL = "https://www.minimax.io/v1/api/openplatform/coding_plan/remains";
|
|
5
|
+
function parseBaseURL(value) {
|
|
6
|
+
const normalized = sanitizeBaseURL(value);
|
|
7
|
+
if (!normalized)
|
|
8
|
+
return undefined;
|
|
9
|
+
try {
|
|
10
|
+
return new URL(normalized);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function isMiniMaxCodingBaseURL(value) {
|
|
17
|
+
const parsed = parseBaseURL(value);
|
|
18
|
+
if (!parsed || parsed.protocol !== "https:")
|
|
19
|
+
return false;
|
|
20
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
21
|
+
const isKnownHost = parsed.host === "api.minimaxi.com" || parsed.host === "api.minimax.io";
|
|
22
|
+
if (!isKnownHost)
|
|
23
|
+
return false;
|
|
24
|
+
return (pathname === "/v1" ||
|
|
25
|
+
pathname === "/anthropic" ||
|
|
26
|
+
pathname === "/anthropic/v1");
|
|
27
|
+
}
|
|
28
|
+
function quotaUrl(baseURL) {
|
|
29
|
+
const parsed = parseBaseURL(baseURL);
|
|
30
|
+
if (parsed?.host === "api.minimax.io")
|
|
31
|
+
return MINIMAX_INTL_QUOTA_URL;
|
|
32
|
+
return MINIMAX_CN_QUOTA_URL;
|
|
33
|
+
}
|
|
34
|
+
function percentFromRemaining(totalValue, remainingValue) {
|
|
35
|
+
const total = asNumber(totalValue);
|
|
36
|
+
const remaining = asNumber(remainingValue);
|
|
37
|
+
if (total === undefined || remaining === undefined || total <= 0)
|
|
38
|
+
return undefined;
|
|
39
|
+
if (!Number.isFinite(total) || !Number.isFinite(remaining))
|
|
40
|
+
return undefined;
|
|
41
|
+
return Math.max(0, Math.min(100, (remaining / total) * 100));
|
|
42
|
+
}
|
|
43
|
+
function windowSeconds(startTime, endTime) {
|
|
44
|
+
const start = Date.parse(toIso(startTime) || "");
|
|
45
|
+
const end = Date.parse(toIso(endTime) || "");
|
|
46
|
+
if (Number.isNaN(start) || Number.isNaN(end) || end <= start)
|
|
47
|
+
return undefined;
|
|
48
|
+
return Math.floor((end - start) / 1000);
|
|
49
|
+
}
|
|
50
|
+
function windowLabel(seconds, fallback) {
|
|
51
|
+
if (!seconds || seconds <= 0)
|
|
52
|
+
return fallback;
|
|
53
|
+
const hours = seconds / 3600;
|
|
54
|
+
if (hours <= 24)
|
|
55
|
+
return `${Math.round(hours)}h`;
|
|
56
|
+
const days = hours / 24;
|
|
57
|
+
if (days <= 6)
|
|
58
|
+
return `${Math.round(days)}d`;
|
|
59
|
+
return "Weekly";
|
|
60
|
+
}
|
|
61
|
+
function parseWindow(args) {
|
|
62
|
+
const remainingPercent = percentFromRemaining(args.total, args.remaining);
|
|
63
|
+
if (remainingPercent === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
return {
|
|
66
|
+
label: windowLabel(windowSeconds(args.startTime, args.endTime), args.fallbackLabel),
|
|
67
|
+
remainingPercent,
|
|
68
|
+
resetAt: toIso(args.endTime),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function parsePlanName(data) {
|
|
72
|
+
const comboCard = isRecord(data.current_combo_card)
|
|
73
|
+
? data.current_combo_card
|
|
74
|
+
: undefined;
|
|
75
|
+
for (const value of [
|
|
76
|
+
data.current_subscribe_title,
|
|
77
|
+
data.plan_name,
|
|
78
|
+
data.combo_title,
|
|
79
|
+
data.current_plan_title,
|
|
80
|
+
comboCard?.title,
|
|
81
|
+
]) {
|
|
82
|
+
if (typeof value !== "string")
|
|
83
|
+
continue;
|
|
84
|
+
const trimmed = value.trim();
|
|
85
|
+
if (trimmed)
|
|
86
|
+
return trimmed;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
async function fetchMiniMaxCodingPlanQuota({ providerID, providerOptions, auth, config, }) {
|
|
91
|
+
const checkedAt = Date.now();
|
|
92
|
+
const base = {
|
|
93
|
+
providerID,
|
|
94
|
+
adapterID: "minimax-cn-coding-plan",
|
|
95
|
+
label: "MiniMax Coding Plan",
|
|
96
|
+
shortLabel: "MiniMax",
|
|
97
|
+
sortOrder: 17,
|
|
98
|
+
};
|
|
99
|
+
const apiKey = resolveApiKey(auth, providerOptions);
|
|
100
|
+
if (!apiKey) {
|
|
101
|
+
return {
|
|
102
|
+
...base,
|
|
103
|
+
status: "unavailable",
|
|
104
|
+
checkedAt,
|
|
105
|
+
note: "missing api key",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const response = await fetchWithTimeout(quotaUrl(providerOptions?.baseURL), {
|
|
109
|
+
method: "GET",
|
|
110
|
+
headers: {
|
|
111
|
+
Accept: "application/json",
|
|
112
|
+
Authorization: `Bearer ${apiKey}`,
|
|
113
|
+
"Content-Type": "application/json",
|
|
114
|
+
"User-Agent": "opencode-quota-sidebar",
|
|
115
|
+
},
|
|
116
|
+
}, config.quota.requestTimeoutMs).catch(swallow("fetchMiniMaxCodingPlanQuota:usage"));
|
|
117
|
+
if (!response) {
|
|
118
|
+
return {
|
|
119
|
+
...base,
|
|
120
|
+
status: "error",
|
|
121
|
+
checkedAt,
|
|
122
|
+
note: "network request failed",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (!response.ok) {
|
|
126
|
+
return {
|
|
127
|
+
...base,
|
|
128
|
+
status: "error",
|
|
129
|
+
checkedAt,
|
|
130
|
+
note: `http ${response.status}`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const payload = await response
|
|
134
|
+
.json()
|
|
135
|
+
.catch(swallow("fetchMiniMaxCodingPlanQuota:json"));
|
|
136
|
+
if (!isRecord(payload)) {
|
|
137
|
+
return {
|
|
138
|
+
...base,
|
|
139
|
+
status: "error",
|
|
140
|
+
checkedAt,
|
|
141
|
+
note: "invalid response",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const data = isRecord(payload.data) ? payload.data : payload;
|
|
145
|
+
const baseResp = isRecord(data.base_resp)
|
|
146
|
+
? data.base_resp
|
|
147
|
+
: isRecord(payload.base_resp)
|
|
148
|
+
? payload.base_resp
|
|
149
|
+
: undefined;
|
|
150
|
+
const statusCode = asNumber(baseResp?.status_code);
|
|
151
|
+
if (statusCode !== undefined && statusCode !== 0) {
|
|
152
|
+
return {
|
|
153
|
+
...base,
|
|
154
|
+
status: "error",
|
|
155
|
+
checkedAt,
|
|
156
|
+
note: typeof baseResp?.status_msg === "string" && baseResp.status_msg
|
|
157
|
+
? baseResp.status_msg
|
|
158
|
+
: `status_code ${statusCode}`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const modelRemains = Array.isArray(data.model_remains)
|
|
162
|
+
? data.model_remains.filter((item) => isRecord(item))
|
|
163
|
+
: [];
|
|
164
|
+
const firstModel = modelRemains[0];
|
|
165
|
+
if (!firstModel) {
|
|
166
|
+
return {
|
|
167
|
+
...base,
|
|
168
|
+
status: "error",
|
|
169
|
+
checkedAt,
|
|
170
|
+
note: "missing model_remains",
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const intervalWindow = parseWindow({
|
|
174
|
+
total: firstModel.current_interval_total_count,
|
|
175
|
+
remaining: firstModel.current_interval_usage_count,
|
|
176
|
+
startTime: firstModel.start_time,
|
|
177
|
+
endTime: firstModel.end_time,
|
|
178
|
+
fallbackLabel: "5h",
|
|
179
|
+
});
|
|
180
|
+
const weeklyWindow = parseWindow({
|
|
181
|
+
total: firstModel.current_weekly_total_count,
|
|
182
|
+
remaining: firstModel.current_weekly_usage_count,
|
|
183
|
+
startTime: firstModel.weekly_start_time,
|
|
184
|
+
endTime: firstModel.weekly_end_time,
|
|
185
|
+
fallbackLabel: "Weekly",
|
|
186
|
+
});
|
|
187
|
+
const windows = [intervalWindow, weeklyWindow].filter((value) => Boolean(value));
|
|
188
|
+
const primary = windows[0];
|
|
189
|
+
return {
|
|
190
|
+
...base,
|
|
191
|
+
status: primary ? "ok" : "error",
|
|
192
|
+
checkedAt,
|
|
193
|
+
remainingPercent: primary?.remainingPercent,
|
|
194
|
+
resetAt: primary?.resetAt,
|
|
195
|
+
note: parsePlanName(data) || (primary ? undefined : "missing quota fields"),
|
|
196
|
+
windows: windows.length > 0 ? windows : undefined,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export const minimaxCnCodingPlanAdapter = {
|
|
200
|
+
id: "minimax-cn-coding-plan",
|
|
201
|
+
label: "MiniMax Coding Plan",
|
|
202
|
+
shortLabel: "MiniMax",
|
|
203
|
+
sortOrder: 17,
|
|
204
|
+
normalizeID: (providerID) => providerID === "minimax-cn-coding-plan"
|
|
205
|
+
? "minimax-cn-coding-plan"
|
|
206
|
+
: undefined,
|
|
207
|
+
matchScore: ({ providerID, providerOptions }) => {
|
|
208
|
+
if (providerID === "minimax-cn-coding-plan")
|
|
209
|
+
return 100;
|
|
210
|
+
return isMiniMaxCodingBaseURL(providerOptions?.baseURL) ? 95 : 0;
|
|
211
|
+
},
|
|
212
|
+
isEnabled: (config) => configuredProviderEnabled(config.quota, "minimax-cn-coding-plan", true),
|
|
213
|
+
fetch: fetchMiniMaxCodingPlanQuota,
|
|
214
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { QuotaProviderAdapter } from
|
|
1
|
+
import type { QuotaProviderAdapter } from "../types.js";
|
|
2
2
|
export declare const zhipuCodingPlanAdapter: QuotaProviderAdapter;
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import { isRecord, swallow } from
|
|
2
|
-
import { asNumber, configuredProviderEnabled, fetchWithTimeout, sanitizeBaseURL, toIso, } from
|
|
3
|
-
const ZHIPU_QUOTA_URL =
|
|
4
|
-
const ZHIPU_INTL_QUOTA_URL =
|
|
5
|
-
function resolveApiKey(auth, providerOptions) {
|
|
6
|
-
const optionKey = providerOptions?.apiKey;
|
|
7
|
-
if (typeof optionKey === 'string' && optionKey)
|
|
8
|
-
return optionKey;
|
|
9
|
-
if (!auth)
|
|
10
|
-
return undefined;
|
|
11
|
-
if (auth.type === 'api' && typeof auth.key === 'string' && auth.key) {
|
|
12
|
-
return auth.key;
|
|
13
|
-
}
|
|
14
|
-
if (auth.type === 'wellknown') {
|
|
15
|
-
if (typeof auth.key === 'string' && auth.key)
|
|
16
|
-
return auth.key;
|
|
17
|
-
if (typeof auth.token === 'string' && auth.token)
|
|
18
|
-
return auth.token;
|
|
19
|
-
}
|
|
20
|
-
if (auth.type === 'oauth' && typeof auth.access === 'string' && auth.access) {
|
|
21
|
-
return auth.access;
|
|
22
|
-
}
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
1
|
+
import { isRecord, swallow } from "../../helpers.js";
|
|
2
|
+
import { asNumber, configuredProviderEnabled, fetchWithTimeout, resolveApiKey, sanitizeBaseURL, toIso, } from "../common.js";
|
|
3
|
+
const ZHIPU_QUOTA_URL = "https://bigmodel.cn/api/monitor/usage/quota/limit";
|
|
4
|
+
const ZHIPU_INTL_QUOTA_URL = "https://api.z.ai/api/monitor/usage/quota/limit";
|
|
25
5
|
function parseBaseURL(value) {
|
|
26
6
|
const normalized = sanitizeBaseURL(value);
|
|
27
7
|
if (!normalized)
|
|
@@ -35,17 +15,17 @@ function parseBaseURL(value) {
|
|
|
35
15
|
}
|
|
36
16
|
function isZhipuCodingBaseURL(value) {
|
|
37
17
|
const parsed = parseBaseURL(value);
|
|
38
|
-
if (!parsed || parsed.protocol !==
|
|
18
|
+
if (!parsed || parsed.protocol !== "https:")
|
|
39
19
|
return false;
|
|
40
|
-
const pathname = parsed.pathname.replace(/\/+$/,
|
|
41
|
-
const isKnownHost = parsed.host ===
|
|
20
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
21
|
+
const isKnownHost = parsed.host === "open.bigmodel.cn" || parsed.host === "api.z.ai";
|
|
42
22
|
if (!isKnownHost)
|
|
43
23
|
return false;
|
|
44
|
-
return pathname ===
|
|
24
|
+
return pathname === "/api/anthropic" || pathname === "/api/coding/paas/v4";
|
|
45
25
|
}
|
|
46
26
|
function quotaUrl(baseURL) {
|
|
47
27
|
const parsed = parseBaseURL(baseURL);
|
|
48
|
-
if (parsed?.host ===
|
|
28
|
+
if (parsed?.host === "api.z.ai")
|
|
49
29
|
return ZHIPU_INTL_QUOTA_URL;
|
|
50
30
|
return ZHIPU_QUOTA_URL;
|
|
51
31
|
}
|
|
@@ -66,22 +46,22 @@ function tokenWindowLabel(unit, count) {
|
|
|
66
46
|
return `${Math.round(countValue)}h`;
|
|
67
47
|
}
|
|
68
48
|
if (unitValue === 1 && countValue === 7)
|
|
69
|
-
return
|
|
49
|
+
return "Weekly";
|
|
70
50
|
if (unitValue === 1 && countValue && countValue > 0) {
|
|
71
51
|
return `${Math.round(countValue)}d`;
|
|
72
52
|
}
|
|
73
53
|
if (unitValue === 5 && countValue && countValue > 0) {
|
|
74
54
|
return `${Math.round(countValue)}m`;
|
|
75
55
|
}
|
|
76
|
-
return
|
|
56
|
+
return "Tokens";
|
|
77
57
|
}
|
|
78
58
|
function formatCountValue(value) {
|
|
79
59
|
if (!Number.isFinite(value))
|
|
80
|
-
return
|
|
60
|
+
return "0";
|
|
81
61
|
return Number.isInteger(value) ? String(value) : value.toFixed(1);
|
|
82
62
|
}
|
|
83
63
|
function parseTokenWindow(value) {
|
|
84
|
-
if (value.type !==
|
|
64
|
+
if (value.type !== "TOKENS_LIMIT")
|
|
85
65
|
return undefined;
|
|
86
66
|
const usedPercent = normalizeUsedPercent(value.percentage);
|
|
87
67
|
if (usedPercent === undefined)
|
|
@@ -97,68 +77,68 @@ async function fetchZhipuCodingPlanQuota({ providerID, providerOptions, auth, co
|
|
|
97
77
|
const checkedAt = Date.now();
|
|
98
78
|
const base = {
|
|
99
79
|
providerID,
|
|
100
|
-
adapterID:
|
|
101
|
-
label:
|
|
102
|
-
shortLabel:
|
|
80
|
+
adapterID: "zhipuai-coding-plan",
|
|
81
|
+
label: "Zhipu Coding Plan",
|
|
82
|
+
shortLabel: "Zhipu",
|
|
103
83
|
sortOrder: 16,
|
|
104
84
|
};
|
|
105
85
|
const apiKey = resolveApiKey(auth, providerOptions);
|
|
106
86
|
if (!apiKey) {
|
|
107
87
|
return {
|
|
108
88
|
...base,
|
|
109
|
-
status:
|
|
89
|
+
status: "unavailable",
|
|
110
90
|
checkedAt,
|
|
111
|
-
note:
|
|
91
|
+
note: "missing api key",
|
|
112
92
|
};
|
|
113
93
|
}
|
|
114
94
|
const response = await fetchWithTimeout(quotaUrl(providerOptions?.baseURL), {
|
|
115
|
-
method:
|
|
95
|
+
method: "GET",
|
|
116
96
|
headers: {
|
|
117
|
-
Accept:
|
|
97
|
+
Accept: "application/json",
|
|
118
98
|
Authorization: apiKey,
|
|
119
|
-
|
|
120
|
-
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
"User-Agent": "opencode-quota-sidebar",
|
|
121
101
|
},
|
|
122
|
-
}, config.quota.requestTimeoutMs).catch(swallow(
|
|
102
|
+
}, config.quota.requestTimeoutMs).catch(swallow("fetchZhipuCodingPlanQuota:usage"));
|
|
123
103
|
if (!response) {
|
|
124
104
|
return {
|
|
125
105
|
...base,
|
|
126
|
-
status:
|
|
106
|
+
status: "error",
|
|
127
107
|
checkedAt,
|
|
128
|
-
note:
|
|
108
|
+
note: "network request failed",
|
|
129
109
|
};
|
|
130
110
|
}
|
|
131
111
|
if (!response.ok) {
|
|
132
112
|
return {
|
|
133
113
|
...base,
|
|
134
|
-
status:
|
|
114
|
+
status: "error",
|
|
135
115
|
checkedAt,
|
|
136
116
|
note: `http ${response.status}`,
|
|
137
117
|
};
|
|
138
118
|
}
|
|
139
119
|
const payload = await response
|
|
140
120
|
.json()
|
|
141
|
-
.catch(swallow(
|
|
121
|
+
.catch(swallow("fetchZhipuCodingPlanQuota:json"));
|
|
142
122
|
if (!isRecord(payload)) {
|
|
143
123
|
return {
|
|
144
124
|
...base,
|
|
145
|
-
status:
|
|
125
|
+
status: "error",
|
|
146
126
|
checkedAt,
|
|
147
|
-
note:
|
|
127
|
+
note: "invalid response",
|
|
148
128
|
};
|
|
149
129
|
}
|
|
150
130
|
if (payload.success !== true || asNumber(payload.code) !== 200) {
|
|
151
131
|
return {
|
|
152
132
|
...base,
|
|
153
|
-
status:
|
|
133
|
+
status: "error",
|
|
154
134
|
checkedAt,
|
|
155
|
-
note: typeof payload.msg ===
|
|
135
|
+
note: typeof payload.msg === "string" && payload.msg
|
|
156
136
|
? payload.msg
|
|
157
|
-
:
|
|
137
|
+
: "quota request failed",
|
|
158
138
|
};
|
|
159
139
|
}
|
|
160
140
|
const data = isRecord(payload.data) ? payload.data : undefined;
|
|
161
|
-
const level = typeof data?.level ===
|
|
141
|
+
const level = typeof data?.level === "string" && data.level
|
|
162
142
|
? `${data.level.toUpperCase()} plan`
|
|
163
143
|
: undefined;
|
|
164
144
|
const limits = Array.isArray(data?.limits)
|
|
@@ -171,25 +151,25 @@ async function fetchZhipuCodingPlanQuota({ providerID, providerOptions, auth, co
|
|
|
171
151
|
const primary = token || windows[0];
|
|
172
152
|
return {
|
|
173
153
|
...base,
|
|
174
|
-
status: primary ?
|
|
154
|
+
status: primary ? "ok" : "error",
|
|
175
155
|
checkedAt,
|
|
176
156
|
remainingPercent: primary?.remainingPercent,
|
|
177
157
|
resetAt: primary?.resetAt,
|
|
178
|
-
note: primary ? level :
|
|
158
|
+
note: primary ? level : "missing quota fields",
|
|
179
159
|
windows: windows.length > 0 ? windows : undefined,
|
|
180
160
|
};
|
|
181
161
|
}
|
|
182
162
|
export const zhipuCodingPlanAdapter = {
|
|
183
|
-
id:
|
|
184
|
-
label:
|
|
185
|
-
shortLabel:
|
|
163
|
+
id: "zhipuai-coding-plan",
|
|
164
|
+
label: "Zhipu Coding Plan",
|
|
165
|
+
shortLabel: "Zhipu",
|
|
186
166
|
sortOrder: 16,
|
|
187
|
-
normalizeID: (providerID) => providerID ===
|
|
167
|
+
normalizeID: (providerID) => providerID === "zhipuai-coding-plan" ? "zhipuai-coding-plan" : undefined,
|
|
188
168
|
matchScore: ({ providerID, providerOptions }) => {
|
|
189
|
-
if (providerID ===
|
|
169
|
+
if (providerID === "zhipuai-coding-plan")
|
|
190
170
|
return 100;
|
|
191
171
|
return isZhipuCodingBaseURL(providerOptions?.baseURL) ? 95 : 0;
|
|
192
172
|
},
|
|
193
|
-
isEnabled: (config) => configuredProviderEnabled(config.quota,
|
|
173
|
+
isEnabled: (config) => configuredProviderEnabled(config.quota, "zhipuai-coding-plan", true),
|
|
194
174
|
fetch: fetchZhipuCodingPlanQuota,
|
|
195
175
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { anthropicAdapter } from './core/anthropic.js';
|
|
2
|
-
import { buzzAdapter } from './third_party/buzz.js';
|
|
3
2
|
import { copilotAdapter } from './core/copilot.js';
|
|
4
3
|
import { kimiForCodingAdapter } from './core/kimi_for_coding.js';
|
|
4
|
+
import { minimaxCnCodingPlanAdapter } from './core/minimax_cn_coding_plan.js';
|
|
5
5
|
import { openaiAdapter } from './core/openai.js';
|
|
6
6
|
import { zhipuCodingPlanAdapter } from './core/zhipu_coding_plan.js';
|
|
7
7
|
import { QuotaProviderRegistry } from './registry.js';
|
|
8
8
|
import { rightCodeAdapter } from './third_party/rightcode.js';
|
|
9
|
-
import {
|
|
9
|
+
import { xyaiAdapter } from './third_party/xyai.js';
|
|
10
10
|
export declare function createDefaultProviderRegistry(): QuotaProviderRegistry;
|
|
11
|
-
export { anthropicAdapter,
|
|
11
|
+
export { anthropicAdapter, copilotAdapter, kimiForCodingAdapter, minimaxCnCodingPlanAdapter, openaiAdapter, rightCodeAdapter, xyaiAdapter, zhipuCodingPlanAdapter, QuotaProviderRegistry, };
|
|
12
12
|
export type { AuthUpdate, AuthValue, ProviderResolveContext, QuotaFetchContext, QuotaProviderAdapter, RefreshedOAuthAuth, } from './types.js';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { anthropicAdapter } from './core/anthropic.js';
|
|
2
|
-
import { buzzAdapter } from './third_party/buzz.js';
|
|
3
2
|
import { copilotAdapter } from './core/copilot.js';
|
|
4
3
|
import { kimiForCodingAdapter } from './core/kimi_for_coding.js';
|
|
4
|
+
import { minimaxCnCodingPlanAdapter } from './core/minimax_cn_coding_plan.js';
|
|
5
5
|
import { openaiAdapter } from './core/openai.js';
|
|
6
6
|
import { zhipuCodingPlanAdapter } from './core/zhipu_coding_plan.js';
|
|
7
7
|
import { QuotaProviderRegistry } from './registry.js';
|
|
8
8
|
import { rightCodeAdapter } from './third_party/rightcode.js';
|
|
9
|
-
import {
|
|
9
|
+
import { xyaiAdapter } from './third_party/xyai.js';
|
|
10
10
|
export function createDefaultProviderRegistry() {
|
|
11
11
|
const registry = new QuotaProviderRegistry();
|
|
12
12
|
registry.register(rightCodeAdapter);
|
|
13
|
-
registry.register(
|
|
14
|
-
registry.register(xyaiVibeAdapter);
|
|
13
|
+
registry.register(xyaiAdapter);
|
|
15
14
|
registry.register(kimiForCodingAdapter);
|
|
16
15
|
registry.register(zhipuCodingPlanAdapter);
|
|
16
|
+
registry.register(minimaxCnCodingPlanAdapter);
|
|
17
17
|
registry.register(openaiAdapter);
|
|
18
18
|
registry.register(copilotAdapter);
|
|
19
19
|
registry.register(anthropicAdapter);
|
|
20
20
|
return registry;
|
|
21
21
|
}
|
|
22
|
-
export { anthropicAdapter,
|
|
22
|
+
export { anthropicAdapter, copilotAdapter, kimiForCodingAdapter, minimaxCnCodingPlanAdapter, openaiAdapter, rightCodeAdapter, xyaiAdapter, zhipuCodingPlanAdapter, QuotaProviderRegistry, };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { QuotaProviderAdapter } from
|
|
1
|
+
import type { QuotaProviderAdapter } from "../types.js";
|
|
2
2
|
export declare const rightCodeAdapter: QuotaProviderAdapter;
|