/** * @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. * Never 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 router = Router(); router.get("/", async (req, res) => { try { await pool.refreshQuotas({ force: req.query.force === "1" }); res.json({ accounts: pool.poolStatus(), blockPercent: pool.BLOCK_PERCENT }); } catch (e) { res.status(500).json({ error: { code: e.code || "EPOOL", message: e.message } }); } }); module.exports = router;