@shanepadgett/tau-agent 0.40.0 → 0.41.0
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.
|
@@ -232,7 +232,7 @@ export async function buildCostReport(options: BuildCostReportOptions): Promise<
|
|
|
232
232
|
tokens: bucket.tokens,
|
|
233
233
|
sessions: bucket.sessions.size,
|
|
234
234
|
}))
|
|
235
|
-
.sort((a, b) => b.cost - a.cost);
|
|
235
|
+
.sort((a, b) => b.tokens - a.tokens || b.cost - a.cost);
|
|
236
236
|
|
|
237
237
|
const subagents: SubagentCost[] = [...subagentMap.values()].sort((a, b) => b.cost - a.cost);
|
|
238
238
|
|
|
@@ -125,15 +125,17 @@ export function renderCostReportHtml(report: CostReport): string {
|
|
|
125
125
|
const scopeLabel = report.scope === "project" ? "Current project" : "All sessions";
|
|
126
126
|
const scopeClass = report.scope === "project" ? "scope-project" : "scope-all";
|
|
127
127
|
const totalShare = report.totalCost;
|
|
128
|
+
const tokenShareBase = report.totalTokens;
|
|
128
129
|
const subagentShareBase = report.subagentCost;
|
|
129
130
|
|
|
130
131
|
const modelRows = report.models
|
|
131
132
|
.map((model) => {
|
|
132
|
-
const share =
|
|
133
|
-
return `<tr>
|
|
133
|
+
const share = tokenShareBase > 0 ? model.tokens / tokenShareBase : 0;
|
|
134
|
+
return `<tr data-cost="${model.cost}" data-share="${model.tokens}">
|
|
134
135
|
<td class="px-3 py-2">${escapeHtml(model.provider)} / ${escapeHtml(model.model)}</td>
|
|
135
136
|
<td class="px-3 py-2 text-right">${money(model.cost)}</td>
|
|
136
|
-
<td class="px-3 py-2 text-right">${
|
|
137
|
+
<td class="px-3 py-2 text-right">${tokens(model.tokens)}</td>
|
|
138
|
+
<td class="px-3 py-2 text-right">${percent(model.tokens, tokenShareBase)}</td>
|
|
137
139
|
<td class="px-3 py-2">${shareBar(share)}</td>
|
|
138
140
|
<td class="px-3 py-2 text-right">${model.sessions}</td>
|
|
139
141
|
</tr>`;
|
|
@@ -294,6 +296,22 @@ export function renderCostReportHtml(report: CostReport): string {
|
|
|
294
296
|
grid-template-columns: repeat(31, minmax(0, 1fr));
|
|
295
297
|
gap: 0.25rem;
|
|
296
298
|
}
|
|
299
|
+
th.sortable {
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
user-select: none;
|
|
302
|
+
}
|
|
303
|
+
th.sortable:hover {
|
|
304
|
+
color: rgb(28 25 23);
|
|
305
|
+
}
|
|
306
|
+
.dark th.sortable:hover {
|
|
307
|
+
color: rgb(245 245 244);
|
|
308
|
+
}
|
|
309
|
+
th.sortable[aria-sort="descending"]::after {
|
|
310
|
+
content: " ↓";
|
|
311
|
+
}
|
|
312
|
+
th.sortable[aria-sort="ascending"]::after {
|
|
313
|
+
content: " ↑";
|
|
314
|
+
}
|
|
297
315
|
</style>
|
|
298
316
|
</head>
|
|
299
317
|
<body class="${scopeClass} min-h-full bg-stone-100 text-stone-900 antialiased dark:bg-stone-950 dark:text-stone-100">
|
|
@@ -353,17 +371,18 @@ export function renderCostReportHtml(report: CostReport): string {
|
|
|
353
371
|
<section aria-labelledby="models-heading">
|
|
354
372
|
<h2 id="models-heading" class="mb-3 text-sm font-semibold">Models</h2>
|
|
355
373
|
<div class="overflow-x-auto rounded border border-stone-300 bg-white dark:border-stone-700 dark:bg-stone-900">
|
|
356
|
-
<table class="w-full text-sm tabular">
|
|
374
|
+
<table id="models-table" class="w-full text-sm tabular">
|
|
357
375
|
<thead>
|
|
358
376
|
<tr class="text-left text-xs font-medium text-stone-600 dark:text-stone-400">
|
|
359
377
|
<th scope="col" class="px-3 py-2 font-medium">Model</th>
|
|
360
|
-
<th scope="col" class="px-3 py-2 text-right font-medium">Cost</th>
|
|
361
|
-
<th scope="col" class="px-3 py-2 text-right font-medium">
|
|
378
|
+
<th scope="col" class="sortable px-3 py-2 text-right font-medium" data-sort="cost" aria-sort="none">Cost</th>
|
|
379
|
+
<th scope="col" class="px-3 py-2 text-right font-medium">Tokens</th>
|
|
380
|
+
<th scope="col" class="sortable px-3 py-2 text-right font-medium" data-sort="share" aria-sort="descending">Share (tok)</th>
|
|
362
381
|
<th scope="col" class="min-w-[7rem] px-3 py-2 font-medium"></th>
|
|
363
382
|
<th scope="col" class="px-3 py-2 text-right font-medium">Sessions</th>
|
|
364
383
|
</tr>
|
|
365
384
|
</thead>
|
|
366
|
-
<tbody class="divide-y divide-stone-200 dark:divide-stone-800">${modelRows || `<tr><td class="px-3 py-2 text-stone-600 dark:text-stone-400" colspan="
|
|
385
|
+
<tbody class="divide-y divide-stone-200 dark:divide-stone-800">${modelRows || `<tr><td class="px-3 py-2 text-stone-600 dark:text-stone-400" colspan="6">No model spend.</td></tr>`}</tbody>
|
|
367
386
|
</table>
|
|
368
387
|
</div>
|
|
369
388
|
</section>
|
|
@@ -467,6 +486,53 @@ export function renderCostReportHtml(report: CostReport): string {
|
|
|
467
486
|
}
|
|
468
487
|
});
|
|
469
488
|
}
|
|
489
|
+
|
|
490
|
+
const modelsTable = document.getElementById("models-table");
|
|
491
|
+
if (modelsTable) {
|
|
492
|
+
const tbody = modelsTable.querySelector("tbody");
|
|
493
|
+
const headers = modelsTable.querySelectorAll("th.sortable");
|
|
494
|
+
if (tbody && headers.length > 0) {
|
|
495
|
+
let active = "share";
|
|
496
|
+
let direction = "desc";
|
|
497
|
+
const sortRows = () => {
|
|
498
|
+
const rows = [...tbody.querySelectorAll("tr[data-cost]")];
|
|
499
|
+
rows.sort((a, b) => {
|
|
500
|
+
const attr = "data-" + active;
|
|
501
|
+
const av = Number(a.getAttribute(attr)) || 0;
|
|
502
|
+
const bv = Number(b.getAttribute(attr)) || 0;
|
|
503
|
+
return direction === "desc" ? bv - av : av - bv;
|
|
504
|
+
});
|
|
505
|
+
for (const row of rows) tbody.appendChild(row);
|
|
506
|
+
for (const header of headers) {
|
|
507
|
+
const key = header.getAttribute("data-sort") || "";
|
|
508
|
+
header.setAttribute(
|
|
509
|
+
"aria-sort",
|
|
510
|
+
key === active ? (direction === "desc" ? "descending" : "ascending") : "none",
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
for (const header of headers) {
|
|
515
|
+
header.tabIndex = 0;
|
|
516
|
+
const activate = () => {
|
|
517
|
+
const key = header.getAttribute("data-sort") || "";
|
|
518
|
+
if (key === active) {
|
|
519
|
+
direction = direction === "desc" ? "asc" : "desc";
|
|
520
|
+
} else {
|
|
521
|
+
active = key;
|
|
522
|
+
direction = "desc";
|
|
523
|
+
}
|
|
524
|
+
sortRows();
|
|
525
|
+
};
|
|
526
|
+
header.addEventListener("click", activate);
|
|
527
|
+
header.addEventListener("keydown", (event) => {
|
|
528
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
529
|
+
event.preventDefault();
|
|
530
|
+
activate();
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
470
536
|
})();
|
|
471
537
|
</script>
|
|
472
538
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shanepadgett/tau-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Tau is a custom agentic harness built with pi extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ast-grep/wasm": "0.45.1",
|
|
38
|
-
"@shanepadgett/tau-tui": "0.
|
|
38
|
+
"@shanepadgett/tau-tui": "0.41.0",
|
|
39
39
|
"@vscode/tree-sitter-wasm": "0.3.1",
|
|
40
40
|
"image-size": "2.0.2",
|
|
41
41
|
"smol-toml": "1.8.0",
|