A new kind of package: a page in magpie's window (magpie.page), with magpie.permissions ["usage:summary"] and nothing else. Today, 7 or 30 days; models by tokens, calls or cost; the picks are saved through magpie.options.set (debounced past the bridge's once-a-second limit). Theme from --magpie-* variables; en and zh text. Run: - bun test packages/usage: 6 tests (permissions are exactly what the scripts read; no fetch/XHR/WebSocket; no inline scripts; every local reference exists; what tiles and rows say). - Sandbox magpie from yetone/magpie origin/main b03031738: `magpie plugin` lists "page Usage glance (reads usage:summary)". `magpie web` on 127.0.0.1:3595 serves every page file under the sandbox CSP (connect-src 'none'); /api/plugin-pages/read usage:summary answers the sandbox's 10 calls; providers:list is refused 403. Headless Chromium and WebKit (playwright 1.62.0) opened the sidebar tab: tiles "Calls 10, Errors 0, Tokens 70, Cost $0", row "stub-1 70 · 10 calls", no console errors; picking 7 days wrote "period": "7d" to plugins.json.
38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Usage glance</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<script src="_magpie/bridge.js"></script>
|
|
<script src="view.js"></script>
|
|
<script src="app.js" defer></script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1 data-t="title">Usage</h1>
|
|
<div class="seg" role="tablist" id="periods">
|
|
<button type="button" role="tab" data-period="today" data-t="today">Today</button>
|
|
<button type="button" role="tab" data-period="7d" data-t="7d">7 days</button>
|
|
<button type="button" role="tab" data-period="30d" data-t="30d">30 days</button>
|
|
</div>
|
|
</header>
|
|
<p class="since" id="since"></p>
|
|
<section class="tiles" id="tiles"></section>
|
|
<section class="models">
|
|
<div class="models-head">
|
|
<h2 data-t="models">Models</h2>
|
|
<div class="seg small" role="tablist" id="sorts">
|
|
<button type="button" role="tab" data-sort="tokens" data-t="tokens">Tokens</button>
|
|
<button type="button" role="tab" data-sort="calls" data-t="calls">Calls</button>
|
|
<button type="button" role="tab" data-sort="cost" data-t="cost">Cost</button>
|
|
</div>
|
|
</div>
|
|
<ol id="models"></ol>
|
|
<p class="empty" id="empty" hidden></p>
|
|
</section>
|
|
<p class="error" id="error" hidden></p>
|
|
</body>
|
|
</html>
|