/** * @file Where the running dashboard answers, for a process that is NOT the * dashboard: the `agenthub` CLI, the MCP server (`mcp/server.js`) and the * statusline (`statusline/statusline.js`). An explicit CLAUDE_DASHBOARD_PORT / * DASHBOARD_PORT wins (the hook handler's contract), then the live-server * discovery file `~/.claude/.agenthub.json` (`server-info.js`, PID-checked), * then the default port. Never throws. * @author Nguyễn Ngọc Trí Vĩ */ const path = require("node:path"); /** Base URL of the live dashboard, e.g. `http://127.0.0.1:4820`. */ function dashboardUrl() { const envPort = process.env.CLAUDE_DASHBOARD_PORT || process.env.DASHBOARD_PORT; if (envPort) return `http://127.0.0.1:${envPort}`; try { const { resolveDashboardPort } = require(path.join(__dirname, "server-info.js")); const port = resolveDashboardPort(); if (port) return `http://127.0.0.1:${port}`; } catch { /* discovery unavailable — fall through to the default */ } return "http://127.0.0.1:4820"; } module.exports = { dashboardUrl };