teapot-coding-agent 0.37.64 → 0.37.66

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.
@@ -395,7 +395,10 @@ export class Agent {
395
395
  const u = e.data;
396
396
  const inTok = u.inputTokens ?? 0;
397
397
  const cached = Math.min(u.cachedInputTokens ?? 0, inTok);
398
- cost += (inTok - cached) * p.prompt + (u.outputTokens ?? 0) * p.completion + cached * p.prompt * 0.1;
398
+ cost +=
399
+ (inTok - cached) * p.prompt +
400
+ (u.outputTokens ?? 0) * p.completion +
401
+ cached * (p.cacheRead ?? p.prompt * 0.1);
399
402
  }
400
403
  this.stats.costUsd = cost;
401
404
  }
@@ -1768,7 +1771,9 @@ export class Agent {
1768
1771
  const uncached = Math.max(0, inTok - cached);
1769
1772
  this.stats.costUsd =
1770
1773
  (this.stats.costUsd ?? 0) +
1771
- (uncached * p.prompt + (res.usage.outputTokens ?? 0) * p.completion + cached * p.prompt * 0.1);
1774
+ (uncached * p.prompt +
1775
+ (res.usage.outputTokens ?? 0) * p.completion +
1776
+ cached * (p.cacheRead ?? p.prompt * 0.1));
1772
1777
  }
1773
1778
  this.lastUsage = {
1774
1779
  input: res.usage.inputTokens ?? 0,
@@ -151,8 +151,22 @@ export function metaFrom(m) {
151
151
  id: String(m.id ?? ""),
152
152
  ...(typeof m.name === "string" ? { name: m.name } : {}),
153
153
  ...(typeof m.limit?.context === "number" ? { contextLength: m.limit.context } : {}),
154
+ /**
155
+ * models.dev quotes USD per MILLION tokens; everything downstream multiplies by TOKENS.
156
+ *
157
+ * MEASURED: `claude-sonnet-4-5` is `{input: 3, output: 15}`, i.e. $3/$15 per million — so feeding
158
+ * those raw made a 892.6M-token session cost $15,239,168 instead of $15.31, and the picker badge
159
+ * read `150000/M`. Normalise here, at the single boundary, and keep the per-token convention the
160
+ * cost code and the badge already assume.
161
+ */
154
162
  ...(m.cost && (typeof m.cost.input === "number" || typeof m.cost.output === "number")
155
- ? { pricing: { prompt: Number(m.cost.input ?? 0), completion: Number(m.cost.output ?? 0) } }
163
+ ? {
164
+ pricing: {
165
+ prompt: Number(m.cost.input ?? 0) / 1e6,
166
+ completion: Number(m.cost.output ?? 0) / 1e6,
167
+ ...(typeof m.cost.cache_read === "number" ? { cacheRead: m.cost.cache_read / 1e6 } : {}),
168
+ },
169
+ }
156
170
  : {}),
157
171
  ...(input ? { modalities: { input, output: output ?? ["text"] } } : {}),
158
172
  ...(efforts ? { supportedEfforts: efforts } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.64",
3
+ "version": "0.37.66",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",