johns-harness 2026.10.21 โ†’ 2026.10.23

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 (73) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +3 -0
  3. package/dist/anthropic-auth-runtime.js +62 -0
  4. package/dist/auth-profiles-5CHn7vq1.js +9 -4
  5. package/dist/compact-B247y5Qt.js +41 -74
  6. package/dist/config-koj5M_EO.js +4 -2
  7. package/dist/daemon-cli.js +4 -2
  8. package/dist/model-selection-BGlGpPgM.js +9 -4
  9. package/dist/model-selection-BU6wl1le.js +9 -4
  10. package/dist/model-selection-L7RMwsG-.js +9 -4
  11. package/dist/pi-embedded-C6ITuRXf.js +42 -89
  12. package/dist/pi-embedded-DoQsYfIY.js +42 -89
  13. package/dist/plugin-sdk/bluebubbles.js +2 -1
  14. package/dist/plugin-sdk/config/types.models.d.ts +1 -0
  15. package/dist/plugin-sdk/config/zod-schema.core.d.ts +3 -0
  16. package/dist/plugin-sdk/config/zod-schema.d.ts +1 -0
  17. package/dist/plugin-sdk/config-4Fgm-yEH.js +9 -4
  18. package/dist/plugin-sdk/config-Di-lyCdh.js +9 -4
  19. package/dist/plugin-sdk/discord.js +4 -2
  20. package/dist/plugin-sdk/dispatch-BP0viZiL.js +42 -89
  21. package/dist/plugin-sdk/dispatch-CQsjmw7g.js +42 -89
  22. package/dist/plugin-sdk/dispatch-Cerq29sy.js +42 -89
  23. package/dist/plugin-sdk/dispatch-Cndjtt0g.js +42 -89
  24. package/dist/plugin-sdk/dispatch-UogiJYul.js +42 -89
  25. package/dist/plugin-sdk/feishu.js +2 -1
  26. package/dist/plugin-sdk/googlechat.js +2 -1
  27. package/dist/plugin-sdk/imessage.js +2 -1
  28. package/dist/plugin-sdk/model-auth-CX9cPHdC.js +9 -4
  29. package/dist/plugin-sdk/model-auth-Ciehz0x5.js +9 -4
  30. package/dist/plugin-sdk/model-auth-DVyo6JSX.js +9 -4
  31. package/dist/plugin-sdk/model-auth-kiHYHGrs.js +9 -4
  32. package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +8 -3
  33. package/dist/plugin-sdk/nostr.js +2 -1
  34. package/dist/plugin-sdk/reply-DbZnH8-h.js +42 -89
  35. package/dist/plugin-sdk/signal.js +2 -1
  36. package/dist/plugin-sdk/slack.js +2 -1
  37. package/dist/plugin-sdk/telegram.js +2 -1
  38. package/dist/plugin-sdk/tlon.js +2 -1
  39. package/dist/plugin-sdk/twitch.js +2 -1
  40. package/dist/plugin-sdk/utils/usage-format.d.ts +1 -0
  41. package/dist/plugin-sdk/voice-call.js +2 -1
  42. package/dist/plugin-sdk/zalo.js +2 -1
  43. package/dist/plugin-sdk/zalouser.js +2 -1
  44. package/dist/reply-C5LKjXcC.js +41 -74
  45. package/dist/session-cost-usage-5CCZbVhO.js +4 -19
  46. package/dist/session-cost-usage-CkCo2kVx.js +4 -19
  47. package/dist/usage-billing.js +88 -0
  48. package/dist/usage-format-CNGi1eHQ.js +6 -11
  49. package/dist/usage-format-CvaU1ntA.js +6 -11
  50. package/docs/PATCHES.md +54 -1
  51. package/docs/providers/anthropic.md +23 -2
  52. package/docs/reference/token-use.md +11 -1
  53. package/models/models.json +33 -33
  54. package/node_modules/@mariozechner/pi-ai/dist/models.d.ts +1 -0
  55. package/node_modules/@mariozechner/pi-ai/dist/models.generated.js +32 -32
  56. package/node_modules/@mariozechner/pi-ai/dist/models.js +16 -5
  57. package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
  58. package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +1 -1
  59. package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +1 -1
  60. package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
  61. package/node_modules/@mariozechner/pi-ai/dist/types.d.ts +3 -0
  62. package/node_modules/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
  63. package/package.json +1 -1
  64. package/scripts/models-sync.mjs +1 -0
  65. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.d.ts +25 -0
  66. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.generated.js +32 -32
  67. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.js +16 -5
  68. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
  69. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google-vertex.js +371 -0
  70. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google.js +1 -1
  71. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
  72. package/vendor/patched-deps/@mariozechner/pi-ai/dist/types.d.ts +282 -0
  73. package/vendor/patched-deps/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
@@ -1,3 +1,5 @@
1
+ import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "../anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
+ import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/reply-DbZnH8-h.js
1
3
  import { importOptional66 } from "../optional-module.js";
2
4
  const JOHNNESS_PATCH_SLIM_TREE_66 = true;
3
5
  import { createImageGenerateTool } from "../image-generate.js";
@@ -29376,7 +29378,7 @@ function resolveModelAuthLabel(params) {
29376
29378
  });
29377
29379
  if (profile.type === "oauth") return `oauth${label ? ` (${label})` : ""}`;
29378
29380
  if (profile.type === "token") return `token${label ? ` (${label})` : ""}`;
29379
- return `api-key${label ? ` (${label})` : ""}`;
29381
+ return `api-key${label ? ` (${label})` : ""}${formatAuthProfileFallback(params.sessionEntry, profileId)}`;
29380
29382
  }
29381
29383
  const envKey = resolveEnvApiKey(providerKey);
29382
29384
  if (envKey?.apiKey) {
@@ -38302,21 +38304,7 @@ function hasNonzeroUsage(usage) {
38302
38304
  ].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
38303
38305
  }
38304
38306
  function normalizeUsage(raw) {
38305
- if (!raw) return;
38306
- const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
38307
- const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
38308
- const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
38309
- const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
38310
- const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
38311
- const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
38312
- if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
38313
- return {
38314
- input,
38315
- output,
38316
- cacheRead,
38317
- cacheWrite,
38318
- total
38319
- };
38307
+ return normalizeBillingUsage(raw);
38320
38308
  }
38321
38309
  function derivePromptTokens(usage) {
38322
38310
  if (!usage) return;
@@ -38370,6 +38358,7 @@ async function updateSessionStoreAfterAgentRun(params) {
38370
38358
  model: modelUsed
38371
38359
  });
38372
38360
  if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
38361
+ next.authProfileFallback = result.meta.agentMeta?.authProfileFallback ?? null; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
38373
38362
  if (isCliProvider(providerUsed, cfg)) {
38374
38363
  const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
38375
38364
  if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
@@ -52897,62 +52886,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
52897
52886
  } catch {
52898
52887
  return;
52899
52888
  }
52900
- if (!fs.existsSync(logPath)) return;
52901
- try {
52902
- const TAIL_BYTES = 8192;
52903
- const stat = fs.statSync(logPath);
52904
- const offset = Math.max(0, stat.size - TAIL_BYTES);
52905
- const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
52906
- const fd = fs.openSync(logPath, "r");
52907
- try {
52908
- fs.readSync(fd, buf, 0, buf.length, offset);
52909
- } finally {
52910
- fs.closeSync(fd);
52911
- }
52912
- const tail = buf.toString("utf-8");
52913
- const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
52914
- let input = 0;
52915
- let output = 0;
52916
- let promptTokens = 0;
52917
- let model;
52918
- let lastUsage;
52919
- for (const line of lines) {
52920
- if (!line.trim()) continue;
52921
- try {
52922
- const parsed = JSON.parse(line);
52923
- const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
52924
- if (usage) lastUsage = usage;
52925
- model = parsed.message?.model ?? parsed.model ?? model;
52926
- } catch {}
52927
- }
52928
- if (!lastUsage) return;
52929
- input = lastUsage.input ?? 0;
52930
- output = lastUsage.output ?? 0;
52931
- promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
52932
- const total = lastUsage.total ?? promptTokens + output;
52933
- if (promptTokens === 0 && total === 0) return;
52934
- return {
52935
- input,
52936
- output,
52937
- promptTokens,
52938
- total,
52939
- model
52940
- };
52941
- } catch {
52942
- return;
52943
- }
52889
+ return readLatestBillingUsage(logPath);
52944
52890
  };
52945
- const formatUsagePair = (input, output) => {
52946
- if (input == null && output == null) return null;
52947
- return `๐Ÿงฎ Tokens: ${typeof input === "number" ? formatTokenCount$1(input) : "?"} in / ${typeof output === "number" ? formatTokenCount$1(output) : "?"} out`;
52891
+ const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
52892
+ if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
52893
+ const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
52894
+ return `๐Ÿงฎ Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
52948
52895
  };
52949
- const formatCacheLine = (input, cacheRead, cacheWrite) => {
52896
+ const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
52950
52897
  if (!cacheRead && !cacheWrite) return null;
52951
- if ((typeof cacheRead !== "number" || cacheRead <= 0) && (typeof cacheWrite !== "number" || cacheWrite <= 0)) return null;
52952
- const cachedLabel = typeof cacheRead === "number" ? formatTokenCount$1(cacheRead) : "0";
52953
- const newLabel = typeof cacheWrite === "number" ? formatTokenCount$1(cacheWrite) : "0";
52954
- const totalInput = (typeof cacheRead === "number" ? cacheRead : 0) + (typeof cacheWrite === "number" ? cacheWrite : 0) + (typeof input === "number" ? input : 0);
52955
- return `๐Ÿ—„๏ธ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit ยท ${cachedLabel} cached, ${newLabel} new`;
52898
+ const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
52899
+ const count = value => (value ?? 0).toLocaleString("en-US");
52900
+ const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
52901
+ return `๐Ÿ—„๏ธ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit ยท ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
52956
52902
  };
52957
52903
  const formatMediaUnderstandingLine = (decisions) => {
52958
52904
  if (!decisions || decisions.length === 0) return null;
@@ -53031,10 +52977,14 @@ function buildStatusMessage(args) {
53031
52977
  let outputTokens = entry?.outputTokens;
53032
52978
  let cacheRead = entry?.cacheRead;
53033
52979
  let cacheWrite = entry?.cacheWrite;
52980
+ let billingUsage;
53034
52981
  let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
53035
- if (args.includeTranscriptUsage) {
52982
+ if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
53036
52983
  const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
53037
52984
  if (logUsage) {
52985
+ billingUsage = logUsage;
52986
+ cacheRead = logUsage.cacheRead ?? 0;
52987
+ cacheWrite = logUsage.cacheWrite ?? 0;
53038
52988
  const candidate = logUsage.promptTokens || logUsage.total;
53039
52989
  if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
53040
52990
  if (!entry?.model && logUsage.model) {
@@ -53053,8 +53003,10 @@ function buildStatusMessage(args) {
53053
53003
  model: logUsage.model,
53054
53004
  fallbackContextTokens: contextTokens ?? void 0
53055
53005
  }) ?? contextTokens;
53056
- if (!inputTokens || inputTokens === 0) inputTokens = logUsage.input;
53057
- if (!outputTokens || outputTokens === 0) outputTokens = logUsage.output;
53006
+ inputTokens = logUsage.input ?? 0;
53007
+ outputTokens = logUsage.output ?? 0;
53008
+ if (logUsage.provider) activeProvider = logUsage.provider;
53009
+ if (logUsage.model) activeModel = logUsage.model;
53058
53010
  }
53059
53011
  }
53060
53012
  const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
@@ -53090,21 +53042,14 @@ function buildStatusMessage(args) {
53090
53042
  state: entry
53091
53043
  });
53092
53044
  const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
53093
- const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
53045
+ const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
53094
53046
  const costConfig = showCost ? resolveModelCostConfig({
53095
53047
  provider: activeProvider,
53096
53048
  model: activeModel,
53097
53049
  config: args.config
53098
53050
  }) : void 0;
53099
- const hasUsage = typeof inputTokens === "number" || typeof outputTokens === "number";
53100
- const cost = showCost && hasUsage ? estimateUsageCost({
53101
- usage: {
53102
- input: inputTokens ?? void 0,
53103
- output: outputTokens ?? void 0
53104
- },
53105
- cost: costConfig
53106
- }) : void 0;
53107
- const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
53051
+ const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
53052
+ billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
53108
53053
  const selectedAuthLabel = selectedAuthLabelValue ? ` ยท ๐Ÿ”‘ ${selectedAuthLabelValue}` : "";
53109
53054
  const channelModelNote = (() => {
53110
53055
  if (!args.config || !entry) return;
@@ -53136,9 +53081,9 @@ function buildStatusMessage(args) {
53136
53081
  const fallbackLine = fallbackState.active ? `โ†ช๏ธ Fallback: ${activeModelLabel}${showFallbackAuth ? ` ยท ๐Ÿ”‘ ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
53137
53082
  const commit = resolveCommitHash();
53138
53083
  const versionLine = `๐Ÿฆž Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
53139
- const usagePair = formatUsagePair(inputTokens, outputTokens);
53140
- const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
53141
- const costLine = costLabel ? `๐Ÿ’ต Cost: ${costLabel}` : null;
53084
+ const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
53085
+ const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
53086
+ const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
53142
53087
  const usageCostLine = usagePair && costLine ? `${usagePair} ยท ${costLine}` : usagePair ?? costLine;
53143
53088
  const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
53144
53089
  const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
@@ -82724,6 +82669,8 @@ function normalizeAssistantUsageSnapshot(usage) {
82724
82669
  cacheRead,
82725
82670
  cacheWrite,
82726
82671
  totalTokens,
82672
+ ...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
82673
+ ...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
82727
82674
  ...cost ? { cost } : {}
82728
82675
  };
82729
82676
  }
@@ -89911,6 +89858,7 @@ async function runEmbeddedPiAgent(params) {
89911
89858
  });
89912
89859
  if (lockedProfileId && !profileOrder.includes(lockedProfileId)) throw new Error(`Auth profile "${lockedProfileId}" is not configured for ${provider}.`);
89913
89860
  const profileCandidates = lockedProfileId ? [lockedProfileId] : profileOrder.length > 0 ? profileOrder : [void 0];
89861
+ const subscriptionAuth = createSubscriptionAuthTracker({ provider, model: modelId, store: authStore, preferredProfileId, lockedProfileId }); // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
89914
89862
  let profileIndex = 0;
89915
89863
  const initialThinkLevel = params.thinkLevel ?? "off";
89916
89864
  let thinkLevel = initialThinkLevel;
@@ -90042,7 +89990,8 @@ async function runEmbeddedPiAgent(params) {
90042
89990
  } else authStorage.setRuntimeApiKey(model.provider, apiKeyInfo.apiKey);
90043
89991
  lastProfileId = apiKeyInfo.profileId;
90044
89992
  };
90045
- const advanceAuthProfile = async () => {
89993
+ const advanceAuthProfile = async (reason) => {
89994
+ subscriptionAuth.failed(profileCandidates[profileIndex], reason);
90046
89995
  if (lockedProfileId) return false;
90047
89996
  let nextIndex = profileIndex + 1;
90048
89997
  while (nextIndex < profileCandidates.length) {
@@ -90092,7 +90041,7 @@ async function runEmbeddedPiAgent(params) {
90092
90041
  allInCooldown: false,
90093
90042
  error: err
90094
90043
  });
90095
- if (!await advanceAuthProfile()) throwAuthProfileFailover({
90044
+ if (!await advanceAuthProfile(/refresh/i.test(String(err)) ? "oauth_refresh_failed" : "credential_unavailable")) throwAuthProfileFailover({
90096
90045
  allInCooldown: false,
90097
90046
  error: err
90098
90047
  });
@@ -90461,7 +90410,7 @@ async function runEmbeddedPiAgent(params) {
90461
90410
  reason: promptProfileFailureReason
90462
90411
  });
90463
90412
  const promptFailoverFailure = isFailoverErrorMessage(errorText);
90464
- if (promptFailoverFailure && promptFailoverReason !== "timeout" && await advanceAuthProfile()) {
90413
+ if (promptFailoverFailure && promptFailoverReason !== "timeout" && await advanceAuthProfile(promptFailoverReason)) {
90465
90414
  await maybeBackoffBeforeOverloadFailover(promptFailoverReason);
90466
90415
  continue;
90467
90416
  }
@@ -90524,7 +90473,7 @@ async function runEmbeddedPiAgent(params) {
90524
90473
  if (timedOut && !isProbeSession) log$7.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
90525
90474
  if (cloudCodeAssistFormatError) log$7.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
90526
90475
  }
90527
- if (await advanceAuthProfile()) {
90476
+ if (await advanceAuthProfile(timedOut ? "timeout" : assistantFailoverReason)) {
90528
90477
  await maybeBackoffBeforeOverloadFailover(assistantFailoverReason);
90529
90478
  continue;
90530
90479
  }
@@ -90558,6 +90507,7 @@ async function runEmbeddedPiAgent(params) {
90558
90507
  lastCallUsage: lastCallUsage ?? void 0,
90559
90508
  promptTokens,
90560
90509
  compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
90510
+ authProfileFallback: subscriptionAuth.result(lastProfileId), // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
90561
90511
  authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
90562
90512
  };
90563
90513
  const payloads = buildEmbeddedRunPayloads({
@@ -101496,6 +101446,7 @@ async function persistSessionUsageUpdate(params) {
101496
101446
  modelProvider: params.providerUsed ?? entry.modelProvider,
101497
101447
  model: params.modelUsed ?? entry.model,
101498
101448
  authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
101449
+ authProfileFallback: params.authProfileFallback ?? null, // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
101499
101450
  contextTokens: resolvedContextTokens,
101500
101451
  systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
101501
101452
  updatedAt: Date.now()
@@ -101776,6 +101727,7 @@ function createFollowupRunner(params) {
101776
101727
  modelUsed,
101777
101728
  providerUsed: fallbackProvider,
101778
101729
  authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
101730
+ authProfileFallback: runResult.meta?.agentMeta?.authProfileFallback, // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
101779
101731
  contextTokensUsed,
101780
101732
  systemPromptReport: runResult.meta?.systemPromptReport,
101781
101733
  logLabel: "followup"
@@ -102114,6 +102066,7 @@ async function runReplyAgent(params) {
102114
102066
  modelUsed,
102115
102067
  providerUsed,
102116
102068
  authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
102069
+ authProfileFallback: runResult.meta?.agentMeta?.authProfileFallback, // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
102117
102070
  contextTokensUsed,
102118
102071
  systemPromptReport: runResult.meta?.systemPromptReport,
102119
102072
  cliSessionId
@@ -4060,7 +4060,8 @@ const ModelDefinitionSchema = z.object({
4060
4060
  input: z.number().optional(),
4061
4061
  output: z.number().optional(),
4062
4062
  cacheRead: z.number().optional(),
4063
- cacheWrite: z.number().optional()
4063
+ cacheWrite: z.number().optional(),
4064
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
4064
4065
  }).strict().optional(),
4065
4066
  contextWindow: z.number().positive().optional(),
4066
4067
  maxTokens: z.number().positive().optional(),
@@ -4630,7 +4630,8 @@ const ModelDefinitionSchema = z.object({
4630
4630
  input: z.number().optional(),
4631
4631
  output: z.number().optional(),
4632
4632
  cacheRead: z.number().optional(),
4633
- cacheWrite: z.number().optional()
4633
+ cacheWrite: z.number().optional(),
4634
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
4634
4635
  }).strict().optional(),
4635
4636
  contextWindow: z.number().positive().optional(),
4636
4637
  maxTokens: z.number().positive().optional(),
@@ -4781,7 +4781,8 @@ const ModelDefinitionSchema = z.object({
4781
4781
  input: z.number().optional(),
4782
4782
  output: z.number().optional(),
4783
4783
  cacheRead: z.number().optional(),
4784
- cacheWrite: z.number().optional()
4784
+ cacheWrite: z.number().optional(),
4785
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
4785
4786
  }).strict().optional(),
4786
4787
  contextWindow: z.number().positive().optional(),
4787
4788
  maxTokens: z.number().positive().optional(),
@@ -3087,7 +3087,8 @@ const ModelDefinitionSchema = z.object({
3087
3087
  input: z.number().optional(),
3088
3088
  output: z.number().optional(),
3089
3089
  cacheRead: z.number().optional(),
3090
- cacheWrite: z.number().optional()
3090
+ cacheWrite: z.number().optional(),
3091
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
3091
3092
  }).strict().optional(),
3092
3093
  contextWindow: z.number().positive().optional(),
3093
3094
  maxTokens: z.number().positive().optional(),
@@ -2846,7 +2846,8 @@ const ModelDefinitionSchema = z.object({
2846
2846
  input: z.number().optional(),
2847
2847
  output: z.number().optional(),
2848
2848
  cacheRead: z.number().optional(),
2849
- cacheWrite: z.number().optional()
2849
+ cacheWrite: z.number().optional(),
2850
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
2850
2851
  }).strict().optional(),
2851
2852
  contextWindow: z.number().positive().optional(),
2852
2853
  maxTokens: z.number().positive().optional(),
@@ -5,6 +5,7 @@ export type ModelCostConfig = {
5
5
  output: number;
6
6
  cacheRead: number;
7
7
  cacheWrite: number;
8
+ cacheWrite1h?: number;
8
9
  };
9
10
  export type UsageTotals = {
10
11
  input?: number;
@@ -181,7 +181,8 @@ const ModelDefinitionSchema = z.object({
181
181
  input: z.number().optional(),
182
182
  output: z.number().optional(),
183
183
  cacheRead: z.number().optional(),
184
- cacheWrite: z.number().optional()
184
+ cacheWrite: z.number().optional(),
185
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
185
186
  }).strict().optional(),
186
187
  contextWindow: z.number().positive().optional(),
187
188
  maxTokens: z.number().positive().optional(),
@@ -3466,7 +3466,8 @@ const ModelDefinitionSchema = z.object({
3466
3466
  input: z.number().optional(),
3467
3467
  output: z.number().optional(),
3468
3468
  cacheRead: z.number().optional(),
3469
- cacheWrite: z.number().optional()
3469
+ cacheWrite: z.number().optional(),
3470
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
3470
3471
  }).strict().optional(),
3471
3472
  contextWindow: z.number().positive().optional(),
3472
3473
  maxTokens: z.number().positive().optional(),
@@ -3505,7 +3505,8 @@ const ModelDefinitionSchema = z.object({
3505
3505
  input: z.number().optional(),
3506
3506
  output: z.number().optional(),
3507
3507
  cacheRead: z.number().optional(),
3508
- cacheWrite: z.number().optional()
3508
+ cacheWrite: z.number().optional(),
3509
+ cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
3509
3510
  }).strict().optional(),
3510
3511
  contextWindow: z.number().positive().optional(),
3511
3512
  maxTokens: z.number().positive().optional(),
@@ -1,3 +1,5 @@
1
+ import { createSubscriptionAuthTracker, formatAuthProfileFallback } from "./anthropic-auth-runtime.js"; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
2
+ import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/reply-C5LKjXcC.js
1
3
  import { importOptional66 } from "./optional-module.js";
2
4
  const JOHNNESS_PATCH_SLIM_TREE_66 = true;
3
5
  import { createImageGenerateTool } from "./image-generate.js";
@@ -25832,7 +25834,7 @@ function resolveModelAuthLabel(params) {
25832
25834
  });
25833
25835
  if (profile.type === "oauth") return `oauth${label ? ` (${label})` : ""}`;
25834
25836
  if (profile.type === "token") return `token${label ? ` (${label})` : ""}`;
25835
- return `api-key${label ? ` (${label})` : ""}`;
25837
+ return `api-key${label ? ` (${label})` : ""}${formatAuthProfileFallback(params.sessionEntry, profileId)}`;
25836
25838
  }
25837
25839
  const envKey = resolveEnvApiKey(providerKey);
25838
25840
  if (envKey?.apiKey) {
@@ -32091,6 +32093,7 @@ async function updateSessionStoreAfterAgentRun(params) {
32091
32093
  model: modelUsed
32092
32094
  });
32093
32095
  if (result.meta.agentMeta?.authProfileId) next.authProfileServed = result.meta.agentMeta.authProfileId; // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
32096
+ next.authProfileFallback = result.meta.agentMeta?.authProfileFallback ?? null; // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
32094
32097
  if (isCliProvider(providerUsed, cfg)) {
32095
32098
  const cliSessionId = result.meta.agentMeta?.sessionId?.trim();
32096
32099
  if (cliSessionId) setCliSessionId(next, providerUsed, cliSessionId);
@@ -46583,62 +46586,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
46583
46586
  } catch {
46584
46587
  return;
46585
46588
  }
46586
- if (!fs.existsSync(logPath)) return;
46587
- try {
46588
- const TAIL_BYTES = 8192;
46589
- const stat = fs.statSync(logPath);
46590
- const offset = Math.max(0, stat.size - TAIL_BYTES);
46591
- const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
46592
- const fd = fs.openSync(logPath, "r");
46593
- try {
46594
- fs.readSync(fd, buf, 0, buf.length, offset);
46595
- } finally {
46596
- fs.closeSync(fd);
46597
- }
46598
- const tail = buf.toString("utf-8");
46599
- const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
46600
- let input = 0;
46601
- let output = 0;
46602
- let promptTokens = 0;
46603
- let model;
46604
- let lastUsage;
46605
- for (const line of lines) {
46606
- if (!line.trim()) continue;
46607
- try {
46608
- const parsed = JSON.parse(line);
46609
- const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
46610
- if (usage) lastUsage = usage;
46611
- model = parsed.message?.model ?? parsed.model ?? model;
46612
- } catch {}
46613
- }
46614
- if (!lastUsage) return;
46615
- input = lastUsage.input ?? 0;
46616
- output = lastUsage.output ?? 0;
46617
- promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
46618
- const total = lastUsage.total ?? promptTokens + output;
46619
- if (promptTokens === 0 && total === 0) return;
46620
- return {
46621
- input,
46622
- output,
46623
- promptTokens,
46624
- total,
46625
- model
46626
- };
46627
- } catch {
46628
- return;
46629
- }
46589
+ return readLatestBillingUsage(logPath);
46630
46590
  };
46631
- const formatUsagePair = (input, output) => {
46632
- if (input == null && output == null) return null;
46633
- return `๐Ÿงฎ Tokens: ${typeof input === "number" ? formatTokenCount$1(input) : "?"} in / ${typeof output === "number" ? formatTokenCount$1(output) : "?"} out`;
46591
+ const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
46592
+ if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
46593
+ const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
46594
+ return `๐Ÿงฎ Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
46634
46595
  };
46635
- const formatCacheLine = (input, cacheRead, cacheWrite) => {
46596
+ const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
46636
46597
  if (!cacheRead && !cacheWrite) return null;
46637
- if ((typeof cacheRead !== "number" || cacheRead <= 0) && (typeof cacheWrite !== "number" || cacheWrite <= 0)) return null;
46638
- const cachedLabel = typeof cacheRead === "number" ? formatTokenCount$1(cacheRead) : "0";
46639
- const newLabel = typeof cacheWrite === "number" ? formatTokenCount$1(cacheWrite) : "0";
46640
- const totalInput = (typeof cacheRead === "number" ? cacheRead : 0) + (typeof cacheWrite === "number" ? cacheWrite : 0) + (typeof input === "number" ? input : 0);
46641
- return `๐Ÿ—„๏ธ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit ยท ${cachedLabel} cached, ${newLabel} new`;
46598
+ const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
46599
+ const count = value => (value ?? 0).toLocaleString("en-US");
46600
+ const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
46601
+ return `๐Ÿ—„๏ธ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit ยท ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
46642
46602
  };
46643
46603
  const formatMediaUnderstandingLine = (decisions) => {
46644
46604
  if (!decisions || decisions.length === 0) return null;
@@ -46717,10 +46677,14 @@ function buildStatusMessage(args) {
46717
46677
  let outputTokens = entry?.outputTokens;
46718
46678
  let cacheRead = entry?.cacheRead;
46719
46679
  let cacheWrite = entry?.cacheWrite;
46680
+ let billingUsage;
46720
46681
  let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
46721
- if (args.includeTranscriptUsage) {
46682
+ if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
46722
46683
  const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
46723
46684
  if (logUsage) {
46685
+ billingUsage = logUsage;
46686
+ cacheRead = logUsage.cacheRead ?? 0;
46687
+ cacheWrite = logUsage.cacheWrite ?? 0;
46724
46688
  const candidate = logUsage.promptTokens || logUsage.total;
46725
46689
  if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
46726
46690
  if (!entry?.model && logUsage.model) {
@@ -46739,8 +46703,10 @@ function buildStatusMessage(args) {
46739
46703
  model: logUsage.model,
46740
46704
  fallbackContextTokens: contextTokens ?? void 0
46741
46705
  }) ?? contextTokens;
46742
- if (!inputTokens || inputTokens === 0) inputTokens = logUsage.input;
46743
- if (!outputTokens || outputTokens === 0) outputTokens = logUsage.output;
46706
+ inputTokens = logUsage.input ?? 0;
46707
+ outputTokens = logUsage.output ?? 0;
46708
+ if (logUsage.provider) activeProvider = logUsage.provider;
46709
+ if (logUsage.model) activeModel = logUsage.model;
46744
46710
  }
46745
46711
  }
46746
46712
  const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
@@ -46776,21 +46742,14 @@ function buildStatusMessage(args) {
46776
46742
  state: entry
46777
46743
  });
46778
46744
  const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
46779
- const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
46745
+ const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
46780
46746
  const costConfig = showCost ? resolveModelCostConfig({
46781
46747
  provider: activeProvider,
46782
46748
  model: activeModel,
46783
46749
  config: args.config
46784
46750
  }) : void 0;
46785
- const hasUsage = typeof inputTokens === "number" || typeof outputTokens === "number";
46786
- const cost = showCost && hasUsage ? estimateUsageCost({
46787
- usage: {
46788
- input: inputTokens ?? void 0,
46789
- output: outputTokens ?? void 0
46790
- },
46791
- cost: costConfig
46792
- }) : void 0;
46793
- const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
46751
+ const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
46752
+ billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
46794
46753
  const selectedAuthLabel = selectedAuthLabelValue ? ` ยท ๐Ÿ”‘ ${selectedAuthLabelValue}` : "";
46795
46754
  const channelModelNote = (() => {
46796
46755
  if (!args.config || !entry) return;
@@ -46822,9 +46781,9 @@ function buildStatusMessage(args) {
46822
46781
  const fallbackLine = fallbackState.active ? `โ†ช๏ธ Fallback: ${activeModelLabel}${showFallbackAuth ? ` ยท ๐Ÿ”‘ ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
46823
46782
  const commit = resolveCommitHash();
46824
46783
  const versionLine = `๐Ÿฆž Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
46825
- const usagePair = formatUsagePair(inputTokens, outputTokens);
46826
- const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
46827
- const costLine = costLabel ? `๐Ÿ’ต Cost: ${costLabel}` : null;
46784
+ const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
46785
+ const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
46786
+ const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
46828
46787
  const usageCostLine = usagePair && costLine ? `${usagePair} ยท ${costLine}` : usagePair ?? costLine;
46829
46788
  const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
46830
46789
  const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
@@ -74740,6 +74699,8 @@ function normalizeAssistantUsageSnapshot(usage) {
74740
74699
  cacheRead,
74741
74700
  cacheWrite,
74742
74701
  totalTokens,
74702
+ ...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
74703
+ ...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
74743
74704
  ...cost ? { cost } : {}
74744
74705
  };
74745
74706
  }
@@ -82085,6 +82046,7 @@ async function runEmbeddedPiAgent(params) {
82085
82046
  });
82086
82047
  if (lockedProfileId && !profileOrder.includes(lockedProfileId)) throw new Error(`Auth profile "${lockedProfileId}" is not configured for ${provider}.`);
82087
82048
  const profileCandidates = lockedProfileId ? [lockedProfileId] : profileOrder.length > 0 ? profileOrder : [void 0];
82049
+ const subscriptionAuth = createSubscriptionAuthTracker({ provider, model: modelId, store: authStore, preferredProfileId, lockedProfileId }); // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
82088
82050
  let profileIndex = 0;
82089
82051
  const initialThinkLevel = params.thinkLevel ?? "off";
82090
82052
  let thinkLevel = initialThinkLevel;
@@ -82216,7 +82178,8 @@ async function runEmbeddedPiAgent(params) {
82216
82178
  } else authStorage.setRuntimeApiKey(model.provider, apiKeyInfo.apiKey);
82217
82179
  lastProfileId = apiKeyInfo.profileId;
82218
82180
  };
82219
- const advanceAuthProfile = async () => {
82181
+ const advanceAuthProfile = async (reason) => {
82182
+ subscriptionAuth.failed(profileCandidates[profileIndex], reason);
82220
82183
  if (lockedProfileId) return false;
82221
82184
  let nextIndex = profileIndex + 1;
82222
82185
  while (nextIndex < profileCandidates.length) {
@@ -82266,7 +82229,7 @@ async function runEmbeddedPiAgent(params) {
82266
82229
  allInCooldown: false,
82267
82230
  error: err
82268
82231
  });
82269
- if (!await advanceAuthProfile()) throwAuthProfileFailover({
82232
+ if (!await advanceAuthProfile(/refresh/i.test(String(err)) ? "oauth_refresh_failed" : "credential_unavailable")) throwAuthProfileFailover({
82270
82233
  allInCooldown: false,
82271
82234
  error: err
82272
82235
  });
@@ -82638,7 +82601,7 @@ async function runEmbeddedPiAgent(params) {
82638
82601
  reason: promptProfileFailureReason
82639
82602
  });
82640
82603
  const promptFailoverFailure = isFailoverErrorMessage(errorText);
82641
- if (promptFailoverFailure && promptFailoverReason !== "timeout" && await advanceAuthProfile()) {
82604
+ if (promptFailoverFailure && promptFailoverReason !== "timeout" && await advanceAuthProfile(promptFailoverReason)) {
82642
82605
  await maybeBackoffBeforeOverloadFailover(promptFailoverReason);
82643
82606
  continue;
82644
82607
  }
@@ -82701,7 +82664,7 @@ async function runEmbeddedPiAgent(params) {
82701
82664
  if (timedOut && !isProbeSession) log$7.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
82702
82665
  if (cloudCodeAssistFormatError) log$7.warn(`Profile ${lastProfileId} hit Cloud Code Assist format error. Tool calls will be sanitized on retry.`);
82703
82666
  }
82704
- if (await advanceAuthProfile()) {
82667
+ if (await advanceAuthProfile(timedOut ? "timeout" : assistantFailoverReason)) {
82705
82668
  await maybeBackoffBeforeOverloadFailover(assistantFailoverReason);
82706
82669
  continue;
82707
82670
  }
@@ -82735,6 +82698,7 @@ async function runEmbeddedPiAgent(params) {
82735
82698
  lastCallUsage: lastCallUsage ?? void 0,
82736
82699
  promptTokens,
82737
82700
  compactionCount: autoCompactionCount > 0 ? autoCompactionCount : void 0,
82701
+ authProfileFallback: subscriptionAuth.result(lastProfileId), // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
82738
82702
  authProfileId: lastProfileId // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89: profile that served this turn
82739
82703
  };
82740
82704
  const payloads = buildEmbeddedRunPayloads({
@@ -93381,6 +93345,7 @@ async function persistSessionUsageUpdate(params) {
93381
93345
  modelProvider: params.providerUsed ?? entry.modelProvider,
93382
93346
  model: params.modelUsed ?? entry.model,
93383
93347
  authProfileServed: params.authProfileServed ?? entry.authProfileServed, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
93348
+ authProfileFallback: params.authProfileFallback ?? null, // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
93384
93349
  contextTokens: resolvedContextTokens,
93385
93350
  systemPromptReport: params.systemPromptReport ?? entry.systemPromptReport,
93386
93351
  updatedAt: Date.now()
@@ -93661,6 +93626,7 @@ function createFollowupRunner(params) {
93661
93626
  modelUsed,
93662
93627
  providerUsed: fallbackProvider,
93663
93628
  authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
93629
+ authProfileFallback: runResult.meta?.agentMeta?.authProfileFallback, // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
93664
93630
  contextTokensUsed,
93665
93631
  systemPromptReport: runResult.meta?.systemPromptReport,
93666
93632
  logLabel: "followup"
@@ -93999,6 +93965,7 @@ async function runReplyAgent(params) {
93999
93965
  modelUsed,
94000
93966
  providerUsed,
94001
93967
  authProfileServed: runResult.meta?.agentMeta?.authProfileId, // JOHNNESS_PATCH_SUBSCRIPTION_ACTIVATE_89
93968
+ authProfileFallback: runResult.meta?.agentMeta?.authProfileFallback, // JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92
94002
93969
  contextTokensUsed,
94003
93970
  systemPromptReport: runResult.meta?.systemPromptReport,
94004
93971
  cliSessionId