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.
- package/CHANGELOG.md +15 -0
- package/README.md +3 -0
- package/dist/anthropic-auth-runtime.js +62 -0
- package/dist/auth-profiles-5CHn7vq1.js +9 -4
- package/dist/compact-B247y5Qt.js +41 -74
- package/dist/config-koj5M_EO.js +4 -2
- package/dist/daemon-cli.js +4 -2
- package/dist/model-selection-BGlGpPgM.js +9 -4
- package/dist/model-selection-BU6wl1le.js +9 -4
- package/dist/model-selection-L7RMwsG-.js +9 -4
- package/dist/pi-embedded-C6ITuRXf.js +42 -89
- package/dist/pi-embedded-DoQsYfIY.js +42 -89
- 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 +9 -4
- package/dist/plugin-sdk/config-Di-lyCdh.js +9 -4
- package/dist/plugin-sdk/discord.js +4 -2
- package/dist/plugin-sdk/dispatch-BP0viZiL.js +42 -89
- package/dist/plugin-sdk/dispatch-CQsjmw7g.js +42 -89
- package/dist/plugin-sdk/dispatch-Cerq29sy.js +42 -89
- package/dist/plugin-sdk/dispatch-Cndjtt0g.js +42 -89
- package/dist/plugin-sdk/dispatch-UogiJYul.js +42 -89
- 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 +9 -4
- package/dist/plugin-sdk/model-auth-Ciehz0x5.js +9 -4
- package/dist/plugin-sdk/model-auth-DVyo6JSX.js +9 -4
- package/dist/plugin-sdk/model-auth-kiHYHGrs.js +9 -4
- package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +8 -3
- package/dist/plugin-sdk/nostr.js +2 -1
- package/dist/plugin-sdk/reply-DbZnH8-h.js +42 -89
- 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 +41 -74
- 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 +54 -1
- package/docs/providers/anthropic.md +23 -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, billingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/session-cost-usage-5CCZbVhO.js
|
|
1
2
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
3
|
import { n as resolveSessionFilePath, s as resolveSessionTranscriptsDirForAgent } from "./paths-BCX3TKIK.js";
|
|
3
4
|
import { i as stripInboundMetadata, n as stripMessageIdHints, o as countToolResults, s as extractToolCallNames, t as stripEnvelope } from "./chat-envelope-B0leI413.js";
|
|
@@ -38,21 +39,7 @@ function hasNonzeroUsage(usage) {
|
|
|
38
39
|
].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
|
|
39
40
|
}
|
|
40
41
|
function normalizeUsage(raw) {
|
|
41
|
-
|
|
42
|
-
const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
|
|
43
|
-
const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
|
|
44
|
-
const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
|
|
45
|
-
const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
|
|
46
|
-
const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
|
|
47
|
-
const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
|
|
48
|
-
if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
|
|
49
|
-
return {
|
|
50
|
-
input,
|
|
51
|
-
output,
|
|
52
|
-
cacheRead,
|
|
53
|
-
cacheWrite,
|
|
54
|
-
total
|
|
55
|
-
};
|
|
42
|
+
return normalizeBillingUsage(raw);
|
|
56
43
|
}
|
|
57
44
|
function derivePromptTokens(usage) {
|
|
58
45
|
if (!usage) return;
|
|
@@ -226,10 +213,8 @@ async function scanTranscriptFile(params) {
|
|
|
226
213
|
model: entry.model,
|
|
227
214
|
config: params.config
|
|
228
215
|
});
|
|
229
|
-
entry.
|
|
230
|
-
|
|
231
|
-
cost
|
|
232
|
-
});
|
|
216
|
+
entry.costBreakdown = billingCost(entry.usage, cost);
|
|
217
|
+
entry.costTotal = entry.costBreakdown?.total;
|
|
233
218
|
}
|
|
234
219
|
params.onEntry(entry);
|
|
235
220
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeBillingUsage, readLatestBillingUsage, formatBillingCost, billingCost } from "./usage-billing.js"; // JOHNNESS_PATCH_USAGE_BILLING_91 dist/session-cost-usage-CkCo2kVx.js
|
|
1
2
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
3
|
import { n as resolveSessionFilePath, s as resolveSessionTranscriptsDirForAgent } from "./paths-BWOXmNIW.js";
|
|
3
4
|
import { i as stripInboundMetadata, n as stripMessageIdHints, o as countToolResults, s as extractToolCallNames, t as stripEnvelope } from "./chat-envelope-BkySjpPY.js";
|
|
@@ -38,21 +39,7 @@ function hasNonzeroUsage(usage) {
|
|
|
38
39
|
].some((v) => typeof v === "number" && Number.isFinite(v) && v > 0);
|
|
39
40
|
}
|
|
40
41
|
function normalizeUsage(raw) {
|
|
41
|
-
|
|
42
|
-
const rawInput = asFiniteNumber(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens);
|
|
43
|
-
const input = rawInput !== void 0 && rawInput < 0 ? 0 : rawInput;
|
|
44
|
-
const output = asFiniteNumber(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens);
|
|
45
|
-
const cacheRead = asFiniteNumber(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens);
|
|
46
|
-
const cacheWrite = asFiniteNumber(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
|
|
47
|
-
const total = asFiniteNumber(raw.total ?? raw.totalTokens ?? raw.total_tokens);
|
|
48
|
-
if (input === void 0 && output === void 0 && cacheRead === void 0 && cacheWrite === void 0 && total === void 0) return;
|
|
49
|
-
return {
|
|
50
|
-
input,
|
|
51
|
-
output,
|
|
52
|
-
cacheRead,
|
|
53
|
-
cacheWrite,
|
|
54
|
-
total
|
|
55
|
-
};
|
|
42
|
+
return normalizeBillingUsage(raw);
|
|
56
43
|
}
|
|
57
44
|
function derivePromptTokens(usage) {
|
|
58
45
|
if (!usage) return;
|
|
@@ -226,10 +213,8 @@ async function scanTranscriptFile(params) {
|
|
|
226
213
|
model: entry.model,
|
|
227
214
|
config: params.config
|
|
228
215
|
});
|
|
229
|
-
entry.
|
|
230
|
-
|
|
231
|
-
cost
|
|
232
|
-
});
|
|
216
|
+
entry.costBreakdown = billingCost(entry.usage, cost);
|
|
217
|
+
entry.costTotal = entry.costBreakdown?.total;
|
|
233
218
|
}
|
|
234
219
|
params.onEntry(entry);
|
|
235
220
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// JOHNNESS_PATCH_USAGE_BILLING_91
|
|
2
|
+
// Status, transcript normalization and fallback estimates share the provider's disjoint buckets.
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { johnnessUsageCost } from "@mariozechner/pi-ai";
|
|
5
|
+
|
|
6
|
+
const number = v => typeof v === "number" && Number.isFinite(v) ? Math.max(0, v) : undefined;
|
|
7
|
+
export function normalizeBillingUsage(raw) {
|
|
8
|
+
if (!raw || typeof raw !== "object") return;
|
|
9
|
+
const cacheRead = number(raw.cacheRead ?? raw.cache_read ?? raw.cache_read_input_tokens ?? raw.cached_tokens ?? raw.input_tokens_details?.cached_tokens ?? raw.prompt_tokens_details?.cached_tokens ?? raw.prompt_cache_hit_tokens ?? raw.cachedContentTokenCount);
|
|
10
|
+
const cacheWrite = number(raw.cacheWrite ?? raw.cache_write ?? raw.cache_creation_input_tokens);
|
|
11
|
+
let input = number(raw.input ?? raw.inputTokens ?? raw.input_tokens ?? raw.promptTokens ?? raw.prompt_tokens ?? raw.promptTokenCount);
|
|
12
|
+
// Native Anthropic input excludes both cache buckets; OpenAI/Google prompt totals include reads.
|
|
13
|
+
if (raw.input === undefined && raw.inputTokens === undefined && (raw.input_tokens_details || raw.prompt_tokens !== undefined || raw.promptTokenCount !== undefined)) input = Math.max(0, (input ?? 0) - (cacheRead ?? 0));
|
|
14
|
+
const output = number(raw.output ?? raw.outputTokens ?? raw.output_tokens ?? raw.completionTokens ?? raw.completion_tokens ?? (raw.candidatesTokenCount !== undefined ? raw.candidatesTokenCount + (raw.thoughtsTokenCount ?? 0) : undefined));
|
|
15
|
+
const total = number(raw.total ?? raw.totalTokens ?? raw.total_tokens ?? raw.totalTokenCount);
|
|
16
|
+
if ([input, output, cacheRead, cacheWrite, total].every(v => v === undefined)) return;
|
|
17
|
+
const usage = { input, output, cacheRead, cacheWrite, total };
|
|
18
|
+
const short = number(raw.cacheWrite5m ?? raw.cache_creation?.ephemeral_5m_input_tokens);
|
|
19
|
+
const long = number(raw.cacheWrite1h ?? raw.cache_creation?.ephemeral_1h_input_tokens);
|
|
20
|
+
if (short !== undefined) usage.cacheWrite5m = short;
|
|
21
|
+
if (long !== undefined) usage.cacheWrite1h = long;
|
|
22
|
+
if (recordedUsageCost(raw)) usage.cost = { ...raw.cost };
|
|
23
|
+
return usage;
|
|
24
|
+
}
|
|
25
|
+
export function recordedUsageCost(usage) {
|
|
26
|
+
const cost = usage?.cost;
|
|
27
|
+
if (!cost || ["input", "output", "cacheRead", "cacheWrite", "total"].some(k => typeof cost[k] !== "number" || !Number.isFinite(cost[k]) || cost[k] < 0)) return;
|
|
28
|
+
return cost;
|
|
29
|
+
}
|
|
30
|
+
export function billingCost(usage, rates) {
|
|
31
|
+
return recordedUsageCost(usage) ?? johnnessUsageCost(usage, rates);
|
|
32
|
+
}
|
|
33
|
+
export function formatBillingUsd(value) {
|
|
34
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return;
|
|
35
|
+
// Do not round a large cache charge to cents or a small input charge to zero.
|
|
36
|
+
return "$" + value.toFixed(8).replace(/(\.\d*?[1-9])0+$|\.0+$/, "$1").replace(/^0$/, "0.00");
|
|
37
|
+
}
|
|
38
|
+
export function formatBillingCost(usage, rates) {
|
|
39
|
+
const cost = billingCost(usage, rates);
|
|
40
|
+
if (!cost) return null;
|
|
41
|
+
const estimate = recordedUsageCost(usage) ? "" : "est. ";
|
|
42
|
+
const line = `💵 Cost: ${estimate}${formatBillingUsd(cost.total)} (input ${formatBillingUsd(cost.input)}, read ${formatBillingUsd(cost.cacheRead)}, write ${formatBillingUsd(cost.cacheWrite)}, output ${formatBillingUsd(cost.output)})`;
|
|
43
|
+
const turn = usage?.turn;
|
|
44
|
+
return turn?.calls > 1 ? `${line}\n💵 Turn total: ${turn.complete ? formatBillingUsd(turn.cost.total) : "unavailable (missing recorded cost)"} across ${turn.calls} API calls` : line;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Read backwards until a complete assistant usage record is found. The old 8 KiB tail
|
|
48
|
+
// missed large text/tool records and accidentally combined different calls' counters.
|
|
49
|
+
export function readLatestBillingUsage(logPath) {
|
|
50
|
+
let fd;
|
|
51
|
+
try {
|
|
52
|
+
fd = fs.openSync(logPath, "r");
|
|
53
|
+
let end = fs.fstatSync(fd).size;
|
|
54
|
+
let carry = Buffer.alloc(0);
|
|
55
|
+
let latest;
|
|
56
|
+
const turn = { calls: 0, complete: true, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } };
|
|
57
|
+
const finish = () => latest ? { ...latest, turn } : undefined;
|
|
58
|
+
while (end > 0) {
|
|
59
|
+
const start = Math.max(0, end - 65536);
|
|
60
|
+
const block = Buffer.alloc(end - start);
|
|
61
|
+
fs.readSync(fd, block, 0, block.length, start);
|
|
62
|
+
const bytes = Buffer.concat([block, carry]);
|
|
63
|
+
let lineEnd = bytes.length;
|
|
64
|
+
for (let i = bytes.length - 1; i >= (start === 0 ? -1 : 0); i--) {
|
|
65
|
+
if (i !== -1 && bytes[i] !== 10) continue;
|
|
66
|
+
const line = bytes.subarray(i + 1, lineEnd).toString("utf8");
|
|
67
|
+
lineEnd = i;
|
|
68
|
+
try {
|
|
69
|
+
const entry = JSON.parse(line);
|
|
70
|
+
const message = entry.message ?? entry;
|
|
71
|
+
if (message.role === "user" && latest) return finish();
|
|
72
|
+
if (message.role !== "assistant") continue;
|
|
73
|
+
const usage = normalizeBillingUsage(message.usage ?? entry.usage);
|
|
74
|
+
if (!usage || ![usage.input, usage.output, usage.cacheRead, usage.cacheWrite].some(v => v > 0)) continue;
|
|
75
|
+
const promptTokens = (usage.input ?? 0) + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0);
|
|
76
|
+
latest ??= { ...usage, promptTokens, total: usage.total ?? promptTokens + (usage.output ?? 0), model: message.model, provider: message.provider };
|
|
77
|
+
turn.calls++;
|
|
78
|
+
const cost = recordedUsageCost(usage);
|
|
79
|
+
if (!cost) turn.complete = false;
|
|
80
|
+
else for (const key of Object.keys(turn.cost)) turn.cost[key] += cost[key];
|
|
81
|
+
} catch {}
|
|
82
|
+
}
|
|
83
|
+
carry = bytes.subarray(0, lineEnd);
|
|
84
|
+
end = start;
|
|
85
|
+
}
|
|
86
|
+
return finish();
|
|
87
|
+
} catch {} finally { if (fd !== undefined) fs.closeSync(fd); }
|
|
88
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getModel, johnnessUsageCost } from "@mariozechner/pi-ai";
|
|
2
|
+
// JOHNNESS_PATCH_USAGE_BILLING_91
|
|
1
3
|
//#region src/utils/usage-format.ts
|
|
2
4
|
function formatTokenCount(value) {
|
|
3
5
|
if (value === void 0 || !Number.isFinite(value)) return "0";
|
|
@@ -21,20 +23,13 @@ function resolveModelCostConfig(params) {
|
|
|
21
23
|
const provider = params.provider?.trim();
|
|
22
24
|
const model = params.model?.trim();
|
|
23
25
|
if (!provider || !model) return;
|
|
24
|
-
return ((params.config?.models?.providers ?? {})[provider]?.models?.find((item) => item.id === model))?.cost;
|
|
26
|
+
return ((params.config?.models?.providers ?? {})[provider]?.models?.find((item) => item.id === model))?.cost ?? getModel(provider, model)?.cost;
|
|
25
27
|
}
|
|
26
28
|
const toNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
27
29
|
function estimateUsageCost(params) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const input = toNumber(usage.input);
|
|
32
|
-
const output = toNumber(usage.output);
|
|
33
|
-
const cacheRead = toNumber(usage.cacheRead);
|
|
34
|
-
const cacheWrite = toNumber(usage.cacheWrite);
|
|
35
|
-
const total = input * cost.input + output * cost.output + cacheRead * cost.cacheRead + cacheWrite * cost.cacheWrite;
|
|
36
|
-
if (!Number.isFinite(total)) return;
|
|
37
|
-
return total / 1e6;
|
|
30
|
+
const recorded = params.usage?.cost?.total;
|
|
31
|
+
if (typeof recorded === "number" && Number.isFinite(recorded) && recorded >= 0) return recorded;
|
|
32
|
+
return johnnessUsageCost(params.usage, params.cost)?.total;
|
|
38
33
|
}
|
|
39
34
|
//#endregion
|
|
40
35
|
export { resolveModelCostConfig as i, formatTokenCount as n, formatUsd as r, estimateUsageCost as t };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getModel, johnnessUsageCost } from "@mariozechner/pi-ai";
|
|
2
|
+
// JOHNNESS_PATCH_USAGE_BILLING_91
|
|
1
3
|
//#region src/utils/usage-format.ts
|
|
2
4
|
function formatTokenCount(value) {
|
|
3
5
|
if (value === void 0 || !Number.isFinite(value)) return "0";
|
|
@@ -21,20 +23,13 @@ function resolveModelCostConfig(params) {
|
|
|
21
23
|
const provider = params.provider?.trim();
|
|
22
24
|
const model = params.model?.trim();
|
|
23
25
|
if (!provider || !model) return;
|
|
24
|
-
return ((params.config?.models?.providers ?? {})[provider]?.models?.find((item) => item.id === model))?.cost;
|
|
26
|
+
return ((params.config?.models?.providers ?? {})[provider]?.models?.find((item) => item.id === model))?.cost ?? getModel(provider, model)?.cost;
|
|
25
27
|
}
|
|
26
28
|
const toNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
27
29
|
function estimateUsageCost(params) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const input = toNumber(usage.input);
|
|
32
|
-
const output = toNumber(usage.output);
|
|
33
|
-
const cacheRead = toNumber(usage.cacheRead);
|
|
34
|
-
const cacheWrite = toNumber(usage.cacheWrite);
|
|
35
|
-
const total = input * cost.input + output * cost.output + cacheRead * cost.cacheRead + cacheWrite * cost.cacheWrite;
|
|
36
|
-
if (!Number.isFinite(total)) return;
|
|
37
|
-
return total / 1e6;
|
|
30
|
+
const recorded = params.usage?.cost?.total;
|
|
31
|
+
if (typeof recorded === "number" && Number.isFinite(recorded) && recorded >= 0) return recorded;
|
|
32
|
+
return johnnessUsageCost(params.usage, params.cost)?.total;
|
|
38
33
|
}
|
|
39
34
|
//#endregion
|
|
40
35
|
export { resolveModelCostConfig as i, formatTokenCount as n, formatUsd as r, estimateUsageCost as t };
|
package/docs/PATCHES.md
CHANGED
|
@@ -17,7 +17,7 @@ they predate ~2026-06-06).
|
|
|
17
17
|
|
|
18
18
|
## Index
|
|
19
19
|
|
|
20
|
-
Current addition: [
|
|
20
|
+
Current addition: [91 - Exact API usage billing](#91---exact-api-usage-billing-2026-10-21).
|
|
21
21
|
|
|
22
22
|
Family 01 is retired. Families 02 through 41, 43 through 81, including the 65.1 amendment, are live on `main`; the `latest` and `extended` release lines converged at 2026.9.24. Family 42 is omitted; native Codex OAuth ownership is Family 58.
|
|
23
23
|
|
|
@@ -3063,3 +3063,56 @@ the already-exhausted five-hour limit; the successful proof waited for its reset
|
|
|
3063
3063
|
gateway restart, live state access or new login. Verifier 564/564; full suite 1,249 pass, 5 existing skips.
|
|
3064
3064
|
|
|
3065
3065
|
**Rollback:** `npm i -g johns-harness@2026.10.20`.
|
|
3066
|
+
|
|
3067
|
+
## 91 - Exact API usage billing (2026-10-21)
|
|
3068
|
+
|
|
3069
|
+
**Release:** `johns-harness@2026.10.22`. Marker `JOHNNESS_PATCH_USAGE_BILLING_91`.
|
|
3070
|
+
|
|
3071
|
+
**Root cause:** status discarded cache buckets when estimating cost, used only the tiny Anthropic uncached suffix as input, and mixed store/log counters. The Anthropic adapter retained cache creation totals but lost their TTL split, pricing the new one-hour default at the five-minute rate. Google counted cached input twice; compatible completions ignored DeepSeek hits and double-counted OpenAI reasoning.
|
|
3072
|
+
|
|
3073
|
+
**Change:** shared disjoint-bucket normalization and pricing; native TTL preservation including mixed responses; catalog one-hour prices; recorded cost preferred (including subscription zero and service-tier multipliers); all ten status copies use complete latest-response counters with explicit input/read/write/output costs. The backward transcript reader also sums calls since the latest user boundary to show multi-call turn spend. Cumulative session summaries use the same costs and preserve the breakdown on fallback estimates. Old costs with missing TTL information are not fabricated.
|
|
3074
|
+
|
|
3075
|
+
**Artifacts:** `dist/usage-billing.js`, `patches/usage-billing-91/changes.json`, `scripts/patch-usage-billing-91.py`, `tests/usage-billing-91.test.mjs`, provider-shaped offline fixtures in `tests/fixtures/usage-billing-91.json`. Fixture counts reproduce the reported rounded 148k/155k scenario; they are not a newly billed live request. Native Anthropic, OpenAI and Google SDK streams are exercised offline, plus DeepSeek and cumulative/session status paths. Exact historical reversals route by bundle path to avoid ambiguous minified aliases. The added Vertex overlay remains pinned to pi-ai 0.55.3.
|
|
3076
|
+
|
|
3077
|
+
**Rollback:** `npm i -g johns-harness@2026.10.21`. No migration or live-state edit required. No invoice-tax or negotiated-price claim; costs use configured/catalog token rates.
|
|
3078
|
+
|
|
3079
|
+
|
|
3080
|
+
## 92 - Current subscription credentials and visible paid fallback (2026-10-21)
|
|
3081
|
+
|
|
3082
|
+
**Release:** `johns-harness@2026.10.23`. Marker `JOHNNESS_PATCH_SUBSCRIPTION_RUNTIME_92`.
|
|
3083
|
+
|
|
3084
|
+
**Root cause:** Family 89 refreshed auth snapshots after login, but non-Codex OAuth generations
|
|
3085
|
+
remained frozen afterward. Following rotation, the session picker still selected the subscription,
|
|
3086
|
+
while `resolveApiKeyForProfile` and even the refresh-lock body reread the expired startup snapshot.
|
|
3087
|
+
The spent refresh token failed before inference, and `advanceAuthProfile` silently selected the API
|
|
3088
|
+
key without recording a profile failure/cooldown. Other runtime paths reading disk could still
|
|
3089
|
+
serve subscription requests. This is not a Fable model allowlist.
|
|
3090
|
+
|
|
3091
|
+
**Change:** all eleven compiled auth-store adapters observe the current disk generation and
|
|
3092
|
+
per-profile metadata for already-activated Anthropic OAuth profiles. Refresh locks read fresh disk
|
|
3093
|
+
state. New logins still activate through Family 89. Local-agent profiles retain precedence; removed
|
|
3094
|
+
credentials are not resurrected; resolved API SecretRefs and Codex ownership are unchanged. The
|
|
3095
|
+
ten runners record a whitelisted fallback category alongside the actual served profile. Both status
|
|
3096
|
+
entrypoints explain paid fallback, including model rejection or pre-inference refresh failure, and
|
|
3097
|
+
clear the annotation when the subscription recovers. Endpoint bodies and credentials are never
|
|
3098
|
+
stored in fallback metadata. Explicit user API selections do not receive a fallback label.
|
|
3099
|
+
|
|
3100
|
+
**Proof:** the clean 2026.10.22 baseline reproduced the failure in an isolated running gateway with
|
|
3101
|
+
a mock Fable endpoint and mock OAuth: a fresh disk token existed, but the spent snapshot token
|
|
3102
|
+
was refreshed once and the request used the API key with no fallback reason. The same fixture on
|
|
3103
|
+
92 sends the current subscription bearer token with zero refresh attempts, reuses it across turns,
|
|
3104
|
+
refreshes an intentionally expired generation exactly once, displays a forced subscription-only
|
|
3105
|
+
model 404 and paid fallback in actual `/status` history, then recovers without reload. A rejected
|
|
3106
|
+
refresh also appears in `/status`. All tokens are fixtures, and external HTTP is blocked. No live
|
|
3107
|
+
gateway or state was changed.
|
|
3108
|
+
|
|
3109
|
+
**Artifacts:** `dist/anthropic-auth-runtime.js`, `patches/subscription-runtime-92/changes.json`,
|
|
3110
|
+
`scripts/patch-subscription-runtime-92.py`, `tests/subscription-runtime-92.test.mjs`. Exact preflight,
|
|
3111
|
+
idempotency, all auth copies, ownership/SecretRefs, cooldown, redaction and historical layer
|
|
3112
|
+
round trips are covered. Reverse newest-to-oldest when recognizing nested patch edits, then
|
|
3113
|
+
reapply oldest-to-newest; never bless whole-bundle hash drift. Verifier checks 92.1 to 92.6.
|
|
3114
|
+
|
|
3115
|
+
**Rollback:** `npm i -g johns-harness@2026.10.22`. After `/update`, the next eligible turn should
|
|
3116
|
+
show `oauth (anthropic:subscription)`. Before that turn, status correctly retains the last served
|
|
3117
|
+
profile. A real subscription failure still follows the existing API fallback policy, but status
|
|
3118
|
+
now says why.
|
|
@@ -55,8 +55,8 @@ Use the `cacheRetention` parameter in your model config:
|
|
|
55
55
|
| Value | Cache Duration | Description |
|
|
56
56
|
| ------- | -------------- | ----------------------------------- |
|
|
57
57
|
| `none` | No caching | Disable prompt caching |
|
|
58
|
-
| `short` | 5 minutes |
|
|
59
|
-
| `long` | 1 hour |
|
|
58
|
+
| `short` | 5 minutes | Explicit shorter retention |
|
|
59
|
+
| `long` | 1 hour | Default for API key and subscription |
|
|
60
60
|
|
|
61
61
|
```json5
|
|
62
62
|
{
|
|
@@ -232,3 +232,24 @@ johnness onboard --auth-choice setup-token
|
|
|
232
232
|
- Add another Anthropic profile or wait for cooldown.
|
|
233
233
|
|
|
234
234
|
More: [/gateway/troubleshooting](/gateway/troubleshooting) and [/help/faq](/help/faq).
|
|
235
|
+
|
|
236
|
+
### Cache billing in status
|
|
237
|
+
|
|
238
|
+
`/status` and `session_status` show uncached input plus cache writes as **new in**, cache reads separately, and output. The cost breakdown separately prices input, reads, writes and output. Anthropic's `cache_creation.ephemeral_5m_input_tokens` and `ephemeral_1h_input_tokens` determine the write rate, including mixed-TTL responses. If the older response omits this split, the adapter uses the TTL actually sent on that request, not the current session setting. Five-minute writes use `cost.cacheWrite`; one-hour writes use `cost.cacheWrite1h` from the catalog (2x input for custom model pricing).
|
|
239
|
+
|
|
240
|
+
The last API response and multi-call turn total are distinct. A tool-heavy turn can have many charged API requests; its total is shown separately. Subscription responses still record zero monetary cost. API fallback responses carry their actual token-rate cost. Historical records without duration metadata retain their recorded cost; changing the default cannot retrospectively recover that missing information.
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
### Subscription profile actually used
|
|
244
|
+
|
|
245
|
+
After `/login claude`, an existing session uses the subscription on its next eligible turn. OAuth
|
|
246
|
+
rotation is also observed automatically by a running gateway; no manual secrets reload or `/new`
|
|
247
|
+
is needed. `/status` and `session_status` report the profile that actually served the last turn:
|
|
248
|
+
`oauth (anthropic:subscription)` for the subscription, or `api-key (anthropic:default)` for the API.
|
|
249
|
+
|
|
250
|
+
When the API key serves as fallback, the label includes a reason, such as
|
|
251
|
+
`[API fallback: model unavailable on subscription]` or
|
|
252
|
+
`[API fallback: subscription token refresh failed]`. Rate limits, cooldown and auth/quota failures
|
|
253
|
+
are labeled too. The reason clears after subscription recovery. An explicitly selected API-key
|
|
254
|
+
profile is not labeled as a subscription fallback. Status before the first post-update turn still
|
|
255
|
+
reflects the previous turn, not a promise about the next request.
|
|
@@ -49,7 +49,9 @@ For a practical breakdown (per injected file, tools, skills, and system prompt s
|
|
|
49
49
|
Use these in chat:
|
|
50
50
|
|
|
51
51
|
- `/status` → **emoji‑rich status card** with the session model, context usage,
|
|
52
|
-
last response input/output tokens
|
|
52
|
+
last API response new-input/cached/output tokens and the recorded API cost
|
|
53
|
+
broken down into input, cache reads, cache writes and output. Multi-call turns
|
|
54
|
+
also show a turn total. Missing recorded cost is explicitly marked `est.`.
|
|
53
55
|
- `/usage off|tokens|full` → appends a **per-response usage footer** to every reply.
|
|
54
56
|
- Persists per session (stored as `responseUsage`).
|
|
55
57
|
- OAuth auth **hides cost** (tokens only).
|
|
@@ -173,3 +175,11 @@ rejects that combination with HTTP 401.
|
|
|
173
175
|
- Prefer smaller models for verbose, exploratory work.
|
|
174
176
|
|
|
175
177
|
See [Skills](/tools/skills) for the exact skill list overhead formula.
|
|
178
|
+
|
|
179
|
+
## Billing buckets
|
|
180
|
+
|
|
181
|
+
Provider input counters do not all mean the same thing. Anthropic `input_tokens` excludes both cache buckets. OpenAI and Google prompt totals include cached reads, which must be subtracted before charging ordinary input. DeepSeek exposes cache hits as `prompt_cache_hit_tokens`. Reasoning tokens are already included in OpenAI output; Google's thought count is separate and is added once.
|
|
182
|
+
|
|
183
|
+
Status uses a coherent native response snapshot, not a mixture of a run's output and another call's cache counters. **New in = uncached input + cache writes**, not just the small uncached suffix. Writes are not ordinary input: their duration-specific rates are applied separately. For example, 4 uncached input + 148,000 one-hour writes + 158 output on the catalog's Fable 5.1 rates costs **$2.96794**, not $0.00794. A plain uncached 148,000-token prompt with no cache write would use the ordinary input rate instead.
|
|
184
|
+
|
|
185
|
+
Costs are token-rate charges calculated from the configured model/catalog prices, not invoice taxes, credits or negotiated account discounts. Provider-recorded adjustments such as OpenAI service tiers and subscription-zero accounting are preserved rather than recomputed by status. `/usage cost` sums the same recorded cost components across the session. Historical entries lacking TTL detail cannot be corrected exactly after the fact.
|
package/models/models.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"about": "Master model file for John's Harness (family 83). Every shipped catalog entry, wire rule and alias lives here; scripts/models-sync.mjs generates every copy in the tree from it. See docs/MODELS.md.",
|
|
3
|
-
"fields": "providers.<provider>.<id>: the pi-ai catalog card (name, api, baseUrl, reasoning, input, cost per MTok, contextWindow = the window the harness uses, maxTokens). harness.xhigh: /think xhigh and wire xhigh allowed. harness.efforts: reasoning efforts the API accepts (others map to the nearest accepted). harness.temperature: drop | drop-unless-effort-none. Anthropic (anthropic-messages) only: harness.thinking adaptive (adaptive thinking + output_config.effort instead of budget_tokens), harness.thinkingOff disabled (thinking.type disabled when /think is off), harness.efforts low..max, harness.temperature drop (also top_p/top_k). harness.nativeContextWindow/source/checked/notes: documentation only. cost is flat; tiered official prices keep the base tier here and the rest in harness.notes. Google native (google-generative-ai): harness.thinking level sends thinkingConfig.thinkingLevel rather than thinkingBudget; thinkingDefault plus efforts governs all /think levels including the non-disableable provider default; cache implicit-only refuses explicit cachedContent. Ordinary per-stream maxTokens only; long decode/continuation is not implemented.",
|
|
3
|
+
"fields": "providers.<provider>.<id>: the pi-ai catalog card (name, api, baseUrl, reasoning, input, cost per MTok, contextWindow = the window the harness uses, maxTokens). harness.xhigh: /think xhigh and wire xhigh allowed. harness.efforts: reasoning efforts the API accepts (others map to the nearest accepted). harness.temperature: drop | drop-unless-effort-none. Anthropic (anthropic-messages) only: harness.thinking adaptive (adaptive thinking + output_config.effort instead of budget_tokens), harness.thinkingOff disabled (thinking.type disabled when /think is off), harness.efforts low..max, harness.temperature drop (also top_p/top_k). harness.nativeContextWindow/source/checked/notes: documentation only. cost.cacheWrite1h is the native Anthropic one-hour write price (cacheWrite is five-minute). Otherwise cost is flat; tiered official prices keep the base tier here and the rest in harness.notes. Google native (google-generative-ai): harness.thinking level sends thinkingConfig.thinkingLevel rather than thinkingBudget; thinkingDefault plus efforts governs all /think levels including the non-disableable provider default; cache implicit-only refuses explicit cachedContent. Ordinary per-stream maxTokens only; long decode/continuation is not implemented.",
|
|
4
4
|
"imageGenerationDefault": {
|
|
5
5
|
"primary": "openai-codex/gpt-image-2.5-sunburst",
|
|
6
6
|
"fallbacks": ["openai-codex/gpt-image-2"]
|
|
@@ -152,38 +152,38 @@
|
|
|
152
152
|
"zai.glm-4.7-flash": {"name":"GLM-4.7-Flash","api":"bedrock-converse-stream","baseUrl":"https://bedrock-runtime.us-east-1.amazonaws.com","reasoning":true,"input":["text"],"cost":{"input":0.07,"output":0.4,"cacheRead":0,"cacheWrite":0},"contextWindow":200000,"maxTokens":131072}
|
|
153
153
|
},
|
|
154
154
|
"anthropic": {
|
|
155
|
-
"claude-3-5-haiku-20241022": {"name":"Claude Haiku 3.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":0.8,"output":4,"cacheRead":0.08,"cacheWrite":1},"contextWindow":200000,"maxTokens":8192},
|
|
156
|
-
"claude-3-5-haiku-latest": {"name":"Claude Haiku 3.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":0.8,"output":4,"cacheRead":0.08,"cacheWrite":1},"contextWindow":200000,"maxTokens":8192},
|
|
157
|
-
"claude-3-5-sonnet-20240620": {"name":"Claude Sonnet 3.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":8192},
|
|
158
|
-
"claude-3-5-sonnet-20241022": {"name":"Claude Sonnet 3.5 v2","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":8192},
|
|
159
|
-
"claude-3-7-sonnet-20250219": {"name":"Claude Sonnet 3.7","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":64000},
|
|
160
|
-
"claude-3-7-sonnet-latest": {"name":"Claude Sonnet 3.7 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":64000},
|
|
161
|
-
"claude-3-haiku-20240307": {"name":"Claude Haiku 3","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":0.25,"output":1.25,"cacheRead":0.03,"cacheWrite":0.3},"contextWindow":200000,"maxTokens":4096},
|
|
162
|
-
"claude-3-opus-20240229": {"name":"Claude Opus 3","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75},"contextWindow":200000,"maxTokens":4096},
|
|
163
|
-
"claude-3-sonnet-20240229": {"name":"Claude Sonnet 3","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":0.3},"contextWindow":200000,"maxTokens":4096},
|
|
164
|
-
"claude-fable-5-1": {"name":"Claude Fable 5.1","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":10,"output":50,"cacheRead":0.25,"cacheWrite":12.5},"contextWindow":300000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
165
|
-
"claude-sonnet-5-5": {"name":"Claude Sonnet 5.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":2,"output":10,"cacheRead":0.1,"cacheWrite":2.5},"contextWindow":1000000,"maxTokens":128000,"harness":{"xhigh":true,"source":"docs.claude.com/docs/en/about-claude/pricing (cache read 0.05x on Claude Opus 5.5 and Claude Sonnet 5.5) and the 2026-10-07 release notes","checked":"2026-10-08","notes":"Cache reads lowered from $0.20 to $0.10/MTok on 2026-10-07; cache writes and all other prices unchanged."}},
|
|
166
|
-
"claude-opus-5-5": {"name":"Claude Opus 5.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":4,"output":20,"cacheRead":0.2,"cacheWrite":5},"contextWindow":500000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
167
|
-
"claude-haiku-5-5": {"name":"Claude Haiku 5.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":0.1,"output":0.5,"cacheRead":0.01,"cacheWrite":0.125},"contextWindow":1000000,"maxTokens":128000,"harness":{"xhigh":true,"thinking":"adaptive","thinkingOff":"disabled","efforts":["low","medium","high","xhigh","max"],"temperature":"drop","nativeContextWindow":1000000,"source":"docs.claude.com/docs/en/models/haiku-5-5/overview, /docs/en/about-claude/pricing, /docs/en/build-with-claude/effort, /docs/en/build-with-claude/thinking and the 2026-10-07 release notes; GET api.anthropic.com/v1/models/claude-haiku-5-5 (max_input_tokens 1000000, max_tokens 128000, effort low..max supported, thinking adaptive and disabled supported, enabled unsupported)","checked":"2026-10-08","notes":"GA 2026-10-07. Adaptive thinking is on by default (display omitted), default effort medium. thinking.type enabled (budget_tokens) returns 400 (live), so the adapter must send adaptive + output_config.effort. Non-default temperature/top_p/top_k return 400 (live: temperature 400). Pricing is tiered by prompt length: prompts up to 100K tokens $0.10 input, $0.50 output, $0.01 cache read, $0.125 5m cache write, $0.20 1h cache write per MTok; prompts over 100K $0.50, $2.50, $0.05, $0.625, $1.00. cost holds the up-to-100K tier because the catalog cost is flat, so usage estimates for prompts over 100K tokens read 5x low. Batch 50% off. Newer tokenizer (about 30% more tokens than Haiku 4.5). Knowledge cutoff Jun 2026."}},
|
|
168
|
-
"claude-opus-5": {"name":"Claude Opus 5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25},"contextWindow":300000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
169
|
-
"claude-sonnet-5": {"name":"Claude Sonnet 5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":2,"output":10,"cacheRead":0.2,"cacheWrite":2.5},"contextWindow":1000000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
170
|
-
"claude-fable-5": {"name":"Claude Fable 5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":10,"output":50,"cacheRead":1,"cacheWrite":12.5},"contextWindow":300000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
171
|
-
"claude-opus-4-8": {"name":"Claude Opus 4.8","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25},"contextWindow":300000,"maxTokens":32000},
|
|
172
|
-
"claude-opus-4-7": {"name":"Claude Opus 4.7","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25},"contextWindow":200000,"maxTokens":32000},
|
|
173
|
-
"claude-haiku-4-5": {"name":"Claude Haiku 4.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":1,"output":5,"cacheRead":0.1,"cacheWrite":1.25},"contextWindow":200000,"maxTokens":64000},
|
|
174
|
-
"claude-haiku-4-5-20251001": {"name":"Claude Haiku 4.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":1,"output":5,"cacheRead":0.1,"cacheWrite":1.25},"contextWindow":200000,"maxTokens":64000},
|
|
175
|
-
"claude-opus-4-0": {"name":"Claude Opus 4 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75},"contextWindow":200000,"maxTokens":32000},
|
|
176
|
-
"claude-opus-4-1": {"name":"Claude Opus 4.1 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75},"contextWindow":200000,"maxTokens":32000},
|
|
177
|
-
"claude-opus-4-1-20250805": {"name":"Claude Opus 4.1","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75},"contextWindow":200000,"maxTokens":32000},
|
|
178
|
-
"claude-opus-4-20250514": {"name":"Claude Opus 4","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75},"contextWindow":200000,"maxTokens":32000},
|
|
179
|
-
"claude-opus-4-5": {"name":"Claude Opus 4.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25},"contextWindow":200000,"maxTokens":64000},
|
|
180
|
-
"claude-opus-4-5-20251101": {"name":"Claude Opus 4.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25},"contextWindow":200000,"maxTokens":64000},
|
|
181
|
-
"claude-opus-4-6": {"name":"Claude Opus 4.6","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25},"contextWindow":200000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
182
|
-
"claude-sonnet-4-0": {"name":"Claude Sonnet 4 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":64000},
|
|
183
|
-
"claude-sonnet-4-20250514": {"name":"Claude Sonnet 4","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":64000},
|
|
184
|
-
"claude-sonnet-4-5": {"name":"Claude Sonnet 4.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":64000},
|
|
185
|
-
"claude-sonnet-4-5-20250929": {"name":"Claude Sonnet 4.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":200000,"maxTokens":64000},
|
|
186
|
-
"claude-sonnet-4-6": {"name":"Claude Sonnet 4.6","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75},"contextWindow":1000000,"maxTokens":64000}
|
|
155
|
+
"claude-3-5-haiku-20241022": {"name":"Claude Haiku 3.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":0.8,"output":4,"cacheRead":0.08,"cacheWrite":1,"cacheWrite1h":1.6},"contextWindow":200000,"maxTokens":8192},
|
|
156
|
+
"claude-3-5-haiku-latest": {"name":"Claude Haiku 3.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":0.8,"output":4,"cacheRead":0.08,"cacheWrite":1,"cacheWrite1h":1.6},"contextWindow":200000,"maxTokens":8192},
|
|
157
|
+
"claude-3-5-sonnet-20240620": {"name":"Claude Sonnet 3.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":8192},
|
|
158
|
+
"claude-3-5-sonnet-20241022": {"name":"Claude Sonnet 3.5 v2","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":8192},
|
|
159
|
+
"claude-3-7-sonnet-20250219": {"name":"Claude Sonnet 3.7","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":64000},
|
|
160
|
+
"claude-3-7-sonnet-latest": {"name":"Claude Sonnet 3.7 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":64000},
|
|
161
|
+
"claude-3-haiku-20240307": {"name":"Claude Haiku 3","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":0.25,"output":1.25,"cacheRead":0.03,"cacheWrite":0.3,"cacheWrite1h":0.5},"contextWindow":200000,"maxTokens":4096},
|
|
162
|
+
"claude-3-opus-20240229": {"name":"Claude Opus 3","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75,"cacheWrite1h":30},"contextWindow":200000,"maxTokens":4096},
|
|
163
|
+
"claude-3-sonnet-20240229": {"name":"Claude Sonnet 3","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":0.3,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":4096},
|
|
164
|
+
"claude-fable-5-1": {"name":"Claude Fable 5.1","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":10,"output":50,"cacheRead":0.25,"cacheWrite":12.5,"cacheWrite1h":20},"contextWindow":300000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
165
|
+
"claude-sonnet-5-5": {"name":"Claude Sonnet 5.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":2,"output":10,"cacheRead":0.1,"cacheWrite":2.5,"cacheWrite1h":4},"contextWindow":1000000,"maxTokens":128000,"harness":{"xhigh":true,"source":"docs.claude.com/docs/en/about-claude/pricing (cache read 0.05x on Claude Opus 5.5 and Claude Sonnet 5.5) and the 2026-10-07 release notes","checked":"2026-10-08","notes":"Cache reads lowered from $0.20 to $0.10/MTok on 2026-10-07; cache writes and all other prices unchanged."}},
|
|
166
|
+
"claude-opus-5-5": {"name":"Claude Opus 5.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":4,"output":20,"cacheRead":0.2,"cacheWrite":5,"cacheWrite1h":8},"contextWindow":500000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
167
|
+
"claude-haiku-5-5": {"name":"Claude Haiku 5.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":0.1,"output":0.5,"cacheRead":0.01,"cacheWrite":0.125,"cacheWrite1h":0.2},"contextWindow":1000000,"maxTokens":128000,"harness":{"xhigh":true,"thinking":"adaptive","thinkingOff":"disabled","efforts":["low","medium","high","xhigh","max"],"temperature":"drop","nativeContextWindow":1000000,"source":"docs.claude.com/docs/en/models/haiku-5-5/overview, /docs/en/about-claude/pricing, /docs/en/build-with-claude/effort, /docs/en/build-with-claude/thinking and the 2026-10-07 release notes; GET api.anthropic.com/v1/models/claude-haiku-5-5 (max_input_tokens 1000000, max_tokens 128000, effort low..max supported, thinking adaptive and disabled supported, enabled unsupported)","checked":"2026-10-08","notes":"GA 2026-10-07. Adaptive thinking is on by default (display omitted), default effort medium. thinking.type enabled (budget_tokens) returns 400 (live), so the adapter must send adaptive + output_config.effort. Non-default temperature/top_p/top_k return 400 (live: temperature 400). Pricing is tiered by prompt length: prompts up to 100K tokens $0.10 input, $0.50 output, $0.01 cache read, $0.125 5m cache write, $0.20 1h cache write per MTok; prompts over 100K $0.50, $2.50, $0.05, $0.625, $1.00. cost holds the up-to-100K tier because the catalog cost is flat, so usage estimates for prompts over 100K tokens read 5x low. Batch 50% off. Newer tokenizer (about 30% more tokens than Haiku 4.5). Knowledge cutoff Jun 2026."}},
|
|
168
|
+
"claude-opus-5": {"name":"Claude Opus 5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25,"cacheWrite1h":10},"contextWindow":300000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
169
|
+
"claude-sonnet-5": {"name":"Claude Sonnet 5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":2,"output":10,"cacheRead":0.2,"cacheWrite":2.5,"cacheWrite1h":4},"contextWindow":1000000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
170
|
+
"claude-fable-5": {"name":"Claude Fable 5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":10,"output":50,"cacheRead":1,"cacheWrite":12.5,"cacheWrite1h":20},"contextWindow":300000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
171
|
+
"claude-opus-4-8": {"name":"Claude Opus 4.8","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25,"cacheWrite1h":10},"contextWindow":300000,"maxTokens":32000},
|
|
172
|
+
"claude-opus-4-7": {"name":"Claude Opus 4.7","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":false,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25,"cacheWrite1h":10},"contextWindow":200000,"maxTokens":32000},
|
|
173
|
+
"claude-haiku-4-5": {"name":"Claude Haiku 4.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":1,"output":5,"cacheRead":0.1,"cacheWrite":1.25,"cacheWrite1h":2},"contextWindow":200000,"maxTokens":64000},
|
|
174
|
+
"claude-haiku-4-5-20251001": {"name":"Claude Haiku 4.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":1,"output":5,"cacheRead":0.1,"cacheWrite":1.25,"cacheWrite1h":2},"contextWindow":200000,"maxTokens":64000},
|
|
175
|
+
"claude-opus-4-0": {"name":"Claude Opus 4 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75,"cacheWrite1h":30},"contextWindow":200000,"maxTokens":32000},
|
|
176
|
+
"claude-opus-4-1": {"name":"Claude Opus 4.1 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75,"cacheWrite1h":30},"contextWindow":200000,"maxTokens":32000},
|
|
177
|
+
"claude-opus-4-1-20250805": {"name":"Claude Opus 4.1","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75,"cacheWrite1h":30},"contextWindow":200000,"maxTokens":32000},
|
|
178
|
+
"claude-opus-4-20250514": {"name":"Claude Opus 4","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":15,"output":75,"cacheRead":1.5,"cacheWrite":18.75,"cacheWrite1h":30},"contextWindow":200000,"maxTokens":32000},
|
|
179
|
+
"claude-opus-4-5": {"name":"Claude Opus 4.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25,"cacheWrite1h":10},"contextWindow":200000,"maxTokens":64000},
|
|
180
|
+
"claude-opus-4-5-20251101": {"name":"Claude Opus 4.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25,"cacheWrite1h":10},"contextWindow":200000,"maxTokens":64000},
|
|
181
|
+
"claude-opus-4-6": {"name":"Claude Opus 4.6","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":5,"output":25,"cacheRead":0.5,"cacheWrite":6.25,"cacheWrite1h":10},"contextWindow":200000,"maxTokens":128000,"harness":{"xhigh":true}},
|
|
182
|
+
"claude-sonnet-4-0": {"name":"Claude Sonnet 4 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":64000},
|
|
183
|
+
"claude-sonnet-4-20250514": {"name":"Claude Sonnet 4","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":64000},
|
|
184
|
+
"claude-sonnet-4-5": {"name":"Claude Sonnet 4.5 (latest)","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":64000},
|
|
185
|
+
"claude-sonnet-4-5-20250929": {"name":"Claude Sonnet 4.5","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":200000,"maxTokens":64000},
|
|
186
|
+
"claude-sonnet-4-6": {"name":"Claude Sonnet 4.6","api":"anthropic-messages","baseUrl":"https://api.anthropic.com","reasoning":true,"input":["text","image"],"cost":{"input":3,"output":15,"cacheRead":0.3,"cacheWrite":3.75,"cacheWrite1h":6},"contextWindow":1000000,"maxTokens":64000}
|
|
187
187
|
},
|
|
188
188
|
"azure-openai-responses": {
|
|
189
189
|
"codex-mini-latest": {"name":"Codex Mini","api":"azure-openai-responses","baseUrl":"","reasoning":true,"input":["text"],"cost":{"input":1.5,"output":6,"cacheRead":0.375,"cacheWrite":0},"contextWindow":200000,"maxTokens":100000},
|
|
@@ -7,6 +7,7 @@ export declare function getModel<TProvider extends KnownProvider, TModelId exten
|
|
|
7
7
|
export declare function getProviders(): KnownProvider[];
|
|
8
8
|
export declare function getModels<TProvider extends KnownProvider>(provider: TProvider): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[];
|
|
9
9
|
export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
|
|
10
|
+
export declare function johnnessUsageCost(usage: Partial<Usage>, rates: Model<Api>["cost"]): Usage["cost"] | undefined;
|
|
10
11
|
/**
|
|
11
12
|
* Check if a model supports xhigh thinking level.
|
|
12
13
|
*
|