johns-harness 2026.10.21 → 2026.10.22

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -0
  3. package/dist/auth-profiles-5CHn7vq1.js +4 -2
  4. package/dist/compact-B247y5Qt.js +28 -69
  5. package/dist/config-koj5M_EO.js +4 -2
  6. package/dist/daemon-cli.js +4 -2
  7. package/dist/model-selection-BGlGpPgM.js +4 -2
  8. package/dist/model-selection-BU6wl1le.js +4 -2
  9. package/dist/model-selection-L7RMwsG-.js +4 -2
  10. package/dist/pi-embedded-C6ITuRXf.js +29 -84
  11. package/dist/pi-embedded-DoQsYfIY.js +29 -84
  12. package/dist/plugin-sdk/bluebubbles.js +2 -1
  13. package/dist/plugin-sdk/config/types.models.d.ts +1 -0
  14. package/dist/plugin-sdk/config/zod-schema.core.d.ts +3 -0
  15. package/dist/plugin-sdk/config/zod-schema.d.ts +1 -0
  16. package/dist/plugin-sdk/config-4Fgm-yEH.js +4 -2
  17. package/dist/plugin-sdk/config-Di-lyCdh.js +4 -2
  18. package/dist/plugin-sdk/discord.js +4 -2
  19. package/dist/plugin-sdk/dispatch-BP0viZiL.js +29 -84
  20. package/dist/plugin-sdk/dispatch-CQsjmw7g.js +29 -84
  21. package/dist/plugin-sdk/dispatch-Cerq29sy.js +29 -84
  22. package/dist/plugin-sdk/dispatch-Cndjtt0g.js +29 -84
  23. package/dist/plugin-sdk/dispatch-UogiJYul.js +29 -84
  24. package/dist/plugin-sdk/feishu.js +2 -1
  25. package/dist/plugin-sdk/googlechat.js +2 -1
  26. package/dist/plugin-sdk/imessage.js +2 -1
  27. package/dist/plugin-sdk/model-auth-CX9cPHdC.js +4 -2
  28. package/dist/plugin-sdk/model-auth-Ciehz0x5.js +4 -2
  29. package/dist/plugin-sdk/model-auth-DVyo6JSX.js +4 -2
  30. package/dist/plugin-sdk/model-auth-kiHYHGrs.js +4 -2
  31. package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +4 -2
  32. package/dist/plugin-sdk/nostr.js +2 -1
  33. package/dist/plugin-sdk/reply-DbZnH8-h.js +29 -84
  34. package/dist/plugin-sdk/signal.js +2 -1
  35. package/dist/plugin-sdk/slack.js +2 -1
  36. package/dist/plugin-sdk/telegram.js +2 -1
  37. package/dist/plugin-sdk/tlon.js +2 -1
  38. package/dist/plugin-sdk/twitch.js +2 -1
  39. package/dist/plugin-sdk/utils/usage-format.d.ts +1 -0
  40. package/dist/plugin-sdk/voice-call.js +2 -1
  41. package/dist/plugin-sdk/zalo.js +2 -1
  42. package/dist/plugin-sdk/zalouser.js +2 -1
  43. package/dist/reply-C5LKjXcC.js +28 -69
  44. package/dist/session-cost-usage-5CCZbVhO.js +4 -19
  45. package/dist/session-cost-usage-CkCo2kVx.js +4 -19
  46. package/dist/usage-billing.js +88 -0
  47. package/dist/usage-format-CNGi1eHQ.js +6 -11
  48. package/dist/usage-format-CvaU1ntA.js +6 -11
  49. package/docs/PATCHES.md +13 -1
  50. package/docs/providers/anthropic.md +8 -2
  51. package/docs/reference/token-use.md +11 -1
  52. package/models/models.json +33 -33
  53. package/node_modules/@mariozechner/pi-ai/dist/models.d.ts +1 -0
  54. package/node_modules/@mariozechner/pi-ai/dist/models.generated.js +32 -32
  55. package/node_modules/@mariozechner/pi-ai/dist/models.js +16 -5
  56. package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
  57. package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +1 -1
  58. package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +1 -1
  59. package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
  60. package/node_modules/@mariozechner/pi-ai/dist/types.d.ts +3 -0
  61. package/node_modules/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
  62. package/package.json +1 -1
  63. package/scripts/models-sync.mjs +1 -0
  64. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.d.ts +25 -0
  65. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.generated.js +32 -32
  66. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.js +16 -5
  67. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
  68. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google-vertex.js +371 -0
  69. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google.js +1 -1
  70. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
  71. package/vendor/patched-deps/@mariozechner/pi-ai/dist/types.d.ts +282 -0
  72. package/vendor/patched-deps/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
@@ -1,3 +1,4 @@
1
+ import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/pi-embedded-DoQsYfIY.js
1
2
  import { importOptional66 } from "./optional-module.js";
2
3
  const JOHNNESS_PATCH_SLIM_TREE_66 = true;
3
4
  import { createImageGenerateTool } from "./image-generate.js";
@@ -24987,21 +24988,7 @@ function hasNonzeroUsage(usage) {
24987
24988
  ].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
24988
24989
  }
24989
24990
  function normalizeUsage(raw) {
24990
- if (!raw) return;
24991
- const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
24992
- const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
24993
- const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
24994
- const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
24995
- const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
24996
- const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
24997
- if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
24998
- return {
24999
- input,
25000
- output,
25001
- cacheRead,
25002
- cacheWrite,
25003
- total
25004
- };
24991
+ return normalizeBillingUsage(raw);
25005
24992
  }
25006
24993
  function derivePromptTokens(usage) {
25007
24994
  if (!usage) return;
@@ -25389,62 +25376,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
25389
25376
  } catch {
25390
25377
  return;
25391
25378
  }
25392
- if (!syncFs.existsSync(logPath)) return;
25393
- try {
25394
- const TAIL_BYTES = 8192;
25395
- const stat = syncFs.statSync(logPath);
25396
- const offset = Math.max(0, stat.size - TAIL_BYTES);
25397
- const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
25398
- const fd = syncFs.openSync(logPath, "r");
25399
- try {
25400
- syncFs.readSync(fd, buf, 0, buf.length, offset);
25401
- } finally {
25402
- syncFs.closeSync(fd);
25403
- }
25404
- const tail = buf.toString("utf-8");
25405
- const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
25406
- let input = 0;
25407
- let output = 0;
25408
- let promptTokens = 0;
25409
- let model;
25410
- let lastUsage;
25411
- for (const line of lines) {
25412
- if (!line.trim()) continue;
25413
- try {
25414
- const parsed = JSON.parse(line);
25415
- const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
25416
- if (usage) lastUsage = usage;
25417
- model = parsed.message?.model ?? parsed.model ?? model;
25418
- } catch {}
25419
- }
25420
- if (!lastUsage) return;
25421
- input = lastUsage.input ?? 0;
25422
- output = lastUsage.output ?? 0;
25423
- promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
25424
- const total = lastUsage.total ?? promptTokens + output;
25425
- if (promptTokens === 0 && total === 0) return;
25426
- return {
25427
- input,
25428
- output,
25429
- promptTokens,
25430
- total,
25431
- model
25432
- };
25433
- } catch {
25434
- return;
25435
- }
25379
+ return readLatestBillingUsage(logPath);
25436
25380
  };
25437
- const formatUsagePair = (input, output) => {
25438
- if (input == null && output == null) return null;
25439
- return `🧮 Tokens: ${typeof input === "number" ? formatTokenCount(input) : "?"} in / ${typeof output === "number" ? formatTokenCount(output) : "?"} out`;
25381
+ const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
25382
+ if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
25383
+ const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
25384
+ return `🧮 Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
25440
25385
  };
25441
- const formatCacheLine = (input, cacheRead, cacheWrite) => {
25386
+ const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
25442
25387
  if (!cacheRead && !cacheWrite) return null;
25443
- if ((typeof cacheRead !== "number" || cacheRead <= 0) && (typeof cacheWrite !== "number" || cacheWrite <= 0)) return null;
25444
- const cachedLabel = typeof cacheRead === "number" ? formatTokenCount(cacheRead) : "0";
25445
- const newLabel = typeof cacheWrite === "number" ? formatTokenCount(cacheWrite) : "0";
25446
- const totalInput = (typeof cacheRead === "number" ? cacheRead : 0) + (typeof cacheWrite === "number" ? cacheWrite : 0) + (typeof input === "number" ? input : 0);
25447
- return `🗄️ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit · ${cachedLabel} cached, ${newLabel} new`;
25388
+ const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
25389
+ const count = value => (value ?? 0).toLocaleString("en-US");
25390
+ const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
25391
+ return `🗄️ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit · ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
25448
25392
  };
25449
25393
  const formatMediaUnderstandingLine = (decisions) => {
25450
25394
  if (!decisions || decisions.length === 0) return null;
@@ -25523,10 +25467,14 @@ function buildStatusMessage(args) {
25523
25467
  let outputTokens = entry?.outputTokens;
25524
25468
  let cacheRead = entry?.cacheRead;
25525
25469
  let cacheWrite = entry?.cacheWrite;
25470
+ let billingUsage;
25526
25471
  let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
25527
- if (args.includeTranscriptUsage) {
25472
+ if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
25528
25473
  const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
25529
25474
  if (logUsage) {
25475
+ billingUsage = logUsage;
25476
+ cacheRead = logUsage.cacheRead ?? 0;
25477
+ cacheWrite = logUsage.cacheWrite ?? 0;
25530
25478
  const candidate = logUsage.promptTokens || logUsage.total;
25531
25479
  if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
25532
25480
  if (!entry?.model && logUsage.model) {
@@ -25545,8 +25493,10 @@ function buildStatusMessage(args) {
25545
25493
  model: logUsage.model,
25546
25494
  fallbackContextTokens: contextTokens ?? void 0
25547
25495
  }) ?? contextTokens;
25548
- if (!inputTokens || inputTokens === 0) inputTokens = logUsage.input;
25549
- if (!outputTokens || outputTokens === 0) outputTokens = logUsage.output;
25496
+ inputTokens = logUsage.input ?? 0;
25497
+ outputTokens = logUsage.output ?? 0;
25498
+ if (logUsage.provider) activeProvider = logUsage.provider;
25499
+ if (logUsage.model) activeModel = logUsage.model;
25550
25500
  }
25551
25501
  }
25552
25502
  const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
@@ -25582,21 +25532,14 @@ function buildStatusMessage(args) {
25582
25532
  state: entry
25583
25533
  });
25584
25534
  const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
25585
- const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
25535
+ const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
25586
25536
  const costConfig = showCost ? resolveModelCostConfig({
25587
25537
  provider: activeProvider,
25588
25538
  model: activeModel,
25589
25539
  config: args.config
25590
25540
  }) : void 0;
25591
- const hasUsage = typeof inputTokens === "number" || typeof outputTokens === "number";
25592
- const cost = showCost && hasUsage ? estimateUsageCost({
25593
- usage: {
25594
- input: inputTokens ?? void 0,
25595
- output: outputTokens ?? void 0
25596
- },
25597
- cost: costConfig
25598
- }) : void 0;
25599
- const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
25541
+ const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
25542
+ billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
25600
25543
  const selectedAuthLabel = selectedAuthLabelValue ? ` · 🔑 ${selectedAuthLabelValue}` : "";
25601
25544
  const channelModelNote = (() => {
25602
25545
  if (!args.config || !entry) return;
@@ -25628,9 +25571,9 @@ function buildStatusMessage(args) {
25628
25571
  const fallbackLine = fallbackState.active ? `↪️ Fallback: ${activeModelLabel}${showFallbackAuth ? ` · 🔑 ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
25629
25572
  const commit = resolveCommitHash();
25630
25573
  const versionLine = `🦞 Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
25631
- const usagePair = formatUsagePair(inputTokens, outputTokens);
25632
- const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
25633
- const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
25574
+ const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
25575
+ const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
25576
+ const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
25634
25577
  const usageCostLine = usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
25635
25578
  const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
25636
25579
  const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
@@ -96735,6 +96678,8 @@ function normalizeAssistantUsageSnapshot(usage) {
96735
96678
  cacheRead,
96736
96679
  cacheWrite,
96737
96680
  totalTokens,
96681
+ ...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
96682
+ ...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
96738
96683
  ...cost ? { cost } : {}
96739
96684
  };
96740
96685
  }
@@ -3880,7 +3880,8 @@ const ModelDefinitionSchema = z.object({
3880
3880
  input: z.number().optional(),
3881
3881
  output: z.number().optional(),
3882
3882
  cacheRead: z.number().optional(),
3883
- cacheWrite: z.number().optional()
3883
+ cacheWrite: z.number().optional(),
3884
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
3884
3885
  }).strict().optional(),
3885
3886
  contextWindow: z.number().positive().optional(),
3886
3887
  maxTokens: z.number().positive().optional(),
@@ -27,6 +27,7 @@ export type ModelDefinitionConfig = {
27
27
  output: number;
28
28
  cacheRead: number;
29
29
  cacheWrite: number;
30
+ cacheWrite1h?: number;
30
31
  };
31
32
  contextWindow: number;
32
33
  maxTokens: number;
@@ -127,6 +127,7 @@ export declare const ModelDefinitionSchema: z.ZodObject<{
127
127
  output: z.ZodOptional<z.ZodNumber>;
128
128
  cacheRead: z.ZodOptional<z.ZodNumber>;
129
129
  cacheWrite: z.ZodOptional<z.ZodNumber>;
130
+ cacheWrite1h: z.ZodOptional<z.ZodNumber>;
130
131
  }, z.core.$strict>>;
131
132
  contextWindow: z.ZodOptional<z.ZodNumber>;
132
133
  maxTokens: z.ZodOptional<z.ZodNumber>;
@@ -207,6 +208,7 @@ export declare const ModelProviderSchema: z.ZodObject<{
207
208
  output: z.ZodOptional<z.ZodNumber>;
208
209
  cacheRead: z.ZodOptional<z.ZodNumber>;
209
210
  cacheWrite: z.ZodOptional<z.ZodNumber>;
211
+ cacheWrite1h: z.ZodOptional<z.ZodNumber>;
210
212
  }, z.core.$strict>>;
211
213
  contextWindow: z.ZodOptional<z.ZodNumber>;
212
214
  maxTokens: z.ZodOptional<z.ZodNumber>;
@@ -298,6 +300,7 @@ export declare const ModelsConfigSchema: z.ZodOptional<z.ZodObject<{
298
300
  output: z.ZodOptional<z.ZodNumber>;
299
301
  cacheRead: z.ZodOptional<z.ZodNumber>;
300
302
  cacheWrite: z.ZodOptional<z.ZodNumber>;
303
+ cacheWrite1h: z.ZodOptional<z.ZodNumber>;
301
304
  }, z.core.$strict>>;
302
305
  contextWindow: z.ZodOptional<z.ZodNumber>;
303
306
  maxTokens: z.ZodOptional<z.ZodNumber>;
@@ -241,6 +241,7 @@ export declare const JohnnessSchema: z.ZodObject<{
241
241
  output: z.ZodOptional<z.ZodNumber>;
242
242
  cacheRead: z.ZodOptional<z.ZodNumber>;
243
243
  cacheWrite: z.ZodOptional<z.ZodNumber>;
244
+ cacheWrite1h: z.ZodOptional<z.ZodNumber>;
244
245
  }, z.core.$strict>>;
245
246
  contextWindow: z.ZodOptional<z.ZodNumber>;
246
247
  maxTokens: z.ZodOptional<z.ZodNumber>;
@@ -7129,7 +7129,8 @@ function resolveModelCost(raw) {
7129
7129
  input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
7130
7130
  output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
7131
7131
  cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
7132
- cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
7132
+ cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
7133
+ ...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
7133
7134
  };
7134
7135
  }
7135
7136
  function resolveAnthropicDefaultAuthMode(cfg) {
@@ -13844,7 +13845,8 @@ const ModelDefinitionSchema = z.object({
13844
13845
  input: z.number().optional(),
13845
13846
  output: z.number().optional(),
13846
13847
  cacheRead: z.number().optional(),
13847
- cacheWrite: z.number().optional()
13848
+ cacheWrite: z.number().optional(),
13849
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
13848
13850
  }).strict().optional(),
13849
13851
  contextWindow: z.number().positive().optional(),
13850
13852
  maxTokens: z.number().positive().optional(),
@@ -8130,7 +8130,8 @@ function resolveModelCost(raw) {
8130
8130
  input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
8131
8131
  output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
8132
8132
  cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
8133
- cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
8133
+ cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
8134
+ ...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
8134
8135
  };
8135
8136
  }
8136
8137
  function resolveAnthropicDefaultAuthMode(cfg) {
@@ -13837,7 +13838,8 @@ const ModelDefinitionSchema = z.object({
13837
13838
  input: z.number().optional(),
13838
13839
  output: z.number().optional(),
13839
13840
  cacheRead: z.number().optional(),
13840
- cacheWrite: z.number().optional()
13841
+ cacheWrite: z.number().optional(),
13842
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
13841
13843
  }).strict().optional(),
13842
13844
  contextWindow: z.number().positive().optional(),
13843
13845
  maxTokens: z.number().positive().optional(),
@@ -5255,7 +5255,8 @@ function resolveModelCost(raw) {
5255
5255
  input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
5256
5256
  output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
5257
5257
  cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
5258
- cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
5258
+ cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
5259
+ ...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
5259
5260
  };
5260
5261
  }
5261
5262
  function resolveAnthropicDefaultAuthMode(cfg) {
@@ -9153,7 +9154,8 @@ const ModelDefinitionSchema = z.object({
9153
9154
  input: z.number().optional(),
9154
9155
  output: z.number().optional(),
9155
9156
  cacheRead: z.number().optional(),
9156
- cacheWrite: z.number().optional()
9157
+ cacheWrite: z.number().optional(),
9158
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
9157
9159
  }).strict().optional(),
9158
9160
  contextWindow: z.number().positive().optional(),
9159
9161
  maxTokens: z.number().positive().optional(),
@@ -1,3 +1,4 @@
1
+ import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-BP0viZiL.js
1
2
  import { importOptional66 } from "../optional-module.js";
2
3
  const JOHNNESS_PATCH_SLIM_TREE_66 = true;
3
4
  import { createImageGenerateTool } from "../image-generate.js";
@@ -33961,21 +33962,7 @@ function hasNonzeroUsage(usage) {
33961
33962
  ].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
33962
33963
  }
33963
33964
  function normalizeUsage(raw) {
33964
- if (!raw) return;
33965
- const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
33966
- const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
33967
- const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
33968
- const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
33969
- const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
33970
- const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
33971
- if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
33972
- return {
33973
- input,
33974
- output,
33975
- cacheRead,
33976
- cacheWrite,
33977
- total
33978
- };
33965
+ return normalizeBillingUsage(raw);
33979
33966
  }
33980
33967
  function derivePromptTokens(usage) {
33981
33968
  if (!usage) return;
@@ -48811,62 +48798,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
48811
48798
  } catch {
48812
48799
  return;
48813
48800
  }
48814
- if (!fs.existsSync(logPath)) return;
48815
- try {
48816
- const TAIL_BYTES = 8192;
48817
- const stat = fs.statSync(logPath);
48818
- const offset = Math.max(0, stat.size - TAIL_BYTES);
48819
- const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
48820
- const fd = fs.openSync(logPath, "r");
48821
- try {
48822
- fs.readSync(fd, buf, 0, buf.length, offset);
48823
- } finally {
48824
- fs.closeSync(fd);
48825
- }
48826
- const tail = buf.toString("utf-8");
48827
- const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
48828
- let input = 0;
48829
- let output = 0;
48830
- let promptTokens = 0;
48831
- let model;
48832
- let lastUsage;
48833
- for (const line of lines) {
48834
- if (!line.trim()) continue;
48835
- try {
48836
- const parsed = JSON.parse(line);
48837
- const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
48838
- if (usage) lastUsage = usage;
48839
- model = parsed.message?.model ?? parsed.model ?? model;
48840
- } catch {}
48841
- }
48842
- if (!lastUsage) return;
48843
- input = lastUsage.input ?? 0;
48844
- output = lastUsage.output ?? 0;
48845
- promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
48846
- const total = lastUsage.total ?? promptTokens + output;
48847
- if (promptTokens === 0 && total === 0) return;
48848
- return {
48849
- input,
48850
- output,
48851
- promptTokens,
48852
- total,
48853
- model
48854
- };
48855
- } catch {
48856
- return;
48857
- }
48801
+ return readLatestBillingUsage(logPath);
48858
48802
  };
48859
- const formatUsagePair = (input, output) => {
48860
- if (input == null && output == null) return null;
48861
- return `🧮 Tokens: ${typeof input === "number" ? formatTokenCount$1(input) : "?"} in / ${typeof output === "number" ? formatTokenCount$1(output) : "?"} out`;
48803
+ const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
48804
+ if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
48805
+ const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
48806
+ return `🧮 Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
48862
48807
  };
48863
- const formatCacheLine = (input, cacheRead, cacheWrite) => {
48808
+ const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
48864
48809
  if (!cacheRead && !cacheWrite) return null;
48865
- if ((typeof cacheRead !== "number" || cacheRead <= 0) && (typeof cacheWrite !== "number" || cacheWrite <= 0)) return null;
48866
- const cachedLabel = typeof cacheRead === "number" ? formatTokenCount$1(cacheRead) : "0";
48867
- const newLabel = typeof cacheWrite === "number" ? formatTokenCount$1(cacheWrite) : "0";
48868
- const totalInput = (typeof cacheRead === "number" ? cacheRead : 0) + (typeof cacheWrite === "number" ? cacheWrite : 0) + (typeof input === "number" ? input : 0);
48869
- return `🗄️ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit · ${cachedLabel} cached, ${newLabel} new`;
48810
+ const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
48811
+ const count = value => (value ?? 0).toLocaleString("en-US");
48812
+ const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
48813
+ return `🗄️ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit · ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
48870
48814
  };
48871
48815
  const formatMediaUnderstandingLine = (decisions) => {
48872
48816
  if (!decisions || decisions.length === 0) return null;
@@ -48945,10 +48889,14 @@ function buildStatusMessage(args) {
48945
48889
  let outputTokens = entry?.outputTokens;
48946
48890
  let cacheRead = entry?.cacheRead;
48947
48891
  let cacheWrite = entry?.cacheWrite;
48892
+ let billingUsage;
48948
48893
  let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
48949
- if (args.includeTranscriptUsage) {
48894
+ if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
48950
48895
  const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
48951
48896
  if (logUsage) {
48897
+ billingUsage = logUsage;
48898
+ cacheRead = logUsage.cacheRead ?? 0;
48899
+ cacheWrite = logUsage.cacheWrite ?? 0;
48952
48900
  const candidate = logUsage.promptTokens || logUsage.total;
48953
48901
  if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
48954
48902
  if (!entry?.model && logUsage.model) {
@@ -48967,8 +48915,10 @@ function buildStatusMessage(args) {
48967
48915
  model: logUsage.model,
48968
48916
  fallbackContextTokens: contextTokens ?? void 0
48969
48917
  }) ?? contextTokens;
48970
- if (!inputTokens || inputTokens === 0) inputTokens = logUsage.input;
48971
- if (!outputTokens || outputTokens === 0) outputTokens = logUsage.output;
48918
+ inputTokens = logUsage.input ?? 0;
48919
+ outputTokens = logUsage.output ?? 0;
48920
+ if (logUsage.provider) activeProvider = logUsage.provider;
48921
+ if (logUsage.model) activeModel = logUsage.model;
48972
48922
  }
48973
48923
  }
48974
48924
  const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
@@ -49004,21 +48954,14 @@ function buildStatusMessage(args) {
49004
48954
  state: entry
49005
48955
  });
49006
48956
  const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
49007
- const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
48957
+ const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
49008
48958
  const costConfig = showCost ? resolveModelCostConfig({
49009
48959
  provider: activeProvider,
49010
48960
  model: activeModel,
49011
48961
  config: args.config
49012
48962
  }) : void 0;
49013
- const hasUsage = typeof inputTokens === "number" || typeof outputTokens === "number";
49014
- const cost = showCost && hasUsage ? estimateUsageCost({
49015
- usage: {
49016
- input: inputTokens ?? void 0,
49017
- output: outputTokens ?? void 0
49018
- },
49019
- cost: costConfig
49020
- }) : void 0;
49021
- const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
48963
+ const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
48964
+ billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
49022
48965
  const selectedAuthLabel = selectedAuthLabelValue ? ` · 🔑 ${selectedAuthLabelValue}` : "";
49023
48966
  const channelModelNote = (() => {
49024
48967
  if (!args.config || !entry) return;
@@ -49050,9 +48993,9 @@ function buildStatusMessage(args) {
49050
48993
  const fallbackLine = fallbackState.active ? `↪️ Fallback: ${activeModelLabel}${showFallbackAuth ? ` · 🔑 ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
49051
48994
  const commit = resolveCommitHash();
49052
48995
  const versionLine = `🦞 Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
49053
- const usagePair = formatUsagePair(inputTokens, outputTokens);
49054
- const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
49055
- const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
48996
+ const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
48997
+ const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
48998
+ const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
49056
48999
  const usageCostLine = usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
49057
49000
  const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
49058
49001
  const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
@@ -81134,6 +81077,8 @@ function normalizeAssistantUsageSnapshot(usage) {
81134
81077
  cacheRead,
81135
81078
  cacheWrite,
81136
81079
  totalTokens,
81080
+ ...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
81081
+ ...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
81137
81082
  ...cost ? { cost } : {}
81138
81083
  };
81139
81084
  }
@@ -1,3 +1,4 @@
1
+ import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-CQsjmw7g.js
1
2
  import { importOptional66 } from "../optional-module.js";
2
3
  const JOHNNESS_PATCH_SLIM_TREE_66 = true;
3
4
  import { createImageGenerateTool } from "../image-generate.js";
@@ -34060,21 +34061,7 @@ function hasNonzeroUsage(usage) {
34060
34061
  ].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
34061
34062
  }
34062
34063
  function normalizeUsage(raw) {
34063
- if (!raw) return;
34064
- const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
34065
- const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
34066
- const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
34067
- const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
34068
- const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
34069
- const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
34070
- if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
34071
- return {
34072
- input,
34073
- output,
34074
- cacheRead,
34075
- cacheWrite,
34076
- total
34077
- };
34064
+ return normalizeBillingUsage(raw);
34078
34065
  }
34079
34066
  function derivePromptTokens(usage) {
34080
34067
  if (!usage) return;
@@ -48811,62 +48798,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
48811
48798
  } catch {
48812
48799
  return;
48813
48800
  }
48814
- if (!fs$1.existsSync(logPath)) return;
48815
- try {
48816
- const TAIL_BYTES = 8192;
48817
- const stat = fs$1.statSync(logPath);
48818
- const offset = Math.max(0, stat.size - TAIL_BYTES);
48819
- const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
48820
- const fd = fs$1.openSync(logPath, "r");
48821
- try {
48822
- fs$1.readSync(fd, buf, 0, buf.length, offset);
48823
- } finally {
48824
- fs$1.closeSync(fd);
48825
- }
48826
- const tail = buf.toString("utf-8");
48827
- const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
48828
- let input = 0;
48829
- let output = 0;
48830
- let promptTokens = 0;
48831
- let model;
48832
- let lastUsage;
48833
- for (const line of lines) {
48834
- if (!line.trim()) continue;
48835
- try {
48836
- const parsed = JSON.parse(line);
48837
- const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
48838
- if (usage) lastUsage = usage;
48839
- model = parsed.message?.model ?? parsed.model ?? model;
48840
- } catch {}
48841
- }
48842
- if (!lastUsage) return;
48843
- input = lastUsage.input ?? 0;
48844
- output = lastUsage.output ?? 0;
48845
- promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
48846
- const total = lastUsage.total ?? promptTokens + output;
48847
- if (promptTokens === 0 && total === 0) return;
48848
- return {
48849
- input,
48850
- output,
48851
- promptTokens,
48852
- total,
48853
- model
48854
- };
48855
- } catch {
48856
- return;
48857
- }
48801
+ return readLatestBillingUsage(logPath);
48858
48802
  };
48859
- const formatUsagePair = (input, output) => {
48860
- if (input == null && output == null) return null;
48861
- return `🧮 Tokens: ${typeof input === "number" ? formatTokenCount$1(input) : "?"} in / ${typeof output === "number" ? formatTokenCount$1(output) : "?"} out`;
48803
+ const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
48804
+ if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
48805
+ const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
48806
+ return `🧮 Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
48862
48807
  };
48863
- const formatCacheLine = (input, cacheRead, cacheWrite) => {
48808
+ const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
48864
48809
  if (!cacheRead && !cacheWrite) return null;
48865
- if ((typeof cacheRead !== "number" || cacheRead <= 0) && (typeof cacheWrite !== "number" || cacheWrite <= 0)) return null;
48866
- const cachedLabel = typeof cacheRead === "number" ? formatTokenCount$1(cacheRead) : "0";
48867
- const newLabel = typeof cacheWrite === "number" ? formatTokenCount$1(cacheWrite) : "0";
48868
- const totalInput = (typeof cacheRead === "number" ? cacheRead : 0) + (typeof cacheWrite === "number" ? cacheWrite : 0) + (typeof input === "number" ? input : 0);
48869
- return `🗄️ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit · ${cachedLabel} cached, ${newLabel} new`;
48810
+ const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
48811
+ const count = value => (value ?? 0).toLocaleString("en-US");
48812
+ const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
48813
+ return `🗄️ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit · ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
48870
48814
  };
48871
48815
  const formatMediaUnderstandingLine = (decisions) => {
48872
48816
  if (!decisions || decisions.length === 0) return null;
@@ -48945,10 +48889,14 @@ function buildStatusMessage(args) {
48945
48889
  let outputTokens = entry?.outputTokens;
48946
48890
  let cacheRead = entry?.cacheRead;
48947
48891
  let cacheWrite = entry?.cacheWrite;
48892
+ let billingUsage;
48948
48893
  let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
48949
- if (args.includeTranscriptUsage) {
48894
+ if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
48950
48895
  const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
48951
48896
  if (logUsage) {
48897
+ billingUsage = logUsage;
48898
+ cacheRead = logUsage.cacheRead ?? 0;
48899
+ cacheWrite = logUsage.cacheWrite ?? 0;
48952
48900
  const candidate = logUsage.promptTokens || logUsage.total;
48953
48901
  if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
48954
48902
  if (!entry?.model && logUsage.model) {
@@ -48967,8 +48915,10 @@ function buildStatusMessage(args) {
48967
48915
  model: logUsage.model,
48968
48916
  fallbackContextTokens: contextTokens ?? void 0
48969
48917
  }) ?? contextTokens;
48970
- if (!inputTokens || inputTokens === 0) inputTokens = logUsage.input;
48971
- if (!outputTokens || outputTokens === 0) outputTokens = logUsage.output;
48918
+ inputTokens = logUsage.input ?? 0;
48919
+ outputTokens = logUsage.output ?? 0;
48920
+ if (logUsage.provider) activeProvider = logUsage.provider;
48921
+ if (logUsage.model) activeModel = logUsage.model;
48972
48922
  }
48973
48923
  }
48974
48924
  const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
@@ -49004,21 +48954,14 @@ function buildStatusMessage(args) {
49004
48954
  state: entry
49005
48955
  });
49006
48956
  const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
49007
- const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
48957
+ const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
49008
48958
  const costConfig = showCost ? resolveModelCostConfig({
49009
48959
  provider: activeProvider,
49010
48960
  model: activeModel,
49011
48961
  config: args.config
49012
48962
  }) : void 0;
49013
- const hasUsage = typeof inputTokens === "number" || typeof outputTokens === "number";
49014
- const cost = showCost && hasUsage ? estimateUsageCost({
49015
- usage: {
49016
- input: inputTokens ?? void 0,
49017
- output: outputTokens ?? void 0
49018
- },
49019
- cost: costConfig
49020
- }) : void 0;
49021
- const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
48963
+ const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
48964
+ billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
49022
48965
  const selectedAuthLabel = selectedAuthLabelValue ? ` · 🔑 ${selectedAuthLabelValue}` : "";
49023
48966
  const channelModelNote = (() => {
49024
48967
  if (!args.config || !entry) return;
@@ -49050,9 +48993,9 @@ function buildStatusMessage(args) {
49050
48993
  const fallbackLine = fallbackState.active ? `↪️ Fallback: ${activeModelLabel}${showFallbackAuth ? ` · 🔑 ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
49051
48994
  const commit = resolveCommitHash();
49052
48995
  const versionLine = `🦞 Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
49053
- const usagePair = formatUsagePair(inputTokens, outputTokens);
49054
- const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
49055
- const costLine = costLabel ? `💵 Cost: ${costLabel}` : null;
48996
+ const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
48997
+ const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
48998
+ const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
49056
48999
  const usageCostLine = usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
49057
49000
  const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
49058
49001
  const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
@@ -81134,6 +81077,8 @@ function normalizeAssistantUsageSnapshot(usage) {
81134
81077
  cacheRead,
81135
81078
  cacheWrite,
81136
81079
  totalTokens,
81080
+ ...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
81081
+ ...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
81137
81082
  ...cost ? { cost } : {}
81138
81083
  };
81139
81084
  }