@sunasteriskrnd/takumi 1.0.0-dev.46 → 1.0.0-dev.47
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/dist/index.js +42 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19815,7 +19815,7 @@ var package_default;
|
|
|
19815
19815
|
var init_package = __esm(() => {
|
|
19816
19816
|
package_default = {
|
|
19817
19817
|
name: "@sunasteriskrnd/takumi",
|
|
19818
|
-
version: "1.0.0-dev.
|
|
19818
|
+
version: "1.0.0-dev.47",
|
|
19819
19819
|
description: "CLI tool for bootstrapping and managing Takumi projects",
|
|
19820
19820
|
type: "module",
|
|
19821
19821
|
repository: {
|
|
@@ -53591,6 +53591,44 @@ function tryOpenBrowser(target) {
|
|
|
53591
53591
|
init_logger();
|
|
53592
53592
|
import * as http from "node:http";
|
|
53593
53593
|
|
|
53594
|
+
// src/domains/sessions/analytics-daily-by-model.ts
|
|
53595
|
+
function buildDailyByModel(aggregates, oldestAllowedMs) {
|
|
53596
|
+
const byDayModel = new Map;
|
|
53597
|
+
for (const agg of aggregates) {
|
|
53598
|
+
const ms = startedMs(agg?.startedAt);
|
|
53599
|
+
if (ms === null)
|
|
53600
|
+
continue;
|
|
53601
|
+
const perModel = agg?.tokensByModel;
|
|
53602
|
+
if (!perModel || typeof perModel !== "object")
|
|
53603
|
+
continue;
|
|
53604
|
+
const date = dayKey(ms);
|
|
53605
|
+
if (Date.parse(`${date}T00:00:00.000Z`) < oldestAllowedMs)
|
|
53606
|
+
continue;
|
|
53607
|
+
let byModel = byDayModel.get(date);
|
|
53608
|
+
if (!byModel) {
|
|
53609
|
+
byModel = new Map;
|
|
53610
|
+
byDayModel.set(date, byModel);
|
|
53611
|
+
}
|
|
53612
|
+
for (const [model, mtok] of Object.entries(perModel)) {
|
|
53613
|
+
let acc = byModel.get(model);
|
|
53614
|
+
if (!acc) {
|
|
53615
|
+
acc = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
53616
|
+
byModel.set(model, acc);
|
|
53617
|
+
}
|
|
53618
|
+
accumulateTokens(acc, normalizeTokens(mtok));
|
|
53619
|
+
}
|
|
53620
|
+
}
|
|
53621
|
+
const rows = [];
|
|
53622
|
+
for (const [date, byModel] of byDayModel) {
|
|
53623
|
+
for (const [model, tokens] of byModel) {
|
|
53624
|
+
if (sumTokens(tokens) > 0)
|
|
53625
|
+
rows.push({ date, model, tokens });
|
|
53626
|
+
}
|
|
53627
|
+
}
|
|
53628
|
+
rows.sort((a3, b3) => a3.date.localeCompare(b3.date) || a3.model.localeCompare(b3.model));
|
|
53629
|
+
return rows;
|
|
53630
|
+
}
|
|
53631
|
+
|
|
53594
53632
|
// src/domains/sessions/analytics.ts
|
|
53595
53633
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
53596
53634
|
var PER_DAY_MAX = 371;
|
|
@@ -53704,6 +53742,7 @@ function foldAnalytics(aggregates, now, range) {
|
|
|
53704
53742
|
const rankedModels = [...tokensByModel.entries()].map(([label, tokens]) => ({ label, tokens, total: sumTokens(tokens) })).filter((m2) => m2.total > 0).sort((a3, b3) => b3.total - a3.total || a3.label.localeCompare(b3.label)).slice(0, TOP_PROJECTS);
|
|
53705
53743
|
const byModel = rankedModels.map(({ label, total }) => ({ label, tokens: total }));
|
|
53706
53744
|
const byModelDetailed = rankedModels.map(({ label, tokens }) => ({ label, tokens }));
|
|
53745
|
+
const dailyByModel = buildDailyByModel(aggregates, oldestAllowedMs);
|
|
53707
53746
|
const cacheDenom = totals.cacheRead + totals.input;
|
|
53708
53747
|
const cacheHitRate = cacheDenom > 0 ? totals.cacheRead / cacheDenom : 0;
|
|
53709
53748
|
return {
|
|
@@ -53725,7 +53764,8 @@ function foldAnalytics(aggregates, now, range) {
|
|
|
53725
53764
|
byProject,
|
|
53726
53765
|
daily,
|
|
53727
53766
|
byModel,
|
|
53728
|
-
byModelDetailed
|
|
53767
|
+
byModelDetailed,
|
|
53768
|
+
dailyByModel
|
|
53729
53769
|
},
|
|
53730
53770
|
window: {
|
|
53731
53771
|
earliest: earliestMs === null ? null : new Date(earliestMs).toISOString(),
|