token-usage-dashboard 1.0.6 → 1.0.7

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 (57) hide show
  1. package/README.md +42 -54
  2. package/build/client/_app/immutable/assets/{2.BABRsmGA.css → 2.H_IHw1Xd.css} +1 -1
  3. package/build/client/_app/immutable/assets/2.H_IHw1Xd.css.br +0 -0
  4. package/build/client/_app/immutable/assets/2.H_IHw1Xd.css.gz +0 -0
  5. package/build/client/_app/immutable/chunks/oCB7A4Kp.js +2 -0
  6. package/build/client/_app/immutable/chunks/oCB7A4Kp.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/oCB7A4Kp.js.gz +0 -0
  8. package/build/client/_app/immutable/entry/{app.C7Gg5PnI.js → app.CdZl8N5I.js} +2 -2
  9. package/build/client/_app/immutable/entry/app.CdZl8N5I.js.br +0 -0
  10. package/build/client/_app/immutable/entry/app.CdZl8N5I.js.gz +0 -0
  11. package/build/client/_app/immutable/entry/start.CwRowqok.js +1 -0
  12. package/build/client/_app/immutable/entry/start.CwRowqok.js.br +0 -0
  13. package/build/client/_app/immutable/entry/start.CwRowqok.js.gz +0 -0
  14. package/build/client/_app/immutable/nodes/{1.Dj3Fzim2.js → 1.BRTb8oj5.js} +1 -1
  15. package/build/client/_app/immutable/nodes/1.BRTb8oj5.js.br +0 -0
  16. package/build/client/_app/immutable/nodes/1.BRTb8oj5.js.gz +0 -0
  17. package/build/client/_app/immutable/nodes/2.f9CssAKs.js +2 -0
  18. package/build/client/_app/immutable/nodes/2.f9CssAKs.js.br +0 -0
  19. package/build/client/_app/immutable/nodes/2.f9CssAKs.js.gz +0 -0
  20. package/build/client/_app/version.json +1 -1
  21. package/build/client/_app/version.json.br +0 -0
  22. package/build/client/_app/version.json.gz +0 -0
  23. package/build/handler.js +4 -4
  24. package/build/index.js +4 -4
  25. package/build/server/chunks/chunks/{client.js-C1_n_a2s.js → client.js-CH1OjaW0.js} +2 -2
  26. package/build/server/chunks/chunks/{internal.js-b-1wrnfA.js → internal.js-C4sX1ZF1.js} +3 -3
  27. package/build/server/chunks/chunks/{queries.js-aTxz7ubg.js → queries.js-Dxe3UrcX.js} +61 -11
  28. package/build/server/chunks/chunks/{refresh.js-DM1hnB2Y.js → refresh.js-b7xuLQYO.js} +2 -2
  29. package/build/server/chunks/chunks/{request.js-B3j1_Icg.js → request.js-DM1A1vDP.js} +2 -2
  30. package/build/server/chunks/entries/endpoints/api/refresh/{_server.ts.js-CJa6pKKD.js → _server.ts.js-DIm5mJGM.js} +4 -4
  31. package/build/server/chunks/entries/endpoints/api/settings/{_server.ts.js-DQt7Bc2q.js → _server.ts.js-B0rNclco.js} +3 -3
  32. package/build/server/chunks/entries/endpoints/api/usage/{_server.ts.js-kInjrhtE.js → _server.ts.js-C1OIFWsl.js} +3 -3
  33. package/build/server/chunks/entries/fallbacks/{error.svelte.js-CVKDebWa.js → error.svelte.js-Bej3DxGb.js} +3 -3
  34. package/build/server/chunks/entries/{hooks.server.js-BbojNy1X.js → hooks.server.js-CBWwmRPG.js} +3 -3
  35. package/build/server/chunks/entries/pages/{_page.server.ts.js-Oa3Sfml2.js → _page.server.ts.js-VL2asSrD.js} +3 -3
  36. package/build/server/chunks/entries/pages/{_page.svelte.js-D91hy9R4.js → _page.svelte.js-DuLeEEhc.js} +170 -23
  37. package/build/server/chunks/{handler-br42Ds2q.js → handler-C8BBXiDH.js} +3 -3
  38. package/build/server/chunks/{index.js-CBAFVV7O.js → index.js-DZopl62R.js} +2 -2
  39. package/build/server/chunks/{manifest.js-s70ajt69.js → manifest.js-XsX0MOFE.js} +7 -7
  40. package/build/server/chunks/nodes/{1.js-Cvu2_eGw.js → 1.js-h8N_CQRc.js} +3 -3
  41. package/build/server/chunks/nodes/{2.js-7xvomkGu.js → 2.js-Bvo-Equv.js} +7 -7
  42. package/package.json +1 -1
  43. package/build/client/_app/immutable/assets/2.BABRsmGA.css.br +0 -0
  44. package/build/client/_app/immutable/assets/2.BABRsmGA.css.gz +0 -0
  45. package/build/client/_app/immutable/chunks/DRLSLo2t.js +0 -2
  46. package/build/client/_app/immutable/chunks/DRLSLo2t.js.br +0 -0
  47. package/build/client/_app/immutable/chunks/DRLSLo2t.js.gz +0 -0
  48. package/build/client/_app/immutable/entry/app.C7Gg5PnI.js.br +0 -0
  49. package/build/client/_app/immutable/entry/app.C7Gg5PnI.js.gz +0 -0
  50. package/build/client/_app/immutable/entry/start.fbJ-_JRS.js +0 -1
  51. package/build/client/_app/immutable/entry/start.fbJ-_JRS.js.br +0 -0
  52. package/build/client/_app/immutable/entry/start.fbJ-_JRS.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/1.Dj3Fzim2.js.br +0 -0
  54. package/build/client/_app/immutable/nodes/1.Dj3Fzim2.js.gz +0 -0
  55. package/build/client/_app/immutable/nodes/2.Csi9nKxw.js +0 -2
  56. package/build/client/_app/immutable/nodes/2.Csi9nKxw.js.br +0 -0
  57. package/build/client/_app/immutable/nodes/2.Csi9nKxw.js.gz +0 -0
@@ -1,4 +1,4 @@
1
- import { i as index_server_exports } from './internal.js-b-1wrnfA.js';
1
+ import { i as index_server_exports } from './internal.js-C4sX1ZF1.js';
2
2
  import './shared.js-7DyfRqo3.js';
3
3
  import './exports.js-Dd48p7Ih.js';
4
4
  import { a1 as noop } from './server.js-mTMwhapa.js';
@@ -25,4 +25,4 @@ if (is_legacy) {
25
25
  /** @import { Query } from './remote-functions/query/instance.svelte.js' */
26
26
  /** @import { LiveQuery } from './remote-functions/query-live/instance.svelte.js' */
27
27
  var { onMount, tick } = index_server_exports;
28
- //# sourceMappingURL=client.js-C1_n_a2s.js.map
28
+ //# sourceMappingURL=client.js-CH1OjaW0.js.map
@@ -1175,7 +1175,7 @@ var options = {
1175
1175
  app: ({ head, body, assets, nonce, env }) => "<!doctype html>\n<html lang=\"en\" data-theme=\"%aiusage.theme%\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta name=\"color-scheme\" content=\"light dark\" />\n <meta\n name=\"description\"\n content=\"Every token your AI coding tools have spent, from the transcripts already on your machine.\"\n />\n <meta name=\"robots\" content=\"noindex\" />\n <link rel=\"icon\" href=\"" + assets + "/favicon.svg\" type=\"image/svg+xml\" />\n " + head + "\n </head>\n <body data-sveltekit-preload-data=\"hover\">\n <div style=\"display: contents\">" + body + "</div>\n </body>\n</html>\n",
1176
1176
  error: error_template_default
1177
1177
  },
1178
- version_hash: "s9j3o6"
1178
+ version_hash: "13lkr9t"
1179
1179
  };
1180
1180
  async function get_hooks() {
1181
1181
  let handle;
@@ -1183,7 +1183,7 @@ async function get_hooks() {
1183
1183
  let handleError;
1184
1184
  let handleValidationError;
1185
1185
  let init;
1186
- ({handle, handleFetch, handleError, handleValidationError, init} = await import('../entries/hooks.server.js-BbojNy1X.js'));
1186
+ ({handle, handleFetch, handleError, handleValidationError, init} = await import('../entries/hooks.server.js-CBWwmRPG.js'));
1187
1187
  let reroute;
1188
1188
  let transport;
1189
1189
  return {
@@ -1198,4 +1198,4 @@ async function get_hooks() {
1198
1198
  }
1199
1199
 
1200
1200
  export { set_public_env as a, set_read_implementation as b, get_hooks as g, index_server_exports as i, options as o, public_env as p, read_implementation as r, set_private_env as s };
1201
- //# sourceMappingURL=internal.js-b-1wrnfA.js.map
1201
+ //# sourceMappingURL=internal.js-C4sX1ZF1.js.map
@@ -38,7 +38,8 @@ create table if not exists events (
38
38
  output integer not null default 0,
39
39
  cache_read integer not null default 0,
40
40
  cache_write integer not null default 0,
41
- reasoning integer not null default 0
41
+ reasoning integer not null default 0,
42
+ subagent integer
42
43
  );
43
44
  create index if not exists events_ts on events (ts);
44
45
  create index if not exists events_day on events (day);
@@ -50,6 +51,12 @@ create table if not exists files (
50
51
  events integer not null default 0,
51
52
  scanned_at integer not null
52
53
  );
54
+ create table if not exists names (
55
+ tool text not null,
56
+ session text not null,
57
+ name text not null,
58
+ primary key (tool, session)
59
+ );
53
60
  create table if not exists windows (
54
61
  id text primary key,
55
62
  tool text not null,
@@ -74,9 +81,15 @@ function db() {
74
81
  writeMeta("schema", String(SCHEMA));
75
82
  }
76
83
  handle.exec(TABLES);
84
+ addSubagent(handle);
77
85
  rebucket(handle);
78
86
  return handle;
79
87
  }
88
+ /** Older databases grow the column in place, then every file is read again to fill it in */
89
+ function addSubagent(handle) {
90
+ if (handle.prepare("pragma table_info(events)").all().some((column) => column.name === "subagent")) return;
91
+ handle.exec("alter table events add column subagent integer; delete from files");
92
+ }
80
93
  var REBUCKET = `
81
94
  update events set
82
95
  day = date(ts / 1000, 'unixepoch', 'localtime'),
@@ -142,12 +155,30 @@ var claudeCode = {
142
155
  output: num(usage.output_tokens),
143
156
  cache_read: num(usage.cache_read_input_tokens),
144
157
  cache_write: num(usage.cache_creation_input_tokens),
145
- reasoning: num(details?.thinking_tokens)
158
+ reasoning: num(details?.thinking_tokens),
159
+ subagent: line.isSidechain === true
146
160
  });
147
161
  }
148
- return { events };
162
+ return {
163
+ events,
164
+ names: names(text)
165
+ };
149
166
  }
150
167
  };
168
+ /** A name somebody typed beats the one Claude came up with, whichever landed last */
169
+ function names(text) {
170
+ const typed = {};
171
+ const guessed = {};
172
+ for (const line of jsonLines(text, "-title\"")) {
173
+ const session = String(line.sessionId || "");
174
+ if (line.type === "custom-title" && line.customTitle) typed[session] = String(line.customTitle);
175
+ if (line.type === "ai-title" && line.aiTitle) guessed[session] = String(line.aiTitle);
176
+ }
177
+ return {
178
+ ...guessed,
179
+ ...typed
180
+ };
181
+ }
151
182
  //#endregion
152
183
  //#region src/lib/server/sources/codex.ts
153
184
  var label = (minutes) => {
@@ -283,7 +314,8 @@ async function listFiles(source) {
283
314
  withFileTypes: true
284
315
  })).filter((entry) => entry.isFile() && entry.name.endsWith(source.ext)).map((entry) => join(entry.parentPath, entry.name));
285
316
  }
286
- var INSERT = "insert into events (id, tool, model, session, project, ts, day, dow, hour, input, output, cache_read, cache_write, reasoning) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict(id) do update set input = max(input, excluded.input), output = max(output, excluded.output), cache_read = max(cache_read, excluded.cache_read), cache_write = max(cache_write, excluded.cache_write), reasoning = max(reasoning, excluded.reasoning)";
317
+ var INSERT = "insert into events (id, tool, model, session, project, ts, day, dow, hour, input, output, cache_read, cache_write, reasoning, subagent) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on conflict(id) do update set input = max(input, excluded.input), output = max(output, excluded.output), cache_read = max(cache_read, excluded.cache_read), cache_write = max(cache_write, excluded.cache_write), reasoning = max(reasoning, excluded.reasoning), subagent = coalesce(excluded.subagent, subagent)";
318
+ var INSERT_NAME = "insert into names (tool, session, name) values (?, ?, ?) on conflict(tool, session) do update set name = excluded.name";
287
319
  var INSERT_WINDOW = "insert into windows (id, tool, label, used_percent, window_minutes, resets_at, detail, seen_at) values (?, ?, ?, ?, ?, ?, ?, ?) on conflict(id) do update set used_percent = excluded.used_percent, resets_at = excluded.resets_at, detail = excluded.detail, seen_at = excluded.seen_at where excluded.seen_at >= windows.seen_at";
288
320
  async function scanSource(source) {
289
321
  const state = {
@@ -305,6 +337,7 @@ async function scanSource(source) {
305
337
  const known = new Map(handle.prepare("select path, size, mtime, events from files where tool = ?").all(source.id).map((row) => [row.path, row]));
306
338
  const insert = handle.prepare(INSERT);
307
339
  const insertWindow = handle.prepare(INSERT_WINDOW);
340
+ const insertName = handle.prepare(INSERT_NAME);
308
341
  const touch = handle.prepare("insert into files (path, tool, size, mtime, events, scanned_at) values (?, ?, ?, ?, ?, ?) on conflict(path) do update set size = excluded.size, mtime = excluded.mtime, events = excluded.events, scanned_at = excluded.scanned_at");
309
342
  let failures = 0;
310
343
  const now = Date.now();
@@ -329,8 +362,9 @@ async function scanSource(source) {
329
362
  handle.exec("begin");
330
363
  for (const event of parsed.events) {
331
364
  const at = new Date(event.ts);
332
- insert.run(event.id, source.id, event.model, event.session, event.project, event.ts, localDay(at), at.getDay(), at.getHours(), event.input, event.output, event.cache_read, event.cache_write, event.reasoning);
365
+ insert.run(event.id, source.id, event.model, event.session, event.project, event.ts, localDay(at), at.getDay(), at.getHours(), event.input, event.output, event.cache_read, event.cache_write, event.reasoning, event.subagent === void 0 ? null : Number(event.subagent));
333
366
  }
367
+ for (const [session, name] of Object.entries(parsed.names ?? {})) insertName.run(source.id, session, name);
334
368
  for (const window of parsed.windows ?? []) insertWindow.run(window.id, source.id, window.label, window.used_percent, window.window_minutes, window.resets_at, window.detail, window.seen_at);
335
369
  touch.run(path, source.id, size, mtime, parsed.events.length, now);
336
370
  handle.exec("commit");
@@ -399,7 +433,8 @@ var DEFAULTS = {
399
433
  metric: "tokens",
400
434
  scanIntervalSec: 120,
401
435
  claudeWindows: true,
402
- prices: {}
436
+ prices: {},
437
+ hiddenColumns: []
403
438
  };
404
439
  var cached = null;
405
440
  function settings() {
@@ -575,9 +610,10 @@ function clock(filters) {
575
610
  total: Number(row.total) || 0
576
611
  }));
577
612
  }
613
+ var SESSION_SUMS = "max(input + cache_read + cache_write) peak, count(subagent) flagged, sum(case when subagent = 1 then input + output + cache_read + cache_write end) side";
578
614
  function sessions(filters, overrides, limit = 60) {
579
615
  const clause = where(filters);
580
- const rows = db().prepare(`select session key, tool, project, model, min(ts) started, max(ts) ended, sum(input) input, sum(output) output, sum(cache_read) cache_read, sum(cache_write) cache_write, sum(reasoning) reasoning, count(*) events, count(distinct tool || ':' || session) sessions from events ${clause.sql} group by session, tool, project, model`).all(...clause.params);
616
+ const rows = db().prepare(`select session key, tool, project, model, min(ts) started, max(ts) ended, ${SUMS}, ${SESSION_SUMS} from events ${clause.sql} group by session, tool, project, model`).all(...clause.params);
581
617
  const merged = /* @__PURE__ */ new Map();
582
618
  for (const row of rows) {
583
619
  const id = String(row.key);
@@ -590,7 +626,12 @@ function sessions(filters, overrides, limit = 60) {
590
626
  started: Number(row.started),
591
627
  ended: Number(row.ended),
592
628
  total: 0,
593
- cost: 0
629
+ cost: 0,
630
+ peak: 0,
631
+ turns: 0,
632
+ read: 0,
633
+ fed: 0,
634
+ side: null
594
635
  };
595
636
  const tokens = {
596
637
  input: Number(row.input) || 0,
@@ -602,14 +643,23 @@ function sessions(filters, overrides, limit = 60) {
602
643
  entry.started = Math.min(entry.started, Number(row.started));
603
644
  entry.ended = Math.max(entry.ended, Number(row.ended));
604
645
  entry.total += totalOf(tokens);
646
+ entry.peak = Math.max(entry.peak, Number(row.peak) || 0);
647
+ entry.turns += Number(row.events) || 0;
648
+ entry.read += tokens.cache_read;
649
+ entry.fed += tokens.input + tokens.cache_read + tokens.cache_write;
650
+ if (Number(row.flagged)) entry.side = (entry.side ?? 0) + (Number(row.side) || 0);
605
651
  const cost = costOf(String(row.model), tokens, overrides);
606
652
  if (cost === null) entry.cost = null;
607
653
  else if (entry.cost !== null) entry.cost += cost;
608
654
  merged.set(at, entry);
609
655
  }
610
- return [...merged.values()].sort((a, b) => b.ended - a.ended).slice(0, limit).map(({ models, ...row }) => ({
656
+ const name = db().prepare("select name from names where tool = ? and session = ?");
657
+ return [...merged.values()].sort((a, b) => b.ended - a.ended).slice(0, limit).map(({ models, read, fed, side, ...row }) => ({
611
658
  ...row,
612
- models: [...models].sort().join(", ")
659
+ name: name.get(row.tool, row.id)?.name ?? null,
660
+ models: [...models].sort().join(", "),
661
+ cacheHit: fed ? read / fed : null,
662
+ subagents: side === null || !row.total ? null : side / row.total
613
663
  }));
614
664
  }
615
665
  var distinct = (column) => db().prepare(`select distinct ${column} value from events order by value`).all().map((row) => String(row.value)).filter(Boolean);
@@ -673,4 +723,4 @@ function rollup(filters) {
673
723
  }
674
724
 
675
725
  export { scan as a, db as b, resolve as c, describe as d, config as e, saveSettings as f, clearUsageMemo as g, report as r, settings as s, usage as u };
676
- //# sourceMappingURL=queries.js-aTxz7ubg.js.map
726
+ //# sourceMappingURL=queries.js-Dxe3UrcX.js.map
@@ -1,4 +1,4 @@
1
- import { s as settings, a as scan, r as report, d as describe, b as db, c as resolve, u as usage, e as config } from './queries.js-aTxz7ubg.js';
1
+ import { s as settings, a as scan, r as report, d as describe, b as db, c as resolve, u as usage, e as config } from './queries.js-Dxe3UrcX.js';
2
2
  import { r as resolveRange } from './range.js-CLYFtcRE.js';
3
3
  import { readFile } from 'node:fs/promises';
4
4
  import { join } from 'node:path';
@@ -104,4 +104,4 @@ function boot() {
104
104
  }
105
105
 
106
106
  export { boot as b, refresh as r };
107
- //# sourceMappingURL=refresh.js-DM1hnB2Y.js.map
107
+ //# sourceMappingURL=refresh.js-b7xuLQYO.js.map
@@ -1,4 +1,4 @@
1
- import { s as settings } from './queries.js-aTxz7ubg.js';
1
+ import { s as settings } from './queries.js-Dxe3UrcX.js';
2
2
  import { r as resolveRange } from './range.js-CLYFtcRE.js';
3
3
 
4
4
  //#region src/lib/server/request.ts
@@ -17,4 +17,4 @@ function filtersFrom(url) {
17
17
  }
18
18
 
19
19
  export { filtersFrom as f };
20
- //# sourceMappingURL=request.js-B3j1_Icg.js.map
20
+ //# sourceMappingURL=request.js-DM1A1vDP.js.map
@@ -1,6 +1,6 @@
1
- import { u as usage } from '../../../../chunks/queries.js-aTxz7ubg.js';
2
- import { r as refresh } from '../../../../chunks/refresh.js-DM1hnB2Y.js';
3
- import { f as filtersFrom } from '../../../../chunks/request.js-B3j1_Icg.js';
1
+ import { u as usage } from '../../../../chunks/queries.js-Dxe3UrcX.js';
2
+ import { r as refresh } from '../../../../chunks/refresh.js-b7xuLQYO.js';
3
+ import { f as filtersFrom } from '../../../../chunks/request.js-DM1A1vDP.js';
4
4
  import { j as json } from '../../../../chunks/utils.js-DzwqnkBT.js';
5
5
  import '../../../../chunks/range.js-CLYFtcRE.js';
6
6
  import 'node:fs/promises';
@@ -18,4 +18,4 @@ var POST = async ({ url }) => {
18
18
  };
19
19
 
20
20
  export { POST };
21
- //# sourceMappingURL=_server.ts.js-CJa6pKKD.js.map
21
+ //# sourceMappingURL=_server.ts.js-DIm5mJGM.js.map
@@ -1,5 +1,5 @@
1
- import { s as settings, f as saveSettings, g as clearUsageMemo } from '../../../../chunks/queries.js-aTxz7ubg.js';
2
- import { r as refresh } from '../../../../chunks/refresh.js-DM1hnB2Y.js';
1
+ import { s as settings, f as saveSettings, g as clearUsageMemo } from '../../../../chunks/queries.js-Dxe3UrcX.js';
2
+ import { r as refresh } from '../../../../chunks/refresh.js-b7xuLQYO.js';
3
3
  import { j as json } from '../../../../chunks/utils.js-DzwqnkBT.js';
4
4
  import '../../../../chunks/range.js-CLYFtcRE.js';
5
5
  import 'node:fs/promises';
@@ -21,4 +21,4 @@ var POST = async ({ request }) => {
21
21
  };
22
22
 
23
23
  export { GET, POST };
24
- //# sourceMappingURL=_server.ts.js-DQt7Bc2q.js.map
24
+ //# sourceMappingURL=_server.ts.js-B0rNclco.js.map
@@ -1,5 +1,5 @@
1
- import { u as usage } from '../../../../chunks/queries.js-aTxz7ubg.js';
2
- import { f as filtersFrom } from '../../../../chunks/request.js-B3j1_Icg.js';
1
+ import { u as usage } from '../../../../chunks/queries.js-Dxe3UrcX.js';
2
+ import { f as filtersFrom } from '../../../../chunks/request.js-DM1A1vDP.js';
3
3
  import { j as json } from '../../../../chunks/utils.js-DzwqnkBT.js';
4
4
  import '../../../../chunks/range.js-CLYFtcRE.js';
5
5
  import 'node:fs/promises';
@@ -14,4 +14,4 @@ import '../../../../chunks/server.js-mTMwhapa.js';
14
14
  var GET = ({ url }) => json(usage(filtersFrom(url)));
15
15
 
16
16
  export { GET };
17
- //# sourceMappingURL=_server.ts.js-kInjrhtE.js.map
17
+ //# sourceMappingURL=_server.ts.js-C1OIFWsl.js.map
@@ -1,6 +1,6 @@
1
- import '../../chunks/internal.js-b-1wrnfA.js';
1
+ import '../../chunks/internal.js-C4sX1ZF1.js';
2
2
  import { ai as escape_html, a3 as getContext } from '../../chunks/server.js-mTMwhapa.js';
3
- import '../../chunks/client.js-C1_n_a2s.js';
3
+ import '../../chunks/client.js-CH1OjaW0.js';
4
4
  import '../../chunks/shared.js-7DyfRqo3.js';
5
5
  import '../../chunks/exports.js-Dd48p7Ih.js';
6
6
  import '../../chunks/utils.js-DzwqnkBT.js';
@@ -65,4 +65,4 @@ function Error$1($$renderer, $$props) {
65
65
  }
66
66
 
67
67
  export { Error$1 as default };
68
- //# sourceMappingURL=error.svelte.js-CVKDebWa.js.map
68
+ //# sourceMappingURL=error.svelte.js-Bej3DxGb.js.map
@@ -1,5 +1,5 @@
1
- import { s as settings } from '../chunks/queries.js-aTxz7ubg.js';
2
- import { b as boot } from '../chunks/refresh.js-DM1hnB2Y.js';
1
+ import { s as settings } from '../chunks/queries.js-Dxe3UrcX.js';
2
+ import { b as boot } from '../chunks/refresh.js-b7xuLQYO.js';
3
3
  import '../chunks/range.js-CLYFtcRE.js';
4
4
  import 'node:fs/promises';
5
5
  import 'node:path';
@@ -13,4 +13,4 @@ boot();
13
13
  var handle = ({ event, resolve }) => resolve(event, { transformPageChunk: ({ html }) => html.replace("%aiusage.theme%", settings().theme === "auto" ? "" : settings().theme) });
14
14
 
15
15
  export { handle };
16
- //# sourceMappingURL=hooks.server.js-BbojNy1X.js.map
16
+ //# sourceMappingURL=hooks.server.js-CBWwmRPG.js.map
@@ -1,5 +1,5 @@
1
- import { e as config, s as settings, u as usage } from '../../chunks/queries.js-aTxz7ubg.js';
2
- import { f as filtersFrom } from '../../chunks/request.js-B3j1_Icg.js';
1
+ import { e as config, s as settings, u as usage } from '../../chunks/queries.js-Dxe3UrcX.js';
2
+ import { f as filtersFrom } from '../../chunks/request.js-DM1A1vDP.js';
3
3
 
4
4
  //#region src/routes/+page.server.ts
5
5
  var load = ({ url }) => ({
@@ -14,4 +14,4 @@ var _page_server_ts = /*#__PURE__*/Object.freeze({
14
14
  });
15
15
 
16
16
  export { _page_server_ts as _ };
17
- //# sourceMappingURL=_page.server.ts.js-Oa3Sfml2.js.map
17
+ //# sourceMappingURL=_page.server.ts.js-VL2asSrD.js.map
@@ -1,7 +1,7 @@
1
- import '../../chunks/internal.js-b-1wrnfA.js';
1
+ import '../../chunks/internal.js-C4sX1ZF1.js';
2
2
  import { a0 as run, aj as head, ak as attr_class, ai as escape_html, al as attr, am as ensure_array_like, an as bind_props, ao as stringify, P as derived, ap as attr_style, aq as element } from '../../chunks/server.js-mTMwhapa.js';
3
3
  import { R as RANGES, a as rangeLabel, b as RATES } from '../../chunks/range.js-CLYFtcRE.js';
4
- import '../../chunks/client.js-C1_n_a2s.js';
4
+ import '../../chunks/client.js-CH1OjaW0.js';
5
5
  import '../../chunks/shared.js-7DyfRqo3.js';
6
6
  import '../../chunks/exports.js-Dd48p7Ih.js';
7
7
  import '../../chunks/utils.js-DzwqnkBT.js';
@@ -90,6 +90,7 @@ function moneyCompact(value) {
90
90
  if (Math.abs(value) >= 1e3) return `$${compact(value)}`;
91
91
  return money(value);
92
92
  }
93
+ var percent = (value, digits = 0) => `${value.toFixed(digits)}%`;
93
94
  var RELATIVE = new Intl.RelativeTimeFormat("en-GB", { numeric: "auto" });
94
95
  var STEPS = [
95
96
  ["second", 60],
@@ -618,23 +619,140 @@ var toolMeta = (id) => TOOLS.find((tool) => tool.id === id) ?? {
618
619
  };
619
620
  //#endregion
620
621
  //#region src/lib/components/Sessions.svelte
622
+ var share = (value) => value === null ? "--" : percent(value * 100);
623
+ var COLUMNS = [
624
+ {
625
+ id: "session",
626
+ label: "Session",
627
+ hint: "The tool and its session id",
628
+ by: (row) => row.id
629
+ },
630
+ {
631
+ id: "name",
632
+ label: "Session name",
633
+ hint: "What the session was called, if it got a name",
634
+ by: (row) => row.name,
635
+ show: (row) => row.name ?? ""
636
+ },
637
+ {
638
+ id: "project",
639
+ label: "Project",
640
+ hint: "Where it ran",
641
+ by: (row) => row.project
642
+ },
643
+ {
644
+ id: "models",
645
+ label: "Models",
646
+ hint: "Every model the session used",
647
+ by: (row) => row.models,
648
+ show: (row) => row.models.split(", ").map(modelName).join(", ")
649
+ },
650
+ {
651
+ id: "ran",
652
+ label: "Ran",
653
+ hint: "When it last did anything",
654
+ by: (row) => row.ended,
655
+ show: (row) => clockLabel(row.ended)
656
+ },
657
+ {
658
+ id: "tokens",
659
+ label: "Tokens",
660
+ hint: "Everything in and out, cache included",
661
+ by: (row) => row.total,
662
+ show: (row) => compact(row.total),
663
+ numeric: true
664
+ },
665
+ {
666
+ id: "cost",
667
+ label: "Est. cost",
668
+ hint: "Worked out from list prices, not your bill",
669
+ by: (row) => row.cost,
670
+ show: (row) => money(row.cost),
671
+ numeric: true
672
+ },
673
+ {
674
+ id: "peak",
675
+ label: "Peak context",
676
+ hint: "The biggest prompt the model was handed in one go",
677
+ by: (row) => row.peak,
678
+ show: (row) => compact(row.peak),
679
+ numeric: true
680
+ },
681
+ {
682
+ id: "cache",
683
+ label: "Cache hits",
684
+ hint: "How much of the input came straight from cache",
685
+ by: (row) => row.cacheHit,
686
+ show: (row) => share(row.cacheHit),
687
+ numeric: true
688
+ },
689
+ {
690
+ id: "subagents",
691
+ label: "Subagents",
692
+ hint: "Share of the tokens spent by subagents. Claude Code only.",
693
+ by: (row) => row.subagents,
694
+ show: (row) => share(row.subagents),
695
+ numeric: true
696
+ },
697
+ {
698
+ id: "turns",
699
+ label: "Turns",
700
+ hint: "Replies from the model, subagents included",
701
+ by: (row) => row.turns,
702
+ show: (row) => String(row.turns),
703
+ numeric: true
704
+ }
705
+ ];
621
706
  function Sessions($$renderer, $$props) {
622
707
  $$renderer.component(($$renderer) => {
623
- let { rows, metric} = $$props;
708
+ let { rows, hidden} = $$props;
709
+ let sortBy = "ran";
710
+ const columns = derived(() => COLUMNS.filter((column) => !hidden.includes(column.id) && (column.id !== "name" || rows.some((row) => row.name))));
711
+ const sorted = derived(() => {
712
+ const by = (COLUMNS.find((column) => column.id === sortBy) ?? COLUMNS[0]).by;
713
+ return rows.toSorted((a, b) => {
714
+ const [left, right] = [by(a), by(b)];
715
+ if (left === right) return 0;
716
+ if (left === null) return 1;
717
+ if (right === null) return -1;
718
+ return -(left < right ? -1 : 1);
719
+ });
720
+ });
624
721
  if (rows.length) {
625
- $$renderer.push(`<!--[0--><div class="scroll svelte-1uqtl83"><table class="svelte-1uqtl83"><thead><tr><th scope="col" class="svelte-1uqtl83">Session</th><th scope="col" class="svelte-1uqtl83">Project</th><th scope="col" class="svelte-1uqtl83">Models</th><th scope="col" class="svelte-1uqtl83">Ran</th><th scope="col" class="right svelte-1uqtl83">${escape_html(metric === "cost" ? "Est. cost" : "Tokens")}</th></tr></thead><tbody class="svelte-1uqtl83"><!--[-->`);
626
- const each_array = ensure_array_like(rows);
722
+ $$renderer.push(`<!--[0--><div class="scroll svelte-1uqtl83"><table class="svelte-1uqtl83"><thead><tr><!--[-->`);
723
+ const each_array = ensure_array_like(columns());
627
724
  for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
628
- let row = each_array[$$index];
725
+ let column = each_array[$$index];
726
+ $$renderer.push(`<th scope="col"${attr("aria-sort", sortBy === column.id ? "descending" : "none")}${attr_class("svelte-1uqtl83", void 0, { "right": column.numeric })}><button type="button" class="svelte-1uqtl83">${escape_html(column.label)}</button></th>`);
727
+ }
728
+ $$renderer.push(`<!--]--></tr></thead><tbody class="svelte-1uqtl83"><!--[-->`);
729
+ const each_array_1 = ensure_array_like(sorted());
730
+ for (let $$index_2 = 0, $$length = each_array_1.length; $$index_2 < $$length; $$index_2++) {
731
+ let row = each_array_1[$$index_2];
629
732
  const tool = toolMeta(row.tool);
630
- $$renderer.push(`<tr class="svelte-1uqtl83"><td class="svelte-1uqtl83"><span class="tool svelte-1uqtl83">`);
631
- Mark($$renderer, {
632
- id: row.tool,
633
- label: tool.label,
634
- colour: tool.colour,
635
- size: 14
636
- });
637
- $$renderer.push(`<!----> <span class="id mono svelte-1uqtl83">${escape_html(row.id.slice(0, 8))}</span></span></td><td class="svelte-1uqtl83"><button type="button" class="link svelte-1uqtl83">${escape_html(projectName(row.project))}</button></td><td class="models svelte-1uqtl83">${escape_html(row.models.split(", ").map(modelName).join(", "))}</td><td class="svelte-1uqtl83">${escape_html(clockLabel(row.ended))}</td><td class="right num svelte-1uqtl83">${escape_html(metric === "cost" ? money(row.cost) : compact(row.total))}</td></tr>`);
733
+ $$renderer.push(`<tr class="svelte-1uqtl83"><!--[-->`);
734
+ const each_array_2 = ensure_array_like(columns());
735
+ for (let $$index_1 = 0, $$length = each_array_2.length; $$index_1 < $$length; $$index_1++) {
736
+ let column = each_array_2[$$index_1];
737
+ if (column.id === "session") {
738
+ $$renderer.push(`<!--[0--><td class="svelte-1uqtl83"><span class="tool svelte-1uqtl83">`);
739
+ Mark($$renderer, {
740
+ id: row.tool,
741
+ label: tool.label,
742
+ colour: tool.colour,
743
+ size: 14
744
+ });
745
+ $$renderer.push(`<!----> <span class="id mono svelte-1uqtl83">${escape_html(row.id.slice(0, 8))}</span></span></td>`);
746
+ } else if (column.id === "project") $$renderer.push(`<!--[1--><td class="svelte-1uqtl83"><button type="button" class="link svelte-1uqtl83">${escape_html(projectName(row.project))}</button></td>`);
747
+ else if (column.id === "ran") $$renderer.push(`<!--[2--><td class="svelte-1uqtl83">${escape_html(column.show?.(row))}</td>`);
748
+ else $$renderer.push(`<!--[-1--><td${attr_class("svelte-1uqtl83", void 0, {
749
+ "right": column.numeric,
750
+ "num": column.numeric,
751
+ "muted": !column.numeric
752
+ })}>${escape_html(column.show?.(row))}</td>`);
753
+ $$renderer.push(`<!--]-->`);
754
+ }
755
+ $$renderer.push(`<!--]--></tr>`);
638
756
  }
639
757
  $$renderer.push(`<!--]--></tbody></table></div>`);
640
758
  } else $$renderer.push(`<!--[-1--><p class="empty svelte-1uqtl83">No sessions in this range</p>`);
@@ -642,6 +760,17 @@ function Sessions($$renderer, $$props) {
642
760
  });
643
761
  }
644
762
  //#endregion
763
+ //#region src/lib/components/Fields.svelte
764
+ function Fields($$renderer, $$props) {
765
+ $$renderer.component(($$renderer) => {
766
+ let { options, hidden = void 0, onchange } = $$props;
767
+ $$renderer.push(`<div class="fields svelte-17j4bwj"><button type="button" class="trigger svelte-17j4bwj" aria-label="Choose columns"${attr("aria-expanded", false)}><svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M2.5 4h11M2.5 8h11M2.5 12h11M6 2.5v11M10 2.5v11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path></svg></button> `);
768
+ $$renderer.push("<!--[-1-->");
769
+ $$renderer.push(`<!--]--></div>`);
770
+ bind_props($$props, { hidden });
771
+ });
772
+ }
773
+ //#endregion
645
774
  //#region src/lib/components/Problems.svelte
646
775
  function Problems($$renderer, $$props) {
647
776
  $$renderer.component(($$renderer) => {
@@ -810,6 +939,7 @@ function _page($$renderer, $$props) {
810
939
  let trendBy = "tool";
811
940
  let modelView = "share";
812
941
  let projectBy = "measure";
942
+ let hiddenColumns = first.settings.hiddenColumns;
813
943
  const query = derived(() => new URLSearchParams({
814
944
  range,
815
945
  tools: tools.join(","),
@@ -1211,14 +1341,31 @@ function _page($$renderer, $$props) {
1211
1341
  });
1212
1342
  }});
1213
1343
  $$renderer.push(`<!----> `);
1214
- Panel($$renderer, {
1215
- title: "Recent sessions",
1216
- span: 12,
1217
- children: ($$renderer) => {
1218
- Sessions($$renderer, {
1219
- rows: usage.sessions,
1220
- metric});
1221
- }});
1344
+ {
1345
+ function actions($$renderer) {
1346
+ Fields($$renderer, {
1347
+ options: COLUMNS,
1348
+ onchange: (hidden) => save({ hiddenColumns: hidden }),
1349
+ get hidden() {
1350
+ return hiddenColumns;
1351
+ },
1352
+ set hidden($$value) {
1353
+ hiddenColumns = $$value;
1354
+ $$settled = false;
1355
+ }
1356
+ });
1357
+ }
1358
+ Panel($$renderer, {
1359
+ title: "Recent sessions",
1360
+ span: 12,
1361
+ hint: "Click a column heading to sort by it",
1362
+ actions,
1363
+ children: ($$renderer) => {
1364
+ Sessions($$renderer, {
1365
+ rows: usage.sessions,
1366
+ hidden: hiddenColumns});
1367
+ }});
1368
+ }
1222
1369
  $$renderer.push(`<!----></div> <footer class="svelte-1uha8ag"><span>Reads the transcripts already on this machine. Nothing is sent anywhere.</span> <span>`);
1223
1370
  if (usage.oldest) $$renderer.push(`<!--[0-->Records from ${escape_html(new Date(usage.oldest).toLocaleDateString("en-GB"))} ·`);
1224
1371
  else $$renderer.push("<!--[-1-->");
@@ -1252,4 +1399,4 @@ function _page($$renderer, $$props) {
1252
1399
  }
1253
1400
 
1254
1401
  export { _page as default };
1255
- //# sourceMappingURL=_page.svelte.js-D91hy9R4.js.map
1402
+ //# sourceMappingURL=_page.svelte.js-DuLeEEhc.js.map
@@ -9,8 +9,8 @@ import * as qs from 'node:querystring';
9
9
  import { Readable } from 'node:stream';
10
10
  import { S as SvelteKitError } from './chunks/shared.js-7DyfRqo3.js';
11
11
  import { y as splitCookiesString } from './chunks/utils.js-DzwqnkBT.js';
12
- import { S as Server } from './index.js-CBAFVV7O.js';
13
- import { m as manifest } from './manifest.js-s70ajt69.js';
12
+ import { S as Server } from './index.js-DZopl62R.js';
13
+ import { m as manifest } from './manifest.js-XsX0MOFE.js';
14
14
  import { env, dir, env_prefix } from '../../env.js';
15
15
  import { format } from 'node:url';
16
16
 
@@ -1472,4 +1472,4 @@ const handler = sequence(
1472
1472
  );
1473
1473
 
1474
1474
  export { format_listening_address as f, handler as h, polka as p };
1475
- //# sourceMappingURL=handler-br42Ds2q.js.map
1475
+ //# sourceMappingURL=handler-C8BBXiDH.js.map
@@ -1,4 +1,4 @@
1
- import { o as options, s as set_private_env, a as set_public_env, g as get_hooks, p as public_env, r as read_implementation, b as set_read_implementation } from './chunks/internal.js-b-1wrnfA.js';
1
+ import { o as options, s as set_private_env, a as set_public_env, g as get_hooks, p as public_env, r as read_implementation, b as set_read_implementation } from './chunks/internal.js-C4sX1ZF1.js';
2
2
  import { n as noop, T as TRAILING_SLASH_PARAM, I as INVALIDATED_PARAM, R as Redirect, b as get_relative_path, S as SvelteKitError, g as get_status, t as text_encoder, o as once, H as HttpError, d as normalize_error, e as create_remote_key, p as parse_remote_arg, s as stringify, A as ActionFailure, f as split_remote_key, h as base64_encode } from './chunks/shared.js-7DyfRqo3.js';
3
3
  import { b as base, o as override, a as assets, r as reset, c as app_dir } from './chunks/internal2.js-BlXt2rfE.js';
4
4
  import { f as format_server_error, j as json, i as is_form_content_type, t as text, h as has_prerendered_path, a as handle_fatal_error, r as redirect_response, g as get_set_cookies, n as negotiate, w as with_request_store, p as parseString, m as merge_tracing, b as method_not_allowed, s as static_error_page, c as handle_error_and_jsonify, d as get_global_name, e as create_replacer, k as serialize_uses, l as clarify_devalue_error, E as ENDPOINT_METHODS, P as PAGE_METHODS, o as get_node_type, q as isRedirect, u as escape_html, v as error, x as deserialize_binary_form } from './chunks/utils.js-DzwqnkBT.js';
@@ -3969,4 +3969,4 @@ var Server = class {
3969
3969
  };
3970
3970
 
3971
3971
  export { Server as S };
3972
- //# sourceMappingURL=index.js-CBAFVV7O.js.map
3972
+ //# sourceMappingURL=index.js-DZopl62R.js.map
@@ -10,11 +10,11 @@ return {
10
10
  assets: new Set(["favicon.svg","robots.txt"]),
11
11
  mimeTypes: {".svg":"image/svg+xml",".txt":"text/plain"},
12
12
  _: {
13
- client: {start:"_app/immutable/entry/start.fbJ-_JRS.js",app:"_app/immutable/entry/app.C7Gg5PnI.js",imports:["_app/immutable/entry/start.fbJ-_JRS.js","_app/immutable/chunks/DRLSLo2t.js","_app/immutable/chunks/DC6tN2WI.js","_app/immutable/entry/app.C7Gg5PnI.js","_app/immutable/chunks/DC6tN2WI.js","_app/immutable/chunks/xihTtKlq.js"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},
13
+ client: {start:"_app/immutable/entry/start.CwRowqok.js",app:"_app/immutable/entry/app.CdZl8N5I.js",imports:["_app/immutable/entry/start.CwRowqok.js","_app/immutable/chunks/oCB7A4Kp.js","_app/immutable/chunks/DC6tN2WI.js","_app/immutable/entry/app.CdZl8N5I.js","_app/immutable/chunks/DC6tN2WI.js","_app/immutable/chunks/xihTtKlq.js"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},
14
14
  nodes: [
15
15
  __memo(() => import('./nodes/0.js-Bzngkdxl.js')),
16
- __memo(() => import('./nodes/1.js-Cvu2_eGw.js')),
17
- __memo(() => import('./nodes/2.js-7xvomkGu.js'))
16
+ __memo(() => import('./nodes/1.js-h8N_CQRc.js')),
17
+ __memo(() => import('./nodes/2.js-Bvo-Equv.js'))
18
18
  ],
19
19
  remotes: {
20
20
 
@@ -32,21 +32,21 @@ return {
32
32
  pattern: /^\/api\/refresh\/?$/,
33
33
  params: [],
34
34
  page: null,
35
- endpoint: __memo(() => import('./entries/endpoints/api/refresh/_server.ts.js-CJa6pKKD.js'))
35
+ endpoint: __memo(() => import('./entries/endpoints/api/refresh/_server.ts.js-DIm5mJGM.js'))
36
36
  },
37
37
  {
38
38
  id: "/api/settings",
39
39
  pattern: /^\/api\/settings\/?$/,
40
40
  params: [],
41
41
  page: null,
42
- endpoint: __memo(() => import('./entries/endpoints/api/settings/_server.ts.js-DQt7Bc2q.js'))
42
+ endpoint: __memo(() => import('./entries/endpoints/api/settings/_server.ts.js-B0rNclco.js'))
43
43
  },
44
44
  {
45
45
  id: "/api/usage",
46
46
  pattern: /^\/api\/usage\/?$/,
47
47
  params: [],
48
48
  page: null,
49
- endpoint: __memo(() => import('./entries/endpoints/api/usage/_server.ts.js-kInjrhtE.js'))
49
+ endpoint: __memo(() => import('./entries/endpoints/api/usage/_server.ts.js-C1OIFWsl.js'))
50
50
  }
51
51
  ],
52
52
  prerendered_routes: new Set([]),
@@ -60,4 +60,4 @@ return {
60
60
  })();
61
61
 
62
62
  export { manifest as m };
63
- //# sourceMappingURL=manifest.js-s70ajt69.js.map
63
+ //# sourceMappingURL=manifest.js-XsX0MOFE.js.map