opencode-minimax-quota 0.1.3 → 0.1.4
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/dist/tui.js +18 -10
- package/package.json +1 -1
package/dist/tui.js
CHANGED
|
@@ -19,15 +19,16 @@ function getAuthPath() {
|
|
|
19
19
|
}
|
|
20
20
|
function loadApiKey() {
|
|
21
21
|
try {
|
|
22
|
-
const fs = __require("fs");
|
|
23
22
|
const authPath = getAuthPath();
|
|
24
|
-
|
|
25
|
-
const auth = JSON.parse(
|
|
23
|
+
log("authPath:", authPath, "exists:", Bun?.file(authPath) !== void 0);
|
|
24
|
+
const auth = JSON.parse(Bun.file(authPath).text());
|
|
25
|
+
log("auth keys:", Object.keys(auth).join(","));
|
|
26
26
|
const entry = auth["minimax-cn-coding-plan"];
|
|
27
|
+
log("entry:", entry ? "found" : "not found");
|
|
27
28
|
if (!entry) return null;
|
|
28
29
|
return typeof entry === "string" ? entry : entry.key;
|
|
29
30
|
} catch (e) {
|
|
30
|
-
log("loadApiKey error:", e.message);
|
|
31
|
+
log("loadApiKey error:", e.message, e.stack);
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -43,16 +44,22 @@ function parseQuota(data) {
|
|
|
43
44
|
}
|
|
44
45
|
async function fetchQuota() {
|
|
45
46
|
const key = loadApiKey();
|
|
46
|
-
if (!key)
|
|
47
|
+
if (!key) {
|
|
48
|
+
log("fetchQuota: no API key");
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
47
51
|
try {
|
|
48
52
|
const res = await fetch(QUOTA_API, {
|
|
49
53
|
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" }
|
|
50
54
|
});
|
|
51
55
|
const data = await res.json();
|
|
52
|
-
if (data.base_resp?.status_code !== 0)
|
|
56
|
+
if (data.base_resp?.status_code !== 0) {
|
|
57
|
+
log("fetchQuota: API error", data.base_resp);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
53
60
|
return parseQuota(data);
|
|
54
61
|
} catch (e) {
|
|
55
|
-
log("fetchQuota error:", e.message);
|
|
62
|
+
log("fetchQuota error:", e.message, e.stack);
|
|
56
63
|
return null;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
@@ -90,7 +97,7 @@ function Badge(props) {
|
|
|
90
97
|
return curTheme.textMuted;
|
|
91
98
|
},
|
|
92
99
|
get children() {
|
|
93
|
-
return "MiniMax
|
|
100
|
+
return "MiniMax loading...";
|
|
94
101
|
}
|
|
95
102
|
})];
|
|
96
103
|
}
|
|
@@ -179,15 +186,16 @@ var tui = async (api) => {
|
|
|
179
186
|
api.slots.register({
|
|
180
187
|
slots: {
|
|
181
188
|
session_prompt_right() {
|
|
182
|
-
log("renderer called");
|
|
189
|
+
log("renderer called, quota:", quota()?.intervalPct);
|
|
183
190
|
return Badge({ quota, theme: () => api.theme.current });
|
|
184
191
|
}
|
|
185
192
|
}
|
|
186
193
|
});
|
|
187
194
|
log("slot registered");
|
|
188
195
|
const load = async () => {
|
|
196
|
+
log("load() fetching...");
|
|
189
197
|
const q = await fetchQuota();
|
|
190
|
-
log("load got quota:", q?.intervalPct);
|
|
198
|
+
log("load() got quota:", q?.intervalPct);
|
|
191
199
|
setQuota(q);
|
|
192
200
|
};
|
|
193
201
|
api.lifecycle.onDispose(dispose);
|