import type { TraceSession } from "./trace-session.js"; export declare function buildUiUrl(port: number): string; /** Resolve a request route to a static UI asset path, GUARDED against path * traversal: the resolved path must stay inside the ui directory. Returns null * for "/" (handled separately as index.html) and for anything escaping the dir. * Pure (no fs access) so it can be unit-tested. */ export declare function resolveStaticAsset(route: string): { filePath: string; contentType: string; } | null; /** Allow a WS upgrade only from a loopback Origin, or when no Origin is sent * (native/non-browser clients). Defends against cross-site WebSocket hijacking. */ export declare function originIsLoopback(info: { origin?: string; }): boolean; /** §12.4 best-effort open of the dashboard in the SYSTEM browser — the fallback * used by the `start` watchdog (§12.6) when nobody opened the in-editor link. * Routing/mode (vscode-link vs immediate vs none) is decided by the caller in * index.ts; this just does the actual system-browser open. SKIPS (returns * false) when CROSSPAD_TRACE_NO_BROWSER is set, or on linux with no * DISPLAY/WAYLAND_DISPLAY (headless). Never throws. */ export declare function openInBrowser(url: string): boolean; /** * §12.1 Persistent dashboard singleton. ONE http+ws server that OUTLIVES trace * sessions for the MCP server's whole lifetime. `currentSession` is mutable: * `bind` attaches a new trace (subscribes to its frames + broadcasts a * `trace_start`); `unbind` detaches it (broadcasts `trace_end`) WITHOUT tearing * the server down, so a browser / VS Code Simple Browser tab stays connected * across start→stop→start cycles. The port (7373) is therefore stable. */ export declare class Dashboard { private server; private wss; private clients; private url; private currentSession; port: number; /** §12.1 start listening once; idempotent — a second call reuses the running * server and resolves with the same url. The server keeps listening across * every trace, so the dashboard tab never goes dead. */ ensureStarted(preferredPort?: number): Promise; /** §12.1 attach a new trace: become its frame sink, broadcast trace_start. */ bind(session: TraceSession): void; /** §12.1 detach the current trace: broadcast trace_end, go idle. The server * KEEPS listening (clients stay connected, ready for the next trace). */ unbind(): void; /** §12.4: any WS client connected right now? `start` uses this to auto-open * the browser ONLY when the dashboard isn't already open in some tab. */ hasClients(): boolean; /** §9/§12.3 GET /symbols handler: resolve symbols against the active session's * ELF, or — when idle — the configured DEFAULT ELF so autocomplete keeps * working between traces. Failures reply 500 rather than crashing the server. */ private serveSymbols; /** Parse a browser → server WS message and forward `add`/`remove` to the bound * session. Ignored when idle (no currentSession) or when malformed (bad JSON, * wrong shape) — silently, per §5. */ private handleInbound; private broadcast; } export declare function getDashboard(): Dashboard;