opencode-statboard 1.0.10 → 1.0.12
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 +1 -1
- package/public/index.html +3 -2
- package/server.js +5 -3
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -66,13 +66,14 @@
|
|
|
66
66
|
.skeleton-card { height: 60px; }
|
|
67
67
|
.trend-bar { position: absolute; bottom: 0; border-radius: 2px 2px 0 0; transition: height .4s ease; }
|
|
68
68
|
.trend-bar-cache { left: 0; right: 0; opacity: .2; }
|
|
69
|
+
.version { font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px; }
|
|
69
70
|
.trend-bar-input { left: 25%; width: 22%; z-index: 1; }
|
|
70
71
|
.trend-bar-output { left: 53%; width: 22%; z-index: 1; }
|
|
71
72
|
</style>
|
|
72
73
|
</head>
|
|
73
74
|
<body>
|
|
74
75
|
<header>
|
|
75
|
-
<h1><span class="dot">●</span> <span data-i18n="title">opencode Dashboard</span></h1>
|
|
76
|
+
<h1><span class="dot">●</span> <span data-i18n="title">opencode Dashboard</span> <span class="version">v__VERSION__</span></h1>
|
|
76
77
|
<div class="status">
|
|
77
78
|
<span id="updated">Loading…</span>
|
|
78
79
|
<span class="pill ok" id="pill" data-i18n="live">Live</span>
|
|
@@ -401,7 +402,7 @@ function formatReport(jr) {
|
|
|
401
402
|
const rpad = (s, w) => { s = String(s); return s.length >= w ? s : ' '.repeat(w - s.length) + s; };
|
|
402
403
|
let out = '';
|
|
403
404
|
out += 'OPENCODE USAGE STATEMENT\n';
|
|
404
|
-
out += 'Period: ' + jr.label + ' | Last ' + jr.days + ' day(s)' + cachedNote + '\n';
|
|
405
|
+
out += 'Period: ' + jr.label + (jr.days >= 0 ? ' | Last ' + jr.days + ' day(s)' : '') + cachedNote + '\n';
|
|
405
406
|
out += '---\n';
|
|
406
407
|
const s = jr.stats;
|
|
407
408
|
if (s && s.ok) {
|
package/server.js
CHANGED
|
@@ -9,6 +9,8 @@ const REFRESH_MS = 15000;
|
|
|
9
9
|
const TREND_MS = 10 * 60 * 1000;
|
|
10
10
|
const REPORT_TTL = 10 * 60 * 1000;
|
|
11
11
|
const CACHE_CLEANUP_MS = 5 * 60 * 1000;
|
|
12
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
|
13
|
+
const VERSION = pkg.version;
|
|
12
14
|
|
|
13
15
|
const EXE = (() => {
|
|
14
16
|
const candidates = [
|
|
@@ -290,8 +292,8 @@ async function buildReport(days) {
|
|
|
290
292
|
: await runStats(['stats', '--days', String(Math.max(days, 1)), '--models', '20']);
|
|
291
293
|
}
|
|
292
294
|
const [agentR, modelR] = await Promise.all([
|
|
293
|
-
run(['db', `SELECT agent, COUNT(*) AS sessions, ROUND(SUM(cost),4) AS cost, SUM(tokens_input) AS tok_in, SUM(tokens_output) AS tok_out, SUM(tokens_cache_read) AS cache_read FROM session WHERE agent IS NOT NULL AND time_updated >= ${timeFilter} GROUP BY
|
|
294
|
-
run(['db', `SELECT COALESCE(json_extract(model,'$.providerID'), 'unknown') AS provider, COALESCE(json_extract(model,'$.id'), 'unknown') AS model, COUNT(*) AS sessions, ROUND(SUM(cost),4) AS cost, SUM(tokens_input) AS tok_in, SUM(tokens_output) AS tok_out, SUM(tokens_cache_read) AS cache_read FROM session WHERE time_updated >= ${timeFilter} GROUP BY
|
|
295
|
+
run(['db', `SELECT agent, COUNT(*) AS sessions, ROUND(SUM(cost),4) AS cost, SUM(tokens_input) AS tok_in, SUM(tokens_output) AS tok_out, SUM(tokens_cache_read) AS cache_read FROM session WHERE agent IS NOT NULL AND time_updated >= ${timeFilter} GROUP BY 1 ORDER BY cost DESC;`, '--format', 'tsv']),
|
|
296
|
+
run(['db', `SELECT COALESCE(json_extract(model,'$.providerID'), 'unknown') AS provider, COALESCE(json_extract(model,'$.id'), 'unknown') AS model, COUNT(*) AS sessions, ROUND(SUM(cost),4) AS cost, SUM(tokens_input) AS tok_in, SUM(tokens_output) AS tok_out, SUM(tokens_cache_read) AS cache_read FROM session WHERE time_updated >= ${timeFilter} GROUP BY 1, 2 ORDER BY cost DESC;`, '--format', 'tsv']),
|
|
295
297
|
]);
|
|
296
298
|
return {
|
|
297
299
|
label: label,
|
|
@@ -357,7 +359,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
357
359
|
return;
|
|
358
360
|
}
|
|
359
361
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
360
|
-
res.end(data);
|
|
362
|
+
res.end(data.replace('__VERSION__', VERSION));
|
|
361
363
|
});
|
|
362
364
|
} else {
|
|
363
365
|
res.statusCode = 404;
|