opencode-statboard 2.10.33 → 2.10.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-statboard",
3
- "version": "2.10.33",
3
+ "version": "2.10.34",
4
4
  "description": "Real-time dashboard for opencode token usage and cost statistics",
5
5
  "main": "server.js",
6
6
  "bin": {
package/public/index.html CHANGED
@@ -62,6 +62,7 @@
62
62
  .scrollx table { min-width: 1080px; }
63
63
  td.clip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
64
64
  .track { background: #1a1f2a; border-radius: 6px; height: 14px; overflow: hidden; }
65
+ .track .fill { height: 100%; border-radius: 6px; transition: width 0.3s ease; }
65
66
  .track.share { min-width: 90px; height: 12px; }
66
67
  /* horizontal bar list (tools). The container must NOT be a .bar-row — each
67
68
  child is a grid item, so a grid container here collapses all rows into
@@ -423,6 +424,8 @@ const STRINGS = {
423
424
  statsFail: 'Failed to read opencode stats', connFail: 'Connection failed', reportFail: 'Failed to read usage report',
424
425
  langBtn: '繁中',
425
426
  backup: 'Backup DB', backingUp: 'Backing up…', backupFail: 'Backup failed',
427
+ unlimited: 'unlimited', freeRpd: 'free RPD', left: 'left', budgetValue: 'budget', freeTier: '[free tier]',
428
+ remaining: 'remaining', used: 'used', quotaReset: 'reset 00:00 UTC = 08:00 TW', cached: 'cached 5 min',
426
429
  },
427
430
  'zh-TW': {
428
431
  title: 'opencode 用量儀表板',
@@ -472,6 +475,8 @@ const STRINGS = {
472
475
  statsFail: 'opencode stats 讀取失敗', connFail: '連線失敗', reportFail: '用量報告讀取失敗',
473
476
  langBtn: 'EN',
474
477
  backup: '備份 DB', backingUp: '備份中…', backupFail: '備份失敗',
478
+ unlimited: '無限制', freeRpd: '免費 RPD', left: '剩', budgetValue: '預算剩', freeTier: '[免費層]',
479
+ remaining: '剩餘', used: '已用', quotaReset: '重置 00:00 UTC = 08:00 台灣', cached: '快取 5 分鐘',
475
480
  }
476
481
  };
477
482
 
@@ -761,30 +766,30 @@ function renderQuota(q) {
761
766
  const free = a.freeModelDaily || {};
762
767
  const rem = a.remainingUsd != null ? fmtUsd(a.remainingUsd) : '—';
763
768
  const used = fmtUsd(a.usedUsd || 0);
764
- const lim = a.limitUsd != null ? fmtUsd(a.limitUsd) : 'unlimited';
769
+ const lim = a.limitUsd != null ? fmtUsd(a.limitUsd) : t('unlimited');
765
770
  const pct = (a.limitUsd && a.limitUsd > 0) ? Math.round(((a.usedUsd || 0) / a.limitUsd) * 100) : null;
766
771
  const freePct = (free.limit && free.limit > 0) ? Math.round((free.used / free.limit) * 100) : 0;
767
772
  const freeLine = free.limit != null
768
- ? '<div style="margin-top:4px">free RPD ' + fmt(free.used) + '/' + fmt(free.limit) + ' (left ' + fmt(free.remaining) + ')</div>'
773
+ ? '<div style="margin-top:4px">' + t('freeRpd') + ' ' + fmt(free.used) + '/' + fmt(free.limit) + ' (' + t('left') + ' ' + fmt(free.remaining) + ')</div>'
769
774
  + '<div class="track" style="margin-top:2px"><div class="fill" style="width:' + freePct + '%;background:' + (freePct > 80 ? 'var(--out)' : 'var(--in)') + '"></div></div>'
770
775
  : '';
771
- const bud = a.budgetRemaining != null ? '<div style="margin-top:4px;color:var(--muted)">budget left ' + fmtUsd(a.budgetRemaining) + '</div>' : '';
776
+ const bud = a.budgetRemaining != null ? '<div style="margin-top:4px;color:var(--muted)">' + t('budgetValue') + ' ' + fmtUsd(a.budgetRemaining) + '</div>' : '';
772
777
  const barColor = pct != null && pct > 80 ? 'var(--out)' : pct != null && pct > 50 ? 'var(--cache)' : 'var(--in)';
773
778
  return '<div style="margin-bottom:12px;padding:12px;background:var(--bg);border:1px solid var(--border);border-radius:8px">'
774
779
  + '<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">'
775
780
  + '<b style="color:var(--text)">' + esc(a.label) + '</b>'
776
- + '<span style="font-size:11px;color:var(--muted)">' + (a.isFreeTier ? '[free tier]' : '') + '</span>'
781
+ + '<span style="font-size:11px;color:var(--muted)">' + (a.isFreeTier ? t('freeTier') : '') + '</span>'
777
782
  + '</div>'
778
783
  + '<div style="display:flex;justify-content:space-between;font-size:12px;margin-bottom:4px">'
779
- + '<span>remaining <b>' + rem + '</b> / ' + lim + '</span>'
780
- + '<span style="color:var(--muted)">used ' + used + '</span>'
784
+ + '<span>' + t('remaining') + ' <b>' + rem + '</b> / ' + lim + '</span>'
785
+ + '<span style="color:var(--muted)">' + t('used') + ' ' + used + '</span>'
781
786
  + '</div>'
782
787
  + (pct != null ? '<div class="track"><div class="fill" style="width:' + pct + '%;background:' + barColor + '"></div></div>' : '')
783
788
  + freeLine
784
789
  + bud
785
790
  + '</div>';
786
791
  }).join('');
787
- body.innerHTML = rows + '<div style="color:var(--muted);font-size:10px;margin-top:8px;text-align:center">reset 00:00 UTC = 08:00 TW · cached 5 min</div>';
792
+ body.innerHTML = rows + '<div style="color:var(--muted);font-size:10px;margin-top:8px;text-align:center">' + t('quotaReset') + ' · ' + t('cached') + '</div>';
788
793
  }
789
794
  async function loadQuota() {
790
795
  try { const r = await fetch('/api/openrouter-quota?_=' + Date.now(), { cache: 'no-store' }); const j = await r.json(); renderQuota(j); } catch (e) { $('quota-body').textContent = 'load failed: ' + e.message; }
@@ -1069,6 +1074,7 @@ async function poll() {
1069
1074
  lastUpdatedText = t('lastUpdated') + ' ' + time + ' (' + t('dataAgo') + ' ' + ago + 's)';
1070
1075
  $('updated').textContent = lastUpdatedText;
1071
1076
  refreshCurrentReport(); // auto-refresh report panels
1077
+ loadQuota(); // keep quota/RPD fresh on a 24/7 dashboard (server caches 5 min, so this is cheap)
1072
1078
  return j;
1073
1079
  } catch (e) {
1074
1080
  $('updated').textContent = t('connFail') + ': ' + e.message;
package/server.js CHANGED
@@ -1576,12 +1576,15 @@ async function fetchOpenRouterQuota() {
1576
1576
  const j = await r.json();
1577
1577
  const d = j.data || {};
1578
1578
  const eb = d.effective_budget || {};
1579
+ // free_model_daily_requests is account-level (shared across all keys of the same account).
1580
+ // Only show RPD for the free tier key; paid keys don't have their own RPD.
1581
+ const isFree = !!d.is_free_tier;
1579
1582
  accounts.push({
1580
1583
  label, limitUsd: d.limit != null ? d.limit : null, usedUsd: d.usage || 0,
1581
1584
  remainingUsd: d.limit_remaining != null ? d.limit_remaining : null,
1582
1585
  dailyUsed: d.usage_daily || 0, weeklyUsed: d.usage_weekly || 0, monthlyUsed: d.usage_monthly || 0,
1583
- isFreeTier: !!d.is_free_tier, expiresAt: d.expires_at || null,
1584
- freeModelDaily: d.free_model_daily_requests || null,
1586
+ isFreeTier: isFree, expiresAt: d.expires_at || null,
1587
+ freeModelDaily: isFree ? (d.free_model_daily_requests || null) : null,
1585
1588
  budgetScope: eb.scope || null, budgetLimit: eb.limit_usd != null ? eb.limit_usd : null,
1586
1589
  budgetSpend: eb.spend_usd != null ? eb.spend_usd : null,
1587
1590
  budgetRemaining: eb.remaining_usd != null ? eb.remaining_usd : null,