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): harden native UI and plugin bindings
Rahman9bdd1685d5fb
diff --git a/claude-skills/mso-mcp-feature-engineering/SKILL.md b/claude-skills/mso-mcp-feature-engineering/SKILL.mdindex 21c0a55a..16d006cb 100644--- a/claude-skills/mso-mcp-feature-engineering/SKILL.md+++ b/claude-skills/mso-mcp-feature-engineering/SKILL.md@@ -69,6 +69,22 @@ For a trusted workflow skill:- validate with `bun run skill:check` and confirm `skills_search` routes intended prompts;- remember that trust is derived from root/provenance/ownership, never frontmatter.+## MCP App/UI contract++When a feature includes a ChatGPT/MCP App surface:++- keep ordinary data tools headless and bind only explicit render tools to `ui.resourceUri`;+- serve `text/html;profile=mcp-app` and prefer the host-neutral `ui/*` bridge:+ `ui/initialize` → initialized → tool input/result notifications → `tools/call` or `ui/message`;+- keep `window.openai` APIs only as documented compatibility fallbacks, never the sole portable path;+- bump a versioned `ui://` resource URI when host-visible behavior changes and keep old URIs read-only;+- prove the real postMessage lifecycle in browser E2E instead of only checking metadata or HTML strings;+- keep `.app.json` package bindings separate from UI resources and authorization. Persist only canonical+ `asdk_app_`, `connector_`, or `templated_apps_` IDs; never persist a `plugin_...` URL identifier.++For deterministic repeated validation/search steps, prefer a bounded script referenced by the skill,+then verify the script result before returning. Do not turn script convenience into a new authority path.+## Project function contractKeep project function names as data behind the stable `project_capabilities` anddiff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex a9937601..c99f218d 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -161,8 +161,8 @@ through the app catch-all.The web catch-all remains the authenticated cockpit route. ChatGPT does **not** frame that cockpit.MSO exposes exactly three user-visible MCP App classes instead:-- `render_mso_list` binds `ui://mso/list-v1.html` for compact searchable collections after ordinary data tools have returned model-checkable structured results. Item/global actions return follow-up messages and do not execute mutations in the widget.-- `render_mso_block` binds `ui://mso/block-v3.html` for compact validation, action buttons, and+- `render_mso_list` binds `ui://mso/list-v2.html` for compact searchable collections after ordinary data tools have returned model-checkable structured results. Item/global actions return follow-up messages and do not execute mutations in the widget.+- `render_mso_block` binds `ui://mso/block-v4.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-v15.html` resource for native `/`, `/monitor`, `/project`, `/diff`,diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 90c77831..67767840 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `mcp` harden native UI and plugin bindings- `ai` separate provider connect from selection- `security` bind Convex snapshot path identity- `browser` derive isolated Camoufox viewer origindiff --git a/docs/CHATGPT-PLUGIN.md b/docs/CHATGPT-PLUGIN.mdindex fd6be1cb..208e4ff3 100644--- a/docs/CHATGPT-PLUGIN.md+++ b/docs/CHATGPT-PLUGIN.md@@ -78,7 +78,7 @@ For the complete non-ChatGPT MSO catalog, scopes, limits, A2A, providers, Tool F## OpenAI/Codex plugin package-The repository root also carries `.codex-plugin/plugin.json` as an OpenAI/Codex compatibility package for the reviewed skills plus an optional registered-app mapping. It points directly at `./claude-skills/`, so the same reviewed skill bundles are reusable without maintaining a second copy. The package deliberately does **not** declare `mcpServers`: the live web-capable MSO MCP connection remains the separately authorized custom app at `/mcp`, preserving its OAuth scopes, server-side credentials, dynamic project MCP seams and browser/mobile availability instead of coupling those capabilities to a local plugin executor. `.app.json` is an intentionally empty OpenAI scaffold (`apps: {}`) until an exact registered app ID is available; this matches the supported plugin-creator scaffold and does not grant MCP access by itself. When an existing OpenAI registration is intentionally packaged, link only its exact registered ID—never a placeholder—and keep OAuth authorization on the live MSO app. Use `bun run plugin:link-app -- plugin_asdk_app_...` (legacy `asdk_app_...` is also accepted); `bun run plugin:link-app -- --clear` restores the empty scaffold.+The repository root also carries `.codex-plugin/plugin.json` as an OpenAI/Codex compatibility package for the reviewed skills plus an optional registered-app mapping. It points directly at `./claude-skills/`, so the same reviewed skill bundles are reusable without maintaining a second copy. The package deliberately does **not** declare `mcpServers`: the live web-capable MSO MCP connection remains the separately authorized custom app at `/mcp`, preserving its OAuth scopes, server-side credentials, dynamic project MCP seams and browser/mobile availability instead of coupling those capabilities to a local plugin executor. `.app.json` is an intentionally empty OpenAI scaffold (`apps: {}`) until an exact registered app ID is available; this matches the supported plugin-creator scaffold and does not grant MCP access by itself. When an existing OpenAI registration is intentionally packaged, link only its exact registered ID—never a placeholder—and keep OAuth authorization on the live MSO app. Use `bun run plugin:link-app -- asdk_app_...`, `connector_...`, or `templated_apps_...`; if a copied plugin URL exposes `plugin_asdk_app_...`, the helper accepts it only as input and writes the canonical `asdk_app_...` ID. `bun run plugin:link-app -- --clear` restores the empty scaffold.The OpenAI-facing repository shape is therefore:diff --git a/docs/PLUGIN-REFERENCE-MATRIX.md b/docs/PLUGIN-REFERENCE-MATRIX.mdindex f67c4560..0c11ba6d 100644--- a/docs/PLUGIN-REFERENCE-MATRIX.md+++ b/docs/PLUGIN-REFERENCE-MATRIX.md@@ -25,7 +25,7 @@ The matrix should be updated after each reference audit. `pending` means that pl| Suggestion is non-blocking | Not established | Strong: continue independent work while user handles connection | pending | pending | pending | pending | pending | pending | pending | pending | pending | pending | Workflows can continue around missing integrations, but no universal suggestion state | Pending extension state | `WAIT` || Installed/pending duplicate prevention | State-aware mutations | Strong: do not suggest installed or already-pending plugins | pending | pending | pending | pending | pending | pending | pending | pending | pending | pending | Skill Market tracks installed/modified/conflict; project MCP inspect reports exact installed bindings | Generic extension state model | `WAIT` || Dependency metadata resolved separately from installation | Domain dependencies exist | Strong: dependency inspection reports canonical dependencies and user-aware status without installing | Strong: `.app.json` names an exact connector and explicitly declares optional dependency state | pending | pending | pending | pending | pending | pending | pending | pending | pending | `.app.json` maps OpenAI package→registered app; project plugin manifest declares skills/MCP, but there is no generic dependency graph | Dependency contract | `WAIT` |-| OpenAI app binding accepts registered apps/connectors with required-or-optional state | No decisive evidence | Required registered-app binding | Strong: exact `connector_*` binding with `required:false`; public plugin guidance also recognizes connector/template bindings | pending | pending | pending | pending | pending | pending | pending | pending | pending | Checker previously accepted only `asdk_app_*` + `required:true` | App-binding compatibility validator | `NEW_GENERALIZABLE` — implemented without changing authorization |+| OpenAI app binding accepts registered apps/connectors with required-or-optional state | Required `asdk_app_*`; no package-level optional example in Shopify | Required registered-app binding | Strong: exact `connector_*` binding with `required:false`; public guidance also recognizes connector/template bindings | pending | pending | pending | pending | Strong: optional multi-app bindings use `optional:true`, categories and snake_case aliases | pending | pending | pending | pending | Canonical `asdk_app_`/`connector_`/`templated_apps_` IDs; optional/required booleans; snake/kebab aliases; URL-style `plugin_asdk_app_*` normalized before persistence | App-binding compatibility validator | `NEW_GENERALIZABLE` — implemented without changing authorization || Optional dependency may degrade transport but never identity/credential authority | No decisive evidence | Missing plugin may leave independent work unblocked, but no transport fallback evidence | Strong: connector-first with targeted CLI fallback and optional app binding | pending | pending | pending | pending | pending | pending | pending | pending | pending | Bounded tools/CLI/shell and multiple Integration sources already exist; source switching is deliberately explicit | Authority-preserving fallback policy | `ALREADY_BUT_IMPROVE` — documented now || Global permission default + per-extension override/inheritance | Not established | Strong: global permission mode plus app-specific override with `inherit` | pending | pending | pending | pending | pending | pending | pending | pending | pending | pending | OAuth `read < write < exec`, live device roles and per-operation confirmation are stronger security boundaries but semantically different | Permission policy overlay | `WAIT` — do not conflate platform UX permissions with MSO authorization || Explicit uninstall/remove only | Mutations are explicit | Strong: uninstall requires explicit user removal intent and exact targets | pending | pending | pending | pending | pending | pending | pending | pending | pending | pending | Project MCP delete is exact-project + revision guarded; Skill Market refuses unmanaged removal; App UI confirms uninstall; managed runtime uninstall is job-based | Shared removal UX vocabulary | `ALREADY_STRONGER` at enforcement level |@@ -112,7 +112,7 @@ The manifest describes a hybrid workflow: inspect repositories, triage PRs/issue### Comparison with MSO-MSO already has the stronger execution boundary: bounded native/project/provider capabilities first, scoped shell only when required, explicit named credential identities, no silent source fallback, revision/CAS checks and evidence verification. The GitHub reference exposes two compatibility refinements. First, OpenAI app bindings may be connector identities rather than only registered `asdk_app_*` ids. Second, `required` is a boolean dependency declaration, not a constant `true`. MSO's plugin checker was stricter than the observed valid format, so it now accepts registered-app, connector and documented template binding ids with either required or optional state. This changes validation compatibility only; package metadata still grants no credential, MCP, host, or provider authority.+MSO already has the stronger execution boundary: bounded native/project/provider capabilities first, scoped shell only when required, explicit named credential identities, no silent source fallback, revision/CAS checks and evidence verification. The GitHub reference exposes two compatibility refinements. First, OpenAI app bindings may be connector identities rather than only registered `asdk_app_*` ids. Second, `required` is a boolean dependency declaration, not a constant `true`. MSO's plugin checker was stricter than the observed valid format, so it now accepts canonical registered-app, connector and documented template binding IDs, both `required` and `optional` booleans when present, and the snake/kebab aliases used by saved reference packages. A `plugin_asdk_app_*` URL identifier is normalized by the linker and is never persisted into `.app.json`. This changes validation compatibility only; package metadata still grants no credential, MCP, host, or provider authority.For optional capabilities, MSO now states the fallback rule explicitly: transport may degrade only through an already-authorized, explicitly selected identity while preserving scope. A missing provider-owned connector must never cause a silent switch to another user, connection, local token, or copied OAuth credential.diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 37b53941..eb591f26 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,23 @@+## 2026-09-19 — Make compact MCP Apps standards-first and align plugin bindings with references++A live ChatGPT test showed MSO render tools returning valid structured data without a visible+component in the current nested connector/orchestration path. Server-side audit confirmed Page+already implements the MCP Apps `ui/*` lifecycle, while compact List/Block still depended on+ChatGPT-specific follow-up APIs for part of their interaction path. List v2 and Block v4 now share+a standards-first bridge: `ui/initialize`, initialized/tool-result notifications, `ui/message`,+host-context updates and teardown, with `window.openai` retained only as a capability-detected+compatibility fallback. Old List v1 and Block v3 remain non-advertised read aliases so cached+clients fail safely. Browser E2E now exercises the real compact postMessage lifecycle.++The plugin/package audit also compared MSO against the saved Shopify, GitHub, Data Analytics,+OpenAI Templates, Plugin Management, Google, Figma, Notion, Convex and Sites references. The+`.app.json` validator now matches the documented canonical ID families, accepts optional/required+booleans and snake/kebab aliases used by the references, and rejects persisted `plugin_...` URL+identifiers. The linker normalizes a copied `plugin_asdk_app_...` identifier to canonical+`asdk_app_...` before writing. All 18 saved reference manifests validate, and all 14 official MSO+skills still pass their contract + `agents/openai.yaml` checks. No app ID is invented for MSO:+the package mapping remains empty until an exact registered identity is supplied.+## 2026-09-19 — Derive an isolated Camoufox sibling instead of assuming the managed-app namespaceCamoufox viewer authentication no longer needs the cockpit Domain cookie, so tying its hostnamediff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.mdindex 648e0b9d..fbe76fee 100644--- a/docs/generated/MCP-CATALOG.md+++ b/docs/generated/MCP-CATALOG.md@@ -4,13 +4,13 @@## Full MSO catalog-<!-- mcp-toolset: server=1.15.1 version=2026.09.19.1 tools=111 read=54 write=35 exec=22 -->+<!-- mcp-toolset: server=1.15.1 version=2026.09.19.2 tools=111 read=54 write=35 exec=22 -->| Fact | Current source value ||---|---:|| MCP server | `1.15.1` |-| Toolset | `2026.09.19.1` |-| Toolset changed at | `2026-09-19T15:00:00+07:00` |+| Toolset | `2026.09.19.2` |+| Toolset changed at | `2026-09-19T16:47:44+07:00` || Transport tools | **113** || Model/operator tools | **111** || Read | **54** |@@ -145,7 +145,7 @@## ChatGPT model profile-<!-- mcp-chatgpt-profile: server=1.15.1 version=2026.09.19.1 tools=111 read=54 write=35 exec=22 app-only=2 total=113 -->+<!-- mcp-chatgpt-profile: server=1.15.1 version=2026.09.19.2 tools=111 read=54 write=35 exec=22 app-only=2 total=113 -->The ChatGPT profile automatically projects the complete MSO-owned generic model/operator catalog. OAuth scope is still enforced independently; app-only compatibility bridges stay app-only, and project-owned MCP tool names remain dynamic data behind the generic project bridge.diff --git a/docs/integrations/CHATGPT-UI.md b/docs/integrations/CHATGPT-UI.mdindex 4a05869d..4390f42f 100644--- a/docs/integrations/CHATGPT-UI.md+++ b/docs/integrations/CHATGPT-UI.md@@ -6,8 +6,8 @@ chooses List, Block or Page as a separate render step.| Surface | Entry tool | Resource | Purpose || --- | --- | --- | --- |-| List | `render_mso_list` | `ui://mso/list-v1.html` | Searchable compact collections and item actions |-| Block | `render_mso_block` | `ui://mso/block-v3.html` | Validation, actions, bounded CRUD input/output |+| List | `render_mso_list` | `ui://mso/list-v2.html` | Searchable compact collections and item actions |+| Block | `render_mso_block` | `ui://mso/block-v4.html` | Validation, actions, bounded CRUD input/output || Page | `render_mso_page`, `integration_setup_open` | `ui://mso/page-v15.html` | Native workspaces, session assets and reviewed project previews |## Layout and identity@@ -78,15 +78,13 @@ Page initializes MCP Apps protocol `2026-01-26`, then sendsnotifications and legacy wrapped `window.openai.toolOutput` use the same route validator.Unchanged outputs do not remount views; teardown clears active forms and observers.-List and Page tools advertise standard `ui.resourceUri` only. Block also retains its-`openai/outputTemplate` compatibility binding. Every ChatGPT tool has an output schema;+List, Block and Page use the standards-first MCP Apps bridge (`ui/initialize`, tool-result notifications and `ui/message`/`tools/call` where applicable). Their render tools advertise standard `ui.resourceUri`; Block additionally retains its existing `openai/outputTemplate` compatibility binding for older ChatGPT hosts. Every ChatGPT tool has an output schema;exact tools, counts and scopes are generated in [the catalog](../generated/MCP-CATALOG.md).Resource CSP is explicit: Block allows no nested frames; Page includes only exact reviewed iframe origins and permits its MSO origin for private setup requests. OpenAI requires stricter review for `frameDomains`; this is an official review boundary, not a blanket iframe ban. `OS_MCP_UI_ORIGIN` controls the widget origin, otherwisethe configured public origin derives it. Legacy redirect metadata supports Open in MSO.-Only the three current resources are listed. Older Block/Page URIs remain read aliases for-current bytes, including Block v2 and Page v14. `workflow_status` and `render_mso_surface`+Only the three current resources are listed. Older List/Block/Page URIs remain read aliases for current bytes, including List v1, Block v3/v2 and Page v14. `workflow_status` and `render_mso_surface`remain app-only compatibility tools. `workflow_start` has no UI binding.## Verification and deploymentdiff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.tsindex 3ef7598a..7ca13e1a 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.15.1";-export const MCP_TOOLSET_VERSION = "2026.09.19.1";-export const MCP_TOOLSET_CHANGED_AT = "2026-09-19T15:00:00+07:00";+export const MCP_TOOLSET_VERSION = "2026.09.19.2";+export const MCP_TOOLSET_CHANGED_AT = "2026-09-19T16:47:44+07:00";export type McpToolsetInfo = {serverVersion: string;diff --git a/lib/mcp/ui-block.ts b/lib/mcp/ui-block.tsindex d30da9da..652a249e 100644--- a/lib/mcp/ui-block.ts+++ b/lib/mcp/ui-block.ts@@ -1,8 +1,9 @@import { MSO_LOGO_SVG } from "@/lib/presentation/logo";import { widgetResourceMeta } from "./ui-config";+import { compactUiBridgeScript } from "./ui-compact-bridge";import { MSO_WIDGET_THEME_SCRIPT, MSO_WIDGET_TOKENS } from "./ui-widget-tokens";-export const MSO_BLOCK_URI = "ui://mso/block-v3.html";+export const MSO_BLOCK_URI = "ui://mso/block-v4.html";const MIME = "text/html;profile=mcp-app";const html = String.raw`<meta charset="utf-8"><main class="mso-block" aria-live="polite">@@ -39,12 +40,12 @@ function persist(){try{if(window.openai&&typeof window.openai.setWidgetState==="function renderChecks(rows){clear(checksEl);checksSection.hidden=!rows.length;for(const row of rows){if(!row||typeof row!=="object")continue;const state=["pass","warn","fail","info"].includes(row.state)?row.state:"info";const item=el("div","check");item.append(el("span","dot "+state),el("strong","",text(row.label,"Check")),el("span","detail",text(row.detail,state)));checksEl.append(item)}}function renderFields(rows){clear(fieldsEl);fieldsSection.hidden=!rows.length;rows.forEach((row,index)=>{if(!row||typeof row!=="object")return;const id=text(row.id,"field-"+index),controlId="mso-field-"+index,inputType=["text","number","email","url","textarea","boolean"].includes(row.input)?row.input:"text",editable=row.editable!==false;const wrap=el("div","field"+(inputType==="textarea"?" full":""));const label=el("label","",text(row.label,id));label.id=controlId+"-label";if(row.required===true)label.append(el("span","required"," *"));wrap.append(label);if(!editable){const value=el("div","readonly",String(scalar(row.value)));value.id=controlId;value.setAttribute("aria-labelledby",label.id);wrap.append(value);fieldsEl.append(wrap);return}let input;if(inputType==="textarea"){input=document.createElement("textarea");input.value=String(scalar(row.value)).slice(0,2000);input.maxLength=2000}else{input=document.createElement("input");input.type=inputType==="boolean"?"checkbox":inputType;if(inputType==="boolean")input.checked=Boolean(row.value);else input.value=String(scalar(row.value)).slice(0,1000);if(["text","email","url"].includes(inputType))input.maxLength=1000}input.id=controlId;label.htmlFor=controlId;input.name=id;input.dataset.fieldId=id;input.required=row.required===true;if(text(row.placeholder,""))input.placeholder=text(row.placeholder,"");input.addEventListener("input",persist);if(inputType==="boolean"){const booleanWrap=el("div","boolean");booleanWrap.append(input,el("span","",text(row.placeholder,"Enabled")));wrap.append(booleanWrap)}else wrap.append(input);fieldsEl.append(wrap)})}function renderOutputs(rows){clear(outputsEl);outputsSection.hidden=!rows.length;for(const row of rows){if(!row||typeof row!=="object")continue;const item=el("div","output");item.append(el("span","dot info"),el("strong","",text(row.label,"Result")),el("span","value",String(scalar(row.value))));outputsEl.append(item)}}-async function submit(action){if(!action||typeof action!=="object")return;if(text(action.confirm,"")&&confirmId!==action.id){confirmId=text(action.id,"");feedback.textContent=text(action.confirm,"Press the action again to confirm.");window.clearTimeout(confirmTimer);confirmTimer=window.setTimeout(()=>{confirmId="";feedback.textContent=""},6000);return}confirmId="";window.clearTimeout(confirmTimer);if(!form.reportValidity())return;const payload={actionId:text(action.id,"action"),blockKind:current.kind,values:fieldValues()};const prompt=text(action.prompt,"Continue with the selected MSO action.")+"\n\nMSO block submission:\n"+JSON.stringify(payload,null,2).slice(0,12000);feedback.textContent="Sending to chat…";try{if(!window.openai||typeof window.openai.sendFollowUpMessage!=="function")throw new Error("unsupported");await window.openai.sendFollowUpMessage({prompt});feedback.textContent="Sent to chat."}catch(_){feedback.textContent="Interactive handoff is unavailable. Continue in the chat."}}+async function submit(action){if(!action||typeof action!=="object")return;if(text(action.confirm,"")&&confirmId!==action.id){confirmId=text(action.id,"");feedback.textContent=text(action.confirm,"Press the action again to confirm.");window.clearTimeout(confirmTimer);confirmTimer=window.setTimeout(()=>{confirmId="";feedback.textContent=""},6000);return}confirmId="";window.clearTimeout(confirmTimer);if(!form.reportValidity())return;const payload={actionId:text(action.id,"action"),blockKind:current.kind,values:fieldValues()};const prompt=text(action.prompt,"Continue with the selected MSO action.")+"\n\nMSO block submission:\n"+JSON.stringify(payload,null,2).slice(0,12000);feedback.textContent="Sending to chat…";try{await msoUiSendMessage(prompt);feedback.textContent="Sent to chat."}catch(_){feedback.textContent="Interactive handoff is unavailable. Continue in the chat."}}function renderActions(rows){clear(actionsEl);actionsSection.hidden=!rows.length;for(const row of rows){if(!row||typeof row!=="object")continue;const button=el("button",["primary","secondary","danger"].includes(row.style)?row.style:"secondary",text(row.label,"Continue"));button.type="button";button.addEventListener("click",()=>submit(row));actionsEl.append(button)}}function render(raw){const next=normalize(raw);if(!next)return;current=next;kindEl.textContent=next.kind;titleEl.textContent=next.title;descriptionEl.textContent=next.description;descriptionEl.hidden=!next.description;statusEl.className="status "+next.status;statusEl.textContent=next.status==="neutral"?"Ready":next.status;renderChecks(next.checks);renderFields(next.fields);renderOutputs(next.outputs);renderActions(next.actions);persist()}function readHostOutput(){const output=window.openai&&window.openai.toolOutput;if(output)render(output)}-window.addEventListener("message",event=>{if(event.source!==window.parent)return;const message=event.data;if(message&&message.method==="ui/notifications/tool-result"&&message.params&&message.params.structuredContent)render(message.params.structuredContent)},{passive:true});-window.addEventListener("openai:set_globals",()=>{applyHostTheme();readHostOutput()},{passive:true});applyHostTheme();readHostOutput();+${compactUiBridgeScript("MSO Block")}+window.addEventListener("openai:set_globals",()=>{applyHostTheme();readHostOutput()},{passive:true});applyHostTheme();readHostOutput();msoUiInitialize();})();</script></main>`;diff --git a/lib/mcp/ui-compact-bridge.ts b/lib/mcp/ui-compact-bridge.tsnew file mode 100644index 00000000..b854543c--- /dev/null+++ b/lib/mcp/ui-compact-bridge.ts@@ -0,0 +1,60 @@+/**+ * Standards-first MCP Apps bridge for compact MSO resources.+ *+ * The host-neutral ui/* postMessage protocol is authoritative. window.openai is+ * retained only as a compatibility fallback for older ChatGPT hosts.+ *+ * The embedded script expects render(raw) and applyHostTheme() in local scope.+ */+export function compactUiBridgeScript(appName: string): string {+ const safeName = JSON.stringify(appName);+ return String.raw`+let msoUiConnected=false,msoUiNextId=1;+const msoUiPending=new Map();+function msoUiRequest(method,params){+ const id=msoUiNextId++;+ return new Promise((resolve,reject)=>{+ const timer=setTimeout(()=>{msoUiPending.delete(id);reject(new Error("Host request timed out"))},10000);+ msoUiPending.set(id,{resolve,reject,timer});+ window.parent.postMessage({jsonrpc:"2.0",id,method,params},"*");+ });+}+async function msoUiSendMessage(prompt){+ if(msoUiConnected){+ return msoUiRequest("ui/message",{role:"user",content:[{type:"text",text:prompt}]});+ }+ if(window.openai&&typeof window.openai.sendFollowUpMessage==="function"){+ return window.openai.sendFollowUpMessage({prompt});+ }+ throw new Error("Host messaging unavailable");+}+function msoUiOnMessage(event){+ if(event.source!==window.parent)return;+ const message=event.data;+ if(!message||message.jsonrpc!=="2.0")return;+ if(message.id!==undefined&&msoUiPending.has(message.id)){+ const pending=msoUiPending.get(message.id);msoUiPending.delete(message.id);clearTimeout(pending.timer);+ message.error?pending.reject(new Error(message.error.message||"Host request failed")):pending.resolve(message.result);+ return;+ }+ if(message.method==="ui/notifications/tool-result"&&message.params?.structuredContent)render(message.params.structuredContent);+ if(message.method==="ui/notifications/host-context-changed")applyHostTheme();+ if(message.method==="ui/resource-teardown"&&message.id!==undefined){+ window.parent.postMessage({jsonrpc:"2.0",id:message.id,result:{}},"*");+ }+}+async function msoUiInitialize(){+ try{+ const result=await msoUiRequest("ui/initialize",{+ protocolVersion:"2026-01-26",+ appInfo:{name:${safeName},version:"1.0.0"},+ appCapabilities:{}+ });+ if(!result||typeof result.protocolVersion!=="string")throw new Error("Invalid host initialization response");+ msoUiConnected=true;+ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}},"*");+ }catch(_){}+}+window.addEventListener("message",msoUiOnMessage,{passive:true});+`;+}diff --git a/lib/mcp/ui-list.ts b/lib/mcp/ui-list.tsindex 2c2fe885..5d98257d 100644--- a/lib/mcp/ui-list.ts+++ b/lib/mcp/ui-list.ts@@ -1,8 +1,9 @@import { MSO_LOGO_SVG } from "@/lib/presentation/logo";import { widgetResourceMeta } from "./ui-config";+import { compactUiBridgeScript } from "./ui-compact-bridge";import { MSO_WIDGET_THEME_SCRIPT, MSO_WIDGET_TOKENS } from "./ui-widget-tokens";-export const MSO_LIST_URI = "ui://mso/list-v1.html";+export const MSO_LIST_URI = "ui://mso/list-v2.html";const MIME = "text/html;profile=mcp-app";const html = String.raw`<meta charset="utf-8"><main class="mso-list" aria-live="polite">@@ -22,12 +23,14 @@ const $=id=>document.getElementById(id);const title=$("title"),description=$("deconst text=(v,f="")=>typeof v==="string"&&v.trim()?v.trim():f;const rows=(v,max)=>Array.isArray(v)?v.filter(x=>x&&typeof x==="object"&&!Array.isArray(x)).slice(0,max):[];const icons={project:"PRJ",file:"DOC",folder:"DIR",workflow:"WF",session:"SES",app:"APP",integration:"INT",agent:"AGT",server:"SRV",code:"CODE",item:"•"};function normalize(raw){if(!raw||typeof raw!=="object")return null;return{title:text(raw.title,"MSO list"),description:text(raw.description),layout:raw.layout==="grid"?"grid":"list",searchable:raw.searchable===true,emptyMessage:text(raw.emptyMessage,"No items."),items:rows(raw.items,40).map((row,index)=>({id:text(row.id,"item-"+(index+1)),title:text(row.title,"Item "+(index+1)),subtitle:text(row.subtitle),badge:text(row.badge),status:["neutral","info","success","warning","error"].includes(row.status)?row.status:"neutral",icon:icons[row.icon]?row.icon:"item",meta:rows(row.meta,4).map(m=>({label:text(m.label),value:text(m.value)})),actions:rows(row.actions,2).map((a,i)=>({id:text(a.id,"action-"+(i+1)),label:text(a.label,"Open"),style:a.style==="primary"?"primary":"secondary",prompt:text(a.prompt)})).filter(a=>a.prompt)})),actions:rows(raw.actions,3).map((a,i)=>({id:text(a.id,"global-"+(i+1)),label:text(a.label,"Continue"),style:a.style==="primary"?"primary":"secondary",prompt:text(a.prompt)})).filter(a=>a.prompt)}}function clear(node){while(node.firstChild)node.removeChild(node.firstChild)}function el(tag,cls,val){const n=document.createElement(tag);if(cls)n.className=cls;if(val!==undefined)n.textContent=String(val);return n}-async function follow(action,item){if(!action?.prompt)return;const context=item?"\n\nMSO list selection:\n"+JSON.stringify({id:item.id,title:item.title}).slice(0,1000):"";feedback.textContent="Sending to chat…";try{if(!window.openai||typeof window.openai.sendFollowUpMessage!=="function")throw new Error("unsupported");await window.openai.sendFollowUpMessage({prompt:action.prompt+context});feedback.textContent="Sent to chat."}catch(_){feedback.textContent="Continue in the chat."}}+async function follow(action,item){if(!action?.prompt)return;const context=item?"\n\nMSO list selection:\n"+JSON.stringify({id:item.id,title:item.title}).slice(0,1000):"";feedback.textContent="Sending to chat…";try{await msoUiSendMessage(action.prompt+context);feedback.textContent="Sent to chat."}catch(_){feedback.textContent="Continue in the chat."}}function renderAction(action,item){const b=el("button",action.style||"secondary",action.label);b.type="button";b.addEventListener("click",()=>follow(action,item));return b}function renderItems(query=""){clear(items);const q=query.trim().toLowerCase();const visible=current.items.filter(row=>!q||[row.title,row.subtitle,row.badge,...row.meta.flatMap(m=>[m.label,m.value])].join(" ").toLowerCase().includes(q));items.className="items"+(current.layout==="grid"?" grid":"");count.textContent=String(visible.length)+"/"+String(current.items.length);empty.hidden=visible.length>0;empty.textContent=q?"No matching items.":current.emptyMessage;for(const row of visible){const item=el("article","item");item.dataset.itemId=row.id;item.append(el("div","icon",icons[row.icon]||"•"));const main=el("div","main"),tr=el("div","title-row");tr.append(el("div","title",row.title));if(row.badge)tr.append(el("span","badge "+row.status,row.badge));main.append(tr);if(row.subtitle)main.append(el("div","subtitle",row.subtitle));if(row.meta.length){const meta=el("div","meta");for(const m of row.meta)meta.append(el("span","",m.label?(m.label+": "+m.value):m.value));main.append(meta)}item.append(main);if(row.actions.length){const actions=el("div","actions");for(const a of row.actions)actions.append(renderAction(a,row));item.append(actions)}items.append(item)}}function persist(){try{if(window.openai&&typeof window.openai.setWidgetState==="function")window.openai.setWidgetState({modelContent:"MSO list: "+(current?.title||"collection"),privateContent:{query:filter.value},imageIds:[]})}catch(_){}}function render(raw){const next=normalize(raw);if(!next)return;current=next;title.textContent=next.title;description.textContent=next.description;description.hidden=!next.description;filterWrap.hidden=!next.searchable;filter.value="";renderItems();clear(footerActions);footer.hidden=!next.actions.length;for(const a of next.actions)footerActions.append(renderAction(a));persist()}-filter.addEventListener("input",()=>{renderItems(filter.value);persist()});function readHostOutput(){const output=window.openai&&window.openai.toolOutput;if(output)render(output)}window.addEventListener("message",event=>{if(event.source!==window.parent)return;const message=event.data;if(message&&message.method==="ui/notifications/tool-result"&&message.params&&message.params.structuredContent)render(message.params.structuredContent)},{passive:true});window.addEventListener("openai:set_globals",()=>{applyHostTheme();readHostOutput()},{passive:true});applyHostTheme();readHostOutput();+filter.addEventListener("input",()=>{renderItems(filter.value);persist()});function readHostOutput(){const output=window.openai&&window.openai.toolOutput;if(output)render(output)}+${compactUiBridgeScript("MSO List")}+window.addEventListener("openai:set_globals",()=>{applyHostTheme();readHostOutput()},{passive:true});applyHostTheme();readHostOutput();msoUiInitialize();})();</script></main>`;export const MSO_LIST_RESOURCE = {diff --git a/lib/mcp/ui-resource-state.test.ts b/lib/mcp/ui-resource-state.test.tsindex 2cfc9bd5..ddd0d8ce 100644--- a/lib/mcp/ui-resource-state.test.ts+++ b/lib/mcp/ui-resource-state.test.ts@@ -9,7 +9,10 @@ afterAll(() => vi.unstubAllEnvs());const { dispatch } = await import("./dispatch");const {MSO_BLOCK_URI,+ MSO_LIST_URI,MSO_PAGE_URI,+ LEGACY_LIST_V1_URI,+ LEGACY_BLOCK_V3_URI,LEGACY_BLOCK_V1_URI,LEGACY_PAGE_V1_URI,LEGACY_WORKFLOW_PROGRESS_URI,@@ -70,12 +73,17 @@ describe("MCP Apps List, Block and Page contract", () => {});it("keeps latest cached workflow/surface URIs as non-advertised Block/Page aliases", async () => {+ const canonicalList = await readUiResource(MSO_LIST_URI);const canonicalBlock = await readUiResource(MSO_BLOCK_URI);const canonicalPage = await readUiResource(MSO_PAGE_URI);+ const listV1 = await readUiResource(LEGACY_LIST_V1_URI);+ const blockV3 = await readUiResource(LEGACY_BLOCK_V3_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(listV1).toMatchObject({ uri: LEGACY_LIST_V1_URI, text: canonicalList?.text });+ expect(blockV3).toMatchObject({ uri: LEGACY_BLOCK_V3_URI, text: canonicalBlock?.text });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 });@@ -83,6 +91,8 @@ describe("MCP Apps List, Block and Page contract", () => {const listed = await dispatch({ id: 31, method: "resources/list" }, "read", "mcp:ui-alias");const serialized = JSON.stringify(listed.result);+ expect(serialized).not.toContain(LEGACY_LIST_V1_URI);+ expect(serialized).not.toContain(LEGACY_BLOCK_V3_URI);expect(serialized).not.toContain(LEGACY_BLOCK_V1_URI);expect(serialized).not.toContain(LEGACY_PAGE_V1_URI);expect(serialized).not.toContain(LEGACY_WORKFLOW_PROGRESS_URI);diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.tsindex d8582306..72120f2f 100644--- a/lib/mcp/ui-resources.test.ts+++ b/lib/mcp/ui-resources.test.ts@@ -135,6 +135,9 @@ describe("MCP Apps List, Block and Page contract", () => {}).contents[0];expect(content.uri).toBe(MSO_BLOCK_URI);expect(content.mimeType).toBe(MCP_APP_MIME_TYPE);+ expect(content.text).toContain("ui/initialize");+ expect(content.text).toContain("ui/notifications/initialized");+ expect(content.text).toContain("ui/message");expect(content.text).toContain("sendFollowUpMessage");expect(content.text).toContain("reportValidity");expect(content.text).toContain("label.id=controlId+\"-label\"");@@ -157,7 +160,7 @@ describe("MCP Apps List, Block and Page contract", () => {});expect(content._meta.ui.csp.frameDomains).toBeUndefined();expect(content._meta["openai/widgetCSP"]).toEqual({ redirect_domains: [MSO_ORIGIN] });- expect(MSO_BLOCK_URI).toContain("block-v3.html");+ expect(MSO_BLOCK_URI).toContain("block-v4.html");});it("serves the full Page without external frame domains by default", async () => {diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.tsindex a152926b..cb360488 100644--- a/lib/mcp/ui-resources.ts+++ b/lib/mcp/ui-resources.ts@@ -8,6 +8,8 @@ export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";// Read-only aliases keep already-cached ChatGPT action descriptors functional// across the UI-contract migration. They are intentionally not advertised by// resources/list advertises the three canonical presentation levels: List, Block and Page.+export const LEGACY_LIST_V1_URI = "ui://mso/list-v1.html";+export const LEGACY_BLOCK_V3_URI = "ui://mso/block-v3.html";export const LEGACY_BLOCK_V2_URI = "ui://mso/block-v2.html";export const LEGACY_PAGE_V14_URI = "ui://mso/page-v14.html";export const LEGACY_PAGE_V13_URI = "ui://mso/page-v13.html";@@ -61,9 +63,10 @@ export async function listUiResources(): Promise<Array<{ uri: string; name: striexport async function readUiResource(uri: string): Promise<McpUiResource | undefined> {if (uri === MSO_LIST_URI) return MSO_LIST_RESOURCE;+ if (uri === LEGACY_LIST_V1_URI) return { ...MSO_LIST_RESOURCE, uri };if (uri === MSO_BLOCK_URI) return MSO_BLOCK_RESOURCE;if (uri === MSO_PAGE_URI) return msoPageResource();- if (uri === LEGACY_BLOCK_V2_URI || uri === LEGACY_BLOCK_V1_URI || uri === LEGACY_WORKFLOW_PROGRESS_URI) return { ...MSO_BLOCK_RESOURCE, uri };+ if (uri === LEGACY_BLOCK_V3_URI || uri === LEGACY_BLOCK_V2_URI || 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/plugins/openai-app-binding.test.ts b/lib/plugins/openai-app-binding.test.tsindex 7ac7d0ce..180f9d0c 100644--- a/lib/plugins/openai-app-binding.test.ts+++ b/lib/plugins/openai-app-binding.test.ts@@ -4,16 +4,35 @@ import { isOpenAiAppBindingId, validateOpenAiAppManifest } from "./openai-app-bidescribe("OpenAI app binding compatibility", () => {it.each(["asdk_app_6a834fa9d250819197e75b23fe1223da",- "plugin_asdk_app_6a834fa9d250819197e75b23fe1223da","connector_76869538009648d5b282a4bb21c3d157",- "templated_apps_example_connector",- ])("accepts supported app/connector binding ids: %s", (id) => {+ "connector_openai_plugin_management",+ "templated_apps_example_connector-v2",+ ])("accepts canonical app/connector binding ids: %s", (id) => {expect(isOpenAiAppBindingId(id)).toBe(true);});- it("accepts required registered apps and optional connectors", () => {+ it.each([+ "plugin_asdk_app_6a834fa9d250819197e75b23fe1223da",+ "unknown_abc123",+ "asdk_app_",+ "connector_bad value",+ ])("rejects non-canonical or malformed ids: %s", (id) => {+ expect(isOpenAiAppBindingId(id)).toBe(false);+ });++ it("accepts required, optional, snake_case aliases, and reference metadata", () => {expect(validateOpenAiAppManifest({ apps: { mso: { id: "asdk_app_abc123", required: true } } }).ok).toBe(true);expect(validateOpenAiAppManifest({ apps: { github: { id: "connector_abc123", required: false } } }).ok).toBe(true);+ expect(validateOpenAiAppManifest({+ apps: {+ google_calendar: {+ id: "connector_947e0d954944416db111db556030eea6",+ optional: true,+ category: "Calendar context",+ },+ },+ }).ok).toBe(true);+ expect(validateOpenAiAppManifest({ apps: { plugin_management: { id: "connector_openai_plugin_management" } } }).ok).toBe(true);});it("accepts an empty app map for skill-only packages", () => {@@ -22,8 +41,9 @@ describe("OpenAI app binding compatibility", () => {it.each([{ apps: { github: { id: "REPLACE_WITH_APP_ID", required: true } } },- { apps: { github: { id: "connector_abc123" } } },+ { apps: { github: { id: "plugin_asdk_app_abc123", required: true } } },{ apps: { github: { id: "connector_abc123", required: "false" } } },+ { apps: { github: { id: "connector_abc123", optional: "true" } } },{ apps: { github: { id: "unknown_abc123", required: false } } },{ apps: { "Bad Key": { id: "connector_abc123", required: false } } },])("rejects placeholders, malformed ids, keys, or non-boolean dependency state", (manifest) => {diff --git a/lib/plugins/openai-app-binding.ts b/lib/plugins/openai-app-binding.tsindex a4e67d3a..5b3cec94 100644--- a/lib/plugins/openai-app-binding.ts+++ b/lib/plugins/openai-app-binding.ts@@ -1,27 +1,28 @@export type OpenAiAppBinding = {id: string;- required: boolean;+ required?: boolean;+ optional?: boolean;+ category?: string;};export type OpenAiAppManifest = {apps: Record<string, OpenAiAppBinding>;};-const APP_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;-const REGISTERED_APP_ID = /^(?:plugin_)?asdk_app_[a-z0-9]+$/;-const CONNECTOR_ID = /^connector_[a-z0-9]+$/;-const TEMPLATED_APP_ID = /^templated_apps_[a-z0-9_]+$/;+// OpenAI treats the object key as a package-local server alias. Reference+// packages use both kebab-case and snake_case aliases, so keep the accepted+// set portable while rejecting whitespace, paths, and punctuation.+const APP_KEY = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;+// Canonical .app.json IDs only. A plugin URL may contain plugin_asdk_app_*,+// but OpenAI requires the referenced app ID to be stored without plugin_.+const OPENAI_APP_ID = /^(?:asdk_app_|connector_|templated_apps_)[A-Za-z0-9][A-Za-z0-9_-]*$/;function record(value: unknown): value is Record<string, unknown> {return Boolean(value) && typeof value === "object" && !Array.isArray(value);}export function isOpenAiAppBindingId(value: unknown): value is string {- return typeof value === "string" && (- REGISTERED_APP_ID.test(value) ||- CONNECTOR_ID.test(value) ||- TEMPLATED_APP_ID.test(value)- );+ return typeof value === "string" && OPENAI_APP_ID.test(value);}export function validateOpenAiAppManifest(value: unknown):@@ -30,13 +31,16 @@ export function validateOpenAiAppManifest(value: unknown):const errors: string[] = [];if (!record(value) || !record(value.apps)) return { ok: false, errors: ["must contain an apps object"] };for (const [name, binding] of Object.entries(value.apps)) {- if (!APP_KEY.test(name)) errors.push(`app key must be kebab-case: ${name}`);+ if (!APP_KEY.test(name)) errors.push(`app key must contain only letters, digits, _ or - and start with a letter/digit: ${name}`);if (!record(binding)) {errors.push(`${name} binding must be an object`);continue;}- if (!isOpenAiAppBindingId(binding.id)) errors.push(`${name}.id must be an exact supported OpenAI app/connector id`);- if (typeof binding.required !== "boolean") errors.push(`${name}.required must be boolean`);+ if (!isOpenAiAppBindingId(binding.id)) errors.push(`${name}.id must be an exact canonical OpenAI app/connector id`);+ if (binding.required !== undefined && typeof binding.required !== "boolean")+ errors.push(`${name}.required must be boolean when provided`);+ if (binding.optional !== undefined && typeof binding.optional !== "boolean")+ errors.push(`${name}.optional must be boolean when provided`);}return errors.length ? { ok: false, errors } : { ok: true, manifest: value as OpenAiAppManifest };}diff --git a/scripts/e2e/mcp-page.mjs b/scripts/e2e/mcp-page.mjsindex 868c2dc9..5a184342 100644--- a/scripts/e2e/mcp-page.mjs+++ b/scripts/e2e/mcp-page.mjs@@ -48,7 +48,7 @@ const output = {},};-assert.equal(listResource.uri, "ui://mso/list-v1.html");+assert.equal(listResource.uri, "ui://mso/list-v2.html");assert.deepEqual(listResource._meta.ui.csp.connectDomains, []);assert.deepEqual(listResource._meta.ui.csp.resourceDomains, []);assert.equal(resource.uri, "ui://mso/page-v15.html");@@ -80,6 +80,23 @@ try {assert.deepEqual(listAudit.violations.map(v=>v.id),[]);assertions++;await listPage.close();await listContext.close();++ // Standards-first compact widget host: initialize over ui/*, deliver tool+ // results through notifications, and receive the follow-up through ui/message.+ const standardContext=await browser.newContext({viewport:{width:640,height:720}});+ const standardPage=await standardContext.newPage();+ await standardPage.route("https://mso-ui.example.com/list-standard",route=>route.fulfill({contentType:"text/html",body:'<!doctype html><script>window.openai={setWidgetState:()=>{}}</script>'+listResource.text}));+ await standardPage.route("https://chatgpt.com/list-standard",route=>route.fulfill({contentType:"text/html",body:'<!doctype html><iframe id="app" src="https://mso-ui.example.com/list-standard" style="width:100%;height:600px"></iframe><script>window.messages=[];window.listOutput='+JSON.stringify(listOutput)+';window.addEventListener("message",event=>{const frame=document.getElementById("app"),m=event.data;if(event.origin!=="https://mso-ui.example.com"||event.source!==frame.contentWindow||!m||m.jsonrpc!=="2.0")return;if(m.method==="ui/initialize")event.source.postMessage({jsonrpc:"2.0",id:m.id,result:{protocolVersion:"2026-01-26",hostContext:{theme:"light"}}},"https://mso-ui.example.com");else if(m.method==="ui/notifications/initialized"){window.initialized=true;event.source.postMessage({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{structuredContent:window.listOutput}},"https://mso-ui.example.com")}else if(m.method==="ui/message"){window.messages.push(m.params);if(m.id!==undefined)event.source.postMessage({jsonrpc:"2.0",id:m.id,result:{}},"https://mso-ui.example.com")}});</script>'}));+ await standardPage.goto("https://chatgpt.com/list-standard");+ const standardList=standardPage.frameLocator('iframe[src="https://mso-ui.example.com/list-standard"]');+ await standardList.locator(".item").first().waitFor();+ assert.equal(await standardList.locator(".item").count(),2);assertions++;+ assert.equal(await standardPage.evaluate(()=>window.initialized),true);assertions++;+ await standardList.getByRole("button",{name:"Open",exact:true}).click();+ await standardPage.waitForFunction(()=>window.messages?.length===1);+ assert.match(await standardPage.evaluate(()=>window.messages[0].content[0].text),/baton/);assertions++;+ await standardPage.close();+ await standardContext.close();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({diff --git a/scripts/link-openai-app.mjs b/scripts/link-openai-app.mjsindex 4a103e93..91d9f253 100755--- a/scripts/link-openai-app.mjs+++ b/scripts/link-openai-app.mjs@@ -11,8 +11,10 @@ if(args.includes("--clear")){console.log("openai-app: cleared registered app mapping; live MCP authorization is unchanged");process.exit(0);}-const id=args[0]?.trim();-if(!id) fail("usage: bun run plugin:link-app -- <plugin_asdk_app...|asdk_app...> | --clear");-if(!/^(?:plugin_)?asdk_app_[a-z0-9]+$/.test(id)) fail("expected an exact registered OpenAI app id; placeholders and URLs are rejected");+const raw=args[0]?.trim();+if(!raw) fail("usage: bun run plugin:link-app -- <asdk_app...|connector_...|templated_apps_...> | --clear");+const id=raw.startsWith("plugin_asdk_app_")?raw.slice("plugin_".length):raw;+if(!/^(?:asdk_app_|connector_|templated_apps_)[A-Za-z0-9][A-Za-z0-9_-]*$/.test(id))+ fail("expected an exact canonical OpenAI app/connector id; placeholders and URLs are rejected");await fs.writeFile(target,JSON.stringify({apps:{mso:{id,required:true}}},null,2)+"\n");-console.log(`openai-app: linked mso -> ${id}`);+console.log(`openai-app: linked mso -> ${id}${raw===id?"":" (normalized from plugin URL id)"}`);diff --git a/scripts/link-openai-app.test.ts b/scripts/link-openai-app.test.tsnew file mode 100644index 00000000..208137d3--- /dev/null+++ b/scripts/link-openai-app.test.ts@@ -0,0 +1,53 @@+import { afterEach, describe, expect, it } from "vitest";+import { copyFile, mkdtemp, mkdir, readFile, rm } from "node:fs/promises";+import { execFileSync } from "node:child_process";+import os from "node:os";+import path from "node:path";++const roots: string[] = [];+afterEach(async () => {+ await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));+});++async function fixture() {+ const root = await mkdtemp(path.join(os.tmpdir(), "mso-openai-app-"));+ roots.push(root);+ const scripts = path.join(root, "scripts");+ await mkdir(scripts, { recursive: true });+ const source = path.resolve("scripts/link-openai-app.mjs");+ const target = path.join(scripts, "link-openai-app.mjs");+ await copyFile(source, target);+ return { root, script: target };+}++async function manifest(root: string) {+ return JSON.parse(await readFile(path.join(root, ".app.json"), "utf8"));+}++describe("link-openai-app", () => {+ it.each([+ ["asdk_app_example-1", "asdk_app_example-1"],+ ["connector_openai_plugin_management", "connector_openai_plugin_management"],+ ["templated_apps_example_connector-v2", "templated_apps_example_connector-v2"],+ ["plugin_asdk_app_example_2", "asdk_app_example_2"],+ ])("writes canonical binding for %s", async (input, expected) => {+ const { root, script } = await fixture();+ execFileSync(process.execPath, [script, input], { encoding: "utf8" });+ expect(await manifest(root)).toEqual({ apps: { mso: { id: expected, required: true } } });+ });++ it("clears the binding without changing live authorization", async () => {+ const { root, script } = await fixture();+ execFileSync(process.execPath, [script, "asdk_app_example"], { encoding: "utf8" });+ execFileSync(process.execPath, [script, "--clear"], { encoding: "utf8" });+ expect(await manifest(root)).toEqual({ apps: {} });+ });++ it.each(["plugin_connector_bad", "asdk_app_", "https://example.com/app", "REPLACE_WITH_APP_ID"])(+ "rejects malformed or placeholder id %s",+ async (input) => {+ const { script } = await fixture();+ expect(() => execFileSync(process.execPath, [script, input], { encoding: "utf8", stdio: "pipe" })).toThrow();+ },+ );+});