Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(mcp): make Page surface registry instance-dynamic
Rahman0a438c423b01
diff --git a/.env.example b/.env.exampleindex a72406cc..07324b44 100644--- a/.env.example+++ b/.env.example@@ -134,9 +134,13 @@ OS_SESSION_SECRET=# mso-ui.<rest-of-host> from a leading mso.<rest-of-host>; otherwise it reuses the# sanitized public origin. This is instance configuration, never source-owned.# OS_MCP_UI_ORIGIN=https://mso-ui.example.com-# Optional reviewed Page/Surface app catalog. Default is empty (no external frame-# domains). JSON must be a bounded array of safe HTTPS origins and absolute paths.-# Example:+# Reviewed Page/Surface app catalog. Portable source stays empty; each owner may+# maintain ~/.mso/surface-apps.json (0600) as the live per-instance registry. The+# Page re-reads it when resources/read runs, so reviewed app/CSP changes do not+# require a source edit or rebuild. Optional alternate file:+# MSO_SURFACE_APPS_FILE=~/.mso/surface-apps.json+# Backward-compatible deployment override: when this variable is DEFINED it wins+# over the file (an empty value intentionally disables external Page apps).# MSO_SURFACE_APPS_JSON=[{"id":"demo","title":"Demo","description":"Reviewed instance app","origin":"https://demo.example.com","startPath":"/embed","renderer":"iframe","presentation":"inline","environment":"production","sandbox":"allow-scripts allow-same-origin allow-forms"}]# Authenticated inbound A2A also requires this exact HTTPS origin. It is never# inferred from Host/X-Forwarded-Host for the public Agent Card/protocol endpoint.diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 29461da1..fe858a26 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -123,7 +123,7 @@ MSO exposes exactly two user-visible MCP App classes instead:- `render_mso_block` binds `ui://mso/block-v2.html` for compact validation, action buttons, andCRUD input-output. A button returns a user-approved follow-up message; it does not execute amutation inside the widget, so ordinary scope, approval, audit, and workflow rules still apply.-- `render_mso_page` binds the canonical `ui://mso/page-v11.html` resource for native `/`, `/monitor`, `/project`, `/diff`,+- `render_mso_page` binds the canonical `ui://mso/page-v12.html` resource for native `/`, `/monitor`, `/project`, `/diff`,`/browser`, and `/apps/<reviewed-id>` views. Native Page views call the same bounded MSO tools.`workflow_start` is orchestration-only and headless: it still owns workflow isolation, skill/recipe@@ -133,7 +133,7 @@ lookup, collision detection, tracing, evidence, and learning, but no longer bindwidgets; prior Block/Page URIs plus the previous workflow/surface resource URIs remain readable aliases but are not advertised. Page tools use the standard MCP Apps `ui.resourceUri` binding only; the legacy ChatGPT `openai/outputTemplate` alias is intentionally absent so one tool result maps to one Page mount.Reviewed Page apps may use a nested iframe only when their exact HTTPS origin exists in the-validated per-installation `MSO_SURFACE_APPS_JSON` catalog and the MCP resource CSP `frameDomains`;+validated owner-local Page registry (`~/.mso/surface-apps.json`, or explicit `MSO_SURFACE_APPS_JSON` override) and the MCP resource CSP `frameDomains`;portable source defaults to no external Page apps. Anti-frame apps stay on the remote-browser seam.This trust catalog is deliberately separate from Store/runtime `AppManifest` data. A locally installed `runtime:"html"` app or HTML widget is user-controlled presentation dataand cannot grant itself a ChatGPT nested-frame origin. `srcDoc` HTML remains opaque-origin@@ -286,4 +286,4 @@ future archaeology task.### ChatGPT MSO Page trust boundary-Each MSO connector/server scope owns its own Page app catalog. Core MSO Page code must not import project identities or trusted frame origins from another server scope. Portable source ships with an empty external-app catalog. An installation may opt into reviewed apps through bounded `MSO_SURFACE_APPS_JSON`; MSO validates each exact HTTPS origin, approved start-path prefix, renderer, sandbox, and presentation before it can enter Page CSP. The dedicated widget origin is installation-derived from `OS_MCP_UI_ORIGIN` / `OS_PUBLIC_ORIGIN`. The Block resource has no frame domains.+Each MSO connector/server scope owns its own Page app catalog. Core MSO Page code must not import project identities or trusted frame origins from another server scope. Portable source ships with an empty external-app catalog. An installation may opt into reviewed apps through the bounded owner-local `~/.mso/surface-apps.json` registry (or an explicit `MSO_SURFACE_APPS_JSON` override); MSO re-reads the registry when the Page resource is read and validates each exact HTTPS origin, approved start-path prefix, renderer, sandbox, and presentation before it can enter Page CSP. The dedicated widget origin is installation-derived from `OS_MCP_UI_ORIGIN` / `OS_PUBLIC_ORIGIN`. The Block resource has no frame domains.diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex d0029240..e49bd604 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -15,6 +15,8 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `mcp` make Page surface registry instance-dynamic+- `update` harden release verification and settings UX- `auth` harden browser session persistence- `integrations` synchronize owner-local SC credential snapshots- `security` eliminate parser gaps and enforce strict SAST coveragediff --git a/docs/integrations/CHATGPT-UI.md b/docs/integrations/CHATGPT-UI.mdindex c8232bfa..e1e3893e 100644--- a/docs/integrations/CHATGPT-UI.md+++ b/docs/integrations/CHATGPT-UI.md@@ -9,7 +9,7 @@ The user-visible contract has exactly two canonical MCP App resources:| Surface | Entry tool | Resource | Intended use || --- | --- | --- | --- || **Block** | `render_mso_block` | `ui://mso/block-v2.html` | Compact validation, action buttons, and CRUD input-output |-| **Page** | `render_mso_page` | `ui://mso/page-v3.html` | Full native operator views and reviewed development, preview, or production app embeds |+| **Page** | `render_mso_page` | `ui://mso/page-v12.html` | Full native operator views and reviewed development, preview, or production app embeds |`workflow_start` is now headless. It remains the required orchestration bootstrap for multi-step work, including skill/recipe lookup, collision checks, workflow isolation, tracing, evidence, and learning, but it has no `_meta.ui.resourceUri` and no `openai/outputTemplate`. Starting background work therefore does not consume the answer with an unrelated workflow card.@@ -52,13 +52,13 @@ The Block resource is self-contained, has no network/frame allowlist, constructs- `/browser` — remote-browser handoff;- `/apps/<reviewed-app-id>` — reviewed app target.-The model cannot pass raw HTML or an external URL. App identity, origin, start path, renderer, environment (`development`, `preview`, `production`, or `other`), sandbox, and presentation mode come from bounded per-installation `MSO_SURFACE_APPS_JSON`. Portable source defaults to an empty external-app catalog. An iframe target is valid only when its exact HTTPS origin is also present in the Page resource's `_meta.ui.csp.frameDomains`, and the browser runtime revalidates origin plus the approved path prefix before assigning `iframe.src`.+The model cannot pass raw HTML or an external URL. App identity, origin, start path, renderer, environment (`development`, `preview`, `production`, or `other`), sandbox, and presentation mode come from the bounded per-instance reviewed registry at `~/.mso/surface-apps.json` (or the explicit `MSO_SURFACE_APPS_JSON` override). Portable source defaults to an empty external-app catalog, and the Page resource rebuilds its `SAFE_APPS` plus CSP frame domains whenever it is read. An iframe target is valid only when its exact HTTPS origin is also present in the Page resource's `_meta.ui.csp.frameDomains`, and the browser runtime revalidates origin plus the approved path prefix before assigning `iframe.src`.Apps that keep restrictive `X-Frame-Options` or `frame-ancestors` remain `remote`. MSO preserves those protections and offers the Camoufox seam instead of stripping headers. User-installed runtime HTML apps and arbitrary HTML snippets cannot add themselves to the ChatGPT frame allowlist; they remain opaque-origin `srcDoc` content inside the authenticated MSO shell.## Compatibility during migration-The canonical `resources/list` response advertises only Block and Page. Four previous URIs remain readable, but are not listed, so already-cached ChatGPT descriptors do not fail immediately:+The canonical `resources/list` response advertises only Block and Page. Previous Page/Block URIs, including `ui://mso/page-v11.html`, remain readable, but are not listed, so already-cached ChatGPT descriptors do not fail immediately:- `ui://mso/block-v1.html` resolves to the current Block resource.- `ui://mso/page-v1.html` resolves to the current Page resource.@@ -133,7 +133,7 @@ After changing UI resources or tool metadata:1. run targeted tests, `bun run verify`, and the official production release path;2. verify `initialize` reports MCP server `1.10.0` and toolset `2026.09.05.1`;3. verify `tools/list` exposes 66 ChatGPT transport tools, keeps `workflow_start` headless, marks the two compatibility actions app-only, and binds only `render_mso_block` / `render_mso_page`;-4. verify `resources/list` contains exactly `ui://mso/block-v2.html` and `ui://mso/page-v3.html`, both with `text/html;profile=mcp-app`;+4. verify `resources/list` contains exactly `ui://mso/block-v2.html` and `ui://mso/page-v12.html`, both with `text/html;profile=mcp-app`;5. verify Block has no frame domain and Page has only reviewed exact origins;6. refresh/re-scan the ChatGPT development app so its cached action/resource snapshot is replaced.diff --git a/lib/mcp/dispatch.ts b/lib/mcp/dispatch.tsindex deffc66c..9d095c72 100644--- a/lib/mcp/dispatch.ts+++ b/lib/mcp/dispatch.ts@@ -55,11 +55,11 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string, agconst tools = visibleTools(scope, profile, allowedTools);return rpcOk(id, { tools: toolList(scope, profile, allowedTools), _meta: { toolset: toolsetInfo(tools, scope, profile) } });}- case "resources/list": return rpcOk(id, { resources: listUiResources() });+ case "resources/list": return rpcOk(id, { resources: await listUiResources() });case "resources/read": {const uri = String(req.params?.uri ?? "");if (!uri) return rpcFail(id, -32602, "resources/read needs { uri }");- const resource = readUiResource(uri);+ const resource = await readUiResource(uri);if (resource) return rpcOk(id, { contents: [{ uri: resource.uri, mimeType: resource.mimeType, text: resource.text, _meta: resource._meta }] });try {const skillResource = await readMcpSkillResource(uri);diff --git a/lib/mcp/integration-model-contract.test.ts b/lib/mcp/integration-model-contract.test.tsindex 1a204a0f..35bcceb5 100644--- a/lib/mcp/integration-model-contract.test.ts+++ b/lib/mcp/integration-model-contract.test.ts@@ -45,8 +45,8 @@ it("returns identity-bound setup only in UI-private metadata on both supported M});it("keeps current and older Page resources readable and emits no extra UI type",async()=>{const {readUiResource,listUiResources,MSO_PAGE_URI}=await import("./ui-resources");- expect(listUiResources()).toHaveLength(2);const html=readUiResource(MSO_PAGE_URI)!.text;- for(const version of [1,2,3,4,5,6])expect(readUiResource(`ui://mso/page-v${version}.html`)?.text).toBe(html);+ expect(await listUiResources()).toHaveLength(2);const html=(await readUiResource(MSO_PAGE_URI))!.text;+ for(const version of [1,2,3,4,5,6])expect((await readUiResource(`ui://mso/page-v${version}.html`))?.text).toBe(html);expect(html).toContain("mountConnectionManager");expect(html).toContain("data-display-mode");const script=inlineScripts(html)[0];expect(()=>new Function(script!)).not.toThrow();});diff --git a/lib/mcp/integration-setup.test.ts b/lib/mcp/integration-setup.test.tsindex b3ba382d..eb35efd4 100644--- a/lib/mcp/integration-setup.test.ts+++ b/lib/mcp/integration-setup.test.ts@@ -4,7 +4,7 @@ import { capabilityDirect, capabilityPrivateMeta } from "@/lib/capabilities/toolimport { structuredResult } from "./dispatch-tool-support";import { SURFACE_TOOLS } from "./tools-surface";import { resolveSurfaceRoute } from "./surface-catalog";-import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";+import { msoSurfaceScript } from "./ui-surface-script";describe("MCP integration setup privacy", () => {it("keeps UI authorization out of serializable/model-visible result fields", () => {const secret = "synthetic-ui-only-capability";@@ -17,17 +17,18 @@ describe("MCP integration setup privacy", () => {// Generic model transports still serialize the weak-map-free raw result.expect(JSON.stringify(raw)).not.toContain(secret);});- it("requires write scope, accepts no credential parameters, and uses the existing Page", () => {+ it("requires write scope, accepts no credential parameters, and uses the existing Page", async () => {const tool = SURFACE_TOOLS.find(t => t.name === "integration_setup_open")!;expect(tool.scope).toBe("write"); expect(Object.keys(tool.inputSchema.properties)).toEqual(["user", "connection", "provider", "method"]);- expect((tool.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v11\.html$/);+ expect((tool.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v12\.html$/);expect(tool.meta?.["openai/outputTemplate"]).toBeUndefined();- expect(resolveSurfaceRoute("/integrations").kind).toBe("integrations");- expect(() => new Function(MSO_SURFACE_SCRIPT)).not.toThrow();- expect(MSO_SURFACE_SCRIPT).toContain('"ui/initialize"');- expect(MSO_SURFACE_SCRIPT).toContain('credentials:"omit"');- expect(MSO_SURFACE_SCRIPT).toContain('save.type="button"');- expect(MSO_SURFACE_SCRIPT).toContain('rpcRequest("ui/open-link"');- expect(MSO_SURFACE_SCRIPT).toContain('"mcp_tool_result"');+ expect((await resolveSurfaceRoute("/integrations")).kind).toBe("integrations");+ const script = await msoSurfaceScript();+ expect(() => new Function(script)).not.toThrow();+ expect(script).toContain('"ui/initialize"');+ expect(script).toContain('credentials:"omit"');+ expect(script).toContain('save.type="button"');+ expect(script).toContain('rpcRequest("ui/open-link"');+ expect(script).toContain('"mcp_tool_result"');});});diff --git a/lib/mcp/privacy-portability.test.ts b/lib/mcp/privacy-portability.test.tsindex d3600a37..2e04c92e 100644--- a/lib/mcp/privacy-portability.test.ts+++ b/lib/mcp/privacy-portability.test.ts@@ -34,13 +34,13 @@ describe("portable public MCP configuration", () => {it("has no external app or frame CSP without explicit configuration", async () => {vi.stubEnv("OS_PUBLIC_ORIGIN", "https://mso.example.test");const catalog = await import("./surface-catalog");- expect(catalog.publicSurfaceApps()).toEqual([]);- expect(catalog.surfaceFrameDomains()).toEqual([]);+ expect(await catalog.publicSurfaceApps()).toEqual([]);+ expect(await catalog.surfaceFrameDomains()).toEqual([]);const config = await import("./ui-config");expect(JSON.stringify({metadataBase: config.MSO_ORIGIN,- apps: catalog.publicSurfaceApps(),+ apps: await catalog.publicSurfaceApps(),meta: config.widgetResourceMeta("test"),}),).not.toMatch(/rahmanef\.com|\/home\/rahman/);@@ -82,16 +82,16 @@ describe("portable public MCP configuration", () => {]),);const catalog = await import("./surface-catalog");- expect(catalog.publicSurfaceApps()).toEqual([+ expect(await catalog.publicSurfaceApps()).toEqual([expect.objectContaining({id: "demo",origin: "https://demo.example.test",}),]);- expect(catalog.surfaceFrameDomains()).toEqual([+ expect(await catalog.surfaceFrameDomains()).toEqual(["https://demo.example.test",]);- expect(catalog.resolveSurfaceRoute("/apps/demo").app?.url).toBe(+ expect((await catalog.resolveSurfaceRoute("/apps/demo")).app?.url).toBe("https://demo.example.test/embed",);});@@ -111,9 +111,9 @@ describe("two independent instance presentations", () => {}]));const { readUiResource, MSO_PAGE_URI } = await import("./ui-resources");const { publicSurfaceApps, surfaceFrameDomains } = await import("./surface-catalog");- expect(publicSurfaceApps().map(app => app.id)).toEqual([id]);- expect(surfaceFrameDomains()).toEqual([`https://app.${id}.example.test`]);- const serialized = JSON.stringify(readUiResource(MSO_PAGE_URI));+ expect((await publicSurfaceApps()).map(app => app.id)).toEqual([id]);+ expect(await surfaceFrameDomains()).toEqual([`https://app.${id}.example.test`]);+ const serialized = JSON.stringify(await readUiResource(MSO_PAGE_URI));expect(serialized).toContain(`widgets.${id}.example.test`);expect(serialized).toContain(`mso.${id}.example.test`);outputs.push(serialized);diff --git a/lib/mcp/surface-catalog.test.ts b/lib/mcp/surface-catalog.test.tsindex 5df97b51..3d69bafe 100644--- a/lib/mcp/surface-catalog.test.ts+++ b/lib/mcp/surface-catalog.test.ts@@ -1,6 +1,6 @@import { afterEach, beforeEach, describe, expect, it } from "vitest";import { publicSurfaceApps, resolveSurfaceRoute, surfaceFrameDomains } from "./surface-catalog";-import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";+import { msoSurfaceScript } from "./ui-surface-script";import { OPEN_IN_MSO_SCRIPT } from "./ui-navigation";const configured = [{@@ -13,44 +13,45 @@ describe("MSO Page trusted app catalog", () => {beforeEach(() => { process.env.MSO_SURFACE_APPS_JSON = JSON.stringify(configured); });afterEach(() => { delete process.env.MSO_SURFACE_APPS_JSON; });- it("uses only instance-configured reviewed origins", () => {- expect(surfaceFrameDomains()).toEqual(["https://demo.example.test"]);- const apps = publicSurfaceApps();+ it("uses only instance-configured reviewed origins", async () => {+ expect(await surfaceFrameDomains()).toEqual(["https://demo.example.test"]);+ const apps = await publicSurfaceApps();expect(apps).toHaveLength(1);expect(apps[0]).toMatchObject({ id: "demo", title: "Demo", origin: "https://demo.example.test", startPath: "/embed", renderer: "iframe", presentation: "inline", environment: "production" });expect(JSON.stringify(apps)).not.toContain("sandbox");expect(JSON.stringify(apps)).not.toContain("externalAuthPath");- expect(resolveSurfaceRoute("/apps/demo").app?.externalAuthPath).toBe("/?auth=google");+ expect((await resolveSurfaceRoute("/apps/demo")).app?.externalAuthPath).toBe("/?auth=google");});- it("rejects arbitrary URLs, protocol-relative routes and traversal", () => {+ it("rejects arbitrary URLs, protocol-relative routes and traversal", async () => {for (const route of ["https://evil.example/app", "//evil.example/app", "/apps/unknown", "/apps/demo/../admin", "/apps/demo/%2e%2e/admin", "/apps/demo\\evil"]) {- expect(() => resolveSurfaceRoute(route), route).toThrow();+ await expect(resolveSurfaceRoute(route), route).rejects.toThrow();}});- it("keeps every configured iframe route inside its start path", () => {- const root = resolveSurfaceRoute("/apps/demo");+ it("keeps every configured iframe route inside its start path", async () => {+ const root = await resolveSurfaceRoute("/apps/demo");expect(root).toMatchObject({ kind: "app", title: "Demo", openPath: "/assistant/mcp" });expect(root.app).toMatchObject({ id: "demo", renderer: "iframe", environment: "production" });expect(new URL(root.app!.url).pathname).toBe("/embed");- const room = resolveSurfaceRoute("/apps/demo/room/ABCD?join=remote");+ const room = await resolveSurfaceRoute("/apps/demo/room/ABCD?join=remote");const url = new URL(room.app!.url);expect(url.origin).toBe("https://demo.example.test");expect(url.pathname).toBe("/embed/room/ABCD");expect(url.searchParams.get("join")).toBe("remote");});- it("ships syntactically valid browser code with no dynamic HTML sink and path-prefix revalidation", () => {- expect(() => new Function(`${OPEN_IN_MSO_SCRIPT}\n${MSO_SURFACE_SCRIPT}`)).not.toThrow();- expect(MSO_SURFACE_SCRIPT).not.toContain("innerHTML");- expect(MSO_SURFACE_SCRIPT).not.toContain("insertAdjacentHTML");- expect(MSO_SURFACE_SCRIPT).not.toContain("document.write");- expect(MSO_SURFACE_SCRIPT).toContain('rpcRequest("tools/call"');- expect(MSO_SURFACE_SCRIPT).toContain('rpcCall("render_mso_page"');- expect(MSO_SURFACE_SCRIPT).not.toContain("window.openai.callTool");- expect(MSO_SURFACE_SCRIPT).toContain("url.origin!==safe.origin");- expect(MSO_SURFACE_SCRIPT).toContain("!url.pathname.startsWith(start+\"/\")");- expect(MSO_SURFACE_SCRIPT).not.toContain("play-together:embed-ready");+ it("ships syntactically valid browser code with no dynamic HTML sink and path-prefix revalidation", async () => {+ const script = await msoSurfaceScript();+ expect(() => new Function(`${OPEN_IN_MSO_SCRIPT}\n${script}`)).not.toThrow();+ expect(script).not.toContain("innerHTML");+ expect(script).not.toContain("insertAdjacentHTML");+ expect(script).not.toContain("document.write");+ expect(script).toContain('rpcRequest("tools/call"');+ expect(script).toContain('rpcCall("render_mso_page"');+ expect(script).not.toContain("window.openai.callTool");+ expect(script).toContain("url.origin!==safe.origin");+ expect(script).toContain("!url.pathname.startsWith(start+\"/\")");+ expect(script).not.toContain("play-together:embed-ready");});});diff --git a/lib/mcp/surface-catalog.ts b/lib/mcp/surface-catalog.tsindex aabaa11a..5e0136e5 100644--- a/lib/mcp/surface-catalog.ts+++ b/lib/mcp/surface-catalog.ts@@ -1,7 +1,7 @@import { configuredSurfaceApps, type SurfaceApp } from "./surface-config";export type { SurfaceApp, SurfaceRenderer, SurfacePresentation, SurfaceEnvironment } from "./surface-config";-export function surfaceApps(): readonly SurfaceApp[] {+export async function surfaceApps(): Promise<readonly SurfaceApp[]> {return configuredSurfaceApps();}@@ -25,28 +25,28 @@ export type ResolvedSurface = {app?: SurfaceApp & { url: string };};-export function publicSurfaceApps(): Array<+export async function publicSurfaceApps(): Promise<Array<Omit<SurfaceApp, "sandbox" | "externalAuthPath">-> {- return surfaceApps().map(+>> {+ return (await surfaceApps()).map(({ sandbox: _sandbox, externalAuthPath: _externalAuthPath, ...app }) => ({...app,}),);}-export function surfaceFrameDomains(): string[] {+export async function surfaceFrameDomains(): Promise<string[]> {return [...new Set(- surfaceApps()+ (await surfaceApps()).filter((app) => app.renderer === "iframe").map((app) => app.origin),),];}-export function surfaceAppById(id: string): SurfaceApp | undefined {- return surfaceApps().find((app) => app.id === id);+export async function surfaceAppById(id: string): Promise<SurfaceApp | undefined> {+ return (await surfaceApps()).find((app) => app.id === id);}function cleanRoute(raw: string): URL {@@ -86,10 +86,10 @@ function safeDemoUrl(app: SurfaceApp, suffix: string, search: string): string {return url.href;}-export function resolveSurfaceRoute(+export async function resolveSurfaceRoute(rawRoute: string,context?: { project?: string; sha?: string },-): ResolvedSurface {+): Promise<ResolvedSurface> {const url = cleanRoute(rawRoute);const decoded = decodeURIComponent(url.pathname);const parts = decoded.split("/").filter(Boolean);@@ -137,7 +137,7 @@ export function resolveSurfaceRoute(};if (parts[0] === "apps" && parts[1]) {- const app = surfaceAppById(parts[1]);+ const app = await surfaceAppById(parts[1]);if (!app) throw new Error(`unknown MSO Page app: ${parts[1]}`);const suffix = parts.slice(2).join("/");return {diff --git a/lib/mcp/surface-config-live.test.ts b/lib/mcp/surface-config-live.test.tsnew file mode 100644index 00000000..37229c6e--- /dev/null+++ b/lib/mcp/surface-config-live.test.ts@@ -0,0 +1,64 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";++let root = "";+afterEach(async () => {+ vi.unstubAllEnvs();+ vi.resetModules();+ if (root) await rm(root, { recursive: true, force: true });+ root = "";+});++const app = (id: string, origin: string) => ({+ id,+ title: id,+ description: `reviewed ${id}`,+ origin,+ startPath: "/embed",+ renderer: "iframe",+ presentation: "inline",+ environment: "production",+ sandbox: "allow-scripts allow-same-origin",+});++describe("owner-local MSO Page surface registry", () => {+ it("re-reads reviewed apps and Page CSP without a module reload or rebuild", async () => {+ root = await mkdtemp(join(tmpdir(), "mso-surfaces-"));+ const registry = join(root, "surface-apps.json");+ vi.stubEnv("MSO_SURFACE_APPS_JSON", undefined);+ vi.stubEnv("MSO_SURFACE_APPS_FILE", registry);+ vi.stubEnv("OS_PUBLIC_ORIGIN", "https://mso.example.test");+ vi.stubEnv("OS_MCP_UI_ORIGIN", "https://mso-ui.example.test");+ vi.resetModules();+ const { configuredSurfaceApps } = await import("./surface-config");+ const { msoPageResource } = await import("./ui-surface");++ await writeFile(registry, JSON.stringify([app("alpha", "https://alpha.example.test")]), { mode: 0o600 });+ expect((await configuredSurfaceApps()).map((row) => row.id)).toEqual(["alpha"]);+ let page = await msoPageResource();+ expect(page.text).toContain('"id":"alpha"');+ expect((page._meta.ui as { csp: { frameDomains?: string[] } }).csp.frameDomains).toEqual(["https://alpha.example.test"]);++ await writeFile(registry, JSON.stringify([app("beta", "https://beta.example.test")]), { mode: 0o600 });+ expect((await configuredSurfaceApps()).map((row) => row.id)).toEqual(["beta"]);+ page = await msoPageResource();+ expect(page.text).not.toContain('"id":"alpha"');+ expect(page.text).toContain('"id":"beta"');+ expect((page._meta.ui as { csp: { frameDomains?: string[] } }).csp.frameDomains).toEqual(["https://beta.example.test"]);+ });++ it("keeps an explicitly defined JSON env value as the deployment override", async () => {+ root = await mkdtemp(join(tmpdir(), "mso-surfaces-"));+ const registry = join(root, "surface-apps.json");+ await writeFile(registry, JSON.stringify([app("file", "https://file.example.test")]), { mode: 0o600 });+ vi.stubEnv("MSO_SURFACE_APPS_FILE", registry);+ vi.stubEnv("MSO_SURFACE_APPS_JSON", JSON.stringify([app("env", "https://env.example.test")]));+ vi.resetModules();+ const { configuredSurfaceApps } = await import("./surface-config");+ expect((await configuredSurfaceApps()).map((row) => row.id)).toEqual(["env"]);+ vi.stubEnv("MSO_SURFACE_APPS_JSON", "");+ expect(await configuredSurfaceApps()).toEqual([]);+ });+});diff --git a/lib/mcp/surface-config.ts b/lib/mcp/surface-config.tsindex 1439468e..ce25ba6b 100644--- a/lib/mcp/surface-config.ts+++ b/lib/mcp/surface-config.ts@@ -1,3 +1,7 @@+import { promises as fs } from "node:fs";+import { homedir } from "node:os";+import { resolve } from "node:path";+export type SurfaceRenderer = "iframe" | "remote";export type SurfacePresentation = "inline" | "fullscreen" | "pip";export type SurfaceEnvironment = "development" | "preview" | "production" | "other";@@ -18,6 +22,13 @@ export type SurfaceApp = {const MAX_APPS = 16;const MAX_TEXT = 240;+const MAX_RAW_BYTES = 16_384;+const DEFAULT_REGISTRY = resolve(homedir(), ".mso", "surface-apps.json");+const REGISTRY_PATH = (() => {+ const value = process.env.MSO_SURFACE_APPS_FILE?.trim();+ if (!value) return DEFAULT_REGISTRY;+ return resolve(value === "~" ? homedir() : value.startsWith("~/") ? `${homedir()}/${value.slice(2)}` : value);+})();const SAFE_SANDBOX = new Set(["allow-downloads", "allow-forms", "allow-modals", "allow-orientation-lock","allow-pointer-lock", "allow-popups", "allow-popups-to-escape-sandbox",@@ -44,7 +55,6 @@ function safePath(value: unknown): string | null {} catch { return null; }}-function safeAuthPath(value: unknown): string | null {if (typeof value !== "string" || !value.startsWith("/") || value.startsWith("//") || value.length > 768 || /[\\\u0000-\u001f]/.test(value)) return null;try {@@ -82,11 +92,30 @@ function parseApp(entry: unknown, seen: Set<string>): SurfaceApp | null {};}-export function configuredSurfaceApps(raw = process.env.MSO_SURFACE_APPS_JSON): SurfaceApp[] {- if (!raw || raw.length > 16_384) return [];+async function readOwnerRegistry(): Promise<string | undefined> {+ try {+ const raw = await fs.readFile(REGISTRY_PATH, "utf8");+ return Buffer.byteLength(raw, "utf8") <= MAX_RAW_BYTES ? raw : undefined;+ } catch {+ return undefined;+ }+}++function parseRegistry(raw: string | undefined): SurfaceApp[] {+ if (!raw || Buffer.byteLength(raw, "utf8") > MAX_RAW_BYTES) return [];let entries: unknown;try { entries = JSON.parse(raw); } catch { return []; }if (!Array.isArray(entries)) return [];const seen = new Set<string>();return entries.slice(0, MAX_APPS).map((entry) => parseApp(entry, seen)).filter((app): app is SurfaceApp => app !== null);}++/**+ * Per-instance reviewed Page registry. An explicitly defined env value remains a+ * backwards-compatible deployment override (including an intentionally empty value).+ * Otherwise the owner-local registry is read on every call so adding/removing a+ * reviewed surface does not require changing portable source or rebuilding MSO.+ */+export async function configuredSurfaceApps(raw = process.env.MSO_SURFACE_APPS_JSON): Promise<SurfaceApp[]> {+ return parseRegistry(raw !== undefined ? raw : await readOwnerRegistry());+}diff --git a/lib/mcp/tools-surface.test.ts b/lib/mcp/tools-surface.test.tsindex 744bfd33..7c94633c 100644--- a/lib/mcp/tools-surface.test.ts+++ b/lib/mcp/tools-surface.test.ts@@ -39,7 +39,7 @@ describe("MSO Page MCP tools", () => {url: "https://demo.example.test/embed",});expect(result.app).not.toHaveProperty("sandbox");- expect((render.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v11\.html$/);+ expect((render.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v12\.html$/);expect(render.meta?.["openai/outputTemplate"]).toBeUndefined();});@@ -58,7 +58,7 @@ describe("MSO Page MCP tools", () => {it("uses only the standard resource binding for Page tools", () => {for (const name of ["render_mso_page", "integration_setup_open"] as const) {const value = tool(name);- expect((value.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v11\.html$/);+ expect((value.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v12\.html$/);expect(value.meta?.["openai/outputTemplate"]).toBeUndefined();}});diff --git a/lib/mcp/tools-surface.ts b/lib/mcp/tools-surface.tsindex 1d8ad660..9a9d5237 100644--- a/lib/mcp/tools-surface.ts+++ b/lib/mcp/tools-surface.ts@@ -46,8 +46,8 @@ function publicResolved(resolved: ResolvedSurface): Record<string, unknown> {}const renderPage = async (input:Record<string,unknown>) => {- const resolved=publicResolved(resolveSurfaceRoute(str(input,"route"),{project:opt(input,"project"),sha:opt(input,"sha")}));- return {...resolved,catalog:publicSurfaceApps(),...(resolved.kind==="integrations"?{integrations:await integrationSnapshot()}: {})};+ const resolved=publicResolved(await resolveSurfaceRoute(str(input,"route"),{project:opt(input,"project"),sha:opt(input,"sha")}));+ return {...resolved,catalog:await publicSurfaceApps(),...(resolved.kind==="integrations"?{integrations:await integrationSnapshot()}: {})};};export const SURFACE_TOOLS: McpTool[] = [@@ -71,7 +71,7 @@ export const SURFACE_TOOLS: McpTool[] = [run: async (input, context) => {metadataOnly(safeActionInput(input));const grant = await openIntegrationSetup(str(input, "provider"), context.principal ?? context.actor ?? "", opt(input, "method"), selectionFrom(input));- const output = { route: "/integrations", kind: "integrations", title: "Integrations", openPath: "/integrations", catalog: publicSurfaceApps(), setup: grant.setup };+ const output = { route: "/integrations", kind: "integrations", title: "Integrations", openPath: "/integrations", catalog: await publicSurfaceApps(), setup: grant.setup };return mcpDirect([{ type: "text", text: `Secure ${grant.setup.title} setup opened. Enter the credential in the form, never in chat.` }], false, output,{ integrationSetup: { token: grant.token, endpoint: `${MSO_ORIGIN}/api/integrations/setup` } });},@@ -84,7 +84,7 @@ export const SURFACE_TOOLS: McpTool[] = [scope: "read", annotations: READ_ONLY,inputSchema: S({}),outputSchema: { type: "object", properties: { apps: { type: "array", items: APP_SCHEMA } }, required: ["apps"], additionalProperties: false },- run: async () => ({ apps: publicSurfaceApps() }),+ run: async () => ({ apps: await publicSurfaceApps() }),},{name: "render_mso_page",diff --git a/lib/mcp/ui-config.ts b/lib/mcp/ui-config.tsindex ab75b51a..46383dc7 100644--- a/lib/mcp/ui-config.ts+++ b/lib/mcp/ui-config.ts@@ -42,8 +42,8 @@ export function mcpUiOrigin(): string {return publicOrigin;}-// Kept as exports for existing resource modules. Values are deployment config at-// process startup; helpers above are used where request-time recomputation matters.+// Kept as exports for existing resource modules/tests. These are startup snapshots;+// widgetResourceMeta() recomputes the deployment origins whenever a resource is read.export const MSO_ORIGIN = publicMsoOrigin();export const MCP_UI_DOMAIN = mcpUiOrigin();@@ -59,9 +59,11 @@ export function widgetResourceMeta(const frameDomains = [...(options?.frameDomains ?? [])];const connectDomains = [...(options?.connectDomains ?? [])];const resourceDomains = [...(options?.resourceDomains ?? [])];+ const uiDomain = mcpUiOrigin();+ const msoOrigin = publicMsoOrigin();return {ui: {- domain: MCP_UI_DOMAIN,+ domain: uiDomain,prefersBorder: true,csp: {connectDomains,@@ -71,11 +73,11 @@ export function widgetResourceMeta(},"openai/widgetDescription": description,"openai/widgetPrefersBorder": true,- "openai/widgetDomain": MCP_UI_DOMAIN,+ "openai/widgetDomain": uiDomain,"openai/widgetCSP": {...(connectDomains.length ? { connect_domains: connectDomains } : {}),...(frameDomains.length ? { frame_domains: frameDomains } : {}),- redirect_domains: [MSO_ORIGIN, ...(options?.redirectDomains ?? [])],+ redirect_domains: [msoOrigin, ...(options?.redirectDomains ?? [])],},};}diff --git a/lib/mcp/ui-page-lifecycle.test.ts b/lib/mcp/ui-page-lifecycle.test.tsindex 0709902b..5bf74a26 100644--- a/lib/mcp/ui-page-lifecycle.test.ts+++ b/lib/mcp/ui-page-lifecycle.test.ts@@ -1,19 +1,20 @@import { inlineScripts } from "../../scripts/test-support/inline-scripts";import { describe, expect, it } from "vitest";-import { LEGACY_PAGE_V10_URI, LEGACY_PAGE_V2_URI, LEGACY_PAGE_V3_URI, LEGACY_PAGE_V9_URI, MSO_PAGE_URI, listUiResources, readUiResource } from "./ui-resources";+import { LEGACY_PAGE_V11_URI, LEGACY_PAGE_V10_URI, LEGACY_PAGE_V2_URI, LEGACY_PAGE_V3_URI, LEGACY_PAGE_V9_URI, MSO_PAGE_URI, listUiResources, readUiResource } from "./ui-resources";describe("MCP Page lifecycle and cached resource migration", () => {- it("serves current bytes to cached v2 clients without advertising a third UI", () => {- const page = readUiResource(MSO_PAGE_URI);- expect(readUiResource(LEGACY_PAGE_V10_URI)).toMatchObject({ uri: LEGACY_PAGE_V10_URI, text: page?.text });- expect(readUiResource(LEGACY_PAGE_V2_URI)).toMatchObject({ uri: LEGACY_PAGE_V2_URI, text: page?.text });- expect(readUiResource(LEGACY_PAGE_V3_URI)).toMatchObject({ uri: LEGACY_PAGE_V3_URI, text: page?.text });- expect(readUiResource(LEGACY_PAGE_V9_URI)).toMatchObject({ uri: LEGACY_PAGE_V9_URI, text: page?.text });- expect(listUiResources()).toHaveLength(2);- expect(listUiResources().some((resource) => resource.uri === LEGACY_PAGE_V2_URI)).toBe(false);+ it("serves current bytes to cached v2 clients without advertising a third UI", async () => {+ const page = await readUiResource(MSO_PAGE_URI);+ expect(await readUiResource(LEGACY_PAGE_V11_URI)).toMatchObject({ uri: LEGACY_PAGE_V11_URI, text: page?.text });+ expect(await readUiResource(LEGACY_PAGE_V10_URI)).toMatchObject({ uri: LEGACY_PAGE_V10_URI, text: page?.text });+ expect(await readUiResource(LEGACY_PAGE_V2_URI)).toMatchObject({ uri: LEGACY_PAGE_V2_URI, text: page?.text });+ expect(await readUiResource(LEGACY_PAGE_V3_URI)).toMatchObject({ uri: LEGACY_PAGE_V3_URI, text: page?.text });+ expect(await readUiResource(LEGACY_PAGE_V9_URI)).toMatchObject({ uri: LEGACY_PAGE_V9_URI, text: page?.text });+ expect(await listUiResources()).toHaveLength(2);+ expect((await listUiResources()).some((resource) => resource.uri === LEGACY_PAGE_V2_URI)).toBe(false);});- it("includes the Apps handshake and readiness contract in valid self-contained JavaScript", () => {- const html = readUiResource(MSO_PAGE_URI)?.text ?? "";+ it("includes the Apps handshake and readiness contract in valid self-contained JavaScript", async () => {+ const html = (await readUiResource(MSO_PAGE_URI))?.text ?? "";const script = inlineScripts(html)[0];expect(script).toBeTruthy();expect(() => new Function(script ?? "")).not.toThrow();diff --git a/lib/mcp/ui-resource-state.test.ts b/lib/mcp/ui-resource-state.test.tsindex 38a04410..e024ffdc 100644--- a/lib/mcp/ui-resource-state.test.ts+++ b/lib/mcp/ui-resource-state.test.ts@@ -70,12 +70,12 @@ describe("MCP Apps Block and Page contract", () => {});it("keeps latest cached workflow/surface URIs as non-advertised Block/Page aliases", async () => {- const canonicalBlock = readUiResource(MSO_BLOCK_URI);- const canonicalPage = readUiResource(MSO_PAGE_URI);- const blockV1 = readUiResource(LEGACY_BLOCK_V1_URI);- const pageV1 = readUiResource(LEGACY_PAGE_V1_URI);- const legacyBlock = readUiResource(LEGACY_WORKFLOW_PROGRESS_URI);- const legacyPage = readUiResource(LEGACY_SURFACE_URI);+ const canonicalBlock = await readUiResource(MSO_BLOCK_URI);+ const canonicalPage = await readUiResource(MSO_PAGE_URI);+ const blockV1 = await readUiResource(LEGACY_BLOCK_V1_URI);+ const pageV1 = await readUiResource(LEGACY_PAGE_V1_URI);+ const legacyBlock = await readUiResource(LEGACY_WORKFLOW_PROGRESS_URI);+ const legacyPage = await readUiResource(LEGACY_SURFACE_URI);expect(blockV1).toMatchObject({ uri: LEGACY_BLOCK_V1_URI, text: canonicalBlock?.text });expect(pageV1).toMatchObject({ uri: LEGACY_PAGE_V1_URI, text: canonicalPage?.text });expect(legacyBlock).toMatchObject({ uri: LEGACY_WORKFLOW_PROGRESS_URI, text: canonicalBlock?.text });@@ -95,14 +95,14 @@ describe("MCP Apps Block and Page contract", () => {"ui://mso/project-diff-v2.html","ui://mso/vps-status-v2.html",]) {- expect(readUiResource(uri)).toBeUndefined();+ expect(await readUiResource(uri)).toBeUndefined();const read = await dispatch({ id: 20, method: "resources/read", params: { uri } }, "read", "mcp:ui-retired");expect(read.error).toMatchObject({ code: -32602 });}});- it("keeps native Page routes and portable tools/call refreshes", () => {- const page = readUiResource(MSO_PAGE_URI)?.text ?? "";+ it("keeps native Page routes and portable tools/call refreshes", async () => {+ const page = (await readUiResource(MSO_PAGE_URI))?.text ?? "";expect(page).toContain('route:"/monitor"');expect(page).toContain('route:"/project"');expect(page).toContain('route:"/diff"');diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.tsindex 8ff74a44..76aaeb60 100644--- a/lib/mcp/ui-resources.test.ts+++ b/lib/mcp/ui-resources.test.ts@@ -152,7 +152,7 @@ describe("MCP Apps Block and Page contract", () => {});expect(content._meta.ui.csp.frameDomains).toBeUndefined();expect(content._meta["openai/widgetCSP"]).toEqual({ connect_domains: [MSO_ORIGIN], redirect_domains: [MSO_ORIGIN] });- expect(MSO_PAGE_URI).toContain("page-v11.html");+ expect(MSO_PAGE_URI).toContain("page-v12.html");});});diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.tsindex 746f51d1..7e91339b 100644--- a/lib/mcp/ui-resources.ts+++ b/lib/mcp/ui-resources.ts@@ -1,5 +1,5 @@import { MSO_BLOCK_RESOURCE, MSO_BLOCK_URI } from "./ui-block";-import { MSO_PAGE_RESOURCE, MSO_PAGE_URI } from "./ui-surface";+import { MSO_PAGE_URI, msoPageResource } from "./ui-surface";export { MSO_BLOCK_URI, MSO_PAGE_URI };export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";@@ -8,6 +8,7 @@ export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";// across the UI-contract migration. They are intentionally not advertised by// resources/list: the public product contract has exactly Block and Page.export const LEGACY_BLOCK_V1_URI = "ui://mso/block-v1.html";+export const LEGACY_PAGE_V11_URI = "ui://mso/page-v11.html";export const LEGACY_PAGE_V10_URI = "ui://mso/page-v10.html";export const LEGACY_PAGE_V9_URI = "ui://mso/page-v9.html";export const LEGACY_PAGE_V8_URI = "ui://mso/page-v8.html";@@ -30,30 +31,30 @@ export type McpUiResource = {_meta: Record<string, unknown>;};-const RESOURCES: readonly McpUiResource[] = [MSO_BLOCK_RESOURCE, MSO_PAGE_RESOURCE];-const LEGACY_ALIASES = new Map<string, McpUiResource>([- [LEGACY_PAGE_V10_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V9_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V8_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V7_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V6_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V5_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V4_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V3_URI, MSO_PAGE_RESOURCE],- [LEGACY_BLOCK_V1_URI, MSO_BLOCK_RESOURCE],- [LEGACY_PAGE_V1_URI, MSO_PAGE_RESOURCE],- [LEGACY_PAGE_V2_URI, MSO_PAGE_RESOURCE],- [LEGACY_WORKFLOW_PROGRESS_URI, MSO_BLOCK_RESOURCE],- [LEGACY_SURFACE_URI, MSO_PAGE_RESOURCE],+const LEGACY_PAGE_URIS = new Set([+ LEGACY_PAGE_V11_URI,+ LEGACY_PAGE_V10_URI,+ LEGACY_PAGE_V9_URI,+ LEGACY_PAGE_V8_URI,+ LEGACY_PAGE_V7_URI,+ LEGACY_PAGE_V6_URI,+ LEGACY_PAGE_V5_URI,+ LEGACY_PAGE_V4_URI,+ LEGACY_PAGE_V3_URI,+ LEGACY_PAGE_V2_URI,+ LEGACY_PAGE_V1_URI,+ LEGACY_SURFACE_URI,]);-export function listUiResources() {- return RESOURCES.map(({ uri, name, description, mimeType }) => ({ uri, name, description, mimeType }));+export async function listUiResources(): Promise<Array<{ uri: string; name: string; description: string; mimeType: string }>> {+ const page = await msoPageResource();+ return [MSO_BLOCK_RESOURCE, page].map(({ uri, name, description, mimeType }) => ({ uri, name, description, mimeType }));}-export function readUiResource(uri: string): McpUiResource | undefined {- const canonical = RESOURCES.find((resource) => resource.uri === uri);- if (canonical) return canonical;- const legacy = LEGACY_ALIASES.get(uri);- return legacy ? { ...legacy, uri } : undefined;+export async function readUiResource(uri: string): Promise<McpUiResource | undefined> {+ if (uri === MSO_BLOCK_URI) return MSO_BLOCK_RESOURCE;+ if (uri === MSO_PAGE_URI) return msoPageResource();+ if (uri === LEGACY_BLOCK_V1_URI || uri === LEGACY_WORKFLOW_PROGRESS_URI) return { ...MSO_BLOCK_RESOURCE, uri };+ if (LEGACY_PAGE_URIS.has(uri)) return { ...(await msoPageResource()), uri };+ return undefined;}diff --git a/lib/mcp/ui-surface-script.ts b/lib/mcp/ui-surface-script.tsindex 3eda201e..f4b5fcf4 100644--- a/lib/mcp/ui-surface-script.ts+++ b/lib/mcp/ui-surface-script.ts@@ -12,23 +12,27 @@ function safeJson(value: unknown): string {.replace(/&/g, "\\u0026");}-const BROWSER_CATALOG = surfaceApps().map((app) => ({- id: app.id,- title: app.title,- description: app.description,- origin: app.origin,- startPath: app.startPath,- renderer: app.renderer,- presentation: app.presentation,- environment: app.environment,- sandbox: app.sandbox ?? "",- externalAuthPath: app.externalAuthPath ?? "",- reason: app.reason ?? "",-}));+async function browserCatalog() {+ return (await surfaceApps()).map((app) => ({+ id: app.id,+ title: app.title,+ description: app.description,+ origin: app.origin,+ startPath: app.startPath,+ renderer: app.renderer,+ presentation: app.presentation,+ environment: app.environment,+ sandbox: app.sandbox ?? "",+ externalAuthPath: app.externalAuthPath ?? "",+ reason: app.reason ?? "",+ }));+}-export const MSO_SURFACE_SCRIPT = String.raw`+export async function msoSurfaceScript(): Promise<string> {+ const catalog = await browserCatalog();+ return String.raw`${MSO_WIDGET_THEME_SCRIPT}-const SAFE_APPS=${safeJson(BROWSER_CATALOG)};+const SAFE_APPS=${safeJson(catalog)};const SAFE_BY_ID=new Map(SAFE_APPS.map(app=>[app.id,app]));const $=id=>document.getElementById(id);const body=$("surface-body"), titleEl=$("surface-title"), routeEl=$("surface-route"), modeEl=$("surface-mode");@@ -115,3 +119,8 @@ window.addEventListener("openai:set_globals",()=>{applyHostGlobals();readOutput(fsBtn.addEventListener("click",()=>displayMode("fullscreen"));pipBtn.addEventListener("click",()=>displayMode("pip"));homeBtn.addEventListener("click",()=>nav("/"));applyHostGlobals();if(!readOutput())render();initializeMcpPage();`;+}++// Compatibility snapshot for tests/consumers that import the historical constant.+// The canonical Page resource calls msoSurfaceScript() so registry changes are live.+export const MSO_SURFACE_SCRIPT = msoSurfaceScript();diff --git a/lib/mcp/ui-surface.ts b/lib/mcp/ui-surface.tsindex e571d9e4..591a2f2b 100644--- a/lib/mcp/ui-surface.ts+++ b/lib/mcp/ui-surface.ts@@ -1,15 +1,16 @@import { CONNECTION_MANAGER_STYLE } from "@/lib/infra/connection-ui";import { INTEGRATION_FORM_STYLE } from "@/lib/infra/setup-ui";-import { widgetResourceMeta, MSO_ORIGIN } from "./ui-config";+import { publicMsoOrigin, widgetResourceMeta } from "./ui-config";import { OPEN_IN_MSO_SCRIPT, openInMsoControls } from "./ui-navigation";import { surfaceFrameDomains } from "./surface-catalog";-import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";+import { msoSurfaceScript } from "./ui-surface-script";import { MSO_SURFACE_STYLE } from "./ui-surface-style";-export const MSO_PAGE_URI = "ui://mso/page-v11.html";+export const MSO_PAGE_URI = "ui://mso/page-v12.html";const MIME = "text/html;profile=mcp-app";-const html = String.raw`<main class="surface" aria-label="MSO Page">+async function pageHtml(): Promise<string> {+ return String.raw`<main class="surface" aria-label="MSO Page"><style>${MSO_SURFACE_STYLE}${INTEGRATION_FORM_STYLE}${CONNECTION_MANAGER_STYLE}</style><header class="bar"><div class="brand" aria-hidden="true">M</div>@@ -23,17 +24,27 @@ const html = String.raw`<main class="surface" aria-label="MSO Page"></div></header><section class="body" id="surface-body"><div class="loading">Loading MSO Page…</div></section>-<script>(()=>{${OPEN_IN_MSO_SCRIPT}${MSO_SURFACE_SCRIPT}})();</script>+<script>(()=>{${OPEN_IN_MSO_SCRIPT}${await msoSurfaceScript()}})();</script></main>`;+}-export const MSO_PAGE_RESOURCE = {- uri: MSO_PAGE_URI,- name: "MSO Page",- description: "Full-page MSO presentation target for native operator views and explicitly reviewed development or production app embeds.",- mimeType: MIME,- text: html,- _meta: widgetResourceMeta(- "Interactive MSO Page. It renders native operator views and exact-origin reviewed development or production targets. Nested frames are limited to explicit CSP frame domains and dedicated embed routes; arbitrary HTML and URLs are never accepted from the model.",- { frameDomains: surfaceFrameDomains(), redirectDomains: surfaceFrameDomains(), connectDomains: [MSO_ORIGIN] },- ),-} as const;+/** Build the canonical Page at read time so reviewed registry edits update both+ * SAFE_APPS and exact CSP frame domains without rebuilding portable source. */+export async function msoPageResource() {+ const frameDomains = await surfaceFrameDomains();+ return {+ uri: MSO_PAGE_URI,+ name: "MSO Page",+ description: "Full-page MSO presentation target for native operator views and explicitly reviewed development or production app embeds.",+ mimeType: MIME,+ text: await pageHtml(),+ _meta: widgetResourceMeta(+ "Interactive MSO Page. It renders native operator views and exact-origin reviewed development or production targets. Nested frames are limited to explicit CSP frame domains and dedicated embed routes; arbitrary HTML and URLs are never accepted from the model.",+ { frameDomains, redirectDomains: frameDomains, connectDomains: [publicMsoOrigin()] },+ ),+ } as const;+}++// Compatibility promise for tests/consumers that imported the historical export.+// resources/read calls msoPageResource() and therefore remains live/dynamic.+export const MSO_PAGE_RESOURCE = msoPageResource();diff --git a/lib/mcp/ui-widget-theme.test.ts b/lib/mcp/ui-widget-theme.test.tsindex 2f0ffd2d..fd142564 100644--- a/lib/mcp/ui-widget-theme.test.ts+++ b/lib/mcp/ui-widget-theme.test.ts@@ -5,7 +5,9 @@ import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";import { MSO_SURFACE_STYLE } from "./ui-surface-style";import { MSO_WIDGET_THEME_SCRIPT, MSO_WIDGET_TOKENS } from "./ui-widget-tokens";-const canonicalHtml = `${MSO_BLOCK_RESOURCE.text}\n${MSO_PAGE_RESOURCE.text}`;+const pageResource = await MSO_PAGE_RESOURCE;+const surfaceScript = await MSO_SURFACE_SCRIPT;+const canonicalHtml = `${MSO_BLOCK_RESOURCE.text}\n${pageResource.text}`;describe("Rahmanef widget theme", () => {it("mirrors the public site's light and dark palette from one shared token source", () => {@@ -23,7 +25,7 @@ describe("Rahmanef widget theme", () => {it("injects the same palette into Block and Page and removes the old generic purple theme", () => {expect(MSO_BLOCK_RESOURCE.text).toContain(MSO_WIDGET_TOKENS);expect(MSO_SURFACE_STYLE).toContain(MSO_WIDGET_TOKENS);- expect(MSO_PAGE_RESOURCE.text).toContain(MSO_WIDGET_TOKENS);+ expect(pageResource.text).toContain(MSO_WIDGET_TOKENS);expect(canonicalHtml).not.toContain("#7c3aed");expect(canonicalHtml).not.toContain("CanvasText");expect(canonicalHtml).not.toContain("color:Canvas");@@ -42,7 +44,7 @@ describe("Rahmanef widget theme", () => {expect(MSO_WIDGET_THEME_SCRIPT).toContain("window.openai.theme");expect(MSO_WIDGET_THEME_SCRIPT).toContain('theme==="light"||theme==="dark"');expect(MSO_BLOCK_RESOURCE.text).toContain("applyHostTheme();readHostOutput()");- expect(MSO_SURFACE_SCRIPT).toContain("applyHostTheme();");- expect(MSO_PAGE_RESOURCE.text).toContain("window.openai.theme");+ expect(surfaceScript).toContain("applyHostTheme();");+ expect(pageResource.text).toContain("window.openai.theme");});});diff --git a/scripts/e2e/mcp-page.mjs b/scripts/e2e/mcp-page.mjsindex 1f9adeba..f2818ab8 100644--- a/scripts/e2e/mcp-page.mjs+++ b/scripts/e2e/mcp-page.mjs@@ -6,7 +6,7 @@ import { createRequire } from "node:module";import path from "node:path";const require = createRequire(import.meta.url);const { chromium } = require(path.join(process.cwd(), "os-browser/node_modules/playwright"));-const resource = JSON.parse(execFileSync("bun", ["-e", 'import { MSO_PAGE_RESOURCE } from "./lib/mcp/ui-surface"; console.log(JSON.stringify(MSO_PAGE_RESOURCE))'], { encoding: "utf8" }));+const resource = JSON.parse(execFileSync("bun", ["-e", 'import { MSO_PAGE_RESOURCE } from "./lib/mcp/ui-surface"; console.log(JSON.stringify(await MSO_PAGE_RESOURCE))'], { encoding: "utf8" }));const output = {route: "/apps/play-together", kind: "app", title: "Play Together", openPath: "/assistant/mcp", catalog: [],app: { id: "play-together", url: "https://game.example.com/embed" },