repospend 0.1.6 → 0.1.8

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/cli.js CHANGED
@@ -12,6 +12,8 @@ function summarize(sessions) {
12
12
  const cacheCreationInputTokens = optionalSum(sessions, "cacheCreationInputTokens");
13
13
  const cacheCreationInputTokens5m = optionalSum(sessions, "cacheCreationInputTokens5m");
14
14
  const cacheCreationInputTokens1h = optionalSum(sessions, "cacheCreationInputTokens1h");
15
+ const cacheCreationInputTokens30m = optionalSum(sessions, "cacheCreationInputTokens30m");
16
+ const cacheCreationInputTokens12h = optionalSum(sessions, "cacheCreationInputTokens12h");
15
17
  return {
16
18
  estimatedCostUsd: cost.knownCount > 0 ? cost.value : void 0,
17
19
  knownCostSessions: cost.knownCount,
@@ -20,13 +22,15 @@ function summarize(sessions) {
20
22
  cacheCreationInputTokens,
21
23
  cacheCreationInputTokens5m,
22
24
  cacheCreationInputTokens1h,
25
+ cacheCreationInputTokens30m,
26
+ cacheCreationInputTokens12h,
23
27
  inputTokens,
24
28
  outputTokens: sum(sessions, "outputTokens"),
25
29
  reasoningTokens: sum(sessions, "reasoningTokens"),
26
30
  cachedInputPct: inputTokens > 0 ? cachedInputTokens / inputTokens : 0,
27
31
  sessionCount: sessions.length,
28
32
  repoCount: repos.length,
29
- modelCount: new Set(sessions.map((session) => session.model).filter(Boolean)).size,
33
+ modelCount: new Set(sessions.flatMap((session) => sessionModelSlices(session).map((slice) => slice.model)).filter(Boolean)).size,
30
34
  mostExpensiveRepo: repos.filter((repo) => repo.estimatedCostUsd !== void 0).sort((a, b) => (b.estimatedCostUsd ?? 0) - (a.estimatedCostUsd ?? 0))[0],
31
35
  unknownCostSessions: sessions.filter((session) => session.estimatedCostUsd === void 0).length,
32
36
  userPromptCount: optionalSum(sessions, "userPromptCount"),
@@ -57,12 +61,53 @@ function groupByRepo(sessions) {
57
61
  }));
58
62
  }
59
63
  function groupByModel(sessions) {
60
- const groups = groupBy(sessions, (session) => session.model ?? "unknown-model", (session) => session.model ?? "Model not recorded");
61
- const unknownModelSessions = sessions.filter((session) => !session.model);
64
+ const groups = /* @__PURE__ */ new Map();
65
+ for (const session of sessions) {
66
+ for (const slice of sessionModelSlices(session)) {
67
+ const id = slice.model ?? "unknown-model";
68
+ const group = groups.get(id) ?? emptyGroup(id, slice.model ?? "Model not recorded");
69
+ accumulateGroup(group, session, slice);
70
+ groups.set(id, group);
71
+ }
72
+ }
73
+ const grouped = sortGroups([...groups.values()]);
74
+ const unknownModelSessions = sessions.filter((session) => !session.model && !(session.modelUsage ?? []).some((entry) => entry.model));
62
75
  if (unknownModelSessions.length > 0 && unknownModelSessions.every(isClaudeSyntheticZeroUsageSession)) {
63
- return groups.map((group) => group.id === "unknown-model" ? { ...group, label: "Claude synthetic / no usage" } : group);
76
+ return grouped.map((group) => group.id === "unknown-model" ? { ...group, label: "Claude synthetic / no usage" } : group);
64
77
  }
65
- return groups;
78
+ return grouped;
79
+ }
80
+ function sessionModelSlices(session) {
81
+ if (session.modelUsage?.length) {
82
+ return session.modelUsage.map((entry) => ({
83
+ model: entry.model,
84
+ inputTokens: entry.inputTokens,
85
+ cachedInputTokens: entry.cachedInputTokens,
86
+ cacheCreationInputTokens: entry.cacheCreationInputTokens,
87
+ cacheCreationInputTokens5m: 0,
88
+ cacheCreationInputTokens1h: 0,
89
+ cacheCreationInputTokens30m: entry.cacheCreationInputTokens30m ?? 0,
90
+ cacheCreationInputTokens12h: entry.cacheCreationInputTokens12h ?? 0,
91
+ outputTokens: entry.outputTokens,
92
+ reasoningTokens: entry.reasoningTokens,
93
+ totalTokens: entry.totalTokens,
94
+ estimatedCostUsd: entry.estimatedCostUsd
95
+ }));
96
+ }
97
+ return [{
98
+ model: session.model,
99
+ inputTokens: session.inputTokens,
100
+ cachedInputTokens: session.cachedInputTokens,
101
+ cacheCreationInputTokens: session.cacheCreationInputTokens ?? 0,
102
+ cacheCreationInputTokens5m: session.cacheCreationInputTokens5m ?? 0,
103
+ cacheCreationInputTokens1h: session.cacheCreationInputTokens1h ?? 0,
104
+ cacheCreationInputTokens30m: session.cacheCreationInputTokens30m ?? 0,
105
+ cacheCreationInputTokens12h: session.cacheCreationInputTokens12h ?? 0,
106
+ outputTokens: session.outputTokens,
107
+ reasoningTokens: session.reasoningTokens,
108
+ totalTokens: session.totalTokens,
109
+ estimatedCostUsd: session.estimatedCostUsd
110
+ }];
66
111
  }
67
112
  function groupBySourceApp(sessions) {
68
113
  return groupBy(sessions, (session) => session.sourceApp, (session) => session.sourceApp);
@@ -77,45 +122,57 @@ function groupBy(sessions, keyFn, labelFn) {
77
122
  const groups = /* @__PURE__ */ new Map();
78
123
  for (const session of sessions) {
79
124
  const id = keyFn(session);
80
- const existing = groups.get(id);
81
- const group = existing ?? {
82
- id,
83
- label: labelFn(session),
84
- estimatedCostUsd: void 0,
85
- knownCostSessions: 0,
86
- unknownCostSessions: 0,
87
- inputTokens: 0,
88
- cachedInputTokens: 0,
89
- cacheCreationInputTokens: 0,
90
- cacheCreationInputTokens5m: 0,
91
- cacheCreationInputTokens1h: 0,
92
- outputTokens: 0,
93
- reasoningTokens: 0,
94
- totalTokens: 0,
95
- sessionCount: 0,
96
- messageCount: 0,
97
- warnings: []
98
- };
99
- group.inputTokens += session.inputTokens;
100
- group.cachedInputTokens += session.cachedInputTokens;
101
- group.cacheCreationInputTokens = (group.cacheCreationInputTokens ?? 0) + (session.cacheCreationInputTokens ?? 0);
102
- group.cacheCreationInputTokens5m = (group.cacheCreationInputTokens5m ?? 0) + (session.cacheCreationInputTokens5m ?? 0);
103
- group.cacheCreationInputTokens1h = (group.cacheCreationInputTokens1h ?? 0) + (session.cacheCreationInputTokens1h ?? 0);
104
- group.outputTokens += session.outputTokens;
105
- group.reasoningTokens += session.reasoningTokens;
106
- group.totalTokens += session.totalTokens;
107
- group.sessionCount += 1;
108
- group.messageCount += session.messageCount;
109
- group.warnings = unique([...group.warnings, ...session.warnings]);
110
- if (session.estimatedCostUsd !== void 0) {
111
- group.estimatedCostUsd = roundCurrency((group.estimatedCostUsd ?? 0) + session.estimatedCostUsd);
112
- group.knownCostSessions += 1;
113
- } else {
114
- group.unknownCostSessions += 1;
115
- }
125
+ const group = groups.get(id) ?? emptyGroup(id, labelFn(session));
126
+ accumulateGroup(group, session, session);
116
127
  groups.set(id, group);
117
128
  }
118
- return [...groups.values()].sort((a, b) => (b.estimatedCostUsd ?? 0) - (a.estimatedCostUsd ?? 0) || b.totalTokens - a.totalTokens);
129
+ return sortGroups([...groups.values()]);
130
+ }
131
+ function emptyGroup(id, label) {
132
+ return {
133
+ id,
134
+ label,
135
+ estimatedCostUsd: void 0,
136
+ knownCostSessions: 0,
137
+ unknownCostSessions: 0,
138
+ inputTokens: 0,
139
+ cachedInputTokens: 0,
140
+ cacheCreationInputTokens: 0,
141
+ cacheCreationInputTokens5m: 0,
142
+ cacheCreationInputTokens1h: 0,
143
+ cacheCreationInputTokens30m: 0,
144
+ cacheCreationInputTokens12h: 0,
145
+ outputTokens: 0,
146
+ reasoningTokens: 0,
147
+ totalTokens: 0,
148
+ sessionCount: 0,
149
+ messageCount: 0,
150
+ warnings: []
151
+ };
152
+ }
153
+ function accumulateGroup(group, session, slice) {
154
+ group.inputTokens += slice.inputTokens;
155
+ group.cachedInputTokens += slice.cachedInputTokens;
156
+ group.cacheCreationInputTokens = (group.cacheCreationInputTokens ?? 0) + (slice.cacheCreationInputTokens ?? 0);
157
+ group.cacheCreationInputTokens5m = (group.cacheCreationInputTokens5m ?? 0) + (slice.cacheCreationInputTokens5m ?? 0);
158
+ group.cacheCreationInputTokens1h = (group.cacheCreationInputTokens1h ?? 0) + (slice.cacheCreationInputTokens1h ?? 0);
159
+ group.cacheCreationInputTokens30m = (group.cacheCreationInputTokens30m ?? 0) + (slice.cacheCreationInputTokens30m ?? 0);
160
+ group.cacheCreationInputTokens12h = (group.cacheCreationInputTokens12h ?? 0) + (slice.cacheCreationInputTokens12h ?? 0);
161
+ group.outputTokens += slice.outputTokens;
162
+ group.reasoningTokens += slice.reasoningTokens;
163
+ group.totalTokens += slice.totalTokens;
164
+ group.sessionCount += 1;
165
+ group.messageCount += session.messageCount;
166
+ group.warnings = unique([...group.warnings, ...session.warnings]);
167
+ if (slice.estimatedCostUsd !== void 0) {
168
+ group.estimatedCostUsd = roundCurrency((group.estimatedCostUsd ?? 0) + slice.estimatedCostUsd);
169
+ group.knownCostSessions += 1;
170
+ } else {
171
+ group.unknownCostSessions += 1;
172
+ }
173
+ }
174
+ function sortGroups(groups) {
175
+ return groups.sort((a, b) => (b.estimatedCostUsd ?? 0) - (a.estimatedCostUsd ?? 0) || b.totalTokens - a.totalTokens);
119
176
  }
120
177
  function isClaudeSyntheticZeroUsageSession(session) {
121
178
  return session.warnings.includes("claude_synthetic_zero_usage");
@@ -142,6 +199,8 @@ function toCsv(sessions) {
142
199
  "cacheCreationInputTokens",
143
200
  "cacheCreationInputTokens5m",
144
201
  "cacheCreationInputTokens1h",
202
+ "cacheCreationInputTokens30m",
203
+ "cacheCreationInputTokens12h",
145
204
  "outputTokens",
146
205
  "reasoningTokens",
147
206
  "reasoningOutputTokens",
@@ -253,9 +312,11 @@ function claudePricingFamilyModel(model, isUsable = () => true) {
253
312
  "claude-sonnet-4-5",
254
313
  "claude-sonnet-4",
255
314
  "claude-haiku-4-5",
315
+ "claude-haiku-5-5",
256
316
  "claude-3-5-haiku"
257
317
  ];
258
318
  const normalized = normalizePricingModelId(model);
319
+ if (normalized.includes("-long-context")) return void 0;
259
320
  const matchesFamily = (candidate) => normalized === candidate || normalized.startsWith(`${candidate}-`) || normalized.startsWith(`${candidate}.`);
260
321
  if (normalized.includes("fast-mode")) {
261
322
  return families.find((candidate) => candidate.includes("fast-mode") && matchesFamily(candidate) && isUsable(candidate));
@@ -271,7 +332,7 @@ function copilotPricingFamilyModel(model, isUsable = () => true) {
271
332
  if ((normalized === "gemini-3-flash" || normalized.startsWith("gemini-3-flash-")) && isUsable("gemini-3-flash")) return "gemini-3-flash";
272
333
  if ((normalized === "gemini-3.1-pro" || normalized.startsWith("gemini-3.1-pro-")) && isUsable("gemini-3.1-pro")) return "gemini-3.1-pro";
273
334
  if ((normalized === "gemini-3.5-flash" || normalized.startsWith("gemini-3.5-flash-")) && isUsable("gemini-3.5-flash")) return "gemini-3.5-flash";
274
- for (const candidate of ["gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "grok-4.5", "grok-4.6", "grok-4.7", "mai-code-1.1-flash", "kimi-k3"]) {
335
+ for (const candidate of ["gemini-3.6-flash", "gemini-3.7-flash", "gemini-3.8-flash", "gemini-4-argon", "grok-4.5", "grok-4.6", "grok-4.7", "mai-code-1.1-flash", "kimi-k3"]) {
275
336
  if ((normalized === candidate || normalized.startsWith(`${candidate}-`)) && isUsable(candidate)) return candidate;
276
337
  }
277
338
  if ((normalized === "raptor-mini" || normalized.startsWith("raptor-mini-") || normalized.startsWith("oswe-vscode")) && isUsable("raptor-mini")) return "raptor-mini";
@@ -282,7 +343,7 @@ function copilotPricingFamilyModel(model, isUsable = () => true) {
282
343
  return void 0;
283
344
  }
284
345
  function parseVersionedModel(normalized) {
285
- if (normalized.includes("fast-mode")) return void 0;
346
+ if (normalized.includes("fast-mode") || normalized.includes("-long-context")) return void 0;
286
347
  const claude = normalized.match(/^(claude-(?:fable|mythos|opus|sonnet|haiku))-(\d+)(?:-(\d{1,2}))?(?!\d)/);
287
348
  if (claude) {
288
349
  const minor = claude[3] ? Number(claude[3]) : 0;
@@ -318,17 +379,36 @@ function positiveRate(value) {
318
379
  function isUsableModelPricing(pricing) {
319
380
  return positiveRate(pricing?.inputPerMillion) && positiveRate(pricing?.outputPerMillion);
320
381
  }
321
- function findModelPricing(model, pricing) {
382
+ function resolvePricingForModel(model, table) {
322
383
  const lower = normalizePricingModelId(model);
323
- const exact = pricing[model] ?? pricing[lower];
324
- if (isUsableModelPricing(exact)) return exact;
325
- const versioned = versionedFallbackModel(lower, Object.keys(pricing), (candidate) => isUsableModelPricing(pricing[candidate]));
326
- if (versioned) return pricing[versioned];
327
- const claudeFamily = claudePricingFamilyModel(lower, (candidate) => isUsableModelPricing(pricing[candidate]));
328
- if (claudeFamily) return pricing[claudeFamily];
329
- const copilotFamily = copilotPricingFamilyModel(lower, (candidate) => isUsableModelPricing(pricing[candidate]));
330
- if (copilotFamily) return pricing[copilotFamily];
331
- return void 0;
384
+ const exactModel = table[model] ? model : table[lower] ? lower : void 0;
385
+ const exactPricing = exactModel ? table[exactModel] : void 0;
386
+ if (isUsableModelPricing(exactPricing)) {
387
+ return { pricing: exactPricing, sourceModel: exactModel, inherited: false };
388
+ }
389
+ const versioned = versionedFallbackModel(lower, Object.keys(table), (candidate) => isUsableModelPricing(table[candidate]));
390
+ if (versioned) {
391
+ return { pricing: table[versioned], sourceModel: versioned, inherited: versioned !== model && versioned !== lower };
392
+ }
393
+ const claudeFamily = claudePricingFamilyModel(lower, (candidate) => isUsableModelPricing(table[candidate]));
394
+ if (claudeFamily) {
395
+ return { pricing: table[claudeFamily], sourceModel: claudeFamily, inherited: claudeFamily !== model && claudeFamily !== lower };
396
+ }
397
+ const copilotFamily = copilotPricingFamilyModel(lower, (candidate) => isUsableModelPricing(table[candidate]));
398
+ if (copilotFamily) {
399
+ return { pricing: table[copilotFamily], sourceModel: copilotFamily, inherited: copilotFamily !== model && copilotFamily !== lower };
400
+ }
401
+ return {
402
+ pricing: exactPricing ?? {
403
+ inputPerMillion: 0,
404
+ cacheCreationInputPerMillion: 0,
405
+ cachedInputPerMillion: 0,
406
+ outputPerMillion: 0,
407
+ reasoningOutputPerMillion: 0
408
+ },
409
+ sourceModel: exactModel,
410
+ inherited: false
411
+ };
332
412
  }
333
413
 
334
414
  // packages/core/src/pricing.ts
@@ -339,30 +419,47 @@ var pricingInfo = {
339
419
  { label: "OpenAI pricing reference", url: "https://developers.openai.com/api/docs/pricing" },
340
420
  { label: "OpenAI GPT-6 model reference", url: "https://developers.openai.com/api/docs/models" },
341
421
  { label: "OpenAI GPT-6.1 Sol reference", url: "https://developers.openai.com/api/docs/models/gpt-6.1-sol" },
422
+ { label: "OpenAI GPT-6.1 Terra reference", url: "https://developers.openai.com/api/docs/models/gpt-6.1-terra" },
423
+ { label: "OpenAI prompt caching guide", url: "https://developers.openai.com/api/docs/guides/prompt-caching" },
342
424
  { label: "OpenAI GPT-5.6 preview pricing", url: "https://openai.com/index/previewing-gpt-5-6-sol/" },
343
425
  { label: "OpenAI GPT-5.6 price update", url: "https://openai.com/index/advancing-the-price-performance-frontier-with-gpt-5-6/" },
344
426
  { label: "Claude pricing reference", url: "https://platform.claude.com/docs/en/about-claude/pricing" },
427
+ { label: "Claude Haiku 5.5 and Sonnet cache update", url: "https://www.anthropic.com/claude-haiku-5-5" },
428
+ { label: "Gemini 4 Argon pricing", url: "https://ai.google.dev/gemini-api/docs/latest-model?hl=en" },
345
429
  { label: "GitHub Copilot model pricing reference", url: "https://docs.github.com/en/copilot/reference/copilot-billing/models-and-pricing" }
346
430
  ],
347
431
  unit: "USD per 1M tokens",
348
- updatedAt: "2026-09-29",
349
- note: "RepoSpend estimates API-equivalent cost from local token counts and public Standard pricing. GPT-6 defaults use short-context rates. Claude transcript fast-mode speeds use explicit published cards. Long-context, other processing modes, regional, and account-specific pricing can differ. This is not your actual bill."
432
+ updatedAt: "2026-10-27",
433
+ note: "RepoSpend estimates API-equivalent cost from local token counts and public Standard pricing. Requests over each model's long-context threshold reprice per request when request sizes are recorded; aggregate-only usage assumes short-context rates and is flagged. Claude transcript fast-mode speeds use explicit published cards. Other processing modes, regional, and account-specific pricing can differ. This is not your actual bill."
350
434
  };
351
435
  var defaultPricing = {
352
- "gpt-6-astra": { inputPerMillion: 10, cachedInputPerMillion: 1, cacheCreationInputPerMillion: 12.5, outputPerMillion: 50, reasoningOutputPerMillion: 50 },
353
- "gpt-6-sol": { inputPerMillion: 2, cachedInputPerMillion: 0.2, cacheCreationInputPerMillion: 2.5, outputPerMillion: 10, reasoningOutputPerMillion: 10 },
354
- "gpt-6.1-sol": { inputPerMillion: 2, cachedInputPerMillion: 0.1, cacheCreationInputPerMillion: 2.5, outputPerMillion: 10, reasoningOutputPerMillion: 10 },
355
- "gpt-6-luna": { inputPerMillion: 0.1, cachedInputPerMillion: 0.01, cacheCreationInputPerMillion: 0.125, outputPerMillion: 0.5, reasoningOutputPerMillion: 0.5 },
356
- "gpt-5.6": { inputPerMillion: 4, cachedInputPerMillion: 0.4, cacheCreationInputPerMillion: 5, outputPerMillion: 20, reasoningOutputPerMillion: 20, note: "GPT-5.6 aliases Sol. Promotional Standard short-context rates are available at least through November 21, 2026: $4 input / $20 output, $0.40 cache reads, and $5 cache writes per 1M tokens." },
357
- "gpt-5.6-sol": { inputPerMillion: 4, cachedInputPerMillion: 0.4, cacheCreationInputPerMillion: 5, outputPerMillion: 20, reasoningOutputPerMillion: 20, note: "Promotional Standard short-context rates available at least through November 21, 2026." },
358
- "gpt-5.6-terra": { inputPerMillion: 2, cachedInputPerMillion: 0.2, cacheCreationInputPerMillion: 2.5, outputPerMillion: 12, reasoningOutputPerMillion: 12, note: "GPT-5.6 Terra reduced API pricing effective July 30, 2026. Cache reads are 90% below input and cache writes are 1.25x input." },
359
- "gpt-5.6-luna": { inputPerMillion: 0.2, cachedInputPerMillion: 0.02, cacheCreationInputPerMillion: 0.25, outputPerMillion: 1.2, reasoningOutputPerMillion: 1.2, note: "GPT-5.6 Luna reduced API pricing effective July 30, 2026. Cache reads are 90% below input and cache writes are 1.25x input." },
436
+ "gpt-6-astra": { inputPerMillion: 10, cachedInputPerMillion: 1, cacheCreationInputPerMillion: 12.5, cacheCreationInput30mPerMillion: 12.5, cacheCreationInput12hPerMillion: 25, outputPerMillion: 50, reasoningOutputPerMillion: 50 },
437
+ "gpt-6-astra-long-context": { inputPerMillion: 20, cachedInputPerMillion: 2, cacheCreationInputPerMillion: 25, cacheCreationInput30mPerMillion: 25, cacheCreationInput12hPerMillion: 50, outputPerMillion: 75, reasoningOutputPerMillion: 75, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
438
+ "gpt-6-sol": { inputPerMillion: 2, cachedInputPerMillion: 0.2, cacheCreationInputPerMillion: 2.5, cacheCreationInput30mPerMillion: 2.5, cacheCreationInput12hPerMillion: 5, outputPerMillion: 10, reasoningOutputPerMillion: 10 },
439
+ "gpt-6-sol-long-context": { inputPerMillion: 4, cachedInputPerMillion: 0.4, cacheCreationInputPerMillion: 5, cacheCreationInput30mPerMillion: 5, cacheCreationInput12hPerMillion: 10, outputPerMillion: 15, reasoningOutputPerMillion: 15, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
440
+ "gpt-6-luna": { inputPerMillion: 0.1, cachedInputPerMillion: 0.01, cacheCreationInputPerMillion: 0.125, cacheCreationInput30mPerMillion: 0.125, cacheCreationInput12hPerMillion: 0.25, outputPerMillion: 0.5, reasoningOutputPerMillion: 0.5 },
441
+ "gpt-6-luna-long-context": { inputPerMillion: 0.2, cachedInputPerMillion: 0.02, cacheCreationInputPerMillion: 0.25, cacheCreationInput30mPerMillion: 0.25, cacheCreationInput12hPerMillion: 0.5, outputPerMillion: 0.75, reasoningOutputPerMillion: 0.75, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
442
+ "gpt-6.1-sol": { inputPerMillion: 2, cachedInputPerMillion: 0.1, cacheCreationInputPerMillion: 2.5, cacheCreationInput30mPerMillion: 2.5, cacheCreationInput12hPerMillion: 5, outputPerMillion: 10, reasoningOutputPerMillion: 10 },
443
+ "gpt-6.1-sol-long-context": { inputPerMillion: 4, cachedInputPerMillion: 0.2, cacheCreationInputPerMillion: 5, cacheCreationInput30mPerMillion: 5, cacheCreationInput12hPerMillion: 10, outputPerMillion: 15, reasoningOutputPerMillion: 15, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
444
+ "gpt-6.1-terra": { inputPerMillion: 1, cachedInputPerMillion: 0.05, cacheCreationInputPerMillion: 1.25, cacheCreationInput30mPerMillion: 1.25, cacheCreationInput12hPerMillion: 2.5, outputPerMillion: 5, reasoningOutputPerMillion: 5, note: "GPT-6.1 Terra Standard short-context rates, released October 26, 2026. Cache writes are 1.25x input for 30-minute TTL and 2.5x for 12-hour TTL." },
445
+ "gpt-6.1-terra-long-context": { inputPerMillion: 2, cachedInputPerMillion: 0.1, cacheCreationInputPerMillion: 2.5, cacheCreationInput30mPerMillion: 2.5, cacheCreationInput12hPerMillion: 5, outputPerMillion: 7.5, reasoningOutputPerMillion: 7.5, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
446
+ "gpt-5.6": { inputPerMillion: 4, cachedInputPerMillion: 0.4, cacheCreationInputPerMillion: 5, cacheCreationInput30mPerMillion: 5, cacheCreationInput12hPerMillion: 10, outputPerMillion: 20, reasoningOutputPerMillion: 20, note: "GPT-5.6 aliases Sol. Promotional Standard short-context rates are available at least through November 21, 2026: $4 input / $20 output, $0.40 cache reads, and $5 cache writes per 1M tokens." },
447
+ "gpt-5.6-sol": { inputPerMillion: 4, cachedInputPerMillion: 0.4, cacheCreationInputPerMillion: 5, cacheCreationInput30mPerMillion: 5, cacheCreationInput12hPerMillion: 10, outputPerMillion: 20, reasoningOutputPerMillion: 20, note: "Promotional Standard short-context rates available at least through November 21, 2026." },
448
+ "gpt-5.6-terra": { inputPerMillion: 2, cachedInputPerMillion: 0.2, cacheCreationInputPerMillion: 2.5, cacheCreationInput30mPerMillion: 2.5, cacheCreationInput12hPerMillion: 5, outputPerMillion: 12, reasoningOutputPerMillion: 12, note: "GPT-5.6 Terra reduced API pricing effective July 30, 2026. Cache reads are 90% below input and cache writes are 1.25x input." },
449
+ "gpt-5.6-luna": { inputPerMillion: 0.2, cachedInputPerMillion: 0.02, cacheCreationInputPerMillion: 0.25, cacheCreationInput30mPerMillion: 0.25, cacheCreationInput12hPerMillion: 0.5, outputPerMillion: 1.2, reasoningOutputPerMillion: 1.2, note: "GPT-5.6 Luna reduced API pricing effective July 30, 2026. Cache reads are 90% below input and cache writes are 1.25x input." },
360
450
  "gpt-5.5": { inputPerMillion: 5, cachedInputPerMillion: 0.5, outputPerMillion: 30, reasoningOutputPerMillion: 30 },
361
451
  "gpt-5.5-pro": { inputPerMillion: 30, outputPerMillion: 180, reasoningOutputPerMillion: 180 },
362
452
  "gpt-5.4": { inputPerMillion: 2.5, cachedInputPerMillion: 0.25, outputPerMillion: 15, reasoningOutputPerMillion: 15 },
363
453
  "gpt-5.4-mini": { inputPerMillion: 0.75, cachedInputPerMillion: 0.075, outputPerMillion: 4.5, reasoningOutputPerMillion: 4.5 },
364
454
  "gpt-5.4-nano": { inputPerMillion: 0.2, cachedInputPerMillion: 0.02, outputPerMillion: 1.25, reasoningOutputPerMillion: 1.25 },
365
455
  "gpt-5.4-pro": { inputPerMillion: 30, outputPerMillion: 180, reasoningOutputPerMillion: 180 },
456
+ "gpt-5.6-sol-long-context": { inputPerMillion: 8, cachedInputPerMillion: 0.8, cacheCreationInputPerMillion: 10, cacheCreationInput30mPerMillion: 10, cacheCreationInput12hPerMillion: 20, outputPerMillion: 30, reasoningOutputPerMillion: 30, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.6 request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
457
+ "gpt-5.6-terra-long-context": { inputPerMillion: 4, cachedInputPerMillion: 0.4, cacheCreationInputPerMillion: 5, cacheCreationInput30mPerMillion: 5, cacheCreationInput12hPerMillion: 10, outputPerMillion: 18, reasoningOutputPerMillion: 18, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.6 Terra request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
458
+ "gpt-5.6-luna-long-context": { inputPerMillion: 0.4, cachedInputPerMillion: 0.04, cacheCreationInputPerMillion: 0.5, cacheCreationInput30mPerMillion: 0.5, cacheCreationInput12hPerMillion: 1, outputPerMillion: 1.8, reasoningOutputPerMillion: 1.8, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.6 Luna request when a single API call exceeds 272K input tokens: input and cache rates 2x, output 1.5x." },
459
+ "gpt-5.5-long-context": { inputPerMillion: 10, cachedInputPerMillion: 1, outputPerMillion: 45, reasoningOutputPerMillion: 45, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.5 request when a single API call exceeds 272K input tokens. No published cache-write rates." },
460
+ "gpt-5.5-pro-long-context": { inputPerMillion: 60, outputPerMillion: 270, reasoningOutputPerMillion: 270, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.5 Pro request when a single API call exceeds 272K input tokens. No published cache rates." },
461
+ "gpt-5.4-long-context": { inputPerMillion: 5, cachedInputPerMillion: 0.5, outputPerMillion: 22.5, reasoningOutputPerMillion: 22.5, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.4 request when a single API call exceeds 272K input tokens. No published cache-write rates." },
462
+ "gpt-5.4-pro-long-context": { inputPerMillion: 60, outputPerMillion: 270, reasoningOutputPerMillion: 270, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole GPT-5.4 Pro request when a single API call exceeds 272K input tokens. No published cache rates." },
366
463
  "gpt-5.3-codex": { inputPerMillion: 1.75, cachedInputPerMillion: 0.175, outputPerMillion: 14, reasoningOutputPerMillion: 14 },
367
464
  "gpt-5.3-codex-spark": { inputPerMillion: 1.75, cachedInputPerMillion: 0.175, outputPerMillion: 14, reasoningOutputPerMillion: 14, note: "Research preview pricing is not final in the OpenAI Codex rate card; this API-equivalent rate matches the practical ccusage/LiteLLM-style estimate." },
368
465
  "gpt-5.2": { inputPerMillion: 1.75, cachedInputPerMillion: 0.175, outputPerMillion: 14, reasoningOutputPerMillion: 14 },
@@ -387,6 +484,7 @@ var defaultPricing = {
387
484
  "gemini-3.6-flash": { inputPerMillion: 0.75, cachedInputPerMillion: 0.075, outputPerMillion: 3.75, note: "GitHub Copilot promotional rates through December 31, 2026; API-equivalent estimate." },
388
485
  "gemini-3.7-flash": { inputPerMillion: 0.75, cachedInputPerMillion: 0.075, outputPerMillion: 3.75, note: "GitHub Copilot promotional rates through December 31, 2026; API-equivalent estimate." },
389
486
  "gemini-3.8-flash": { inputPerMillion: 0.75, cachedInputPerMillion: 0.075, outputPerMillion: 3.75, note: "GitHub Copilot promotional rates through December 31, 2026; API-equivalent estimate." },
487
+ "gemini-4-argon": { inputPerMillion: 2, cachedInputPerMillion: 0.1, outputPerMillion: 10, reasoningOutputPerMillion: 10, note: "Introductory rates through November 30, 2026. From December 1: $4 input / $0.20 cached input / $20 output (including thinking) per 1M tokens. No explicit cache-write charge. Bundled prices are a dated snapshot, not an automatic future rate switch." },
390
488
  "grok-4.5": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 6, note: "GitHub Copilot Standard rates up to 200K input tokens; longer requests use different rates." },
391
489
  "grok-4.6": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 6, note: "GitHub Copilot Standard rates up to 200K input tokens; longer requests use different rates." },
392
490
  "grok-4.7": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 6, note: "GitHub Copilot Standard rates up to 200K input tokens; longer requests use different rates." },
@@ -414,15 +512,18 @@ var defaultPricing = {
414
512
  "claude-opus-4-5": { inputPerMillion: 5, cacheCreationInput5mPerMillion: 6.25, cacheCreationInput1hPerMillion: 10, cacheCreationInputPerMillion: 10, cachedInputPerMillion: 0.5, outputPerMillion: 25 },
415
513
  "claude-opus-4-1": { inputPerMillion: 15, cacheCreationInput5mPerMillion: 18.75, cacheCreationInput1hPerMillion: 30, cacheCreationInputPerMillion: 30, cachedInputPerMillion: 1.5, outputPerMillion: 75 },
416
514
  "claude-opus-4": { inputPerMillion: 15, cacheCreationInput5mPerMillion: 18.75, cacheCreationInput1hPerMillion: 30, cacheCreationInputPerMillion: 30, cachedInputPerMillion: 1.5, outputPerMillion: 75 },
417
- "claude-sonnet-5-5": { inputPerMillion: 2, cacheCreationInput5mPerMillion: 2.5, cacheCreationInput1hPerMillion: 4, cacheCreationInputPerMillion: 4, cachedInputPerMillion: 0.2, outputPerMillion: 10 },
515
+ "claude-sonnet-5-5": { inputPerMillion: 2, cacheCreationInput5mPerMillion: 2.5, cacheCreationInput1hPerMillion: 4, cacheCreationInputPerMillion: 4, cachedInputPerMillion: 0.1, outputPerMillion: 10 },
418
516
  "claude-sonnet-5": { inputPerMillion: 2, cacheCreationInput5mPerMillion: 2.5, cacheCreationInput1hPerMillion: 4, cacheCreationInputPerMillion: 4, cachedInputPerMillion: 0.2, outputPerMillion: 10, note: "Anthropic made the $2 input / $10 output introductory pricing permanent on August 10, 2026." },
419
517
  "claude-sonnet-4-6": { inputPerMillion: 3, cacheCreationInput5mPerMillion: 3.75, cacheCreationInput1hPerMillion: 6, cacheCreationInputPerMillion: 6, cachedInputPerMillion: 0.3, outputPerMillion: 15 },
420
518
  "claude-sonnet-4-5": { inputPerMillion: 3, cacheCreationInput5mPerMillion: 3.75, cacheCreationInput1hPerMillion: 6, cacheCreationInputPerMillion: 6, cachedInputPerMillion: 0.3, outputPerMillion: 15 },
421
519
  "claude-sonnet-4": { inputPerMillion: 3, cacheCreationInput5mPerMillion: 3.75, cacheCreationInput1hPerMillion: 6, cacheCreationInputPerMillion: 6, cachedInputPerMillion: 0.3, outputPerMillion: 15 },
422
520
  "claude-haiku-4-5": { inputPerMillion: 1, cacheCreationInput5mPerMillion: 1.25, cacheCreationInput1hPerMillion: 2, cacheCreationInputPerMillion: 2, cachedInputPerMillion: 0.1, outputPerMillion: 5 },
521
+ "claude-haiku-5-5": { inputPerMillion: 0.1, cacheCreationInput5mPerMillion: 0.125, cacheCreationInput1hPerMillion: 0.2, cacheCreationInputPerMillion: 0.2, cachedInputPerMillion: 0.01, outputPerMillion: 0.5, note: "Prompts up to 100,000 input tokens per request, including cache reads and writes. Larger prompts use the separately editable claude-haiku-5-5-long-context card. Aggregate-only usage stays unpriced when request lengths are unknown." },
522
+ "claude-haiku-5-5-long-context": { inputPerMillion: 0.5, cacheCreationInput5mPerMillion: 0.625, cacheCreationInput1hPerMillion: 1, cacheCreationInputPerMillion: 1, cachedInputPerMillion: 0.05, outputPerMillion: 2.5, note: "RepoSpend pricing card, not a provider model ID. Applied to the whole Haiku 5.5 request when total prompt length exceeds 100,000 tokens." },
423
523
  "claude-3-5-haiku": { inputPerMillion: 0.8, cacheCreationInput5mPerMillion: 1, cacheCreationInput1hPerMillion: 1.6, cacheCreationInputPerMillion: 1.6, cachedInputPerMillion: 0.08, outputPerMillion: 4 }
424
524
  };
425
525
  var legacyBundledPricing = {
526
+ "claude-sonnet-5-5": { inputPerMillion: 2, cacheCreationInput5mPerMillion: 2.5, cacheCreationInput1hPerMillion: 4, cacheCreationInputPerMillion: 4, cachedInputPerMillion: 0.2, outputPerMillion: 10 },
426
527
  "gpt-5.6": { inputPerMillion: 5, cachedInputPerMillion: 0.5, cacheCreationInputPerMillion: 6.25, outputPerMillion: 30, reasoningOutputPerMillion: 30, note: "GPT-5.6 Sol flagship tier. OpenAI preview pricing lists Sol at $5 input / $30 output per 1M tokens, cache writes at 1.25x input, and cache reads at a 90% discount." },
427
528
  "gpt-5.6-sol": { inputPerMillion: 5, cachedInputPerMillion: 0.5, cacheCreationInputPerMillion: 6.25, outputPerMillion: 30, reasoningOutputPerMillion: 30 },
428
529
  "gpt-5.6-terra": { inputPerMillion: 2.5, cachedInputPerMillion: 0.25, cacheCreationInputPerMillion: 3.125, outputPerMillion: 15, reasoningOutputPerMillion: 15 },
@@ -529,17 +630,94 @@ function savePricingTable(pricingPath, pricing) {
529
630
  function repospendHome() {
530
631
  return process.env.REPOSPEND_HOME || path.join(os.homedir(), ".repospend");
531
632
  }
532
- function calculateCostUsd(usage, pricing) {
633
+ function calculateCostUsd(usage, pricing, requestInputTokens) {
634
+ const cost = unroundedCostUsd(usage, pricing, requestInputTokens);
635
+ return cost === void 0 ? void 0 : Number((cost + Number.EPSILON).toFixed(6));
636
+ }
637
+ function calculateRequestCosts(requests, pricing) {
638
+ const resolutions = /* @__PURE__ */ new Map();
639
+ const warnings = /* @__PURE__ */ new Set();
640
+ const assumptions = /* @__PURE__ */ new Set();
641
+ let total = 0;
642
+ const requestCosts = requests.map((request) => {
643
+ let resolution = request.model ? resolutions.get(request.model) : void 0;
644
+ if (request.model && !resolution) {
645
+ resolution = resolvePricingForModel(request.model, pricing);
646
+ resolutions.set(request.model, resolution);
647
+ }
648
+ const context = requestContextPricing(request, pricing, resolution);
649
+ if (context.assumption) assumptions.add(context.assumption);
650
+ const cost = context.pricing === void 0 ? void 0 : costFromModelPricing(request, context.pricing);
651
+ if (cost !== void 0) total += cost;
652
+ else if (request.model && resolution) {
653
+ warnings.add(context.unknownContext ? "unknown_request_context" : `unknown_pricing_model:${normalizePricingModelId(request.model)}`);
654
+ } else warnings.add("unknown_pricing");
655
+ return cost;
656
+ });
657
+ return {
658
+ costUsd: requests.length && !warnings.size ? Number((total + Number.EPSILON).toFixed(6)) : void 0,
659
+ requestCosts,
660
+ warnings: [...warnings],
661
+ assumptions: [...assumptions]
662
+ };
663
+ }
664
+ var REQUEST_CONTEXT_RULES = [
665
+ { baseModel: "claude-haiku-5-5", thresholdInputTokens: 1e5, longContextModel: "claude-haiku-5-5-long-context", unknownRequestSize: "unpriced", missingLongContextCard: "unpriced", inheritedModelPattern: /^claude-haiku-5-5(?:$|[-.@[])/ },
666
+ { baseModel: "gpt-6-astra", thresholdInputTokens: 272e3, longContextModel: "gpt-6-astra-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
667
+ { baseModel: "gpt-6-sol", thresholdInputTokens: 272e3, longContextModel: "gpt-6-sol-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
668
+ { baseModel: "gpt-6-luna", thresholdInputTokens: 272e3, longContextModel: "gpt-6-luna-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
669
+ { baseModel: "gpt-6.1-sol", thresholdInputTokens: 272e3, longContextModel: "gpt-6.1-sol-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
670
+ { baseModel: "gpt-6.1-terra", thresholdInputTokens: 272e3, longContextModel: "gpt-6.1-terra-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
671
+ // GPT-5.x Standard cards carry the same >272K tiers; mini/nano have no published tier.
672
+ { baseModel: "gpt-5.6", thresholdInputTokens: 272e3, longContextModel: "gpt-5.6-sol-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
673
+ { baseModel: "gpt-5.6-sol", thresholdInputTokens: 272e3, longContextModel: "gpt-5.6-sol-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
674
+ { baseModel: "gpt-5.6-terra", thresholdInputTokens: 272e3, longContextModel: "gpt-5.6-terra-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
675
+ { baseModel: "gpt-5.6-luna", thresholdInputTokens: 272e3, longContextModel: "gpt-5.6-luna-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
676
+ { baseModel: "gpt-5.5", thresholdInputTokens: 272e3, longContextModel: "gpt-5.5-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
677
+ { baseModel: "gpt-5.5-pro", thresholdInputTokens: 272e3, longContextModel: "gpt-5.5-pro-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
678
+ { baseModel: "gpt-5.4", thresholdInputTokens: 272e3, longContextModel: "gpt-5.4-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true },
679
+ { baseModel: "gpt-5.4-pro", thresholdInputTokens: 272e3, longContextModel: "gpt-5.4-pro-long-context", unknownRequestSize: "short-context", missingLongContextCard: "base", canonicalFlatOverride: true }
680
+ ];
681
+ function pricingContextRules() {
682
+ return REQUEST_CONTEXT_RULES.map(({ baseModel, longContextModel, thresholdInputTokens }) => ({ baseModel, longContextModel, thresholdInputTokens }));
683
+ }
684
+ function requestContextPricing(request, pricing, resolution) {
685
+ if (!request.model || !resolution) return { pricing: void 0, unknownContext: false };
686
+ const normalizedModel = normalizePricingModelId(request.model);
687
+ const rule = REQUEST_CONTEXT_RULES.find((candidate) => candidate.baseModel === resolution.sourceModel || resolution.inherited && candidate.inheritedModelPattern?.test(normalizedModel));
688
+ if (!rule) return { pricing: resolution.pricing, unknownContext: false };
689
+ const baseRow = pricing[rule.baseModel];
690
+ const basePricing = resolution.sourceModel === rule.baseModel ? resolution.pricing : isUsableModelPricing(baseRow) ? baseRow : void 0;
691
+ const requestInputTokens = request.requestInputTokens;
692
+ if (requestInputTokens === void 0 || !Number.isFinite(requestInputTokens) || requestInputTokens < 0) {
693
+ return rule.unknownRequestSize === "unpriced" ? { pricing: void 0, unknownContext: true } : { pricing: basePricing, unknownContext: false, assumption: `assumed_short_context_rates:${rule.baseModel}` };
694
+ }
695
+ if (requestInputTokens <= rule.thresholdInputTokens) return { pricing: basePricing, unknownContext: false };
696
+ const bundledBase = defaultPricing[rule.baseModel];
697
+ if (rule.canonicalFlatOverride && resolution.sourceModel === rule.baseModel && bundledBase && basePricing && !pricingEntriesEqual(basePricing, bundledBase) && pricingEntriesEqual(pricing[rule.longContextModel], defaultPricing[rule.longContextModel])) {
698
+ return { pricing: basePricing, unknownContext: false };
699
+ }
700
+ const longContext = resolvePricingForModel(rule.longContextModel, pricing);
701
+ if (isUsableModelPricing(longContext.pricing)) return { pricing: longContext.pricing, unknownContext: false };
702
+ return rule.missingLongContextCard === "unpriced" ? { pricing: void 0, unknownContext: false } : { pricing: basePricing, unknownContext: false, assumption: `missing_long_context_pricing:${rule.baseModel}` };
703
+ }
704
+ function unroundedCostUsd(usage, pricing, requestInputTokens) {
533
705
  if (!usage.model) {
534
706
  return void 0;
535
707
  }
536
- const modelPricing = findModelPricing(usage.model, pricing);
537
- if (!modelPricing) {
708
+ const resolution = resolvePricingForModel(usage.model, pricing);
709
+ const modelPricing = requestContextPricing({ ...usage, requestInputTokens }, pricing, resolution).pricing;
710
+ return costFromModelPricing(usage, modelPricing);
711
+ }
712
+ function costFromModelPricing(usage, modelPricing) {
713
+ if (!usage.model || !isUsableModelPricing(modelPricing)) {
538
714
  return void 0;
539
715
  }
540
716
  const cacheCreationInput5m = usage.cacheCreationInputTokens5m ?? 0;
541
717
  const cacheCreationInput1h = usage.cacheCreationInputTokens1h ?? 0;
542
- const splitCacheCreationInput = cacheCreationInput5m + cacheCreationInput1h;
718
+ const cacheCreationInput30m = usage.cacheCreationInputTokens30m ?? 0;
719
+ const cacheCreationInput12h = usage.cacheCreationInputTokens12h ?? 0;
720
+ const splitCacheCreationInput = cacheCreationInput5m + cacheCreationInput1h + cacheCreationInput30m + cacheCreationInput12h;
543
721
  const cacheCreationInput = usage.cacheCreationInputTokens ?? splitCacheCreationInput;
544
722
  const unclassifiedCacheCreationInput = Math.max(cacheCreationInput - splitCacheCreationInput, 0);
545
723
  const billableInput = Math.max(usage.inputTokens - usage.cachedInputTokens - cacheCreationInput, 0);
@@ -547,16 +725,18 @@ function calculateCostUsd(usage, pricing) {
547
725
  const cacheCreationRate = firstPositiveRate(modelPricing.cacheCreationInputPerMillion, modelPricing.cacheCreationInput1hPerMillion, modelPricing.cacheCreationInput5mPerMillion, modelPricing.inputPerMillion);
548
726
  const cacheCreation5mRate = firstPositiveRate(modelPricing.cacheCreationInput5mPerMillion, modelPricing.cacheCreationInputPerMillion, modelPricing.inputPerMillion);
549
727
  const cacheCreation1hRate = firstPositiveRate(modelPricing.cacheCreationInput1hPerMillion, modelPricing.cacheCreationInputPerMillion, modelPricing.inputPerMillion);
728
+ const cacheCreation30mRate = firstPositiveRate(modelPricing.cacheCreationInput30mPerMillion, modelPricing.cacheCreationInputPerMillion, modelPricing.inputPerMillion);
729
+ const cacheCreation12hRate = firstPositiveRate(modelPricing.cacheCreationInput12hPerMillion, modelPricing.cacheCreationInputPerMillion, modelPricing.inputPerMillion);
550
730
  const reasoningRate = modelPricing.reasoningOutputPerMillion ?? modelPricing.outputPerMillion;
551
- const cost = billableInput / 1e6 * modelPricing.inputPerMillion + usage.cachedInputTokens / 1e6 * cachedRate + cacheCreationInput5m / 1e6 * cacheCreation5mRate + cacheCreationInput1h / 1e6 * cacheCreation1hRate + unclassifiedCacheCreationInput / 1e6 * cacheCreationRate + usage.outputTokens / 1e6 * modelPricing.outputPerMillion + usage.reasoningTokens / 1e6 * reasoningRate;
552
- return Number(cost.toFixed(6));
731
+ const cost = billableInput / 1e6 * modelPricing.inputPerMillion + usage.cachedInputTokens / 1e6 * cachedRate + cacheCreationInput5m / 1e6 * cacheCreation5mRate + cacheCreationInput1h / 1e6 * cacheCreation1hRate + cacheCreationInput30m / 1e6 * cacheCreation30mRate + cacheCreationInput12h / 1e6 * cacheCreation12hRate + unclassifiedCacheCreationInput / 1e6 * cacheCreationRate + usage.outputTokens / 1e6 * modelPricing.outputPerMillion + usage.reasoningTokens / 1e6 * reasoningRate;
732
+ return cost;
553
733
  }
554
734
  function firstPositiveRate(...rates) {
555
735
  return rates.find((rate) => typeof rate === "number" && Number.isFinite(rate) && rate > 0) ?? 0;
556
736
  }
557
737
 
558
738
  // packages/core/src/cache.ts
559
- var activeCacheVersion = "parse-v1";
739
+ var activeCacheVersion = "parse-v2";
560
740
  var preparedCacheRoot;
561
741
  function parseCacheRoot() {
562
742
  return path2.join(repospendHome(), "cache", activeCacheVersion);
@@ -820,7 +1000,7 @@ function filterUsage(sessions, filters) {
820
1000
  if (!matchesAny(session.sourceClient, filters.source)) return false;
821
1001
  if (!matchesAny(session.sourceApp, filters.sourceApp)) return false;
822
1002
  if (!matchesRepo(session, filters.repo)) return false;
823
- if (!matchesModel(session.model, filters.model)) return false;
1003
+ if (!matchesModel(session, filters.model)) return false;
824
1004
  const startedAt = timestamp(session.startedAt);
825
1005
  const hasDateFilter = Boolean(filters.from || filters.to);
826
1006
  if (hasDateFilter && startedAt === void 0) return false;
@@ -829,7 +1009,38 @@ function filterUsage(sessions, filters) {
829
1009
  if (from !== void 0 && startedAt !== void 0 && startedAt < from) return false;
830
1010
  if (to !== void 0 && startedAt !== void 0 && startedAt > to) return false;
831
1011
  return true;
832
- });
1012
+ }).map((session) => projectModelFilter(session, filters.model));
1013
+ }
1014
+ function projectModelFilter(session, filter) {
1015
+ const values = filterValues(filter);
1016
+ if (!values.length || !session.modelUsage?.length) return session;
1017
+ const slices = session.modelUsage.filter((entry) => modelValueMatches(entry.model, values));
1018
+ const reasoningTokens = sumSlices(slices, "reasoningTokens");
1019
+ return {
1020
+ ...session,
1021
+ // The representative model must belong to the selected usage: keep the original
1022
+ // model when it is selected, otherwise use the first matching slice's model.
1023
+ model: session.model !== void 0 && slices.some((entry) => entry.model === session.model) ? session.model : slices[0]?.model,
1024
+ modelUsage: slices,
1025
+ inputTokens: sumSlices(slices, "inputTokens"),
1026
+ cachedInputTokens: sumSlices(slices, "cachedInputTokens"),
1027
+ cacheCreationInputTokens: sumSlices(slices, "cacheCreationInputTokens"),
1028
+ cacheCreationInputTokens5m: sumSlices(slices, "cacheCreationInputTokens5m"),
1029
+ cacheCreationInputTokens1h: sumSlices(slices, "cacheCreationInputTokens1h"),
1030
+ cacheCreationInputTokens30m: sumSlices(slices, "cacheCreationInputTokens30m"),
1031
+ cacheCreationInputTokens12h: sumSlices(slices, "cacheCreationInputTokens12h"),
1032
+ outputTokens: sumSlices(slices, "outputTokens"),
1033
+ reasoningTokens,
1034
+ reasoningOutputTokens: reasoningTokens,
1035
+ totalTokens: sumSlices(slices, "totalTokens"),
1036
+ estimatedCostUsd: slices.every((entry) => entry.estimatedCostUsd !== void 0) ? slices.reduce((total, entry) => total + (entry.estimatedCostUsd ?? 0), 0) : void 0
1037
+ };
1038
+ }
1039
+ function modelValueMatches(model, values) {
1040
+ return values.includes(model ?? "unknown-model");
1041
+ }
1042
+ function sumSlices(slices, key) {
1043
+ return slices.reduce((total, entry) => total + (entry[key] ?? 0), 0);
833
1044
  }
834
1045
  function matchesAny(value, filter) {
835
1046
  const values = filterValues(filter);
@@ -841,10 +1052,11 @@ function matchesRepo(session, filter) {
841
1052
  if (!values.length) return true;
842
1053
  return values.includes(session.repoName) || values.includes(session.repoRoot);
843
1054
  }
844
- function matchesModel(value, filter) {
1055
+ function matchesModel(session, filter) {
845
1056
  const values = filterValues(filter);
846
1057
  if (!values.length) return true;
847
- return value !== void 0 ? values.includes(value) : values.includes("unknown-model");
1058
+ const models = session.modelUsage?.length ? session.modelUsage.map((entry) => entry.model) : [session.model];
1059
+ return models.some((model) => model !== void 0 ? values.includes(model) : values.includes("unknown-model"));
848
1060
  }
849
1061
  function filterValues(filter) {
850
1062
  if (!filter) return [];
@@ -1841,28 +2053,35 @@ function dateValue(value) {
1841
2053
  }
1842
2054
 
1843
2055
  // packages/core/src/sources/codex-token.ts
1844
- function aggregateTokens(records) {
2056
+ function aggregateTokens(records, modelForRecord) {
1845
2057
  const accumulator = emptyTokenAccumulator();
1846
2058
  for (const record of records) {
1847
- collectRecordTokens(accumulator, record);
2059
+ collectRecordTokens(accumulator, record, modelForRecord?.(record));
1848
2060
  }
1849
2061
  finalizeTokenAccumulator(accumulator);
1850
2062
  return {
1851
2063
  inputTokens: accumulator.inputTokens,
1852
2064
  cachedInputTokens: accumulator.cachedInputTokens,
2065
+ cacheCreationInputTokens: accumulator.cacheCreationInputTokens || void 0,
2066
+ cacheCreationInputTokens30m: accumulator.cacheCreationInputTokens30m || void 0,
2067
+ cacheCreationInputTokens12h: accumulator.cacheCreationInputTokens12h || void 0,
1853
2068
  outputTokens: accumulator.outputTokens,
1854
2069
  reasoningTokens: accumulator.reasoningTokens,
1855
2070
  totalTokens: accumulator.totalTokens,
1856
2071
  tokenAggregationMethod: accumulator.tokenAggregationMethod,
1857
2072
  tokenConfidence: accumulator.tokenConfidence,
1858
2073
  tokenSnapshotCount: accumulator.tokenSnapshotCount,
1859
- warnings: accumulator.warnings
2074
+ warnings: accumulator.warnings,
2075
+ requestUsages: accumulator.requestUsages
1860
2076
  };
1861
2077
  }
1862
2078
  function emptyTokenAccumulator() {
1863
2079
  return {
1864
2080
  inputTokens: 0,
1865
2081
  cachedInputTokens: 0,
2082
+ cacheCreationInputTokens: 0,
2083
+ cacheCreationInputTokens30m: 0,
2084
+ cacheCreationInputTokens12h: 0,
1866
2085
  outputTokens: 0,
1867
2086
  reasoningTokens: 0,
1868
2087
  totalTokens: 0,
@@ -1871,12 +2090,14 @@ function emptyTokenAccumulator() {
1871
2090
  tokenSnapshotCount: 0,
1872
2091
  warnings: [],
1873
2092
  cumulativeTokenSnapshots: [],
1874
- directTokenUsages: []
2093
+ directTokenUsages: [],
2094
+ requestUsages: []
1875
2095
  };
1876
2096
  }
1877
- function collectRecordTokens(accumulator, record) {
2097
+ function collectRecordTokens(accumulator, record, model) {
1878
2098
  const usage = extractRecordTokens(record);
1879
2099
  if (!usage) return;
2100
+ usage.model = model;
1880
2101
  accumulator.tokenSnapshotCount += 1;
1881
2102
  if (usage.cumulative) {
1882
2103
  accumulator.cumulativeTokenSnapshots.push(usage);
@@ -1893,6 +2114,7 @@ function finalizeTokenAccumulator(accumulator) {
1893
2114
  applyFinalUsage(accumulator, finalSnapshot);
1894
2115
  accumulator.tokenAggregationMethod = "final_snapshot";
1895
2116
  accumulator.tokenConfidence = "high";
2117
+ accumulator.requestUsages = [{ ...requestUsageFrom(finalSnapshot, void 0), model: void 0 }];
1896
2118
  if (accumulator.directTokenUsages.length > 0) accumulator.warnings.push("token_direct_usage_ignored_after_cumulative_snapshot");
1897
2119
  return;
1898
2120
  }
@@ -1903,15 +2125,19 @@ function finalizeTokenAccumulator(accumulator) {
1903
2125
  (sum2, usage) => ({
1904
2126
  inputTokens: sum2.inputTokens + usage.inputTokens,
1905
2127
  cachedInputTokens: sum2.cachedInputTokens + usage.cachedInputTokens,
2128
+ cacheCreationInputTokens: sum2.cacheCreationInputTokens + usage.cacheCreationInputTokens,
2129
+ cacheCreationInputTokens30m: sum2.cacheCreationInputTokens30m + usage.cacheCreationInputTokens30m,
2130
+ cacheCreationInputTokens12h: sum2.cacheCreationInputTokens12h + usage.cacheCreationInputTokens12h,
1906
2131
  outputTokens: sum2.outputTokens + usage.outputTokens,
1907
2132
  reasoningTokens: sum2.reasoningTokens + usage.reasoningTokens,
1908
2133
  totalTokens: sum2.totalTokens + usage.totalTokens
1909
2134
  }),
1910
- { inputTokens: 0, cachedInputTokens: 0, outputTokens: 0, reasoningTokens: 0, totalTokens: 0 }
2135
+ { inputTokens: 0, cachedInputTokens: 0, cacheCreationInputTokens: 0, cacheCreationInputTokens30m: 0, cacheCreationInputTokens12h: 0, outputTokens: 0, reasoningTokens: 0, totalTokens: 0 }
1911
2136
  );
1912
2137
  applyFinalUsage(accumulator, total);
1913
2138
  accumulator.tokenAggregationMethod = "delta_sum";
1914
2139
  accumulator.tokenConfidence = "high";
2140
+ accumulator.requestUsages = filteredDirect.map((usage) => requestUsageFrom(usage, usage.inputTokens));
1915
2141
  const skipped = direct.length - filteredDirect.length;
1916
2142
  if (skipped > 0) accumulator.warnings.push("duplicate_or_stale_token_snapshots_skipped");
1917
2143
  return;
@@ -1919,6 +2145,20 @@ function finalizeTokenAccumulator(accumulator) {
1919
2145
  accumulator.tokenAggregationMethod = "unknown";
1920
2146
  accumulator.tokenConfidence = "low";
1921
2147
  }
2148
+ function requestUsageFrom(usage, requestInputTokens) {
2149
+ return {
2150
+ model: "model" in usage ? usage.model : void 0,
2151
+ requestInputTokens,
2152
+ inputTokens: usage.inputTokens,
2153
+ cachedInputTokens: usage.cachedInputTokens,
2154
+ cacheCreationInputTokens: usage.cacheCreationInputTokens,
2155
+ cacheCreationInputTokens30m: usage.cacheCreationInputTokens30m,
2156
+ cacheCreationInputTokens12h: usage.cacheCreationInputTokens12h,
2157
+ outputTokens: usage.outputTokens,
2158
+ reasoningTokens: usage.reasoningTokens,
2159
+ totalTokens: usage.totalTokens
2160
+ };
2161
+ }
1922
2162
  function extractRecordTokens(record) {
1923
2163
  if (!record || typeof record !== "object") return void 0;
1924
2164
  const object = record;
@@ -1954,10 +2194,10 @@ function filterDuplicateDirectUsages(usages) {
1954
2194
  return filtered;
1955
2195
  }
1956
2196
  function sameTokenUsage(a, b) {
1957
- return a.inputTokens === b.inputTokens && a.cachedInputTokens === b.cachedInputTokens && a.outputTokens === b.outputTokens && a.reasoningTokens === b.reasoningTokens && a.totalTokens === b.totalTokens;
2197
+ return a.inputTokens === b.inputTokens && a.cachedInputTokens === b.cachedInputTokens && a.cacheCreationInputTokens === b.cacheCreationInputTokens && a.cacheCreationInputTokens30m === b.cacheCreationInputTokens30m && a.cacheCreationInputTokens12h === b.cacheCreationInputTokens12h && a.outputTokens === b.outputTokens && a.reasoningTokens === b.reasoningTokens && a.totalTokens === b.totalTokens;
1958
2198
  }
1959
2199
  function isMonotonicFrom(current, previous) {
1960
- return current.inputTokens >= previous.inputTokens && current.cachedInputTokens >= previous.cachedInputTokens && current.outputTokens >= previous.outputTokens && current.reasoningTokens >= previous.reasoningTokens;
2200
+ return current.inputTokens >= previous.inputTokens && current.cachedInputTokens >= previous.cachedInputTokens && current.cacheCreationInputTokens >= previous.cacheCreationInputTokens && current.outputTokens >= previous.outputTokens && current.reasoningTokens >= previous.reasoningTokens;
1961
2201
  }
1962
2202
  function looksLikeStaleRegression(current, previous, last) {
1963
2203
  const previousTotal = tokenBucketTotal(previous);
@@ -1973,22 +2213,34 @@ function stripSnapshot(usage) {
1973
2213
  return {
1974
2214
  inputTokens: usage.inputTokens,
1975
2215
  cachedInputTokens: usage.cachedInputTokens,
2216
+ cacheCreationInputTokens: usage.cacheCreationInputTokens,
2217
+ cacheCreationInputTokens30m: usage.cacheCreationInputTokens30m,
2218
+ cacheCreationInputTokens12h: usage.cacheCreationInputTokens12h,
1976
2219
  outputTokens: usage.outputTokens,
1977
2220
  reasoningTokens: usage.reasoningTokens,
1978
2221
  totalTokens: usage.totalTokens
1979
2222
  };
1980
2223
  }
1981
2224
  function tokenUsageFromObject(target, cumulative) {
2225
+ const inputDetails = firstObject2(target.input_tokens_details, target.inputTokensDetails, target.prompt_tokens_details, target.promptTokensDetails);
2226
+ const ttlDetails = firstObject2(target.cache_write_tokens_details, target.cacheWriteTokensDetails, inputDetails?.cache_write_tokens_details, inputDetails?.cacheWriteTokensDetails);
1982
2227
  const input = numberFromKeys(target, ["input_tokens", "inputTokens", "prompt_tokens", "promptTokens"]);
1983
- const cached = numberFromKeys(target, ["cached_input_tokens", "cachedInputTokens", "cached_tokens", "cachedTokens", "cache_read_input_tokens"]);
2228
+ const cached = numberFromKeys(target, ["cached_input_tokens", "cachedInputTokens", "cached_tokens", "cachedTokens", "cache_read_input_tokens"]) || (inputDetails ? numberFromKeys(inputDetails, ["cached_tokens", "cachedTokens"]) : 0);
1984
2229
  const outputWithReasoning = numberFromKeys(target, ["output_tokens", "outputTokens", "completion_tokens", "completionTokens"]);
1985
- const reasoning = numberFromKeys(target, ["reasoning_tokens", "reasoningTokens", "reasoning_output_tokens", "reasoningOutputTokens"]);
2230
+ const reasoning = numberFromKeys(target, ["reasoning_tokens", "reasoningTokens", "reasoning_output_tokens", "reasoningOutputTokens"]) || (firstObject2(target.output_tokens_details, target.outputTokensDetails) ? numberFromKeys(firstObject2(target.output_tokens_details, target.outputTokensDetails), ["reasoning_tokens", "reasoningTokens"]) : 0);
1986
2231
  const output = Math.max(outputWithReasoning - reasoning, 0);
1987
2232
  const total = numberFromKeys(target, ["total_tokens", "totalTokens", "tokens_used", "tokensUsed"]);
1988
- if (input + cached + output + reasoning + total === 0) return void 0;
2233
+ const cacheWrite30m = ttlDetails ? numberFromKeys(ttlDetails, ["ttl_30m_tokens", "ttl30mTokens", "ttl_30m"]) : 0;
2234
+ const cacheWrite12h = ttlDetails ? numberFromKeys(ttlDetails, ["ttl_12h_tokens", "ttl12hTokens", "ttl_12h"]) : 0;
2235
+ const cacheWriteDeclared = numberFromKeys(target, ["cache_creation_input_tokens", "cacheCreationInputTokens", "cache_write_input_tokens", "cacheWriteInputTokens", "cache_write_tokens", "cacheWriteTokens"]) || (inputDetails ? numberFromKeys(inputDetails, ["cache_write_tokens", "cacheWriteTokens", "cache_creation_input_tokens", "cacheCreationInputTokens"]) : 0);
2236
+ const cacheCreation = Math.max(cacheWriteDeclared, cacheWrite30m + cacheWrite12h);
2237
+ if (input + cached + output + reasoning + total + cacheCreation === 0) return void 0;
1989
2238
  return {
1990
2239
  inputTokens: input,
1991
2240
  cachedInputTokens: cached,
2241
+ cacheCreationInputTokens: cacheCreation,
2242
+ cacheCreationInputTokens30m: cacheWrite30m,
2243
+ cacheCreationInputTokens12h: cacheWrite12h,
1992
2244
  outputTokens: output,
1993
2245
  reasoningTokens: reasoning,
1994
2246
  totalTokens: total || input + output + reasoning,
@@ -1998,6 +2250,9 @@ function tokenUsageFromObject(target, cumulative) {
1998
2250
  function applyFinalUsage(accumulator, usage) {
1999
2251
  accumulator.inputTokens = usage.inputTokens;
2000
2252
  accumulator.cachedInputTokens = usage.cachedInputTokens;
2253
+ accumulator.cacheCreationInputTokens = usage.cacheCreationInputTokens;
2254
+ accumulator.cacheCreationInputTokens30m = usage.cacheCreationInputTokens30m;
2255
+ accumulator.cacheCreationInputTokens12h = usage.cacheCreationInputTokens12h;
2001
2256
  accumulator.outputTokens = usage.outputTokens;
2002
2257
  accumulator.reasoningTokens = usage.reasoningTokens;
2003
2258
  accumulator.totalTokens = usage.totalTokens || usage.inputTokens + usage.outputTokens + usage.reasoningTokens;
@@ -2018,7 +2273,7 @@ function numberFromKeys(object, keys) {
2018
2273
  }
2019
2274
 
2020
2275
  // packages/core/src/sources/codex.ts
2021
- var codexSessionCacheVersion = "codex-session-v1";
2276
+ var codexSessionCacheVersion = "codex-session-v2";
2022
2277
  var nativeSqliteRebuildAttempted = false;
2023
2278
  function scanCodex(options) {
2024
2279
  const codexHome = options.codexHome ?? path5.join(os3.homedir(), ".codex");
@@ -2249,6 +2504,9 @@ function threadToUsage(row, index, sessionFiles, options, importedModels = /* @_
2249
2504
  provider,
2250
2505
  inputTokens,
2251
2506
  cachedInputTokens,
2507
+ cacheCreationInputTokens: sessionBreakdown.cacheCreationInputTokens,
2508
+ cacheCreationInputTokens30m: sessionBreakdown.cacheCreationInputTokens30m,
2509
+ cacheCreationInputTokens12h: sessionBreakdown.cacheCreationInputTokens12h,
2252
2510
  outputTokens,
2253
2511
  reasoningTokens,
2254
2512
  reasoningOutputTokens: reasoningTokens,
@@ -2288,12 +2546,14 @@ function threadToUsage(row, index, sessionFiles, options, importedModels = /* @_
2288
2546
  sessionOutcome: inferOutcome(sessionBreakdown),
2289
2547
  compaction: sessionBreakdown.compaction
2290
2548
  };
2291
- const cost = hasPricedBreakdown ? calculateCostUsd(usage, options.pricing) : void 0;
2292
- const costWarnings = hasPricedBreakdown ? warnings : [...warnings, "missing_token_breakdown"];
2549
+ const estimate = hasPricedBreakdown ? sessionEstimate(sessionBreakdown.requestUsages, model, options.pricing) : void 0;
2550
+ const cost = estimate?.result.costUsd;
2551
+ const costWarnings = [...warnings, ...estimate?.result.assumptions ?? []];
2293
2552
  return {
2294
2553
  ...usage,
2295
2554
  estimatedCostUsd: cost,
2296
- warnings: cost === void 0 ? [...costWarnings, "unknown_pricing"] : warnings
2555
+ modelUsage: estimate?.modelUsage,
2556
+ warnings: cost === void 0 ? [.../* @__PURE__ */ new Set([...hasPricedBreakdown ? costWarnings : [...costWarnings, "missing_token_breakdown"], "unknown_pricing", ...estimate?.result.warnings ?? []])] : [...new Set(costWarnings)]
2297
2557
  };
2298
2558
  }
2299
2559
  function readStandaloneSessions(sessionFiles, options) {
@@ -2323,6 +2583,9 @@ function readStandaloneSessions(sessionFiles, options) {
2323
2583
  provider,
2324
2584
  inputTokens: breakdown.inputTokens,
2325
2585
  cachedInputTokens: breakdown.cachedInputTokens,
2586
+ cacheCreationInputTokens: breakdown.cacheCreationInputTokens,
2587
+ cacheCreationInputTokens30m: breakdown.cacheCreationInputTokens30m,
2588
+ cacheCreationInputTokens12h: breakdown.cacheCreationInputTokens12h,
2326
2589
  outputTokens: breakdown.outputTokens,
2327
2590
  reasoningTokens: breakdown.reasoningTokens,
2328
2591
  reasoningOutputTokens: breakdown.reasoningTokens,
@@ -2363,14 +2626,53 @@ function readStandaloneSessions(sessionFiles, options) {
2363
2626
  compaction: breakdown.compaction
2364
2627
  };
2365
2628
  const hasPricedBreakdown = breakdown.inputTokens + breakdown.cachedInputTokens + breakdown.outputTokens + breakdown.reasoningTokens > 0;
2366
- const cost = hasPricedBreakdown ? calculateCostUsd(usage, options.pricing) : void 0;
2629
+ const estimate = hasPricedBreakdown ? sessionEstimate(breakdown.requestUsages, model, options.pricing) : void 0;
2630
+ const cost = estimate?.result.costUsd;
2367
2631
  return {
2368
2632
  ...usage,
2369
2633
  estimatedCostUsd: cost,
2370
- warnings: cost === void 0 ? [...usage.warnings, hasPricedBreakdown ? "unknown_pricing" : "missing_token_breakdown"] : usage.warnings
2634
+ modelUsage: estimate?.modelUsage,
2635
+ warnings: cost === void 0 ? [.../* @__PURE__ */ new Set([...usage.warnings, hasPricedBreakdown ? "unknown_pricing" : "missing_token_breakdown", ...estimate?.result.warnings ?? [], ...estimate?.result.assumptions ?? []])] : [.../* @__PURE__ */ new Set([...usage.warnings, ...estimate?.result.assumptions ?? []])]
2371
2636
  };
2372
2637
  });
2373
2638
  }
2639
+ function sessionEstimate(requestUsages, fallbackModel, pricing) {
2640
+ const requests = requestUsages.map((request) => ({ ...request, model: request.model ?? fallbackModel }));
2641
+ const result = calculateRequestCosts(requests, pricing);
2642
+ return { result, modelUsage: buildSessionModelUsage(requests, result.requestCosts) };
2643
+ }
2644
+ function buildSessionModelUsage(requests, requestCosts) {
2645
+ if (!requests.length) return void 0;
2646
+ const groups = /* @__PURE__ */ new Map();
2647
+ requests.forEach((request, index) => {
2648
+ const entry = groups.get(request.model) ?? {
2649
+ model: request.model,
2650
+ requestCount: 0,
2651
+ inputTokens: 0,
2652
+ cachedInputTokens: 0,
2653
+ cacheCreationInputTokens: 0,
2654
+ cacheCreationInputTokens30m: 0,
2655
+ cacheCreationInputTokens12h: 0,
2656
+ outputTokens: 0,
2657
+ reasoningTokens: 0,
2658
+ totalTokens: 0,
2659
+ estimatedCostUsd: 0
2660
+ };
2661
+ entry.requestCount += 1;
2662
+ entry.inputTokens += request.inputTokens;
2663
+ entry.cachedInputTokens += request.cachedInputTokens;
2664
+ entry.cacheCreationInputTokens += request.cacheCreationInputTokens;
2665
+ entry.cacheCreationInputTokens30m = (entry.cacheCreationInputTokens30m ?? 0) + request.cacheCreationInputTokens30m;
2666
+ entry.cacheCreationInputTokens12h = (entry.cacheCreationInputTokens12h ?? 0) + request.cacheCreationInputTokens12h;
2667
+ entry.outputTokens += request.outputTokens;
2668
+ entry.reasoningTokens += request.reasoningTokens;
2669
+ entry.totalTokens += request.totalTokens;
2670
+ const requestCost = requestCosts[index];
2671
+ entry.estimatedCostUsd = requestCost === void 0 || entry.estimatedCostUsd === void 0 ? void 0 : Number((entry.estimatedCostUsd + requestCost).toFixed(6));
2672
+ groups.set(request.model, entry);
2673
+ });
2674
+ return [...groups.values()];
2675
+ }
2374
2676
  function hasImportedSession(sessions, candidate) {
2375
2677
  const candidatePath = comparableSourcePath(candidate.sourcePath);
2376
2678
  return sessions.some((session) => {
@@ -2515,7 +2817,8 @@ function readSessionBreakdown(filePath) {
2515
2817
  applyCompactionEvent(breakdown, record, lastUserMessageText);
2516
2818
  }
2517
2819
  breakdown.messageCount = eventMessageCount || responseMessageCount;
2518
- const tokenAggregation = aggregateTokens(records);
2820
+ const modelByRecord = recordModels(records);
2821
+ const tokenAggregation = aggregateTokens(records, (record) => modelByRecord.get(record));
2519
2822
  Object.assign(breakdown, {
2520
2823
  ...tokenAggregation,
2521
2824
  warnings: [...breakdown.warnings, ...tokenAggregation.warnings]
@@ -2530,6 +2833,22 @@ function readSessionBreakdown(filePath) {
2530
2833
  if (cacheKey) writeJsonCache("codex-session", cacheKey, breakdown);
2531
2834
  return breakdown;
2532
2835
  }
2836
+ function recordModels(records) {
2837
+ const models = /* @__PURE__ */ new Map();
2838
+ let current;
2839
+ for (const record of records) {
2840
+ const declared = declaredRecordModel(record);
2841
+ if (declared) current = declared;
2842
+ models.set(record, current);
2843
+ }
2844
+ return models;
2845
+ }
2846
+ function declaredRecordModel(record) {
2847
+ const object = asRecord(record);
2848
+ const payload = firstObject3(object?.payload) ?? object;
2849
+ const collaborationSettings = firstObject3(firstObject3(payload?.collaboration_mode)?.settings);
2850
+ return stringValue2(payload?.model) ?? stringValue2(collaborationSettings?.model);
2851
+ }
2533
2852
  function sessionBreakdownCacheKey(filePath) {
2534
2853
  try {
2535
2854
  const stat = fs5.statSync(filePath);
@@ -2614,6 +2933,7 @@ function emptyBreakdown() {
2614
2933
  outputTokens: 0,
2615
2934
  reasoningTokens: 0,
2616
2935
  totalTokens: 0,
2936
+ requestUsages: [],
2617
2937
  tokenAggregationMethod: "unknown",
2618
2938
  tokenConfidence: "low",
2619
2939
  tokenSnapshotCount: 0,
@@ -3053,21 +3373,30 @@ function claudeBreakdownToUsage(file, index, options, breakdown, idSuffix = "")
3053
3373
  promptTimeline: breakdown.promptTimeline,
3054
3374
  sessionOutcome: inferOutcome2(breakdown)
3055
3375
  };
3056
- const costBuckets = /* @__PURE__ */ new Map();
3057
- for (const event of breakdown.usageEvents) {
3376
+ const requests = breakdown.usageEvents.map((event) => {
3058
3377
  const model = event.model ?? breakdown.model;
3059
3378
  const normalized = model ? normalizePricingModelId(model) : void 0;
3060
3379
  const pricingModel = normalized && normalizedServiceTier(event.usage.speed) === "fast" && !normalized.includes("fast-mode") && !/^claude-opus-4-6(?:$|-)/.test(normalized) ? `${normalized}-fast-mode` : model;
3061
- const totals = costBuckets.get(pricingModel) ?? emptyBreakdown2();
3380
+ const totals = emptyBreakdown2();
3062
3381
  applyUsage(totals, event.usage);
3063
- costBuckets.set(pricingModel, totals);
3064
- }
3065
- const costs = hasTokenBreakdown ? [...costBuckets].map(([model, totals]) => calculateCostUsd({ ...totals, model, reasoningTokens: 0 }, options.pricing)) : [];
3066
- const cost = costs.length && costs.every((value) => value !== void 0) ? Number(costs.reduce((sum2, value) => sum2 + (value ?? 0), 0).toFixed(6)) : void 0;
3382
+ return {
3383
+ model: pricingModel,
3384
+ inputTokens: totals.inputTokens,
3385
+ cachedInputTokens: totals.cachedInputTokens,
3386
+ cacheCreationInputTokens: totals.cacheCreationInputTokens,
3387
+ cacheCreationInputTokens5m: totals.cacheCreationInputTokens5m,
3388
+ cacheCreationInputTokens1h: totals.cacheCreationInputTokens1h,
3389
+ outputTokens: totals.outputTokens,
3390
+ reasoningTokens: 0,
3391
+ requestInputTokens: hasInputTokenCount(event.usage) ? totals.inputTokens : void 0
3392
+ };
3393
+ });
3394
+ const estimate = hasTokenBreakdown ? calculateRequestCosts(requests, options.pricing) : void 0;
3395
+ const cost = estimate?.costUsd;
3067
3396
  return {
3068
3397
  ...usage,
3069
3398
  estimatedCostUsd: cost,
3070
- warnings: cost === void 0 ? [...usage.warnings, "unknown_pricing", ...costs.some((value, index2) => value === void 0 && [...costBuckets.keys()][index2]?.includes("fast-mode")) ? ["unknown_fast_mode_pricing"] : []] : usage.warnings
3399
+ warnings: cost === void 0 ? [.../* @__PURE__ */ new Set([...usage.warnings, "unknown_pricing", ...estimate?.warnings ?? [], ...estimate?.assumptions ?? [], ...estimate?.warnings.some((warning) => warning.startsWith("unknown_pricing_model:") && warning.includes("fast-mode")) ? ["unknown_fast_mode_pricing"] : []])] : [.../* @__PURE__ */ new Set([...usage.warnings, ...estimate?.assumptions ?? []])]
3071
3400
  };
3072
3401
  }
3073
3402
  function inferClaudeEntrypointFromPath(filePath) {
@@ -3169,10 +3498,14 @@ function usageDedupKey(record, message) {
3169
3498
  function occurrenceKey(filePath, recordIndex) {
3170
3499
  return `${path6.resolve(filePath)}:${recordIndex}`;
3171
3500
  }
3501
+ function hasInputTokenCount(usage) {
3502
+ const value = usage.input_tokens;
3503
+ return (typeof value === "number" || typeof value === "string" && value.trim() !== "") && Number.isFinite(Number(value)) && Number(value) >= 0;
3504
+ }
3172
3505
  function cloneUsage(usage) {
3173
3506
  const cacheCreation = firstObject4(usage.cache_creation);
3174
3507
  return {
3175
- input_tokens: numberValue(usage.input_tokens),
3508
+ input_tokens: hasInputTokenCount(usage) ? numberValue(usage.input_tokens) : void 0,
3176
3509
  cache_read_input_tokens: numberValue(usage.cache_read_input_tokens),
3177
3510
  cache_creation_input_tokens: numberValue(usage.cache_creation_input_tokens),
3178
3511
  cache_creation: cacheCreation ? {
@@ -3187,7 +3520,7 @@ function cloneUsage(usage) {
3187
3520
  function mergeUsageMax(target, usage) {
3188
3521
  const targetCacheCreation = firstObject4(target.cache_creation) ?? {};
3189
3522
  const usageCacheCreation = firstObject4(usage.cache_creation) ?? {};
3190
- target.input_tokens = Math.max(numberValue(target.input_tokens), numberValue(usage.input_tokens));
3523
+ if (hasInputTokenCount(target) || hasInputTokenCount(usage)) target.input_tokens = Math.max(numberValue(target.input_tokens), numberValue(usage.input_tokens));
3191
3524
  target.cache_read_input_tokens = Math.max(numberValue(target.cache_read_input_tokens), numberValue(usage.cache_read_input_tokens));
3192
3525
  target.cache_creation_input_tokens = Math.max(numberValue(target.cache_creation_input_tokens), numberValue(usage.cache_creation_input_tokens));
3193
3526
  target.cache_creation = {
@@ -3770,6 +4103,8 @@ function usageCandidateFromRecord(record, index, fallbackTimestamp, traceContext
3770
4103
  const output = numberValue2(attributes["gen_ai.usage.output_tokens"]);
3771
4104
  const cached = numberValue2(attributes["gen_ai.usage.cache_read.input_tokens"]);
3772
4105
  const cacheCreation = firstPositiveNumber(attributes, ["gen_ai.usage.cache_write.input_tokens", "gen_ai.usage.cache_creation.input_tokens"]);
4106
+ const rawInput = attributes["gen_ai.usage.input_tokens"];
4107
+ const requestInputTokens = typeof rawInput === "number" && Number.isFinite(rawInput) && rawInput >= cached + cacheCreation ? rawInput : void 0;
3773
4108
  const reasoning = firstPositiveNumber(attributes, ["gen_ai.usage.reasoning.output_tokens", "gen_ai.usage.reasoning_tokens"]);
3774
4109
  const total = firstPositiveNumber(attributes, ["gen_ai.usage.total_tokens", "gen_ai.usage.total.token_count"]);
3775
4110
  const outputWithFallback = output || outputTokensFromTotal(total, input, reasoning);
@@ -3786,6 +4121,7 @@ function usageCandidateFromRecord(record, index, fallbackTimestamp, traceContext
3786
4121
  model: firstNonEmptyAttr(attributes, modelAttrs) ?? traceContext?.model,
3787
4122
  timestamp: timestamp3,
3788
4123
  durationMs: durationMsFromRecord(record),
4124
+ requestInputTokens,
3789
4125
  inputTokens: input,
3790
4126
  cachedInputTokens: cached,
3791
4127
  cacheCreationInputTokens: cacheCreation,
@@ -3848,6 +4184,8 @@ function applyCandidate(breakdown, candidate) {
3848
4184
  breakdown.endedAt = maxDate2(breakdown.endedAt, candidate.timestamp);
3849
4185
  applyTokenEvent(breakdown, {
3850
4186
  dedupKey: candidate.dedupKey,
4187
+ model: candidate.model,
4188
+ requestInputTokens: candidate.source === "chat_span" || candidate.source === "inference_log" ? candidate.requestInputTokens : void 0,
3851
4189
  detailed: candidate.inputTokens > 0 || candidate.cachedInputTokens > 0 || candidate.cacheCreationInputTokens > 0 || candidate.reasoningTokens > 0,
3852
4190
  inputTokens: candidate.inputTokens,
3853
4191
  cachedInputTokens: candidate.cachedInputTokens,
@@ -3969,8 +4307,9 @@ function breakdownToUsage(breakdown, index, options) {
3969
4307
  fileEditCount: breakdown.fileEditCount,
3970
4308
  sourceMetadata: { copilot: { sourcePaths: breakdown.sourcePaths, surface: breakdown.surface } }
3971
4309
  };
3972
- const cost = hasPricedBreakdown ? calculateCostUsd(usage, options.pricing) : void 0;
3973
- return { ...usage, estimatedCostUsd: cost, warnings: hasPricedBreakdown && cost === void 0 ? [...usage.warnings, "unknown_pricing"] : usage.warnings };
4310
+ const estimate = hasPricedBreakdown ? calculateRequestCosts(breakdown.tokenEvents.map((event) => ({ ...event, model: normalizeCopilotModel(hasKnownModel(event.model) ? event.model : breakdown.model) })), options.pricing) : void 0;
4311
+ const cost = estimate?.costUsd;
4312
+ return { ...usage, estimatedCostUsd: cost, warnings: hasPricedBreakdown && cost === void 0 ? [.../* @__PURE__ */ new Set([...usage.warnings, "unknown_pricing", ...estimate?.warnings ?? [], ...estimate?.assumptions ?? []])] : [.../* @__PURE__ */ new Set([...usage.warnings, ...estimate?.assumptions ?? []])] };
3974
4313
  }
3975
4314
  function unknownCopilotRepoInfo() {
3976
4315
  return {
@@ -4676,9 +5015,12 @@ function applyCursorRecord(breakdown, record) {
4676
5015
  }
4677
5016
  }
4678
5017
  const usage = extractUsage(objects);
4679
- if (usage.inputTokens + usage.cachedInputTokens + usage.outputTokens + usage.reasoningTokens + usage.totalTokens > 0) {
5018
+ if (usage.inputTokens + usage.cachedInputTokens + usage.outputTokens + usage.reasoningTokens + usage.totalTokens + usage.cacheCreationInputTokens > 0) {
4680
5019
  breakdown.inputTokens += usage.inputTokens;
4681
5020
  breakdown.cachedInputTokens += usage.cachedInputTokens;
5021
+ breakdown.cacheCreationInputTokens += usage.cacheCreationInputTokens;
5022
+ breakdown.cacheCreationInputTokens30m += usage.cacheCreationInputTokens30m;
5023
+ breakdown.cacheCreationInputTokens12h += usage.cacheCreationInputTokens12h;
4682
5024
  breakdown.outputTokens += usage.outputTokens;
4683
5025
  breakdown.reasoningTokens += usage.reasoningTokens;
4684
5026
  breakdown.totalTokens += usage.totalTokens;
@@ -4771,9 +5113,16 @@ function textFromUnknown(value) {
4771
5113
  function extractUsage(objects) {
4772
5114
  const usageObjects = objects.filter((object) => Object.keys(object).some((key) => key.toLowerCase().includes("token") || key.toLowerCase() === "usage"));
4773
5115
  const candidates = usageObjects.length ? usageObjects : objects;
5116
+ const detailObjects = candidates.flatMap((candidate) => [firstObject6(candidate.input_tokens_details), firstObject6(candidate.inputTokensDetails), firstObject6(candidate.cache_write_tokens_details)].filter((item) => Boolean(item)));
5117
+ const cacheCreation30m = firstNumberByKeys(detailObjects, ["ttl_30m_tokens", "ttl30mTokens"]) ?? 0;
5118
+ const cacheCreation12h = firstNumberByKeys(detailObjects, ["ttl_12h_tokens", "ttl12hTokens"]) ?? 0;
5119
+ const cacheCreationDeclared = firstNumberByKeys(candidates, ["cacheCreationInputTokens", "cache_creation_input_tokens", "cacheWriteInputTokens", "cache_write_input_tokens", "cache_write_tokens"]) ?? firstNumberByKeys(detailObjects, ["cache_write_tokens", "cacheWriteTokens"]) ?? 0;
4774
5120
  return {
4775
5121
  inputTokens: firstNumberByKeys(candidates, ["inputTokens", "input_tokens", "promptTokens", "prompt_tokens", "totalUsedTokens"]) ?? 0,
4776
- cachedInputTokens: firstNumberByKeys(candidates, ["cachedInputTokens", "cached_input_tokens", "cacheReadInputTokens", "cache_read_input_tokens"]) ?? 0,
5122
+ cachedInputTokens: firstNumberByKeys(candidates, ["cachedInputTokens", "cached_input_tokens", "cached_tokens", "cacheReadInputTokens", "cache_read_input_tokens"]) ?? firstNumberByKeys(detailObjects, ["cached_tokens", "cachedTokens"]) ?? 0,
5123
+ cacheCreationInputTokens: Math.max(cacheCreationDeclared, cacheCreation30m + cacheCreation12h),
5124
+ cacheCreationInputTokens30m: cacheCreation30m,
5125
+ cacheCreationInputTokens12h: cacheCreation12h,
4777
5126
  outputTokens: firstNumberByKeys(candidates, ["outputTokens", "output_tokens", "completionTokens", "completion_tokens"]) ?? 0,
4778
5127
  reasoningTokens: firstNumberByKeys(candidates, ["reasoningTokens", "reasoning_tokens", "reasoningOutputTokens", "reasoning_output_tokens"]) ?? 0,
4779
5128
  totalTokens: firstNumberByKeys(candidates, ["totalTokens", "total_tokens", "tokens", "tokenCount", "token_count"]) ?? 0,
@@ -4829,6 +5178,9 @@ function candidateToUsage(candidate, index, options) {
4829
5178
  provider: providerForModel2(breakdown.model ?? ""),
4830
5179
  inputTokens: breakdown.inputTokens,
4831
5180
  cachedInputTokens: breakdown.cachedInputTokens,
5181
+ cacheCreationInputTokens: breakdown.cacheCreationInputTokens || void 0,
5182
+ cacheCreationInputTokens30m: breakdown.cacheCreationInputTokens30m || void 0,
5183
+ cacheCreationInputTokens12h: breakdown.cacheCreationInputTokens12h || void 0,
4832
5184
  outputTokens: breakdown.outputTokens,
4833
5185
  reasoningTokens: breakdown.reasoningTokens,
4834
5186
  reasoningOutputTokens: breakdown.reasoningTokens,
@@ -4875,12 +5227,13 @@ function candidateToUsage(candidate, index, options) {
4875
5227
  }
4876
5228
  }
4877
5229
  };
4878
- const pricedCost = hasTokenBreakdown ? calculateCostUsd(usage, options.pricing) : void 0;
5230
+ const estimate = hasTokenBreakdown ? calculateRequestCosts([usage], options.pricing) : void 0;
5231
+ const pricedCost = estimate?.costUsd;
4879
5232
  const estimatedCostUsd = pricedCost ?? breakdown.estimatedCostUsd;
4880
5233
  return {
4881
5234
  ...usage,
4882
5235
  estimatedCostUsd,
4883
- warnings: estimatedCostUsd === void 0 ? [...usage.warnings, breakdown.hasEstimatedPromptTokens ? "cursor_cost_not_estimated_from_prompt_tokens" : hasTokenBreakdown ? "unknown_pricing" : "unknown_cost"] : usage.warnings
5236
+ warnings: estimatedCostUsd === void 0 ? [.../* @__PURE__ */ new Set([...usage.warnings, breakdown.hasEstimatedPromptTokens ? "cursor_cost_not_estimated_from_prompt_tokens" : hasTokenBreakdown ? "unknown_pricing" : "unknown_cost", ...estimate?.warnings ?? [], ...estimate?.assumptions ?? []])] : [.../* @__PURE__ */ new Set([...usage.warnings, ...estimate?.assumptions ?? []])]
4884
5237
  };
4885
5238
  }
4886
5239
  function inferProjectPathFromCursorPath(filePath, cursorHome) {
@@ -4994,6 +5347,9 @@ function emptyBreakdown4() {
4994
5347
  model: void 0,
4995
5348
  inputTokens: 0,
4996
5349
  cachedInputTokens: 0,
5350
+ cacheCreationInputTokens: 0,
5351
+ cacheCreationInputTokens30m: 0,
5352
+ cacheCreationInputTokens12h: 0,
4997
5353
  outputTokens: 0,
4998
5354
  reasoningTokens: 0,
4999
5355
  totalTokens: 0,
@@ -5271,7 +5627,9 @@ function readPricingData() {
5271
5627
  const pricingPath = resolvePricingPath(config);
5272
5628
  return {
5273
5629
  path: pricingPath,
5274
- models: loadPricingTable(pricingPath)
5630
+ models: loadPricingTable(pricingPath),
5631
+ defaults: defaultPricing,
5632
+ contextRules: pricingContextRules()
5275
5633
  };
5276
5634
  }
5277
5635
  function readConfigData() {
@@ -5295,7 +5653,9 @@ function writePricingData(models) {
5295
5653
  clearScanCache();
5296
5654
  return {
5297
5655
  path: pricingPath,
5298
- models: loadPricingTable(pricingPath)
5656
+ models: loadPricingTable(pricingPath),
5657
+ defaults: defaultPricing,
5658
+ contextRules: pricingContextRules()
5299
5659
  };
5300
5660
  }
5301
5661
  function clearRepoSpendLocalData() {
@@ -6366,12 +6726,18 @@ function recentCommandLines(lines) {
6366
6726
  function createServer(options = {}) {
6367
6727
  const app = Fastify({ logger: false });
6368
6728
  app.addHook("onRequest", async (request, reply) => {
6369
- if (!isProtectedLocalMutation(request.method, request.url)) return;
6370
- if (!isAllowedLocalHost(request.headers.host)) {
6371
- return reply.code(403).send({ error: "Mutating RepoSpend local settings requires a localhost Host header." });
6729
+ const path11 = guardRequestPath(request);
6730
+ if (isProtectedLocalMutation(request.method, path11)) {
6731
+ if (!isAllowedLocalHost(request.headers.host)) {
6732
+ return reply.code(403).send({ error: "Mutating RepoSpend local settings requires a localhost Host header." });
6733
+ }
6734
+ if (!isAllowedLocalOrigin(request.headers.origin)) {
6735
+ return reply.code(403).send({ error: "Mutating RepoSpend local settings requires a localhost Origin." });
6736
+ }
6737
+ return;
6372
6738
  }
6373
- if (!isAllowedLocalOrigin(request.headers.origin)) {
6374
- return reply.code(403).send({ error: "Mutating RepoSpend local settings requires a localhost Origin." });
6739
+ if (isSensitiveLocalRead(request.method, path11) && request.headers.host && !isAllowedLocalHost(request.headers.host)) {
6740
+ return reply.code(403).send({ error: "Reading RepoSpend local data requires a localhost Host header." });
6375
6741
  }
6376
6742
  });
6377
6743
  app.get("/api/health", async () => ({ ok: true, app: "RepoSpend", version: readPackageVersion() }));
@@ -6486,7 +6852,26 @@ function isAddressInUse(error) {
6486
6852
  }
6487
6853
  function isProtectedLocalMutation(method, url) {
6488
6854
  if (method !== "PUT" && method !== "POST" && method !== "DELETE") return false;
6489
- return url.startsWith("/api/settings/") || url.startsWith("/api/cache/");
6855
+ const pathname = routerNormalizedPath(url);
6856
+ return pathname.startsWith("/api/settings/") || pathname.startsWith("/api/cache/");
6857
+ }
6858
+ var SENSITIVE_LOCAL_READS = /* @__PURE__ */ new Set(["/api/dashboard", "/api/export.json", "/api/export.csv"]);
6859
+ function isSensitiveLocalRead(method, url) {
6860
+ if (method !== "GET" && method !== "HEAD") return false;
6861
+ return SENSITIVE_LOCAL_READS.has(routerNormalizedPath(url));
6862
+ }
6863
+ function guardRequestPath(request) {
6864
+ const matched = request.routeOptions?.url;
6865
+ return typeof matched === "string" ? matched : routerNormalizedPath(request.url);
6866
+ }
6867
+ function routerNormalizedPath(url) {
6868
+ const absoluteStripped = url.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/?#]*/, "");
6869
+ const raw = absoluteStripped.split("?")[0] ?? "";
6870
+ try {
6871
+ return decodeURIComponent(raw);
6872
+ } catch {
6873
+ return raw;
6874
+ }
6490
6875
  }
6491
6876
  function isAllowedLocalHost(hostHeader) {
6492
6877
  if (!hostHeader) return false;
@@ -6533,11 +6918,15 @@ function validatePricingBody(body) {
6533
6918
  const cachedInputPerMillion = finiteNumber(row.cachedInputPerMillion);
6534
6919
  const cacheCreationInput5mPerMillion = finiteNumber(row.cacheCreationInput5mPerMillion);
6535
6920
  const cacheCreationInput1hPerMillion = finiteNumber(row.cacheCreationInput1hPerMillion);
6921
+ const cacheCreationInput30mPerMillion = finiteNumber(row.cacheCreationInput30mPerMillion);
6922
+ const cacheCreationInput12hPerMillion = finiteNumber(row.cacheCreationInput12hPerMillion);
6536
6923
  const cacheCreationInputPerMillion = finiteNumber(row.cacheCreationInputPerMillion);
6537
6924
  const reasoningOutputPerMillion = finiteNumber(row.reasoningOutputPerMillion);
6538
6925
  if (cachedInputPerMillion !== void 0) modelPricing.cachedInputPerMillion = cachedInputPerMillion;
6539
6926
  if (cacheCreationInput5mPerMillion !== void 0) modelPricing.cacheCreationInput5mPerMillion = cacheCreationInput5mPerMillion;
6540
6927
  if (cacheCreationInput1hPerMillion !== void 0) modelPricing.cacheCreationInput1hPerMillion = cacheCreationInput1hPerMillion;
6928
+ if (cacheCreationInput30mPerMillion !== void 0) modelPricing.cacheCreationInput30mPerMillion = cacheCreationInput30mPerMillion;
6929
+ if (cacheCreationInput12hPerMillion !== void 0) modelPricing.cacheCreationInput12hPerMillion = cacheCreationInput12hPerMillion;
6541
6930
  if (cacheCreationInputPerMillion !== void 0) modelPricing.cacheCreationInputPerMillion = cacheCreationInputPerMillion;
6542
6931
  if (reasoningOutputPerMillion !== void 0) modelPricing.reasoningOutputPerMillion = reasoningOutputPerMillion;
6543
6932
  if (typeof row.note === "string") modelPricing.note = row.note;