opencode-usage 0.5.6 → 0.5.8
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/commander-ui/assets/index-Ctp6fkHv.js +20 -0
- package/dist/commander-ui/dist/assets/index-Ctp6fkHv.js +20 -0
- package/dist/commander-ui/dist/index.html +1 -1
- package/dist/commander-ui/index.html +1 -1
- package/dist/index.js +47 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/commander-ui/assets/index-ybRDM9XN.js +0 -20
- package/dist/commander-ui/dist/assets/index-ybRDM9XN.js +0 -20
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
if (d) document.documentElement.classList.add("dark");
|
|
15
15
|
})();
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-Ctp6fkHv.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-BQeHKMP0.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
if (d) document.documentElement.classList.add("dark");
|
|
15
15
|
})();
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-Ctp6fkHv.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-BQeHKMP0.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -321,6 +321,31 @@ async function directCodexPing(alias) {
|
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
+
async function tryDirectCodexRefresh(alias) {
|
|
325
|
+
const STORE_PATHS = [
|
|
326
|
+
join8(homedir6(), ".config", "opencode", "codex-multi-account-accounts.json"),
|
|
327
|
+
join8(homedir6(), ".config", "opencode", "codex-multi-accounts.json"),
|
|
328
|
+
join8(homedir6(), ".config", "oc-codex-multi-account", "accounts.json")
|
|
329
|
+
];
|
|
330
|
+
let storePath = null;
|
|
331
|
+
let store = null;
|
|
332
|
+
for (const p of STORE_PATHS) {
|
|
333
|
+
try {
|
|
334
|
+
store = JSON.parse(await Bun.file(p).text());
|
|
335
|
+
storePath = p;
|
|
336
|
+
break;
|
|
337
|
+
} catch {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (!store || !storePath)
|
|
342
|
+
return false;
|
|
343
|
+
const accounts = store.accounts ?? {};
|
|
344
|
+
const account = accounts[alias];
|
|
345
|
+
if (!account)
|
|
346
|
+
return false;
|
|
347
|
+
return refreshSingleCodexToken(alias, account, storePath);
|
|
348
|
+
}
|
|
324
349
|
function decodeJwtPayload(token) {
|
|
325
350
|
try {
|
|
326
351
|
const parts = token.split(".");
|
|
@@ -417,7 +442,13 @@ async function proactiveRefreshCodexTokens() {
|
|
|
417
442
|
const timeSinceRefresh = now - lastRefresh;
|
|
418
443
|
const timeToExpiry = expiresAt - now;
|
|
419
444
|
if (timeToExpiry <= 0) {
|
|
420
|
-
console.log(`[proactiveRefresh] ${alias}: token expired,
|
|
445
|
+
console.log(`[proactiveRefresh] ${alias}: token expired, attempting refresh\u2026`);
|
|
446
|
+
const ok2 = await refreshSingleCodexToken(alias, account, storePath);
|
|
447
|
+
if (ok2) {
|
|
448
|
+
refreshed++;
|
|
449
|
+
} else {
|
|
450
|
+
console.log(`[proactiveRefresh] ${alias}: refresh failed \u2014 needs reauth`);
|
|
451
|
+
}
|
|
421
452
|
continue;
|
|
422
453
|
}
|
|
423
454
|
if (timeSinceRefresh < REFRESH_COOLDOWN_MS) {
|
|
@@ -715,7 +746,11 @@ var init_plugin_adapters = __esm(() => {
|
|
|
715
746
|
input.alias
|
|
716
747
|
]);
|
|
717
748
|
const status = String(result.status ?? "error");
|
|
749
|
+
const quota = result.quota;
|
|
718
750
|
ctx.log("info", `Result: ${status}`);
|
|
751
|
+
if (quota) {
|
|
752
|
+
ctx.log("info", `Quota from ping: ${JSON.stringify(quota)}`);
|
|
753
|
+
}
|
|
719
754
|
if (status === "ok") {
|
|
720
755
|
await clearStaleMetrics(input.provider, input.alias);
|
|
721
756
|
}
|
|
@@ -735,7 +770,16 @@ var init_plugin_adapters = __esm(() => {
|
|
|
735
770
|
return { status: "ok", message: "pong" };
|
|
736
771
|
}
|
|
737
772
|
if (direct.status === "expired") {
|
|
738
|
-
ctx.log("info", "Token expired \u2014
|
|
773
|
+
ctx.log("info", "Token expired \u2014 attempting direct token refresh\u2026");
|
|
774
|
+
const directRefreshOk = await tryDirectCodexRefresh(input.alias);
|
|
775
|
+
if (directRefreshOk) {
|
|
776
|
+
const rePing = await directCodexPing(input.alias);
|
|
777
|
+
if (rePing.status === "ok") {
|
|
778
|
+
await clearStaleMetrics(input.provider, input.alias);
|
|
779
|
+
return { status: "ok", message: "pong (token refreshed)" };
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
ctx.log("info", "Direct refresh failed \u2014 trying plugin CLI\u2026");
|
|
739
783
|
try {
|
|
740
784
|
const result = await spawnPluginCli("oc-codex-multi-account", [
|
|
741
785
|
"ping",
|
|
@@ -31114,4 +31158,4 @@ async function main2() {
|
|
|
31114
31158
|
var WATCH_INTERVAL_MS = 5 * 60 * 1000;
|
|
31115
31159
|
main2().catch(console.error);
|
|
31116
31160
|
|
|
31117
|
-
//# debugId=
|
|
31161
|
+
//# debugId=5A3E5FE73F68D7CA64756E2164756E21
|