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:
@@ -19,10 +19,11 @@
|
||||
* fast columns: Codex's fast/priority service tier is booked as `speed = fast`
|
||||
* (`codex-usage.js`), and its flex tier as `service_tier = 'flex'` (half price,
|
||||
* like batch, in `ratesForBucket`).
|
||||
* A Claude model's `*_above_100k_tokens` input/output rates (Haiku 5.5) fill
|
||||
* the long_* columns, priced against token_usage's long-context subsets.
|
||||
* ponytail: OpenAI's long-context (>272k) and Gemini's >200k-token rates are
|
||||
* not modelled — Codex's context window (258k) stays under 272k and no current
|
||||
* Claude model has such a tier; it needs a context-size bucket in token_usage
|
||||
* (a primary-key rebuild) if that changes.
|
||||
* not modelled — Codex's context window (258k) stays under 272k, and a
|
||||
* threshold other than LONG_CONTEXT_TOKENS (100k) needs its own subsets.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
@@ -112,6 +113,14 @@ function toRow(fam, e) {
|
||||
: [per(e.input_cost_per_token_priority), per(e.output_cost_per_token_priority)];
|
||||
const prioOk =
|
||||
prio.length > 0 && prio.every((v) => Number.isFinite(v) && v > 0 && v <= MAX_PER_MTOK);
|
||||
const long = claude
|
||||
? [
|
||||
per(e.input_cost_per_token_above_100k_tokens),
|
||||
per(e.output_cost_per_token_above_100k_tokens),
|
||||
]
|
||||
: [];
|
||||
const longOk =
|
||||
long.length > 0 && long.every((v) => Number.isFinite(v) && v > 0 && v <= MAX_PER_MTOK);
|
||||
// Rounded: 0.000004 * 1e6 is 3.9999999999999996, which Settings would show.
|
||||
const r = (n) => Math.round(n * 1e6) / 1e6;
|
||||
return {
|
||||
@@ -124,6 +133,8 @@ function toRow(fam, e) {
|
||||
w1h: r(w1h),
|
||||
fastIn: fastOk ? r(input * fast) : prioOk ? r(prio[0]) : 0,
|
||||
fastOut: fastOk ? r(output * fast) : prioOk ? r(prio[1]) : 0,
|
||||
longIn: longOk ? r(long[0]) : 0,
|
||||
longOut: longOk ? r(long[1]) : 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,6 +203,8 @@ const RATE_COLS = [
|
||||
["w1h", "cache_write_1h_per_mtok"],
|
||||
["fastIn", "fast_input_per_mtok"],
|
||||
["fastOut", "fast_output_per_mtok"],
|
||||
["longIn", "long_input_per_mtok"],
|
||||
["longOut", "long_output_per_mtok"],
|
||||
];
|
||||
const sameRates = (row, db) => RATE_COLS.every(([k, col]) => Math.abs(row[k] - db[col]) < 1e-9);
|
||||
|
||||
@@ -253,12 +266,14 @@ async function syncPricing(db, { fetchList = defaultFetch, now = Date.now() } =
|
||||
const insert = db.prepare(
|
||||
`INSERT OR IGNORE INTO model_pricing (model_pattern, display_name, input_per_mtok,
|
||||
output_per_mtok, cache_read_per_mtok, cache_write_per_mtok, cache_write_1h_per_mtok,
|
||||
fast_input_per_mtok, fast_output_per_mtok, source) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'sync')`
|
||||
fast_input_per_mtok, fast_output_per_mtok, long_input_per_mtok, long_output_per_mtok, source)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'sync')`
|
||||
);
|
||||
const update = db.prepare(
|
||||
`UPDATE model_pricing SET display_name = ?, input_per_mtok = ?, output_per_mtok = ?,
|
||||
cache_read_per_mtok = ?, cache_write_per_mtok = ?, cache_write_1h_per_mtok = ?,
|
||||
fast_input_per_mtok = ?, fast_output_per_mtok = ?,
|
||||
long_input_per_mtok = ?, long_output_per_mtok = ?,
|
||||
updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
||||
WHERE model_pattern = ? AND source = 'sync'`
|
||||
);
|
||||
@@ -273,7 +288,17 @@ async function syncPricing(db, { fetchList = defaultFetch, now = Date.now() } =
|
||||
if (dismissed.has(pattern)) continue;
|
||||
const row = toRow(fam, list[fam]);
|
||||
if (!row) continue;
|
||||
const rates = [row.input, row.output, row.read, row.w5m, row.w1h, row.fastIn, row.fastOut];
|
||||
const rates = [
|
||||
row.input,
|
||||
row.output,
|
||||
row.read,
|
||||
row.w5m,
|
||||
row.w1h,
|
||||
row.fastIn,
|
||||
row.fastOut,
|
||||
row.longIn,
|
||||
row.longOut,
|
||||
];
|
||||
const have = rows.get(pattern);
|
||||
if (!have) {
|
||||
if (insert.run(pattern, row.name, ...rates).changes) added.push(pattern);
|
||||
|
||||
Reference in New Issue
Block a user