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(integrations): recover setup UI and cached chat links
Rahman97aa1cc9e830
diff --git a/app/api/v1/infra/setup/route.ts b/app/api/v1/infra/setup/route.tsindex c61ea7ad..45b8eb02 100644--- a/app/api/v1/infra/setup/route.ts+++ b/app/api/v1/infra/setup/route.ts@@ -15,6 +15,6 @@ export async function POST(req: NextRequest) {if (Object.keys(body).some(k => !["provider", "method"].includes(k)) || typeof body.provider !== "string" || (body.method !== undefined && typeof body.method !== "string")) throw new Error("invalid");const grant = await openIntegrationSetup(body.provider, context.session.device_id, body.method as string | undefined);void audit({ action: "infra.write", actor: context.session.device_id, target: body.provider, ok: true, detail: "integration.setup-open" });- return NextResponse.json({ ...grant, setupUrl: `${MSO_ORIGIN}/api/integrations/setup` }, { headers });+ return NextResponse.json({ ...grant, setupUrl: `${MSO_ORIGIN}/integrations` }, { headers });} catch { return NextResponse.json({ error: "setup_unavailable" }, { status: 400, headers }); }}diff --git a/app/integrations/route.test.ts b/app/integrations/route.test.tsnew file mode 100644index 00000000..b77a001a--- /dev/null+++ b/app/integrations/route.test.ts@@ -0,0 +1,7 @@+import { expect, it } from "vitest";+import { GET } from "./route";+it("serves a public uncached integration document with its own matching nonce", async () => {+ const r = GET(); const html = await r.text(); expect(r.status).toBe(200);+ const nonce = html.match(/<script nonce="([^"]+)"/)![1]; expect(r.headers.get("content-security-policy")).toContain(`script-src 'nonce-${nonce}'`);+ expect(r.headers.get("cache-control")).toContain("no-store"); expect(r.headers.get("x-frame-options")).toBe("DENY");+});diff --git a/app/integrations/route.ts b/app/integrations/route.tsnew file mode 100644index 00000000..5e494714--- /dev/null+++ b/app/integrations/route.ts@@ -0,0 +1,8 @@+import { NextResponse } from "next/server";+import { integrationSetupPage } from "@/lib/infra/setup-page";+export const runtime = "nodejs";+export const dynamic = "force-dynamic";+export function GET() {+ const page = integrationSetupPage();+ return new NextResponse(page.html, { headers: { "Content-Type": "text/html; charset=utf-8", "Content-Security-Policy": page.csp, "Cache-Control": "no-store, private", "Referrer-Policy": "no-referrer", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "DENY" } });+}diff --git a/docs/INTEGRATIONS.md b/docs/INTEGRATIONS.mdindex fb226cf1..9d24006a 100644--- a/docs/INTEGRATIONS.md+++ b/docs/INTEGRATIONS.md@@ -6,8 +6,12 @@ API key or an organization API key; these are separate setup methods.## Browser and terminal-Open `/api/integrations/setup` on your MSO origin, sign in as an owner in another-tab when needed, select the provider, then choose **Start secure setup**. The form+Open `/integrations` on your MSO origin. The page checks your live session and+disables **Open secure form** until the device has Owner permission. Provider+guides remain readable before sign-in. Open MSO sign-in in another tab, then return;+focus/visibility refreshes the session, with **Check sign-in again** as a fallback.+Choose the provider and authentication method, then open its secure form. The old+`/api/integrations/setup` URL remains compatible. The formincludes official links, expandable instructions, masked inputs with show/hide,and **Validate & save**. Existing stored values are never displayed; blank fieldskeep them unchanged. A rejected or unreachable provider does not replace them.@@ -44,9 +48,16 @@ ChatGPT → integration_setup_open(provider, method)provider validation → private MSO store```+Page v4 keeps explicit public browser links and provider guides visible even when+a cached chat cannot call the new setup tool. A missing tool or missing private+metadata no longer replaces the whole page with an error. A server update does+not itself refresh the client catalog; reconnect MSO to load new actions.+Older Page resource URIs resolve to the current resource without adding a third+UI type.+The grant reaches the UI through hidden MCP `_meta`. A WeakMap keeps it out ofordinary result serialization and non-ChatGPT model transports. The UI supports-both standards-based MCP Apps initialization and ChatGPT's canonical metadata+standards-based MCP Apps initialization and ChatGPT's canonical metadataenvelope. Credential values never enter `tools/call`, `ui/message`, widget state,local storage, or session storage. Buttons do not require iframe `allow-forms`;reference links use the host's approved external-link bridge.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex db4f7f00..6e558082 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,5 +1,24 @@## 2026-09-05 — MCP Page preview lifecycle+## 2026-09-05 — Integration setup recovery and complete browser navigation++The previous setup document exposed a clickable setup button before Owner sign-in,+then collapsed authentication and transport failures into the same 403 message.+The Page also depended on a new setup action that cached chat catalogs may not know.+The native `/integrations` hub now probes live auth before enabling changes, keeps+provider/method guides available beforehand, refreshes on return from sign-in, and+provides expiry recovery and a route back from completed forms. Old URLs are retained.+Page v4 preserves usable browser links on unknown-tool/missing-private-metadata+responses, while older Page URIs map to the same current resource. Framing policy,+Owner gates, direct secret submission, and scoped capability checks remain intact.++Validation: isolated desktop/mobile browser runs exercise the signed-out to Owner+transition, method selection, rejected-save retry, cleared successful inputs, and+cached/current MCP bridge modes. No real credential was written by those tests.+The connected chat can display the Page, but a browser fixture is not proof that+its cached tool catalog has refreshed; the visible fallback is part of the contract.++Fixed a missing MCP Apps host initialization handshake, wrapped tool-result handling andrepeated iframe remounts on unchanged globals. Page v3 now waits for an origin/source-checkedapp readiness message, displays bounded retry/direct-production actions, and preserves thediff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.mdindex 0d94a680..c3eb1644 100644--- a/docs/generated/MCP-CATALOG.md+++ b/docs/generated/MCP-CATALOG.md@@ -4,13 +4,13 @@## Full MSO catalog-<!-- mcp-toolset: server=1.12.0 version=2026.09.05.4 tools=89 read=44 write=26 exec=19 -->+<!-- mcp-toolset: server=1.12.0 version=2026.09.05.5 tools=89 read=44 write=26 exec=19 -->| Fact | Current source value ||---|---:|| MCP server | `1.12.0` |-| Toolset | `2026.09.05.4` |-| Toolset changed at | `2026-09-05T11:59:00Z` |+| Toolset | `2026.09.05.5` |+| Toolset changed at | `2026-09-05T12:36:17Z` || Transport tools | **91** || Model/operator tools | **89** || Read | **44** |@@ -123,7 +123,7 @@## ChatGPT static profile-<!-- mcp-chatgpt-profile: server=1.12.0 version=2026.09.05.4 tools=65 read=35 write=18 exec=12 app-only=2 total=67 -->+<!-- mcp-chatgpt-profile: server=1.12.0 version=2026.09.05.5 tools=65 read=35 write=18 exec=12 app-only=2 total=67 -->The ChatGPT profile is a fail-closed static projection defined by `CHATGPT_TOOL_NAMES`. OAuth scope is still enforced independently; project-owned MCP tool names remain dynamic data behind the generic project bridge.diff --git a/lib/infra/setup-hub.test.ts b/lib/infra/setup-hub.test.tsnew file mode 100644index 00000000..01bcda01--- /dev/null+++ b/lib/infra/setup-hub.test.ts@@ -0,0 +1,15 @@+import { expect, it } from "vitest";+import { setupCatalog, SETUP_HUB_SCRIPT } from "./setup-hub";+import { INFRA_PROVIDER_IDS } from "./types";+import { integrationSetupPage } from "./setup-page";+it("derives the complete native setup catalog from the same provider registry", () => {+ const rows = setupCatalog(); expect(rows.map(p => p.id)).toEqual([...INFRA_PROVIDER_IDS]);+ for (const p of rows) for (const method of p.methods) { expect(method.guidance.url).toMatch(/^https:/); expect(method.guidance.steps.length).toBeGreaterThan(1); }+ expect(rows.find(p => p.id === "composio")?.methods.map(m => m.id)).toEqual(["project", "organization"]);+});+it("public hub is usable before sign-in and offers explicit auth/expiry recovery", () => {+ const page = integrationSetupPage();+ expect(() => new Function(page.html.match(/<script[^>]*>([\s\S]*?)<\/script>/)![1])).not.toThrow();+ for (const marker of ['"/api/auth/me"', 'start.disabled=userState.role!=="owner"', '"visibilitychange"', '"How to get this credential"', '"Open a new setup session"']) expect(page.html).toContain(marker);+ expect(SETUP_HUB_SCRIPT).not.toContain('localStorage'); expect(page.csp).toContain("form-action 'none'");+});diff --git a/lib/infra/setup-hub.ts b/lib/infra/setup-hub.tsnew file mode 100644index 00000000..80f68d9a--- /dev/null+++ b/lib/infra/setup-hub.ts@@ -0,0 +1,44 @@+import { listInfraProviderDefinitions } from "./catalog";+import { setupGuidance } from "./setup-guidance";++export function setupCatalog() {+ return listInfraProviderDefinitions().map(p => ({+ id: p.id, title: p.title, description: p.description,+ methods: (p.id === "composio" ? ["project", "organization"] as const : ["direct"] as const).map(id => ({+ id, title: id === "direct" ? "API token" : `${id === "project" ? "Project" : "Organization"} API key`,+ guidance: setupGuidance(p.id, id),+ })),+ }));+}+export const SETUP_HUB_STYLE = String.raw`+[hidden]{display:none!important}.integration{width:100%;min-width:0}.integration .hub-heading{display:flex;gap:16px;align-items:start;justify-content:space-between;flex-wrap:wrap}.integration .hub-layout{display:grid;grid-template-columns:minmax(180px,.75fr) minmax(0,1.8fr);gap:24px;margin-top:24px}.integration .hub-sidebar{display:grid;gap:8px;align-content:start}.integration .hub-provider{display:block;width:100%;text-align:left;font:inherit;border:1px solid var(--sep-strong);border-radius:12px;padding:12px;background:var(--field);color:var(--text);cursor:pointer}.integration .hub-provider[aria-pressed=true]{border-color:var(--os-accent);box-shadow:inset 3px 0 0 var(--os-accent)}.integration .hub-provider span{display:block;font-size:12px;color:var(--text-dim);margin-top:2px}.integration .hub-panel{min-width:0;padding:20px;border:1px solid var(--sep-strong);border-radius:16px;background:var(--field)}.integration .hub-auth{border:1px solid var(--sep-strong);border-radius:12px;padding:14px;margin:16px 0}.integration .hub-status{font-size:13px;min-height:24px}.integration .hub-search{margin-bottom:8px}.integration .hub-provider strong{font-size:14px}.integration .setup-tag{margin:0 0 12px}.integration .hub-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}.integration .hub-actions a{display:inline-flex;align-items:center;min-height:42px}.integration .hub-panel h3{margin:0 0 8px;font-size:20px}.integration .grid{grid-template-columns:repeat(2,minmax(0,1fr))}.integration .card strong{font-size:16px}.integration .card p{font-size:13px}.integration .hub-help{font-size:12px}.integration button:focus-visible,.integration a:focus-visible{outline:2px solid var(--os-accent);outline-offset:3px}@media(max-width:620px){.integration .grid{grid-template-columns:1fr}.integration .hub-layout{grid-template-columns:1fr;gap:16px}.integration .hub-sidebar{grid-template-columns:1fr 1fr}.integration .hub-search{grid-column:1/-1}.integration .hub-panel{padding:16px}.integration .hub-provider{padding:10px}}`;++/** Display data only. Authentication is checked before presenting a usable Save path. */+export const SETUP_HUB_SCRIPT = String.raw`+function mountIntegrationHub(root,catalog){+ let userState={authenticated:false,role:null},selected=catalog.find(p=>p.id===new URLSearchParams(location.search).get("provider"))||catalog[0],busy=false,disposed=false;+ const endpoint=location.origin+"/api/integrations/setup";+ const n=integrationNode;root.replaceChildren();+ const head=n("div"),intro=n("div");head.className="hub-heading";intro.append(n("h2","Integrations"),n("p","Connect your services to MSO. Choose a provider, follow its guide, then enter the credential securely."));head.append(intro);root.append(head);+ const auth=n("div"),authText=n("p","Checking sign-in…"),authActions=n("div"),login=n("a","Sign in to MSO"),refresh=n("button","Check sign-in again");auth.className="hub-auth";authText.setAttribute("role","status");authActions.className="hub-actions";login.href="/";login.target="_blank";login.rel="noopener noreferrer";refresh.type="button";authActions.append(login,refresh);auth.append(authText,authActions);root.append(auth);+ const layout=n("div"),sidebar=n("nav"),panel=n("section"),search=n("input");layout.className="hub-layout";sidebar.className="hub-sidebar";sidebar.setAttribute("aria-label","Providers");panel.className="hub-panel";search.type="search";search.placeholder="Find a provider";search.setAttribute("aria-label","Find a provider");search.className="hub-search";sidebar.append(search);layout.append(sidebar,panel);root.append(layout);+ const buttons=[];+ for(const provider of catalog){const b=n("button"),title=n("strong",provider.title);b.type="button";b.className="hub-provider";b.append(title,n("span",provider.methods.length>1?"Choose key type":"Direct connection"));b.onclick=()=>{if(!busy){selected=provider;renderPanel()}};sidebar.append(b);buttons.push({provider,b})}+ search.oninput=()=>{for(const {provider,b} of buttons)b.hidden=!provider.title.toLowerCase().includes(search.value.toLowerCase())};+ function renderPanel(){+ if(disposed)return;panel.replaceChildren();for(const {provider,b} of buttons)b.setAttribute("aria-pressed",String(provider.id===selected.id));+ panel.append(n("h3",selected.title),n("p",selected.description));+ const label=n("label","Authentication method"),method=n("select");method.id="setup-method";label.htmlFor=method.id;+ for(const m of selected.methods){const option=n("option",m.title);option.value=m.id;method.append(option)}+ const desired=new URLSearchParams(location.search).get("method");if(selected.methods.some(m=>m.id===desired))method.value=desired;+ panel.append(label,method);+ const guide=n("details"),guideBody=n("div"),summary=n("summary","How to get this credential");guide.open=true;guide.append(summary,guideBody);panel.append(guide);+ function renderGuide(){guideBody.replaceChildren();const g=selected.methods.find(m=>m.id===method.value).guidance;for(const [url,text] of [[g.url,"Provider dashboard"],[g.reference,"Official documentation"]]){const a=n("a",text);a.href=url;a.target="_blank";a.rel="noopener noreferrer";const p=n("p");p.append(a);guideBody.append(p)}const list=n("ol");for(const step of g.steps)list.append(n("li",step));guideBody.append(list)}method.onchange=renderGuide;renderGuide();+ const actions=n("div"),start=n("button","Open secure form"),status=n("p");actions.className="hub-actions";start.type="button";start.className="primary";start.disabled=userState.role!=="owner";status.className="hub-status";status.setAttribute("role","status");status.textContent=userState.role==="owner"?"Ready. Existing keys stay hidden and are kept until validation succeeds.":"Read the guide now. Sign in with an approved Owner device to enter or change credentials.";actions.append(start);panel.append(actions,status,n("p","A form expires after ten minutes. MSO never asks you to put a key in chat."));+ start.onclick=async()=>{if(busy||start.disabled)return;busy=true;start.disabled=true;status.textContent="Opening your secure form…";try{const r=await fetch("/api/v1/infra/setup",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:selected.id,method:method.value}),signal:AbortSignal.timeout(15000)});const data=await r.json();if(!r.ok){if(r.status===403){await refreshAuth();throw new Error("Your Owner session is no longer available. Sign in again.")}throw new Error("Setup is temporarily unavailable. Retry without changing your existing credentials.")}disposed=true;removeListeners();const back=n("button","← All integrations");back.type="button";const host=n("div"),formRoot=n("div");root.replaceChildren(back,host);host.append(formRoot);let cleanup=mountIntegrationForm(formRoot,data.setup,{endpoint,token:data.token});back.onclick=()=>{cleanup?.();mountIntegrationHub(root,catalog)}}catch(e){status.textContent=e.message;start.disabled=userState.role!=="owner"}finally{busy=false}};+ }+ async function refreshAuth(){if(disposed)return;refresh.disabled=true;try{const r=await fetch("/api/auth/me",{cache:"no-store",credentials:"same-origin",signal:AbortSignal.timeout(8000)});if(!r.ok)throw new Error();userState=await r.json();authText.textContent=userState.role==="owner"?"Owner session ready. Your credentials are stored only on this MSO server.":userState.authenticated?"You are signed in, but credential changes require an approved Owner device.":"You are not signed in. Open MSO sign-in, then return to this page.";login.hidden=userState.role==="owner";renderPanel()}catch{authText.textContent="Cannot reach MSO. Check your connection, then retry."}finally{refresh.disabled=false}}+ function visible(){if(document.visibilityState==="visible")refreshAuth()}function removeListeners(){window.removeEventListener("focus",refreshAuth);document.removeEventListener("visibilitychange",visible)}+ refresh.onclick=refreshAuth;window.addEventListener("focus",refreshAuth);document.addEventListener("visibilitychange",visible);renderPanel();refreshAuth();+}+`;diff --git a/lib/infra/setup-page.ts b/lib/infra/setup-page.tsindex 375d53c3..33d91875 100644--- a/lib/infra/setup-page.ts+++ b/lib/infra/setup-page.ts@@ -1,19 +1,12 @@import { randomBytes } from "node:crypto";import { MSO_WIDGET_TOKENS } from "@/lib/presentation/widget-tokens";import { INTEGRATION_FORM_SCRIPT, INTEGRATION_FORM_STYLE } from "./setup-ui";+import { setupCatalog, SETUP_HUB_SCRIPT, SETUP_HUB_STYLE } from "./setup-hub";export function integrationSetupPage() {const nonce = randomBytes(18).toString("base64");- const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>MSO Integrations</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_FORM_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:clamp(18px,4vw,50px);font-family:var(--font-body);color:var(--text)}header{max-width:850px;margin:0 auto 28px;font-size:13px}button{border:1px solid var(--sep-strong);border-radius:10px;background:var(--field);color:var(--text);padding:9px 15px;cursor:pointer}select{margin:8px 0 16px}a{color:var(--os-accent)}</style></head><body><header>MSO / Integrations · Secure setup</header><main id="setup" class="integration"></main><script nonce="${nonce}">${INTEGRATION_FORM_SCRIPT}-(async()=>{-const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup";-let token=location.hash.slice(1);history.replaceState(null,"",location.pathname);-if(token){try{const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"schema"})});if(!response.ok)throw new Error("Setup expired or unavailable. Open a new session.");mountIntegrationForm(root,await response.json(),{endpoint,token});token="";return}catch(error){root.append(integrationNode("p",error.message));return}}-root.append(integrationNode("h2","Connect a service"),integrationNode("p","Sign in to MSO as an owner, then start a temporary credential form. No extra plugin is required."));-const label=integrationNode("label","Provider"),select=integrationNode("select");select.id="provider";label.htmlFor=select.id;for(const name of ["composio","dokploy","cloudflare","hostinger"]){const o=integrationNode("option",name[0].toUpperCase()+name.slice(1));o.value=name;select.append(o)}-const ml=integrationNode("label","Composio key type"),method=integrationNode("select");method.id="method";ml.htmlFor=method.id;for(const name of ["project","organization"]){const o=integrationNode("option",name+" API key");o.value=name;method.append(o)}select.addEventListener("change",()=>{method.hidden=ml.hidden=select.value!=="composio"});-const open=integrationNode("button","Start secure setup"),status=integrationNode("p"),login=integrationNode("a","Open MSO sign-in");login.href="/";login.target="_blank";login.rel="noopener noreferrer";open.type="button";-root.append(label,select,ml,method,open,status,login);open.addEventListener("click",async()=>{open.disabled=true;try{const response=await fetch("/api/v1/infra/setup",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:select.value,method:select.value==="composio"?method.value:"direct"})});if(!response.ok)throw new Error("Owner sign-in is required, or setup is temporarily unavailable.");const data=await response.json();mountIntegrationForm(root,data.setup,{endpoint,token:data.token})}catch(error){status.textContent=error.message;open.disabled=false}})-})();</script></body></html>`;+ const catalog = JSON.stringify(setupCatalog()).replace(/</g, "\\u003c");+ const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>MSO Integrations</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_FORM_STYLE}${SETUP_HUB_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:clamp(18px,4vw,50px);font-family:var(--font-body);color:var(--text)}header{max-width:850px;margin:0 auto 24px;font-size:13px}button{border:1px solid var(--sep-strong);border-radius:10px;background:var(--field);color:var(--text);padding:9px 15px;cursor:pointer}select{margin:8px 0 16px}a{color:var(--os-accent)}</style></head><body><header>MSO / Integrations</header><main id="setup" class="integration"><p>Loading integrations…</p></main><noscript>JavaScript is needed for secure credential setup. Use the MSO terminal as an alternative.</noscript><script nonce="${nonce}">${INTEGRATION_FORM_SCRIPT}${SETUP_HUB_SCRIPT}+(async()=>{const root=document.getElementById("setup"),endpoint=location.origin+"/api/integrations/setup",catalog=${catalog};let token=location.hash.slice(1);history.replaceState(null,"",location.pathname+location.search);if(!token){mountIntegrationHub(root,catalog);return}root.replaceChildren(integrationNode("p","Checking secure setup session…"));try{const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"schema"}),signal:AbortSignal.timeout(12000)});if(!response.ok)throw new Error("This private setup session expired or was already used.");const setup=await response.json();const cleanup=mountIntegrationForm(root,setup,{endpoint,token});token="";window.addEventListener("pagehide",()=>cleanup?.(),{once:true})}catch{token="";root.replaceChildren(integrationNode("h2","Setup session unavailable"),integrationNode("p","The link may have expired or already been used. Your stored credentials have not changed."));const retry=integrationNode("button","Open a new setup session");retry.type="button";retry.onclick=()=>mountIntegrationHub(root,catalog);root.append(retry)}})();</script></body></html>`;return { html, csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; connect-src 'self'; form-action 'none'; base-uri 'none'; frame-ancestors 'none'` };}diff --git a/lib/infra/setup-ui.ts b/lib/infra/setup-ui.tsindex 7114295f..82dbe9d5 100644--- a/lib/infra/setup-ui.ts+++ b/lib/infra/setup-ui.ts@@ -26,7 +26,7 @@ function mountIntegrationForm(root,setup,access){guide.append(link(setup.guidance.url,"Open official provider dashboard"));for(const text of setup.guidance.steps)steps.append(integrationNode("li",text));guide.append(steps,link(setup.guidance.reference,"Official documentation"));const storage=integrationNode("details");storage.append(integrationNode("summary","Storage and privacy"),integrationNode("p",setup.store),integrationNode("p","The form expires after 10 minutes and closes after a successful save. Existing keys are never displayed. Blank fields keep existing values. If a key was shared publicly, revoke it at its provider."));aside.append(guide,storage);grid.append(form,aside);root.append(grid);- let used=false;+ let used=false;const abort=new AbortController();const expire=()=>{used=true;save.disabled=true;inputs.forEach(f=>{f.input.value="";f.input.disabled=true});status.textContent="Setup expired. Open a new secure form."};const timer=setTimeout(expire,Math.max(0,setup.expiresAt-Date.now()));form.addEventListener("submit",e=>e.preventDefault());@@ -35,12 +35,12 @@ function mountIntegrationForm(root,setup,access){e.preventDefault();if(used||save.disabled||!form.reportValidity())return;save.disabled=true;status.textContent="Checking provider access…";const values={};for(const f of inputs)if(f.input.value.trim())values[f.key]=f.input.value.trim();try{- const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"save",values}),signal:AbortSignal.timeout(25000)});+ const response=await fetch(endpoint,{method:"POST",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/json",Authorization:"Bearer "+token},body:JSON.stringify({action:"save",values}),signal:AbortSignal.any([abort.signal,AbortSignal.timeout(45000)])});const data=await response.json();if(!response.ok){const messages={credential_validation_failed:"The provider rejected this key or could not be reached. Check key type, permissions, and expiry; nothing was saved.",invalid_credential_format:"Check the credential format and remove pasted line breaks.",required_fields_missing:"Complete all required fields.",enter_at_least_one_value:"Enter a value to update.",setup_expired_or_invalid:"Setup expired or already used. Open a new form."};throw new Error(messages[data.error]||"Unable to save. Reopen setup or check the provider; nothing was displayed.")}used=true;clearTimeout(timer);inputs.forEach(f=>{f.input.value="";f.input.disabled=true});save.textContent="Saved";status.textContent="Verified and saved in MSO. This setup session is now closed.";}catch(error){status.textContent=error.message||"Connection failed. Check MSO connectivity."}finally{if(!used)save.disabled=false;for(const key of Object.keys(values))delete values[key]}});- return()=>{clearTimeout(timer);inputs.forEach(f=>{f.input.value=""});root.replaceChildren()};+ return()=>{abort.abort();clearTimeout(timer);inputs.forEach(f=>{f.input.value=""});root.replaceChildren()};}`;diff --git a/lib/mcp/surface-catalog.ts b/lib/mcp/surface-catalog.tsindex 0752fc3d..906734ce 100644--- a/lib/mcp/surface-catalog.ts+++ b/lib/mcp/surface-catalog.ts@@ -85,7 +85,7 @@ export function resolveSurfaceRoute(rawRoute: string, context?: { project?: striconst route = `${url.pathname}${url.search}`;if (parts.length === 0) return { route, kind: "home", title: "MSO", openPath: "/assistant/mcp" };- if (parts[0] === "integrations" && parts.length === 1) return { route, kind: "integrations", title: "Integrations", openPath: "/api/integrations/setup" };+ if (parts[0] === "integrations" && parts.length === 1) return { route, kind: "integrations", title: "Integrations", openPath: "/integrations" };if (parts[0] === "monitor" && parts.length === 1) return { route, kind: "monitor", title: "System Monitor", openPath: "/monitor" };if (parts[0] === "browser" && parts.length === 1) return { route, kind: "browser", title: "Remote Browser", openPath: "/browser" };if (parts[0] === "project" && parts.length === 1) return { route, kind: "project", title: "Project", openPath: "/files", ...(context?.project ? { project: context.project } : {}) };diff --git a/lib/mcp/tools-infra.ts b/lib/mcp/tools-infra.tsindex b87a828a..d32ef88b 100644--- a/lib/mcp/tools-infra.ts+++ b/lib/mcp/tools-infra.ts@@ -11,7 +11,7 @@ const dnsSchema = {export const INFRA_TOOLS: McpTool[] = [{name: "infra_providers_list",- description: "List MSO infrastructure providers (Dokploy, Cloudflare, Hostinger), showing masked configuration state and missing required fields. Raw credentials are never returned.",+ description: "List MSO infrastructure providers (Dokploy, Cloudflare, Hostinger, Composio), showing masked configuration state and missing required fields. Raw credentials are never returned.",scope: "read",annotations: { readOnlyHint: true, idempotentHint: true },inputSchema: S({}),diff --git a/lib/mcp/tools-surface.ts b/lib/mcp/tools-surface.tsindex ae1da47d..e5454005 100644--- a/lib/mcp/tools-surface.ts+++ b/lib/mcp/tools-surface.ts@@ -68,7 +68,7 @@ export const SURFACE_TOOLS: McpTool[] = [},run: async (input, context) => {const grant = await openIntegrationSetup(str(input, "provider"), context.principal ?? context.actor ?? "", opt(input, "method"));- const output = { route: "/integrations", kind: "integrations", title: "Integrations", openPath: "/api/integrations/setup", catalog: publicSurfaceApps(), setup: grant.setup };+ const output = { route: "/integrations", kind: "integrations", title: "Integrations", openPath: "/integrations", catalog: 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` } });},diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.tsindex 5a8b08bf..eb20be4e 100644--- a/lib/mcp/toolset.ts+++ b/lib/mcp/toolset.ts@@ -4,8 +4,8 @@ import type { McpTool } from "./tool-kit";import { toolDescriptor, type McpToolProfile } from "./tool-contract";export const MCP_SERVER_VERSION = "1.12.0";-export const MCP_TOOLSET_VERSION = "2026.09.05.4";-export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T11:59:00Z";+export const MCP_TOOLSET_VERSION = "2026.09.05.5";+export const MCP_TOOLSET_CHANGED_AT = "2026-09-05T12:36:17Z";export type McpToolsetInfo = {serverVersion: string;diff --git a/lib/mcp/ui-page-integrations.ts b/lib/mcp/ui-page-integrations.tsindex c49cf937..b82bcbd4 100644--- a/lib/mcp/ui-page-integrations.ts+++ b/lib/mcp/ui-page-integrations.ts@@ -1,39 +1,43 @@import { INTEGRATION_FORM_SCRIPT } from "@/lib/infra/setup-ui";-import { INFRA_PROVIDER_IDS } from "@/lib/infra/types";+import { setupCatalog } from "@/lib/infra/setup-hub";import { MSO_ORIGIN } from "./ui-config";-/** Native secret form; shares the existing Page lifecycle without sending secrets to it. */export const MSO_PAGE_INTEGRATIONS_SCRIPT = String.raw`${INTEGRATION_FORM_SCRIPT}const INTEGRATION_ENDPOINT=${JSON.stringify(MSO_ORIGIN + "/api/integrations/setup")};-const INTEGRATION_PROVIDERS=${JSON.stringify(INFRA_PROVIDER_IDS)};+const INTEGRATION_BROWSER=${JSON.stringify(MSO_ORIGIN + "/integrations")};+const INTEGRATION_CATALOG=${JSON.stringify(setupCatalog()).replace(/</g, "\\u003c")};let integrationAccess=null;function captureIntegrationAccess(raw){- const envelopes=[raw,raw&&raw._meta,raw&&raw.mcp_tool_result&&raw.mcp_tool_result._meta,raw&&raw.call_tool_result&&raw.call_tool_result._meta];+ const envelopes=[raw,raw&&raw._meta,raw&&raw.mcp_tool_result&&raw.mcp_tool_result._meta,raw&&raw.call_tool_result&&raw.call_tool_result._meta,raw&&raw.result&&raw.result._meta];for(const meta of envelopes){const access=meta&&meta.integrationSetup;if(access&&typeof access.token==="string"&&/^[A-Za-z0-9_-]{43}$/.test(access.token)&&access.endpoint===INTEGRATION_ENDPOINT){integrationAccess=access;return}}}async function openIntegrationReference(url){if(window.openai&&typeof window.openai.openExternal==="function")return window.openai.openExternal({href:url,redirectUrl:false});return rpcRequest("ui/open-link",{url});}+function integrationLink(url,label,feedback){+ const a=el("a","button",label);a.href=url;a.target="_blank";a.rel="noopener noreferrer";+ a.addEventListener("click",event=>{event.preventDefault();openIntegrationReference(url).catch(()=>{feedback.textContent="The host could not open the browser. Copy this public address: "+url})});return a;+}function renderIntegrations(){- if(current.setup){- viewCleanup=mountIntegrationForm(body,current.setup,integrationAccess?{...integrationAccess,openLink:openIntegrationReference}:null)||(()=>{});- return;- }- const root=el("div","integration");root.append(el("h2","","Integrations"),el("p","","Connect a service directly to MSO. Credentials stay outside the chat. Choose a service to open a ten-minute setup form."));+ if(current.setup&&integrationAccess){viewCleanup=mountIntegrationForm(body,current.setup,{...integrationAccess,openLink:openIntegrationReference})||(()=>{});return;}+ const root=el("div","integration"),feedback=el("p","setup-status");feedback.setAttribute("role","status");+ root.append(el("h2","","Integrations"),el("p","","Choose a provider below. Browser setup works independently of whether this chat has refreshed its tool catalog."));+ const external=el("div","setup-actions");external.append(integrationLink(INTEGRATION_BROWSER,"Open secure setup in browser",feedback));root.append(external,el("p","mono",INTEGRATION_BROWSER));+ if(current.setup&&!integrationAccess)feedback.textContent="The chat host did not deliver the private setup authorization. No key input is shown here. Use the secure browser page or refresh the MSO connection.";const list=el("div","grid");- for(const provider of INTEGRATION_PROVIDERS){- const card=el("div","card");card.append(el("strong","",provider));- for(const method of provider==="composio"?["project","organization"]:["direct"]){- const b=button(provider==="composio"?method+" API key":"Connect",async()=>{- b.disabled=true;- try{const result=await rpcCall("integration_setup_open",{provider,method});if(!acceptPageResult(result)||!current.setup)throw new Error("Setup requires write permission and refreshed MSO tools.")}- catch(error){showError(error)}- });card.append(b);+ for(const provider of INTEGRATION_CATALOG){+ const card=el("div","card");card.append(el("strong","",provider.title),el("p","",provider.description));+ for(const method of provider.methods){+ const details=el("details"),summary=el("summary","",method.title),steps=el("ol");details.append(summary);+ for(const step of method.guidance.steps)steps.append(el("li","",step));details.append(steps,integrationLink(method.guidance.url,"Provider dashboard",feedback),integrationLink(method.guidance.reference,"Official documentation",feedback));+ const browserUrl=INTEGRATION_BROWSER+"?provider="+encodeURIComponent(provider.id)+"&method="+encodeURIComponent(method.id);+ const b=button("Set up in chat",async()=>{b.disabled=true;feedback.textContent="Opening secure form…";try{const result=await rpcCall("integration_setup_open",{provider:provider.id,method:method.id});captureIntegrationAccess(result);captureIntegrationAccess(window.openai&&window.openai.toolResponseMetadata);if(result?.isError||!unbox(result)?.setup)throw new Error("setup tool unavailable");if(!acceptPageResult(result))throw new Error("missing setup data")}catch{feedback.textContent="This chat could not open the setup tool. Refresh the MSO connection to load its new tools, or use Open in browser. Your credentials have not changed.";b.disabled=false}},"primary");+ const actions=el("div","setup-actions");actions.append(b,integrationLink(browserUrl,"Open in browser",feedback));details.append(actions);card.append(details);}list.append(card);}- root.append(list);body.append(root);+ root.append(feedback,list);body.append(root);}`;diff --git a/lib/mcp/ui-page-lifecycle.test.ts b/lib/mcp/ui-page-lifecycle.test.tsindex d483d07f..2f8f2df0 100644--- a/lib/mcp/ui-page-lifecycle.test.ts+++ b/lib/mcp/ui-page-lifecycle.test.ts@@ -1,10 +1,11 @@import { describe, expect, it } from "vitest";-import { LEGACY_PAGE_V2_URI, MSO_PAGE_URI, listUiResources, readUiResource } from "./ui-resources";+import { LEGACY_PAGE_V2_URI, LEGACY_PAGE_V3_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_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(listUiResources()).toHaveLength(2);expect(listUiResources().some((resource) => resource.uri === LEGACY_PAGE_V2_URI)).toBe(false);});diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.tsindex 2749bb99..99b8c9a9 100644--- a/lib/mcp/ui-resources.test.ts+++ b/lib/mcp/ui-resources.test.ts@@ -149,7 +149,7 @@ describe("MCP Apps Block and Page contract", () => {frameDomains: ["https://game.rahmanef.com"],});expect(content._meta["openai/widgetCSP"]).toEqual({ redirect_domains: [MSO_ORIGIN, "https://game.rahmanef.com"] });- expect(MSO_PAGE_URI).toContain("page-v3.html");+ expect(MSO_PAGE_URI).toContain("page-v4.html");});it("returns only redacted structured workflow state and keeps status polling out of workflow memory", async () => {diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.tsindex 4f2ffeaf..3313e3ab 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_V3_URI = "ui://mso/page-v3.html";export const LEGACY_PAGE_V2_URI = "ui://mso/page-v2.html";export const LEGACY_PAGE_V1_URI = "ui://mso/page-v1.html";export const LEGACY_WORKFLOW_PROGRESS_URI = "ui://mso/workflow-progress-v3.html";@@ -27,6 +28,7 @@ const LEGACY_ALIASES = new Map<string, McpUiResource>([[LEGACY_BLOCK_V1_URI, MSO_BLOCK_RESOURCE],[LEGACY_PAGE_V1_URI, MSO_PAGE_RESOURCE],[LEGACY_PAGE_V2_URI, MSO_PAGE_RESOURCE],+ [LEGACY_PAGE_V3_URI, MSO_PAGE_RESOURCE],[LEGACY_WORKFLOW_PROGRESS_URI, MSO_BLOCK_RESOURCE],[LEGACY_SURFACE_URI, MSO_PAGE_RESOURCE],]);diff --git a/lib/mcp/ui-surface.ts b/lib/mcp/ui-surface.tsindex 6af26084..50c30e4c 100644--- a/lib/mcp/ui-surface.ts+++ b/lib/mcp/ui-surface.ts@@ -1,3 +1,4 @@+import { SETUP_HUB_STYLE } from "@/lib/infra/setup-hub";import { INTEGRATION_FORM_STYLE } from "@/lib/infra/setup-ui";import { widgetResourceMeta, MSO_ORIGIN } from "./ui-config";import { OPEN_IN_MSO_SCRIPT, openInMsoControls } from "./ui-navigation";@@ -5,11 +6,11 @@ import { surfaceFrameDomains } from "./surface-catalog";import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";import { MSO_SURFACE_STYLE } from "./ui-surface-style";-export const MSO_PAGE_URI = "ui://mso/page-v3.html";+export const MSO_PAGE_URI = "ui://mso/page-v4.html";const MIME = "text/html;profile=mcp-app";const html = String.raw`<main class="surface" aria-label="MSO Page">-<style>${MSO_SURFACE_STYLE}${INTEGRATION_FORM_STYLE}</style>+<style>${MSO_SURFACE_STYLE}${INTEGRATION_FORM_STYLE}${SETUP_HUB_STYLE}</style><header class="bar"><div class="brand" aria-hidden="true">M</div><div class="heading"><strong id="surface-title">MSO Page</strong><span id="surface-route">/</span></div>diff --git a/proxy.ts b/proxy.tsindex 0557269c..64ec1220 100644--- a/proxy.ts+++ b/proxy.ts@@ -304,7 +304,8 @@ export async function proxy(request: NextRequest) {const isA2A =pathname === "/a2a/v1" || pathname === "/.well-known/agent-card.json";const isMachineProtocol = isMcp || isA2A;- const isApi = pathname.startsWith("/api/") || isMachineProtocol;+ // The public integration document owns its nonce/CSP; its mutations use the guarded APIs.+ const isApi = pathname.startsWith("/api/") || isMachineProtocol || pathname === "/integrations";// The historical same-origin bridge is permanently closed. noVNC is executable// third-party code and is served only from its reserved split-origin host above.if (pathname.startsWith("/camoufox-vnc/")) return notFound();