// SPEC: PJ2026-01060508 Web哨兵 draft-2026-06-26-p7-web-probe-sentinel-dashboard. // Responsibility: Static dashboard shell and asset serving for the web-probe sentinel frontend. import { readFileSync } from "node:fs"; import { rootPath } from "./config"; interface DashboardShellConfig { readonly node: string; readonly lane: string; readonly plan: { readonly ok: boolean }; readonly publicExposure: Record; } const DASHBOARD_ASSET_ROOT = "scripts/assets/web-probe-sentinel-dashboard"; const DASHBOARD_CONTRACT_VERSION = "draft-2026-06-26-p7-web-probe-sentinel-dashboard"; export function renderWebProbeSentinelDashboardHtml(config: DashboardShellConfig): string { const publicOrigin = stringOrNull(config.publicExposure.publicBaseUrl) ?? ""; return ` HWLAB Web Probe Sentinel

HWLAB Web Probe Sentinel

${escapeHtml(config.node)} / ${escapeHtml(config.lane)}

idle
Overall - -
Latest run - -
Findings 0 -
Scheduler - -
config - pvc - analyzer - public - maintenance -

Run Timeline

-

Runs

-
Run Status Scenario Findings Updated

Findings

-
`; } export function webProbeSentinelDashboardAssetResponse(pathname: string): Response | null { if (pathname === "/dashboard/assets/dashboard.css") return textAsset(`${DASHBOARD_ASSET_ROOT}/dashboard.css`, "text/css; charset=utf-8"); if (pathname === "/dashboard/assets/dashboard.js") return textAsset(`${DASHBOARD_ASSET_ROOT}/dashboard.js`, "application/javascript; charset=utf-8"); return null; } function textAsset(path: string, contentType: string): Response { return new Response(readFileSync(rootPath(path), "utf8"), { headers: { "cache-control": "no-store", "content-type": contentType, }, }); } function stringOrNull(value: unknown): string | null { return typeof value === "string" && value.length > 0 ? value : null; } function escapeHtml(value: string): string { return value.replace(/&/gu, "&").replace(//gu, ">").replace(/"/gu, """); } function escapeAttr(value: string): string { return escapeHtml(value).replace(/'/gu, "'"); }