// SPEC: PJ2026-01060508 Web哨兵 draft-2026-06-26-p8-web-probe-sentinel-recovery. // 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-p8-web-probe-sentinel-recovery"; export function renderWebProbeSentinelDashboardHtml(config: DashboardShellConfig): string { const publicOrigin = stringOrNull(config.publicExposure.publicBaseUrl) ?? ""; return ` HWLAB Web哨兵

HWLAB Web哨兵

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

空闲
当前状态 - -
最近运行 - -
历史发现项 0 -
调度器 - -
config - pvc - analyzer - public - maintenance -

运行时间线

-

运行历史

-
运行 状态 场景 发现项 更新时间

发现分析

-
`; } 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, "'"); }