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.
- package/CHANGELOG.md +8 -0
- package/README.md +3 -0
- package/dist/auth-profiles-5CHn7vq1.js +4 -2
- package/dist/compact-B247y5Qt.js +28 -69
- package/dist/config-koj5M_EO.js +4 -2
- package/dist/daemon-cli.js +4 -2
- package/dist/model-selection-BGlGpPgM.js +4 -2
- package/dist/model-selection-BU6wl1le.js +4 -2
- package/dist/model-selection-L7RMwsG-.js +4 -2
- package/dist/pi-embedded-C6ITuRXf.js +29 -84
- package/dist/pi-embedded-DoQsYfIY.js +29 -84
- package/dist/plugin-sdk/bluebubbles.js +2 -1
- package/dist/plugin-sdk/config/types.models.d.ts +1 -0
- package/dist/plugin-sdk/config/zod-schema.core.d.ts +3 -0
- package/dist/plugin-sdk/config/zod-schema.d.ts +1 -0
- package/dist/plugin-sdk/config-4Fgm-yEH.js +4 -2
- package/dist/plugin-sdk/config-Di-lyCdh.js +4 -2
- package/dist/plugin-sdk/discord.js +4 -2
- package/dist/plugin-sdk/dispatch-BP0viZiL.js +29 -84
- package/dist/plugin-sdk/dispatch-CQsjmw7g.js +29 -84
- package/dist/plugin-sdk/dispatch-Cerq29sy.js +29 -84
- package/dist/plugin-sdk/dispatch-Cndjtt0g.js +29 -84
- package/dist/plugin-sdk/dispatch-UogiJYul.js +29 -84
- package/dist/plugin-sdk/feishu.js +2 -1
- package/dist/plugin-sdk/googlechat.js +2 -1
- package/dist/plugin-sdk/imessage.js +2 -1
- package/dist/plugin-sdk/model-auth-CX9cPHdC.js +4 -2
- package/dist/plugin-sdk/model-auth-Ciehz0x5.js +4 -2
- package/dist/plugin-sdk/model-auth-DVyo6JSX.js +4 -2
- package/dist/plugin-sdk/model-auth-kiHYHGrs.js +4 -2
- package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +4 -2
- package/dist/plugin-sdk/nostr.js +2 -1
- package/dist/plugin-sdk/reply-DbZnH8-h.js +29 -84
- package/dist/plugin-sdk/signal.js +2 -1
- package/dist/plugin-sdk/slack.js +2 -1
- package/dist/plugin-sdk/telegram.js +2 -1
- package/dist/plugin-sdk/tlon.js +2 -1
- package/dist/plugin-sdk/twitch.js +2 -1
- package/dist/plugin-sdk/utils/usage-format.d.ts +1 -0
- package/dist/plugin-sdk/voice-call.js +2 -1
- package/dist/plugin-sdk/zalo.js +2 -1
- package/dist/plugin-sdk/zalouser.js +2 -1
- package/dist/reply-C5LKjXcC.js +28 -69
- package/dist/session-cost-usage-5CCZbVhO.js +4 -19
- package/dist/session-cost-usage-CkCo2kVx.js +4 -19
- package/dist/usage-billing.js +88 -0
- package/dist/usage-format-CNGi1eHQ.js +6 -11
- package/dist/usage-format-CvaU1ntA.js +6 -11
- package/docs/PATCHES.md +13 -1
- package/docs/providers/anthropic.md +8 -2
- package/docs/reference/token-use.md +11 -1
- package/models/models.json +33 -33
- package/node_modules/@mariozechner/pi-ai/dist/models.d.ts +1 -0
- package/node_modules/@mariozechner/pi-ai/dist/models.generated.js +32 -32
- package/node_modules/@mariozechner/pi-ai/dist/models.js +16 -5
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +1 -1
- package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +1 -1
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
- package/node_modules/@mariozechner/pi-ai/dist/types.d.ts +3 -0
- package/node_modules/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
- package/package.json +1 -1
- package/scripts/models-sync.mjs +1 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.d.ts +25 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.generated.js +32 -32
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.js +16 -5
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google-vertex.js +371 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google.js +1 -1
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/types.d.ts +282 -0
- 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/plugin-sdk/dispatch-Cerq29sy.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";
|
|
@@ -34654,21 +34655,7 @@ function hasNonzeroUsage(usage) {
|
|
|
34654
34655
|
].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
|
|
34655
34656
|
}
|
|
34656
34657
|
function normalizeUsage(raw) {
|
|
34657
|
-
|
|
34658
|
-
const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
|
|
34659
|
-
const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
|
|
34660
|
-
const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
|
|
34661
|
-
const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
|
|
34662
|
-
const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
|
|
34663
|
-
const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
|
|
34664
|
-
if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
|
|
34665
|
-
return {
|
|
34666
|
-
input,
|
|
34667
|
-
output,
|
|
34668
|
-
cacheRead,
|
|
34669
|
-
cacheWrite,
|
|
34670
|
-
total
|
|
34671
|
-
};
|
|
34658
|
+
return normalizeBillingUsage(raw);
|
|
34672
34659
|
}
|
|
34673
34660
|
function derivePromptTokens(usage) {
|
|
34674
34661
|
if (!usage) return;
|
|
@@ -49202,62 +49189,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
|
|
|
49202
49189
|
} catch {
|
|
49203
49190
|
return;
|
|
49204
49191
|
}
|
|
49205
|
-
|
|
49206
|
-
try {
|
|
49207
|
-
const TAIL_BYTES = 8192;
|
|
49208
|
-
const stat = fs.statSync(logPath);
|
|
49209
|
-
const offset = Math.max(0, stat.size - TAIL_BYTES);
|
|
49210
|
-
const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
|
|
49211
|
-
const fd = fs.openSync(logPath, "r");
|
|
49212
|
-
try {
|
|
49213
|
-
fs.readSync(fd, buf, 0, buf.length, offset);
|
|
49214
|
-
} finally {
|
|
49215
|
-
fs.closeSync(fd);
|
|
49216
|
-
}
|
|
49217
|
-
const tail = buf.toString("utf-8");
|
|
49218
|
-
const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
|
|
49219
|
-
let input = 0;
|
|
49220
|
-
let output = 0;
|
|
49221
|
-
let promptTokens = 0;
|
|
49222
|
-
let model;
|
|
49223
|
-
let lastUsage;
|
|
49224
|
-
for (const line of lines) {
|
|
49225
|
-
if (!line.trim()) continue;
|
|
49226
|
-
try {
|
|
49227
|
-
const parsed = JSON.parse(line);
|
|
49228
|
-
const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
|
|
49229
|
-
if (usage) lastUsage = usage;
|
|
49230
|
-
model = parsed.message?.model ?? parsed.model ?? model;
|
|
49231
|
-
} catch {}
|
|
49232
|
-
}
|
|
49233
|
-
if (!lastUsage) return;
|
|
49234
|
-
input = lastUsage.input ?? 0;
|
|
49235
|
-
output = lastUsage.output ?? 0;
|
|
49236
|
-
promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
|
|
49237
|
-
const total = lastUsage.total ?? promptTokens + output;
|
|
49238
|
-
if (promptTokens === 0 && total === 0) return;
|
|
49239
|
-
return {
|
|
49240
|
-
input,
|
|
49241
|
-
output,
|
|
49242
|
-
promptTokens,
|
|
49243
|
-
total,
|
|
49244
|
-
model
|
|
49245
|
-
};
|
|
49246
|
-
} catch {
|
|
49247
|
-
return;
|
|
49248
|
-
}
|
|
49192
|
+
return readLatestBillingUsage(logPath);
|
|
49249
49193
|
};
|
|
49250
|
-
const formatUsagePair = (input, output) => {
|
|
49251
|
-
if (input == null && output == null) return null;
|
|
49252
|
-
|
|
49194
|
+
const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
|
|
49195
|
+
if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
|
|
49196
|
+
const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
|
|
49197
|
+
return `🧮 Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
|
|
49253
49198
|
};
|
|
49254
|
-
const formatCacheLine = (input, cacheRead, cacheWrite) => {
|
|
49199
|
+
const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
|
|
49255
49200
|
if (!cacheRead && !cacheWrite) return null;
|
|
49256
|
-
|
|
49257
|
-
const
|
|
49258
|
-
const
|
|
49259
|
-
|
|
49260
|
-
return `🗄️ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit · ${cachedLabel} cached, ${newLabel} new`;
|
|
49201
|
+
const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
|
|
49202
|
+
const count = value => (value ?? 0).toLocaleString("en-US");
|
|
49203
|
+
const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
|
|
49204
|
+
return `🗄️ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit · ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
|
|
49261
49205
|
};
|
|
49262
49206
|
const formatMediaUnderstandingLine = (decisions) => {
|
|
49263
49207
|
if (!decisions || decisions.length === 0) return null;
|
|
@@ -49336,10 +49280,14 @@ function buildStatusMessage(args) {
|
|
|
49336
49280
|
let outputTokens = entry?.outputTokens;
|
|
49337
49281
|
let cacheRead = entry?.cacheRead;
|
|
49338
49282
|
let cacheWrite = entry?.cacheWrite;
|
|
49283
|
+
let billingUsage;
|
|
49339
49284
|
let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
|
|
49340
|
-
if (
|
|
49285
|
+
if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
|
|
49341
49286
|
const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
|
|
49342
49287
|
if (logUsage) {
|
|
49288
|
+
billingUsage = logUsage;
|
|
49289
|
+
cacheRead = logUsage.cacheRead ?? 0;
|
|
49290
|
+
cacheWrite = logUsage.cacheWrite ?? 0;
|
|
49343
49291
|
const candidate = logUsage.promptTokens || logUsage.total;
|
|
49344
49292
|
if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
|
|
49345
49293
|
if (!entry?.model && logUsage.model) {
|
|
@@ -49358,8 +49306,10 @@ function buildStatusMessage(args) {
|
|
|
49358
49306
|
model: logUsage.model,
|
|
49359
49307
|
fallbackContextTokens: contextTokens ?? void 0
|
|
49360
49308
|
}) ?? contextTokens;
|
|
49361
|
-
|
|
49362
|
-
|
|
49309
|
+
inputTokens = logUsage.input ?? 0;
|
|
49310
|
+
outputTokens = logUsage.output ?? 0;
|
|
49311
|
+
if (logUsage.provider) activeProvider = logUsage.provider;
|
|
49312
|
+
if (logUsage.model) activeModel = logUsage.model;
|
|
49363
49313
|
}
|
|
49364
49314
|
}
|
|
49365
49315
|
const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
|
|
@@ -49395,21 +49345,14 @@ function buildStatusMessage(args) {
|
|
|
49395
49345
|
state: entry
|
|
49396
49346
|
});
|
|
49397
49347
|
const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
|
|
49398
|
-
const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
|
|
49348
|
+
const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
|
|
49399
49349
|
const costConfig = showCost ? resolveModelCostConfig({
|
|
49400
49350
|
provider: activeProvider,
|
|
49401
49351
|
model: activeModel,
|
|
49402
49352
|
config: args.config
|
|
49403
49353
|
}) : void 0;
|
|
49404
|
-
const hasUsage =
|
|
49405
|
-
|
|
49406
|
-
usage: {
|
|
49407
|
-
input: inputTokens ?? void 0,
|
|
49408
|
-
output: outputTokens ?? void 0
|
|
49409
|
-
},
|
|
49410
|
-
cost: costConfig
|
|
49411
|
-
}) : void 0;
|
|
49412
|
-
const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
|
|
49354
|
+
const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
|
|
49355
|
+
billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
|
49413
49356
|
const selectedAuthLabel = selectedAuthLabelValue ? ` · 🔑 ${selectedAuthLabelValue}` : "";
|
|
49414
49357
|
const channelModelNote = (() => {
|
|
49415
49358
|
if (!args.config || !entry) return;
|
|
@@ -49441,9 +49384,9 @@ function buildStatusMessage(args) {
|
|
|
49441
49384
|
const fallbackLine = fallbackState.active ? `↪️ Fallback: ${activeModelLabel}${showFallbackAuth ? ` · 🔑 ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
|
|
49442
49385
|
const commit = resolveCommitHash();
|
|
49443
49386
|
const versionLine = `🦞 Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
|
|
49444
|
-
const usagePair = formatUsagePair(inputTokens, outputTokens);
|
|
49445
|
-
const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
|
|
49446
|
-
const costLine =
|
|
49387
|
+
const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
|
|
49388
|
+
const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
|
|
49389
|
+
const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
|
|
49447
49390
|
const usageCostLine = usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
|
|
49448
49391
|
const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
|
|
49449
49392
|
const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
|
|
@@ -81448,6 +81391,8 @@ function normalizeAssistantUsageSnapshot(usage) {
|
|
|
81448
81391
|
cacheRead,
|
|
81449
81392
|
cacheWrite,
|
|
81450
81393
|
totalTokens,
|
|
81394
|
+
...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
|
|
81395
|
+
...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
|
|
81451
81396
|
...cost ? { cost } : {}
|
|
81452
81397
|
};
|
|
81453
81398
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-Cndjtt0g.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";
|
|
@@ -34325,21 +34326,7 @@ function hasNonzeroUsage(usage) {
|
|
|
34325
34326
|
].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
|
|
34326
34327
|
}
|
|
34327
34328
|
function normalizeUsage(raw) {
|
|
34328
|
-
|
|
34329
|
-
const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
|
|
34330
|
-
const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
|
|
34331
|
-
const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
|
|
34332
|
-
const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
|
|
34333
|
-
const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
|
|
34334
|
-
const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
|
|
34335
|
-
if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
|
|
34336
|
-
return {
|
|
34337
|
-
input,
|
|
34338
|
-
output,
|
|
34339
|
-
cacheRead,
|
|
34340
|
-
cacheWrite,
|
|
34341
|
-
total
|
|
34342
|
-
};
|
|
34329
|
+
return normalizeBillingUsage(raw);
|
|
34343
34330
|
}
|
|
34344
34331
|
function derivePromptTokens(usage) {
|
|
34345
34332
|
if (!usage) return;
|
|
@@ -48852,62 +48839,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
|
|
|
48852
48839
|
} catch {
|
|
48853
48840
|
return;
|
|
48854
48841
|
}
|
|
48855
|
-
|
|
48856
|
-
try {
|
|
48857
|
-
const TAIL_BYTES = 8192;
|
|
48858
|
-
const stat = fs.statSync(logPath);
|
|
48859
|
-
const offset = Math.max(0, stat.size - TAIL_BYTES);
|
|
48860
|
-
const buf = Buffer.alloc(Math.min(TAIL_BYTES, stat.size));
|
|
48861
|
-
const fd = fs.openSync(logPath, "r");
|
|
48862
|
-
try {
|
|
48863
|
-
fs.readSync(fd, buf, 0, buf.length, offset);
|
|
48864
|
-
} finally {
|
|
48865
|
-
fs.closeSync(fd);
|
|
48866
|
-
}
|
|
48867
|
-
const tail = buf.toString("utf-8");
|
|
48868
|
-
const lines = (offset > 0 ? tail.slice(tail.indexOf("\n") + 1) : tail).split(/\n+/);
|
|
48869
|
-
let input = 0;
|
|
48870
|
-
let output = 0;
|
|
48871
|
-
let promptTokens = 0;
|
|
48872
|
-
let model;
|
|
48873
|
-
let lastUsage;
|
|
48874
|
-
for (const line of lines) {
|
|
48875
|
-
if (!line.trim()) continue;
|
|
48876
|
-
try {
|
|
48877
|
-
const parsed = JSON.parse(line);
|
|
48878
|
-
const usage = normalizeUsage(parsed.message?.usage ?? parsed.usage);
|
|
48879
|
-
if (usage) lastUsage = usage;
|
|
48880
|
-
model = parsed.message?.model ?? parsed.model ?? model;
|
|
48881
|
-
} catch {}
|
|
48882
|
-
}
|
|
48883
|
-
if (!lastUsage) return;
|
|
48884
|
-
input = lastUsage.input ?? 0;
|
|
48885
|
-
output = lastUsage.output ?? 0;
|
|
48886
|
-
promptTokens = derivePromptTokens(lastUsage) ?? lastUsage.total ?? input + output;
|
|
48887
|
-
const total = lastUsage.total ?? promptTokens + output;
|
|
48888
|
-
if (promptTokens === 0 && total === 0) return;
|
|
48889
|
-
return {
|
|
48890
|
-
input,
|
|
48891
|
-
output,
|
|
48892
|
-
promptTokens,
|
|
48893
|
-
total,
|
|
48894
|
-
model
|
|
48895
|
-
};
|
|
48896
|
-
} catch {
|
|
48897
|
-
return;
|
|
48898
|
-
}
|
|
48842
|
+
return readLatestBillingUsage(logPath);
|
|
48899
48843
|
};
|
|
48900
|
-
const formatUsagePair = (input, output) => {
|
|
48901
|
-
if (input == null && output == null) return null;
|
|
48902
|
-
|
|
48844
|
+
const formatUsagePair = (input, output, cacheRead, cacheWrite) => {
|
|
48845
|
+
if (input == null && output == null && cacheRead == null && cacheWrite == null) return null;
|
|
48846
|
+
const count = value => typeof value === "number" ? value.toLocaleString("en-US") : "?";
|
|
48847
|
+
return `🧮 Tokens: ${count((input ?? 0) + (cacheWrite ?? 0))} new in / ${count(cacheRead ?? 0)} cached / ${count(output)} out (last API call)`;
|
|
48903
48848
|
};
|
|
48904
|
-
const formatCacheLine = (input, cacheRead, cacheWrite) => {
|
|
48849
|
+
const formatCacheLine = (input, cacheRead, cacheWrite, usage) => {
|
|
48905
48850
|
if (!cacheRead && !cacheWrite) return null;
|
|
48906
|
-
|
|
48907
|
-
const
|
|
48908
|
-
const
|
|
48909
|
-
|
|
48910
|
-
return `🗄️ Cache: ${totalInput > 0 && typeof cacheRead === "number" ? Math.round(cacheRead / totalInput * 100) : 0}% hit · ${cachedLabel} cached, ${newLabel} new`;
|
|
48851
|
+
const total = (input ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0);
|
|
48852
|
+
const count = value => (value ?? 0).toLocaleString("en-US");
|
|
48853
|
+
const ttl = usage?.cacheWrite5m !== undefined || usage?.cacheWrite1h !== undefined ? ` (${count(usage.cacheWrite5m)} 5m / ${count(usage.cacheWrite1h)} 1h)` : "";
|
|
48854
|
+
return `🗄️ Cache: ${total > 0 ? Math.round((cacheRead ?? 0) / total * 100) : 0}% hit · ${count(input)} uncached + ${count(cacheWrite)} written${ttl}`;
|
|
48911
48855
|
};
|
|
48912
48856
|
const formatMediaUnderstandingLine = (decisions) => {
|
|
48913
48857
|
if (!decisions || decisions.length === 0) return null;
|
|
@@ -48986,10 +48930,14 @@ function buildStatusMessage(args) {
|
|
|
48986
48930
|
let outputTokens = entry?.outputTokens;
|
|
48987
48931
|
let cacheRead = entry?.cacheRead;
|
|
48988
48932
|
let cacheWrite = entry?.cacheWrite;
|
|
48933
|
+
let billingUsage;
|
|
48989
48934
|
let totalTokens = entry?.totalTokens ?? (entry?.inputTokens ?? 0) + (entry?.outputTokens ?? 0);
|
|
48990
|
-
if (
|
|
48935
|
+
if (entry?.sessionId) { // Always use a coherent latest API call on both status paths.
|
|
48991
48936
|
const logUsage = readUsageFromSessionLog(entry?.sessionId, entry, args.agentId, args.sessionKey, args.sessionStorePath);
|
|
48992
48937
|
if (logUsage) {
|
|
48938
|
+
billingUsage = logUsage;
|
|
48939
|
+
cacheRead = logUsage.cacheRead ?? 0;
|
|
48940
|
+
cacheWrite = logUsage.cacheWrite ?? 0;
|
|
48993
48941
|
const candidate = logUsage.promptTokens || logUsage.total;
|
|
48994
48942
|
if (!totalTokens || totalTokens === 0 || candidate > totalTokens) totalTokens = candidate;
|
|
48995
48943
|
if (!entry?.model && logUsage.model) {
|
|
@@ -49008,8 +48956,10 @@ function buildStatusMessage(args) {
|
|
|
49008
48956
|
model: logUsage.model,
|
|
49009
48957
|
fallbackContextTokens: contextTokens ?? void 0
|
|
49010
48958
|
}) ?? contextTokens;
|
|
49011
|
-
|
|
49012
|
-
|
|
48959
|
+
inputTokens = logUsage.input ?? 0;
|
|
48960
|
+
outputTokens = logUsage.output ?? 0;
|
|
48961
|
+
if (logUsage.provider) activeProvider = logUsage.provider;
|
|
48962
|
+
if (logUsage.model) activeModel = logUsage.model;
|
|
49013
48963
|
}
|
|
49014
48964
|
}
|
|
49015
48965
|
const thinkLevel = args.resolvedThink ?? args.sessionEntry?.thinkingLevel ?? args.agent?.thinkingDefault ?? "off";
|
|
@@ -49045,21 +48995,14 @@ function buildStatusMessage(args) {
|
|
|
49045
48995
|
state: entry
|
|
49046
48996
|
});
|
|
49047
48997
|
const effectiveCostAuthMode = fallbackState.active ? activeAuthMode : selectedAuthMode ?? activeAuthMode;
|
|
49048
|
-
const showCost = effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
|
|
48998
|
+
const showCost = billingUsage?.cost?.total > 0 || effectiveCostAuthMode === "api-key" || effectiveCostAuthMode === "mixed";
|
|
49049
48999
|
const costConfig = showCost ? resolveModelCostConfig({
|
|
49050
49000
|
provider: activeProvider,
|
|
49051
49001
|
model: activeModel,
|
|
49052
49002
|
config: args.config
|
|
49053
49003
|
}) : void 0;
|
|
49054
|
-
const hasUsage =
|
|
49055
|
-
|
|
49056
|
-
usage: {
|
|
49057
|
-
input: inputTokens ?? void 0,
|
|
49058
|
-
output: outputTokens ?? void 0
|
|
49059
|
-
},
|
|
49060
|
-
cost: costConfig
|
|
49061
|
-
}) : void 0;
|
|
49062
|
-
const costLabel = showCost && hasUsage ? formatUsd(cost) : void 0;
|
|
49004
|
+
const hasUsage = [inputTokens, outputTokens, cacheRead, cacheWrite].some(value => typeof value === "number");
|
|
49005
|
+
billingUsage ??= { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
|
49063
49006
|
const selectedAuthLabel = selectedAuthLabelValue ? ` · 🔑 ${selectedAuthLabelValue}` : "";
|
|
49064
49007
|
const channelModelNote = (() => {
|
|
49065
49008
|
if (!args.config || !entry) return;
|
|
@@ -49091,9 +49034,9 @@ function buildStatusMessage(args) {
|
|
|
49091
49034
|
const fallbackLine = fallbackState.active ? `↪️ Fallback: ${activeModelLabel}${showFallbackAuth ? ` · 🔑 ${activeAuthLabelValue}` : ""} (${fallbackState.reason ?? "selected model unavailable"})` : null;
|
|
49092
49035
|
const commit = resolveCommitHash();
|
|
49093
49036
|
const versionLine = `🦞 Johnness ${VERSION}${commit ? ` (${commit})` : ""}`;
|
|
49094
|
-
const usagePair = formatUsagePair(inputTokens, outputTokens);
|
|
49095
|
-
const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite);
|
|
49096
|
-
const costLine =
|
|
49037
|
+
const usagePair = formatUsagePair(inputTokens, outputTokens, cacheRead, cacheWrite);
|
|
49038
|
+
const cacheLine = formatCacheLine(inputTokens, cacheRead, cacheWrite, billingUsage);
|
|
49039
|
+
const costLine = showCost && hasUsage ? formatBillingCost(billingUsage, costConfig) : null;
|
|
49097
49040
|
const usageCostLine = usagePair && costLine ? `${usagePair} · ${costLine}` : usagePair ?? costLine;
|
|
49098
49041
|
const mediaLine = formatMediaUnderstandingLine(args.mediaDecisions);
|
|
49099
49042
|
const voiceLine = formatVoiceModeLine(args.config, args.sessionEntry);
|
|
@@ -81175,6 +81118,8 @@ function normalizeAssistantUsageSnapshot(usage) {
|
|
|
81175
81118
|
cacheRead,
|
|
81176
81119
|
cacheWrite,
|
|
81177
81120
|
totalTokens,
|
|
81121
|
+
...normalized.cacheWrite5m !== undefined ? { cacheWrite5m: normalized.cacheWrite5m } : {},
|
|
81122
|
+
...normalized.cacheWrite1h !== undefined ? { cacheWrite1h: normalized.cacheWrite1h } : {},
|
|
81178
81123
|
...cost ? { cost } : {}
|
|
81179
81124
|
};
|
|
81180
81125
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost } from "../usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/plugin-sdk/dispatch-UogiJYul.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";
|
|
@@ -34248,21 +34249,7 @@ function hasNonzeroUsage(usage) {
|
|
|
34248
34249
|
].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
|
|
34249
34250
|
}
|
|
34250
34251
|
function normalizeUsage(raw) {
|
|
34251
|
-
|
|
34252
|
-
const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
|
|
34253
|
-
const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
|
|
34254
|
-
const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
|
|
34255
|
-
const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
|
|
34256
|
-
const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
|
|
34257
|
-
const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
|
|
34258
|
-
if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
|
|
34259
|
-
return {
|
|
34260
|
-
input,
|
|
34261
|
-
output,
|
|
34262
|
-
cacheRead,
|
|
34263
|
-
cacheWrite,
|
|
34264
|
-
total
|
|
34265
|
-
};
|
|
34252
|
+
return normalizeBillingUsage(raw);
|
|
34266
34253
|
}
|
|
34267
34254
|
function derivePromptTokens(usage) {
|
|
34268
34255
|
if (!usage) return;
|
|
@@ -48811,62 +48798,19 @@ const readUsageFromSessionLog = (sessionId, sessionEntry, agentId, sessionKey, s
|
|
|
48811
48798
|
} catch {
|
|
48812
48799
|
return;
|
|
48813
48800
|
}
|
|
48814
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48866
|
-
const
|
|
48867
|
-
const
|
|
48868
|
-
|
|
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 (
|
|
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
|
-
|
|
48971
|
-
|
|
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 =
|
|
49014
|
-
|
|
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 =
|
|
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
|
}
|
|
@@ -3603,7 +3603,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
3603
3603
|
input: z.number().optional(),
|
|
3604
3604
|
output: z.number().optional(),
|
|
3605
3605
|
cacheRead: z.number().optional(),
|
|
3606
|
-
cacheWrite: z.number().optional()
|
|
3606
|
+
cacheWrite: z.number().optional(),
|
|
3607
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
3607
3608
|
}).strict().optional(),
|
|
3608
3609
|
contextWindow: z.number().positive().optional(),
|
|
3609
3610
|
maxTokens: z.number().positive().optional(),
|
|
@@ -3780,7 +3780,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
3780
3780
|
input: z.number().optional(),
|
|
3781
3781
|
output: z.number().optional(),
|
|
3782
3782
|
cacheRead: z.number().optional(),
|
|
3783
|
-
cacheWrite: z.number().optional()
|
|
3783
|
+
cacheWrite: z.number().optional(),
|
|
3784
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
3784
3785
|
}).strict().optional(),
|
|
3785
3786
|
contextWindow: z.number().positive().optional(),
|
|
3786
3787
|
maxTokens: z.number().positive().optional(),
|
|
@@ -4065,7 +4065,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
4065
4065
|
input: z.number().optional(),
|
|
4066
4066
|
output: z.number().optional(),
|
|
4067
4067
|
cacheRead: z.number().optional(),
|
|
4068
|
-
cacheWrite: z.number().optional()
|
|
4068
|
+
cacheWrite: z.number().optional(),
|
|
4069
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
4069
4070
|
}).strict().optional(),
|
|
4070
4071
|
contextWindow: z.number().positive().optional(),
|
|
4071
4072
|
maxTokens: z.number().positive().optional(),
|
|
@@ -6047,7 +6047,8 @@ function resolveModelCost(raw) {
|
|
|
6047
6047
|
input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
|
|
6048
6048
|
output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
|
|
6049
6049
|
cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
|
|
6050
|
-
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
|
|
6050
|
+
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
|
|
6051
|
+
...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
6051
6052
|
};
|
|
6052
6053
|
}
|
|
6053
6054
|
function resolveAnthropicDefaultAuthMode(cfg) {
|
|
@@ -11776,7 +11777,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
11776
11777
|
input: z.number().optional(),
|
|
11777
11778
|
output: z.number().optional(),
|
|
11778
11779
|
cacheRead: z.number().optional(),
|
|
11779
|
-
cacheWrite: z.number().optional()
|
|
11780
|
+
cacheWrite: z.number().optional(),
|
|
11781
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
11780
11782
|
}).strict().optional(),
|
|
11781
11783
|
contextWindow: z.number().positive().optional(),
|
|
11782
11784
|
maxTokens: z.number().positive().optional(),
|
|
@@ -5016,7 +5016,8 @@ function resolveModelCost(raw) {
|
|
|
5016
5016
|
input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
|
|
5017
5017
|
output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
|
|
5018
5018
|
cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
|
|
5019
|
-
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
|
|
5019
|
+
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
|
|
5020
|
+
...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
5020
5021
|
};
|
|
5021
5022
|
}
|
|
5022
5023
|
function resolveAnthropicDefaultAuthMode(cfg) {
|
|
@@ -11776,7 +11777,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
11776
11777
|
input: z.number().optional(),
|
|
11777
11778
|
output: z.number().optional(),
|
|
11778
11779
|
cacheRead: z.number().optional(),
|
|
11779
|
-
cacheWrite: z.number().optional()
|
|
11780
|
+
cacheWrite: z.number().optional(),
|
|
11781
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
11780
11782
|
}).strict().optional(),
|
|
11781
11783
|
contextWindow: z.number().positive().optional(),
|
|
11782
11784
|
maxTokens: z.number().positive().optional(),
|
|
@@ -5020,7 +5020,8 @@ function resolveModelCost(raw) {
|
|
|
5020
5020
|
input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
|
|
5021
5021
|
output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
|
|
5022
5022
|
cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
|
|
5023
|
-
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
|
|
5023
|
+
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
|
|
5024
|
+
...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
5024
5025
|
};
|
|
5025
5026
|
}
|
|
5026
5027
|
function resolveAnthropicDefaultAuthMode(cfg) {
|
|
@@ -11780,7 +11781,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
11780
11781
|
input: z.number().optional(),
|
|
11781
11782
|
output: z.number().optional(),
|
|
11782
11783
|
cacheRead: z.number().optional(),
|
|
11783
|
-
cacheWrite: z.number().optional()
|
|
11784
|
+
cacheWrite: z.number().optional(),
|
|
11785
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
11784
11786
|
}).strict().optional(),
|
|
11785
11787
|
contextWindow: z.number().positive().optional(),
|
|
11786
11788
|
maxTokens: z.number().positive().optional(),
|
|
@@ -5020,7 +5020,8 @@ function resolveModelCost(raw) {
|
|
|
5020
5020
|
input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
|
|
5021
5021
|
output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
|
|
5022
5022
|
cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
|
|
5023
|
-
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
|
|
5023
|
+
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite,
|
|
5024
|
+
...typeof raw?.cacheWrite1h === "number" ? { cacheWrite1h: raw.cacheWrite1h } : {} // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
5024
5025
|
};
|
|
5025
5026
|
}
|
|
5026
5027
|
function resolveAnthropicDefaultAuthMode(cfg) {
|
|
@@ -11780,7 +11781,8 @@ const ModelDefinitionSchema = z.object({
|
|
|
11780
11781
|
input: z.number().optional(),
|
|
11781
11782
|
output: z.number().optional(),
|
|
11782
11783
|
cacheRead: z.number().optional(),
|
|
11783
|
-
cacheWrite: z.number().optional()
|
|
11784
|
+
cacheWrite: z.number().optional(),
|
|
11785
|
+
cacheWrite1h: z.number().nonnegative().optional() // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
11784
11786
|
}).strict().optional(),
|
|
11785
11787
|
contextWindow: z.number().positive().optional(),
|
|
11786
11788
|
maxTokens: z.number().positive().optional(),
|