@jeffreycao/copilot-api 2.6.32 → 2.6.33

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pages/index.html +54 -13
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@jeffreycao/copilot-api",
4
- "version": "2.6.32",
4
+ "version": "2.6.33",
5
5
  "description": "GitHub Copilot, OpenAI Codex, OpenCode Go, and third-party AI provider gateway with OpenAI and Anthropic API compatibility.",
6
6
  "keywords": [
7
7
  "github-copilot",
package/pages/index.html CHANGED
@@ -349,7 +349,11 @@
349
349
  }
350
350
 
351
351
  .metric-grid-tight {
352
- grid-template-columns: repeat(8, minmax(0, 1fr));
352
+ grid-template-columns: repeat(6, minmax(0, 1fr));
353
+ }
354
+
355
+ .metric-grid-tight .metric-label {
356
+ white-space: nowrap;
353
357
  }
354
358
 
355
359
  .metric-card {
@@ -468,9 +472,9 @@
468
472
  gap: 10px;
469
473
  }
470
474
 
471
- @media (max-width: 1280px) {
475
+ @media (max-width: 899px) {
472
476
  .metric-grid-tight {
473
- grid-template-columns: repeat(4, minmax(0, 1fr));
477
+ grid-template-columns: repeat(3, minmax(0, 1fr));
474
478
  }
475
479
  }
476
480
 
@@ -488,7 +492,7 @@
488
492
  }
489
493
  }
490
494
 
491
- @media (max-width: 640px) {
495
+ @media (max-width: 639px) {
492
496
  .main-shell {
493
497
  padding: 12px 14px 18px;
494
498
  }
@@ -1478,11 +1482,30 @@
1478
1482
  * @param {object} details - The details object for the quota.
1479
1483
  * @returns {string} HTML string for a single card.
1480
1484
  */
1485
+ function getCopilotQuotaRemaining(details) {
1486
+ if (Number.isFinite(details.remaining)) return details.remaining;
1487
+ if (Number.isFinite(details.quota_remaining)) {
1488
+ return details.quota_remaining;
1489
+ }
1490
+ return null;
1491
+ }
1492
+
1493
+ function getCopilotQuotaPercentRemaining(details) {
1494
+ if (details.unlimited) return 100;
1495
+ const percent = Number.isFinite(details.percent_remaining)
1496
+ ? details.percent_remaining
1497
+ : Number.isFinite(details.entitlement) && details.entitlement > 0
1498
+ ? ((getCopilotQuotaRemaining(details) ?? details.entitlement) /
1499
+ details.entitlement) * 100
1500
+ : 100;
1501
+ return Math.max(0, Math.min(100, percent));
1502
+ }
1503
+
1481
1504
  function renderQuotaCard(title, details) {
1482
- const { entitlement, remaining, percent_remaining, unlimited } =
1483
- details;
1505
+ const { entitlement, unlimited } = details;
1506
+ const remaining = getCopilotQuotaRemaining(details) ?? 0;
1484
1507
 
1485
- const percentUsed = unlimited ? 0 : 100 - percent_remaining;
1508
+ const percentUsed = 100 - getCopilotQuotaPercentRemaining(details);
1486
1509
  const used = unlimited
1487
1510
  ? "N/A"
1488
1511
  : (entitlement - remaining).toLocaleString();
@@ -1672,6 +1695,9 @@
1672
1695
  getMetricDisplayText(totals.request_count),
1673
1696
  formatTokenUsageCosts(totals.costs),
1674
1697
  ]);
1698
+ const costCurrencies = [
1699
+ ...new Set(totals.costs.map((cost) => cost.currency)),
1700
+ ];
1675
1701
  return [
1676
1702
  renderTokenUsageMetric(
1677
1703
  "Total",
@@ -1715,12 +1741,27 @@
1715
1741
  "var(--color-purple-accent)",
1716
1742
  metricFontSize
1717
1743
  ),
1718
- renderTokenUsageCostMetric(
1719
- "Cost",
1720
- formatTokenUsageCosts(totals.costs),
1721
- "var(--color-yellow-accent)",
1722
- metricFontSize
1723
- ),
1744
+ ...(costCurrencies.length > 0
1745
+ ? costCurrencies.map((currency) =>
1746
+ renderTokenUsageCostMetric(
1747
+ `Cost (${currency})`,
1748
+ formatTokenUsageCost(
1749
+ totals.costs.find(
1750
+ (cost) => cost.currency === currency
1751
+ )
1752
+ ),
1753
+ "var(--color-yellow-accent)",
1754
+ metricFontSize
1755
+ )
1756
+ )
1757
+ : [
1758
+ renderTokenUsageCostMetric(
1759
+ "Cost",
1760
+ formatTokenUsageCosts(totals.costs),
1761
+ "var(--color-yellow-accent)",
1762
+ metricFontSize
1763
+ ),
1764
+ ]),
1724
1765
  ].join("");
1725
1766
  })()
1726
1767
  }