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:
2026-10-08 12:22:14 +07:00
parent 6ef9a5d4b7
commit a9c71cd905
133 changed files with 8007 additions and 1830 deletions
+52 -3
View File
@@ -11,9 +11,16 @@
* price; anything unknown collapses to the standard/global default so old
* transcripts (which lack `speed` / `inference_geo` / `cache_creation`
* breakdown / `server_tool_use`) price exactly as they did before.
*
* A request whose whole prompt (input + cache read + cache write) is above
* LONG_CONTEXT_TOKENS is ALSO counted into the bucket's `long*` fields — a
* subset of the totals, like `cacheWrite1h` — so cost can price that part at
* the model's long-context rates.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
const { LONG_CONTEXT_TOKENS } = require("./pricing-constants");
// Separator for composite bucket keys — U+0001 (SOH) cannot occur in a model id.
const BUCKET_SEP = String.fromCharCode(1);
@@ -56,6 +63,13 @@ function emptyBucket(model, speed, geo, tier) {
webSearch: 0, // server_tool_use.web_search_requests (billed per 1k)
webFetch: 0, // server_tool_use.web_fetch_requests (free; tracked for visibility)
codeExec: 0, // server_tool_use.code_execution_requests (time-billed; estimated)
// Subsets of input/output/cacheRead/cacheWrite/cacheWrite1h spent by
// requests whose prompt was above LONG_CONTEXT_TOKENS.
longInput: 0,
longOutput: 0,
longCacheRead: 0,
longCacheWrite: 0,
longCacheWrite1h: 0,
};
}
@@ -76,6 +90,11 @@ function extractUsageFields(usage) {
webSearch: 0,
webFetch: 0,
codeExec: 0,
longInput: 0,
longOutput: 0,
longCacheRead: 0,
longCacheWrite: 0,
longCacheWrite1h: 0,
};
}
const cc =
@@ -93,18 +112,42 @@ function extractUsageFields(usage) {
usage.server_tool_use && typeof usage.server_tool_use === "object"
? usage.server_tool_use
: null;
const input = usage.input_tokens || 0;
const output = usage.output_tokens || 0;
const cacheRead = usage.cache_read_input_tokens || 0;
const long = input + cacheRead + cacheWrite > LONG_CONTEXT_TOKENS;
return {
input: usage.input_tokens || 0,
output: usage.output_tokens || 0,
cacheRead: usage.cache_read_input_tokens || 0,
input,
output,
cacheRead,
cacheWrite,
cacheWrite1h,
webSearch: stu ? stu.web_search_requests || 0 : 0,
webFetch: stu ? stu.web_fetch_requests || 0 : 0,
codeExec: stu ? stu.code_execution_requests || 0 : 0,
longInput: long ? input : 0,
longOutput: long ? output : 0,
longCacheRead: long ? cacheRead : 0,
longCacheWrite: long ? cacheWrite : 0,
longCacheWrite1h: long ? cacheWrite1h : 0,
};
}
/**
* A bucket's long-context subsets in `long_*_tokens` column order, or null
* when it has none (the caller then skips the extra write).
*/
function longArgs(b) {
const args = [
b.longInput,
b.longOutput,
b.longCacheRead,
b.longCacheWrite,
b.longCacheWrite1h,
].map((n) => n || 0);
return args.some((n) => n > 0) ? args : null;
}
/** Add the numeric fields of `src` into `target` in place. */
function accumulateBucket(target, src) {
target.input += src.input || 0;
@@ -115,6 +158,11 @@ function accumulateBucket(target, src) {
target.webSearch += src.webSearch || 0;
target.webFetch += src.webFetch || 0;
target.codeExec += src.codeExec || 0;
target.longInput = (target.longInput || 0) + (src.longInput || 0);
target.longOutput = (target.longOutput || 0) + (src.longOutput || 0);
target.longCacheRead = (target.longCacheRead || 0) + (src.longCacheRead || 0);
target.longCacheWrite = (target.longCacheWrite || 0) + (src.longCacheWrite || 0);
target.longCacheWrite1h = (target.longCacheWrite1h || 0) + (src.longCacheWrite1h || 0);
return target;
}
@@ -127,4 +175,5 @@ module.exports = {
emptyBucket,
extractUsageFields,
accumulateBucket,
longArgs,
};