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:
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @file quit.js — Quit AgentHub (issue #65, 9router's tray "Quit"): stop the
|
||||
* dashboard and every lane pane, and keep it stopped until the user starts it
|
||||
* again. "Stopped" is the file `<data dir>/runtime/stopped`: the plugin
|
||||
* bootstrap starts no server while it exists, and every server that starts
|
||||
* clears it — so a boot or login through an enabled autostart unit still
|
||||
* brings the dashboard back, and only Claude Code's SessionStart is held off.
|
||||
* Kept free of anything but fs/path: the bootstrap reads it before the
|
||||
* runtime's dependencies are installed.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { getDataDir } = require("./claude-home");
|
||||
|
||||
function flagPath(rt = path.join(getDataDir(), "runtime")) {
|
||||
return path.join(rt, "stopped");
|
||||
}
|
||||
|
||||
function isQuit(rt) {
|
||||
return fs.existsSync(flagPath(rt));
|
||||
}
|
||||
|
||||
function markQuit(rt) {
|
||||
const file = flagPath(rt);
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(file, `${new Date().toISOString()}\n`, "utf8");
|
||||
}
|
||||
|
||||
function clearQuit(rt) {
|
||||
fs.rmSync(flagPath(rt), { force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops this server. A unit of ours that is running is stopped THROUGH its
|
||||
* service manager: a SIGTERM'd server exits 0, which `Restart=always` /
|
||||
* `KeepAlive` answer by starting it again. Async spawns, because launchd's
|
||||
* `bootout` waits for the job — this process — to exit. If this process was
|
||||
* not the unit's (a second dashboard beside it), it follows a moment later.
|
||||
*/
|
||||
function stopServer({
|
||||
svc = require("../../scripts/service-manager"),
|
||||
spawn = require("child_process").spawn,
|
||||
kill = () => process.kill(process.pid, "SIGTERM"),
|
||||
} = {}) {
|
||||
const owned =
|
||||
svc.systemctlAvailable() && svc.unitIsOurs("agenthub") && svc.unitIsActive("agenthub");
|
||||
if (!owned) return kill();
|
||||
const argv =
|
||||
svc.kind === "launchd"
|
||||
? ["launchctl", ["bootout", `gui/${process.getuid()}/io.smartgift.agenthub`]]
|
||||
: ["systemctl", ["--user", "stop", "--no-block", "agenthub.service"]];
|
||||
spawn(argv[0], argv[1], { detached: true, stdio: "ignore" }).unref();
|
||||
setTimeout(kill, 5000).unref();
|
||||
}
|
||||
|
||||
module.exports = { flagPath, isQuit, markQuit, clearQuit, stopServer };
|
||||
Reference in New Issue
Block a user