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): align widgets with rahmanef palette
Rahman77e0f7706012
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 41a7c772..44575e86 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -120,17 +120,17 @@ through the app catch-all.The web catch-all remains the authenticated cockpit route. ChatGPT does **not** frame that cockpit.MSO exposes exactly two user-visible MCP App classes instead:-- `render_mso_block` binds `ui://mso/block-v1.html` for compact validation, action buttons, and+- `render_mso_block` binds `ui://mso/block-v2.html` for compact validation, action buttons, andCRUD input-output. A button returns a user-approved follow-up message; it does not execute amutation inside the widget, so ordinary scope, approval, audit, and workflow rules still apply.-- `render_mso_page` binds `ui://mso/page-v1.html` for native `/`, `/monitor`, `/project`, `/diff`,+- `render_mso_page` binds `ui://mso/page-v2.html` for native `/`, `/monitor`, `/project`, `/diff`,`/browser`, and `/apps/<reviewed-id>` views. Native Page views call the same bounded MSO tools.`workflow_start` is orchestration-only and headless: it still owns workflow isolation, skill/recipelookup, collision detection, tracing, evidence, and learning, but no longer binds a UI resource.`project_get`, `project_diff`, and `vps_status` likewise remain pure data tools. The previous`render_mso_surface` and `workflow_status` actions are app-only compatibility shims for cached-widgets; the previous resource URIs remain readable aliases but are not advertised.+widgets; Block/Page v1 plus the previous workflow/surface resource URIs remain readable aliases but are not advertised.Reviewed Page apps may use a nested iframe only when their exact HTTPS origin exists in thecode-owned Page catalog and the MCP resource CSP `frameDomains`; anti-frame apps stay on thediff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex d42c7b94..7d770d97 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` align widgets with rahmanef palette- `release` bound local dependency audit**Changed**diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 2f04bb1b..4dd03a72 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,4 +1,5 @@# mso — Progress Log+- **Rahmanef-aligned MCP widget palette / Block + Page v2 (2026-09-04):** MCP server `1.10.0` / toolset `2026.09.04.7` moves the two canonical ChatGPT resources to `ui://mso/block-v2.html` and `ui://mso/page-v2.html` so hosts do not reuse the old purple CSS cache key. Block and Page now share one visual-token source aligned with `rahmanef.com`: light `#f4f4f7` / `#1c1c1f`, dark `#1b1b20` / `#f2f2f5`, accent `#1f6df0`, Plus Jakarta Sans display copy, Inter body copy, fine separators, and editorial foreground/background primary-action inversion. ChatGPT theme changes propagate through `window.openai.theme` with a color-scheme fallback. Block/Page v1 and the earlier workflow/surface URIs remain readable but unlisted compatibility aliases; the headless workflow and two-surface/security contracts are unchanged.- **Headless workflows + two-surface MCP UI contract (2026-09-04):** MCP server `1.10.0` / toolset `2026.09.04.6` removes the automatic UI binding from `workflow_start`: orchestration, collision checks, tracing, evidence, and learning continue in the background without consuming the answer with a progress card. ChatGPT now has exactly two canonical MCP App resources: `ui://mso/block-v1.html` through `render_mso_block` for compact validation/action/CRUD input-output, and `ui://mso/page-v1.html` through `render_mso_page` for native operator views plus reviewed development/preview/production embeds. Block buttons send a user-approved follow-up and never execute mutations inside the widget, preserving normal scope, approval, audit, and workflow boundaries. The prior workflow/surface URIs remain non-advertised read aliases, while `workflow_status` and `render_mso_surface` remain app-only compatibility shims for cached clients. The ChatGPT transport profile is 66 tools: 64 model-visible actions (35 read / 17 write / 12 exec) plus two app-only shims; the full catalog is 90. Only Block and Page advertise a resource URI.- **Local release audit timeout hardening (2026-09-04):** the tolerant pre-push dependency audit now caps `bun audit --json` at 15 seconds. A registry timeout is reported and skipped only in the local gate, matching its existing network-tolerant policy; CI remains the fail-closed dependency-audit authority. This prevents a slow registry request from holding GitHub's pre-push SSH session open for minutes and failing the otherwise-green release with a transport/SIGPIPE-style exit.- **MCP Apps CSP metadata dedup / Surface v5 (2026-09-04):** MCP server `1.9.4` / toolset `2026.09.04.5` moves all standard widget CSP fields to the preferred `_meta.ui.csp` surface and leaves legacy `openai/widgetCSP` with only `redirect_domains` for `Open in MSO`. Workflow/Surface resources are cache-busted to `workflow-progress-v3` and `surface-v5`; the reviewed Play Together iframe remains exact-origin under `/embed`, so one external-iframe review advisory is expected from `ui.csp.frameDomains`. Scanner-facing Surface metadata explicitly names `/apps/play-together` and has a regression guard against cross-scope app examples.diff --git a/docs/TESTING-HANDOFF.md b/docs/TESTING-HANDOFF.mdindex 920e8b97..ea5c1309 100644--- a/docs/TESTING-HANDOFF.md+++ b/docs/TESTING-HANDOFF.md@@ -5,12 +5,12 @@ Update this file at the end of every manual or automated test session. Keep it f## Current status-The current release target is **MSO CLI 1.12.1**, MCP server `1.10.0`, toolset `2026.09.04.6`; use `mso --version` plus `/api/health` for the exact Git build because documentation-only release commits also advance that identity. The v1.10/v1.11 findings and the v1.12 sectioned-terminal/recoverable-error work below are resolved and retained as historical test evidence. Do not re-open a resolved finding from prose alone: reproduce it against the current build first. There is no known 1.12 release blocker in this handoff.+The current release target is **MSO CLI 1.12.1**, MCP server `1.10.0`, toolset `2026.09.04.7`; use `mso --version` plus `/api/health` for the exact Git build because documentation-only release commits also advance that identity. The v1.10/v1.11 findings and the v1.12 sectioned-terminal/recoverable-error work below are resolved and retained as historical test evidence. Do not re-open a resolved finding from prose alone: reproduce it against the current build first. There is no known 1.12 release blocker in this handoff.Current verified behavior:- **2026-09-04 Cognitive Runtime public-claim audit:** source/main/origin + loopback/public production were revalidated on the latest concurrent baseline. Fresh reruns pass `bench:cognitive`, `bench:memory`, P9 200-correction calibration, P10 lifecycle, and P10 retrieval calibration. Current deterministic evidence: 100% required-tool recall, 96.6% active-schema reduction, memory 8/8, P9 6/6, P10 lifecycle 8/8, lexical/local-semantic 4/6 vs 3/6, graph fixture 3/3. Canonical raw comparison artifacts were re-hashed: P6 `e0b5e1e30a9f1e5b34624e42d4bb5195792e50129b74de7d4006906a99716ba5`, P7 two-run `a0c12961d142420f6ac334ff021bde7ab82faa89f9294107d3bd46823606a530`, P8 three-run `f70e2f5e8132f0808976ed69e2cb6769d2cec861d58612a8cca2ef5d80a7d838`, P8 cache `b4a2b1be5dc6edfb2ce8282eae64e3a4fc206cd043ecb825a1eae6a617c9f871`. The canonical P7 file is `mso-p7-repeat-full-2x9.json`; the similarly named `mso-p7-repeat-full-2runs.json` is a different, non-canonical run. Recomputed P7+P8 evidence is 5/5 perfect for both MSO and Hermes with 74.7% fewer normalized tokens/attempt, 12.8% lower mean average latency, and 34.1% lower mean per-run p50 for MSO on that exact matched nine-scenario corpus. P4/P5 exact numeric tables are historical-only because their exact raw artifacts were not independently revalidated in this audit. Cost/cache/OpenClaw remain unranked. Tool Forge source/non-Docker tests pass, but the local Forge Docker image was absent, so three Docker-only tests were correctly skipped and executable evaluation fails closed until explicitly provisioned.-- Fresh 3 current MCP contract: server `1.10.0` / toolset `2026.09.04.6`; ChatGPT receives **66 transport tools = 64 model-visible actions (35 read / 17 write / 12 exec) + app-only `workflow_status` and `render_mso_surface` compatibility shims**, while the full transport catalog is 90 tools. Every ChatGPT action advertises `outputSchema`, and the dedicated MCP Apps origin remains `https://mso-ui.rahmanef.com`. Exactly two canonical resources are published: `ui://mso/block-v1.html` for validation/action/CRUD input-output and `ui://mso/page-v1.html` for native views plus reviewed dev/preview/prod embeds. `workflow_start` is headless and has no UI template. Only `render_mso_block` and `render_mso_page` bind resources. Previous workflow/surface URIs remain readable but unlisted; the two app-only actions keep cached clients functional. Page framing remains exact-origin under `https://game.rahmanef.com/embed`, while Block has no frame domains and cannot execute a mutation directly.-- MCP App acceptance: starting a workflow must produce structured workflow identity without opening an App. A Block must render bounded validation/CRUD data and return a user-approved follow-up when its action is pressed; it must not call a mutation itself. A Page must render native `/monitor`/`/project`/`/diff` views through `tools/call` and frame Play Together only from `https://game.rahmanef.com/embed`. The old workflow/surface URIs must resolve only as non-advertised compatibility aliases. Block v1 and Page v1 are cache-busting resource changes, so ChatGPT must re-scan Fresh 3 after deployment.+- Fresh 3 current MCP contract: server `1.10.0` / toolset `2026.09.04.7`; ChatGPT receives **66 transport tools = 64 model-visible actions (35 read / 17 write / 12 exec) + app-only `workflow_status` and `render_mso_surface` compatibility shims**, while the full transport catalog is 90 tools. Every ChatGPT action advertises `outputSchema`, and the dedicated MCP Apps origin remains `https://mso-ui.rahmanef.com`. Exactly two canonical resources are published: `ui://mso/block-v2.html` for validation/action/CRUD input-output and `ui://mso/page-v2.html` for native views plus reviewed dev/preview/prod embeds. `workflow_start` is headless and has no UI template. Only `render_mso_block` and `render_mso_page` bind resources. Block/Page v1 and previous workflow/surface URIs remain readable but unlisted; the two app-only actions keep cached clients functional. Page framing remains exact-origin under `https://game.rahmanef.com/embed`, while Block has no frame domains and cannot execute a mutation directly.+- MCP App acceptance: starting a workflow must produce structured workflow identity without opening an App. A Block must render bounded validation/CRUD data and return a user-approved follow-up when its action is pressed; it must not call a mutation itself. A Page must render native `/monitor`/`/project`/`/diff` views through `tools/call` and frame Play Together only from `https://game.rahmanef.com/embed`. The old Block/Page v1 and workflow/surface URIs must resolve only as non-advertised compatibility aliases. Block v2 and Page v2 are cache-busting visual-resource changes, so ChatGPT must re-scan Fresh 3 after deployment.- Alfa Cockpit acceptance: Assistant → Chat shows a compact project/model/activity bar; Cockpit opens as a desktop panel and mobile drawer; project search can select a project outside the first bounded page; selected project metadata reaches the next Alfa system prompt but raw `KNOWLEDGE.md`/repo-memory bodies do not; private typed-memory keys/values render as `Private memory`; Host Skills lazy-load from `/api/skills`; model switch stays within the configured provider; Activity & Runs shows local Alfa tool state alongside MCP workflow activity without treating the browser run as MCP `workflow_finish`.- Alfa Automation acceptance: a saved recipe's Run action switches to its configured persona and submits the ordered recipe through normal Alfa execution. Read steps may execute directly; write/exec steps must still park on the existing approval card. Playbook starter prompts appear as bounded empty-chat quick actions.diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.mdindex b9310206..3bdfbd99 100644--- a/docs/generated/MCP-CATALOG.md+++ b/docs/generated/MCP-CATALOG.md@@ -4,13 +4,13 @@## Full MSO catalog-<!-- mcp-toolset: server=1.10.0 version=2026.09.04.6 tools=88 read=44 write=25 exec=19 -->+<!-- mcp-toolset: server=1.10.0 version=2026.09.04.7 tools=88 read=44 write=25 exec=19 -->| Fact | Current source value ||---|---:|| MCP server | `1.10.0` |-| Toolset | `2026.09.04.6` |-| Toolset changed at | `2026-09-04T09:36:00Z` |+| Toolset | `2026.09.04.7` |+| Toolset changed at | `2026-09-04T10:25:00Z` || Transport tools | **90** || Model/operator tools | **88** || Read | **44** |@@ -122,7 +122,7 @@## ChatGPT static profile-<!-- mcp-chatgpt-profile: server=1.10.0 version=2026.09.04.6 tools=64 read=35 write=17 exec=12 app-only=2 total=66 -->+<!-- mcp-chatgpt-profile: server=1.10.0 version=2026.09.04.7 tools=64 read=35 write=17 exec=12 app-only=2 total=66 -->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/docs/integrations/CHATGPT-UI.md b/docs/integrations/CHATGPT-UI.mdindex 04c72ca5..ca3083f3 100644--- a/docs/integrations/CHATGPT-UI.md+++ b/docs/integrations/CHATGPT-UI.md@@ -8,13 +8,19 @@ The user-visible contract has exactly two canonical MCP App resources:| Surface | Entry tool | Resource | Intended use || --- | --- | --- | --- |-| **Block** | `render_mso_block` | `ui://mso/block-v1.html` | Compact validation, action buttons, and CRUD input-output |-| **Page** | `render_mso_page` | `ui://mso/page-v1.html` | Full native operator views and reviewed development, preview, or production app embeds |+| **Block** | `render_mso_block` | `ui://mso/block-v2.html` | Compact validation, action buttons, and CRUD input-output |+| **Page** | `render_mso_page` | `ui://mso/page-v2.html` | Full native operator views and reviewed development, preview, or production app embeds |`workflow_start` is now headless. It remains the required orchestration bootstrap for multi-step work, including skill/recipe lookup, collision checks, workflow isolation, tracing, evidence, and learning, but it has no `_meta.ui.resourceUri` and no `openai/outputTemplate`. Starting background work therefore does not consume the answer with an unrelated workflow card.A normal data/action tool also remains headless unless its result genuinely needs one of the two explicit presentation tools. `project_get`, `project_diff`, and `vps_status`, for example, keep structured outputs with no UI binding; the Page may call them through the standard MCP Apps `tools/call` bridge when it needs a native view.+## Visual identity++Block and Page share one presentation-token source in `lib/mcp/ui-widget-tokens.ts`, aligned with the public `rahmanef.com` design system: light surface `#f4f4f7` with text `#1c1c1f`, dark surface `#1b1b20` with text `#f2f2f5`, and the restrained blue accent `#1f6df0`. Display copy uses the Plus Jakarta Sans stack, body copy uses Inter/system fallbacks, and routes or section labels use the mono stack. Primary actions use the editorial foreground/background inversion rather than a colored fill; blue is reserved for focus, state, and small accents.++The widget first follows ChatGPT's `window.openai.theme` signal and updates on `openai:set_globals`; `prefers-color-scheme` remains the fallback for other MCP Apps hosts. The v2 resource URIs are intentional cache keys for this CSS/HTML refresh.+Official references:- <https://developers.openai.com/plugins/build/chatgpt-ui>@@ -54,8 +60,10 @@ Apps that keep restrictive `X-Frame-Options` or `frame-ancestors` remain `remote## Compatibility during migration-The canonical `resources/list` response advertises only Block and Page. Two previous URIs remain readable, but are not listed, so already-cached ChatGPT descriptors do not fail immediately:+The canonical `resources/list` response advertises only Block and Page. Four previous URIs remain readable, but are not listed, so already-cached ChatGPT descriptors do not fail immediately:+- `ui://mso/block-v1.html` resolves to the current Block resource.+- `ui://mso/page-v1.html` resolves to the current Page resource.- `ui://mso/workflow-progress-v3.html` resolves to the Block resource. The Block recognizes the old workflow structured result and presents a small compatibility summary rather than the historical live progress dashboard.- `ui://mso/surface-v5.html` resolves to the Page resource.@@ -75,6 +83,7 @@ Current ChatGPT transport profile: **66 tools** — 64 model-visible actions (35| Contract | MSO source || --- | --- |+| Shared Block/Page visual tokens and host-theme bridge | `lib/mcp/ui-widget-tokens.ts` || Block resource/runtime | `lib/mcp/ui-block.ts` || Block tool/schema | `lib/mcp/tools-block.ts` || Page resource/runtime | `lib/mcp/ui-surface.ts`, `lib/mcp/ui-surface-script.ts`, `lib/mcp/ui-surface-style.ts` |@@ -84,7 +93,7 @@ Current ChatGPT transport profile: **66 tools** — 64 model-visible actions (35| Resource capability / RPC | `lib/mcp/dispatch.ts` || MCP descriptor/profile contract | `lib/mcp/tool-contract.ts` || Toolset signature | `lib/mcp/toolset.ts` |-| Contract tests | `lib/mcp/ui-resources.test.ts`, `lib/mcp/tools-block.test.ts`, `lib/mcp/tools-surface.test.ts`, `lib/mcp/surface-catalog.test.ts` |+| Contract tests | `lib/mcp/ui-resources.test.ts`, `lib/mcp/ui-widget-theme.test.ts`, `lib/mcp/tools-block.test.ts`, `lib/mcp/tools-surface.test.ts`, `lib/mcp/surface-catalog.test.ts` |## Flow@@ -124,9 +133,9 @@ ChatGPT modelAfter changing UI resources or tool metadata:1. run targeted tests, `bun run verify`, and the official production release path;-2. verify `initialize` reports MCP server `1.10.0` and toolset `2026.09.04.6`;+2. verify `initialize` reports MCP server `1.10.0` and toolset `2026.09.04.7`;3. verify `tools/list` exposes 66 ChatGPT transport tools, keeps `workflow_start` headless, marks the two compatibility actions app-only, and binds only `render_mso_block` / `render_mso_page`;-4. verify `resources/list` contains exactly `ui://mso/block-v1.html` and `ui://mso/page-v1.html`, both with `text/html;profile=mcp-app`;+4. verify `resources/list` contains exactly `ui://mso/block-v2.html` and `ui://mso/page-v2.html`, both with `text/html;profile=mcp-app`;5. verify Block has no frame domain and Page has only reviewed exact origins;6. refresh/re-scan the ChatGPT development app so its cached action/resource snapshot is replaced.diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.tsindex c6bfeb5c..caefbc83 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.10.0";-export const MCP_TOOLSET_VERSION = "2026.09.04.6";-export const MCP_TOOLSET_CHANGED_AT = "2026-09-04T09:36:00Z";+export const MCP_TOOLSET_VERSION = "2026.09.04.7";+export const MCP_TOOLSET_CHANGED_AT = "2026-09-04T10:25:00Z";export type McpToolsetInfo = {serverVersion: string;diff --git a/lib/mcp/ui-block.ts b/lib/mcp/ui-block.tsindex e5bda13a..12cd748f 100644--- a/lib/mcp/ui-block.ts+++ b/lib/mcp/ui-block.ts@@ -1,11 +1,13 @@import { widgetResourceMeta } from "./ui-config";+import { MSO_WIDGET_THEME_SCRIPT, MSO_WIDGET_TOKENS } from "./ui-widget-tokens";-export const MSO_BLOCK_URI = "ui://mso/block-v1.html";+export const MSO_BLOCK_URI = "ui://mso/block-v2.html";const MIME = "text/html;profile=mcp-app";const html = String.raw`<main class="mso-block" aria-live="polite"><style>-:root{color-scheme:light dark;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--line:color-mix(in srgb,CanvasText 14%,transparent);--muted:color-mix(in srgb,CanvasText 58%,transparent);--soft:color-mix(in srgb,CanvasText 5%,Canvas);--accent:#7c3aed;--success:#16a34a;--warning:#d97706;--danger:#dc2626}*{box-sizing:border-box}html,body{margin:0;min-width:0;background:transparent;color:CanvasText}body{padding:7px}.card{overflow:hidden;border:1px solid var(--line);border-radius:16px;background:color-mix(in srgb,Canvas 97%,transparent);box-shadow:0 6px 24px color-mix(in srgb,#000 10%,transparent)}.head{display:flex;align-items:flex-start;gap:10px;padding:12px 12px 9px}.mark{display:grid;width:30px;height:30px;flex:0 0 30px;place-items:center;border-radius:9px;background:color-mix(in srgb,var(--accent) 17%,Canvas);font-size:12px;font-weight:850}.copy{min-width:0;flex:1}.eyebrow{font-size:8px;font-weight:750;letter-spacing:.09em;text-transform:uppercase;color:var(--muted)}h2{margin:2px 0 0;font-size:13px;line-height:1.3}.description{margin:4px 0 0;font-size:10px;line-height:1.45;color:var(--muted);overflow-wrap:anywhere}.status{flex:0 0 auto;border:1px solid var(--line);border-radius:999px;padding:4px 7px;font-size:8px;font-weight:800;letter-spacing:.06em;text-transform:uppercase}.status.pending{background:color-mix(in srgb,var(--accent) 12%,Canvas)}.status.success{background:color-mix(in srgb,var(--success) 12%,Canvas)}.status.warning{background:color-mix(in srgb,var(--warning) 13%,Canvas)}.status.error{background:color-mix(in srgb,var(--danger) 12%,Canvas)}.section{border-top:1px solid var(--line);padding:9px 12px}.section-title{margin:0 0 7px;font-size:8px;font-weight:750;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}.checks,.outputs{display:grid;gap:5px}.check,.output{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:7px;min-height:27px}.dot{width:7px;height:7px;border-radius:50%;background:color-mix(in srgb,CanvasText 30%,transparent)}.dot.pass{background:var(--success)}.dot.warn{background:var(--warning)}.dot.fail{background:var(--danger)}.check strong,.output strong{min-width:0;font-size:10px}.detail,.value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:9px;color:var(--muted)}.fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.field{min-width:0}.field.full{grid-column:1/-1}.field label{display:block;margin-bottom:4px;font-size:9px;font-weight:650}.required{color:var(--danger)}input,textarea{width:100%;min-height:34px;border:1px solid var(--line);border-radius:9px;background:var(--soft);color:CanvasText;padding:7px 8px;font:inherit;font-size:10px;outline:none}textarea{min-height:72px;resize:vertical}input:focus,textarea:focus{border-color:color-mix(in srgb,var(--accent) 55%,var(--line));box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 15%,transparent)}.boolean{display:flex;min-height:34px;align-items:center;gap:7px;border:1px solid var(--line);border-radius:9px;padding:7px 8px;background:var(--soft);font-size:10px}.boolean input{width:15px;min-height:15px;margin:0}.readonly{min-height:34px;border:1px solid var(--line);border-radius:9px;padding:8px;background:var(--soft);font-size:10px;overflow-wrap:anywhere}.actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}.feedback{min-width:0;flex:1;font-size:9px;color:var(--muted)}button{appearance:none;min-height:32px;border:1px solid var(--line);border-radius:9px;background:var(--soft);color:CanvasText;padding:6px 10px;font:inherit;font-size:10px;font-weight:700;cursor:pointer}button.primary{background:color-mix(in srgb,var(--accent) 17%,Canvas)}button.danger{background:color-mix(in srgb,var(--danger) 12%,Canvas)}button:disabled{cursor:default;opacity:.55}button:focus-visible{outline:2px solid Highlight;outline-offset:2px}.empty{padding:4px 0;font-size:10px;color:var(--muted)}@media(max-width:520px){body{padding:4px}.card{border-radius:13px}.head{padding:10px}.section{padding:8px 10px}.fields{grid-template-columns:1fr}.field.full{grid-column:auto}.actions{align-items:stretch}.feedback{width:100%;flex-basis:100%}button{flex:1}}+${MSO_WIDGET_TOKENS}+*{box-sizing:border-box}html,body{margin:0;min-width:0;background:transparent;color:var(--text)}body{padding:7px;font-family:var(--font-body)}.card{position:relative;overflow:hidden;border:1px solid var(--sep-strong);border-radius:var(--radius);background:var(--surface);box-shadow:var(--shadow-pop)}.card::before{content:"";display:block;height:3px;background:var(--os-accent)}.head{display:flex;align-items:flex-start;gap:10px;padding:11px 12px 9px}.mark{display:grid;width:30px;height:30px;flex:0 0 30px;place-items:center;border-radius:6px;background:var(--text);color:var(--surface);font-family:var(--font-display);font-size:12px;font-weight:800;letter-spacing:-.03em}.copy{min-width:0;flex:1}.eyebrow{font-family:var(--font-mono);font-size:8px;font-weight:650;letter-spacing:.11em;text-transform:uppercase;color:var(--text-dim)}h2{margin:2px 0 0;font-family:var(--font-display);font-size:13px;font-weight:720;letter-spacing:-.026em;line-height:1.3}.description{margin:4px 0 0;font-size:10px;line-height:1.45;color:var(--text-dim);overflow-wrap:anywhere}.status{flex:0 0 auto;border:1px solid var(--sep-strong);border-radius:999px;background:var(--field);padding:4px 7px;font-family:var(--font-mono);font-size:8px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}.status.pending{border-color:color-mix(in srgb,var(--os-accent) 45%,var(--sep));background:color-mix(in srgb,var(--os-accent) 8%,var(--surface))}.status.success{border-color:color-mix(in srgb,var(--success) 48%,var(--sep));background:color-mix(in srgb,var(--success) 8%,var(--surface))}.status.warning{border-color:color-mix(in srgb,var(--warning) 52%,var(--sep));background:color-mix(in srgb,var(--warning) 9%,var(--surface))}.status.error{border-color:color-mix(in srgb,var(--destructive-text) 48%,var(--sep));background:color-mix(in srgb,var(--destructive-text) 8%,var(--surface))}.section{border-top:1px solid var(--sep);padding:9px 12px}.section-title{margin:0 0 7px;font-family:var(--font-mono);font-size:8px;font-weight:650;letter-spacing:.1em;text-transform:uppercase;color:var(--text-dim)}.checks,.outputs{display:grid;gap:5px}.check,.output{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:7px;min-height:27px}.dot{width:7px;height:7px;border-radius:50%;background:var(--text-faint)}.dot.info{background:var(--info)}.dot.pass{background:var(--success)}.dot.warn{background:var(--warning)}.dot.fail{background:var(--destructive-text)}.check strong,.output strong{min-width:0;font-size:10px}.detail,.value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:9px;color:var(--text-dim)}.fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.field{min-width:0}.field.full{grid-column:1/-1}.field label{display:block;margin-bottom:4px;font-size:9px;font-weight:650}.required{color:var(--destructive-text)}input,textarea{width:100%;min-height:34px;border:1px solid var(--sep-strong);border-radius:8px;background:var(--field);color:var(--text);caret-color:var(--os-accent);padding:7px 8px;font:inherit;font-size:10px;outline:none}input::placeholder,textarea::placeholder{color:var(--text-faint)}textarea{min-height:72px;resize:vertical}input:focus,textarea:focus{border-color:var(--os-accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--os-accent) 17%,transparent)}.boolean{display:flex;min-height:34px;align-items:center;gap:7px;border:1px solid var(--sep-strong);border-radius:8px;padding:7px 8px;background:var(--field);font-size:10px}.boolean input{width:15px;min-height:15px;margin:0;accent-color:var(--os-accent)}.readonly{min-height:34px;border:1px solid var(--sep);border-radius:8px;padding:8px;background:var(--inset);font-size:10px;overflow-wrap:anywhere}.actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}.feedback{min-width:0;flex:1;font-size:9px;color:var(--text-dim)}button{appearance:none;min-height:32px;border:1px solid var(--sep-strong);border-radius:8px;background:transparent;color:var(--text);padding:6px 10px;font:inherit;font-size:10px;font-weight:680;cursor:pointer;transition:transform .18s cubic-bezier(.16,1,.3,1),box-shadow .18s ease,background-color .18s ease}button:hover{background:var(--hover-strong);transform:translateY(-1px)}button:active{transform:translateY(1px) scale(.99)}button.primary{border-color:var(--text);background:var(--text);color:var(--surface)}button.primary:hover{background:var(--text);box-shadow:0 8px 22px color-mix(in srgb,var(--text) 15%,transparent)}button.danger{border-color:color-mix(in srgb,var(--destructive-text) 48%,var(--sep));background:color-mix(in srgb,var(--destructive-text) 7%,var(--surface));color:var(--destructive-text)}button:disabled{cursor:default;opacity:.55;transform:none}button:focus-visible{outline:2px solid var(--os-accent);outline-offset:2px}.empty{padding:4px 0;font-size:10px;color:var(--text-dim)}@media(max-width:520px){body{padding:4px}.card{border-radius:9px}.head{padding:10px}.section{padding:8px 10px}.fields{grid-template-columns:1fr}.field.full{grid-column:auto}.actions{align-items:stretch}.feedback{width:100%;flex-basis:100%}button{flex:1}}</style><section class="card" aria-label="MSO interaction block"><header class="head">@@ -21,6 +23,7 @@ const html = String.raw`<main class="mso-block" aria-live="polite"></form></section><script>(()=>{+${MSO_WIDGET_THEME_SCRIPT}const $=id=>document.getElementById(id);const kindEl=$("kind"),titleEl=$("title"),descriptionEl=$("description"),statusEl=$("status"),form=$("form"),feedback=$("feedback");const checksSection=$("checks-section"),checksEl=$("checks"),fieldsSection=$("fields-section"),fieldsEl=$("fields"),outputsSection=$("outputs-section"),outputsEl=$("outputs"),actionsSection=$("actions-section"),actionsEl=$("actions");let current=null;let confirmId="";let confirmTimer=0;@@ -40,7 +43,7 @@ function renderActions(rows){clear(actionsEl);actionsSection.hidden=!rows.lengthfunction 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",readHostOutput,{passive:true});readHostOutput();+window.addEventListener("openai:set_globals",()=>{applyHostTheme();readHostOutput()},{passive:true});applyHostTheme();readHostOutput();})();</script></main>`;diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.tsindex 391c2839..112d0480 100644--- a/lib/mcp/ui-resources.test.ts+++ b/lib/mcp/ui-resources.test.ts@@ -7,6 +7,8 @@ const {MCP_APP_MIME_TYPE,MSO_BLOCK_URI,MSO_PAGE_URI,+ LEGACY_BLOCK_V1_URI,+ LEGACY_PAGE_V1_URI,LEGACY_WORKFLOW_PROGRESS_URI,LEGACY_SURFACE_URI,readUiResource,@@ -122,7 +124,7 @@ describe("MCP Apps 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-v1.html");+ expect(MSO_BLOCK_URI).toContain("block-v2.html");});it("serves the full Page with a minimal reviewed nested-frame allowlist", async () => {@@ -145,7 +147,7 @@ describe("MCP Apps Block and Page contract", () => {frameDomains: ["https://game.rahmanef.com"],});expect(content._meta["openai/widgetCSP"]).toEqual({ redirect_domains: [MSO_ORIGIN] });- expect(MSO_PAGE_URI).toContain("page-v1.html");+ expect(MSO_PAGE_URI).toContain("page-v2.html");});it("returns only redacted structured workflow state and keeps status polling out of workflow memory", async () => {@@ -198,13 +200,19 @@ describe("MCP Apps Block and Page contract", () => {it("keeps latest cached workflow/surface URIs as non-advertised Block/Page aliases", async () => {const canonicalBlock = readUiResource(MSO_BLOCK_URI);const canonicalPage = readUiResource(MSO_PAGE_URI);+ const blockV1 = readUiResource(LEGACY_BLOCK_V1_URI);+ const pageV1 = readUiResource(LEGACY_PAGE_V1_URI);const legacyBlock = readUiResource(LEGACY_WORKFLOW_PROGRESS_URI);const legacyPage = readUiResource(LEGACY_SURFACE_URI);+ 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 });expect(legacyPage).toMatchObject({ uri: LEGACY_SURFACE_URI, text: canonicalPage?.text });const listed = await dispatch({ id: 31, method: "resources/list" }, "read", "mcp:ui-alias");const serialized = JSON.stringify(listed.result);+ expect(serialized).not.toContain(LEGACY_BLOCK_V1_URI);+ expect(serialized).not.toContain(LEGACY_PAGE_V1_URI);expect(serialized).not.toContain(LEGACY_WORKFLOW_PROGRESS_URI);expect(serialized).not.toContain(LEGACY_SURFACE_URI);});diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.tsindex 40730a9f..8ab68931 100644--- a/lib/mcp/ui-resources.ts+++ b/lib/mcp/ui-resources.ts@@ -7,6 +7,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: the public product contract has exactly Block and Page.+export const LEGACY_BLOCK_V1_URI = "ui://mso/block-v1.html";+export const LEGACY_PAGE_V1_URI = "ui://mso/page-v1.html";export const LEGACY_WORKFLOW_PROGRESS_URI = "ui://mso/workflow-progress-v3.html";export const LEGACY_SURFACE_URI = "ui://mso/surface-v5.html";@@ -21,6 +23,8 @@ export type McpUiResource = {const RESOURCES: readonly McpUiResource[] = [MSO_BLOCK_RESOURCE, MSO_PAGE_RESOURCE];const LEGACY_ALIASES = new Map<string, McpUiResource>([+ [LEGACY_BLOCK_V1_URI, MSO_BLOCK_RESOURCE],+ [LEGACY_PAGE_V1_URI, MSO_PAGE_RESOURCE],[LEGACY_WORKFLOW_PROGRESS_URI, MSO_BLOCK_RESOURCE],[LEGACY_SURFACE_URI, MSO_PAGE_RESOURCE],]);diff --git a/lib/mcp/ui-surface-script.ts b/lib/mcp/ui-surface-script.tsindex a52bdff2..72486df4 100644--- a/lib/mcp/ui-surface-script.ts+++ b/lib/mcp/ui-surface-script.ts@@ -1,4 +1,5 @@import { SURFACE_APPS } from "./surface-catalog";+import { MSO_WIDGET_THEME_SCRIPT } from "./ui-widget-tokens";function safeJson(value: unknown): string {return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026");@@ -18,6 +19,7 @@ const BROWSER_CATALOG = SURFACE_APPS.map((app) => ({}));export const MSO_SURFACE_SCRIPT = String.raw`+${MSO_WIDGET_THEME_SCRIPT}const SAFE_APPS=${safeJson(BROWSER_CATALOG)};const SAFE_BY_ID=new Map(SAFE_APPS.map(app=>[app.id,app]));const $=id=>document.getElementById(id);@@ -43,6 +45,7 @@ function safeAppResult(raw){function openPath(path){setMsoTarget(validRoute(path)?path:"/assistant/mcp")}function applyHostGlobals(){const api=window.openai||{};+ applyHostTheme();const max=Number(api.maxHeight);document.documentElement.style.setProperty("--host-max-h",Number.isFinite(max)&&max>180?Math.floor(max)+"px":"680px");const safe=api.safeArea||{};for(const [key,value] of [["top",safe.top],["right",safe.right],["bottom",safe.bottom],["left",safe.left]]){const n=Number(value);document.documentElement.style.setProperty("--safe-"+key,Number.isFinite(n)?Math.max(0,n)+"px":"0px")}modeEl.textContent=text(api.displayMode,"inline");diff --git a/lib/mcp/ui-surface-style.ts b/lib/mcp/ui-surface-style.tsindex e2ccb0c2..1278acc6 100644--- a/lib/mcp/ui-surface-style.ts+++ b/lib/mcp/ui-surface-style.ts@@ -1,5 +1,8 @@+import { MSO_WIDGET_TOKENS } from "./ui-widget-tokens";+export const MSO_SURFACE_STYLE = String.raw`-:root{color-scheme:light dark;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--line:color-mix(in srgb,CanvasText 13%,transparent);--muted:color-mix(in srgb,CanvasText 58%,transparent);--soft:color-mix(in srgb,CanvasText 5%,Canvas);--accent:#7c3aed;--safe-top:0px;--safe-right:0px;--safe-bottom:0px;--safe-left:0px;--host-max-h:680px}*{box-sizing:border-box}html,body{margin:0;min-width:0;background:transparent;color:CanvasText}body{padding:8px}.surface{display:flex;min-height:260px;max-height:min(var(--host-max-h),78vh);overflow:hidden;flex-direction:column;border:1px solid var(--line);border-radius:18px;background:color-mix(in srgb,Canvas 96%,transparent);box-shadow:0 8px 36px color-mix(in srgb,#000 12%,transparent)}.bar{display:flex;min-height:48px;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid var(--line);padding-left:max(10px,var(--safe-left));padding-right:max(10px,var(--safe-right))}.brand{display:grid;place-items:center;width:30px;height:30px;flex:0 0 30px;border-radius:9px;background:color-mix(in srgb,var(--accent) 18%,Canvas);font-weight:850}.heading{min-width:0;flex:1}.heading strong{display:block;font-size:12px;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.heading span{display:block;margin-top:2px;font-size:9px;color:var(--muted);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tools{display:flex;align-items:center;gap:5px;flex-wrap:wrap;justify-content:flex-end}button,.button{appearance:none;border:1px solid var(--line);background:var(--soft);color:CanvasText;border-radius:9px;padding:6px 8px;min-height:30px;font:inherit;font-size:10px;font-weight:650;cursor:pointer;text-decoration:none}button:hover,.button:hover{background:color-mix(in srgb,CanvasText 9%,Canvas)}button:focus-visible,.button:focus-visible{outline:2px solid Highlight;outline-offset:2px}.primary{background:color-mix(in srgb,var(--accent) 17%,Canvas)}.open-direct{font-size:9px;color:CanvasText}.open-feedback{display:none}.body{min-height:0;flex:1;overflow:auto;padding:12px;padding-bottom:max(12px,var(--safe-bottom));scrollbar-gutter:stable}.home{display:grid;gap:12px}.hero{padding:14px;border:1px solid var(--line);border-radius:15px;background:linear-gradient(135deg,color-mix(in srgb,var(--accent) 12%,Canvas),Canvas)}.hero h2{margin:0;font-size:17px}.hero p{max-width:680px;margin:5px 0 0;font-size:11px;line-height:1.5;color:var(--muted)}.section-title{margin:2px 0 7px;font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.card{min-width:0;text-align:left;padding:11px;border:1px solid var(--line);border-radius:13px;background:var(--soft)}.card strong{display:block;font-size:11px}.card span{display:block;margin-top:4px;font-size:9px;line-height:1.4;color:var(--muted)}.tag{display:inline-flex!important;width:auto!important;margin-top:8px!important;padding:2px 6px;border-radius:999px;border:1px solid var(--line);font-size:8px!important;text-transform:uppercase;letter-spacing:.06em}.stage{display:flex;min-height:330px;height:100%;flex-direction:column}.stage-head{display:flex;align-items:center;gap:8px;margin-bottom:8px}.back{flex:0 0 auto}.stage-title{min-width:0;flex:1}.stage-title strong{display:block;font-size:12px}.stage-title span{display:block;margin-top:2px;font-size:9px;color:var(--muted)}.frame-wrap{position:relative;min-height:280px;flex:1;overflow:hidden;border:1px solid var(--line);border-radius:13px;background:#111}.frame-wrap iframe{display:block;width:100%;height:100%;min-height:360px;border:0;background:#fff}.notice{display:grid;min-height:280px;place-items:center;border:1px solid var(--line);border-radius:13px;background:var(--soft);padding:24px;text-align:center}.notice>div{max-width:520px}.notice h3{margin:0;font-size:14px}.notice p{margin:7px 0 0;color:var(--muted);font-size:10px;line-height:1.5}.notice .row{justify-content:center;margin-top:12px}.metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}.metric{padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--soft)}.metric span{display:block;font-size:8px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.metric strong{display:block;margin-top:4px;font-size:13px}.list{margin-top:8px;border:1px solid var(--line);border-radius:12px;overflow:hidden}.line{display:flex;align-items:center;gap:10px;min-height:34px;padding:7px 9px;border-top:1px solid var(--line);font-size:10px}.line:first-child{border-top:0}.line span{color:var(--muted)}.line strong{margin-left:auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.loading{display:grid;min-height:240px;place-items:center;color:var(--muted);font-size:11px}.error{color:#dc2626}.mode-badge{padding:3px 6px;border-radius:999px;background:var(--soft);font-size:8px;color:var(--muted)}+${MSO_WIDGET_TOKENS}+:root{font-family:var(--font-body);--line:var(--sep);--muted:var(--text-dim);--soft:var(--field);--accent:var(--os-accent);--safe-top:0px;--safe-right:0px;--safe-bottom:0px;--safe-left:0px;--host-max-h:680px}*{box-sizing:border-box}html,body{margin:0;min-width:0;background:transparent;color:var(--text)}body{padding:8px;font-family:var(--font-body)}.surface{display:flex;min-height:260px;max-height:min(var(--host-max-h),78vh);overflow:hidden;flex-direction:column;border:1px solid var(--sep-strong);border-radius:18px;background:var(--surface);box-shadow:var(--shadow-pop)}.bar{display:flex;min-height:48px;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid var(--sep);padding-left:max(10px,var(--safe-left));padding-right:max(10px,var(--safe-right))}.brand{display:grid;place-items:center;width:30px;height:30px;flex:0 0 30px;border-radius:9px;background:var(--text);color:var(--surface);font-family:var(--font-display);font-size:12px;font-weight:850}.heading{min-width:0;flex:1}.heading strong{display:block;font-family:var(--font-display);font-size:12px;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.heading span{display:block;margin-top:2px;font-size:9px;color:var(--text-dim);font-family:var(--font-mono);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tools{display:flex;align-items:center;gap:5px;flex-wrap:wrap;justify-content:flex-end}button,.button{appearance:none;border:1px solid var(--sep-strong);background:var(--field);color:var(--text);border-radius:9px;padding:6px 8px;min-height:30px;font:inherit;font-size:10px;font-weight:650;cursor:pointer;text-decoration:none}button:hover,.button:hover{background:var(--hover-strong)}button:focus-visible,.button:focus-visible{outline:2px solid var(--os-accent);outline-offset:2px}.primary{border-color:var(--text);background:var(--text);color:var(--surface)}.primary:hover{background:var(--text);box-shadow:0 8px 22px color-mix(in srgb,var(--text) 15%,transparent)}.open-direct{font-size:9px;color:inherit}.open-feedback{display:none}.body{min-height:0;flex:1;overflow:auto;padding:12px;padding-bottom:max(12px,var(--safe-bottom));scrollbar-gutter:stable}.home{display:grid;gap:12px}.hero{padding:14px;border:1px solid var(--sep-strong);border-radius:15px;background:linear-gradient(135deg,color-mix(in srgb,var(--os-accent) 9%,var(--surface)),var(--surface))}.hero h2{margin:0;font-family:var(--font-display);font-size:17px}.hero p{max-width:680px;margin:5px 0 0;font-size:11px;line-height:1.5;color:var(--text-dim)}.section-title{margin:2px 0 7px;font-family:var(--font-mono);font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim)}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.card{min-width:0;text-align:left;padding:11px;border:1px solid var(--sep-strong);border-radius:13px;background:var(--field)}.card:hover{background:var(--hover)}.card strong{display:block;font-family:var(--font-display);font-size:11px}.card span{display:block;margin-top:4px;font-size:9px;line-height:1.4;color:var(--text-dim)}.tag{display:inline-flex!important;width:auto!important;margin-top:8px!important;padding:2px 6px;border-radius:999px;border:1px solid var(--sep-strong);font-family:var(--font-mono);font-size:8px!important;text-transform:uppercase;letter-spacing:.06em}.stage{display:flex;min-height:330px;height:100%;flex-direction:column}.stage-head{display:flex;align-items:center;gap:8px;margin-bottom:8px}.back{flex:0 0 auto}.stage-title{min-width:0;flex:1}.stage-title strong{display:block;font-family:var(--font-display);font-size:12px}.stage-title span{display:block;margin-top:2px;font-size:9px;color:var(--text-dim)}.frame-wrap{position:relative;min-height:280px;flex:1;overflow:hidden;border:1px solid var(--sep-strong);border-radius:13px;background:var(--inset)}.frame-wrap iframe{display:block;width:100%;height:100%;min-height:360px;border:0;background:#fff}.notice{display:grid;min-height:280px;place-items:center;border:1px solid var(--sep-strong);border-radius:13px;background:var(--field);padding:24px;text-align:center}.notice>div{max-width:520px}.notice h3{margin:0;font-family:var(--font-display);font-size:14px}.notice p{margin:7px 0 0;color:var(--text-dim);font-size:10px;line-height:1.5}.notice .row{justify-content:center;margin-top:12px}.metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}.metric{padding:12px;border:1px solid var(--sep-strong);border-radius:12px;background:var(--field)}.metric span{display:block;font-family:var(--font-mono);font-size:8px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim)}.metric strong{display:block;margin-top:4px;font-family:var(--font-display);font-size:13px}.list{margin-top:8px;border:1px solid var(--sep-strong);border-radius:12px;overflow:hidden}.line{display:flex;align-items:center;gap:10px;min-height:34px;padding:7px 9px;border-top:1px solid var(--sep);font-size:10px}.line:first-child{border-top:0}.line span{color:var(--text-dim)}.line strong{margin-left:auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mono{font-family:var(--font-mono)}.loading{display:grid;min-height:240px;place-items:center;color:var(--text-dim);font-size:11px}.error{color:var(--destructive-text)}.mode-badge{padding:3px 6px;border-radius:999px;background:var(--field);font-family:var(--font-mono);font-size:8px;color:var(--text-dim)}@media(max-width:660px){body{padding:5px}.surface{max-height:min(var(--host-max-h),82vh);border-radius:14px}.bar{align-items:flex-start;min-height:46px}.tools{max-width:50%}.tools button,.tools .button{padding:5px 7px}.grid{grid-template-columns:1fr 1fr}.frame-wrap iframe{min-height:430px}.metrics{grid-template-columns:1fr 1fr}.body{padding:9px}}@media(max-width:420px){.grid{grid-template-columns:1fr}.heading span{max-width:150px}.tools .optional{display:none}.metrics{grid-template-columns:1fr}.frame-wrap iframe{min-height:480px}}`;diff --git a/lib/mcp/ui-surface.ts b/lib/mcp/ui-surface.tsindex 26d4ff86..671afc0f 100644--- a/lib/mcp/ui-surface.ts+++ b/lib/mcp/ui-surface.ts@@ -4,7 +4,7 @@ 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-v1.html";+export const MSO_PAGE_URI = "ui://mso/page-v2.html";const MIME = "text/html;profile=mcp-app";const html = String.raw`<main class="surface" aria-label="MSO Page">diff --git a/lib/mcp/ui-widget-theme.test.ts b/lib/mcp/ui-widget-theme.test.tsnew file mode 100644index 00000000..2f0ffd2d--- /dev/null+++ b/lib/mcp/ui-widget-theme.test.ts@@ -0,0 +1,48 @@+import { describe, expect, it } from "vitest";+import { MSO_BLOCK_RESOURCE } from "./ui-block";+import { MSO_PAGE_RESOURCE } from "./ui-surface";+import { MSO_SURFACE_SCRIPT } from "./ui-surface-script";+import { MSO_SURFACE_STYLE } from "./ui-surface-style";+import { MSO_WIDGET_THEME_SCRIPT, MSO_WIDGET_TOKENS } from "./ui-widget-tokens";++const canonicalHtml = `${MSO_BLOCK_RESOURCE.text}\n${MSO_PAGE_RESOURCE.text}`;++describe("Rahmanef widget theme", () => {+ it("mirrors the public site's light and dark palette from one shared token source", () => {+ expect(MSO_WIDGET_TOKENS).toContain("--text:#1c1c1f;");+ expect(MSO_WIDGET_TOKENS).toContain("--surface:#f4f4f7;");+ expect(MSO_WIDGET_TOKENS).toContain("--os-accent:#1f6df0;");+ expect(MSO_WIDGET_TOKENS).toContain("--info:#0060df;");+ expect(MSO_WIDGET_TOKENS).toContain(':root[data-theme="dark"]');+ expect(MSO_WIDGET_TOKENS).toContain("--text:#f2f2f5;");+ expect(MSO_WIDGET_TOKENS).toContain("--surface:#1b1b20;");+ expect(MSO_WIDGET_TOKENS).toContain("--info:#409cff;");+ expect(MSO_WIDGET_TOKENS).toContain(":root:not([data-theme])");+ });++ it("injects the same palette into Block and Page and removes the old generic purple theme", () => {+ expect(MSO_BLOCK_RESOURCE.text).toContain(MSO_WIDGET_TOKENS);+ expect(MSO_SURFACE_STYLE).toContain(MSO_WIDGET_TOKENS);+ expect(MSO_PAGE_RESOURCE.text).toContain(MSO_WIDGET_TOKENS);+ expect(canonicalHtml).not.toContain("#7c3aed");+ expect(canonicalHtml).not.toContain("CanvasText");+ expect(canonicalHtml).not.toContain("color:Canvas");+ });++ it("uses the editorial foreground/background inversion for primary actions", () => {+ expect(MSO_BLOCK_RESOURCE.text).toContain(+ "button.primary{border-color:var(--text);background:var(--text);color:var(--surface)}",+ );+ expect(MSO_SURFACE_STYLE).toContain(+ ".primary{border-color:var(--text);background:var(--text);color:var(--surface)}",+ );+ });++ it("tracks the ChatGPT host theme while retaining prefers-color-scheme fallback", () => {+ expect(MSO_WIDGET_THEME_SCRIPT).toContain("window.openai.theme");+ expect(MSO_WIDGET_THEME_SCRIPT).toContain('theme==="light"||theme==="dark"');+ expect(MSO_BLOCK_RESOURCE.text).toContain("applyHostTheme();readHostOutput()");+ expect(MSO_SURFACE_SCRIPT).toContain("applyHostTheme();");+ expect(MSO_PAGE_RESOURCE.text).toContain("window.openai.theme");+ });+});diff --git a/lib/mcp/ui-widget-tokens.ts b/lib/mcp/ui-widget-tokens.tsnew file mode 100644index 00000000..76b2be3e--- /dev/null+++ b/lib/mcp/ui-widget-tokens.ts@@ -0,0 +1,68 @@+/**+ * Shared visual contract for ChatGPT Block and Page resources.+ *+ * Core values mirror rahmanef.com/app/globals.css. The widget keeps its own+ * small presentation aliases, but the public brand palette stays single-source.+ */+const DARK_TOKENS = String.raw`+--text:#f2f2f5;+--text-dim:rgba(242,242,245,.64);+--text-faint:rgba(242,242,245,.4);+--sep:rgba(255,255,255,.1);+--sep-strong:rgba(255,255,255,.18);+--grouped:#000;+--fill:rgba(120,120,128,.24);+--fill2:rgba(120,120,128,.36);+--window-bg:rgba(34,34,40,.82);+--surface:#1b1b20;+--field:rgba(255,255,255,.08);+--hover:rgba(255,255,255,.08);+--hover-strong:rgba(255,255,255,.14);+--inset:rgba(0,0,0,.25);+--shadow-pop:0 0 0 .5px rgba(255,255,255,.08),0 16px 40px -8px rgba(0,0,0,.6);+--warning:#ff9f0a;+--info:#409cff;+--destructive-text:#ff5f57;+`;++export const MSO_WIDGET_TOKENS = String.raw`+:root,:root[data-theme="light"]{+color-scheme:light;+--text:#1c1c1f;+--text-dim:rgba(28,28,31,.66);+--text-faint:rgba(28,28,31,.38);+--sep:rgba(0,0,0,.1);+--sep-strong:rgba(0,0,0,.16);+--os-accent:#1f6df0;+--accent-text:#fff;+--grouped:#f2f2f7;+--fill:rgba(118,118,128,.12);+--fill2:rgba(118,118,128,.24);+--window-bg:rgba(248,248,251,.86);+--surface:#f4f4f7;+--field:rgba(255,255,255,.7);+--hover:rgba(0,0,0,.05);+--hover-strong:rgba(0,0,0,.09);+--inset:rgba(0,0,0,.04);+--shadow-pop:0 0 0 .5px rgba(0,0,0,.12),0 14px 38px -8px rgba(0,0,0,.32);+--success:#34c759;+--warning:#ff9500;+--info:#0060df;+--destructive-text:#d70015;+--font-display:"Plus Jakarta Sans",Inter,ui-sans-serif,system-ui,sans-serif;+--font-body:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;+--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;+--radius:10px;+}+:root[data-theme="dark"]{color-scheme:dark;${DARK_TOKENS}}+@media(prefers-color-scheme:dark){:root:not([data-theme]){color-scheme:dark;${DARK_TOKENS}}}+`;++/** Keep a ChatGPT widget synchronized with the host theme, with media fallback. */+export const MSO_WIDGET_THEME_SCRIPT = String.raw`+function applyHostTheme(){+ const theme=window.openai&&window.openai.theme;+ if(theme==="light"||theme==="dark")document.documentElement.dataset.theme=theme;+ else document.documentElement.removeAttribute("data-theme");+}+`;