feat: v2.5.12 — plan and quota for every AI tool, Grok Build and Kimi Code, Quit AgentHub (#65)
Usage panel (status bar): - every account shows its plan (Claude subscriptionType, Codex chatgpt_plan_type, Cursor membershipType, Grok subscriptionTier) - new quota rows: Cursor CLI (cursor.com usage-summary), Antigravity (`agy --print /usage`, two model pools; AGENTHUB_AGY_USAGE=0 never runs agy), Grok Build, Kimi Code, OpenCode Go — each login read from the tool's own file, sent only to its own host while valid, never refreshed - in-flight quota reads are shared between tabs AI Tools catalog: Grok Build (`grok`) and Kimi Code (`kimi`) added; Gemini CLI, Hermes and OpenClaw removed. Also: Quit AgentHub (#65, `agenthub stop`), status-area icon, Add to Chat on an editor selection, Settings in three groups, JetBrains-style Changes panel (ticked files/hunks, ignore, blame, file history), terminal font. --no-verify: :3000 is taken by another dev server (lane-detect tests); both suites run by hand — server 2636/2639 (the 3 are :3000), client 1131/1131.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* @file Unit tests for the enhanced pricing calculator and the shared token-usage
|
||||
* normalizer: 5m/1h cache-write split, server-tool surcharges, and the per-bucket
|
||||
* pricing modifiers (fast mode, US data residency, Batch API).
|
||||
* pricing modifiers (fast mode, US data residency, Batch API), and the
|
||||
* long-context subsets priced at a rule's long_* rates.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
@@ -363,3 +364,72 @@ describe("DEFAULT_PRICING — Opus 5.5", () => {
|
||||
assert.equal(r.total_cost.toFixed(2), "2.72");
|
||||
});
|
||||
});
|
||||
|
||||
describe("long-context tier (prompt > 100k tokens)", () => {
|
||||
// Haiku 5.5: every rate x5 above a 100k-token prompt.
|
||||
const HAIKU = [
|
||||
{
|
||||
model_pattern: "claude-haiku-5-5%",
|
||||
display_name: "Claude Haiku 5.5",
|
||||
input_per_mtok: 0.1,
|
||||
output_per_mtok: 0.5,
|
||||
cache_read_per_mtok: 0.01,
|
||||
cache_write_per_mtok: 0.125,
|
||||
cache_write_1h_per_mtok: 0.2,
|
||||
long_input_per_mtok: 0.5,
|
||||
long_output_per_mtok: 2.5,
|
||||
},
|
||||
];
|
||||
const haiku = (extra) => bucket({ model: "claude-haiku-5-5", ...extra });
|
||||
|
||||
it("counts a request into the long subsets by its whole prompt: input + cache read + cache write", () => {
|
||||
const short = extractUsageFields({ input_tokens: 100_000, output_tokens: 5 });
|
||||
assert.equal(short.longInput, 0);
|
||||
const long = extractUsageFields({
|
||||
input_tokens: 10,
|
||||
output_tokens: 5,
|
||||
cache_read_input_tokens: 90_000,
|
||||
cache_creation_input_tokens: 10_000,
|
||||
cache_creation: { ephemeral_5m_input_tokens: 4_000, ephemeral_1h_input_tokens: 6_000 },
|
||||
});
|
||||
assert.deepEqual(
|
||||
[
|
||||
long.longInput,
|
||||
long.longOutput,
|
||||
long.longCacheRead,
|
||||
long.longCacheWrite,
|
||||
long.longCacheWrite1h,
|
||||
],
|
||||
[10, 5, 90_000, 10_000, 6_000]
|
||||
);
|
||||
});
|
||||
|
||||
it("prices the long subset at the long rates, cache rates scaled by the input ratio", () => {
|
||||
const all = {
|
||||
input_tokens: M,
|
||||
output_tokens: M,
|
||||
cache_read_tokens: M,
|
||||
cache_write_tokens: 2 * M,
|
||||
cache_write_1h_tokens: M,
|
||||
};
|
||||
const long = Object.fromEntries(Object.entries(all).map(([k, v]) => [`long_${k}`, v]));
|
||||
// 0.5 + 2.5 + 0.05 + 0.625 + 1.0
|
||||
assert.equal(calculateCost([haiku({ ...all, ...long })], HAIKU).total_cost, 4.675);
|
||||
});
|
||||
|
||||
it("prices only the long part of a bucket at the long rates", () => {
|
||||
const r = calculateCost([haiku({ input_tokens: 2 * M, long_input_tokens: M })], HAIKU);
|
||||
assert.equal(r.total_cost, 0.6);
|
||||
assert.equal(r.breakdown[0].long_input_tokens, M);
|
||||
});
|
||||
|
||||
it("never prices more long tokens than the bucket holds", () => {
|
||||
const r = calculateCost([haiku({ input_tokens: M, long_input_tokens: 3 * M })], HAIKU);
|
||||
assert.equal(r.total_cost, 0.5);
|
||||
});
|
||||
|
||||
it("prices a long subset at the standard rates when the rule has no long rates", () => {
|
||||
const r = calculateCost([bucket({ input_tokens: M, long_input_tokens: M })], RULES);
|
||||
assert.equal(r.total_cost, 5);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user