/** * @file accounts.js * @description `GET /api/accounts` — the Claude account pool as the balancer * sees it (server/lib/claude-pool.js): per account its live panes, $ spent in * the last 5 h / 7 d, the last quota reading and whether it counts as full; * `codex` is the same for the Codex pool (server/lib/codex-pool.js). Never a * key or a token. `?force=1` re-reads every quota first. Accounts are added and * removed only from the host's shell (`agenthub accounts …`). * @author Nguyễn Ngọc Trí Vĩ */ const { Router } = require("express"); const pool = require("../lib/claude-pool"); const codexPool = require("../lib/codex-pool"); const router = Router(); router.get("/", async (req, res) => { try { await pool.refreshQuotas({ force: req.query.force === "1" }); if (req.query.force === "1") codexPool.resetQuota(); res.json({ accounts: pool.poolStatus(), codex: codexPool.poolStatus(), blockPercent: pool.BLOCK_PERCENT, }); } catch (e) { res.status(500).json({ error: { code: e.code || "EPOOL", message: e.message } }); } }); module.exports = router;