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:
+90
-1
@@ -239,6 +239,14 @@ db.exec(`
|
||||
baseline_web_search INTEGER NOT NULL DEFAULT 0,
|
||||
baseline_web_fetch INTEGER NOT NULL DEFAULT 0,
|
||||
baseline_code_execution INTEGER NOT NULL DEFAULT 0,
|
||||
-- Subsets of the token columns spent by requests whose prompt was above
|
||||
-- LONG_CONTEXT_TOKENS (server/lib/pricing-constants.js), priced at the
|
||||
-- rule's long_* rates. Kept at their high-water mark like the hourly rows.
|
||||
long_input_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_output_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_cache_read_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_cache_write_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_cache_write_1h_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (session_id, model, speed, inference_geo, service_tier),
|
||||
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -262,6 +270,14 @@ db.exec(`
|
||||
web_search_requests INTEGER NOT NULL DEFAULT 0,
|
||||
web_fetch_requests INTEGER NOT NULL DEFAULT 0,
|
||||
code_execution_requests INTEGER NOT NULL DEFAULT 0,
|
||||
-- Subsets of the token columns spent by requests whose prompt was above
|
||||
-- LONG_CONTEXT_TOKENS (server/lib/pricing-constants.js), priced at the
|
||||
-- rule's long_* rates. Kept at their high-water mark like the hourly rows.
|
||||
long_input_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_output_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_cache_read_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_cache_write_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
long_cache_write_1h_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (session_id, hour, model, speed, inference_geo, service_tier),
|
||||
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -279,6 +295,11 @@ db.exec(`
|
||||
-- caching multipliers (see server/lib/pricing-constants.js).
|
||||
fast_input_per_mtok REAL NOT NULL DEFAULT 0,
|
||||
fast_output_per_mtok REAL NOT NULL DEFAULT 0,
|
||||
-- Rates for a request whose prompt is above LONG_CONTEXT_TOKENS (Haiku 5.5);
|
||||
-- 0 = no long-context pricing. Cache rates are derived from long_input by
|
||||
-- the same ratio, as fast mode's are.
|
||||
long_input_per_mtok REAL NOT NULL DEFAULT 0,
|
||||
long_output_per_mtok REAL NOT NULL DEFAULT 0,
|
||||
-- Time-limited introductory rates. When intro_until is set, usage on/before
|
||||
-- that date (YYYY-MM-DD) is priced at the intro_* rates and usage after it at
|
||||
-- the standard rates — so promo pricing (e.g. Claude Sonnet 5's launch
|
||||
@@ -999,6 +1020,19 @@ try {
|
||||
setFast.run(30, 150, "claude-opus-4-6%");
|
||||
}
|
||||
|
||||
// Migrate: long-context rate columns (0 = none; filled by the pricing sync or
|
||||
// DEFAULT_PRICING's top-up below).
|
||||
try {
|
||||
db.prepare("SELECT long_input_per_mtok FROM model_pricing LIMIT 1").get();
|
||||
} catch {
|
||||
db.prepare(
|
||||
"ALTER TABLE model_pricing ADD COLUMN long_input_per_mtok REAL NOT NULL DEFAULT 0"
|
||||
).run();
|
||||
db.prepare(
|
||||
"ALTER TABLE model_pricing ADD COLUMN long_output_per_mtok REAL NOT NULL DEFAULT 0"
|
||||
).run();
|
||||
}
|
||||
|
||||
// Migrate: add time-limited introductory-rate columns to model_pricing.
|
||||
// Usage on/before intro_until prices at the intro_* rates; usage after prices at
|
||||
// standard — so promo pricing (e.g. Claude Sonnet 5's launch discount) stays
|
||||
@@ -1602,6 +1636,27 @@ try {
|
||||
db.pragma("foreign_keys = ON");
|
||||
}
|
||||
|
||||
// Migrate: long-context subsets (Haiku 5.5 bills a prompt above 100k tokens at
|
||||
// higher rates). Plain added columns, NOT a new key dimension: a build that
|
||||
// predates them (prod and dev share one DB) keeps writing its rows unchanged,
|
||||
// and an existing row's totals never split, so nothing is counted twice.
|
||||
const LONG_TOKEN_COLS = [
|
||||
"long_input_tokens",
|
||||
"long_output_tokens",
|
||||
"long_cache_read_tokens",
|
||||
"long_cache_write_tokens",
|
||||
"long_cache_write_1h_tokens",
|
||||
];
|
||||
for (const table of ["token_usage", "token_usage_hourly"]) {
|
||||
try {
|
||||
db.prepare(`SELECT long_input_tokens FROM ${table} LIMIT 1`).get();
|
||||
} catch {
|
||||
for (const col of LONG_TOKEN_COLS) {
|
||||
db.prepare(`ALTER TABLE ${table} ADD COLUMN ${col} INTEGER NOT NULL DEFAULT 0`).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Startup cleanup: mark stale active sessions as completed.
|
||||
// Legacy sessions (created before SessionEnd hook) will never receive a SessionEnd event,
|
||||
// so they stay "active" forever. Complete any active session whose last event is older than
|
||||
@@ -2052,6 +2107,38 @@ const stmts = {
|
||||
OR excluded.web_fetch_requests > web_fetch_requests
|
||||
OR excluded.code_execution_requests > code_execution_requests
|
||||
`),
|
||||
// A bucket's long-context subsets (see the token_usage columns), written
|
||||
// after its row by the same caller. Args: the five long_* values in column
|
||||
// order, then the row's key. RAISE keeps the high-water mark (the live and
|
||||
// import writers, like the hourly rows); SET is the exact reconcile path's.
|
||||
raiseLongTokens: db.prepare(`
|
||||
UPDATE token_usage SET
|
||||
long_input_tokens = MAX(long_input_tokens, ?),
|
||||
long_output_tokens = MAX(long_output_tokens, ?),
|
||||
long_cache_read_tokens = MAX(long_cache_read_tokens, ?),
|
||||
long_cache_write_tokens = MAX(long_cache_write_tokens, ?),
|
||||
long_cache_write_1h_tokens = MAX(long_cache_write_1h_tokens, ?)
|
||||
WHERE session_id = ? AND model = ? AND speed = ? AND inference_geo = ? AND service_tier = ?
|
||||
`),
|
||||
setLongTokens: db.prepare(`
|
||||
UPDATE token_usage SET
|
||||
long_input_tokens = ?,
|
||||
long_output_tokens = ?,
|
||||
long_cache_read_tokens = ?,
|
||||
long_cache_write_tokens = ?,
|
||||
long_cache_write_1h_tokens = ?
|
||||
WHERE session_id = ? AND model = ? AND speed = ? AND inference_geo = ? AND service_tier = ?
|
||||
`),
|
||||
raiseLongHourly: db.prepare(`
|
||||
UPDATE token_usage_hourly SET
|
||||
long_input_tokens = MAX(long_input_tokens, ?),
|
||||
long_output_tokens = MAX(long_output_tokens, ?),
|
||||
long_cache_read_tokens = MAX(long_cache_read_tokens, ?),
|
||||
long_cache_write_tokens = MAX(long_cache_write_tokens, ?),
|
||||
long_cache_write_1h_tokens = MAX(long_cache_write_1h_tokens, ?)
|
||||
WHERE session_id = ? AND hour = ? AND model = ? AND speed = ? AND inference_geo = ?
|
||||
AND service_tier = ?
|
||||
`),
|
||||
getTokenTotals: db.prepare(`
|
||||
SELECT
|
||||
COALESCE(SUM(input_tokens + baseline_input), 0) as total_input,
|
||||
@@ -2073,7 +2160,9 @@ const stmts = {
|
||||
cache_write_1h_tokens + baseline_cache_write_1h as cache_write_1h_tokens,
|
||||
web_search_requests + baseline_web_search as web_search_requests,
|
||||
web_fetch_requests + baseline_web_fetch as web_fetch_requests,
|
||||
code_execution_requests + baseline_code_execution as code_execution_requests
|
||||
code_execution_requests + baseline_code_execution as code_execution_requests,
|
||||
long_input_tokens, long_output_tokens, long_cache_read_tokens,
|
||||
long_cache_write_tokens, long_cache_write_1h_tokens
|
||||
FROM token_usage WHERE session_id = ?`
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user