ai-wrapped 1.8.1 → 1.8.2
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/src/bun/aggregator.test.ts +38 -0
- package/src/bun/aggregator.ts +31 -6
- package/src/bun/normalizer.ts +50 -1
- package/src/bun/parsers/codex.test.ts +87 -0
- package/src/bun/parsers/codex.ts +9 -1
- package/src/bun/pricing.test.ts +14 -0
- package/src/bun/pricing.ts +7 -0
- package/src/bun/session-schema.ts +1 -1
- package/src/bun/store.test.ts +3 -3
- package/src/bun/store.ts +1 -1
- package/src/shared/schema.ts +9 -1
- package/src/shared/session-types.ts +9 -0
package/package.json
CHANGED
|
@@ -21,6 +21,13 @@ const makeSession = (overrides: Partial<Session>): Session => ({
|
|
|
21
21
|
messageCount: 2,
|
|
22
22
|
totalTokens: { ...EMPTY_TOKEN_USAGE },
|
|
23
23
|
totalCostUsd: 0.5,
|
|
24
|
+
modelUsage: [{
|
|
25
|
+
model: "gpt-5",
|
|
26
|
+
messageCount: 2,
|
|
27
|
+
toolCallCount: 1,
|
|
28
|
+
tokens: { ...EMPTY_TOKEN_USAGE },
|
|
29
|
+
costUsd: 0.5,
|
|
30
|
+
}],
|
|
24
31
|
toolCallCount: 1,
|
|
25
32
|
isHousekeeping: false,
|
|
26
33
|
parsedAt: "2026-02-21T10:02:00.000Z",
|
|
@@ -97,4 +104,35 @@ describe("aggregateSessionsByDate", () => {
|
|
|
97
104
|
expect(entry).toBeDefined();
|
|
98
105
|
expect(entry?.byHour["10"]?.sessions).toBe(1);
|
|
99
106
|
});
|
|
107
|
+
|
|
108
|
+
test("attributes token and cost usage to every model used in a session", () => {
|
|
109
|
+
const daily = aggregateSessionsByDate([
|
|
110
|
+
makeSession({
|
|
111
|
+
model: "gpt-5.5",
|
|
112
|
+
totalTokens: { inputTokens: 300, outputTokens: 30, cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 },
|
|
113
|
+
totalCostUsd: 0.003,
|
|
114
|
+
modelUsage: [
|
|
115
|
+
{
|
|
116
|
+
model: "gpt-5.5",
|
|
117
|
+
messageCount: 1,
|
|
118
|
+
toolCallCount: 0,
|
|
119
|
+
tokens: { inputTokens: 100, outputTokens: 10, cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 },
|
|
120
|
+
costUsd: 0.001,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
model: "gpt-5.6-sol",
|
|
124
|
+
messageCount: 1,
|
|
125
|
+
toolCallCount: 0,
|
|
126
|
+
tokens: { inputTokens: 200, outputTokens: 20, cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 },
|
|
127
|
+
costUsd: 0.002,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
}),
|
|
131
|
+
], { timeZone: "UTC" });
|
|
132
|
+
|
|
133
|
+
const entry = daily["2026-02-21"];
|
|
134
|
+
expect(entry?.byModel["gpt-5.5"]?.inputTokens).toBe(100);
|
|
135
|
+
expect(entry?.byModel["gpt-5.6-sol"]?.inputTokens).toBe(200);
|
|
136
|
+
expect(entry?.byModel["gpt-5.6-sol"]?.costUsd).toBe(0.002);
|
|
137
|
+
});
|
|
100
138
|
});
|
package/src/bun/aggregator.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Session } from "./session-schema";
|
|
1
|
+
import type { Session, SessionModelUsage } from "./session-schema";
|
|
2
2
|
import {
|
|
3
3
|
createEmptyDayStats,
|
|
4
4
|
type DailyAggregateEntry,
|
|
@@ -110,6 +110,21 @@ const toSessionStats = (session: Session): DayStats => ({
|
|
|
110
110
|
durationMs: session.durationMs ?? 0,
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
+
const toModelStats = (usage: SessionModelUsage): DayStats => ({
|
|
114
|
+
// A session that uses several models is intentionally counted once for each
|
|
115
|
+
// model, while its token and cost totals remain exclusive to that model.
|
|
116
|
+
sessions: 1,
|
|
117
|
+
messages: usage.messageCount,
|
|
118
|
+
toolCalls: usage.toolCallCount,
|
|
119
|
+
inputTokens: usage.tokens.inputTokens,
|
|
120
|
+
outputTokens: usage.tokens.outputTokens,
|
|
121
|
+
cacheReadTokens: usage.tokens.cacheReadTokens,
|
|
122
|
+
cacheWriteTokens: usage.tokens.cacheWriteTokens,
|
|
123
|
+
reasoningTokens: usage.tokens.reasoningTokens,
|
|
124
|
+
costUsd: usage.costUsd,
|
|
125
|
+
durationMs: 0,
|
|
126
|
+
});
|
|
127
|
+
|
|
113
128
|
const toRepoKey = (repoName: string | null): string | null => {
|
|
114
129
|
if (!repoName) return null;
|
|
115
130
|
const trimmed = repoName.trim();
|
|
@@ -196,16 +211,12 @@ export const aggregateSessionsByDate = (
|
|
|
196
211
|
for (const session of sessions) {
|
|
197
212
|
const date = toDayKey(session, dateFormatter);
|
|
198
213
|
const entry = ensureDateEntry(daily, date);
|
|
199
|
-
const modelKey = session.model && session.model.trim().length > 0 ? session.model : "unknown";
|
|
200
214
|
const repoKey = toRepoKey(session.repoName);
|
|
201
215
|
const stats = toSessionStats(session);
|
|
202
216
|
|
|
203
217
|
if (!entry.bySource[session.source]) {
|
|
204
218
|
entry.bySource[session.source] = createEmptyDayStats();
|
|
205
219
|
}
|
|
206
|
-
if (!entry.byModel[modelKey]) {
|
|
207
|
-
entry.byModel[modelKey] = createEmptyDayStats();
|
|
208
|
-
}
|
|
209
220
|
if (repoKey && !entry.byRepo[repoKey]) {
|
|
210
221
|
entry.byRepo[repoKey] = createEmptyDayStats();
|
|
211
222
|
}
|
|
@@ -224,7 +235,21 @@ export const aggregateSessionsByDate = (
|
|
|
224
235
|
}
|
|
225
236
|
|
|
226
237
|
addStats(entry.bySource[session.source] as DayStats, stats);
|
|
227
|
-
|
|
238
|
+
const modelUsage = session.modelUsage.length > 0
|
|
239
|
+
? session.modelUsage
|
|
240
|
+
: [{
|
|
241
|
+
model: session.model?.trim() || "unknown",
|
|
242
|
+
messageCount: session.messageCount,
|
|
243
|
+
toolCallCount: session.toolCallCount,
|
|
244
|
+
tokens: session.totalTokens,
|
|
245
|
+
costUsd: session.totalCostUsd ?? 0,
|
|
246
|
+
}];
|
|
247
|
+
for (const usage of modelUsage) {
|
|
248
|
+
if (!entry.byModel[usage.model]) {
|
|
249
|
+
entry.byModel[usage.model] = createEmptyDayStats();
|
|
250
|
+
}
|
|
251
|
+
addStats(entry.byModel[usage.model] as DayStats, toModelStats(usage));
|
|
252
|
+
}
|
|
228
253
|
if (repoKey) {
|
|
229
254
|
addStats(entry.byRepo[repoKey] as DayStats, stats);
|
|
230
255
|
}
|
package/src/bun/normalizer.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
EMPTY_TOKEN_USAGE,
|
|
4
4
|
type TokenUsage,
|
|
5
5
|
} from "../shared/schema";
|
|
6
|
-
import type { Session, SessionEvent, SessionEventKind } from "./session-schema";
|
|
6
|
+
import type { Session, SessionEvent, SessionEventKind, SessionModelUsage } from "./session-schema";
|
|
7
7
|
import { computeCost } from "./pricing";
|
|
8
8
|
import type { RawParsedSession } from "./parsers/types";
|
|
9
9
|
|
|
@@ -345,6 +345,54 @@ const findSessionModel = (events: SessionEvent[], fallback: string | null): stri
|
|
|
345
345
|
return winner ?? fallback;
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
+
const buildModelUsage = (events: SessionEvent[], fallback: string | null): SessionModelUsage[] => {
|
|
349
|
+
const byModel = new Map<string, SessionModelUsage>();
|
|
350
|
+
|
|
351
|
+
for (const event of events) {
|
|
352
|
+
const hasUsage = event.tokens !== null || event.costUsd !== null;
|
|
353
|
+
const isCountableEvent = event.kind === "user" || event.kind === "assistant" || event.kind === "tool_call";
|
|
354
|
+
if (!hasUsage && !isCountableEvent) continue;
|
|
355
|
+
|
|
356
|
+
// Do not turn a provider name from session metadata (for example
|
|
357
|
+
// "openai" or "omnirouter") into a model row for early user messages.
|
|
358
|
+
const model = event.model?.trim() || (hasUsage ? fallback?.trim() || "unknown" : "");
|
|
359
|
+
if (!model) continue;
|
|
360
|
+
const current = byModel.get(model) ?? {
|
|
361
|
+
model,
|
|
362
|
+
messageCount: 0,
|
|
363
|
+
toolCallCount: 0,
|
|
364
|
+
tokens: { ...EMPTY_TOKEN_USAGE },
|
|
365
|
+
costUsd: 0,
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
current.tokens = addTokenUsage(current.tokens, event.tokens);
|
|
369
|
+
if (typeof event.costUsd === "number" && Number.isFinite(event.costUsd)) {
|
|
370
|
+
current.costUsd += event.costUsd;
|
|
371
|
+
}
|
|
372
|
+
if (event.kind === "user" || event.kind === "assistant") {
|
|
373
|
+
current.messageCount += 1;
|
|
374
|
+
}
|
|
375
|
+
if (event.kind === "tool_call") {
|
|
376
|
+
current.toolCallCount += 1;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
byModel.set(model, current);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (byModel.size === 0) {
|
|
383
|
+
const model = fallback?.trim() || "unknown";
|
|
384
|
+
byModel.set(model, {
|
|
385
|
+
model,
|
|
386
|
+
messageCount: 0,
|
|
387
|
+
toolCallCount: 0,
|
|
388
|
+
tokens: { ...EMPTY_TOKEN_USAGE },
|
|
389
|
+
costUsd: 0,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return Array.from(byModel.values()).sort((left, right) => left.model.localeCompare(right.model));
|
|
394
|
+
};
|
|
395
|
+
|
|
348
396
|
const deriveTitle = (events: SessionEvent[], explicit: string | null): string | null => {
|
|
349
397
|
if (explicit && explicit.trim().length > 0) return explicit.trim();
|
|
350
398
|
|
|
@@ -445,6 +493,7 @@ export const normalizeSession = (parsed: RawParsedSession): { session: Session;
|
|
|
445
493
|
messageCount,
|
|
446
494
|
totalTokens,
|
|
447
495
|
totalCostUsd: hasCost ? totalCost : null,
|
|
496
|
+
modelUsage: buildModelUsage(events, parsed.metadata.model),
|
|
448
497
|
toolCallCount,
|
|
449
498
|
isHousekeeping: housekeeping,
|
|
450
499
|
parsedAt: new Date().toISOString(),
|
|
@@ -173,6 +173,21 @@ describe("codexParser", () => {
|
|
|
173
173
|
cacheWriteTokens: 0,
|
|
174
174
|
reasoningTokens: 15,
|
|
175
175
|
});
|
|
176
|
+
expect(normalized.session.modelUsage).toEqual([
|
|
177
|
+
{
|
|
178
|
+
model: "unknown",
|
|
179
|
+
messageCount: 0,
|
|
180
|
+
toolCallCount: 0,
|
|
181
|
+
tokens: {
|
|
182
|
+
inputTokens: 90,
|
|
183
|
+
outputTokens: 20,
|
|
184
|
+
cacheReadTokens: 80,
|
|
185
|
+
cacheWriteTokens: 0,
|
|
186
|
+
reasoningTokens: 15,
|
|
187
|
+
},
|
|
188
|
+
costUsd: 0,
|
|
189
|
+
},
|
|
190
|
+
]);
|
|
176
191
|
} finally {
|
|
177
192
|
rmSync(fixtureDir, { recursive: true, force: true });
|
|
178
193
|
}
|
|
@@ -347,4 +362,76 @@ describe("codexParser", () => {
|
|
|
347
362
|
rmSync(fixtureDir, { recursive: true, force: true });
|
|
348
363
|
}
|
|
349
364
|
});
|
|
365
|
+
|
|
366
|
+
test("attributes token deltas to the model active in each turn", async () => {
|
|
367
|
+
const fixtureDir = mkdtempSync(join(tmpdir(), "ai-stats-codex-"));
|
|
368
|
+
|
|
369
|
+
try {
|
|
370
|
+
const filePath = join(fixtureDir, "rollout-2026-07-13T13-19-00-model-switch.jsonl");
|
|
371
|
+
const content = [
|
|
372
|
+
JSON.stringify({
|
|
373
|
+
type: "session_meta",
|
|
374
|
+
timestamp: "2026-07-13T13:19:00Z",
|
|
375
|
+
payload: { id: "session-model-switch", cwd: "/tmp/project", model_provider: "gpt-5.5" },
|
|
376
|
+
}),
|
|
377
|
+
JSON.stringify({
|
|
378
|
+
type: "turn_context",
|
|
379
|
+
timestamp: "2026-07-13T13:19:01Z",
|
|
380
|
+
payload: { model: "gpt-5.5" },
|
|
381
|
+
}),
|
|
382
|
+
JSON.stringify({
|
|
383
|
+
type: "event_msg",
|
|
384
|
+
timestamp: "2026-07-13T13:19:02Z",
|
|
385
|
+
payload: {
|
|
386
|
+
type: "token_count",
|
|
387
|
+
info: { total_token_usage: { input_tokens: 100, output_tokens: 10 } },
|
|
388
|
+
},
|
|
389
|
+
}),
|
|
390
|
+
JSON.stringify({
|
|
391
|
+
type: "turn_context",
|
|
392
|
+
timestamp: "2026-07-13T13:20:00Z",
|
|
393
|
+
payload: { model: "gpt-5.6-sol" },
|
|
394
|
+
}),
|
|
395
|
+
JSON.stringify({
|
|
396
|
+
type: "event_msg",
|
|
397
|
+
timestamp: "2026-07-13T13:20:01Z",
|
|
398
|
+
payload: {
|
|
399
|
+
type: "token_count",
|
|
400
|
+
info: { total_token_usage: { input_tokens: 350, output_tokens: 40 } },
|
|
401
|
+
},
|
|
402
|
+
}),
|
|
403
|
+
].join("\n");
|
|
404
|
+
|
|
405
|
+
writeFileSync(filePath, content, "utf8");
|
|
406
|
+
const fileStat = statSync(filePath);
|
|
407
|
+
const parsed = await codexParser.parse({
|
|
408
|
+
path: filePath,
|
|
409
|
+
source: "codex",
|
|
410
|
+
mtime: fileStat.mtimeMs,
|
|
411
|
+
size: fileStat.size,
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
expect(parsed).not.toBeNull();
|
|
415
|
+
if (!parsed) return;
|
|
416
|
+
|
|
417
|
+
const normalized = normalizeSession(parsed);
|
|
418
|
+
expect(normalized.session.modelUsage).toHaveLength(2);
|
|
419
|
+
expect(normalized.session.modelUsage[0]).toMatchObject({
|
|
420
|
+
model: "gpt-5.5",
|
|
421
|
+
messageCount: 0,
|
|
422
|
+
toolCallCount: 0,
|
|
423
|
+
tokens: { inputTokens: 100, outputTokens: 10, cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 },
|
|
424
|
+
});
|
|
425
|
+
expect(normalized.session.modelUsage[0]?.costUsd).toBeCloseTo(0.0008, 12);
|
|
426
|
+
expect(normalized.session.modelUsage[1]).toMatchObject({
|
|
427
|
+
model: "gpt-5.6-sol",
|
|
428
|
+
messageCount: 0,
|
|
429
|
+
toolCallCount: 0,
|
|
430
|
+
tokens: { inputTokens: 250, outputTokens: 30, cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 },
|
|
431
|
+
});
|
|
432
|
+
expect(normalized.session.modelUsage[1]?.costUsd).toBeCloseTo(0.00215, 12);
|
|
433
|
+
} finally {
|
|
434
|
+
rmSync(fixtureDir, { recursive: true, force: true });
|
|
435
|
+
}
|
|
436
|
+
});
|
|
350
437
|
});
|
package/src/bun/parsers/codex.ts
CHANGED
|
@@ -14,6 +14,14 @@ const getString = (value: unknown): string | null => {
|
|
|
14
14
|
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const CODEX_PROVIDER_NAMES = new Set(["openai", "chatgpt", "codex", "omnirouter"]);
|
|
18
|
+
|
|
19
|
+
const getCodexModelProvider = (value: unknown): string | null => {
|
|
20
|
+
const candidate = getString(value);
|
|
21
|
+
if (!candidate || CODEX_PROVIDER_NAMES.has(candidate.toLowerCase())) return null;
|
|
22
|
+
return candidate;
|
|
23
|
+
};
|
|
24
|
+
|
|
17
25
|
const parseJsonl = (content: string): Array<Record<string, unknown>> => {
|
|
18
26
|
const records: Array<Record<string, unknown>> = [];
|
|
19
27
|
for (const line of content.split(/\r?\n/)) {
|
|
@@ -358,7 +366,7 @@ export const codexParser: SessionParser = {
|
|
|
358
366
|
cwd = cwd ?? getString(payload?.cwd);
|
|
359
367
|
gitBranch = gitBranch ?? getString(git?.branch);
|
|
360
368
|
cliVersion = cliVersion ?? getString(payload?.cli_version);
|
|
361
|
-
model = model ??
|
|
369
|
+
model = model ?? getCodexModelProvider(payload?.model_provider);
|
|
362
370
|
|
|
363
371
|
events.push(
|
|
364
372
|
createEvent(sessionId, lineIndex, record, "meta", {
|
package/src/bun/pricing.test.ts
CHANGED
|
@@ -45,6 +45,20 @@ describe("computeCost", () => {
|
|
|
45
45
|
expect(cost).toBe(0);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
test("prices GPT-5.6 variants and Claude Fable without a remote pricing refresh", () => {
|
|
49
|
+
const usage = {
|
|
50
|
+
inputTokens: 1_000_000,
|
|
51
|
+
outputTokens: 0,
|
|
52
|
+
cacheReadTokens: 0,
|
|
53
|
+
cacheWriteTokens: 0,
|
|
54
|
+
reasoningTokens: 0,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
expect(computeCost(usage, "gpt-5.6-sol")).toBe(5);
|
|
58
|
+
expect(computeCost(usage, "gpt-5.6-terra")).toBe(2.5);
|
|
59
|
+
expect(computeCost(usage, "claude-fable-5")).toBe(10);
|
|
60
|
+
});
|
|
61
|
+
|
|
48
62
|
test("does not remap gpt-5.3-codex to gpt-5.2-codex pricing", async () => {
|
|
49
63
|
globalThis.fetch = ((async () =>
|
|
50
64
|
new Response(
|
package/src/bun/pricing.ts
CHANGED
|
@@ -35,12 +35,19 @@ export const PRICING: Record<string, ModelPricing> = {
|
|
|
35
35
|
"claude-3-5-haiku-20241022": { inputPer1M: 0.8, outputPer1M: 4, cacheReadPer1M: 0.08, cacheWritePer1M: 1 },
|
|
36
36
|
|
|
37
37
|
"gpt-5": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.125, cacheWritePer1M: 0 },
|
|
38
|
+
"gpt-5.5": { inputPer1M: 5, outputPer1M: 30, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
39
|
+
"gpt-5.6": { inputPer1M: 5, outputPer1M: 30, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
40
|
+
"gpt-5.6-sol": { inputPer1M: 5, outputPer1M: 30, cacheReadPer1M: 0.5, cacheWritePer1M: 0 },
|
|
41
|
+
"gpt-5.6-terra": { inputPer1M: 2.5, outputPer1M: 15, cacheReadPer1M: 0.25, cacheWritePer1M: 0 },
|
|
42
|
+
"gpt-5.6-luna": { inputPer1M: 1, outputPer1M: 6, cacheReadPer1M: 0.1, cacheWritePer1M: 0 },
|
|
38
43
|
"gpt-5.2-codex": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.125, cacheWritePer1M: 0 },
|
|
39
44
|
"gpt-5-codex": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.125, cacheWritePer1M: 0 },
|
|
40
45
|
"gpt-4o": { inputPer1M: 2.5, outputPer1M: 10, cacheReadPer1M: 1.25, cacheWritePer1M: 0 },
|
|
41
46
|
o1: { inputPer1M: 15, outputPer1M: 60, cacheReadPer1M: 7.5, cacheWritePer1M: 0 },
|
|
42
47
|
o3: { inputPer1M: 10, outputPer1M: 40, cacheReadPer1M: 2.5, cacheWritePer1M: 0 },
|
|
43
48
|
|
|
49
|
+
"claude-fable-5": { inputPer1M: 10, outputPer1M: 50, cacheReadPer1M: 1, cacheWritePer1M: 12.5 },
|
|
50
|
+
|
|
44
51
|
"gemini-2.5-pro": { inputPer1M: 1.25, outputPer1M: 10, cacheReadPer1M: 0.315, cacheWritePer1M: 4.5 },
|
|
45
52
|
"gemini-2.5-flash": { inputPer1M: 0.15, outputPer1M: 0.6, cacheReadPer1M: 0.0375, cacheWritePer1M: 1 },
|
|
46
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { Session, SessionEvent, SessionEventKind } from "../shared/schema";
|
|
1
|
+
export type { Session, SessionEvent, SessionEventKind, SessionModelUsage } from "../shared/schema";
|
package/src/bun/store.test.ts
CHANGED
|
@@ -117,7 +117,7 @@ describe("rawAggregationMetaNeedsTimeZoneBackfill", () => {
|
|
|
117
117
|
test("returns true when version changes", () => {
|
|
118
118
|
expect(
|
|
119
119
|
rawAggregationMetaNeedsTimeZoneBackfill(
|
|
120
|
-
{ version:
|
|
120
|
+
{ version: 1, timeZone: "America/Los_Angeles" },
|
|
121
121
|
"America/Los_Angeles",
|
|
122
122
|
),
|
|
123
123
|
).toBe(true);
|
|
@@ -126,7 +126,7 @@ describe("rawAggregationMetaNeedsTimeZoneBackfill", () => {
|
|
|
126
126
|
test("returns true when timezone changes", () => {
|
|
127
127
|
expect(
|
|
128
128
|
rawAggregationMetaNeedsTimeZoneBackfill(
|
|
129
|
-
{ version:
|
|
129
|
+
{ version: 2, timeZone: "UTC" },
|
|
130
130
|
"America/Los_Angeles",
|
|
131
131
|
),
|
|
132
132
|
).toBe(true);
|
|
@@ -135,7 +135,7 @@ describe("rawAggregationMetaNeedsTimeZoneBackfill", () => {
|
|
|
135
135
|
test("returns false for matching version and timezone", () => {
|
|
136
136
|
expect(
|
|
137
137
|
rawAggregationMetaNeedsTimeZoneBackfill(
|
|
138
|
-
{ version:
|
|
138
|
+
{ version: 2, timeZone: "America/Los_Angeles" },
|
|
139
139
|
"America/Los_Angeles",
|
|
140
140
|
),
|
|
141
141
|
).toBe(false);
|
package/src/bun/store.ts
CHANGED
|
@@ -47,7 +47,7 @@ const SCAN_STATE_PATH = join(DATA_DIR, "scan-state.json");
|
|
|
47
47
|
const DAILY_PATH = join(DATA_DIR, "daily.json");
|
|
48
48
|
const AGGREGATION_META_PATH = join(DATA_DIR, "aggregation-meta.json");
|
|
49
49
|
const SETTINGS_PATH = join(DATA_DIR, "settings.json");
|
|
50
|
-
const AGGREGATION_META_VERSION =
|
|
50
|
+
const AGGREGATION_META_VERSION = 2;
|
|
51
51
|
|
|
52
52
|
const DEFAULT_SETTINGS: AppSettings = {
|
|
53
53
|
scanOnLaunch: true,
|
package/src/shared/schema.ts
CHANGED
|
@@ -10,7 +10,15 @@ export interface TokenUsage {
|
|
|
10
10
|
reasoningTokens: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export type {
|
|
13
|
+
export type {
|
|
14
|
+
Session,
|
|
15
|
+
SessionEvent,
|
|
16
|
+
SessionEventKind,
|
|
17
|
+
SessionFilters,
|
|
18
|
+
SessionModelUsage,
|
|
19
|
+
SessionSortBy,
|
|
20
|
+
SessionSortDir,
|
|
21
|
+
} from "./session-types";
|
|
14
22
|
|
|
15
23
|
export const EMPTY_TOKEN_USAGE: TokenUsage = {
|
|
16
24
|
inputTokens: 0,
|
|
@@ -20,6 +20,14 @@ export interface SessionEvent {
|
|
|
20
20
|
costUsd: number | null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export interface SessionModelUsage {
|
|
24
|
+
model: string;
|
|
25
|
+
messageCount: number;
|
|
26
|
+
toolCallCount: number;
|
|
27
|
+
tokens: TokenUsage;
|
|
28
|
+
costUsd: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
export interface Session {
|
|
24
32
|
id: string;
|
|
25
33
|
source: SessionSource;
|
|
@@ -38,6 +46,7 @@ export interface Session {
|
|
|
38
46
|
messageCount: number;
|
|
39
47
|
totalTokens: TokenUsage;
|
|
40
48
|
totalCostUsd: number | null;
|
|
49
|
+
modelUsage: SessionModelUsage[];
|
|
41
50
|
toolCallCount: number;
|
|
42
51
|
isHousekeeping: boolean;
|
|
43
52
|
parsedAt: string;
|