opencode-usage 0.5.7 → 0.5.10

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.
@@ -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-ybRDM9XN.js"></script>
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-ybRDM9XN.js"></script>
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
@@ -415,6 +415,16 @@ async function refreshSingleCodexToken(alias, account, storePath) {
415
415
  }
416
416
  }
417
417
  async function proactiveRefreshCodexTokens() {
418
+ if (_proactiveRefreshRunning)
419
+ return;
420
+ _proactiveRefreshRunning = true;
421
+ try {
422
+ await _proactiveRefreshCodexTokensInner();
423
+ } finally {
424
+ _proactiveRefreshRunning = false;
425
+ }
426
+ }
427
+ async function _proactiveRefreshCodexTokensInner() {
418
428
  const STORE_PATHS = [
419
429
  join8(homedir6(), ".config", "opencode", "codex-multi-account-accounts.json"),
420
430
  join8(homedir6(), ".config", "opencode", "codex-multi-accounts.json"),
@@ -437,6 +447,10 @@ async function proactiveRefreshCodexTokens() {
437
447
  const now = Date.now();
438
448
  let refreshed = 0;
439
449
  for (const [alias, account] of Object.entries(accounts)) {
450
+ if (account.authInvalid === true) {
451
+ console.log(`[proactiveRefresh] ${alias}: authInvalid, skipping (needs reauth)`);
452
+ continue;
453
+ }
440
454
  const expiresAt = typeof account.expiresAt === "number" ? account.expiresAt : 0;
441
455
  const lastRefresh = typeof account.lastRefresh === "string" ? new Date(account.lastRefresh).getTime() : 0;
442
456
  const timeSinceRefresh = now - lastRefresh;
@@ -619,7 +633,7 @@ function reauthCliCommand(provider) {
619
633
  throw new Error(`Re-auth not supported for provider: ${provider}`);
620
634
  return cmd;
621
635
  }
622
- var isBun4, PROVIDER_SOURCE, CODEX_TOKEN_URL = "https://auth.openai.com/oauth/token", CODEX_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann", REFRESH_COOLDOWN_MS, bunxQueue, REAUTH_PROVIDERS;
636
+ var isBun4, PROVIDER_SOURCE, CODEX_TOKEN_URL = "https://auth.openai.com/oauth/token", CODEX_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann", REFRESH_COOLDOWN_MS, _proactiveRefreshRunning = false, bunxQueue, REAUTH_PROVIDERS;
623
637
  var init_plugin_adapters = __esm(() => {
624
638
  init_command_runner();
625
639
  init_config_service();
@@ -746,7 +760,11 @@ var init_plugin_adapters = __esm(() => {
746
760
  input.alias
747
761
  ]);
748
762
  const status = String(result.status ?? "error");
763
+ const quota = result.quota;
749
764
  ctx.log("info", `Result: ${status}`);
765
+ if (quota) {
766
+ ctx.log("info", `Quota from ping: ${JSON.stringify(quota)}`);
767
+ }
750
768
  if (status === "ok") {
751
769
  await clearStaleMetrics(input.provider, input.alias);
752
770
  }
@@ -31154,4 +31172,4 @@ async function main2() {
31154
31172
  var WATCH_INTERVAL_MS = 5 * 60 * 1000;
31155
31173
  main2().catch(console.error);
31156
31174
 
31157
- //# debugId=31E49E1C5B0730A864756E2164756E21
31175
+ //# debugId=8161BB1074E571D664756E2164756E21