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): keep ChatGPT Page iframe-free
Rahman88c13f11b1db
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex e49bd604..52ed25e0 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -15,6 +15,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `mcp` keep ChatGPT Page iframe-free- `mcp` make Page surface registry instance-dynamic- `update` harden release verification and settings UX- `auth` harden browser session persistencediff --git a/lib/mcp/integration-setup.test.ts b/lib/mcp/integration-setup.test.tsindex eb35efd4..06a71346 100644--- a/lib/mcp/integration-setup.test.ts+++ b/lib/mcp/integration-setup.test.ts@@ -20,7 +20,7 @@ describe("MCP integration setup privacy", () => {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-v12\.html$/);+ expect((tool.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v13\.html$/);expect(tool.meta?.["openai/outputTemplate"]).toBeUndefined();expect((await resolveSurfaceRoute("/integrations")).kind).toBe("integrations");const script = await msoSurfaceScript();diff --git a/lib/mcp/privacy-portability.test.ts b/lib/mcp/privacy-portability.test.tsindex 2e04c92e..47c0a834 100644--- a/lib/mcp/privacy-portability.test.ts+++ b/lib/mcp/privacy-portability.test.ts@@ -86,6 +86,7 @@ describe("portable public MCP configuration", () => {expect.objectContaining({id: "demo",origin: "https://demo.example.test",+ renderer: "remote",}),]);expect(await catalog.surfaceFrameDomains()).toEqual([@@ -113,9 +114,12 @@ describe("two independent instance presentations", () => {const { publicSurfaceApps, surfaceFrameDomains } = await import("./surface-catalog");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));+ const resource = await readUiResource(MSO_PAGE_URI);+ const serialized = JSON.stringify(resource);expect(serialized).toContain(`widgets.${id}.example.test`);expect(serialized).toContain(`mso.${id}.example.test`);+ expect((resource?._meta.ui as { csp: { frameDomains?: string[] } }).csp.frameDomains).toBeUndefined();+ expect((resource?._meta["openai/widgetCSP"] as { frame_domains?: string[] }).frame_domains).toBeUndefined();outputs.push(serialized);}expect(outputs[0]).not.toContain("beta.example.test");diff --git a/lib/mcp/surface-catalog.test.ts b/lib/mcp/surface-catalog.test.tsindex 3d69bafe..ec48d278 100644--- a/lib/mcp/surface-catalog.test.ts+++ b/lib/mcp/surface-catalog.test.ts@@ -17,7 +17,7 @@ describe("MSO Page trusted app catalog", () => {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(apps[0]).toMatchObject({ id: "demo", title: "Demo", origin: "https://demo.example.test", startPath: "/embed", renderer: "remote", presentation: "inline", environment: "production" });expect(JSON.stringify(apps)).not.toContain("sandbox");expect(JSON.stringify(apps)).not.toContain("externalAuthPath");expect((await resolveSurfaceRoute("/apps/demo")).app?.externalAuthPath).toBe("/?auth=google");@@ -29,10 +29,10 @@ describe("MSO Page trusted app catalog", () => {}});- it("keeps every configured iframe route inside its start path", async () => {+ it("keeps every registry route inside its start path while forcing ChatGPT handoff remote", 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(root).toMatchObject({ kind: "app", title: "Demo", openPath: "/browser" });+ expect(root.app).toMatchObject({ id: "demo", renderer: "remote", environment: "production" });expect(new URL(root.app!.url).pathname).toBe("/embed");const room = await resolveSurfaceRoute("/apps/demo/room/ABCD?join=remote");const url = new URL(room.app!.url);@@ -53,5 +53,7 @@ describe("MSO Page trusted app catalog", () => {expect(script).toContain("url.origin!==safe.origin");expect(script).toContain("!url.pathname.startsWith(start+\"/\")");expect(script).not.toContain("play-together:embed-ready");+ expect(script).not.toContain("mountReviewedFrame");+ expect(script).not.toContain("createElement(\"iframe\")");});});diff --git a/lib/mcp/surface-catalog.ts b/lib/mcp/surface-catalog.tsindex 5e0136e5..5898915b 100644--- a/lib/mcp/surface-catalog.ts+++ b/lib/mcp/surface-catalog.ts@@ -31,6 +31,8 @@ export async function publicSurfaceApps(): Promise<Array<return (await surfaceApps()).map(({ sandbox: _sandbox, externalAuthPath: _externalAuthPath, ...app }) => ({...app,+ renderer: "remote" as const,+ reason: app.reason ?? "External apps use the remote-browser seam so the ChatGPT Page stays free of nested external iframes.",}),);}@@ -137,14 +139,19 @@ export async function resolveSurfaceRoute(};if (parts[0] === "apps" && parts[1]) {- const app = await surfaceAppById(parts[1]);- if (!app) throw new Error(`unknown MSO Page app: ${parts[1]}`);+ const source = await surfaceAppById(parts[1]);+ if (!source) throw new Error(`unknown MSO Page app: ${parts[1]}`);const suffix = parts.slice(2).join("/");+ const app: SurfaceApp = {+ ...source,+ renderer: "remote",+ reason: source.reason ?? "External apps use the remote-browser seam so the ChatGPT Page stays free of nested external iframes.",+ };return {route,kind: "app",title: app.title,- openPath: app.renderer === "remote" ? "/browser" : "/assistant/mcp",+ openPath: "/browser",app: { ...app, url: safeDemoUrl(app, suffix, url.search) },};}diff --git a/lib/mcp/surface-config-live.test.ts b/lib/mcp/surface-config-live.test.tsindex 37229c6e..fe712fcc 100644--- a/lib/mcp/surface-config-live.test.ts+++ b/lib/mcp/surface-config-live.test.ts@@ -24,7 +24,7 @@ const app = (id: string, origin: string) => ({});describe("owner-local MSO Page surface registry", () => {- it("re-reads reviewed apps and Page CSP without a module reload or rebuild", async () => {+ it("re-reads reviewed apps without adding external frame CSP to the ChatGPT Page", async () => {root = await mkdtemp(join(tmpdir(), "mso-surfaces-"));const registry = join(root, "surface-apps.json");vi.stubEnv("MSO_SURFACE_APPS_JSON", undefined);@@ -39,14 +39,19 @@ describe("owner-local MSO Page surface registry", () => {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"]);+ expect((page._meta.ui as { csp: { frameDomains?: string[] } }).csp.frameDomains).toBeUndefined();+ expect((page._meta["openai/widgetCSP"] as { frame_domains?: string[] }).frame_domains).toBeUndefined();+ expect(page.text).toContain('"renderer":"remote"');+ expect(page.text).not.toContain("createElement(\"iframe\")");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"]);+ expect((page._meta.ui as { csp: { frameDomains?: string[] } }).csp.frameDomains).toBeUndefined();+ expect((page._meta["openai/widgetCSP"] as { frame_domains?: string[] }).frame_domains).toBeUndefined();+ expect(page.text).toContain('"renderer":"remote"');});it("keeps an explicitly defined JSON env value as the deployment override", async () => {diff --git a/lib/mcp/tools-surface.test.ts b/lib/mcp/tools-surface.test.tsindex 7c94633c..2f3d0b49 100644--- a/lib/mcp/tools-surface.test.ts+++ b/lib/mcp/tools-surface.test.ts@@ -8,7 +8,7 @@ const tool = (name: string) => {};describe("MSO Page MCP tools", () => {- beforeEach(() => { process.env.MSO_SURFACE_APPS_JSON = JSON.stringify([{ id: "demo", title: "Demo", description: "Configured demo", origin: "https://demo.example.test", startPath: "/embed", renderer: "iframe", presentation: "inline", environment: "production", sandbox: "allow-scripts allow-same-origin" }]); });+ beforeEach(() => { process.env.MSO_SURFACE_APPS_JSON = JSON.stringify([{ id: "demo", title: "Demo", description: "Configured demo", origin: "https://demo.example.test", startPath: "/embed", renderer: "remote", presentation: "inline", environment: "production", sandbox: "allow-scripts allow-same-origin" }]); });afterEach(() => { delete process.env.MSO_SURFACE_APPS_JSON; });it("returns only the server-reviewed public app catalog", async () => {const result = await tool("mso_surface_apps_list").run({}, { scope: "read" }) as { apps: Array<Record<string, unknown>> };@@ -16,7 +16,7 @@ describe("MSO Page MCP tools", () => {expect(result.apps[0]).toMatchObject({title: "Demo",origin: "https://demo.example.test",- renderer: "iframe",+ renderer: "remote",startPath: "/embed",environment: "production",});@@ -31,7 +31,7 @@ describe("MSO Page MCP tools", () => {const result = await render.run({ route: "/apps/demo" }, { scope: "read" }) as { app?: Record<string, unknown> };expect(result.app).toMatchObject({id: "demo",- renderer: "iframe",+ renderer: "remote",presentation: "inline",origin: "https://demo.example.test",startPath: "/embed",@@ -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-v12\.html$/);+ expect((render.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v13\.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-v12\.html$/);+ expect((value.meta?.ui as { resourceUri?: string }).resourceUri).toMatch(/^ui:\/\/mso\/page-v13\.html$/);expect(value.meta?.["openai/outputTemplate"]).toBeUndefined();}});diff --git a/lib/mcp/tools-surface.ts b/lib/mcp/tools-surface.tsindex 9a9d5237..a3008f99 100644--- a/lib/mcp/tools-surface.ts+++ b/lib/mcp/tools-surface.ts@@ -79,8 +79,8 @@ export const SURFACE_TOOLS: McpTool[] = [{name: "mso_surface_apps_list",title: "List MSO Page Apps",- description: "List the small server-owned catalog of development or production apps that MSO may present inside the ChatGPT Page. The model cannot add URLs or HTML to this catalog. Apps marked iframe have a reviewed exact frame origin; remote means the app keeps its own anti-framing policy and MSO will not strip it.",- chatgptDescription: "List reviewed apps available to the ChatGPT MSO Page, including whether each can be framed directly or must use the remote-browser seam.",+ description: "List the server-owned catalog of development or production apps available from the ChatGPT MSO Page. The model cannot add URLs or HTML. External apps are presented through the isolated remote-browser seam, so the ChatGPT Page itself does not embed third-party frames.",+ chatgptDescription: "List reviewed apps available from the ChatGPT MSO Page. External apps use the remote-browser seam; the Page itself stays free of nested external frames.",scope: "read", annotations: READ_ONLY,inputSchema: S({}),outputSchema: { type: "object", properties: { apps: { type: "array", items: APP_SCHEMA } }, required: ["apps"], additionalProperties: false },@@ -89,7 +89,7 @@ export const SURFACE_TOOLS: McpTool[] = [{name: "render_mso_page",title: "Render MSO Page",- description: "Render the full MSO Page MCP App for native operator views or reviewed development/production embeds. Use an MSO-style route such as /, /integrations, /monitor, /project, /diff, /browser, or /apps/<reviewed-app-id>. For project/diff views pass project separately. This tool never accepts raw HTML or arbitrary external URLs; iframe targets come only from the server-owned allowlist.",+ description: "Render the full MSO Page MCP App for native operator views or registry-backed external app handoff. Use an MSO-style route such as /, /integrations, /monitor, /project, /diff, /browser, or /apps/<reviewed-app-id>. For project/diff views pass project separately. This tool never accepts raw HTML or arbitrary external URLs; external apps are resolved only from the server-owned registry and handed to the remote-browser seam.",chatgptDescription: "Render the full secure MSO Page in ChatGPT. Native routes: /, /integrations, /monitor, /project, /diff, /browser; configured app route: /apps/<configured-app-id>. Raw HTML and arbitrary URLs are rejected.",scope: "read", annotations: READ_ONLY,inputSchema: PAGE_INPUT,diff --git a/lib/mcp/ui-page-lifecycle.test.ts b/lib/mcp/ui-page-lifecycle.test.tsindex 5bf74a26..b020fd5c 100644--- a/lib/mcp/ui-page-lifecycle.test.ts+++ b/lib/mcp/ui-page-lifecycle.test.ts@@ -1,10 +1,11 @@import { inlineScripts } from "../../scripts/test-support/inline-scripts";import { describe, expect, it } from "vitest";-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";+import { LEGACY_PAGE_V12_URI, 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", async () => {const page = await readUiResource(MSO_PAGE_URI);+ expect(await readUiResource(LEGACY_PAGE_V12_URI)).toMatchObject({ uri: LEGACY_PAGE_V12_URI, text: page?.text });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 });@@ -13,7 +14,7 @@ describe("MCP Page lifecycle and cached resource migration", () => {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", async () => {+ it("includes the Apps handshake and iframe-free remote handoff contract in valid self-contained JavaScript", async () => {const html = (await readUiResource(MSO_PAGE_URI))?.text ?? "";const script = inlineScripts(html)[0];expect(script).toBeTruthy();@@ -23,17 +24,18 @@ describe("MCP Page lifecycle and cached resource migration", () => {'appInfo:{name:"MSO Page",version:"3.0.0"}','method:"ui/notifications/initialized"','event.source!==window.parent',- 'frame.addEventListener("load",loaded)',- 'frame.referrerPolicy="no-referrer"','if(key===lastOutputKey){',- 'setTimeout(unavailable,12000)','hostMax*.48','availableDisplayModes:["inline","fullscreen","pip"]',+ 'stageBase("Remote-browser handoff")',+ 'openPath("/browser")',]) expect(script).toContain(marker);expect(html).toContain('html[data-display-mode="inline"] .surface');expect(html).toContain('max-height:var(--inline-max-h)');expect(html).toContain('html[data-display-mode="fullscreen"] .surface{height:100vh;height:100dvh');expect(html).not.toContain('presentation:"fullscreen"');expect(script).not.toContain('play-together:embed-ready');+ expect(script).not.toContain('createElement("iframe")');+ expect(script).not.toContain("mountReviewedFrame");});});diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.tsindex 76aaeb60..ab4e8202 100644--- a/lib/mcp/ui-resources.test.ts+++ b/lib/mcp/ui-resources.test.ts@@ -152,7 +152,9 @@ 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-v12.html");+ expect(MSO_PAGE_URI).toContain("page-v13.html");+ expect(content.text).not.toContain("createElement(\"iframe\")");+ expect(content.text).not.toContain("mountReviewedFrame");});});diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.tsindex 7e91339b..495a30de 100644--- a/lib/mcp/ui-resources.ts+++ b/lib/mcp/ui-resources.ts@@ -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_V12_URI = "ui://mso/page-v12.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";@@ -32,6 +33,7 @@ export type McpUiResource = {};const LEGACY_PAGE_URIS = new Set([+ LEGACY_PAGE_V12_URI,LEGACY_PAGE_V11_URI,LEGACY_PAGE_V10_URI,LEGACY_PAGE_V9_URI,diff --git a/lib/mcp/ui-surface-script.ts b/lib/mcp/ui-surface-script.tsindex f4b5fcf4..5d703a2b 100644--- a/lib/mcp/ui-surface-script.ts+++ b/lib/mcp/ui-surface-script.ts@@ -1,8 +1,6 @@import { MSO_PAGE_INTEGRATIONS_SCRIPT } from "./ui-page-integrations";import { MSO_PAGE_BRIDGE_SCRIPT } from "./ui-page-bridge";-import { MSO_PAGE_FRAME_SCRIPT } from "./ui-page-frame";-import { MSO_PAGE_AUTH_SCRIPT } from "./ui-page-auth";-import { surfaceApps } from "./surface-catalog";+import { publicSurfaceApps } from "./surface-catalog";import { MSO_WIDGET_THEME_SCRIPT } from "./ui-widget-tokens";function safeJson(value: unknown): string {@@ -13,7 +11,7 @@ function safeJson(value: unknown): string {}async function browserCatalog() {- return (await surfaceApps()).map((app) => ({+ return (await publicSurfaceApps()).map((app) => ({id: app.id,title: app.title,description: app.description,@@ -22,8 +20,6 @@ async function browserCatalog() {renderer: app.renderer,presentation: app.presentation,environment: app.environment,- sandbox: app.sandbox ?? "",- externalAuthPath: app.externalAuthPath ?? "",reason: app.reason ?? "",}));}@@ -40,8 +36,6 @@ const fsBtn=$("surface-fullscreen"), pipBtn=$("surface-pip"), homeBtn=$("surfacelet current={route:"/",kind:"home",title:"MSO",openPath:"/assistant/mcp",catalog:[]};const pending=new Map();let nextRpcId=5000;${MSO_PAGE_BRIDGE_SCRIPT}-${MSO_PAGE_FRAME_SCRIPT}-${MSO_PAGE_AUTH_SCRIPT}${MSO_PAGE_INTEGRATIONS_SCRIPT}function text(value,fallback="—"){return typeof value==="string"&&value.trim()?value.trim():fallback}@@ -89,10 +83,10 @@ function nav(route,extra={}){}function showError(error){viewCleanup();viewCleanup=()=>{};clear(body);const box=el("div","notice");const inner=el("div");inner.append(el("h3","","Page unavailable"),el("p","error",error&&error.message?error.message:"The requested page could not be loaded."));box.append(inner);body.append(box)}function renderHome(){- const root=el("div","home");const hero=el("section","hero");hero.append(el("h2","","MSO Page"),el("p","","ChatGPT is another MSO presentation target. Open a native operator view or a reviewed live demo without leaving the conversation."));root.append(hero);+ const root=el("div","home");const hero=el("section","hero");hero.append(el("h2","","MSO Page"),el("p","","ChatGPT is another MSO presentation target. Open native operator views here; registry-backed external apps continue through the isolated MSO Browser seam."));root.append(hero);root.append(el("div","section-title","Native pages"));const native=el("div","grid");- for(const item of [{route:"/integrations",title:"Integrations",desc:"Secure, native credential setup."},{route:"/monitor",title:"System Monitor",desc:"Live bounded host status."},{route:"/project",title:"Project",desc:"Project snapshot and Git state."},{route:"/diff",title:"Diff",desc:"Review project changes."},{route:"/browser",title:"Remote Browser",desc:"Fallback seam for sites that deny framing."}]){const card=button("",()=>nav(item.route),"card");card.append(el("strong","",item.title),el("span","",item.desc));native.append(card)}root.append(native);- root.append(el("div","section-title","Reviewed development and production pages"));const apps=el("div","grid");+ for(const item of [{route:"/integrations",title:"Integrations",desc:"Secure, native credential setup."},{route:"/monitor",title:"System Monitor",desc:"Live bounded host status."},{route:"/project",title:"Project",desc:"Project snapshot and Git state."},{route:"/diff",title:"Diff",desc:"Review project changes."},{route:"/browser",title:"Remote Browser",desc:"Isolated seam for external apps and authenticated sites."}]){const card=button("",()=>nav(item.route),"card");card.append(el("strong","",item.title),el("span","",item.desc));native.append(card)}root.append(native);+ root.append(el("div","section-title","Registry-backed external apps"));const apps=el("div","grid");for(const app of SAFE_APPS){const card=button("",()=>nav("/apps/"+encodeURIComponent(app.id)),"card");card.append(el("strong","",app.title),el("span","",app.description),el("span","tag",app.environment+" · "+app.renderer));apps.append(card)}root.append(apps);body.append(root)}function renderMonitor(){@@ -107,9 +101,8 @@ function renderProjectPrompt(kind){const box=el("div","notice");const inner=el("function appendLine(list,label,value){const row=el("div","line");row.append(el("span","",label),el("strong","mono",value==null?"—":value));list.append(row)}function stageBase(subtitle){const root=el("div","stage"),head=el("div","stage-head"),content=el("div");head.append(button("←",()=>nav("/"),"back"));const t=el("div","stage-title");t.append(el("strong","",current.title),el("span","",subtitle));head.append(t);root.append(head,content);return{root,content}}function renderApp(){- const raw=current.app,safe=safeAppResult(raw);if(!safe){showError(new Error("The app result is not in the reviewed MSO Page registry."));return}const stage=stageBase(safe.renderer==="iframe"?"Live app demo":"Remote-browser fallback");body.append(stage.root);openPath(safe.renderer==="remote"?"/browser":"/assistant/mcp");- if(safe.renderer==="iframe"){mountReviewedFrame(safe,stage);return}- const box=el("div","notice"),inner=el("div");inner.append(el("h3","",safe.title+" protects itself from framing"),el("p","",safe.reason||"This app is not allowlisted for nested framing. MSO preserves the app's own frame policy instead of stripping it."));const row=el("div","row");row.append(button("Open Remote Browser",()=>openMso(),"primary"));if(window.openai&&typeof window.openai.sendFollowUpMessage==="function")row.append(button("Ask ChatGPT to continue",()=>window.openai.sendFollowUpMessage({prompt:"Continue this demo using the MSO remote-browser fallback for "+safe.title+"."})));inner.append(row);box.append(inner);stage.content.append(box);if(safe.presentation==="pip")pipBtn.hidden=false+ const raw=current.app,safe=safeAppResult(raw);if(!safe){showError(new Error("The app result is not in the reviewed MSO Page registry."));return}const stage=stageBase("Remote-browser handoff");body.append(stage.root);openPath("/browser");+ const box=el("div","notice"),inner=el("div");inner.append(el("h3","",safe.title+" opens through MSO Browser"),el("p","",safe.reason||"External apps stay outside the ChatGPT Page iframe and continue through MSO's isolated remote-browser seam."));const row=el("div","row");row.append(button("Open Remote Browser",()=>openMso(),"primary"));if(window.openai&&typeof window.openai.sendFollowUpMessage==="function")row.append(button("Ask ChatGPT to continue",()=>window.openai.sendFollowUpMessage({prompt:"Continue this demo using the MSO remote-browser fallback for "+safe.title+"."})));inner.append(row);box.append(inner);stage.content.append(box);if(safe.presentation==="pip")pipBtn.hidden=false}function renderBrowser(){const box=el("div","notice"),inner=el("div");inner.append(el("h3","","Remote Browser seam"),el("p","","Sites that deny iframe embedding stay isolated. MSO can continue them through Camoufox without exposing its VNC password or authenticated viewer URL to this widget."));const row=el("div","row");row.append(button("Open MSO Browser",()=>openMso(),"primary"));inner.append(row);box.append(inner);body.append(box);openPath("/browser")}function render(){viewCleanup();viewCleanup=()=>{};clear(body);titleEl.textContent=text(current.title,"MSO Page");routeEl.textContent=text(current.route,"/");openPath(text(current.openPath,"/assistant/mcp"));persistRoute();if(current.kind==="home")renderHome();else if(current.kind==="integrations")renderIntegrations();else if(current.kind==="monitor")renderMonitor();else if(current.kind==="project")renderProject("project");else if(current.kind==="diff")renderProject("diff");else if(current.kind==="app")renderApp();else if(current.kind==="browser")renderBrowser();else body.append(el("div","loading","Loading MSO Page…"))}diff --git a/lib/mcp/ui-surface.ts b/lib/mcp/ui-surface.tsindex 591a2f2b..2ebb83f7 100644--- a/lib/mcp/ui-surface.ts+++ b/lib/mcp/ui-surface.ts@@ -2,11 +2,10 @@ import { CONNECTION_MANAGER_STYLE } from "@/lib/infra/connection-ui";import { INTEGRATION_FORM_STYLE } from "@/lib/infra/setup-ui";import { publicMsoOrigin, widgetResourceMeta } from "./ui-config";import { OPEN_IN_MSO_SCRIPT, openInMsoControls } from "./ui-navigation";-import { surfaceFrameDomains } from "./surface-catalog";import { msoSurfaceScript } from "./ui-surface-script";import { MSO_SURFACE_STYLE } from "./ui-surface-style";-export const MSO_PAGE_URI = "ui://mso/page-v12.html";+export const MSO_PAGE_URI = "ui://mso/page-v13.html";const MIME = "text/html;profile=mcp-app";async function pageHtml(): Promise<string> {@@ -28,19 +27,19 @@ async function pageHtml(): Promise<string> {</main>`;}-/** Build the canonical Page at read time so reviewed registry edits update both- * SAFE_APPS and exact CSP frame domains without rebuilding portable source. */+/** Build the canonical Page at read time. External apps remain registry-driven,+ * but ChatGPT presentation is iframe-free to avoid external-frame review and to+ * preserve each app's own auth/frame boundary through the remote-browser seam. */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.",+ description: "Full-page MSO presentation target for native operator views and registry-backed external app handoff through the remote-browser seam.",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()] },+ "Interactive MSO Page. It renders native operator views and registry-backed external app handoff without nested external iframes; arbitrary HTML and URLs are never accepted from the model.",+ { connectDomains: [publicMsoOrigin()] },),} as const;}diff --git a/scripts/e2e/mcp-page.mjs b/scripts/e2e/mcp-page.mjsindex f2818ab8..4c632d17 100644--- a/scripts/e2e/mcp-page.mjs+++ b/scripts/e2e/mcp-page.mjs@@ -1,96 +1,80 @@#!/usr/bin/env node-// Browser contract for the portable MCP host, readiness, timeout and legacy cached output.+// Browser contract for the iframe-free ChatGPT MSO Page external-app handoff.import assert from "node:assert/strict";import { execFileSync } from "node:child_process";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(await MSO_PAGE_RESOURCE))'], { encoding: "utf8" }));+const registry = [{+ id: "play-together",+ title: "Play Together",+ description: "Controlled external app fixture",+ origin: "https://game.example.com",+ startPath: "/embed",+ renderer: "iframe",+ presentation: "inline",+ environment: "production",+ sandbox: "allow-scripts allow-same-origin",+}];+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", env: { ...process.env, MSO_SURFACE_APPS_JSON: JSON.stringify(registry), OS_PUBLIC_ORIGIN: "https://mso.example.com", OS_MCP_UI_ORIGIN: "https://mso-ui.example.com" } },+));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" },+ route: "/apps/play-together",+ kind: "app",+ title: "Play Together",+ openPath: "/browser",+ catalog: [],+ app: {+ id: "play-together",+ title: "Play Together",+ description: "Controlled external app fixture",+ origin: "https://game.example.com",+ startPath: "/embed",+ renderer: "remote",+ presentation: "inline",+ environment: "production",+ reason: "External apps use the remote-browser seam so the ChatGPT Page stays free of nested external iframes.",+ url: "https://game.example.com/embed",+ },};++assert.equal(resource.uri, "ui://mso/page-v13.html");+assert.equal(resource._meta.ui.csp.frameDomains, undefined);+assert.equal(resource._meta["openai/widgetCSP"].frame_domains, undefined);+assert(!resource.text.includes('createElement("iframe")'));+assert(!resource.text.includes("mountReviewedFrame"));+assert(resource.text.includes('"renderer":"remote"'));+const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH ?? "/usr/bin/google-chrome", args: ["--no-sandbox", "--disable-dev-shm-usage"] });-let assertions = 0;+let assertions = 6;try {- for (const legacy of [false, true]) {- const page = await browser.newPage({ viewport: { width: legacy ? 390 : 1280, height: 800 } });- await page.clock.install();- let childLoads = 0;- await page.route("https://game.example.com/embed", (route) => {- childLoads++;- return route.fulfill({ contentType: "text/html", body: "<!doctype html><title>Controlled game readiness fixture</title><main>Fixture game shell</main>" });- });- await page.route("https://mso-ui.example.com/qa", (route) => route.fulfill({ contentType: "text/html", body: `${legacy ? `<script>window.openai={toolOutput:${JSON.stringify({ structuredContent: output })}}</script>` : ""}${resource.text}` }));- await page.route("https://chatgpt.com/qa", (route) => route.fulfill({ contentType: "text/html", body: `<!doctype html><script>- window.calls=[];window.result=${JSON.stringify(output)};- window.addEventListener("message",event=>{- const msg=event.data;if(!msg||msg.jsonrpc!=="2.0")return;calls.push(msg);- const frame=document.querySelector("iframe").contentWindow;- if(msg.method==="ui/initialize"&&!${legacy})frame.postMessage({jsonrpc:"2.0",id:msg.id,result:{protocolVersion:"2026-01-26",hostCapabilities:{serverTools:{},openLinks:{}},hostContext:{displayMode:"inline",maxHeight:800}}},"https://mso-ui.example.com");- if(msg.method==="ui/notifications/initialized"){- frame.postMessage({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:{route:result.route}}},"https://mso-ui.example.com");- frame.postMessage({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{structuredContent:result}},"https://mso-ui.example.com");- }- if(msg.method==="ui/notifications/size-changed")document.querySelector("iframe").style.height=msg.params.height+"px";- if(msg.method==="ui/open-link")frame.postMessage({jsonrpc:"2.0",id:msg.id,result:{}},"https://mso-ui.example.com");- });</script><iframe src="https://mso-ui.example.com/qa" style="width:100%;height:740px"></iframe>` }));+ for (const viewport of [{ width: 1280, height: 800 }, { width: 390, height: 800 }]) {+ const page = await browser.newPage({ viewport });+ await page.route("https://mso-ui.example.com/qa", (route) => route.fulfill({+ contentType: "text/html",+ body: `<script>window.openai={toolOutput:${JSON.stringify({ structuredContent: output })}}</script>${resource.text}`,+ }));+ await page.route("https://chatgpt.com/qa", (route) => route.fulfill({+ contentType: "text/html",+ body: '<!doctype html><iframe src="https://mso-ui.example.com/qa" style="width:100%;height:740px"></iframe>',+ }));+await page.goto("https://chatgpt.com/qa");const component = page.frameLocator('iframe[src="https://mso-ui.example.com/qa"]');- await component.locator('.frame-wrap[data-state="loading"]').waitFor();- assert.equal(childLoads, 1); assertions++;- assert.equal(await component.locator("iframe").count(), 1, "one Page document must mount exactly one reviewed app frame"); assertions++;- if (!legacy) {- await page.waitForTimeout(50);- const hostHeight = await page.locator('iframe[src="https://mso-ui.example.com/qa"]').evaluate((node) => node.getBoundingClientRect().height);- assert(hostHeight < 400, `inline Page must stay below 50% of the 800px host viewport, got ${hostHeight}`); assertions++;- assert.equal(await component.locator("#surface-mode").textContent(), "inline"); assertions++;- }- const widget = page.frames().find((frame) => frame.url() === "https://mso-ui.example.com/qa");- const game = page.frames().find((frame) => frame.url() === "https://game.example.com/embed");- assert(widget && game);- if (!legacy) {- const calls = await page.evaluate(() => window.calls);- assert.equal(calls[0].method, "ui/initialize");- assert.equal(calls[0].params.appInfo.name, "MSO Page");- assert.deepEqual(calls[0].params.appCapabilities.availableDisplayModes, ["inline", "fullscreen", "pip"]);- assert(calls.some((call) => call.method === "ui/notifications/initialized")); assertions++;- }- await widget.evaluate(() => window.dispatchEvent(new MessageEvent("message", { origin: "https://game.example.com", source: window, data: { type: "play-together:embed-ready", schemaVersion: 1 } })));- assert.equal(await component.locator(".frame-wrap").getAttribute("data-state"), "loading"); assertions++;- await game.evaluate(() => parent.postMessage({ type: "play-together:embed-ready", schemaVersion: 99 }, "https://mso-ui.example.com"));- assert.equal(await component.locator(".frame-wrap").getAttribute("data-state"), "loading"); assertions++;- await page.clock.fastForward(13000);- await component.locator('.frame-wrap[data-state="unavailable"]').waitFor();- await component.getByRole("button", { name: "Retry preview" }).click();- await component.locator('.frame-wrap[data-state="loading"]').waitFor();- await page.waitForTimeout(50);- const reloaded = page.frames().find((frame) => frame.url() === "https://game.example.com/embed");- assert(reloaded); assertions++;- await reloaded.evaluate(() => parent.postMessage({ type: "play-together:embed-ready", schemaVersion: 1 }, "https://mso-ui.example.com"));- await component.locator('.frame-wrap[data-state="ready"]').waitFor(); assertions++;- const previousLoads = childLoads;- await page.evaluate(() => document.querySelector("iframe").contentWindow.postMessage({ jsonrpc: "2.0", method: "ui/notifications/tool-result", params: { structuredContent: window.result } }, "https://mso-ui.example.com"));- await widget.evaluate(() => window.dispatchEvent(new Event("openai:set_globals")));- await page.waitForTimeout(50);- assert.equal(childLoads, previousLoads, "Unchanged results and host globals must not restart the game"); assertions++;- if (!legacy) {- await component.getByRole("button", { name: "Open production" }).click();- assert((await page.evaluate(() => window.calls)).some((call) => call.method === "ui/open-link" && call.params.url === "https://game.example.com")); assertions++;- }- const authAction = component.getByRole("button", { name: "Google login in browser", exact: true });- await authAction.waitFor();- const opensBeforeAuth = (await page.evaluate(() => window.calls)).filter(call => call.method === "ui/open-link").length;- await reloaded.evaluate(() => parent.postMessage({ type: "mso:app-auth-request", schemaVersion: 1, provider: "google" }, "https://mso-ui.example.com"));- await page.waitForTimeout(50);- assert.equal((await page.evaluate(() => window.calls)).filter(call => call.method === "ui/open-link").length, opensBeforeAuth, "Nested messages must not trigger external navigation"); assertions++;- if (!legacy) {- await authAction.click();- assert((await page.evaluate(() => window.calls)).some(call => call.method === "ui/open-link" && call.params.url === "https://game.example.com/?auth=google")); assertions++;- }- console.log(`PASS ${legacy ? "legacy wrapped toolOutput / mobile" : "pure MCP Apps host / desktop"}: init, source validation, timeout, retry, ready, no repeated reload`);+ await component.getByText("Play Together opens through MSO Browser", { exact: true }).waitFor();+ assert.equal(await component.locator("iframe").count(), 0, "MSO Page must not mount a nested external iframe"); assertions++;+ assert.equal(await component.locator("#open").getAttribute("data-mso-path"), "/browser"); assertions++;+ assert.equal(await component.getByText(/remote-browser seam/i).count(), 1); assertions++;+ assert.equal(await component.getByRole("button", { name: "Open Remote Browser" }).count(), 1); assertions++;+ console.log(`PASS iframe-free external app handoff ${viewport.width}x${viewport.height}`);await page.close();}console.log(`MCP Page browser checks: ${assertions} assertions passed`);-} finally { await browser.close(); }+} finally {+ await browser.close();+}