/** * Self-contained HTML pages served in place of an installed app's real UI * bundle while it's building, or when it can never be served (missing file * with no `ui.build`, a failed build, a removed app dir). Both surfaces that * serve an app's UI as a PAGE — the `ui://app_ui_/view` MCP resource * (app-ui-apps.ts) and `GET /apps/:appId/ui` (http-server.ts) — render * through here instead of ever putting raw `{"error":...}` JSON in a page * body. That JSON shape is kept exactly as-is for MCP TOOL callers (e.g. * `app_install`'s error result) — this module is for the two PAGE routes * only. * * Reload strategy — deliberately two different mechanisms for the two * hosts, because neither works everywhere: * * - The VS Code webview panel (packages/vscode appPanel.ts) embeds this * page as an inner `srcdoc` iframe of an outer document it fully * controls (buildAppHostHtml). `srcdoc` has no URL, so a navigation * inside it (meta-refresh) just re-parses the SAME string — it can * never pick up new content on its own. The extension host is what can: * appPanel.ts detects `BUILDING_STATUS_ATTR` on the returned html and * re-issues `resources/read` on a timer, replacing `panel.webview.html` * wholesale until the marker is gone (see appPanel.logic.ts's * `isAppUiBuilding`). * - `GET /apps/:appId/ui` (http-server.ts) IS a real navigation target. * The page keeps a meta refresh as a no-script fallback and also calls * `location.reload()` from its inline timer. VS Code's Simple Browser can * leave a meta refresh parked in an embedded page; the explicit reload is * what makes the already-open tab pick up the completed bundle reliably. * * Both mechanisms are outside this module's own script, which is * deliberate: the page also has to survive the strictest CSP either host * imposes — the VS Code outer document sets `default-src 'none'; script-src * 'unsafe-inline'; style-src 'unsafe-inline'` with NO `connect-src`, and the * srcdoc iframe inherits it verbatim, so nothing here may `fetch`, open a * `WebSocket`/`EventSource`, or load an external image/font. The one bit of * live JS this page does carry — the elapsed-time counter and an HTTP-page * reload timer — needs no `connect-src`. The reload is skipped for the * webview's `about:srcdoc`, whose extension host owns polling. */ /** `data-agentproto-ui-status` value while a build is in flight (or about to * start) — `appPanel.logic.ts`'s `isAppUiBuilding` matches on this exact * attribute/value pair; keep the two in lockstep (same cross-package * duplication the file's own `appUiToolId` already accepts, since a * `ui://`-served page can't import back into `@agentproto/vscode`). */ declare const APP_UI_BUILDING_STATUS_ATTR = "data-agentproto-ui-status=\"building\""; interface AppUiBuildingHtmlInput { readonly appName: string; /** `Date.now()`-style epoch ms the build actually started — the elapsed * counter is computed client-side off this, not baked in as static text, * so it keeps ticking between reloads. */ readonly startedAt: number; /** Last lines of the app's ui-build log (`appUiBuildLogPath`), if cheap to read. */ readonly logTail?: string; } /** The "still building" placeholder — see the module doc for the reload * strategy. Never blocks on the build itself; the caller decides when to * show this (app-ui-build.ts's `resolveAppUiBuildState`). */ declare function renderAppUiBuildingHtml(input: AppUiBuildingHtmlInput): string; interface AppUiErrorHtmlInput { readonly appName: string; readonly message: string; /** A path worth showing verbatim (the missing file, the removed app dir, * the build log). */ readonly detailPath?: string; readonly logTail?: string; /** Defaults to the generic reinstall/APP.md pointer. */ readonly fix?: string; } /** A readable terminal-failure page — never auto-reloads (unlike the * building placeholder): the failure already happened, and refreshing a * failed `ui.build` run on a timer would just re-run it forever. A human * reloading the panel/tab gets a fresh attempt instead. */ declare function renderAppUiErrorHtml(input: AppUiErrorHtmlInput): string; export { APP_UI_BUILDING_STATUS_ATTR, type AppUiBuildingHtmlInput, type AppUiErrorHtmlInput, renderAppUiBuildingHtml, renderAppUiErrorHtml };