sunpeak 0.18.9 → 0.18.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/bin/commands/inspect.mjs +4 -1
- package/bin/commands/start.mjs +2 -1
- package/bin/lib/sandbox-server.mjs +12 -1
- package/dist/chatgpt/index.cjs +1 -1
- package/dist/chatgpt/index.js +1 -1
- package/dist/claude/index.cjs +1 -1
- package/dist/claude/index.js +1 -1
- package/dist/host/chatgpt/index.cjs +1 -1
- package/dist/host/chatgpt/index.js +1 -1
- package/dist/index.cjs +93 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -54
- package/dist/index.js.map +1 -1
- package/dist/inspector/hosts.d.ts +12 -0
- package/dist/inspector/index.cjs +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/{inspector-CTMccsz9.cjs → inspector-8nPV2A-z.cjs} +93 -51
- package/dist/inspector-8nPV2A-z.cjs.map +1 -0
- package/dist/{inspector-DkS75JCk.js → inspector-Cdo5BK2D.js} +92 -50
- package/dist/inspector-Cdo5BK2D.js.map +1 -0
- package/dist/mcp/index.cjs +69 -62
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.js +63 -56
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/production-server.d.ts +12 -0
- package/dist/{protocol-DJmRaBzO.js → protocol-BfAACnv0.js} +14 -9
- package/dist/{protocol-DJmRaBzO.js.map → protocol-BfAACnv0.js.map} +1 -1
- package/dist/{protocol-jbxhzcnS.cjs → protocol-C7kTcBr_.cjs} +14 -9
- package/dist/{protocol-jbxhzcnS.cjs.map → protocol-C7kTcBr_.cjs.map} +1 -1
- package/dist/style.css +36 -1
- package/dist/{use-app-BNbz1uzj.js → use-app-CfP9VypY.js} +107 -56
- package/dist/use-app-CfP9VypY.js.map +1 -0
- package/dist/{use-app-Dqh20JPP.cjs → use-app-CzcYw1Kz.cjs} +165 -114
- package/dist/use-app-CzcYw1Kz.cjs.map +1 -0
- package/package.json +3 -3
- package/template/README.md +12 -0
- package/template/dist/albums/albums.html +16 -15
- package/template/dist/albums/albums.json +1 -1
- package/template/dist/carousel/carousel.html +20 -19
- package/template/dist/carousel/carousel.json +1 -1
- package/template/dist/map/map.html +7 -6
- package/template/dist/map/map.json +1 -1
- package/template/dist/review/review.html +6 -5
- package/template/dist/review/review.json +1 -1
- package/template/node_modules/.vite/deps/_metadata.json +3 -3
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +49 -49
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +49 -49
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +89 -89
- package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -1
- package/template/node_modules/.vite-mcp/deps/_metadata.json +24 -24
- package/template/node_modules/.vite-mcp/deps/{protocol-CTflwIfG.js → protocol-B_qKkui_.js} +14 -9
- package/template/node_modules/.vite-mcp/deps/protocol-B_qKkui_.js.map +1 -0
- package/template/src/resources/carousel/carousel.test.tsx +16 -2
- package/template/src/resources/carousel/carousel.tsx +42 -14
- package/template/src/resources/carousel/components/carousel.tsx +20 -0
- package/template/src/resources/carousel/components/index.ts +1 -0
- package/template/src/resources/carousel/components/place-detail.tsx +153 -0
- package/template/tests/e2e/carousel.spec.ts +125 -0
- package/template/tests/live/carousel.spec.ts +2 -2
- package/template/tests/simulations/show-carousel.json +54 -5
- package/dist/inspector-CTMccsz9.cjs.map +0 -1
- package/dist/inspector-DkS75JCk.js.map +0 -1
- package/dist/use-app-BNbz1uzj.js.map +0 -1
- package/dist/use-app-Dqh20JPP.cjs.map +0 -1
- package/template/node_modules/.vite-mcp/deps/protocol-CTflwIfG.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspector-CTMccsz9.cjs","names":["BQ","OQ","h","zQ","_Q","VQ","m","TQ","oQ","pQ","mQ","yQ","bQ","uQ","nQ","fQ","kQ","rQ","xQ","hQ","iQ","lQ","dQ","cQ"],"sources":["../src/lib/default-style-variables.ts","../src/inspector/hosts.ts","../src/inspector/inspector-types.ts","../src/chatgpt/chatgpt-conversation.tsx","../src/chatgpt/chatgpt-host.ts","../src/claude/claude-conversation.tsx","../src/claude/claude-host.ts","../../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.3.1_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__react-_cd1fb28fd87e0bddd0a29eba0721855d/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js","../src/inspector/mcp-app-host.ts","../src/inspector/mock-openai-runtime.ts","../src/inspector/sandbox-proxy.ts","../src/inspector/iframe-resource.tsx","../src/inspector/use-inspector-state.ts","../src/inspector/use-mcp-connection.ts","../src/inspector/theme-provider.tsx","../src/inspector/simple-sidebar.tsx","../src/types/simulation.ts","../src/inspector/inspector.tsx"],"sourcesContent":["/**\n * Default MCP App style variables.\n *\n * Uses CSS light-dark() so a single set of values adapts to the document's\n * color-scheme automatically. These are applied as fallbacks when the host\n * doesn't provide style variables, and host shells use them as a base to\n * override specific entries for their brand palette.\n *\n * @see https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx#theming\n */\nimport type { McpUiStyles } from '@modelcontextprotocol/ext-apps';\n\nexport const DEFAULT_STYLE_VARIABLES: McpUiStyles = {\n // Background colors\n '--color-background-primary': 'light-dark(#ffffff, #1a1a1a)',\n '--color-background-secondary': 'light-dark(#f5f5f5, #2d2d2d)',\n '--color-background-tertiary': 'light-dark(#e5e5e5, #404040)',\n '--color-background-inverse': 'light-dark(#1a1a1a, #ffffff)',\n '--color-background-ghost': 'light-dark(rgba(255,255,255,0), rgba(26,26,26,0))',\n '--color-background-info': 'light-dark(#eff6ff, #1e3a5f)',\n '--color-background-danger': 'light-dark(#fef2f2, #7f1d1d)',\n '--color-background-success': 'light-dark(#f0fdf4, #14532d)',\n '--color-background-warning': 'light-dark(#fefce8, #713f12)',\n '--color-background-disabled': 'light-dark(rgba(255,255,255,0.5), rgba(26,26,26,0.5))',\n\n // Text colors\n '--color-text-primary': 'light-dark(#1f2937, #f3f4f6)',\n '--color-text-secondary': 'light-dark(#6b7280, #9ca3af)',\n '--color-text-tertiary': 'light-dark(#9ca3af, #6b7280)',\n '--color-text-inverse': 'light-dark(#f3f4f6, #1f2937)',\n '--color-text-ghost': 'light-dark(rgba(107,114,128,0.5), rgba(156,163,175,0.5))',\n '--color-text-info': 'light-dark(#1d4ed8, #60a5fa)',\n '--color-text-danger': 'light-dark(#b91c1c, #f87171)',\n '--color-text-success': 'light-dark(#15803d, #4ade80)',\n '--color-text-warning': 'light-dark(#a16207, #fbbf24)',\n '--color-text-disabled': 'light-dark(rgba(31,41,55,0.5), rgba(243,244,246,0.5))',\n\n // Border colors\n '--color-border-primary': 'light-dark(#e5e7eb, #404040)',\n '--color-border-secondary': 'light-dark(#d1d5db, #525252)',\n '--color-border-tertiary': 'light-dark(#f3f4f6, #374151)',\n '--color-border-inverse': 'light-dark(rgba(255,255,255,0.3), rgba(0,0,0,0.3))',\n '--color-border-ghost': 'light-dark(rgba(229,231,235,0), rgba(64,64,64,0))',\n '--color-border-info': 'light-dark(#93c5fd, #1e40af)',\n '--color-border-danger': 'light-dark(#fca5a5, #991b1b)',\n '--color-border-success': 'light-dark(#86efac, #166534)',\n '--color-border-warning': 'light-dark(#fde047, #854d0e)',\n '--color-border-disabled': 'light-dark(rgba(229,231,235,0.5), rgba(64,64,64,0.5))',\n\n // Ring colors (focus)\n '--color-ring-primary': 'light-dark(#3b82f6, #60a5fa)',\n '--color-ring-secondary': 'light-dark(#6b7280, #9ca3af)',\n '--color-ring-inverse': 'light-dark(#ffffff, #1f2937)',\n '--color-ring-info': 'light-dark(#2563eb, #3b82f6)',\n '--color-ring-danger': 'light-dark(#dc2626, #ef4444)',\n '--color-ring-success': 'light-dark(#16a34a, #22c55e)',\n '--color-ring-warning': 'light-dark(#ca8a04, #eab308)',\n\n // Typography — Family\n '--font-sans': \"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\",\n '--font-mono': \"ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace\",\n\n // Typography — Weight\n '--font-weight-normal': '400',\n '--font-weight-medium': '500',\n '--font-weight-semibold': '600',\n '--font-weight-bold': '700',\n\n // Typography — Text Size\n '--font-text-xs-size': '0.75rem',\n '--font-text-sm-size': '0.875rem',\n '--font-text-md-size': '1rem',\n '--font-text-lg-size': '1.125rem',\n\n // Typography — Heading Size\n '--font-heading-xs-size': '0.75rem',\n '--font-heading-sm-size': '0.875rem',\n '--font-heading-md-size': '1rem',\n '--font-heading-lg-size': '1.25rem',\n '--font-heading-xl-size': '1.5rem',\n '--font-heading-2xl-size': '1.875rem',\n '--font-heading-3xl-size': '2.25rem',\n\n // Typography — Text Line Height\n '--font-text-xs-line-height': '1.4',\n '--font-text-sm-line-height': '1.4',\n '--font-text-md-line-height': '1.5',\n '--font-text-lg-line-height': '1.5',\n\n // Typography — Heading Line Height\n '--font-heading-xs-line-height': '1.4',\n '--font-heading-sm-line-height': '1.4',\n '--font-heading-md-line-height': '1.4',\n '--font-heading-lg-line-height': '1.3',\n '--font-heading-xl-line-height': '1.25',\n '--font-heading-2xl-line-height': '1.2',\n '--font-heading-3xl-line-height': '1.1',\n\n // Border radius\n '--border-radius-xs': '2px',\n '--border-radius-sm': '4px',\n '--border-radius-md': '6px',\n '--border-radius-lg': '8px',\n '--border-radius-xl': '12px',\n '--border-radius-full': '9999px',\n\n // Border width\n '--border-width-regular': '1px',\n\n // Shadows\n '--shadow-hairline': '0 1px 2px 0 rgba(0, 0, 0, 0.05)',\n '--shadow-sm': '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)',\n '--shadow-md': '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',\n '--shadow-lg': '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)',\n};\n","import type {\n McpUiDisplayMode,\n McpUiHostContext,\n McpUiHostCapabilities,\n McpUiStyles,\n} from '@modelcontextprotocol/ext-apps';\nimport type { ScreenWidth } from './inspector-types';\n\ntype Platform = NonNullable<McpUiHostContext['platform']>;\n\n/**\n * Props passed to a host shell (conversation chrome) component.\n * Each host implements a React component matching this interface.\n */\nexport interface HostConversationProps {\n /** The resource content (iframe or children) to render inside the conversation */\n children: React.ReactNode;\n /** Current simulated screen width */\n screenWidth: ScreenWidth;\n /** Current MCP display mode */\n displayMode: McpUiDisplayMode;\n /** Current platform (desktop/mobile/web) */\n platform: Platform;\n /** Callback when the shell requests a display mode change (e.g., close button) */\n onRequestDisplayMode?: (mode: McpUiDisplayMode) => void;\n /** App name for display in conversation chrome */\n appName?: string;\n /** App icon (emoji or URL) for display in conversation chrome */\n appIcon?: string;\n /** User message to show in the conversation (decorative) */\n userMessage?: string;\n /** Optional action element rendered in the conversation header (e.g., Run button in Prod Tools mode) */\n headerAction?: React.ReactNode;\n /**\n * Called when the content container width changes (via ResizeObserver).\n * The inspector uses this to set containerDimensions.maxWidth in hostContext,\n * matching what real hosts report to apps.\n */\n onContentWidthChange?: (width: number) => void;\n}\n\n/** Unique identifier for a host */\nexport type HostId = 'chatgpt' | 'claude' | (string & {});\n\n/**\n * A registered host shell provides the conversation chrome and\n * functional configuration for a specific MCP App host.\n */\nexport interface HostShell {\n /** Unique host identifier */\n id: HostId;\n /** Human-readable name for the sidebar dropdown */\n label: string;\n /** The conversation shell React component */\n Conversation: React.ComponentType<HostConversationProps>;\n /** Apply the host's theme to the document (CSS variables, data attributes, etc.) */\n applyTheme: (theme: 'light' | 'dark') => void;\n /** Host info reported to the app via MCP protocol */\n hostInfo: { name: string; version: string };\n /** Host capabilities reported to the app via MCP protocol */\n hostCapabilities: McpUiHostCapabilities;\n /**\n * User agent string sent to the app via hostContext.userAgent.\n * Real hosts send identifiers like \"chatgpt\" or \"claude\".\n */\n userAgent?: string;\n /**\n * MCP App style variables sent to the app via hostContext.styles.variables.\n * Uses CSS light-dark() values so a single set adapts to theme automatically.\n * The SDK's applyDocumentTheme() sets color-scheme which light-dark() reads.\n * @see McpUiStyleVariableKey from @modelcontextprotocol/ext-apps\n */\n styleVariables?: McpUiStyles;\n /**\n * CSS custom properties for the inspector page chrome (sidebar, conversation area).\n * These are applied to the document root and can override the defaults:\n * --sim-bg-sidebar (fallback: var(--color-background-secondary))\n * --sim-bg-conversation (fallback: var(--color-background-primary))\n *\n * Values should use CSS light-dark() for automatic theme adaptation.\n */\n pageStyles?: Record<string, string>;\n /**\n * Display modes this host supports.\n * The sidebar display mode picker only shows modes in this list.\n * Defaults to ['inline', 'pip', 'fullscreen'] if not specified.\n */\n availableDisplayModes?: McpUiDisplayMode[];\n /**\n * CSS containing @font-face rules for the host's custom fonts.\n * Injected into the inspector page when this host is active so the\n * conversation chrome can use the same font as the real host.\n */\n fontCss?: string;\n}\n\n// ── Host Shell Registry ──────────────────────────────────────────\n\nconst registry = new Map<HostId, HostShell>();\n\n/** Register a host shell. Idempotent — re-registering with the same id replaces. */\nexport function registerHostShell(shell: HostShell): void {\n registry.set(shell.id, shell);\n}\n\n/** Get a registered host shell by id. */\nexport function getHostShell(id: HostId): HostShell | undefined {\n return registry.get(id);\n}\n\n/** Get all registered host shells, in insertion order. */\nexport function getRegisteredHosts(): HostShell[] {\n return Array.from(registry.values());\n}\n","import { DisplayMode, Theme } from '../types/runtime';\n\nexport type ScreenWidth = 'mobile-s' | 'mobile-l' | 'tablet' | 'full';\n\nexport type InspectorConfig = {\n theme: Theme;\n displayMode: DisplayMode;\n screenWidth: ScreenWidth;\n};\n\nexport const SCREEN_WIDTHS: Record<ScreenWidth, number> = {\n 'mobile-s': 375,\n 'mobile-l': 425,\n tablet: 768,\n full: 1024,\n};\n","import * as React from 'react';\nimport { useEffect, useRef, useCallback } from 'react';\nimport { SCREEN_WIDTHS, type ScreenWidth } from '../inspector/inspector-types';\nimport type { McpUiDisplayMode, McpUiHostContext } from '@modelcontextprotocol/ext-apps';\n\ntype Platform = NonNullable<McpUiHostContext['platform']>;\n\nfunction CloseIcon({ className }: { className?: string }) {\n return (\n <svg width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" fill=\"currentColor\" className={className}>\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.83071 5.83077C6.33839 5.32309 7.16151 5.32309 7.66919 5.83077L12 10.1615L16.3307 5.83077C16.8384 5.32309 17.6615 5.32309 18.1692 5.83077C18.6769 6.33845 18.6769 7.16157 18.1692 7.66925L13.8384 12L18.1692 16.3308C18.6769 16.8385 18.6769 17.6616 18.1692 18.1693C17.6615 18.6769 16.8384 18.6769 16.3307 18.1693L12 13.8385L7.66919 18.1693C7.16151 18.6769 6.33839 18.6769 5.83071 18.1693C5.32303 17.6616 5.32303 16.8385 5.83071 16.3308L10.1615 12L5.83071 7.66925C5.32303 7.16157 5.32303 6.33845 5.83071 5.83077Z\"\n />\n </svg>\n );\n}\n\ninterface ConversationProps {\n children?: React.ReactNode;\n screenWidth: ScreenWidth;\n displayMode: McpUiDisplayMode;\n platform: Platform;\n onRequestDisplayMode?: (mode: McpUiDisplayMode) => void;\n appName?: string;\n appIcon?: string;\n userMessage?: string;\n /** Optional action element rendered in the conversation header (e.g., Run button) */\n headerAction?: React.ReactNode;\n /** Called when the content container width changes */\n onContentWidthChange?: (width: number) => void;\n}\n\n/**\n * Conversation layout that renders children (iframe) at a stable tree position.\n *\n * All three display modes (inline, pip, fullscreen) share the same React tree\n * shape so that the iframe never unmounts when switching modes, avoiding a\n * white-flash reload.\n *\n * Visual differences are achieved purely with CSS:\n * - **inline**: content in normal document flow\n * - **pip**: content wrapper becomes `position: fixed` floating overlay\n * - **fullscreen**: content wrapper becomes `position: fixed` covering the viewport;\n * fullscreen chrome (header/footer) rendered as a separate fixed overlay\n */\nexport function Conversation({\n children,\n screenWidth,\n displayMode,\n platform,\n onRequestDisplayMode,\n appName = 'Sunpeak',\n appIcon,\n userMessage = 'What have you got for me today?',\n headerAction,\n onContentWidthChange,\n}: ConversationProps) {\n const isDesktop = platform === 'desktop';\n const containerWidth = screenWidth === 'full' ? '100%' : `${SCREEN_WIDTHS[screenWidth]}px`;\n const isFullscreen = displayMode === 'fullscreen';\n const isPip = displayMode === 'pip';\n\n // Measure the content container width and report it via onContentWidthChange.\n const contentRef = useRef<HTMLDivElement>(null);\n const onContentWidthChangeRef = useRef(onContentWidthChange);\n useEffect(() => {\n onContentWidthChangeRef.current = onContentWidthChange;\n });\n\n const setContentRef = useCallback((node: HTMLDivElement | null) => {\n contentRef.current = node;\n }, []);\n\n useEffect(() => {\n const el = contentRef.current;\n if (!el) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const width = Math.round(entry.contentBoxSize[0]?.inlineSize ?? entry.contentRect.width);\n if (width > 0) {\n onContentWidthChangeRef.current?.(width);\n }\n }\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n\n const handleClose = () => onRequestDisplayMode?.('inline');\n\n return (\n <div\n className=\"flex flex-col w-full h-full flex-1 items-center relative\"\n style={{\n transform: 'translate(0)',\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n color: 'var(--color-text-primary)',\n }}\n >\n {/* ─── Fullscreen chrome overlay ─── */}\n {isFullscreen && (\n <div\n className=\"fixed start-0 end-0 top-0 bottom-0 z-[51] mx-auto flex flex-col pointer-events-none\"\n style={{ maxWidth: containerWidth }}\n >\n <div\n className=\"z-20 flex h-[3.25rem] items-center justify-between p-2 pointer-events-auto\"\n style={{\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n >\n <button\n onClick={handleClose}\n aria-label=\"Close\"\n className=\"h-7 w-7 flex items-center justify-center rounded-lg transition-colors hover:opacity-70\"\n type=\"button\"\n >\n <CloseIcon />\n </button>\n {isDesktop && (\n <div className=\"flex items-center justify-center text-base\">{appName}</div>\n )}\n {isDesktop && <div />}\n </div>\n {/* Spacer - pointer events pass through to content below */}\n <div className=\"flex-1\" />\n <footer className=\"relative\">\n {/* Scroll fade mask — ChatGPT uses gradient mask, not backdrop blur */}\n <div\n className=\"absolute inset-x-0 bottom-0 h-full -z-10\"\n style={{\n maskImage: 'linear-gradient(to bottom, transparent 0%, black 50%)',\n WebkitMaskImage: 'linear-gradient(to bottom, transparent 0%, black 50%)',\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n />\n <div className=\"max-w-[40rem] min-[1440px]:max-w-[48rem] mx-auto px-4 pt-4 pb-4 pointer-events-auto\">\n <div className=\"relative\">\n <input\n type=\"text\"\n name=\"userInput\"\n disabled\n placeholder=\"Message sunpeak.ai\"\n className=\"w-full rounded-[28px] p-2.5 shadow-sm\"\n style={{\n backgroundColor: 'var(--sim-bg-reply-input, var(--color-background-secondary))',\n color: 'var(--color-text-primary)',\n border: 'none',\n // @ts-expect-error -- corner-shape is a newer CSS property (squircle)\n cornerShape: 'superellipse',\n }}\n />\n </div>\n </div>\n </footer>\n </div>\n )}\n\n {/* ─── Conversation header ─── */}\n {!isFullscreen && (\n <header\n className=\"h-12 flex items-center gap-3 px-4 text-lg sticky top-0 z-40 w-full\"\n style={{\n maxWidth: containerWidth,\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n >\n <span>sunpeak.ai</span>\n {headerAction}\n </header>\n )}\n\n {/* ─── Conversation container ─── */}\n <div\n className=\"flex flex-col flex-1 w-full transition-all duration-200 overflow-hidden\"\n style={{ maxWidth: containerWidth }}\n >\n <main className=\"flex-1 overflow-y-auto overflow-x-hidden flex flex-col\">\n {/* User turn - hidden in fullscreen */}\n {!isFullscreen && (\n <article className=\"w-full focus:outline-none\" dir=\"auto\" data-turn=\"user\">\n <h5 className=\"sr-only\">You said:</h5>\n <div className=\"text-base my-auto mx-auto md:pt-8 px-4\">\n <div className=\"max-w-[40rem] min-[1440px]:max-w-[48rem] mx-auto flex-1 relative flex w-full min-w-0 flex-col\">\n <div className=\"flex max-w-full flex-col grow\">\n <div\n data-message-author-role=\"user\"\n className=\"min-h-8 relative flex w-full flex-col items-end gap-2 text-start break-words whitespace-normal\"\n >\n <div className=\"flex w-full flex-col gap-1 empty:hidden items-end\">\n <div\n className=\"relative rounded-[22px] px-4 py-2.5 leading-6 max-w-[70%]\"\n style={{\n backgroundColor:\n 'var(--sim-bg-user-bubble, var(--color-background-tertiary))',\n // @ts-expect-error -- corner-shape is a newer CSS property (squircle)\n cornerShape: 'superellipse',\n }}\n >\n <div className=\"whitespace-pre-wrap\">{userMessage}</div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </article>\n )}\n\n {/* Assistant turn — flex-1 so short content still pushes the input to the bottom */}\n <article className=\"w-full focus:outline-none flex-1\" dir=\"auto\" data-turn=\"assistant\">\n <h6 className=\"sr-only\">{appName} said:</h6>\n <div className=\"text-base my-auto mx-auto pb-10 px-4\">\n <div className=\"max-w-[40rem] min-[1440px]:max-w-[48rem] mx-auto flex-1 relative flex w-full min-w-0 flex-col\">\n <div className=\"flex max-w-full flex-col grow\">\n {/* Assistant avatar and name - hidden in fullscreen */}\n {!isFullscreen && (\n <div className=\"flex items-center gap-2 my-3\">\n {appIcon ? (\n appIcon.startsWith('data:') || appIcon.startsWith('http') ? (\n <img src={appIcon} alt=\"\" className=\"size-6 rounded-full object-cover\" />\n ) : (\n <div className=\"size-6 flex items-center justify-center text-base\">\n {appIcon}\n </div>\n )\n ) : (\n <div\n className=\"size-6 rounded-full flex items-center justify-center font-medium text-xs text-white\"\n style={{ backgroundColor: '#10a37f' }}\n >\n AI\n </div>\n )}\n <span className=\"font-semibold text-sm\">{appName}</span>\n </div>\n )}\n\n {/* Assistant message content */}\n <div\n data-message-author-role=\"assistant\"\n className=\"min-h-8 relative flex w-full flex-col items-start gap-2 text-start break-words whitespace-normal\"\n >\n <div className=\"flex w-full flex-col gap-1 empty:hidden\">\n {/*\n * ─── CONTENT AREA ───\n * Children (iframe) are always at this tree position.\n * CSS handles visual positioning for each display mode:\n * inline: normal flow (position: relative)\n * pip: floating overlay (position: fixed)\n * fullscreen: viewport takeover (position: fixed)\n */}\n <div\n ref={setContentRef}\n className={\n isPip\n ? 'no-scrollbar @w-xl/main:top-4 fixed start-4 end-4 top-12 z-50 mx-auto max-w-[40rem] lg:max-w-[48rem] sm:start-0 sm:end-0 sm:top-[3.25rem] sm:w-full overflow-visible'\n : isFullscreen\n ? 'no-scrollbar fixed inset-x-0 top-[3.25rem] bottom-0 z-50 mx-auto'\n : 'no-scrollbar relative mb-2 @w-sm/main:w-full mx-0 max-sm:-mx-[1rem] max-sm:w-[100cqw] max-sm:overflow-hidden overflow-visible'\n }\n style={{\n ...(isPip ? { maxHeight: 'calc(50dvh - 38px)' } : {}),\n ...(isFullscreen ? { maxWidth: containerWidth } : {}),\n }}\n >\n {/* PiP close button - keyed so it doesn't shift content's position */}\n {isPip && (\n <button\n key=\"pip-close\"\n onClick={handleClose}\n className=\"absolute -start-2 md:-start-6 -top-1.5 z-10 rounded-full bg-[#3a3a3a] p-1.25 text-white shadow-[0px_0px_0px_1px_var(--color-border-primary),0px_4px_12px_rgba(0,0,0,0.12)] hover:bg-[#6a6a6a]\"\n aria-label=\"Close picture-in-picture\"\n type=\"button\"\n >\n <CloseIcon className=\"h-4 w-4\" />\n </button>\n )}\n <div\n key=\"content\"\n className={\n isPip\n ? 'relative overflow-hidden h-full rounded-2xl sm:rounded-3xl shadow-[0px_0px_0px_1px_var(--color-border-primary),0px_6px_20px_rgba(0,0,0,0.1)] md:-mx-4'\n : 'relative overflow-hidden h-full'\n }\n >\n <div\n className=\"h-full w-full max-w-full\"\n style={{\n ...(isPip\n ? {\n overflow: 'auto',\n backgroundColor: 'var(--color-background-primary)',\n }\n : isFullscreen\n ? {\n overflow: 'auto',\n backgroundColor: 'var(--color-background-primary)',\n }\n : { backgroundColor: 'transparent' }),\n }}\n >\n {children}\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </article>\n\n {/* Input area - sticky at bottom, content scrolls underneath with blur.\n Hidden in fullscreen since fullscreen chrome has its own footer. */}\n {!isFullscreen && (\n <div className=\"sticky bottom-0 z-10 pointer-events-none\">\n {/* Scroll fade mask — ChatGPT uses gradient mask, not backdrop blur */}\n <div\n className=\"absolute inset-x-0 bottom-0 h-full -z-10\"\n style={{\n maskImage: 'linear-gradient(to bottom, transparent 0%, black 50%)',\n WebkitMaskImage: 'linear-gradient(to bottom, transparent 0%, black 50%)',\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n />\n <div className=\"max-w-[40rem] min-[1440px]:max-w-[48rem] mx-auto px-4 pt-4 pb-4 pointer-events-auto\">\n <div className=\"relative\">\n <input\n type=\"text\"\n name=\"userInput\"\n disabled\n placeholder=\"Message sunpeak.ai\"\n className=\"w-full rounded-3xl px-5 py-3 pr-12 shadow-sm\"\n style={{\n backgroundColor:\n 'var(--sim-bg-reply-input, var(--color-background-secondary))',\n color: 'var(--color-text-primary)',\n border: '1px solid var(--color-border-tertiary)',\n }}\n />\n </div>\n </div>\n </div>\n )}\n </main>\n </div>\n </div>\n );\n}\n","import type { McpUiHostCapabilities } from '@modelcontextprotocol/ext-apps';\nimport { registerHostShell } from '../inspector/hosts';\nimport { DEFAULT_STYLE_VARIABLES } from '../inspector/host-styles';\nimport { Conversation } from './chatgpt-conversation';\n\n/**\n * ChatGPT host version info — matches what ChatGPT reports via the MCP protocol.\n * Verified against production ChatGPT on 2026-03-19.\n */\nconst CHATGPT_HOST_INFO = {\n name: 'chatgpt',\n version: '0.0.1',\n};\n\nconst CHATGPT_HOST_CAPABILITIES: McpUiHostCapabilities = {\n openLinks: {},\n serverTools: {},\n serverResources: {},\n logging: {},\n updateModelContext: {},\n message: {},\n sandbox: {\n permissions: {\n microphone: {},\n },\n },\n};\n\n/**\n * Apply ChatGPT-style theming to the document.\n * Sets data-theme attribute and color-scheme for light-dark() CSS support.\n */\nfunction applyChatGPTTheme(theme: 'light' | 'dark'): void {\n document.documentElement.setAttribute('data-theme', theme);\n document.documentElement.style.colorScheme = theme;\n}\n\n/**\n * ChatGPT style variables — matches SDK defaults exactly.\n * Verified against production ChatGPT on 2026-03-19.\n */\nconst CHATGPT_STYLE_VARIABLES = {\n ...DEFAULT_STYLE_VARIABLES,\n};\n\nregisterHostShell({\n id: 'chatgpt',\n label: 'ChatGPT',\n Conversation,\n applyTheme: applyChatGPTTheme,\n hostInfo: CHATGPT_HOST_INFO,\n hostCapabilities: CHATGPT_HOST_CAPABILITIES,\n userAgent: 'chatgpt',\n styleVariables: CHATGPT_STYLE_VARIABLES,\n pageStyles: {\n '--sim-bg-sidebar': 'light-dark(#ffffff, #212121)',\n '--sim-bg-conversation': 'light-dark(#ffffff, #212121)',\n '--sim-bg-user-bubble': 'light-dark(rgba(233,233,233,0.5), rgba(50,50,50,0.85))',\n '--sim-bg-reply-input': 'light-dark(#ffffff, #303030)',\n },\n});\n","import * as React from 'react';\nimport { useEffect, useRef, useCallback } from 'react';\nimport { SCREEN_WIDTHS, type ScreenWidth } from '../inspector/inspector-types';\nimport type { McpUiDisplayMode, McpUiHostContext } from '@modelcontextprotocol/ext-apps';\n\ntype Platform = NonNullable<McpUiHostContext['platform']>;\n\ninterface ClaudeConversationProps {\n children?: React.ReactNode;\n screenWidth: ScreenWidth;\n displayMode: McpUiDisplayMode;\n platform: Platform;\n onRequestDisplayMode?: (mode: McpUiDisplayMode) => void;\n appName?: string;\n appIcon?: string;\n userMessage?: string;\n /** Optional action element rendered in the conversation header (e.g., Run button) */\n headerAction?: React.ReactNode;\n /** Called when the content container width changes */\n onContentWidthChange?: (width: number) => void;\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M12 4L4 12M4 4L12 12\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n\nfunction BackIcon() {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M10 3L5 8L10 13\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\n/**\n * Claude conversation shell — mimics Claude's chat UI chrome.\n *\n * All three display modes (inline, pip, fullscreen) share the same React tree\n * shape so that the iframe never unmounts when switching modes.\n */\nexport function ClaudeConversation({\n children,\n screenWidth,\n displayMode,\n platform,\n onRequestDisplayMode,\n appName = 'Sunpeak',\n appIcon,\n userMessage = 'What have you got for me today?',\n headerAction,\n onContentWidthChange,\n}: ClaudeConversationProps) {\n const isDesktop = platform === 'desktop';\n const containerWidth = screenWidth === 'full' ? '100%' : `${SCREEN_WIDTHS[screenWidth]}px`;\n const isFullscreen = displayMode === 'fullscreen';\n const isPip = displayMode === 'pip';\n\n // Measure the content container width and report it via onContentWidthChange.\n const contentRef = useRef<HTMLDivElement>(null);\n const onContentWidthChangeRef = useRef(onContentWidthChange);\n useEffect(() => {\n onContentWidthChangeRef.current = onContentWidthChange;\n });\n\n const setContentRef = useCallback((node: HTMLDivElement | null) => {\n contentRef.current = node;\n }, []);\n\n useEffect(() => {\n const el = contentRef.current;\n if (!el) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const width = Math.round(entry.contentBoxSize[0]?.inlineSize ?? entry.contentRect.width);\n if (width > 0) {\n onContentWidthChangeRef.current?.(width);\n }\n }\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n\n const handleClose = () => onRequestDisplayMode?.('inline');\n\n return (\n <div\n className=\"flex flex-col w-full h-full flex-1 items-center relative\"\n style={{\n transform: 'translate(0)',\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n color: 'var(--color-text-primary)',\n fontFamily: 'var(--font-sans)',\n WebkitFontSmoothing: 'antialiased',\n }}\n >\n {/* ─── Fullscreen chrome overlay ─── */}\n {isFullscreen && (\n <div\n className=\"fixed start-0 end-0 top-0 bottom-0 z-[51] mx-auto flex flex-col pointer-events-none\"\n style={{ maxWidth: containerWidth }}\n >\n <div\n className=\"z-10 flex items-center h-12 border-b px-3 pointer-events-auto\"\n style={{\n borderColor: 'var(--color-border-primary)',\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n >\n <button\n onClick={handleClose}\n aria-label=\"Back\"\n className=\"h-8 w-8 flex items-center justify-center rounded-lg transition-colors hover:opacity-70\"\n type=\"button\"\n >\n <BackIcon />\n </button>\n <div className=\"flex-1 text-center text-sm font-medium\">{appName}</div>\n {isDesktop && <div className=\"w-8\" />}\n </div>\n <div className=\"flex-1\" />\n <footer\n className=\"pointer-events-auto p-3\"\n style={{\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n >\n <div className=\"max-w-[48rem] mx-auto\">\n <div\n className=\"relative rounded-[20px] px-4 py-2.5\"\n style={{\n backgroundColor: 'var(--sim-bg-reply-input, var(--color-background-secondary))',\n boxShadow:\n '0 4px 20px rgba(0, 0, 0, 0.035), 0 0 0 0.5px var(--color-border-tertiary)',\n }}\n >\n <div\n className=\"w-full text-base outline-none opacity-50\"\n style={{\n lineHeight: '1.4',\n color: 'var(--color-text-tertiary)',\n }}\n >\n Reply to sunpeak...\n </div>\n </div>\n </div>\n </footer>\n </div>\n )}\n\n {/* ─── Conversation header ─── */}\n {!isFullscreen && (\n <header\n className=\"h-12 flex items-center gap-3 px-4 text-sm font-medium sticky top-0 z-40 w-full\"\n style={{\n maxWidth: containerWidth,\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n >\n <span>sunpeak.ai</span>\n {headerAction}\n </header>\n )}\n\n {/* ─── Conversation container ─── */}\n <div\n className=\"flex flex-col flex-1 w-full transition-all duration-200 overflow-hidden\"\n style={{ maxWidth: containerWidth }}\n >\n <main className=\"flex-1 overflow-y-auto overflow-x-hidden\">\n {/* User turn */}\n {!isFullscreen && (\n <article className=\"w-full\" dir=\"auto\" data-turn=\"user\">\n <div className=\"px-4 py-4\">\n <div className=\"max-w-[48rem] mx-auto flex justify-end\">\n <div\n className=\"inline-flex rounded-xl max-w-[85%] break-words\"\n style={{\n padding: '10px 16px',\n lineHeight: '22.4px',\n fontSize: '16px',\n fontWeight: 430,\n backgroundColor:\n 'var(--sim-bg-user-bubble, var(--color-background-tertiary))',\n }}\n >\n {userMessage}\n </div>\n </div>\n </div>\n </article>\n )}\n\n {/* Assistant turn */}\n <article className=\"w-full\" dir=\"auto\" data-turn=\"assistant\">\n <h6 className=\"sr-only\">{appName} said:</h6>\n <div className=\"px-4 py-2\">\n <div className=\"max-w-[48rem] mx-auto\">\n {/* Claude avatar + name */}\n {!isFullscreen && (\n <div className=\"flex items-center gap-2 mb-3\">\n {appIcon ? (\n appIcon.startsWith('data:') || appIcon.startsWith('http') ? (\n <img src={appIcon} alt=\"\" className=\"size-6 rounded-full object-cover\" />\n ) : (\n <div className=\"size-6 flex items-center justify-center text-base\">\n {appIcon}\n </div>\n )\n ) : (\n <div\n className=\"size-6 rounded-full flex items-center justify-center text-xs font-medium text-white\"\n style={{ backgroundColor: '#c55a30' }}\n >\n C\n </div>\n )}\n <span className=\"text-sm font-medium\">{appName}</span>\n </div>\n )}\n\n {/* ─── CONTENT AREA ─── */}\n <div\n ref={setContentRef}\n className={\n isPip\n ? 'fixed start-4 end-4 top-12 z-50 mx-auto max-w-[40rem] lg:max-w-[48rem] sm:start-0 sm:end-0 sm:top-[3rem] sm:w-full overflow-visible'\n : isFullscreen\n ? 'fixed inset-x-0 top-[3rem] bottom-0 z-50 mx-auto'\n : 'relative mb-2 w-full overflow-visible'\n }\n style={{\n ...(isPip ? { maxHeight: '480px' } : {}),\n ...(isFullscreen ? { maxWidth: containerWidth } : {}),\n }}\n >\n {/* PiP close button */}\n {isPip && (\n <button\n key=\"pip-close\"\n onClick={handleClose}\n className=\"absolute -start-2 -top-1.5 z-10 rounded-full p-1.5 text-white shadow-md\"\n style={{ backgroundColor: '#4a4a4a' }}\n aria-label=\"Close picture-in-picture\"\n type=\"button\"\n >\n <CloseIcon />\n </button>\n )}\n <div\n key=\"content\"\n className={\n isPip\n ? 'relative overflow-hidden h-full rounded-2xl shadow-lg'\n : 'relative overflow-hidden h-full'\n }\n >\n <div\n className=\"h-full w-full max-w-full\"\n style={{\n ...(isPip\n ? {\n overflow: 'auto',\n backgroundColor: 'var(--color-background-secondary)',\n }\n : isFullscreen\n ? {\n overflow: 'auto',\n backgroundColor: 'var(--color-background-primary)',\n }\n : { backgroundColor: 'transparent' }),\n }}\n >\n {children}\n </div>\n </div>\n </div>\n </div>\n </div>\n </article>\n </main>\n\n {/* Input area */}\n {!isFullscreen && (\n <footer\n style={{\n backgroundColor: 'var(--sim-bg-conversation, var(--color-background-primary))',\n }}\n >\n <div className=\"max-w-[48rem] mx-auto px-4 py-4\">\n <div\n className=\"relative rounded-[20px] px-4 py-2.5\"\n style={{\n backgroundColor: 'var(--sim-bg-reply-input, var(--color-background-secondary))',\n boxShadow:\n '0 4px 20px rgba(0, 0, 0, 0.035), 0 0 0 0.5px var(--color-border-tertiary)',\n }}\n >\n <div\n className=\"w-full text-base outline-none opacity-50\"\n style={{\n lineHeight: '1.4',\n color: 'var(--color-text-tertiary)',\n }}\n >\n Reply to sunpeak...\n </div>\n </div>\n </div>\n </footer>\n )}\n </div>\n </div>\n );\n}\n","import type { McpUiHostCapabilities } from '@modelcontextprotocol/ext-apps';\nimport { registerHostShell } from '../inspector/hosts';\nimport { DEFAULT_STYLE_VARIABLES } from '../inspector/host-styles';\nimport { ClaudeConversation } from './claude-conversation';\n\n/**\n * Claude host version info — matches what Claude reports via the MCP protocol.\n * Verified against production Claude on 2026-03-25.\n */\nconst CLAUDE_HOST_INFO = {\n name: 'Claude',\n version: '1.0.0',\n};\n\n/**\n * Claude host capabilities — matches what Claude reports via the MCP protocol.\n * Verified against production Claude on 2026-03-25.\n *\n * Notable: Claude supports downloadFile, updateModelContext.image, and\n * message.text. serverTools and serverResources both report listChanged.\n * No sandbox.permissions (no microphone etc.). No PiP display mode.\n */\nconst CLAUDE_HOST_CAPABILITIES: McpUiHostCapabilities = {\n openLinks: {},\n downloadFile: {},\n serverTools: { listChanged: true },\n serverResources: { listChanged: true },\n logging: {},\n updateModelContext: { text: {}, image: {} },\n message: { text: {} },\n sandbox: {},\n};\n\n/**\n * Apply Claude-style theming to the document.\n * Sets data-theme attribute and color-scheme so CSS light-dark() resolves correctly.\n */\nfunction applyClaudeTheme(theme: 'light' | 'dark'): void {\n document.documentElement.setAttribute('data-theme', theme);\n document.documentElement.style.colorScheme = theme;\n}\n\n/**\n * Claude style variable overrides — warm beige/cream palette with Anthropic Sans.\n * Verified against production Claude on 2026-03-25.\n *\n * Only overrides values that differ from DEFAULT_STYLE_VARIABLES.\n * Claude sends all variables via styles.variables using light-dark(rgba()) format.\n */\nconst CLAUDE_STYLE_VARIABLES = {\n ...DEFAULT_STYLE_VARIABLES,\n\n // ── Background colors ──\n '--color-background-primary': 'light-dark(rgba(255, 255, 255, 1), rgba(48, 48, 46, 1))',\n '--color-background-secondary': 'light-dark(rgba(245, 244, 237, 1), rgba(38, 38, 36, 1))',\n '--color-background-tertiary': 'light-dark(rgba(250, 249, 245, 1), rgba(20, 20, 19, 1))',\n '--color-background-inverse': 'light-dark(rgba(20, 20, 19, 1), rgba(250, 249, 245, 1))',\n '--color-background-ghost': 'light-dark(rgba(255, 255, 255, 0), rgba(48, 48, 46, 0))',\n '--color-background-info': 'light-dark(rgba(214, 228, 246, 1), rgba(37, 62, 95, 1))',\n '--color-background-danger': 'light-dark(rgba(247, 236, 236, 1), rgba(96, 42, 40, 1))',\n '--color-background-success': 'light-dark(rgba(233, 241, 220, 1), rgba(27, 70, 20, 1))',\n '--color-background-warning': 'light-dark(rgba(246, 238, 223, 1), rgba(72, 58, 15, 1))',\n '--color-background-disabled': 'light-dark(rgba(255, 255, 255, 0.5), rgba(48, 48, 46, 0.5))',\n\n // ── Text colors ──\n '--color-text-primary': 'light-dark(rgba(20, 20, 19, 1), rgba(250, 249, 245, 1))',\n '--color-text-secondary': 'light-dark(rgba(61, 61, 58, 1), rgba(194, 192, 182, 1))',\n '--color-text-tertiary': 'light-dark(rgba(115, 114, 108, 1), rgba(156, 154, 146, 1))',\n '--color-text-inverse': 'light-dark(rgba(255, 255, 255, 1), rgba(20, 20, 19, 1))',\n '--color-text-ghost': 'light-dark(rgba(115, 114, 108, 0.5), rgba(156, 154, 146, 0.5))',\n '--color-text-info': 'light-dark(rgba(50, 102, 173, 1), rgba(128, 170, 221, 1))',\n '--color-text-danger': 'light-dark(rgba(127, 44, 40, 1), rgba(238, 136, 132, 1))',\n '--color-text-success': 'light-dark(rgba(38, 91, 25, 1), rgba(122, 185, 72, 1))',\n '--color-text-warning': 'light-dark(rgba(90, 72, 21, 1), rgba(209, 160, 65, 1))',\n '--color-text-disabled': 'light-dark(rgba(20, 20, 19, 0.5), rgba(250, 249, 245, 0.5))',\n\n // ── Border colors ──\n '--color-border-primary': 'light-dark(rgba(31, 30, 29, 0.4), rgba(222, 220, 209, 0.4))',\n '--color-border-secondary': 'light-dark(rgba(31, 30, 29, 0.3), rgba(222, 220, 209, 0.3))',\n '--color-border-tertiary': 'light-dark(rgba(31, 30, 29, 0.15), rgba(222, 220, 209, 0.15))',\n '--color-border-inverse': 'light-dark(rgba(255, 255, 255, 0.3), rgba(20, 20, 19, 0.15))',\n '--color-border-ghost': 'light-dark(rgba(31, 30, 29, 0), rgba(222, 220, 209, 0))',\n '--color-border-info': 'light-dark(rgba(70, 130, 213, 1), rgba(70, 130, 213, 1))',\n '--color-border-danger': 'light-dark(rgba(167, 61, 57, 1), rgba(205, 92, 88, 1))',\n '--color-border-success': 'light-dark(rgba(67, 116, 38, 1), rgba(89, 145, 48, 1))',\n '--color-border-warning': 'light-dark(rgba(128, 92, 31, 1), rgba(168, 120, 41, 1))',\n '--color-border-disabled': 'light-dark(rgba(31, 30, 29, 0.1), rgba(222, 220, 209, 0.1))',\n\n // ── Ring colors ──\n '--color-ring-primary': 'light-dark(rgba(20, 20, 19, 0.7), rgba(250, 249, 245, 0.7))',\n '--color-ring-secondary': 'light-dark(rgba(61, 61, 58, 0.7), rgba(194, 192, 182, 0.7))',\n '--color-ring-inverse': 'light-dark(rgba(255, 255, 255, 0.7), rgba(20, 20, 19, 0.7))',\n '--color-ring-info': 'light-dark(rgba(50, 102, 173, 0.5), rgba(128, 170, 221, 0.5))',\n '--color-ring-danger': 'light-dark(rgba(167, 61, 57, 0.5), rgba(205, 92, 88, 0.5))',\n '--color-ring-success': 'light-dark(rgba(67, 116, 38, 0.5), rgba(89, 145, 48, 0.5))',\n '--color-ring-warning': 'light-dark(rgba(128, 92, 31, 0.5), rgba(168, 120, 41, 0.5))',\n\n // ── Typography ──\n '--font-sans': '\"Anthropic Sans\", system-ui, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif',\n '--font-mono': 'ui-monospace, monospace',\n // Sizes (px, not rem — Claude uses fixed px values)\n '--font-text-xs-size': '12px',\n '--font-text-sm-size': '14px',\n '--font-text-md-size': '16px',\n '--font-text-lg-size': '20px',\n '--font-heading-xs-size': '12px',\n '--font-heading-sm-size': '14px',\n '--font-heading-md-size': '16px',\n '--font-heading-lg-size': '20px',\n '--font-heading-xl-size': '24px',\n '--font-heading-2xl-size': '28px',\n '--font-heading-3xl-size': '36px',\n // Line heights\n '--font-text-md-line-height': '1.4',\n '--font-text-lg-line-height': '1.25',\n '--font-heading-lg-line-height': '1.25',\n '--font-heading-2xl-line-height': '1.1',\n '--font-heading-3xl-line-height': '1',\n\n // ── Border radius (Claude uses slightly larger values) ──\n '--border-radius-xs': '4px',\n '--border-radius-sm': '6px',\n '--border-radius-md': '8px',\n '--border-radius-lg': '10px',\n\n // ── Border width ──\n '--border-width-regular': '0.5px',\n};\n\nregisterHostShell({\n id: 'claude',\n label: 'Claude',\n Conversation: ClaudeConversation,\n applyTheme: applyClaudeTheme,\n hostInfo: CLAUDE_HOST_INFO,\n hostCapabilities: CLAUDE_HOST_CAPABILITIES,\n styleVariables: CLAUDE_STYLE_VARIABLES,\n pageStyles: {\n '--sim-bg-sidebar': 'light-dark(rgb(250, 249, 245), rgb(38, 38, 36))',\n '--sim-bg-conversation': 'light-dark(rgb(250, 249, 245), rgb(38, 38, 36))',\n '--sim-bg-user-bubble': 'light-dark(rgb(240, 238, 230), rgb(20, 20, 19))',\n '--sim-bg-reply-input': 'light-dark(rgb(255, 255, 255), rgb(48, 48, 46))',\n },\n availableDisplayModes: ['inline', 'fullscreen'],\n fontCss: `@font-face {\n font-family: \"Anthropic Sans\";\n src: url(\"https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/cc27851ad-CFxw3nG7.woff2\") format(\"woff2\");\n font-weight: 300 800;\n font-style: normal;\n font-display: swap;\n font-feature-settings: \"dlig\" 0;\n}\n@font-face {\n font-family: \"Anthropic Sans\";\n src: url(\"https://assets-proxy.anthropic.com/claude-ai/v2/assets/v1/c9d3a3a49-BI1hrwN4.woff2\") format(\"woff2\");\n font-weight: 300 800;\n font-style: italic;\n font-display: swap;\n font-feature-settings: \"dlig\" 0;\n}`,\n});\n","import{CallToolRequestSchema as yQ,CallToolResultSchema as kQ,ListPromptsRequestSchema as fQ,ListPromptsResultSchema as dQ,ListResourcesRequestSchema as bQ,ListResourcesResultSchema as xQ,ListResourceTemplatesRequestSchema as uQ,ListResourceTemplatesResultSchema as hQ,LoggingMessageNotificationSchema as mQ,PingRequestSchema as pQ,PromptListChangedNotificationSchema as cQ,ReadResourceRequestSchema as nQ,ReadResourceResultSchema as iQ,ResourceListChangedNotificationSchema as lQ,ToolListChangedNotificationSchema as rQ}from\"@modelcontextprotocol/sdk/types.js\";import{Protocol as oQ}from\"@modelcontextprotocol/sdk/shared/protocol.js\";var G=\"2026-01-26\",s=\"ui/open-link\",e=\"ui/download-file\",QQ=\"ui/message\",XQ=\"ui/notifications/sandbox-proxy-ready\",YQ=\"ui/notifications/sandbox-resource-ready\",ZQ=\"ui/notifications/size-changed\",$Q=\"ui/notifications/tool-input\",_=\"ui/notifications/tool-input-partial\",JQ=\"ui/notifications/tool-result\",KQ=\"ui/notifications/tool-cancelled\",GQ=\"ui/notifications/host-context-changed\",DQ=\"ui/notifications/request-teardown\",NQ=\"ui/resource-teardown\",jQ=\"ui/initialize\",EQ=\"ui/notifications/initialized\",WQ=\"ui/request-display-mode\";import{z as Q}from\"zod/v4\";import{ContentBlockSchema as h,CallToolResultSchema as zQ,EmbeddedResourceSchema as BQ,ImplementationSchema as m,RequestIdSchema as _Q,ResourceLinkSchema as OQ,ToolSchema as VQ}from\"@modelcontextprotocol/sdk/types.js\";var p=Q.union([Q.literal(\"light\"),Q.literal(\"dark\")]).describe(\"Color theme preference for the host environment.\"),D=Q.union([Q.literal(\"inline\"),Q.literal(\"fullscreen\"),Q.literal(\"pip\")]).describe(\"Display mode for UI presentation.\"),IQ=Q.union([Q.literal(\"--color-background-primary\"),Q.literal(\"--color-background-secondary\"),Q.literal(\"--color-background-tertiary\"),Q.literal(\"--color-background-inverse\"),Q.literal(\"--color-background-ghost\"),Q.literal(\"--color-background-info\"),Q.literal(\"--color-background-danger\"),Q.literal(\"--color-background-success\"),Q.literal(\"--color-background-warning\"),Q.literal(\"--color-background-disabled\"),Q.literal(\"--color-text-primary\"),Q.literal(\"--color-text-secondary\"),Q.literal(\"--color-text-tertiary\"),Q.literal(\"--color-text-inverse\"),Q.literal(\"--color-text-ghost\"),Q.literal(\"--color-text-info\"),Q.literal(\"--color-text-danger\"),Q.literal(\"--color-text-success\"),Q.literal(\"--color-text-warning\"),Q.literal(\"--color-text-disabled\"),Q.literal(\"--color-border-primary\"),Q.literal(\"--color-border-secondary\"),Q.literal(\"--color-border-tertiary\"),Q.literal(\"--color-border-inverse\"),Q.literal(\"--color-border-ghost\"),Q.literal(\"--color-border-info\"),Q.literal(\"--color-border-danger\"),Q.literal(\"--color-border-success\"),Q.literal(\"--color-border-warning\"),Q.literal(\"--color-border-disabled\"),Q.literal(\"--color-ring-primary\"),Q.literal(\"--color-ring-secondary\"),Q.literal(\"--color-ring-inverse\"),Q.literal(\"--color-ring-info\"),Q.literal(\"--color-ring-danger\"),Q.literal(\"--color-ring-success\"),Q.literal(\"--color-ring-warning\"),Q.literal(\"--font-sans\"),Q.literal(\"--font-mono\"),Q.literal(\"--font-weight-normal\"),Q.literal(\"--font-weight-medium\"),Q.literal(\"--font-weight-semibold\"),Q.literal(\"--font-weight-bold\"),Q.literal(\"--font-text-xs-size\"),Q.literal(\"--font-text-sm-size\"),Q.literal(\"--font-text-md-size\"),Q.literal(\"--font-text-lg-size\"),Q.literal(\"--font-heading-xs-size\"),Q.literal(\"--font-heading-sm-size\"),Q.literal(\"--font-heading-md-size\"),Q.literal(\"--font-heading-lg-size\"),Q.literal(\"--font-heading-xl-size\"),Q.literal(\"--font-heading-2xl-size\"),Q.literal(\"--font-heading-3xl-size\"),Q.literal(\"--font-text-xs-line-height\"),Q.literal(\"--font-text-sm-line-height\"),Q.literal(\"--font-text-md-line-height\"),Q.literal(\"--font-text-lg-line-height\"),Q.literal(\"--font-heading-xs-line-height\"),Q.literal(\"--font-heading-sm-line-height\"),Q.literal(\"--font-heading-md-line-height\"),Q.literal(\"--font-heading-lg-line-height\"),Q.literal(\"--font-heading-xl-line-height\"),Q.literal(\"--font-heading-2xl-line-height\"),Q.literal(\"--font-heading-3xl-line-height\"),Q.literal(\"--border-radius-xs\"),Q.literal(\"--border-radius-sm\"),Q.literal(\"--border-radius-md\"),Q.literal(\"--border-radius-lg\"),Q.literal(\"--border-radius-xl\"),Q.literal(\"--border-radius-full\"),Q.literal(\"--border-width-regular\"),Q.literal(\"--shadow-hairline\"),Q.literal(\"--shadow-sm\"),Q.literal(\"--shadow-md\"),Q.literal(\"--shadow-lg\")]).describe(\"CSS variable keys available to MCP apps for theming.\"),AQ=Q.record(IQ.describe(`Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses \\`Record<K, string | undefined>\\` rather than \\`Partial<Record<K, string>>\\`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Q.union([Q.string(),Q.undefined()]).describe(`Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses \\`Record<K, string | undefined>\\` rather than \\`Partial<Record<K, string>>\\`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses \\`Record<K, string | undefined>\\` rather than \\`Partial<Record<K, string>>\\`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.`),V=Q.object({method:Q.literal(\"ui/open-link\"),params:Q.object({url:Q.string().describe(\"URL to open in the host's browser\")})}),I=Q.object({isError:Q.boolean().optional().describe(\"True if the host failed to open the URL (e.g., due to security policy).\")}).passthrough(),A=Q.object({isError:Q.boolean().optional().describe(\"True if the download failed (e.g., user cancelled or host denied).\")}).passthrough(),F=Q.object({isError:Q.boolean().optional().describe(\"True if the host rejected or failed to deliver the message.\")}).passthrough(),L=Q.object({method:Q.literal(\"ui/notifications/sandbox-proxy-ready\"),params:Q.object({})}),j=Q.object({connectDomains:Q.array(Q.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).\n\n- Maps to CSP \\`connect-src\\` directive\n- Empty or omitted → no network connections (secure default)`),resourceDomains:Q.array(Q.string()).optional().describe(\"Origins for static resources (images, scripts, stylesheets, fonts, media).\\n\\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\\n- Wildcard subdomains supported: `https://*.example.com`\\n- Empty or omitted → no network resources (secure default)\"),frameDomains:Q.array(Q.string()).optional().describe(\"Origins for nested iframes.\\n\\n- Maps to CSP `frame-src` directive\\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)\"),baseUriDomains:Q.array(Q.string()).optional().describe(\"Allowed base URIs for the document.\\n\\n- Maps to CSP `base-uri` directive\\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)\")}),E=Q.object({camera:Q.object({}).optional().describe(\"Request camera access.\\n\\nMaps to Permission Policy `camera` feature.\"),microphone:Q.object({}).optional().describe(\"Request microphone access.\\n\\nMaps to Permission Policy `microphone` feature.\"),geolocation:Q.object({}).optional().describe(\"Request geolocation access.\\n\\nMaps to Permission Policy `geolocation` feature.\"),clipboardWrite:Q.object({}).optional().describe(\"Request clipboard write access.\\n\\nMaps to Permission Policy `clipboard-write` feature.\")}),P=Q.object({method:Q.literal(\"ui/notifications/size-changed\"),params:Q.object({width:Q.number().optional().describe(\"New width in pixels.\"),height:Q.number().optional().describe(\"New height in pixels.\")})}),T=Q.object({method:Q.literal(\"ui/notifications/tool-input\"),params:Q.object({arguments:Q.record(Q.string(),Q.unknown().describe(\"Complete tool call arguments as key-value pairs.\")).optional().describe(\"Complete tool call arguments as key-value pairs.\")})}),w=Q.object({method:Q.literal(\"ui/notifications/tool-input-partial\"),params:Q.object({arguments:Q.record(Q.string(),Q.unknown().describe(\"Partial tool call arguments (incomplete, may change).\")).optional().describe(\"Partial tool call arguments (incomplete, may change).\")})}),R=Q.object({method:Q.literal(\"ui/notifications/tool-cancelled\"),params:Q.object({reason:Q.string().optional().describe('Optional reason for the cancellation (e.g., \"user action\", \"timeout\").')})}),c=Q.object({fonts:Q.string().optional()}),n=Q.object({variables:AQ.optional().describe(\"CSS variables for theming the app.\"),css:c.optional().describe(\"CSS blocks that apps can inject.\")}),U=Q.object({method:Q.literal(\"ui/resource-teardown\"),params:Q.object({})}),H=Q.record(Q.string(),Q.unknown()),O=Q.object({text:Q.object({}).optional().describe(\"Host supports text content blocks.\"),image:Q.object({}).optional().describe(\"Host supports image content blocks.\"),audio:Q.object({}).optional().describe(\"Host supports audio content blocks.\"),resource:Q.object({}).optional().describe(\"Host supports resource content blocks.\"),resourceLink:Q.object({}).optional().describe(\"Host supports resource link content blocks.\"),structuredContent:Q.object({}).optional().describe(\"Host supports structured content.\")}),M=Q.object({method:Q.literal(\"ui/notifications/request-teardown\"),params:Q.object({}).optional()}),i=Q.object({experimental:Q.object({}).optional().describe(\"Experimental features (structure TBD).\"),openLinks:Q.object({}).optional().describe(\"Host supports opening external URLs.\"),downloadFile:Q.object({}).optional().describe(\"Host supports file downloads via ui/download-file.\"),serverTools:Q.object({listChanged:Q.boolean().optional().describe(\"Host supports tools/list_changed notifications.\")}).optional().describe(\"Host can proxy tool calls to the MCP server.\"),serverResources:Q.object({listChanged:Q.boolean().optional().describe(\"Host supports resources/list_changed notifications.\")}).optional().describe(\"Host can proxy resource reads to the MCP server.\"),logging:Q.object({}).optional().describe(\"Host accepts log messages.\"),sandbox:Q.object({permissions:E.optional().describe(\"Permissions granted by the host (camera, microphone, geolocation).\"),csp:j.optional().describe(\"CSP domains approved by the host.\")}).optional().describe(\"Sandbox configuration applied by the host.\"),updateModelContext:O.optional().describe(\"Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.\"),message:O.optional().describe(\"Host supports receiving content messages (ui/message) from the view.\")}),l=Q.object({experimental:Q.object({}).optional().describe(\"Experimental features (structure TBD).\"),tools:Q.object({listChanged:Q.boolean().optional().describe(\"App supports tools/list_changed notifications.\")}).optional().describe(\"App exposes MCP-style tools that the host can call.\"),availableDisplayModes:Q.array(D).optional().describe(\"Display modes the app supports.\")}),v=Q.object({method:Q.literal(\"ui/notifications/initialized\"),params:Q.object({}).optional()}),FQ=Q.object({csp:j.optional().describe(\"Content Security Policy configuration for UI resources.\"),permissions:E.optional().describe(\"Sandbox permissions requested by the UI resource.\"),domain:Q.string().optional().describe(`Dedicated origin for view sandbox.\n\nUseful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.\n\n**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:\n- Hash-based subdomains (e.g., \\`{hash}.claudemcpcontent.com\\`)\n- URL-derived subdomains (e.g., \\`www-example-com.oaiusercontent.com\\`)\n\nIf omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:Q.boolean().optional().describe(`Visual boundary preference - true if view prefers a visible border.\n\nBoolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.\n\n- \\`true\\`: request visible border + background\n- \\`false\\`: request no visible border + background\n- omitted: host decides border`)}),W=Q.object({method:Q.literal(\"ui/request-display-mode\"),params:Q.object({mode:D.describe(\"The display mode being requested.\")})}),g=Q.object({mode:D.describe(\"The display mode that was actually set. May differ from requested if not supported.\")}).passthrough(),r=Q.union([Q.literal(\"model\"),Q.literal(\"app\")]).describe(\"Tool visibility scope - who can access the tool.\"),LQ=Q.object({resourceUri:Q.string().optional(),visibility:Q.array(r).optional().describe(`Who can access this tool. Default: [\"model\", \"app\"]\n- \"model\": Tool visible to and callable by the agent\n- \"app\": Tool callable by the app from this server only`)}),YX=Q.object({mimeTypes:Q.array(Q.string()).optional().describe('Array of supported MIME types for UI resources.\\nMust include `\"text/html;profile=mcp-app\"` for MCP Apps support.')}),C=Q.object({method:Q.literal(\"ui/download-file\"),params:Q.object({contents:Q.array(Q.union([BQ,OQ])).describe(\"Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.\")})}),S=Q.object({method:Q.literal(\"ui/message\"),params:Q.object({role:Q.literal(\"user\").describe('Message role, currently only \"user\" is supported.'),content:Q.array(h).describe(\"Message content blocks (text, image, etc.).\")})}),PQ=Q.object({method:Q.literal(\"ui/notifications/sandbox-resource-ready\"),params:Q.object({html:Q.string().describe(\"HTML content to load into the inner iframe.\"),sandbox:Q.string().optional().describe(\"Optional override for the inner iframe's sandbox attribute.\"),csp:j.optional().describe(\"CSP configuration from resource metadata.\"),permissions:E.optional().describe(\"Sandbox permissions from resource metadata.\")})}),q=Q.object({method:Q.literal(\"ui/notifications/tool-result\"),params:zQ.describe(\"Standard MCP tool execution result.\")}),y=Q.object({toolInfo:Q.object({id:_Q.optional().describe(\"JSON-RPC id of the tools/call request.\"),tool:VQ.describe(\"Tool definition including name, inputSchema, etc.\")}).optional().describe(\"Metadata of the tool call that instantiated this App.\"),theme:p.optional().describe(\"Current color theme preference.\"),styles:n.optional().describe(\"Style configuration for theming the app.\"),displayMode:D.optional().describe(\"How the UI is currently displayed.\"),availableDisplayModes:Q.array(D).optional().describe(\"Display modes the host supports.\"),containerDimensions:Q.union([Q.object({height:Q.number().describe(\"Fixed container height in pixels.\")}),Q.object({maxHeight:Q.union([Q.number(),Q.undefined()]).optional().describe(\"Maximum container height in pixels.\")})]).and(Q.union([Q.object({width:Q.number().describe(\"Fixed container width in pixels.\")}),Q.object({maxWidth:Q.union([Q.number(),Q.undefined()]).optional().describe(\"Maximum container width in pixels.\")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other\ncontainer holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:Q.string().optional().describe(\"User's language and region preference in BCP 47 format.\"),timeZone:Q.string().optional().describe(\"User's timezone in IANA format.\"),userAgent:Q.string().optional().describe(\"Host application identifier.\"),platform:Q.union([Q.literal(\"web\"),Q.literal(\"desktop\"),Q.literal(\"mobile\")]).optional().describe(\"Platform type for responsive design decisions.\"),deviceCapabilities:Q.object({touch:Q.boolean().optional().describe(\"Whether the device supports touch input.\"),hover:Q.boolean().optional().describe(\"Whether the device supports hover interactions.\")}).optional().describe(\"Device input capabilities.\"),safeAreaInsets:Q.object({top:Q.number().describe(\"Top safe area inset in pixels.\"),right:Q.number().describe(\"Right safe area inset in pixels.\"),bottom:Q.number().describe(\"Bottom safe area inset in pixels.\"),left:Q.number().describe(\"Left safe area inset in pixels.\")}).optional().describe(\"Mobile safe area boundaries in pixels.\")}).passthrough(),k=Q.object({method:Q.literal(\"ui/notifications/host-context-changed\"),params:y.describe(\"Partial context update containing only changed fields.\")}),f=Q.object({method:Q.literal(\"ui/update-model-context\"),params:Q.object({content:Q.array(h).optional().describe(\"Context content blocks (text, image, etc.).\"),structuredContent:Q.record(Q.string(),Q.unknown().describe(\"Structured content for machine-readable context data.\")).optional().describe(\"Structured content for machine-readable context data.\")})}),d=Q.object({method:Q.literal(\"ui/initialize\"),params:Q.object({appInfo:m.describe(\"App identification (name and version).\"),appCapabilities:l.describe(\"Features and capabilities this app provides.\"),protocolVersion:Q.string().describe(\"Protocol version this app supports.\")})}),b=Q.object({protocolVersion:Q.string().describe('Negotiated protocol version string (e.g., \"2025-11-21\").'),hostInfo:m.describe(\"Host application identification and version.\"),hostCapabilities:i.describe(\"Features and capabilities provided by the host.\"),hostContext:y.describe(\"Rich context about the host environment.\")}).passthrough();import{Protocol as wQ}from\"@modelcontextprotocol/sdk/shared/protocol.js\";import{CallToolRequestSchema as RQ,CallToolResultSchema as UQ,EmptyResultSchema as HQ,ListResourcesResultSchema as MQ,ListToolsRequestSchema as vQ,PingRequestSchema as gQ,ReadResourceResultSchema as CQ}from\"@modelcontextprotocol/sdk/types.js\";import{JSONRPCMessageSchema as TQ}from\"@modelcontextprotocol/sdk/types.js\";class N{eventTarget;eventSource;messageListener;constructor(X=window.parent,Y){this.eventTarget=X;this.eventSource=Y;this.messageListener=(Z)=>{if(Y&&Z.source!==this.eventSource){console.debug(\"Ignoring message from unknown source\",Z);return}let $=TQ.safeParse(Z.data);if($.success)console.debug(\"Parsed message\",$.data),this.onmessage?.($.data);else if(Z.data?.jsonrpc!==\"2.0\")console.debug(\"Ignoring non-JSON-RPC message\",$.error.message,Z);else console.error(\"Failed to parse message\",$.error.message,Z),this.onerror?.(Error(\"Invalid JSON-RPC message received: \"+$.error.message))}}async start(){window.addEventListener(\"message\",this.messageListener)}async send(X,Y){if(X.method!==_)console.debug(\"Sending message\",X);this.eventTarget.postMessage(X,\"*\")}async close(){window.removeEventListener(\"message\",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var x=\"ui/resourceUri\",SQ=\"text/html;profile=mcp-app\";class qQ extends wQ{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;constructor(X,Y={},Z={autoResize:!0}){super(Z);this._appInfo=X;this._capabilities=Y;this.options=Z;this.setRequestHandler(gQ,($)=>{return console.log(\"Received ping:\",$.params),{}}),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(X){this.setNotificationHandler(T,(Y)=>X(Y.params))}set ontoolinputpartial(X){this.setNotificationHandler(w,(Y)=>X(Y.params))}set ontoolresult(X){this.setNotificationHandler(q,(Y)=>X(Y.params))}set ontoolcancelled(X){this.setNotificationHandler(R,(Y)=>X(Y.params))}set onhostcontextchanged(X){this.setNotificationHandler(k,(Y)=>{this._hostContext={...this._hostContext,...Y.params},X(Y.params)})}set onteardown(X){this.setRequestHandler(U,(Y,Z)=>X(Y.params,Z))}set oncalltool(X){this.setRequestHandler(RQ,(Y,Z)=>X(Y.params,Z))}set onlisttools(X){this.setRequestHandler(vQ,(Y,Z)=>X(Y.params,Z))}assertCapabilityForMethod(X){}assertRequestHandlerCapability(X){switch(X){case\"tools/call\":case\"tools/list\":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${X})`);return;case\"ping\":case\"ui/resource-teardown\":return;default:throw Error(`No handler for method ${X} registered`)}}assertNotificationCapability(X){}assertTaskCapability(X){throw Error(\"Tasks are not supported in MCP Apps\")}assertTaskHandlerCapability(X){throw Error(\"Task handlers are not supported in MCP Apps\")}async callServerTool(X,Y){if(typeof X===\"string\")throw Error(`callServerTool() expects an object as its first argument, but received a string (\"${X}\"). Did you mean: callServerTool({ name: \"${X}\", arguments: { ... } })?`);return await this.request({method:\"tools/call\",params:X},UQ,Y)}async readServerResource(X,Y){return await this.request({method:\"resources/read\",params:X},CQ,Y)}async listServerResources(X,Y){return await this.request({method:\"resources/list\",params:X},MQ,Y)}sendMessage(X,Y){return this.request({method:\"ui/message\",params:X},F,Y)}sendLog(X){return this.notification({method:\"notifications/message\",params:X})}updateModelContext(X,Y){return this.request({method:\"ui/update-model-context\",params:X},HQ,Y)}openLink(X,Y){return this.request({method:\"ui/open-link\",params:X},I,Y)}sendOpenLink=this.openLink;downloadFile(X,Y){return this.request({method:\"ui/download-file\",params:X},A,Y)}requestTeardown(X={}){return this.notification({method:\"ui/notifications/request-teardown\",params:X})}requestDisplayMode(X,Y){return this.request({method:\"ui/request-display-mode\",params:X},g,Y)}sendSizeChanged(X){return this.notification({method:\"ui/notifications/size-changed\",params:X})}setupSizeChangedNotifications(){let X=!1,Y=0,Z=0,$=()=>{if(X)return;X=!0,requestAnimationFrame(()=>{X=!1;let J=document.documentElement,o=J.style.width,a=J.style.height;J.style.width=\"fit-content\",J.style.height=\"max-content\";let u=J.getBoundingClientRect();J.style.width=o,J.style.height=a;let t=window.innerWidth-J.clientWidth,z=Math.ceil(u.width+t),B=Math.ceil(u.height);if(z!==Y||B!==Z)Y=z,Z=B,this.sendSizeChanged({width:z,height:B})})};$();let K=new ResizeObserver($);return K.observe(document.documentElement),K.observe(document.body),()=>K.disconnect()}async connect(X=new N(window.parent,window.parent),Y){if(this.transport)throw Error(\"App is already connected. Call close() before connecting again.\");await super.connect(X);try{let Z=await this.request({method:\"ui/initialize\",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:G}},b,Y);if(Z===void 0)throw Error(`Server sent invalid initialize result: ${Z}`);if(this._hostCapabilities=Z.hostCapabilities,this._hostInfo=Z.hostInfo,this._hostContext=Z.hostContext,await this.notification({method:\"ui/notifications/initialized\"}),this.options?.autoResize)this.setupSizeChangedNotifications()}catch(Z){throw this.close(),Z}}}function nY(X){let Z=X._meta?.ui?.resourceUri;if(Z===void 0)Z=X._meta?.[x];if(typeof Z===\"string\"&&Z.startsWith(\"ui://\"))return Z;else if(Z!==void 0)throw Error(`Invalid UI resource URI: ${JSON.stringify(Z)}`);return}function iY(X){let Z=X._meta?.ui?.visibility;if(!Z)return!1;if(Z.length===1&&Z[0]===\"model\")return!0;return!1}function lY(X){let Z=X._meta?.ui?.visibility;if(!Z)return!1;if(Z.length===1&&Z[0]===\"app\")return!0;return!1}function rY(X){if(!X)return\"\";let Y=[];if(X.camera)Y.push(\"camera\");if(X.microphone)Y.push(\"microphone\");if(X.geolocation)Y.push(\"geolocation\");if(X.clipboardWrite)Y.push(\"clipboard-write\");return Y.join(\"; \")}var aQ=[G];class tQ extends oQ{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;constructor(X,Y,Z,$){super($);this._client=X;this._hostInfo=Y;this._capabilities=Z;this._hostContext=$?.hostContext||{},this.setRequestHandler(d,(K)=>this._oninitialize(K)),this.setRequestHandler(pQ,(K,J)=>{return this.onping?.(K.params,J),{}}),this.setRequestHandler(W,(K)=>{return{mode:this._hostContext.displayMode??\"inline\"}})}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;set onsizechange(X){this.setNotificationHandler(P,(Y)=>X(Y.params))}set onsandboxready(X){this.setNotificationHandler(L,(Y)=>X(Y.params))}set oninitialized(X){this.setNotificationHandler(v,(Y)=>X(Y.params))}set onmessage(X){this.setRequestHandler(S,async(Y,Z)=>{return X(Y.params,Z)})}set onopenlink(X){this.setRequestHandler(V,async(Y,Z)=>{return X(Y.params,Z)})}set ondownloadfile(X){this.setRequestHandler(C,async(Y,Z)=>{return X(Y.params,Z)})}set onrequestteardown(X){this.setNotificationHandler(M,(Y)=>X(Y.params))}set onrequestdisplaymode(X){this.setRequestHandler(W,async(Y,Z)=>{return X(Y.params,Z)})}set onloggingmessage(X){this.setNotificationHandler(mQ,async(Y)=>{X(Y.params)})}set onupdatemodelcontext(X){this.setRequestHandler(f,async(Y,Z)=>{return X(Y.params,Z)})}set oncalltool(X){this.setRequestHandler(yQ,async(Y,Z)=>{return X(Y.params,Z)})}sendToolListChanged(X={}){return this.notification({method:\"notifications/tools/list_changed\",params:X})}set onlistresources(X){this.setRequestHandler(bQ,async(Y,Z)=>{return X(Y.params,Z)})}set onlistresourcetemplates(X){this.setRequestHandler(uQ,async(Y,Z)=>{return X(Y.params,Z)})}set onreadresource(X){this.setRequestHandler(nQ,async(Y,Z)=>{return X(Y.params,Z)})}sendResourceListChanged(X={}){return this.notification({method:\"notifications/resources/list_changed\",params:X})}set onlistprompts(X){this.setRequestHandler(fQ,async(Y,Z)=>{return X(Y.params,Z)})}sendPromptListChanged(X={}){return this.notification({method:\"notifications/prompts/list_changed\",params:X})}assertCapabilityForMethod(X){}assertRequestHandlerCapability(X){}assertNotificationCapability(X){}assertTaskCapability(X){throw Error(\"Tasks are not supported in MCP Apps\")}assertTaskHandlerCapability(X){throw Error(\"Task handlers are not supported in MCP Apps\")}getCapabilities(){return this._capabilities}async _oninitialize(X){let Y=X.params.protocolVersion;return this._appCapabilities=X.params.appCapabilities,this._appInfo=X.params.appInfo,{protocolVersion:aQ.includes(Y)?Y:G,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(X){let Y={},Z=!1;for(let $ of Object.keys(X)){let K=this._hostContext[$],J=X[$];if(sQ(K,J))continue;Y[$]=J,Z=!0}if(Z)this._hostContext=X,this.sendHostContextChange(Y)}sendHostContextChange(X){return this.notification({method:\"ui/notifications/host-context-changed\",params:X})}sendToolInput(X){return this.notification({method:\"ui/notifications/tool-input\",params:X})}sendToolInputPartial(X){return this.notification({method:\"ui/notifications/tool-input-partial\",params:X})}sendToolResult(X){return this.notification({method:\"ui/notifications/tool-result\",params:X})}sendToolCancelled(X){return this.notification({method:\"ui/notifications/tool-cancelled\",params:X})}sendSandboxResourceReady(X){return this.notification({method:\"ui/notifications/sandbox-resource-ready\",params:X})}teardownResource(X,Y){return this.request({method:\"ui/resource-teardown\",params:X},H,Y)}sendResourceTeardown=this.teardownResource;async connect(X){if(this.transport)throw Error(\"AppBridge is already connected. Call close() before connecting again.\");if(this._client){let Y=this._client.getServerCapabilities();if(!Y)throw Error(\"Client server capabilities not available\");if(Y.tools){if(this.oncalltool=async(Z,$)=>{return this._client.request({method:\"tools/call\",params:Z},kQ,{signal:$.signal})},Y.tools.listChanged)this._client.setNotificationHandler(rQ,(Z)=>this.sendToolListChanged(Z.params))}if(Y.resources){if(this.onlistresources=async(Z,$)=>{return this._client.request({method:\"resources/list\",params:Z},xQ,{signal:$.signal})},this.onlistresourcetemplates=async(Z,$)=>{return this._client.request({method:\"resources/templates/list\",params:Z},hQ,{signal:$.signal})},this.onreadresource=async(Z,$)=>{return this._client.request({method:\"resources/read\",params:Z},iQ,{signal:$.signal})},Y.resources.listChanged)this._client.setNotificationHandler(lQ,(Z)=>this.sendResourceListChanged(Z.params))}if(Y.prompts){if(this.onlistprompts=async(Z,$)=>{return this._client.request({method:\"prompts/list\",params:Z},dQ,{signal:$.signal})},Y.prompts.listChanged)this._client.setNotificationHandler(cQ,(Z)=>this.sendPromptListChanged(Z.params))}}return super.connect(X)}}function sQ(X,Y){return JSON.stringify(X)===JSON.stringify(Y)}export{iY as isToolVisibilityModelOnly,lY as isToolVisibilityAppOnly,nY as getToolUiResourceUri,rY as buildAllowAttribute,JQ as TOOL_RESULT_METHOD,_ as TOOL_INPUT_PARTIAL_METHOD,$Q as TOOL_INPUT_METHOD,KQ as TOOL_CANCELLED_METHOD,aQ as SUPPORTED_PROTOCOL_VERSIONS,ZQ as SIZE_CHANGED_METHOD,YQ as SANDBOX_RESOURCE_READY_METHOD,XQ as SANDBOX_PROXY_READY_METHOD,x as RESOURCE_URI_META_KEY,NQ as RESOURCE_TEARDOWN_METHOD,SQ as RESOURCE_MIME_TYPE,DQ as REQUEST_TEARDOWN_METHOD,WQ as REQUEST_DISPLAY_MODE_METHOD,N as PostMessageTransport,s as OPEN_LINK_METHOD,f as McpUiUpdateModelContextRequestSchema,r as McpUiToolVisibilitySchema,q as McpUiToolResultNotificationSchema,LQ as McpUiToolMetaSchema,w as McpUiToolInputPartialNotificationSchema,T as McpUiToolInputNotificationSchema,R as McpUiToolCancelledNotificationSchema,p as McpUiThemeSchema,O as McpUiSupportedContentBlockModalitiesSchema,P as McpUiSizeChangedNotificationSchema,PQ as McpUiSandboxResourceReadyNotificationSchema,L as McpUiSandboxProxyReadyNotificationSchema,H as McpUiResourceTeardownResultSchema,U as McpUiResourceTeardownRequestSchema,E as McpUiResourcePermissionsSchema,FQ as McpUiResourceMetaSchema,j as McpUiResourceCspSchema,M as McpUiRequestTeardownNotificationSchema,g as McpUiRequestDisplayModeResultSchema,W as McpUiRequestDisplayModeRequestSchema,I as McpUiOpenLinkResultSchema,V as McpUiOpenLinkRequestSchema,F as McpUiMessageResultSchema,S as McpUiMessageRequestSchema,v as McpUiInitializedNotificationSchema,b as McpUiInitializeResultSchema,d as McpUiInitializeRequestSchema,n as McpUiHostStylesSchema,c as McpUiHostCssSchema,y as McpUiHostContextSchema,k as McpUiHostContextChangedNotificationSchema,i as McpUiHostCapabilitiesSchema,A as McpUiDownloadFileResultSchema,C as McpUiDownloadFileRequestSchema,D as McpUiDisplayModeSchema,l as McpUiAppCapabilitiesSchema,QQ as MESSAGE_METHOD,G as LATEST_PROTOCOL_VERSION,jQ as INITIALIZE_METHOD,EQ as INITIALIZED_METHOD,GQ as HOST_CONTEXT_CHANGED_METHOD,e as DOWNLOAD_FILE_METHOD,tQ as AppBridge};\n","import {\n AppBridge,\n PostMessageTransport,\n type McpUiHostContext,\n type McpUiDisplayMode,\n type McpUiHostCapabilities,\n type McpUiToolInputNotification,\n type McpUiToolInputPartialNotification,\n type McpUiToolResultNotification,\n type McpUiToolCancelledNotification,\n} from '@modelcontextprotocol/ext-apps/app-bridge';\nimport type {\n CallToolRequest,\n CallToolResult,\n LoggingMessageNotification,\n} from '@modelcontextprotocol/sdk/types.js';\n\nconst DEFAULT_HOST_INFO = { name: 'SunpeakInspector', version: '1.0.0' };\n\nconst DEFAULT_HOST_CAPABILITIES: McpUiHostCapabilities = {\n openLinks: {},\n serverTools: {},\n serverResources: {},\n downloadFile: {},\n logging: {},\n updateModelContext: { text: {} },\n message: { text: {} },\n sandbox: {},\n};\n\nexport interface McpAppHostOptions {\n hostContext?: McpUiHostContext;\n /** Host info reported to the app via MCP protocol. Defaults to SunpeakInspector. */\n hostInfo?: { name: string; version: string };\n /** Host capabilities reported to the app. Defaults to baseline MCP capabilities. */\n hostCapabilities?: McpUiHostCapabilities;\n onDisplayModeChange?: (mode: McpUiDisplayMode) => void;\n onMessage?: (role: string, content: unknown[]) => void;\n onOpenLink?: (url: string) => void;\n onUpdateModelContext?: (content: unknown[], structuredContent?: unknown) => void;\n onSizeChanged?: (params: { width?: number; height?: number }) => void;\n onLog?: (params: LoggingMessageNotification['params']) => void;\n onCallTool?: (params: CallToolRequest['params']) => CallToolResult | Promise<CallToolResult>;\n onDownloadFile?: (contents: unknown[]) => void;\n /** Called when the app requests teardown (app-initiated close). */\n onRequestTeardown?: () => void;\n /** Called after the iframe confirms rendering in a new display mode (paint fence resolved). */\n onDisplayModeReady?: (mode: string) => void;\n /**\n * Called when the sandbox proxy signals readiness (double-iframe mode).\n * The host should respond by sending HTML content via sendSandboxResourceReady().\n */\n onSandboxReady?: () => void;\n}\n\n/**\n * MCP Apps host for the Sunpeak inspector.\n * Wraps AppBridge to provide a simpler API for the inspector.\n * Connects to an iframe via PostMessageTransport.\n */\nexport class McpAppHost {\n private bridge: AppBridge;\n private options: McpAppHostOptions;\n private _initialized = false;\n private _contentWindow: Window | null = null;\n private _fenceId = 0;\n private _fenceCleanup: (() => void) | null = null;\n private _prevDisplayMode: string | undefined;\n private _pendingToolInput: McpUiToolInputNotification['params'] | null = null;\n private _pendingToolResult: McpUiToolResultNotification['params'] | null = null;\n private _messageListener: ((event: MessageEvent) => void) | null = null;\n\n constructor(options: McpAppHostOptions = {}) {\n this.options = options;\n this._prevDisplayMode = options.hostContext?.displayMode;\n\n const hostInfo = options.hostInfo ?? DEFAULT_HOST_INFO;\n const hostCapabilities = options.hostCapabilities ?? DEFAULT_HOST_CAPABILITIES;\n this.bridge = new AppBridge(null, hostInfo, hostCapabilities, {\n hostContext: options.hostContext,\n });\n\n this.bridge.oninitialized = () => {\n this._initialized = true;\n\n // Flush any data that was sent before initialization completed\n if (this._pendingToolInput) {\n this.bridge.sendToolInput(this._pendingToolInput);\n this._pendingToolInput = null;\n }\n if (this._pendingToolResult) {\n this.bridge.sendToolResult(this._pendingToolResult);\n this._pendingToolResult = null;\n }\n };\n\n this.bridge.onopenlink = async ({ url }) => {\n if (this.options.onOpenLink) {\n this.options.onOpenLink(url);\n } else {\n // Validate URL scheme to prevent javascript: and data: URLs\n try {\n const parsed = new URL(url);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n console.warn('[MCP App] openLink blocked non-http(s) URL:', url);\n } else {\n window.open(url, '_blank');\n }\n } catch {\n console.warn('[MCP App] openLink blocked invalid URL:', url);\n }\n }\n const ack = {};\n console.log(\n `%c[MCP ↓]%c host → app: %copenLink ack`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n ack\n );\n return ack;\n };\n\n this.bridge.onmessage = async ({ role, content }) => {\n if (this.options.onMessage) {\n this.options.onMessage(role, content);\n }\n const ack = {};\n console.log(\n `%c[MCP ↓]%c host → app: %csendMessage ack`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n ack\n );\n return ack;\n };\n\n this.bridge.onrequestdisplaymode = async ({ mode }) => {\n this.options.onDisplayModeChange?.(mode);\n const result = { mode };\n console.log(\n `%c[MCP ↓]%c host → app: %crequestDisplayMode result`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n result\n );\n return result;\n };\n\n this.bridge.onupdatemodelcontext = async ({ content, structuredContent }) => {\n this.options.onUpdateModelContext?.(content ?? [], structuredContent);\n const ack = {};\n console.log(\n `%c[MCP ↓]%c host → app: %cupdateModelContext ack`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n ack\n );\n return ack;\n };\n\n this.bridge.onsizechange = (params) => {\n this.options.onSizeChanged?.(params);\n };\n\n this.bridge.onloggingmessage = (params) => {\n if (this.options.onLog) {\n this.options.onLog(params);\n } else {\n // Default: log to console with appropriate level\n const level = params.level ?? 'info';\n const prefix = `[MCP App${params.logger ? ` ${params.logger}` : ''}]`;\n if (\n level === 'error' ||\n level === 'critical' ||\n level === 'alert' ||\n level === 'emergency'\n ) {\n console.error(prefix, params.data);\n } else if (level === 'warning') {\n console.warn(prefix, params.data);\n } else if (level === 'debug') {\n console.debug(prefix, params.data);\n } else {\n console.log(prefix, params.data);\n }\n }\n };\n\n this.bridge.oncalltool = async (params) => {\n let result: CallToolResult;\n if (this.options.onCallTool) {\n result = await this.options.onCallTool(params);\n } else {\n result = {\n content: [\n {\n type: 'text',\n text: `[Inspector] Tool \"${params.name}\" called (no handler configured)`,\n },\n ],\n };\n }\n console.log(\n `%c[MCP ↓]%c host → app: %ccallServerTool result(${params.name})`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n result\n );\n return result;\n };\n\n this.bridge.ondownloadfile = async ({ contents }) => {\n if (this.options.onDownloadFile) {\n this.options.onDownloadFile(contents);\n }\n const ack = {};\n console.log(\n `%c[MCP ↓]%c host → app: %cdownloadFile ack`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n ack\n );\n return ack;\n };\n\n this.bridge.onrequestteardown = () => {\n if (this.options.onRequestTeardown) {\n this.options.onRequestTeardown();\n } else {\n console.log('[MCP App] requestTeardown (app requested close)');\n }\n };\n\n // Double-iframe sandbox support: when the proxy signals readiness,\n // notify the host so it can deliver the app HTML.\n this.bridge.onsandboxready = () => {\n this.options.onSandboxReady?.();\n };\n }\n\n /**\n * Connect to an iframe's contentWindow.\n */\n async connectToIframe(contentWindow: Window): Promise<void> {\n // Clean up previous listener if reconnecting\n if (this._messageListener) {\n window.removeEventListener('message', this._messageListener);\n }\n\n this._contentWindow = contentWindow;\n\n // Log incoming MCP protocol messages from the app (skip sunpeak internals)\n this._messageListener = (event: MessageEvent) => {\n if (event.source !== contentWindow) return;\n const data = event.data;\n if (!data || typeof data !== 'object') return;\n const method: string | undefined = data.method;\n // Skip sunpeak-internal and sandbox infrastructure messages\n if (method?.startsWith('sunpeak/') || method === 'ui/notifications/sandbox-proxy-ready')\n return;\n const label = method ?? (data.id != null ? `response #${data.id}` : 'unknown');\n console.log(\n `%c[MCP ↑]%c app → host: %c${label}`,\n 'color:#6ee7b7',\n 'color:inherit',\n 'color:#93c5fd',\n data\n );\n };\n window.addEventListener('message', this._messageListener);\n\n const transport = new PostMessageTransport(contentWindow, contentWindow);\n await this.bridge.connect(transport);\n }\n\n /**\n * Wait for the iframe to process all pending messages and commit its DOM.\n *\n * Uses a postMessage fence: since messages to the same target are delivered\n * in FIFO order, a fence message sent after setHostContext is guaranteed to\n * be processed after the host context change. The iframe's fence responder\n * waits for requestAnimationFrame before acking, ensuring the DOM has been\n * committed for the re-render triggered by the context change.\n *\n * Returns immediately if the iframe is not connected.\n */\n waitForPaint(): Promise<void> {\n const win = this._contentWindow;\n if (!win) return Promise.resolve();\n\n // Cancel any previous pending fence\n this._fenceCleanup?.();\n\n const id = ++this._fenceId;\n\n return new Promise<void>((resolve) => {\n const handler = (event: MessageEvent) => {\n if (event.source !== win) return;\n if (event.data?.method === 'sunpeak/fence-ack' && event.data.params?.fenceId === id) {\n cleanup();\n resolve();\n }\n };\n\n const cleanup = () => {\n window.removeEventListener('message', handler);\n if (this._fenceCleanup === cleanup) {\n this._fenceCleanup = null;\n }\n };\n\n this._fenceCleanup = cleanup;\n window.addEventListener('message', handler);\n\n try {\n // Format as a valid JSON-RPC 2.0 notification so the SDK's\n // PostMessageTransport parses it without error. Unknown notification\n // methods are silently ignored by the bridge.\n const fenceMsg = { jsonrpc: '2.0', method: 'sunpeak/fence', params: { fenceId: id } };\n win.postMessage(fenceMsg, '*');\n } catch {\n // Detached or cross-origin window\n cleanup();\n resolve();\n }\n });\n }\n\n /**\n * Update the host context and notify the connected app.\n * Automatically detects display mode changes and waits for the iframe\n * to commit its DOM before firing onDisplayModeReady.\n */\n setHostContext(context: McpUiHostContext): void {\n console.log(\n `%c[MCP ↓]%c host → app: %csetHostContext`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n context\n );\n this.bridge.setHostContext(context);\n\n const currentMode = context.displayMode;\n if (currentMode && currentMode !== this._prevDisplayMode) {\n this._prevDisplayMode = currentMode;\n const mode = currentMode;\n this.waitForPaint().then(() => {\n this.options.onDisplayModeReady?.(mode);\n });\n }\n }\n\n /**\n * Send tool input to the app.\n * If the app hasn't initialized yet, the input is queued.\n */\n sendToolInput(args: Record<string, unknown>): void {\n const params: McpUiToolInputNotification['params'] = { arguments: args };\n console.log(\n `%c[MCP ↓]%c host → app: %csendToolInput`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n params\n );\n if (this._initialized) {\n this.bridge.sendToolInput(params);\n } else {\n this._pendingToolInput = params;\n }\n }\n\n /**\n * Send tool result to the app.\n * If the app hasn't initialized yet, the result is queued.\n */\n sendToolResult(result: CallToolResult): void {\n console.log(\n `%c[MCP ↓]%c host → app: %csendToolResult`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n result\n );\n if (this._initialized) {\n this.bridge.sendToolResult(result);\n } else {\n this._pendingToolResult = result;\n }\n }\n\n /**\n * Send partial/streaming tool input to the app.\n * Useful for simulating streaming tool arguments.\n */\n sendToolInputPartial(args: Record<string, unknown>): void {\n const params: McpUiToolInputPartialNotification['params'] = { arguments: args };\n console.log(\n `%c[MCP ↓]%c host → app: %csendToolInputPartial`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n params\n );\n if (this._initialized) {\n this.bridge.sendToolInputPartial(params);\n }\n // Don't queue partials - they're only meaningful during streaming\n }\n\n /**\n * Send tool cancellation notification to the app.\n * Simulates user or host cancelling a tool execution.\n */\n sendToolCancelled(reason?: string): void {\n const params: McpUiToolCancelledNotification['params'] = reason ? { reason } : {};\n console.log(\n `%c[MCP ↓]%c host → app: %csendToolCancelled`,\n 'color:#f9a8d4',\n 'color:inherit',\n 'color:#93c5fd',\n params\n );\n if (this._initialized) {\n this.bridge.sendToolCancelled(params);\n }\n }\n\n /**\n * Send HTML resource to the sandbox proxy for secure loading.\n * Used in the double-iframe architecture after the proxy signals readiness.\n */\n sendSandboxResourceReady(params: { html: string; sandbox?: string }): void {\n this.bridge.sendSandboxResourceReady(params);\n }\n\n /**\n * Send a custom message to the connected iframe (for sandbox proxy commands).\n */\n sendRawMessage(data: unknown): void {\n const win = this._contentWindow;\n if (!win) return;\n try {\n win.postMessage(data, '*');\n } catch {\n // Detached or cross-origin window\n }\n }\n\n /**\n * Close the connection.\n */\n async close(): Promise<void> {\n if (this._messageListener) {\n window.removeEventListener('message', this._messageListener);\n this._messageListener = null;\n }\n this._fenceCleanup?.();\n this._fenceCleanup = null;\n try {\n if (this._initialized) {\n await this.bridge.teardownResource({});\n }\n } catch {\n // Ignore teardown errors\n }\n await this.bridge.close();\n this._initialized = false;\n // Note: _contentWindow is intentionally NOT cleared here.\n // In React strict mode, close() runs asynchronously during the cleanup\n // phase of double-mount, completing after effects have re-run. Clearing\n // _contentWindow would break injectState() and waitForPaint() which\n // use it directly (unlike sendToolResult which goes through the bridge).\n // The reference becomes harmless on real unmount since no code calls\n // methods on a host whose component has been removed from the tree.\n }\n\n /**\n * Debug: Inject state directly into the app's useAppState hook.\n * This bypasses the normal MCP Apps protocol and is intended for\n * inspector testing/debugging only.\n */\n injectState(state: Record<string, unknown>): void {\n const win = this._contentWindow;\n if (!win) return;\n\n try {\n win.postMessage({ jsonrpc: '2.0', method: 'sunpeak/injectState', params: { state } }, '*');\n } catch {\n // Detached or cross-origin window - ignore\n }\n }\n\n /**\n * Update mutable options (callbacks) after construction.\n * Allows the inspector to swap handlers (e.g. onCallTool) without\n * recreating the host and tearing down the iframe connection.\n */\n updateOptions(partial: Partial<McpAppHostOptions>): void {\n Object.assign(this.options, partial);\n }\n\n get initialized(): boolean {\n return this._initialized;\n }\n}\n","/**\n * Mock OpenAI runtime for the inspector.\n *\n * ChatGPT-specific hooks (useUploadFile, useRequestModal, etc.) call\n * `window.openai` directly — they don't use the MCP protocol. When the\n * ChatGPT host is selected in the inspector, we inject this mock into\n * the iframe's window so those hooks work during local development.\n */\n\n/**\n * Inline script that sets up a mock `window.openai` for srcdoc iframes.\n * Embedded in the generated HTML *before* the app's script so that\n * `isChatGPT()` and hooks work from the very first render.\n */\nexport const MOCK_OPENAI_RUNTIME_SCRIPT = [\n 'window.openai={',\n 'uploadFile:function(f){console.log(\"[Inspector] uploadFile:\",f.name);',\n 'return Promise.resolve({fileId:\"sim_file_\"+Date.now()})},',\n 'getFileDownloadUrl:function(p){console.log(\"[Inspector] getFileDownloadUrl:\",p.fileId);',\n 'return Promise.resolve({downloadUrl:\"https://inspector.local/files/\"+p.fileId})},',\n 'requestModal:function(p){console.log(\"[Inspector] requestModal:\",JSON.stringify(p));',\n 'return Promise.resolve()},',\n 'requestCheckout:function(s){console.log(\"[Inspector] requestCheckout:\",JSON.stringify(s));',\n 'return Promise.resolve({id:\"sim_order_\"+Date.now(),checkout_session_id:s.id||\"sim_session\",status:\"completed\"})},',\n 'requestClose:function(){console.log(\"[Inspector] requestClose\")},',\n 'requestDisplayMode:function(p){console.log(\"[Inspector] requestDisplayMode:\",p.mode);',\n 'return Promise.resolve()},',\n 'sendFollowUpMessage:function(p){console.log(\"[Inspector] sendFollowUpMessage:\",p.prompt)},',\n 'openExternal:function(p){console.log(\"[Inspector] openExternal:\",p.href);window.open(p.href,\"_blank\")}',\n '};',\n].join('');\n\n/**\n * Create a mock OpenAI runtime object for direct injection into an\n * iframe's `contentWindow`. Used for src-mode iframes (dev with Vite)\n * where we can't embed inline scripts in the page.\n */\nexport function createMockOpenAIRuntime(): Record<string, (...args: never[]) => unknown> {\n return {\n uploadFile: async (file: File) => {\n console.log('[Inspector] uploadFile:', file.name);\n return { fileId: `sim_file_${Date.now()}` };\n },\n getFileDownloadUrl: async (params: { fileId: string }) => {\n console.log('[Inspector] getFileDownloadUrl:', params.fileId);\n return { downloadUrl: `https://inspector.local/files/${params.fileId}` };\n },\n requestModal: async (params: unknown) => {\n console.log('[Inspector] requestModal:', params);\n },\n requestCheckout: async (session: { id?: string }) => {\n console.log('[Inspector] requestCheckout:', session);\n return {\n id: `sim_order_${Date.now()}`,\n checkout_session_id: session.id || 'sim_session',\n status: 'completed',\n };\n },\n requestClose: () => {\n console.log('[Inspector] requestClose');\n },\n requestDisplayMode: async (params: { mode: string }) => {\n console.log('[Inspector] requestDisplayMode:', params.mode);\n },\n sendFollowUpMessage: (params: { prompt: string }) => {\n console.log('[Inspector] sendFollowUpMessage:', params.prompt);\n },\n openExternal: (params: { href: string }) => {\n console.log('[Inspector] openExternal:', params.href);\n window.open(params.href, '_blank');\n },\n };\n}\n","/**\n * Sandbox proxy for the double-iframe architecture.\n *\n * Real hosts (ChatGPT, Claude) use a two-level iframe structure:\n * 1. Outer iframe (sandbox proxy) — acts as a message relay on a separate origin\n * 2. Inner iframe — loads the untrusted app HTML\n *\n * The proxy relays PostMessage between the host (parent) and the app (inner iframe),\n * providing origin isolation and security boundaries.\n *\n * The inspector replicates this architecture so apps are tested under the same\n * iframe nesting they'll encounter in production.\n *\n * Protocol:\n * 1. Host creates outer iframe with proxy HTML (srcdoc)\n * 2. Proxy sends `ui/notifications/sandbox-proxy-ready` to parent\n * 3. Host sends `ui/notifications/sandbox-resource-ready` with { html, sandbox, csp, permissions }\n * OR `sunpeak/sandbox-load-src` with { src } for dev mode\n * 4. Proxy creates inner iframe and loads the content\n * 5. All subsequent messages relay transparently between parent and inner iframe\n */\n\n/**\n * Generate the sandbox proxy HTML.\n *\n * This HTML is loaded into the outer iframe via srcdoc. It:\n * - Signals readiness via `ui/notifications/sandbox-proxy-ready`\n * - Listens for resource content or URL to load into the inner iframe\n * - Relays all PostMessage between parent and inner iframe\n * - Optionally injects platform runtime scripts (e.g., mock window.openai)\n *\n * @param platformScript - Optional JS to inject into the inner iframe before the app loads\n */\nexport function generateSandboxProxyHtml(platformScript?: string): string {\n const escapedPlatformScript = platformScript ? JSON.stringify(platformScript) : 'null';\n // Default to dark — theme is propagated to the app via hostContext PostMessage,\n // not via the proxy HTML. Using dark avoids white flash on load.\n const colorScheme = 'dark';\n\n return `<!DOCTYPE html>\n<html style=\"color-scheme:${colorScheme}\">\n<head>\n<meta name=\"color-scheme\" content=\"${colorScheme}\" />\n<style>\nhtml, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: transparent; }\niframe { border: none; width: 100%; height: 100%; display: block; }\n</style>\n</head>\n<body>\n<script>\n(function() {\n var innerFrame = null;\n var innerWindow = null;\n var platformScript = ${escapedPlatformScript};\n\n // Relay messages between parent (host) and inner iframe (app)\n window.addEventListener('message', function(event) {\n var data = event.data;\n if (!data || typeof data !== 'object') return;\n\n if (event.source === window.parent) {\n // ── Messages from the host ──\n\n // sandbox-resource-ready: load HTML into inner iframe (scriptSrc/prod mode)\n if (data.method === 'ui/notifications/sandbox-resource-ready' && data.params) {\n createInnerFrame(data.params);\n return;\n }\n\n // sunpeak/sandbox-load-src: load URL into inner iframe (src/dev mode)\n if (data.method === 'sunpeak/sandbox-load-src' && data.params) {\n createInnerFrameWithSrc(data.params);\n return;\n }\n\n // Handle paint fence. Forward to the inner iframe and wait for its ack.\n // If the inner iframe has a fence responder (same-origin, script injected),\n // the ack is deterministic. Otherwise fall back to a 150ms timeout.\n if (data.method === 'sunpeak/fence' && data.params) {\n var fenceId = data.params.fenceId;\n var acked = false;\n var onAck = function(e) {\n if (e.source !== innerWindow) return;\n if (e.data && e.data.method === 'sunpeak/fence-ack' &&\n e.data.params && e.data.params.fenceId === fenceId) {\n acked = true;\n window.removeEventListener('message', onAck);\n window.parent.postMessage(e.data, '*');\n }\n };\n window.addEventListener('message', onAck);\n if (innerWindow) {\n try { innerWindow.postMessage(data, '*'); } catch(e) {}\n }\n setTimeout(function() {\n if (!acked) {\n window.removeEventListener('message', onAck);\n window.parent.postMessage({\n jsonrpc: '2.0',\n method: 'sunpeak/fence-ack',\n params: { fenceId: fenceId }\n }, '*');\n }\n }, 150);\n return;\n }\n\n // Sync color-scheme on the inner iframe element when theme changes.\n // This ensures prefers-color-scheme resolves correctly inside the app.\n // Important: do NOT set color-scheme on the proxy's own document —\n // changing it from the initial 'dark' causes Chrome to re-evaluate\n // the CSS Canvas as opaque white, blocking the host's conversation\n // background from showing through the transparent proxy.\n if (data.method === 'ui/notifications/host-context-changed' && data.params && data.params.theme) {\n if (innerFrame) innerFrame.style.colorScheme = data.params.theme;\n }\n\n // Forward all other messages to the inner iframe\n if (innerWindow) {\n try { innerWindow.postMessage(data, '*'); } catch(e) { /* detached */ }\n }\n } else if (innerWindow && event.source === innerWindow) {\n // ── Messages from the app → forward to host ──\n try { window.parent.postMessage(data, '*'); } catch(e) { /* detached */ }\n }\n });\n\n function createInnerFrame(params) {\n if (innerFrame) innerFrame.remove();\n\n innerFrame = document.createElement('iframe');\n innerFrame.sandbox = params.sandbox ||\n 'allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox';\n if (params.allow) innerFrame.allow = params.allow;\n document.body.appendChild(innerFrame);\n innerWindow = innerFrame.contentWindow;\n\n // Write HTML content into the inner iframe\n var doc = innerFrame.contentDocument;\n if (doc && params.html) {\n doc.open();\n doc.write(params.html);\n doc.close();\n }\n }\n\n function createInnerFrameWithSrc(params) {\n if (innerFrame) innerFrame.remove();\n\n innerFrame = document.createElement('iframe');\n innerFrame.sandbox =\n 'allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox';\n if (params.allow) innerFrame.allow = params.allow;\n innerFrame.src = params.src;\n innerFrame.style.height = '100%';\n\n // Set color-scheme on the inner iframe to match the host theme.\n // This ensures prefers-color-scheme resolves correctly inside.\n if (params.theme) {\n innerFrame.style.colorScheme = params.theme;\n }\n\n // After load, inject helpers into the inner iframe\n innerFrame.addEventListener('load', function() {\n innerWindow = innerFrame.contentWindow;\n\n // Inject platform runtime (e.g., mock window.openai for ChatGPT)\n if (platformScript && innerWindow) {\n try {\n var pScript = innerFrame.contentDocument.createElement('script');\n pScript.textContent = platformScript;\n innerFrame.contentDocument.head.appendChild(pScript);\n } catch(e) { /* cross-origin */ }\n }\n\n // Inject paint fence responder\n try {\n var fenceScript = innerFrame.contentDocument.createElement('script');\n fenceScript.setAttribute('data-sunpeak-fence', '');\n fenceScript.textContent = PAINT_FENCE_SCRIPT;\n innerFrame.contentDocument.head.appendChild(fenceScript);\n } catch(e) { /* cross-origin */ }\n\n // Inject background rule\n if (params.theme) {\n try {\n innerFrame.contentDocument.documentElement.style.colorScheme = params.theme;\n var bgStyle = innerFrame.contentDocument.createElement('style');\n bgStyle.setAttribute('data-sunpeak-bg', '');\n bgStyle.textContent = 'html { background-color: var(--color-background-primary, Canvas); }';\n innerFrame.contentDocument.head.appendChild(bgStyle);\n } catch(e) { /* cross-origin */ }\n }\n\n // Inject style variables for immediate rendering\n if (params.styleVars) {\n try {\n var root = innerFrame.contentDocument.documentElement;\n for (var key in params.styleVars) {\n if (params.styleVars[key]) root.style.setProperty(key, params.styleVars[key]);\n }\n } catch(e) { /* cross-origin */ }\n }\n\n // Signal that load is complete — fade in\n innerFrame.style.opacity = '1';\n innerFrame.style.transition = 'opacity 100ms';\n });\n\n // Start hidden for smooth fade-in\n innerFrame.style.opacity = '0';\n document.body.appendChild(innerFrame);\n innerWindow = innerFrame.contentWindow;\n }\n\n // Paint fence responder — same as in iframe-resource.ts\n var PAINT_FENCE_SCRIPT = 'window.addEventListener(\"message\",function(e){' +\n 'if(e.data&&e.data.method===\"sunpeak/fence\"){' +\n 'var fid=e.data.params&&e.data.params.fenceId;' +\n 'requestAnimationFrame(function(){' +\n 'e.source.postMessage({jsonrpc:\"2.0\",method:\"sunpeak/fence-ack\",params:{fenceId:fid}},\"*\");' +\n '});}});';\n\n // Signal to the host that the proxy is ready.\n // Use setTimeout to ensure the host's PostMessageTransport listener\n // is set up before we send the ready notification. The srcdoc is parsed\n // synchronously by the browser, which can race with React's ref callback.\n setTimeout(function() {\n window.parent.postMessage({\n jsonrpc: '2.0',\n method: 'ui/notifications/sandbox-proxy-ready',\n params: {}\n }, '*');\n }, 0);\n})();\n</script>\n</body>\n</html>`;\n}\n\n/**\n * The mock OpenAI runtime script body for injection into the inner iframe.\n * Re-exported from mock-openai-runtime so the proxy can inject it.\n */\nexport { MOCK_OPENAI_RUNTIME_SCRIPT } from './mock-openai-runtime';\n","import * as React from 'react';\nimport { useEffect, useRef, useMemo, useCallback } from 'react';\nimport { McpAppHost, type McpAppHostOptions } from './mcp-app-host';\nimport { MOCK_OPENAI_RUNTIME_SCRIPT } from './mock-openai-runtime';\nimport { generateSandboxProxyHtml } from './sandbox-proxy';\nimport type { McpUiHostContext, McpUiResourcePermissions } from '@modelcontextprotocol/ext-apps';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\n\n/**\n * Allowed origins for cross-origin script loading.\n * - Local development: localhost, 127.0.0.1, file://\n * - Production: sunpeak-prod-app-storage.s3.us-east-2.amazonaws.com (serves user scripts)\n */\nconst ALLOWED_SCRIPT_ORIGINS = [\n 'https://sunpeak-prod-app-storage.s3.us-east-2.amazonaws.com',\n 'http://localhost',\n 'https://localhost',\n 'http://127.0.0.1',\n 'https://127.0.0.1',\n];\n\n/**\n * Escapes HTML special characters to prevent XSS via attribute injection.\n */\nfunction escapeHtml(str: string): string {\n return str.replace(/[&<>\"']/g, (c) => {\n const entities: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n };\n return entities[c] ?? c;\n });\n}\n\n/**\n * Validates that a URL is from an allowed origin.\n * Allows same-origin URLs and URLs from whitelisted domains.\n */\nfunction isAllowedUrl(src: string): boolean {\n if (!src) return false;\n\n // Allow relative paths (same-origin) - must start with / but not //\n if (src.startsWith('/') && !src.startsWith('//')) return true;\n\n // Reject strings that don't look like URLs (no protocol)\n if (!src.includes('://')) return false;\n\n try {\n const url = new URL(src);\n\n // Allow same-origin\n if (url.origin === window.location.origin) return true;\n\n // Allow localhost with any port for development\n if (url.hostname === 'localhost' || url.hostname === '127.0.0.1') return true;\n\n // Check against allowed origins (strict origin comparison only)\n return ALLOWED_SCRIPT_ORIGINS.some((allowed) => {\n try {\n return url.origin === new URL(allowed).origin;\n } catch {\n return false;\n }\n });\n } catch {\n return false;\n }\n}\n\n/**\n * Content Security Policy configuration for iframe resources.\n * Matches McpUiResourceCsp from the MCP Apps spec.\n */\nexport interface ResourceCSP {\n /** Domains allowed for fetch/XHR/WebSocket connections */\n connectDomains?: string[];\n /** Domains allowed for scripts, images, styles, fonts */\n resourceDomains?: string[];\n /** Domains allowed for nested iframes */\n frameDomains?: string[];\n /** Domains allowed for the base-uri directive */\n baseUriDomains?: string[];\n}\n\n/**\n * Extract CSP configuration from a resource's _meta.ui.csp field.\n */\nexport function extractResourceCSP(resource: { _meta?: unknown }): ResourceCSP | undefined {\n const meta = resource._meta as Record<string, unknown> | undefined;\n const ui = meta?.ui as { csp?: ResourceCSP } | undefined;\n return ui?.csp;\n}\n\n/**\n * Validates a CSP source entry is a safe origin URL (scheme + host + optional port).\n * Rejects wildcards, CSP keywords, and whitespace that could inject extra directives.\n */\nfunction isValidCspSource(source: string): boolean {\n // Block CSP keywords like 'unsafe-inline', wildcards like *, and whitespace injection\n if (!source || /[\\s;,']/.test(source) || source === '*') return false;\n try {\n const url = new URL(source);\n return (\n url.protocol === 'http:' ||\n url.protocol === 'https:' ||\n url.protocol === 'ws:' ||\n url.protocol === 'wss:'\n );\n } catch {\n return false;\n }\n}\n\n/**\n * Generates a Content Security Policy string.\n */\nfunction generateCSP(csp: ResourceCSP | undefined, scriptSrc: string): string {\n let scriptOrigin = '';\n try {\n scriptOrigin = new URL(scriptSrc, window.location.origin).origin;\n } catch {\n // Invalid URL, skip\n }\n\n // frame-src: default to 'none', but allow declared frame domains\n const frameSources = new Set<string>();\n if (csp?.frameDomains) {\n for (const domain of csp.frameDomains) {\n if (isValidCspSource(domain)) {\n frameSources.add(domain);\n } else {\n console.warn('[IframeResource] Ignoring invalid CSP frame domain:', domain);\n }\n }\n }\n const frameSrc =\n frameSources.size > 0 ? `frame-src ${Array.from(frameSources).join(' ')}` : \"frame-src 'none'\";\n\n // base-uri: default to 'self', but allow declared base-uri domains\n const baseSources = new Set<string>([\"'self'\"]);\n if (csp?.baseUriDomains) {\n for (const domain of csp.baseUriDomains) {\n if (isValidCspSource(domain)) {\n baseSources.add(domain);\n } else {\n console.warn('[IframeResource] Ignoring invalid CSP base-uri domain:', domain);\n }\n }\n }\n\n const directives: string[] = [\n \"default-src 'none'\",\n `script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ${scriptOrigin}`.trim(),\n `style-src 'self' 'unsafe-inline' ${scriptOrigin}`.trim(),\n frameSrc,\n \"object-src 'none'\",\n \"form-action 'none'\",\n `base-uri ${Array.from(baseSources).join(' ')}`,\n ];\n\n const connectSources = new Set<string>([\"'self'\"]);\n if (scriptOrigin) connectSources.add(scriptOrigin);\n if (csp?.connectDomains) {\n for (const domain of csp.connectDomains) {\n if (isValidCspSource(domain)) {\n connectSources.add(domain);\n } else {\n console.warn('[IframeResource] Ignoring invalid CSP connect domain:', domain);\n }\n }\n }\n directives.push(`connect-src ${Array.from(connectSources).join(' ')}`);\n\n const resourceSources = new Set<string>([\"'self'\", 'data:', 'blob:']);\n if (scriptOrigin) resourceSources.add(scriptOrigin);\n if (csp?.resourceDomains) {\n for (const domain of csp.resourceDomains) {\n if (isValidCspSource(domain)) {\n resourceSources.add(domain);\n } else {\n console.warn('[IframeResource] Ignoring invalid CSP resource domain:', domain);\n }\n }\n }\n const resourceList = Array.from(resourceSources).join(' ');\n directives.push(`img-src ${resourceList}`);\n directives.push(`font-src ${resourceList}`);\n directives.push(`media-src ${resourceList}`);\n\n return directives.join('; ');\n}\n\n/**\n * Paint fence responder script body.\n * Embedded in the generated HTML for scriptSrc mode. The sandbox proxy\n * handles fence injection for src-mode iframes.\n */\nconst PAINT_FENCE_SCRIPT = `window.addEventListener(\"message\",function(e){\nif(e.data&&e.data.method===\"sunpeak/fence\"){\nvar fid=e.data.params&&e.data.params.fenceId;\nrequestAnimationFrame(function(){\ne.source.postMessage({jsonrpc:\"2.0\",method:\"sunpeak/fence-ack\",params:{fenceId:fid}},\"*\");\n});}});`;\n\n/**\n * Generates HTML wrapper for a script URL.\n * The MCP Apps SDK in the loaded script handles communication via PostMessageTransport.\n */\nfunction generateScriptHtml(\n scriptSrc: string,\n theme: string,\n cspPolicy: string,\n platformScript?: string\n): string {\n const safeScriptSrc = escapeHtml(scriptSrc);\n const safeCsp = escapeHtml(cspPolicy);\n const safeTheme = escapeHtml(theme);\n // Platform runtime script (e.g. mock window.openai) runs before the app\n // script so that isChatGPT() and platform hooks work from first render.\n const platformTag = platformScript ? `\\n <script>${platformScript}</script>` : '';\n return `<!DOCTYPE html>\n<html lang=\"en\" data-theme=\"${safeTheme}\" style=\"color-scheme:${safeTheme};background:Canvas\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"color-scheme\" content=\"${safeTheme}\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"Content-Security-Policy\" content=\"${safeCsp}\" />\n <title>Resource</title>\n <style>\n html {\n /* Use the MCP App background variable once JS sets it, otherwise\n Canvas (the system color that auto-adapts to color-scheme). */\n background-color: var(--color-background-primary, Canvas);\n }\n body, #root {\n margin: 0;\n padding: 0;\n width: 100%;\n background: transparent;\n }\n </style>\n <script>${PAINT_FENCE_SCRIPT}</script>${platformTag}\n</head>\n<body>\n <div id=\"root\"></div>\n <script src=\"${safeScriptSrc}\"></script>\n</body>\n</html>`;\n}\n\n/**\n * Build the iframe `allow` attribute from resource-declared permissions.\n * Maps McpUiResourcePermissions to Permission Policy directives and\n * combines them with inspector baseline permissions.\n */\nfunction buildIframeAllow(permissions: McpUiResourcePermissions | undefined): string {\n const parts: string[] = [\n 'local-network-access *', // Always needed for local dev server access\n ];\n\n // Map spec permissions to their Permission Policy names\n const permMap: [keyof McpUiResourcePermissions, string][] = [\n ['camera', 'camera'],\n ['microphone', 'microphone'],\n ['geolocation', 'geolocation'],\n ['clipboardWrite', 'clipboard-write'],\n ];\n\n for (const [key, directive] of permMap) {\n if (permissions?.[key]) {\n parts.push(directive);\n }\n }\n\n return parts.join('; ');\n}\n\ninterface IframeResourceProps {\n /**\n * URL to an HTML page to load directly in the iframe.\n * Used for dev mode where Vite serves the resource page.\n * Mutually exclusive with scriptSrc.\n */\n src?: string;\n /**\n * URL to a built resource to load in the iframe via srcdoc.\n * Used for production builds where we generate the HTML wrapper.\n * Mutually exclusive with src.\n */\n scriptSrc?: string;\n /** Initial host context for the MCP Apps bridge */\n hostContext?: McpUiHostContext;\n /** Tool input arguments to send after connection */\n toolInput?: Record<string, unknown>;\n /** Partial/streaming tool input to send as a tool-input-partial notification */\n toolInputPartial?: Record<string, unknown>;\n /** Tool result to send after connection */\n toolResult?: CallToolResult;\n /** Optional callbacks for the MCP Apps host */\n hostOptions?: McpAppHostOptions;\n /** Optional CSP configuration (only used with scriptSrc) */\n csp?: ResourceCSP;\n /** Resource-declared sandbox permissions (camera, microphone, etc.) */\n permissions?: McpUiResourcePermissions;\n /** Whether the host should render a border around the resource */\n prefersBorder?: boolean;\n /** Optional className for the iframe container */\n className?: string;\n /** Optional style for the iframe */\n style?: React.CSSProperties;\n /**\n * Called after the iframe has rendered following a display mode change.\n * The callback receives the display mode that was confirmed.\n * Used by the inspector to hide content during transitions and only\n * reveal it once the app has committed its DOM for the new mode.\n */\n onDisplayModeReady?: (mode: string) => void;\n /**\n * Debug: State to inject directly into the app's useAppState hook.\n * This bypasses the normal MCP Apps protocol and is for inspector testing.\n */\n debugInjectState?: Record<string, unknown> | null;\n /**\n * Whether to inject a mock ChatGPT runtime (window.openai) into the iframe.\n * When true, ChatGPT-specific hooks (useUploadFile, useRequestModal, etc.)\n * and isChatGPT() will work inside the iframe.\n */\n injectOpenAIRuntime?: boolean;\n /**\n * Base URL of the separate-origin sandbox server (e.g., \"http://localhost:24680\").\n * When provided, the outer iframe loads from this server instead of using srcdoc,\n * giving real cross-origin isolation that matches production hosts like ChatGPT.\n * Falls back to srcdoc when not provided (unit tests, embedded usage).\n */\n sandboxUrl?: string;\n}\n\n/**\n * IframeResource renders MCP Apps in an iframe, communicating via the\n * MCP Apps protocol (PostMessageTransport + AppBridge).\n *\n * Supports two modes:\n * - `src`: Load an HTML page directly (dev mode with Vite HMR)\n * - `scriptSrc`: Generate HTML wrapper for a JS file (production builds)\n *\n * The loaded app uses the MCP Apps SDK's useApp() hook which automatically\n * connects via PostMessageTransport to window.parent. The parent side uses\n * McpAppHost (wrapping AppBridge) to communicate.\n */\nexport function IframeResource({\n src,\n scriptSrc,\n hostContext,\n toolInput,\n toolInputPartial,\n toolResult,\n hostOptions,\n csp,\n permissions,\n prefersBorder,\n className,\n style,\n onDisplayModeReady,\n debugInjectState,\n injectOpenAIRuntime,\n sandboxUrl,\n}: IframeResourceProps) {\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const hostRef = useRef<McpAppHost | null>(null);\n\n // Determine which URL to validate\n const resourceUrl = src ?? scriptSrc;\n\n // Refs for resource data so the stable onSandboxReady callback can access current values\n // Refs for values that the stable onSandboxReady callback needs to access.\n // Without refs, the callback would capture stale values from the initial render.\n const srcRef = useRef(src);\n srcRef.current = src;\n const scriptSrcRef = useRef(scriptSrc);\n scriptSrcRef.current = scriptSrc;\n const cspRef = useRef(csp);\n cspRef.current = csp;\n const hostContextRef = useRef(hostContext);\n hostContextRef.current = hostContext;\n const injectOpenAIRuntimeRef = useRef(injectOpenAIRuntime);\n injectOpenAIRuntimeRef.current = injectOpenAIRuntime;\n const permissionsRef = useRef(permissions);\n permissionsRef.current = permissions;\n\n // Track whether we've received an initial size report\n const hasReceivedSizeRef = useRef(false);\n\n // Track current display mode so the stable onSizeChanged callback can\n // skip auto-resizing in fullscreen (where the host container is fixed).\n const displayModeRef = useRef(hostContext?.displayMode);\n displayModeRef.current = hostContext?.displayMode;\n\n // Remember the last content-driven height so we can restore it when\n // leaving fullscreen (the app won't re-report until content changes).\n const lastContentHeightRef = useRef<number | null>(null);\n\n // Create the MCP Apps host\n const host = useMemo(\n () =>\n new McpAppHost({\n hostContext,\n ...hostOptions,\n onSizeChanged: (params) => {\n hostOptions?.onSizeChanged?.(params);\n if (params.height != null) {\n lastContentHeightRef.current = params.height;\n }\n // Skip auto-resizing in fullscreen mode where the host provides a\n // fixed container — auto-sizing would create a feedback loop with\n // viewport-relative units like dvh. PIP and inline use content-driven sizing.\n if (displayModeRef.current === 'fullscreen') return;\n const iframe = iframeRef.current;\n if (!iframe) return;\n\n // Border-box compensation: if the iframe has borders, add their\n // width/height so the content area matches the reported size.\n // Pattern from ext-apps basic-host reference implementation.\n const style = getComputedStyle(iframe);\n const isBorderBox = style.boxSizing === 'border-box';\n\n const from: Record<string, string> = {};\n const to: Record<string, string> = {};\n\n if (params.width != null) {\n let w = params.width;\n if (isBorderBox) {\n w += parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);\n }\n // Use min-width with min() to allow responsive growing while\n // respecting the content's minimum width.\n from.minWidth = `${iframe.offsetWidth}px`;\n iframe.style.minWidth = `min(${w}px, 100%)`;\n to.minWidth = `min(${w}px, 100%)`;\n }\n if (params.height != null) {\n hasReceivedSizeRef.current = true;\n let h = params.height;\n if (isBorderBox) {\n h += parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);\n }\n from.height = `${iframe.offsetHeight}px`;\n iframe.style.height = `${h}px`;\n to.height = `${h}px`;\n }\n\n // Smooth animated transition for size changes.\n if (Object.keys(from).length > 0) {\n iframe.animate([from, to], { duration: 300, easing: 'ease-out' });\n }\n },\n onDisplayModeReady: (mode) => onDisplayModeReady?.(mode),\n onSandboxReady: () => {\n // The sandbox proxy is ready. Deliver the app content.\n const currentSrc = srcRef.current;\n const currentScriptSrc = scriptSrcRef.current;\n const currentHost = hostRef.current;\n if (!currentHost) return;\n\n if (currentScriptSrc) {\n // scriptSrc mode (prod): use the official sandbox-resource-ready protocol.\n // Generate the full app HTML and send it to the proxy.\n const absoluteScriptSrc = currentScriptSrc.startsWith('/')\n ? `${window.location.origin}${currentScriptSrc}`\n : currentScriptSrc;\n const cspPolicy = generateCSP(cspRef.current, absoluteScriptSrc);\n const theme = hostContextRef.current?.theme ?? 'dark';\n const platformScriptStr = injectOpenAIRuntimeRef.current\n ? MOCK_OPENAI_RUNTIME_SCRIPT\n : undefined;\n const appHtml = generateScriptHtml(\n absoluteScriptSrc,\n theme,\n cspPolicy,\n platformScriptStr\n );\n\n currentHost.sendSandboxResourceReady({\n html: appHtml,\n sandbox:\n 'allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox',\n });\n\n // Fade in the outer iframe\n if (iframeRef.current) {\n iframeRef.current.style.opacity = '1';\n iframeRef.current.style.transition = 'opacity 100ms';\n }\n } else if (currentSrc) {\n // src mode (dev): send the URL to the proxy for inner iframe src loading.\n // This is a inspector-specific extension — the proxy creates an inner iframe\n // with src pointing to the Vite dev server, preserving HMR.\n //\n // When using a separate-origin sandbox server, the src must be absolute\n // (relative paths would resolve against the sandbox origin, not the Vite server).\n const absoluteSrc = currentSrc.startsWith('/')\n ? `${window.location.origin}${currentSrc}`\n : currentSrc;\n const allowAttr = buildIframeAllow(permissionsRef.current);\n currentHost.sendRawMessage({\n jsonrpc: '2.0',\n method: 'sunpeak/sandbox-load-src',\n params: {\n src: absoluteSrc,\n allow: allowAttr,\n theme: hostContextRef.current?.theme,\n styleVars: hostContextRef.current?.styles?.variables,\n },\n });\n }\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [] // Stable - create once\n );\n hostRef.current = host;\n\n // Connect bridge transport as soon as the iframe element exists in the DOM,\n // before the browser loads the iframe content. For built HTML files with\n // inline scripts (same-origin), React effects inside the iframe can fire\n // before the parent's onLoad event, causing the app's `initialize` request\n // to be lost if the bridge transport isn't listening yet.\n const setIframeRef = useCallback(\n (node: HTMLIFrameElement | null) => {\n iframeRef.current = node;\n if (node?.contentWindow) {\n host.connectToIframe(node.contentWindow);\n }\n },\n [host]\n );\n\n // The outer iframe loads the sandbox proxy HTML. Show it immediately since\n // it's just the proxy shell. The proxy handles inner iframe creation and content.\n const handleLoad = useCallback(() => {\n if (iframeRef.current) {\n iframeRef.current.style.opacity = '1';\n iframeRef.current.style.transition = 'opacity 100ms';\n }\n }, []);\n\n // Sync mutable host options (e.g. onCallTool) into the existing host\n // instance when they change, without recreating the connection.\n useEffect(() => {\n if (hostOptions) {\n host.updateOptions(hostOptions);\n }\n }, [host, hostOptions]);\n\n // Update host context when props change.\n // McpAppHost.setHostContext() internally detects display mode changes\n // and waits for the iframe to commit its DOM before firing onDisplayModeReady.\n useEffect(() => {\n if (hostContext) {\n host.setHostContext(hostContext);\n }\n // In fullscreen the host provides a fixed container, so the iframe\n // should fill it. When leaving fullscreen, restore the last content-driven\n // height so the iframe isn't stuck at 100% or collapsed.\n if (iframeRef.current) {\n if (hostContext?.displayMode === 'fullscreen') {\n iframeRef.current.style.height = '100%';\n } else if (lastContentHeightRef.current != null) {\n iframeRef.current.style.height = `${lastContentHeightRef.current}px`;\n }\n }\n }, [host, hostContext]);\n\n // Send tool input updates\n // Note: Don't check host.initialized here - McpAppHost handles queueing internally\n useEffect(() => {\n if (toolInput) {\n host.sendToolInput(toolInput);\n }\n }, [host, toolInput]);\n\n // Send partial/streaming tool input\n useEffect(() => {\n if (toolInputPartial) {\n host.sendToolInputPartial(toolInputPartial);\n }\n }, [host, toolInputPartial]);\n\n // Send tool result updates\n // Note: Don't check host.initialized here - McpAppHost handles queueing internally\n useEffect(() => {\n if (toolResult) {\n host.sendToolResult(toolResult);\n }\n }, [host, toolResult]);\n\n // Debug: Inject state directly into app's useAppState hook\n useEffect(() => {\n if (debugInjectState != null) {\n host.injectState(debugInjectState);\n }\n }, [host, debugInjectState]);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n hostRef.current?.close();\n };\n }, []);\n\n // Validate URL\n const isValidUrl = useMemo(() => resourceUrl && isAllowedUrl(resourceUrl), [resourceUrl]);\n\n // Build iframe allow attribute from resource permissions\n const allowAttribute = useMemo(() => buildIframeAllow(permissions), [permissions]);\n\n // Border style when resource declares prefersBorder\n const borderStyle: React.CSSProperties = prefersBorder\n ? { border: '1px solid var(--color-border-primary, #e5e7eb)' }\n : { border: 'none' };\n\n // Build sandbox proxy content. When a separate-origin sandbox server is available,\n // use its URL for real cross-origin isolation (matching production hosts).\n // Otherwise fall back to srcdoc with the proxy HTML (for unit tests, embedded use).\n // Build sandbox proxy URL/HTML. These must NOT depend on theme — changing\n // theme should not reload the iframe (which would destroy app state and\n // show a loading flash). Theme is propagated to the app via hostContext\n // through PostMessage, not via iframe src/srcdoc.\n const sandboxSrc = useMemo(() => {\n if (!sandboxUrl) return undefined;\n const url = new URL('/proxy', sandboxUrl);\n if (injectOpenAIRuntime) url.searchParams.set('platform', 'chatgpt');\n return url.toString();\n }, [sandboxUrl, injectOpenAIRuntime]);\n\n const proxyHtml = useMemo(() => {\n if (sandboxSrc) return undefined;\n const platformScript = injectOpenAIRuntime ? MOCK_OPENAI_RUNTIME_SCRIPT : undefined;\n return generateSandboxProxyHtml(platformScript);\n }, [sandboxSrc, injectOpenAIRuntime]);\n\n const iframeStyle: React.CSSProperties = {\n ...borderStyle,\n background: 'transparent',\n colorScheme: hostContext?.theme === 'light' ? 'light dark' : 'dark light',\n // Start hidden; handleLoad fades in via direct DOM update\n opacity: 0,\n width: '100%',\n // In fullscreen, fill the container immediately. In other modes, use\n // minHeight to prevent collapse while waiting for the app to report size.\n ...(hostContext?.displayMode === 'fullscreen' ? { height: '100%' } : { minHeight: '200px' }),\n ...style,\n };\n\n // Apply containerDimensions constraints as a host-side wrapper so the app\n // reports its natural size via sizechange (no feedback loop) while the\n // inspector visually enforces the configured dimensions.\n //\n // height / maxHeight → clip the iframe vertically with overflow:hidden.\n // Using a wrapper (not SafeArea inside the app) is intentional: if the\n // app were to apply the height constraint internally, sizechange would\n // echo the constrained value back and the host would lock in that size.\n // width / maxWidth → constrain the wrapper's width; the iframe fills 100%.\n //\n // The wrapper div is always rendered (never conditional) so that adding or\n // removing constraints is a style update, not a tree change. Conditionally\n // toggling the wrapper would unmount/remount the iframe mid-handshake,\n // which causes the tool result to never reach the app.\n const dims = hostContext?.containerDimensions;\n const isFullscreenMode = hostContext?.displayMode === 'fullscreen';\n const wrapperStyle: React.CSSProperties = {};\n if (dims && !isFullscreenMode) {\n const h = 'height' in dims ? dims.height : undefined;\n const mh = 'maxHeight' in dims ? dims.maxHeight : undefined;\n const w = 'width' in dims ? dims.width : undefined;\n const mw = 'maxWidth' in dims ? dims.maxWidth : undefined;\n if (h != null) {\n wrapperStyle.height = h;\n wrapperStyle.overflow = 'hidden';\n }\n if (mh != null) {\n wrapperStyle.maxHeight = mh;\n wrapperStyle.overflow = 'hidden';\n }\n if (w != null) wrapperStyle.width = w;\n if (mw != null) wrapperStyle.maxWidth = mw;\n }\n\n // Validate URL for src mode\n if (src && !isValidUrl) {\n console.error('[IframeResource] URL not allowed:', src);\n return <div style={{ color: 'red', padding: 20 }}>Error: URL not allowed: {src}</div>;\n }\n if (scriptSrc && !isValidUrl) {\n console.error('[IframeResource] Script source not allowed:', scriptSrc);\n return <div style={{ color: 'red', padding: 20 }}>Error: Script source not allowed.</div>;\n }\n\n // Both src and scriptSrc modes use the sandbox proxy. The proxy creates\n // the inner iframe after receiving content via onSandboxReady.\n return (\n <div className={className} style={wrapperStyle}>\n <iframe\n ref={setIframeRef}\n onLoad={handleLoad}\n style={iframeStyle}\n title=\"Resource Preview\"\n sandbox=\"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox\"\n allow={allowAttribute}\n src={sandboxSrc ?? undefined}\n srcDoc={sandboxSrc ? undefined : proxyHtml}\n />\n </div>\n );\n}\n\n// Export security helpers for testing\nexport const _testExports = {\n escapeHtml,\n isAllowedUrl,\n isValidCspSource,\n generateCSP,\n generateScriptHtml,\n buildIframeAllow,\n ALLOWED_SCRIPT_ORIGINS,\n};\n","import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type {\n McpUiHostContext,\n McpUiDisplayMode,\n McpUiTheme,\n McpUiResourcePermissions,\n} from '@modelcontextprotocol/ext-apps';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { Simulation } from '../types/simulation';\nimport type { ScreenWidth } from './inspector-types';\nimport type { HostId } from './hosts';\nimport { extractResourceCSP, type ResourceCSP } from './iframe-resource';\n\ntype Platform = NonNullable<McpUiHostContext['platform']>;\n\nconst DEFAULT_THEME: McpUiTheme = 'dark';\nconst DEFAULT_DISPLAY_MODE: McpUiDisplayMode = 'inline';\nconst DEFAULT_PLATFORM: Platform = 'desktop';\n\nexport interface UseInspectorStateOptions {\n simulations: Record<string, Simulation>;\n defaultHost?: HostId;\n}\n\nexport interface InspectorState {\n // ── Simulation selection ──\n simulationNames: string[];\n selectedSimulationName: string;\n setSelectedSimulationName: (name: string) => void;\n selectedSim: Simulation | undefined;\n\n // ── Host selection ──\n activeHost: HostId;\n setActiveHost: (host: HostId) => void;\n\n // ── Screen width ──\n screenWidth: ScreenWidth;\n setScreenWidth: (width: ScreenWidth) => void;\n\n // ── Host context ──\n theme: McpUiTheme;\n setTheme: (theme: McpUiTheme) => void;\n displayMode: McpUiDisplayMode;\n setDisplayMode: (mode: McpUiDisplayMode) => void;\n locale: string;\n setLocale: (locale: string) => void;\n containerHeight: number | undefined;\n setContainerHeight: (height: number | undefined) => void;\n containerWidth: number | undefined;\n setContainerWidth: (width: number | undefined) => void;\n containerMaxHeight: number | undefined;\n setContainerMaxHeight: (height: number | undefined) => void;\n containerMaxWidth: number | undefined;\n setContainerMaxWidth: (width: number | undefined) => void;\n platform: Platform;\n setPlatform: (platform: Platform) => void;\n hover: boolean;\n setHover: (hover: boolean) => void;\n touch: boolean;\n setTouch: (touch: boolean) => void;\n safeAreaInsets: { top: number; bottom: number; left: number; right: number };\n setSafeAreaInsets: React.Dispatch<\n React.SetStateAction<{ top: number; bottom: number; left: number; right: number }>\n >;\n timeZone: string;\n setTimeZone: (tz: string) => void;\n // ── Computed host context ──\n hostContext: McpUiHostContext;\n\n // ── Display mode ready callback (for IframeResource paint fence) ──\n handleDisplayModeReady: (mode: string) => void;\n\n // ── Tool data ──\n toolInput: Record<string, unknown>;\n setToolInput: (input: Record<string, unknown>) => void;\n toolResult: CallToolResult | undefined;\n setToolResult: (result: CallToolResult | undefined) => void;\n effectiveToolResult: CallToolResult | undefined;\n\n // ── Model context ──\n modelContext: Record<string, unknown> | null;\n setModelContext: (ctx: Record<string, unknown> | null) => void;\n\n // ── JSON editing state (for sidebar) ──\n toolInputJson: string;\n setToolInputJson: (json: string) => void;\n toolInputError: string;\n setToolInputError: (error: string) => void;\n toolResultJson: string;\n setToolResultJson: (json: string) => void;\n toolResultError: string;\n setToolResultError: (error: string) => void;\n modelContextJson: string;\n setModelContextJson: (json: string) => void;\n modelContextError: string;\n setModelContextError: (error: string) => void;\n editingField: string | null;\n setEditingField: (field: string | null) => void;\n\n // ── JSON helpers ──\n validateJSON: (\n json: string,\n setJson: (value: string) => void,\n setError: (error: string) => void\n ) => void;\n commitJSON: (\n json: string,\n setError: (error: string) => void,\n updateFn: (value: Record<string, unknown> | null) => void\n ) => void;\n\n // ── Content width (from conversation ResizeObserver) ──\n measuredContentWidth: number | undefined;\n handleContentWidthChange: (width: number) => void;\n\n // ── Host callbacks ──\n handleDisplayModeChange: (mode: McpUiDisplayMode) => void;\n handleUpdateModelContext: (content: unknown[], structuredContent?: unknown) => void;\n\n // ── Content props (for IframeResource) ──\n resourceUrl: string | undefined;\n resourceScript: string | undefined;\n csp: ResourceCSP | undefined;\n permissions: McpUiResourcePermissions | undefined;\n prefersBorder: boolean;\n // ── URL param overrides ──\n urlTool: string | undefined;\n urlProdResources: boolean | undefined;\n urlSidebar: boolean | undefined;\n urlDevOverlay: boolean | undefined;\n}\n\n/**\n * Parse URL params for initial inspector values.\n * Supported params:\n * - simulation: simulation name (e.g., 'show-albums')\n * - theme: 'light' | 'dark'\n * - displayMode: 'inline' | 'pip' | 'fullscreen'\n * - locale: e.g., 'en-US'\n * - maxHeight: number (containerDimensions.maxHeight)\n * - maxWidth: number (containerDimensions.maxWidth)\n * - deviceType: 'mobile' | 'tablet' | 'desktop' → maps to platform\n * - hover: 'true' | 'false'\n * - touch: 'true' | 'false'\n * - safeAreaTop, safeAreaBottom, safeAreaLeft, safeAreaRight: number\n * - host: 'chatgpt' | 'claude'\n * - tool: tool name (e.g., 'show-albums') — selects tool without mock data\n * - prodResources: 'true' | 'false'\n */\nfunction parseUrlParams(): {\n simulation?: string;\n tool?: string;\n theme?: McpUiTheme;\n displayMode?: McpUiDisplayMode;\n locale?: string;\n containerMaxHeight?: number;\n containerMaxWidth?: number;\n platform?: Platform;\n deviceCapabilities?: { hover?: boolean; touch?: boolean };\n safeAreaInsets?: { top: number; bottom: number; left: number; right: number };\n host?: HostId;\n prodResources?: boolean;\n sidebar?: boolean;\n devOverlay?: boolean;\n} {\n if (typeof window === 'undefined') return {};\n\n const params = new URLSearchParams(window.location.search);\n\n const simulation = params.get('simulation') ?? undefined;\n const tool = params.get('tool') ?? undefined;\n const theme = params.get('theme') as McpUiTheme | null;\n const displayMode = params.get('displayMode') as McpUiDisplayMode | null;\n const locale = params.get('locale');\n const maxHeightParam = params.get('maxHeight');\n const containerMaxHeight = maxHeightParam ? Number(maxHeightParam) : undefined;\n const maxWidthParam = params.get('maxWidth');\n const containerMaxWidth = maxWidthParam ? Number(maxWidthParam) : undefined;\n const host = (params.get('host') as HostId) ?? undefined;\n\n const prodResourcesParam = params.get('prodResources');\n const prodResources =\n prodResourcesParam === 'true' ? true : prodResourcesParam === 'false' ? false : undefined;\n\n const sidebarParam = params.get('sidebar');\n const sidebar = sidebarParam === 'false' ? false : sidebarParam === 'true' ? true : undefined;\n\n const devOverlayParam = params.get('devOverlay');\n const devOverlay =\n devOverlayParam === 'false' ? false : devOverlayParam === 'true' ? true : undefined;\n\n // Map deviceType param to MCP Apps platform\n const deviceType = params.get('deviceType');\n let platform: Platform | undefined;\n if (deviceType === 'mobile' || deviceType === 'tablet') {\n platform = 'mobile';\n } else if (deviceType === 'desktop') {\n platform = 'desktop';\n }\n\n // Device capabilities\n const hoverParam = params.get('hover');\n const touchParam = params.get('touch');\n const hasCapParams = hoverParam || touchParam;\n const deviceCapabilities = hasCapParams\n ? {\n hover: hoverParam === 'false' ? false : true,\n touch: touchParam === 'true' ? true : false,\n }\n : undefined;\n\n // Safe area insets\n const safeAreaTop = params.get('safeAreaTop');\n const safeAreaBottom = params.get('safeAreaBottom');\n const safeAreaLeft = params.get('safeAreaLeft');\n const safeAreaRight = params.get('safeAreaRight');\n const hasSafeAreaParams = safeAreaTop || safeAreaBottom || safeAreaLeft || safeAreaRight;\n const safeAreaInsets = hasSafeAreaParams\n ? {\n top: safeAreaTop ? Number(safeAreaTop) : 0,\n bottom: safeAreaBottom ? Number(safeAreaBottom) : 0,\n left: safeAreaLeft ? Number(safeAreaLeft) : 0,\n right: safeAreaRight ? Number(safeAreaRight) : 0,\n }\n : undefined;\n\n return {\n simulation,\n tool,\n theme: theme ?? undefined,\n displayMode: displayMode ?? undefined,\n locale: locale ?? undefined,\n containerMaxHeight,\n containerMaxWidth,\n platform,\n deviceCapabilities,\n safeAreaInsets,\n host: host ?? undefined,\n prodResources,\n sidebar,\n devOverlay,\n };\n}\n\nexport function useInspectorState({\n simulations,\n defaultHost = 'chatgpt',\n}: UseInspectorStateOptions): InspectorState {\n // Only list simulations with a UI resource — backend-only tools have nothing to render.\n const simulationNames = Object.keys(simulations)\n .filter((name) => simulations[name].resource)\n .sort((a, b) => {\n const simA = simulations[a];\n const simB = simulations[b];\n const resourceLabelA = (simA.resource!.title as string) || simA.resource!.name;\n const resourceLabelB = (simB.resource!.title as string) || simB.resource!.name;\n const labelA = `${resourceLabelA}: ${(simA.tool.title as string) || simA.tool.name}`;\n const labelB = `${resourceLabelB}: ${(simB.tool.title as string) || simB.tool.name}`;\n return labelA.localeCompare(labelB);\n });\n const urlParams = useMemo(() => parseUrlParams(), []);\n const [screenWidth, setScreenWidth] = useState<ScreenWidth>('full');\n\n const isMobileWidth = (width: ScreenWidth) => width === 'mobile-s' || width === 'mobile-l';\n\n // ── Host selection ──\n const [activeHost, setActiveHost] = useState<HostId>(urlParams.host ?? defaultHost);\n\n // ── Simulation selection ──\n const initialSimulationName = useMemo(() => {\n const defaultName = simulationNames[0] ?? '';\n if (!urlParams.simulation) return defaultName;\n return urlParams.simulation in simulations ? urlParams.simulation : defaultName;\n }, [urlParams.simulation, simulations, simulationNames]);\n\n const [selectedSimulationName, setSelectedSimulationName] =\n useState<string>(initialSimulationName);\n\n const selectedSim = simulations[selectedSimulationName];\n\n // ── Host context state ──\n\n const [theme, setTheme] = useState<McpUiTheme>(urlParams.theme ?? DEFAULT_THEME);\n const [displayMode, _setDisplayMode] = useState<McpUiDisplayMode>(\n urlParams.displayMode ?? DEFAULT_DISPLAY_MODE\n );\n const [locale, setLocale] = useState(urlParams.locale ?? 'en-US');\n const [containerHeight, setContainerHeight] = useState<number | undefined>(undefined);\n const [containerWidth, setContainerWidth] = useState<number | undefined>(undefined);\n const [containerMaxHeight, setContainerMaxHeight] = useState<number | undefined>(\n urlParams.containerMaxHeight\n );\n const [containerMaxWidth, setContainerMaxWidth] = useState<number | undefined>(\n urlParams.containerMaxWidth\n );\n const [platform, setPlatform] = useState<Platform>(urlParams.platform ?? DEFAULT_PLATFORM);\n const [hover, setHover] = useState(urlParams.deviceCapabilities?.hover ?? true);\n const [touch, setTouch] = useState(urlParams.deviceCapabilities?.touch ?? false);\n const [safeAreaInsets, setSafeAreaInsets] = useState(\n urlParams.safeAreaInsets ?? { top: 0, bottom: 0, left: 0, right: 0 }\n );\n const [timeZone, setTimeZone] = useState(() => Intl.DateTimeFormat().resolvedOptions().timeZone);\n\n // Content width measured from the conversation component's ResizeObserver.\n // Used as containerDimensions.maxWidth unless the user manually sets one.\n const [measuredContentWidth, setMeasuredContentWidth] = useState<number | undefined>(undefined);\n const handleContentWidthChange = useCallback((width: number) => {\n setMeasuredContentWidth(width);\n }, []);\n\n // Display mode setter that respects mobile width constraints\n const setDisplayMode = (mode: McpUiDisplayMode) => {\n if (isMobileWidth(screenWidth) && mode === 'pip') {\n _setDisplayMode('fullscreen');\n } else {\n _setDisplayMode(mode);\n }\n };\n\n // Callback for IframeResource's onDisplayModeReady (paint fence ack).\n // Currently a no-op — the inspector doesn't need to track the confirmed\n // display mode. Kept as a stable reference to avoid unnecessary re-renders.\n const handleDisplayModeReady = useCallback((_mode: string) => {}, []);\n\n // Build containerDimensions based on the current display mode.\n // Real hosts (ChatGPT) report different shapes per mode:\n // inline: { height: <content height>, maxWidth: <column width> }\n // fullscreen: { height: <viewport height>, width: <viewport width> }\n // pip: { height: <pip height>, maxWidth: <pip max width> }\n //\n // User-set sidebar values always take priority. When not set, we derive\n // values from the measured content width (ResizeObserver) and the\n // browser viewport for fullscreen mode.\n const containerDimensions = useMemo(() => {\n // User-set values always take priority\n if (\n containerHeight != null ||\n containerWidth != null ||\n containerMaxHeight != null ||\n containerMaxWidth != null\n ) {\n return {\n ...(containerHeight != null ? { height: containerHeight } : {}),\n ...(containerWidth != null ? { width: containerWidth } : {}),\n ...(containerMaxHeight != null ? { maxHeight: containerMaxHeight } : {}),\n ...(containerMaxWidth != null ? { maxWidth: containerMaxWidth } : {}),\n };\n }\n\n // Auto-derived dimensions based on display mode\n if (displayMode === 'fullscreen') {\n // Fullscreen: report actual viewport dimensions (width + height, no maxWidth).\n // Use window.innerHeight minus the fullscreen chrome header (52px).\n const h = typeof window !== 'undefined' ? window.innerHeight - 52 : 800;\n const w = measuredContentWidth ?? (typeof window !== 'undefined' ? window.innerWidth : 1280);\n return { height: h, width: w };\n }\n\n if (displayMode === 'pip') {\n // PiP: report maxHeight (not fixed height) — content determines actual height.\n // ChatGPT uses calc(50dvh - 38px): half the viewport minus chrome.\n // Confirmed by extraction at 7 viewport sizes (2026-03-21).\n const viewportH = typeof window !== 'undefined' ? window.innerHeight : 800;\n const pipMaxHeight = Math.round(viewportH * 0.5 - 38);\n return {\n maxHeight: pipMaxHeight,\n ...(measuredContentWidth != null ? { maxWidth: measuredContentWidth } : {}),\n };\n }\n\n // Inline: report maxWidth from the measured content container.\n if (measuredContentWidth != null) {\n return { maxWidth: measuredContentWidth };\n }\n\n return undefined;\n }, [\n containerHeight,\n containerWidth,\n containerMaxHeight,\n containerMaxWidth,\n measuredContentWidth,\n displayMode,\n ]);\n\n const hostContext = useMemo<McpUiHostContext>(\n () => ({\n theme,\n displayMode,\n availableDisplayModes: ['inline', 'pip', 'fullscreen'],\n locale,\n timeZone,\n platform,\n deviceCapabilities: { hover, touch },\n safeAreaInsets,\n ...(containerDimensions ? { containerDimensions } : {}),\n }),\n [\n theme,\n displayMode,\n locale,\n timeZone,\n platform,\n hover,\n touch,\n safeAreaInsets,\n containerDimensions,\n ]\n );\n\n // ── Tool data state ──\n\n const [toolInput, setToolInput] = useState<Record<string, unknown>>(\n () => selectedSim?.toolInput ?? {}\n );\n const [toolResult, setToolResult] = useState<CallToolResult | undefined>(\n () => selectedSim?.toolResult as CallToolResult | undefined\n );\n\n // Editable JSON strings for sidebar\n const [toolInputJson, setToolInputJson] = useState(() => JSON.stringify(toolInput, null, 2));\n const [toolResultJson, setToolResultJson] = useState(() =>\n JSON.stringify(toolResult ?? null, null, 2)\n );\n\n // Model context\n const [modelContextJson, setModelContextJson] = useState<string>('null');\n const [modelContext, setModelContext] = useState<Record<string, unknown> | null>(null);\n\n // Track which field is being edited\n const [editingField, setEditingField] = useState<string | null>(null);\n\n // JSON validation errors\n const [toolInputError, setToolInputError] = useState('');\n const [toolResultError, setToolResultError] = useState('');\n const [modelContextError, setModelContextError] = useState('');\n\n // Reset tool data when simulation changes.\n useEffect(() => {\n const newInput = selectedSim?.toolInput ?? {};\n const newResult = (selectedSim?.toolResult as CallToolResult | undefined) ?? undefined;\n setToolInput(newInput);\n setToolResult(newResult);\n if (editingField !== 'toolInput') {\n setToolInputJson(JSON.stringify(newInput, null, 2));\n setToolInputError('');\n }\n if (editingField !== 'toolResult') {\n setToolResultJson(JSON.stringify(newResult ?? null, null, 2));\n setToolResultError('');\n }\n if (editingField !== 'modelContext') {\n setModelContextJson('null');\n setModelContext(null);\n setModelContextError('');\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedSimulationName, selectedSim]);\n\n // Disallow PiP on mobile widths\n useEffect(() => {\n if (isMobileWidth(screenWidth) && displayMode === 'pip') {\n _setDisplayMode('fullscreen');\n }\n }, [screenWidth, displayMode]);\n\n // ── Host callbacks ──\n\n const handleDisplayModeChange = (mode: McpUiDisplayMode) => {\n setDisplayMode(mode);\n };\n\n const handleUpdateModelContext = (content: unknown[], structuredContent?: unknown) => {\n setModelContextJson(JSON.stringify(structuredContent ?? content, null, 2));\n };\n\n // ── JSON helpers ──\n\n const validateJSON = (\n json: string,\n setJson: (value: string) => void,\n setError: (error: string) => void\n ) => {\n setJson(json);\n try {\n if (json.trim() !== '') JSON.parse(json);\n setError('');\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Invalid JSON');\n }\n };\n\n const commitJSON = (\n json: string,\n setError: (error: string) => void,\n updateFn: (value: Record<string, unknown> | null) => void\n ) => {\n try {\n const parsed = json.trim() === '' ? null : JSON.parse(json);\n setError('');\n updateFn(parsed);\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Invalid JSON');\n } finally {\n setEditingField(null);\n }\n };\n\n // ── Content props ──\n\n const effectiveToolResult = useMemo((): CallToolResult | undefined => {\n if (!toolResult && !modelContext) return undefined;\n if (!modelContext) return toolResult;\n\n const baseResult = toolResult ?? { content: [] };\n const baseStructured = (baseResult.structuredContent as Record<string, unknown>) ?? {};\n return {\n ...baseResult,\n structuredContent: { ...baseStructured, ...modelContext },\n };\n }, [toolResult, modelContext]);\n\n const resourceUrl = selectedSim?.resourceUrl;\n const resourceScript = selectedSim?.resourceScript;\n const csp = selectedSim?.resource ? extractResourceCSP(selectedSim.resource) : undefined;\n const resourceMeta = (selectedSim?.resource?._meta as Record<string, unknown> | undefined)?.ui as\n | { permissions?: McpUiResourcePermissions; prefersBorder?: boolean; domain?: string }\n | undefined;\n const permissions = resourceMeta?.permissions;\n const prefersBorder = resourceMeta?.prefersBorder ?? false;\n\n return {\n simulationNames,\n selectedSimulationName,\n setSelectedSimulationName,\n selectedSim,\n\n activeHost,\n setActiveHost,\n\n screenWidth,\n setScreenWidth,\n\n theme,\n setTheme,\n displayMode,\n setDisplayMode,\n locale,\n setLocale,\n containerHeight,\n setContainerHeight,\n containerWidth,\n setContainerWidth,\n containerMaxHeight,\n setContainerMaxHeight,\n containerMaxWidth,\n setContainerMaxWidth,\n platform,\n setPlatform,\n hover,\n setHover,\n touch,\n setTouch,\n safeAreaInsets,\n setSafeAreaInsets,\n timeZone,\n setTimeZone,\n\n hostContext,\n\n handleDisplayModeReady,\n\n toolInput,\n setToolInput,\n toolResult,\n setToolResult,\n effectiveToolResult,\n\n modelContext,\n setModelContext,\n\n toolInputJson,\n setToolInputJson,\n toolInputError,\n setToolInputError,\n toolResultJson,\n setToolResultJson,\n toolResultError,\n setToolResultError,\n modelContextJson,\n setModelContextJson,\n modelContextError,\n setModelContextError,\n editingField,\n setEditingField,\n\n validateJSON,\n commitJSON,\n\n measuredContentWidth,\n handleContentWidthChange,\n\n handleDisplayModeChange,\n handleUpdateModelContext,\n\n resourceUrl,\n resourceScript,\n csp,\n permissions,\n prefersBorder,\n urlTool: urlParams.tool,\n urlProdResources: urlParams.prodResources,\n urlSidebar: urlParams.sidebar,\n urlDevOverlay: urlParams.devOverlay,\n };\n}\n","import { useState, useEffect, useCallback } from 'react';\n\nexport type AuthType = 'none' | 'bearer' | 'oauth';\n\nexport interface AuthConfig {\n type: AuthType;\n /** Bearer token (when type === 'bearer') */\n bearerToken?: string;\n}\n\nexport interface McpConnectionState {\n /** Current connection status */\n status: 'disconnected' | 'connecting' | 'connected' | 'error';\n /** Error message if status is 'error' */\n error?: string;\n /** Simulations returned after a successful reconnect (undefined until first reconnect or after a failed reconnect) */\n simulations?: Record<string, unknown>;\n /** True after at least one user-initiated reconnect has been attempted (URL change). */\n hasReconnected: boolean;\n /** Connect to a new MCP server URL. Returns discovered simulations on success. */\n reconnect: (url: string, auth?: AuthConfig) => Promise<void>;\n /** Update connection state after OAuth completes (bypasses /__sunpeak/connect). */\n setConnected: (simulations?: Record<string, unknown>) => void;\n}\n\n/**\n * Hook for managing MCP server connection status via the dev server proxy.\n *\n * On mount (when `initialServerUrl` is provided), verifies the connection is alive\n * by fetching `/__sunpeak/list-tools`. URL changes are handled by the caller\n * via `reconnect()`, which posts to `/__sunpeak/connect`.\n *\n * This split avoids React StrictMode issues: the mount-only health check runs\n * once (or safely twice with cancellation), while explicit `reconnect()` calls\n * are triggered by the Inspector's URL-change effect.\n */\nexport function useMcpConnection(initialServerUrl: string | undefined): McpConnectionState {\n const [status, setStatus] = useState<McpConnectionState['status']>(\n initialServerUrl ? 'connecting' : 'disconnected'\n );\n const [error, setError] = useState<string | undefined>();\n const [simulations, setSimulations] = useState<Record<string, unknown> | undefined>();\n const [hasReconnected, setHasReconnected] = useState(false);\n\n const reconnect = useCallback(async (url: string, auth?: AuthConfig) => {\n setHasReconnected(true);\n setStatus('connecting');\n setError(undefined);\n try {\n const body: Record<string, unknown> = { url };\n if (auth && auth.type !== 'none') {\n body.auth = auth;\n }\n const res = await fetch('/__sunpeak/connect', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n });\n if (!res.ok) {\n let message: string | undefined;\n try {\n const json = await res.json();\n if (json.error) message = json.error;\n } catch {\n // Response wasn't JSON — fall through to status-based message\n }\n if (!message) {\n if (res.status === 404) {\n message =\n 'Server not found at this URL. Check the URL and make sure the server is running.';\n } else if (res.status >= 500) {\n message = `Server error (${res.status}). Check the MCP server logs for details.`;\n } else {\n message = `Connection failed (${res.status})`;\n }\n }\n throw new Error(message);\n }\n const data = await res.json();\n setStatus('connected');\n setSimulations(data.simulations ?? undefined);\n } catch (err) {\n let message = err instanceof Error ? err.message : String(err);\n // fetch throws TypeError on network failure (server not running, DNS, etc.)\n if (err instanceof TypeError && message === 'Failed to fetch') {\n message = 'Cannot reach MCP server. Is it running?';\n }\n setError(message);\n setStatus('error');\n setSimulations(undefined);\n }\n }, []);\n\n const setConnected = useCallback((sims?: Record<string, unknown>) => {\n setHasReconnected(true);\n setStatus('connected');\n setError(undefined);\n setSimulations(sims);\n }, []);\n\n // Initial health check (mount-only). Verifies the connection is alive\n // when the component mounts with a pre-configured server URL.\n // In React StrictMode the first invocation is cancelled; the second runs to completion.\n useEffect(() => {\n if (!initialServerUrl) return;\n let cancelled = false;\n setStatus('connecting');\n (async () => {\n try {\n const res = await fetch('/__sunpeak/list-tools');\n if (cancelled) return;\n if (!res.ok) {\n const msg =\n res.status === 404\n ? 'MCP server not reachable. Is it running?'\n : `Health check failed (${res.status}). Check the MCP server logs.`;\n throw new Error(msg);\n }\n setStatus('connected');\n } catch (err) {\n if (cancelled) return;\n setError(err instanceof Error ? err.message : String(err));\n setStatus('error');\n }\n })();\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Mount-only — URL changes are handled by the caller via reconnect()\n\n return { status, error, simulations, hasReconnected, reconnect, setConnected };\n}\n","import * as React from 'react';\n\ntype Theme = 'light' | 'dark';\n\ntype ThemeProviderProps = {\n children: React.ReactNode;\n defaultTheme?: Theme;\n theme?: Theme;\n /** Custom theme applier. If not provided, falls back to setting data-theme attribute. */\n applyTheme?: (theme: Theme) => void;\n};\n\ntype ThemeProviderState = {\n theme: Theme;\n};\n\nconst ThemeProviderContext = React.createContext<ThemeProviderState | undefined>(undefined);\n\n/** Default theme applier: sets data-theme attribute on document.documentElement */\nfunction defaultApplyTheme(theme: Theme): void {\n if (typeof document !== 'undefined') {\n document.documentElement.setAttribute('data-theme', theme);\n }\n}\n\nexport function ThemeProvider({\n children,\n defaultTheme = 'light',\n theme: controlledTheme,\n applyTheme,\n ...props\n}: ThemeProviderProps) {\n const [internalTheme] = React.useState<Theme>(defaultTheme);\n\n const theme = controlledTheme ?? internalTheme;\n const applier = applyTheme ?? defaultApplyTheme;\n\n // Apply theme synchronously before paint to avoid FOUC\n React.useLayoutEffect(() => {\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n try {\n applier(theme);\n } catch (error) {\n console.warn('Failed to apply document theme:', error);\n }\n }\n }, [theme, applier]);\n\n const value = {\n theme,\n };\n\n return (\n <ThemeProviderContext.Provider {...props} value={value}>\n {children}\n </ThemeProviderContext.Provider>\n );\n}\n\nexport const useThemeContext = () => {\n const context = React.useContext(ThemeProviderContext);\n\n if (context === undefined) throw new Error('useThemeContext must be used within a ThemeProvider');\n\n return context;\n};\n","import * as React from 'react';\nimport { useState } from 'react';\n\ninterface SimpleSidebarProps {\n children: React.ReactNode;\n controls: React.ReactNode;\n /** Optional element rendered right-aligned in the Controls header row */\n headerRight?: React.ReactNode;\n}\n\nconst DEFAULT_SIDEBAR_WIDTH = 260; // ChatGPT sidebar: 260px (extracted 2026-03-21)\n\nfunction ChevronRightIcon() {\n return (\n <svg width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path\n fillRule=\"evenodd\"\n d=\"M8.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L14.586 12 8.293 5.707a1 1 0 0 1 0-1.414Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n );\n}\n\nexport function SimpleSidebar({ children, controls, headerRight }: SimpleSidebarProps) {\n const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);\n const [sidebarWidth, setSidebarWidth] = React.useState(DEFAULT_SIDEBAR_WIDTH);\n const [isResizing, setIsResizing] = React.useState(false);\n\n const handleMouseDown = React.useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n setIsResizing(true);\n }, []);\n\n React.useEffect(() => {\n if (!isResizing) return;\n\n const handleMouseMove = (e: MouseEvent) => {\n const maxWidth = Math.floor(window.innerWidth / 3);\n const newWidth = Math.min(maxWidth, Math.max(DEFAULT_SIDEBAR_WIDTH, e.clientX));\n setSidebarWidth(newWidth);\n };\n\n const handleMouseUp = () => {\n setIsResizing(false);\n };\n\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n\n return () => {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n };\n }, [isResizing]);\n\n return (\n <div className=\"sunpeak-inspector-root flex h-screen w-full overflow-hidden relative\">\n {/* Resize overlay to capture mouse events during drag */}\n {isResizing && <div className=\"fixed inset-0 z-50 cursor-col-resize\" />}\n\n {/* Mobile drawer overlay */}\n {isDrawerOpen && (\n <div\n className=\"md:hidden fixed inset-0 bg-black/50 z-40 pointer-events-auto\"\n onClick={(e) => {\n if (e.target === e.currentTarget) {\n setIsDrawerOpen(false);\n }\n }}\n />\n )}\n\n {/* Sidebar */}\n <aside\n className={`\n relative flex flex-col bg-sidebar\n md:z-auto\n max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-[100]\n max-md:transition-transform max-md:duration-300 max-md:!w-2/3\n ${isDrawerOpen ? 'max-md:translate-x-0' : 'max-md:-translate-x-full'}\n `}\n style={{\n width: sidebarWidth,\n borderRight: '1px solid var(--color-border-primary)',\n }}\n >\n <div className=\"flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0\">\n <div className=\"space-y-3\">\n <div>\n <div className=\"flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2\">\n <h2\n className=\"text-xs font-semibold\"\n style={{ color: 'var(--color-text-primary)' }}\n >\n Controls\n </h2>\n <div className=\"flex items-center gap-2\">\n {headerRight}\n {/* Close button for mobile */}\n <button\n onClick={() => setIsDrawerOpen(false)}\n className=\"md:hidden p-1 transition-colors\"\n style={{ color: 'var(--color-text-secondary)' }}\n type=\"button\"\n aria-label=\"Close sidebar\"\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 4L4 12M4 4L12 12\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n </button>\n </div>\n </div>\n {controls}\n </div>\n </div>\n </div>\n\n {/* Resize handle */}\n <div\n onMouseDown={handleMouseDown}\n className=\"hidden md:block absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-black/10 dark:hover:bg-white/10 active:bg-black/20 dark:active:bg-white/20 transition-colors\"\n />\n </aside>\n\n {/* Main content */}\n <main className=\"flex-1 overflow-auto relative\">\n {/* Mobile drawer toggle button */}\n <button\n onClick={() => setIsDrawerOpen(true)}\n className=\"md:hidden fixed top-18 left-0 z-30 bg-sidebar rounded-r-md p-2 shadow-lg hover:bg-black/5 dark:hover:bg-white/10 transition-colors\"\n style={{\n borderRight: '1px solid var(--color-border-primary)',\n borderTop: '1px solid var(--color-border-primary)',\n borderBottom: '1px solid var(--color-border-primary)',\n }}\n type=\"button\"\n aria-label=\"Open sidebar\"\n >\n <ChevronRightIcon />\n </button>\n {children}\n </main>\n </div>\n );\n}\n\n/* ── Help icon with tooltip ── */\n\nconst DOCS_BASE_URL = 'https://sunpeak.ai/docs';\n\ninterface HelpIconProps {\n tooltip: string;\n docsPath: string;\n}\n\nfunction HelpIcon({ tooltip, docsPath }: HelpIconProps) {\n const [pos, setPos] = React.useState<{ top: number; left: number } | null>(null);\n const ref = React.useRef<HTMLAnchorElement>(null);\n\n const showTooltip = () => {\n const rect = ref.current?.getBoundingClientRect();\n if (rect) {\n setPos({ top: rect.top + rect.height / 2, left: rect.right + 6 });\n }\n };\n\n return (\n <a\n ref={ref}\n href={`${DOCS_BASE_URL}/${docsPath}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center justify-center no-underline flex-shrink-0 transition-colors\"\n style={{\n color: 'var(--color-text-tertiary, var(--color-text-secondary))',\n }}\n onClick={(e) => e.stopPropagation()}\n onMouseEnter={showTooltip}\n onMouseLeave={() => setPos(null)}\n >\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"6\" cy=\"6\" r=\"5.25\" stroke=\"currentColor\" strokeWidth=\"1\" />\n <text\n x=\"6.25\"\n y=\"8.5\"\n textAnchor=\"middle\"\n fill=\"currentColor\"\n fontSize=\"7.5\"\n fontWeight=\"600\"\n fontFamily=\"system-ui, sans-serif\"\n >\n ?\n </text>\n </svg>\n {pos && (\n <span\n className=\"pointer-events-none fixed whitespace-nowrap rounded px-2 py-1 text-[11px] font-normal leading-tight z-[200]\"\n style={{\n top: pos.top,\n left: pos.left,\n transform: 'translateY(-50%)',\n backgroundColor: 'var(--color-text-primary)',\n color: 'var(--color-background-primary)',\n }}\n >\n {tooltip}\n </span>\n )}\n </a>\n );\n}\n\ninterface SidebarControlProps {\n label: React.ReactNode;\n children: React.ReactNode;\n /** Short tooltip shown on hover of the help icon */\n tooltip?: string;\n /** Docs path appended to https://sunpeak.ai/docs/ */\n docsPath?: string;\n 'data-testid'?: string;\n}\n\nexport function SidebarControl({\n label,\n children,\n tooltip,\n docsPath,\n 'data-testid': testId,\n}: SidebarControlProps) {\n return (\n <div className=\"space-y-1\" data-testid={testId}>\n <span\n className=\"text-[10px] font-medium leading-tight inline-flex items-center gap-1\"\n style={{ color: 'var(--color-text-secondary)' }}\n >\n {label}\n {tooltip && docsPath && <HelpIcon tooltip={tooltip} docsPath={docsPath} />}\n </span>\n {children}\n </div>\n );\n}\n\ninterface SidebarCollapsibleControlProps {\n label: string;\n children: React.ReactNode;\n defaultCollapsed?: boolean;\n /** Short tooltip shown on hover of the help icon */\n tooltip?: string;\n /** Docs path appended to https://sunpeak.ai/docs/ */\n docsPath?: string;\n 'data-testid'?: string;\n}\n\nexport function SidebarCollapsibleControl({\n label,\n children,\n defaultCollapsed = true,\n tooltip,\n docsPath,\n 'data-testid': testId,\n}: SidebarCollapsibleControlProps) {\n const [isCollapsed, setIsCollapsed] = React.useState(defaultCollapsed);\n\n return (\n <div className=\"space-y-1\" data-testid={testId}>\n <button\n onClick={() => setIsCollapsed(!isCollapsed)}\n className=\"w-full flex items-center justify-between text-[10px] font-medium leading-tight transition-colors py-1 cursor-pointer\"\n style={{ color: 'var(--color-text-secondary)' }}\n type=\"button\"\n >\n <span className=\"inline-flex items-center gap-1\">\n {label}\n {tooltip && docsPath && <HelpIcon tooltip={tooltip} docsPath={docsPath} />}\n </span>\n <span className=\"text-[8px]\">{isCollapsed ? '▶' : '▼'}</span>\n </button>\n {!isCollapsed && children}\n </div>\n );\n}\n\n/* ── Shared form element styles ── */\n\nconst formElementStyle: React.CSSProperties = {\n color: 'var(--color-text-primary)',\n backgroundColor: 'var(--color-background-primary)',\n cursor: 'pointer',\n};\n\ninterface SidebarSelectProps {\n value: string;\n onChange: (value: string) => void;\n options: Array<{ value: string; label: string }>;\n placeholder?: string;\n}\n\nexport function SidebarSelect({ value, onChange, options, placeholder }: SidebarSelectProps) {\n return (\n <select\n value={value}\n onChange={(e) => onChange(e.target.value)}\n className=\"w-full h-7 text-xs rounded-full px-2 outline-none appearance-none bg-no-repeat bg-[length:12px] bg-[right_6px_center]\"\n style={{\n ...formElementStyle,\n backgroundImage: `url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3e%3cpath d='M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z'/%3e%3c/svg%3e\")`,\n paddingRight: '1.5rem',\n }}\n >\n {placeholder && (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n )}\n {options.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n );\n}\n\ninterface SidebarInputProps {\n value: string;\n onChange: (value: string) => void;\n /** When provided, onChange is only called on blur instead of on every keystroke. */\n applyOnBlur?: boolean;\n placeholder?: string;\n type?: 'text' | 'number' | 'password';\n disabled?: boolean;\n}\n\nexport function SidebarInput({\n value,\n onChange,\n applyOnBlur = false,\n placeholder,\n type = 'text',\n disabled = false,\n}: SidebarInputProps) {\n const [draft, setDraft] = useState(value);\n const [isEditing, setIsEditing] = useState(false);\n const [prevValue, setPrevValue] = useState(value);\n\n // Sync draft when the controlled value changes externally (while not editing).\n // Done during render (not in an effect) to avoid cascading renders.\n if (!isEditing && value !== prevValue) {\n setPrevValue(value);\n setDraft(value);\n }\n\n if (applyOnBlur) {\n return (\n <input\n type={type}\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onFocus={() => setIsEditing(true)}\n onBlur={() => {\n setIsEditing(false);\n onChange(draft);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n setIsEditing(false);\n onChange(draft);\n (e.target as HTMLInputElement).blur();\n }\n }}\n placeholder={placeholder}\n disabled={disabled}\n className=\"w-full h-7 text-xs rounded-md px-2 outline-none disabled:opacity-50 disabled:cursor-not-allowed\"\n style={{ ...formElementStyle, cursor: disabled ? undefined : 'text' }}\n />\n );\n }\n\n return (\n <input\n type={type}\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n disabled={disabled}\n className=\"w-full h-7 text-xs rounded-md px-2 outline-none disabled:opacity-50 disabled:cursor-not-allowed\"\n style={{ ...formElementStyle, cursor: disabled ? undefined : 'text' }}\n />\n );\n}\n\ninterface SidebarCheckboxProps {\n checked: boolean;\n onChange: (checked: boolean) => void;\n label: string;\n /** Short tooltip shown on hover of the help icon */\n tooltip?: string;\n /** Docs path appended to https://sunpeak.ai/docs/ */\n docsPath?: string;\n}\n\nexport function SidebarCheckbox({\n checked,\n onChange,\n label,\n tooltip,\n docsPath,\n}: SidebarCheckboxProps) {\n const id = React.useId();\n return (\n <div className=\"flex items-center gap-1.5\">\n <input\n id={id}\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onChange(e.target.checked)}\n className=\"outline-none cursor-pointer\"\n />\n <label\n htmlFor={id}\n className=\"text-[11px] select-none cursor-pointer leading-tight inline-flex items-center gap-1\"\n style={{ color: 'var(--color-text-primary)' }}\n >\n {label}\n {tooltip && docsPath && <HelpIcon tooltip={tooltip} docsPath={docsPath} />}\n </label>\n </div>\n );\n}\n\ninterface SidebarTextareaProps {\n value: string;\n onChange: (value: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n placeholder?: string;\n maxRows?: number;\n error?: string;\n 'data-testid'?: string;\n}\n\nexport function SidebarTextarea({\n value,\n onChange,\n onFocus,\n onBlur,\n placeholder,\n maxRows = 8,\n error,\n 'data-testid': testId,\n}: SidebarTextareaProps) {\n const contentRows = value?.split('\\n').length ?? 1;\n const rows = Math.min(contentRows, maxRows);\n\n return (\n <div className=\"space-y-0.5\">\n <textarea\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onFocus={onFocus}\n onBlur={onBlur}\n placeholder={placeholder}\n rows={rows}\n data-testid={testId}\n className=\"w-full text-[10px] font-mono rounded-md px-2 py-1.5 outline-none resize-y\"\n style={{\n ...formElementStyle,\n cursor: 'text',\n whiteSpace: 'pre',\n overflowX: 'auto',\n overflowWrap: 'normal',\n ...(error ? { boxShadow: 'inset 0 0 0 1px var(--color-text-danger, #dc2626)' } : {}),\n }}\n aria-invalid={!!error}\n />\n {error && (\n <div className=\"text-[9px]\" style={{ color: 'var(--color-text-danger, #dc2626)' }}>\n {error}\n </div>\n )}\n </div>\n );\n}\n\ninterface SidebarToggleProps {\n value: string;\n onChange: (value: string) => void;\n options: Array<{ value: string; label: string }>;\n}\n\nexport function SidebarToggle({ value, onChange, options }: SidebarToggleProps) {\n return (\n <div\n className=\"inline-flex w-full rounded-full p-[3px] gap-0.5\"\n style={{ backgroundColor: 'var(--color-background-tertiary)' }}\n role=\"group\"\n aria-label=\"Toggle options\"\n >\n {options.map((option) => {\n const isSelected = value === option.value;\n return (\n <button\n key={option.value}\n onClick={() => onChange(option.value)}\n aria-pressed={isSelected}\n className=\"flex-1 text-[10px] font-medium h-[22px] px-2 rounded-full outline-none transition-all duration-150 cursor-pointer\"\n style={{\n backgroundColor: isSelected ? 'var(--color-background-primary)' : 'transparent',\n color: isSelected ? 'var(--color-text-primary)' : 'var(--color-text-secondary)',\n boxShadow: isSelected ? '0 1px 2px 0 rgba(0,0,0,0.06)' : 'none',\n }}\n type=\"button\"\n >\n {option.label}\n </button>\n );\n })}\n </div>\n );\n}\n","/**\n * Core simulation types for development and testing.\n * These types define how simulations are configured and used in both\n * the dev inspector and MCP server contexts.\n */\n\nimport type { Tool, Resource, CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { McpUiHostContext } from '@modelcontextprotocol/ext-apps';\n\n/**\n * Mock response for a server tool call within a simulation.\n *\n * Simple form: a single `CallToolResult` always returned.\n * Conditional form: an array of `{ when, result }` entries — the first\n * entry whose `when` keys shallow-match the call arguments wins.\n */\nexport type ServerToolMock =\n | CallToolResult\n | Array<{ when: Record<string, unknown>; result: CallToolResult }>;\n\n/**\n * A simulation packages a component with its example data and metadata.\n * Each simulation represents a complete tool experience in the inspector.\n *\n * Resource rendering options (mutually exclusive):\n * - `resourceUrl`: URL to an HTML page (dev mode with Vite HMR)\n * - `resourceScript`: URL to a built resource file (production builds)\n */\nexport interface Simulation {\n // Unique identifier derived from the simulation filename (e.g., 'show-albums')\n name: string;\n\n // URL to an HTML page to load in an iframe (dev mode).\n // The page mounts the resource component and uses SDK's useApp().\n resourceUrl?: string;\n\n // URL to a built resource for iframe rendering (production builds).\n resourceScript?: string;\n\n userMessage?: string; // Decoration for the inspector, no functional purpose.\n\n // Official Tool type from the MCP SDK, used in ListTools response.\n tool: Tool;\n\n // Official Resource type from the MCP SDK, used in ListResources response.\n // Undefined for tools without a UI.\n resource?: Resource;\n\n // Tool input arguments (the arguments object sent to CallTool).\n toolInput?: Record<string, unknown>;\n\n // Tool result data (the response from CallTool).\n toolResult?: {\n content?: Array<{ type: string; text: string }>;\n structuredContent?: unknown;\n isError?: boolean;\n };\n\n // Initial host context overrides for the simulation.\n hostContext?: Partial<McpUiHostContext>;\n\n /**\n * Mock responses for `callServerTool` calls made by the resource.\n * Keys are tool names; values are either a single result or an array\n * of conditional `{ when, result }` entries for argument-based matching.\n */\n serverTools?: Record<string, ServerToolMock>;\n}\n\n/**\n * Resolve a `ServerToolMock` to a concrete `CallToolResult` given the call arguments.\n *\n * - Simple form (single result): returns it directly.\n * - Conditional form (array of `{ when, result }`): returns the first entry\n * whose `when` keys all shallow-equal the corresponding values in `args`.\n * Falls back to `undefined` if no condition matches.\n */\nexport function resolveServerToolResult(\n mock: ServerToolMock,\n args: Record<string, unknown> | undefined\n): CallToolResult | undefined {\n if (!Array.isArray(mock)) return mock;\n\n for (const entry of mock) {\n const matches = Object.entries(entry.when).every(\n ([key, value]) => args != null && args[key] === value\n );\n if (matches) return entry.result;\n }\n return undefined;\n}\n","import * as React from 'react';\nimport type {\n McpUiDisplayMode,\n McpUiTheme,\n McpUiHostContext,\n} from '@modelcontextprotocol/ext-apps';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { useInspectorState } from './use-inspector-state';\nimport { useMcpConnection, type AuthType, type AuthConfig } from './use-mcp-connection';\nimport { IframeResource } from './iframe-resource';\nimport { ThemeProvider } from './theme-provider';\nimport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\nimport { getHostShell, getRegisteredHosts, type HostId } from './hosts';\nimport { resolveServerToolResult } from '../types/simulation';\nimport type { Simulation } from '../types/simulation';\nimport type { ScreenWidth } from './inspector-types';\n\n// Register built-in host shells. These imports live here (in the component file)\n// rather than in the barrel index.ts because Rollup code-splitting can separate\n// side-effect imports from barrel exports, letting consumer bundlers tree-shake\n// them. Importing here makes registration part of the Inspector component's\n// dependency graph, which can't be tree-shaken since the component is used.\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\nconst DOCS_BASE_URL = 'https://sunpeak.ai/docs';\n\nexport interface InspectorProps {\n children?: React.ReactNode;\n simulations?: Record<string, Simulation>;\n appName?: string;\n appIcon?: string;\n /** Which host shell to use initially. Defaults to 'chatgpt'. */\n defaultHost?: HostId;\n /** Override callServerTool resolution. When provided, bypasses simulation serverTools mocks. Routes through MCP which returns simulation fixture data for UI tools. */\n onCallTool?: (params: {\n name: string;\n arguments?: Record<string, unknown>;\n }) => Promise<CallToolResult> | CallToolResult;\n /** Direct tool handler call, bypassing MCP server mock data. Falls back to onCallTool if not provided. */\n onCallToolDirect?: (params: {\n name: string;\n arguments?: Record<string, unknown>;\n }) => Promise<CallToolResult> | CallToolResult;\n /** Initial prod-resources mode state. When true, resources load from dist/ instead of HMR. Defaults to false. */\n defaultProdResources?: boolean;\n /** Hide framework-only controls (Prod Resources) in the sidebar. */\n hideInspectorModes?: boolean;\n /**\n * Demo mode for embedding on marketing sites. When true:\n * - Hides Prod Resources checkbox\n * - Disables the MCP Server URL input (shows a static example URL)\n * - Hides the Run button (prevents sending real MCP requests)\n * - Hides connection status indicator\n */\n demoMode?: boolean;\n /**\n * Base URL of the separate-origin sandbox server (e.g., \"http://localhost:24680\").\n * When provided, the outer iframe loads from this URL instead of using srcdoc,\n * giving real cross-origin isolation that matches production hosts.\n */\n sandboxUrl?: string;\n /**\n * MCP server URL. Pre-populates the server URL field in the sidebar and\n * shows connection status. Users can edit this URL at any time to connect\n * to a different server.\n */\n mcpServerUrl?: string;\n}\n\ntype Platform = 'mobile' | 'desktop' | 'web';\n\n/** Info about a unique tool, derived from simulations. */\ninterface ToolInfo {\n tool: Simulation['tool'];\n resource?: Simulation['resource'];\n /** All simulation names for this tool (first entry is the \"base\" for resource URL). */\n simNames: string[];\n /** Simulation names that have fixture data (toolInput, toolResult, or serverTools). */\n fixtureSimNames: string[];\n}\n\n/** Check whether a simulation has user-authored fixture data. */\nfunction hasFixtureData(sim: Simulation): boolean {\n return sim.toolResult != null || sim.toolInput != null || sim.serverTools != null;\n}\n\nexport function Inspector({\n children,\n simulations: initialSimulations = {},\n appName = 'Sunpeak',\n appIcon,\n defaultHost = 'chatgpt',\n onCallTool,\n onCallToolDirect,\n defaultProdResources = false,\n hideInspectorModes = false,\n demoMode = false,\n sandboxUrl,\n mcpServerUrl,\n}: InspectorProps) {\n // Simulations can be updated when the user reconnects to a different server.\n const [simulations, setSimulations] = React.useState(initialSimulations);\n // Sync with prop changes (e.g., HMR during development).\n React.useEffect(() => {\n setSimulations(initialSimulations);\n }, [initialSimulations]);\n\n // ── Derive tools from simulations ──\n // Each unique tool name becomes a ToolInfo with all its associated simulations.\n const toolMap = React.useMemo(() => {\n const map = new Map<string, ToolInfo>();\n for (const [simName, sim] of Object.entries(simulations)) {\n if (!sim.resource) continue; // Skip backend-only tools\n const toolName = sim.tool.name;\n if (!map.has(toolName)) {\n map.set(toolName, {\n tool: sim.tool,\n resource: sim.resource,\n simNames: [],\n fixtureSimNames: [],\n });\n }\n const info = map.get(toolName)!;\n info.simNames.push(simName);\n if (hasFixtureData(sim)) {\n info.fixtureSimNames.push(simName);\n }\n }\n return map;\n }, [simulations]);\n\n const toolNames = React.useMemo(\n () =>\n Array.from(toolMap.keys()).sort((a, b) => {\n const infoA = toolMap.get(a)!;\n const infoB = toolMap.get(b)!;\n const labelA = (infoA.tool.title as string | undefined) || a;\n const labelB = (infoB.tool.title as string | undefined) || b;\n return labelA.localeCompare(labelB);\n }),\n [toolMap]\n );\n\n // Parse URL params once for tool/simulation initialization.\n const initUrlParams = React.useMemo(() => {\n if (typeof window === 'undefined') return { tool: null, simulation: null, noMockData: false };\n const params = new URLSearchParams(window.location.search);\n return {\n tool: params.get('tool'),\n simulation: params.get('simulation'),\n noMockData: false,\n };\n }, []);\n\n // ── Tool selection ──\n // ?tool=X explicitly selects a tool. ?simulation=X infers the tool from the simulation.\n const [selectedToolName, setSelectedToolName] = React.useState(() => {\n if (initUrlParams.tool && toolMap.has(initUrlParams.tool)) return initUrlParams.tool;\n if (initUrlParams.simulation) {\n for (const [toolName, info] of toolMap) {\n if (info.simNames.includes(initUrlParams.simulation)) return toolName;\n }\n }\n return toolNames[0] ?? '';\n });\n\n // Reset tool selection when tools change (e.g., after reconnect)\n const prevToolNamesRef = React.useRef(toolNames);\n if (prevToolNamesRef.current !== toolNames) {\n prevToolNamesRef.current = toolNames;\n if (toolNames.length > 0 && !toolMap.has(selectedToolName)) {\n setSelectedToolName(toolNames[0]);\n }\n }\n\n const selectedToolInfo = toolMap.get(selectedToolName);\n\n // ── Simulation selection ──\n // null = \"None\" (no mock data, call the real server)\n // string = a specific simulation with fixture data\n // ?tool=X without ?simulation=Y means \"select tool, no mock data\"\n const [activeSimulationName, setActiveSimulationName] = React.useState<string | null>(() => {\n if (!selectedToolInfo) return null;\n if (initUrlParams.noMockData) return null;\n if (initUrlParams.tool && !initUrlParams.simulation) return null;\n // ?simulation=X explicitly selects a simulation (if it exists and has fixture data)\n if (\n initUrlParams.simulation &&\n selectedToolInfo.fixtureSimNames.includes(initUrlParams.simulation)\n ) {\n return initUrlParams.simulation;\n }\n return selectedToolInfo.fixtureSimNames[0] ?? null;\n });\n\n // When tool changes, auto-select first fixture simulation (or null)\n const prevToolNameRef = React.useRef(selectedToolName);\n if (prevToolNameRef.current !== selectedToolName) {\n prevToolNameRef.current = selectedToolName;\n const newInfo = toolMap.get(selectedToolName);\n setActiveSimulationName(newInfo?.fixtureSimNames[0] ?? null);\n }\n\n // The effective simulation name for useInspectorState:\n // - If a fixture simulation is active, use it (for tool input, tool result, resource URL)\n // - Otherwise, use the base simulation for the tool (for resource URL, tool definition)\n const effectiveSimulationName = activeSimulationName ?? selectedToolInfo?.simNames[0] ?? '';\n\n // Derive the current simulation directly from simulations + effectiveSimulationName.\n // This avoids the one-render lag from the useEffect sync to state.selectedSimulationName.\n const currentSim = simulations[effectiveSimulationName];\n\n const state = useInspectorState({ simulations, defaultHost });\n const [serverUrl, setServerUrl] = React.useState(mcpServerUrl ?? '');\n const [authType, setAuthType] = React.useState<AuthType>('none');\n const [bearerToken, setBearerToken] = React.useState('');\n const [oauthScopes, setOauthScopes] = React.useState('');\n const [oauthClientId, setOauthClientId] = React.useState('');\n const [oauthClientSecret, setOauthClientSecret] = React.useState('');\n const [oauthStatus, setOauthStatus] = React.useState<\n 'none' | 'authorizing' | 'authorized' | 'error'\n >('none');\n const [oauthError, setOauthError] = React.useState<string | undefined>();\n\n // useMcpConnection does a mount-only health check for the initial URL.\n // URL changes are handled below via connection.reconnect().\n const connection = useMcpConnection(mcpServerUrl || undefined);\n const [prodResources, setProdResources] = React.useState(\n state.urlProdResources ?? defaultProdResources\n );\n const showSidebar = state.urlSidebar !== false;\n const showDevOverlay = state.urlDevOverlay !== false;\n const [isRunning, setIsRunning] = React.useState(false);\n const [hasRun, setHasRun] = React.useState(false);\n const [showCheck, setShowCheck] = React.useState(false);\n const checkTimerRef = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const oauthCleanupRef = React.useRef<(() => void) | undefined>(undefined);\n\n // Keep useInspectorState's selection in sync with our tool/simulation selection.\n React.useEffect(() => {\n state.setSelectedSimulationName(effectiveSimulationName);\n }, [effectiveSimulationName]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // Build the current auth config for reconnects\n const currentAuthConfig = React.useMemo<AuthConfig | undefined>(() => {\n if (authType === 'bearer' && bearerToken) {\n return { type: 'bearer', bearerToken };\n }\n if (authType === 'oauth') {\n return { type: 'oauth' };\n }\n return undefined;\n }, [authType, bearerToken]);\n\n // Handle URL changes: when the user edits the server URL, reconnect to the new server.\n // The hook's mount-only health check handles the initial URL — this effect handles changes.\n const prevServerUrlRef = React.useRef(serverUrl);\n React.useEffect(() => {\n const urlChanged = serverUrl !== prevServerUrlRef.current;\n prevServerUrlRef.current = serverUrl;\n if (!urlChanged) return;\n if (serverUrl) {\n // Reset OAuth status when URL changes\n setOauthStatus('none');\n setOauthError(undefined);\n if (authType === 'oauth') {\n // Don't auto-connect for OAuth — user must click Authorize\n return;\n }\n connection.reconnect(serverUrl, currentAuthConfig);\n }\n }, [serverUrl, connection.reconnect, authType, currentAuthConfig]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // OAuth flow handler (disabled in demo mode)\n const handleStartOAuth = React.useCallback(async () => {\n if (!serverUrl || demoMode) return;\n setOauthStatus('authorizing');\n setOauthError(undefined);\n\n // Open a blank popup immediately (synchronous, inside the click handler)\n // so browsers treat it as a user-initiated action and don't block it.\n // We'll navigate it to the auth URL after the server responds.\n const popup = window.open(\n 'about:blank',\n `sunpeak-oauth-${Date.now()}`,\n 'width=600,height=700,popup=yes'\n );\n\n try {\n const res = await fetch('/__sunpeak/oauth/start', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n url: serverUrl,\n scope: oauthScopes || undefined,\n clientId: oauthClientId || undefined,\n clientSecret: oauthClientSecret || undefined,\n }),\n });\n if (!res.ok) {\n let message = `OAuth start failed (${res.status})`;\n try {\n const json = await res.json();\n if (json.error) message = json.error;\n } catch {\n // Response wasn't JSON\n }\n throw new Error(message);\n }\n const data = await res.json();\n\n if (data.error) {\n popup?.close();\n setOauthError(data.error);\n setOauthStatus('error');\n return;\n }\n\n if (data.status === 'authorized') {\n // Already authorized (tokens were cached)\n popup?.close();\n setOauthStatus('authorized');\n connection.setConnected(data.simulations);\n return;\n }\n\n if (data.status === 'redirect' && data.authUrl) {\n // Navigate the pre-opened popup to the authorization URL.\n // If the popup was blocked, show an error.\n if (!popup || popup.closed) {\n setOauthError('Popup was blocked. Allow popups for this site and try again.');\n setOauthStatus('error');\n return;\n }\n popup.location.href = data.authUrl;\n\n // Listen for the popup's callback via two channels:\n // 1. postMessage — works when window.opener is available\n // 2. BroadcastChannel — fallback for OAuth providers that set\n // Cross-Origin-Opener-Policy (COOP) which nullifies window.opener\n let checkClosed: ReturnType<typeof setInterval>;\n let bc: BroadcastChannel | undefined;\n const cleanup = () => {\n clearInterval(checkClosed);\n window.removeEventListener('message', handleMessage);\n bc?.close();\n oauthCleanupRef.current = undefined;\n };\n // Store cleanup so it runs on unmount if the popup is still open.\n oauthCleanupRef.current?.();\n oauthCleanupRef.current = cleanup;\n const handleOAuthResult = (result: Record<string, unknown>) => {\n cleanup();\n if (result.error) {\n setOauthError((result.errorDescription || result.error) as string);\n setOauthStatus('error');\n } else if (result.success) {\n setOauthStatus('authorized');\n connection.setConnected(result.simulations as Record<string, unknown> | undefined);\n }\n };\n // Channel 1: postMessage (origin-verified)\n const handleMessage = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) return;\n if (event.data?.type !== 'sunpeak-oauth-callback') return;\n handleOAuthResult(event.data);\n };\n window.addEventListener('message', handleMessage);\n // Channel 2: BroadcastChannel (same-origin by spec, no extra check needed)\n if (typeof BroadcastChannel !== 'undefined') {\n bc = new BroadcastChannel('sunpeak-oauth');\n bc.onmessage = (event) => {\n if (event.data?.type !== 'sunpeak-oauth-callback') return;\n handleOAuthResult(event.data);\n };\n }\n\n // Clean up if popup is closed without completing\n checkClosed = setInterval(() => {\n if (popup?.closed) {\n cleanup();\n // Only reset if still authorizing (not yet completed)\n setOauthStatus((prev) => (prev === 'authorizing' ? 'none' : prev));\n }\n }, 500);\n }\n } catch (err) {\n popup?.close();\n setOauthError(err instanceof Error ? err.message : String(err));\n setOauthStatus('error');\n }\n }, [serverUrl, oauthScopes, oauthClientId, oauthClientSecret, demoMode, connection]);\n\n // When reconnecting to a new server succeeds, update simulations.\n // Only clear on error after a user-initiated reconnect (URL change), not on the\n // initial health check — so prop-based simulations from fixture files survive\n // a server that happens to be unreachable on mount.\n React.useEffect(() => {\n if (connection.simulations) {\n setSimulations(connection.simulations as Record<string, Simulation>);\n } else if (connection.status === 'error' && connection.hasReconnected) {\n setSimulations({});\n }\n }, [connection.simulations, connection.status, connection.hasReconnected]);\n\n // Sync mock data based on the active simulation selection.\n // - \"None\" (null): clear toolResult so the \"Press Run\" empty state shows.\n // - Simulation selected: restore toolResult from the fixture. This handles the\n // case where effectiveSimulationName didn't change (e.g., None → same fixture),\n // so useInspectorState's internal sync wouldn't re-run.\n const { setToolResult, setToolResultJson, setToolResultError } = state;\n React.useEffect(() => {\n if (activeSimulationName === null) {\n setToolResult(undefined);\n setToolResultJson('');\n setToolResultError('');\n } else {\n const sim = simulations[activeSimulationName];\n const result = (sim?.toolResult as CallToolResult | undefined) ?? undefined;\n setToolResult(result);\n setToolResultJson(result ? JSON.stringify(result, null, 2) : '');\n setToolResultError('');\n }\n }, [\n activeSimulationName,\n effectiveSimulationName,\n simulations,\n setToolResult,\n setToolResultJson,\n setToolResultError,\n ]);\n\n // Reset hasRun and timing when tool or simulation changes.\n React.useEffect(() => {\n setHasRun(false);\n }, [effectiveSimulationName]);\n\n // Cleanup timers and OAuth listeners on unmount\n React.useEffect(\n () => () => {\n clearTimeout(checkTimerRef.current);\n oauthCleanupRef.current?.();\n },\n []\n );\n\n // Run button handler: call the real tool handler with current toolInput.\n // Uses currentSim (derived directly from simulations + effectiveSimulationName)\n // rather than state.selectedSim, which lags one render behind due to the\n // useEffect sync from effectiveSimulationName → state.setSelectedSimulationName.\n const handleRun = React.useCallback(async () => {\n const caller = onCallToolDirect ?? onCallTool;\n const sim = simulations[effectiveSimulationName];\n if (!caller || !sim) return;\n const toolName = sim.tool.name;\n setIsRunning(true);\n const startTime = performance.now();\n try {\n const result = await caller({ name: toolName, arguments: state.toolInput });\n const clientMs = Math.round((performance.now() - startTime) * 10) / 10;\n // Prefer server-reported timing (_meta._sunpeak.requestTimeMs) when available,\n // since it measures actual handler execution. Fall back to client round-trip\n // for non-sunpeak servers that don't include server-side timing.\n const resultMeta = (result as Record<string, unknown>)?._meta as\n | Record<string, unknown>\n | undefined;\n const serverMs = (resultMeta?._sunpeak as Record<string, unknown> | undefined)?.requestTimeMs;\n const durationMs = typeof serverMs === 'number' ? serverMs : clientMs;\n const resultWithTiming = {\n ...result,\n _meta: { ...resultMeta, _sunpeak: { requestTimeMs: durationMs } },\n };\n state.setToolResult(resultWithTiming);\n // Strip _sunpeak timing from the display JSON so the textarea shows the\n // clean result the app would receive. The server may include _meta._sunpeak.\n const displayResult = resultMeta?._sunpeak\n ? (() => {\n const { _sunpeak: _, ...cleanMeta } = resultMeta;\n const clean = { ...result } as Record<string, unknown>;\n clean._meta = Object.keys(cleanMeta).length > 0 ? cleanMeta : undefined;\n if (clean._meta === undefined) delete clean._meta;\n return clean;\n })()\n : result;\n state.setToolResultJson(JSON.stringify(displayResult, null, 2));\n state.setToolResultError('');\n setHasRun(true);\n setShowCheck(true);\n clearTimeout(checkTimerRef.current);\n checkTimerRef.current = setTimeout(() => setShowCheck(false), 2000);\n } catch (err) {\n const durationMs = Math.round((performance.now() - startTime) * 10) / 10;\n const message = err instanceof Error ? err.message : String(err);\n state.setToolResult({\n content: [{ type: 'text', text: `Error: ${message}` }],\n isError: true,\n _meta: { _sunpeak: { requestTimeMs: durationMs } },\n });\n state.setToolResultJson(\n JSON.stringify(\n { content: [{ type: 'text', text: `Error: ${message}` }], isError: true },\n null,\n 2\n )\n );\n setHasRun(true);\n } finally {\n setIsRunning(false);\n }\n }, [onCallTool, onCallToolDirect, simulations, effectiveSimulationName, state]);\n\n // Resolve the active host shell\n const activeShell = getHostShell(state.activeHost);\n const registeredHosts = getRegisteredHosts();\n const ShellConversation = activeShell?.Conversation;\n\n // Merge host style variables, userAgent, and availableDisplayModes into hostContext.\n const hostContext = React.useMemo(() => {\n const styleVars = activeShell?.styleVariables;\n const userAgent = activeShell?.userAgent;\n const ctx = { ...state.hostContext };\n if (styleVars) {\n (ctx as McpUiHostContext).styles = { variables: styleVars };\n }\n if (userAgent) {\n (ctx as McpUiHostContext).userAgent = userAgent;\n }\n if (activeShell?.availableDisplayModes) {\n (ctx as McpUiHostContext).availableDisplayModes = activeShell.availableDisplayModes;\n }\n return ctx as McpUiHostContext;\n }, [state.hostContext, activeShell]);\n\n // Reset display mode to inline if the active host doesn't support it.\n const { displayMode, setDisplayMode } = state;\n React.useEffect(() => {\n const modes = activeShell?.availableDisplayModes;\n if (modes && !modes.includes(displayMode)) {\n setDisplayMode('inline');\n }\n }, [activeShell, displayMode, setDisplayMode]);\n\n // Apply host style variables to the document root.\n // Uses useLayoutEffect so variables are set BEFORE paint, preventing a flash\n // of stale colors when switching hosts and then toggling theme.\n React.useLayoutEffect(() => {\n const vars = activeShell?.styleVariables;\n if (!vars) return;\n const root = document.documentElement;\n for (const [key, value] of Object.entries(vars)) {\n if (value) root.style.setProperty(key, value);\n }\n }, [activeShell]);\n\n // Apply host page styles. Cleans up old properties when switching hosts.\n // Uses useLayoutEffect to stay in sync with style variables above.\n const prevPageStyleKeysRef = React.useRef<string[]>([]);\n React.useLayoutEffect(() => {\n const root = document.documentElement;\n for (const key of prevPageStyleKeysRef.current) {\n root.style.removeProperty(key);\n }\n const pageStyles = activeShell?.pageStyles;\n if (pageStyles) {\n const keys: string[] = [];\n for (const [key, value] of Object.entries(pageStyles)) {\n root.style.setProperty(key, value);\n keys.push(key);\n }\n prevPageStyleKeysRef.current = keys;\n } else {\n prevPageStyleKeysRef.current = [];\n }\n }, [activeShell]);\n\n // Inject host font CSS (@font-face rules) so the conversation chrome\n // uses the same font as the real host (e.g., Anthropic Sans for Claude).\n React.useLayoutEffect(() => {\n const fontCss = activeShell?.fontCss;\n const id = 'sunpeak-host-fonts';\n const existing = document.getElementById(id);\n if (!fontCss) {\n existing?.remove();\n return;\n }\n if (existing) {\n existing.textContent = fontCss;\n } else {\n const style = document.createElement('style');\n style.id = id;\n style.textContent = fontCss;\n document.head.appendChild(style);\n }\n }, [activeShell]);\n\n // Handle callServerTool from the iframe.\n // When a simulation is active: prefer serverTools mocks, fall back to MCP.\n // When \"None\": always use MCP (real handlers).\n // Uses simulations[activeSimulationName] directly rather than state.selectedSim,\n // which lags one render behind due to the useEffect sync.\n const handleCallTool = React.useCallback(\n (params: {\n name: string;\n arguments?: Record<string, unknown>;\n }): CallToolResult | Promise<CallToolResult> => {\n if (activeSimulationName) {\n const activeSim = simulations[activeSimulationName];\n const mock = activeSim?.serverTools?.[params.name];\n if (mock) {\n const result = resolveServerToolResult(mock, params.arguments);\n if (result) return result;\n }\n }\n if (onCallTool) {\n return onCallTool(params);\n }\n return {\n content: [\n {\n type: 'text',\n text: `[Inspector] Tool \"${params.name}\" called — no serverTools mock found in simulation \"${effectiveSimulationName}\".`,\n },\n ],\n };\n },\n [onCallTool, activeSimulationName, simulations, effectiveSimulationName]\n );\n\n // Derive user message for the conversation shell\n const userMessage = currentSim\n ? (currentSim.userMessage ??\n `Call my ${(currentSim.tool.title as string | undefined) || currentSim.tool.name} tool`)\n : undefined;\n\n // ── Prod resources ──\n const prodResourcesPath = React.useMemo(() => {\n if (!prodResources || !state.selectedSim?.resource) return undefined;\n const name = state.selectedSim.resource.name as string;\n return `/dist/${name}/${name}.html`;\n }, [prodResources, state.selectedSim?.resource]);\n\n const [prodResourcesReady, setProdResourcesReady] = React.useState(false);\n const [prodResourcesGeneration, setProdResourcesGeneration] = React.useState(0);\n const prodResourcesWasReady = React.useRef(false);\n React.useEffect(() => {\n if (!prodResourcesPath) {\n setProdResourcesReady(false);\n prodResourcesWasReady.current = false;\n return;\n }\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout>;\n\n const check = async () => {\n let ok = false;\n try {\n const res = await fetch(prodResourcesPath, { method: 'HEAD' });\n ok = res.ok;\n } catch {\n // network error → not ready\n }\n if (cancelled) return;\n if (ok) {\n if (!prodResourcesWasReady.current) {\n setProdResourcesGeneration((g) => g + 1);\n }\n prodResourcesWasReady.current = true;\n setProdResourcesReady(true);\n } else {\n prodResourcesWasReady.current = false;\n setProdResourcesReady(false);\n }\n timer = setTimeout(check, 1000);\n };\n\n check();\n return () => {\n cancelled = true;\n clearTimeout(timer);\n };\n }, [prodResourcesPath]);\n\n const baseResourceUrl =\n (prodResourcesPath && prodResourcesReady ? prodResourcesPath : undefined) ?? state.resourceUrl;\n // Append devOverlay=false to the resource URL so the server can strip the overlay script\n const effectiveResourceUrl =\n baseResourceUrl && !showDevOverlay\n ? `${baseResourceUrl}${baseResourceUrl.includes('?') ? '&' : '?'}devOverlay=false`\n : baseResourceUrl;\n const prodResourcesLoading = !!prodResourcesPath && !prodResourcesReady;\n\n // ── Content rendering ──\n const hasTools = toolNames.length > 0;\n const hasMockData = activeSimulationName !== null && currentSim?.toolResult != null;\n const showEmptyState = !hasMockData && !hasRun;\n let content: React.ReactNode;\n const iframeBg = 'var(--sim-bg-conversation, var(--color-background-primary, transparent))';\n\n if (!hasTools) {\n const isConnected = connection.status === 'connected';\n const isError = connection.status === 'error';\n content = (\n <div\n className=\"h-full w-full flex items-center justify-center\"\n style={{ background: iframeBg }}\n >\n <span\n className=\"text-sm text-center max-w-xs\"\n style={{ color: 'var(--color-text-secondary)' }}\n >\n {isError\n ? 'Could not connect to MCP server'\n : isConnected\n ? 'No tools with UI resources found on this server'\n : serverUrl\n ? 'Connecting\\u2026'\n : 'Enter an MCP server URL to get started'}\n </span>\n </div>\n );\n } else if (showEmptyState) {\n content = (\n <div\n className=\"h-full w-full flex items-center justify-center\"\n style={{ background: iframeBg }}\n >\n <span className=\"text-sm\" style={{ color: 'var(--color-text-secondary)' }}>\n Press <strong>Run</strong> to call the tool\n </span>\n </div>\n );\n } else if (prodResourcesLoading) {\n content = (\n <div\n className=\"h-full w-full flex items-center justify-center\"\n style={{ background: iframeBg }}\n >\n <span className=\"text-sm\" style={{ color: 'var(--color-text-secondary)' }}>\n Building…\n </span>\n </div>\n );\n } else if (effectiveResourceUrl) {\n content = (\n <div className=\"h-full w-full\" style={{ background: iframeBg }}>\n <IframeResource\n key={`${state.activeHost}-${state.selectedSimulationName}-${effectiveResourceUrl}-${prodResources}-${prodResourcesGeneration}`}\n src={effectiveResourceUrl}\n hostContext={hostContext}\n toolInput={state.toolInput}\n toolResult={state.effectiveToolResult}\n hostOptions={{\n hostInfo: activeShell?.hostInfo,\n hostCapabilities: activeShell?.hostCapabilities,\n onDisplayModeChange: state.handleDisplayModeChange,\n onUpdateModelContext: state.handleUpdateModelContext,\n onCallTool: handleCallTool,\n }}\n permissions={state.permissions}\n prefersBorder={state.prefersBorder}\n onDisplayModeReady={state.handleDisplayModeReady}\n debugInjectState={state.modelContext}\n injectOpenAIRuntime={state.activeHost === 'chatgpt'}\n sandboxUrl={sandboxUrl}\n className=\"h-full w-full\"\n />\n </div>\n );\n } else if (!prodResources && state.resourceScript) {\n content = (\n <div className=\"h-full w-full\" style={{ background: iframeBg }}>\n <IframeResource\n key={`${state.activeHost}-${state.selectedSimulationName}-${state.resourceScript}`}\n scriptSrc={state.resourceScript}\n hostContext={hostContext}\n toolInput={state.toolInput}\n toolResult={state.effectiveToolResult}\n csp={state.csp}\n hostOptions={{\n hostInfo: activeShell?.hostInfo,\n hostCapabilities: activeShell?.hostCapabilities,\n onDisplayModeChange: state.handleDisplayModeChange,\n onUpdateModelContext: state.handleUpdateModelContext,\n onCallTool: handleCallTool,\n }}\n permissions={state.permissions}\n prefersBorder={state.prefersBorder}\n onDisplayModeReady={state.handleDisplayModeReady}\n debugInjectState={state.modelContext}\n injectOpenAIRuntime={state.activeHost === 'chatgpt'}\n sandboxUrl={sandboxUrl}\n className=\"h-full w-full\"\n />\n </div>\n );\n } else {\n content = children;\n }\n\n // Use the active host's theme applier\n const applyTheme = activeShell?.applyTheme;\n\n // ── Run button (shown in conversation header when no simulation is active) ──\n // Visible when \"None (call server)\" is selected OR when no fixtures exist for the tool.\n // Hidden in demo mode to prevent sending real MCP requests from embedded contexts.\n const runButton =\n !demoMode && onCallTool && currentSim && activeSimulationName === null ? (\n <button\n type=\"button\"\n onClick={handleRun}\n disabled={isRunning}\n className=\"rounded-full px-3 py-1 text-sm font-medium transition-opacity disabled:opacity-40 flex items-center gap-1.5 cursor-pointer\"\n style={{\n backgroundColor: 'var(--color-text-primary)',\n color: 'var(--color-background-primary)',\n }}\n >\n {showCheck ? (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M2 6L5 9L10 3\" />\n </svg>\n ) : (\n <svg width=\"10\" height=\"12\" viewBox=\"0 0 10 12\" fill=\"currentColor\">\n <path d=\"M0 0L10 6L0 12V0Z\" />\n </svg>\n )}\n Run\n </button>\n ) : undefined;\n\n const conversationContent = ShellConversation ? (\n <ShellConversation\n screenWidth={state.screenWidth}\n displayMode={state.displayMode}\n platform={state.platform}\n onRequestDisplayMode={state.handleDisplayModeChange}\n appName={appName}\n appIcon={appIcon}\n userMessage={userMessage}\n onContentWidthChange={state.handleContentWidthChange}\n headerAction={runButton}\n >\n {content}\n </ShellConversation>\n ) : (\n content\n );\n\n if (!showSidebar) {\n return (\n <ThemeProvider theme={state.theme} applyTheme={applyTheme}>\n <div className=\"flex h-screen w-screen\">{conversationContent}</div>\n </ThemeProvider>\n );\n }\n\n return (\n <ThemeProvider theme={state.theme} applyTheme={applyTheme}>\n <SimpleSidebar\n controls={\n <div className=\"space-y-1\">\n {/* ── MCP Server URL (always visible; read-only in demo mode) ── */}\n <SidebarControl\n label={\n <span className=\"flex items-center gap-1.5\">\n MCP Server\n {serverUrl && !demoMode && (\n <span\n className=\"inline-block w-2 h-2 rounded-full\"\n data-testid=\"connection-status\"\n style={{\n backgroundColor:\n connection.status === 'connected'\n ? '#22c55e'\n : connection.status === 'connecting'\n ? '#eab308'\n : connection.status === 'error'\n ? '#ef4444'\n : '#6b7280',\n }}\n title={connection.error ?? connection.status}\n />\n )}\n </span>\n }\n tooltip=\"MCP server URL\"\n data-testid=\"server-url\"\n >\n <SidebarInput\n value={demoMode ? 'http://localhost:8000/mcp' : serverUrl}\n onChange={demoMode ? () => {} : setServerUrl}\n applyOnBlur\n placeholder=\"http://localhost:8000/mcp\"\n disabled={demoMode}\n />\n </SidebarControl>\n\n {/* ── Authentication (hidden in demo mode) ── */}\n {!demoMode && (\n <SidebarCollapsibleControl\n key={`auth-${authType === 'none' ? 'none' : 'active'}`}\n label=\"Authentication\"\n defaultCollapsed={authType === 'none'}\n >\n <div className=\"space-y-1\">\n <SidebarSelect\n value={authType}\n onChange={(value) => {\n const newType = value as AuthType;\n setAuthType(newType);\n setOauthStatus('none');\n setOauthError(undefined);\n // Reconnect without auth when switching to \"none\"\n if (newType === 'none' && serverUrl) {\n connection.reconnect(serverUrl);\n }\n }}\n options={[\n { value: 'none', label: 'None' },\n { value: 'bearer', label: 'Bearer Token' },\n { value: 'oauth', label: 'OAuth' },\n ]}\n />\n\n {authType === 'bearer' && (\n <SidebarInput\n type=\"password\"\n value={bearerToken}\n onChange={(value) => {\n setBearerToken(value);\n // Reconnect with the new token when applied\n if (serverUrl && value) {\n connection.reconnect(serverUrl, { type: 'bearer', bearerToken: value });\n }\n }}\n applyOnBlur\n placeholder=\"Paste your token\"\n />\n )}\n\n {authType === 'oauth' && (\n <div className=\"space-y-1\">\n <SidebarInput\n value={oauthClientId}\n onChange={setOauthClientId}\n applyOnBlur\n placeholder=\"Client ID (optional)\"\n />\n {oauthClientId && (\n <SidebarInput\n type=\"password\"\n value={oauthClientSecret}\n onChange={setOauthClientSecret}\n applyOnBlur\n placeholder=\"Client Secret (optional)\"\n />\n )}\n <SidebarInput\n value={oauthScopes}\n onChange={setOauthScopes}\n applyOnBlur\n placeholder=\"Scopes (optional)\"\n />\n <button\n type=\"button\"\n onClick={handleStartOAuth}\n disabled={!serverUrl || oauthStatus === 'authorizing'}\n className=\"w-full h-7 text-xs rounded-md px-2 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed\"\n style={{\n backgroundColor:\n oauthStatus === 'authorized' ? '#22c55e' : 'var(--color-text-primary)',\n color: 'var(--color-background-primary)',\n }}\n >\n {oauthStatus === 'authorizing'\n ? 'Authorizing\\u2026'\n : oauthStatus === 'authorized'\n ? 'Authorized'\n : 'Authorize'}\n </button>\n {oauthError && (\n <div\n className=\"text-[9px]\"\n style={{ color: 'var(--color-text-danger, #dc2626)' }}\n >\n {oauthError}\n </div>\n )}\n </div>\n )}\n </div>\n </SidebarCollapsibleControl>\n )}\n\n {/* ── Prod Resources (framework mode only, hidden in demo mode) ── */}\n {!hideInspectorModes && !demoMode && (\n <SidebarCheckbox\n checked={prodResources}\n onChange={setProdResources}\n label=\"Prod Resources\"\n tooltip=\"Load resources from dist/ builds instead of HMR\"\n docsPath=\"api-reference/cli/dev#prod-tools-and-prod-resources-flags\"\n />\n )}\n\n {/* ── Tool + Simulation row ── */}\n {hasTools && (\n <div className=\"grid grid-cols-2 gap-2\" data-testid=\"tool-simulation-row\">\n <SidebarControl\n label=\"Tool\"\n tooltip=\"Tool to inspect\"\n docsPath=\"api-reference/cli/dev\"\n data-testid=\"tool-selector\"\n >\n <SidebarSelect\n value={selectedToolName}\n onChange={(value) => setSelectedToolName(value)}\n options={toolNames.map((name) => {\n const info = toolMap.get(name)!;\n return {\n value: name,\n label: (info.tool.title as string | undefined) || name,\n };\n })}\n />\n </SidebarControl>\n <SidebarControl\n label={\n selectedToolInfo && selectedToolInfo.fixtureSimNames.length > 0 ? (\n 'Simulation'\n ) : (\n <a\n href={`${DOCS_BASE_URL}/api-reference/simulations/simulation`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"no-underline transition-colors\"\n style={{ color: 'var(--color-text-secondary)' }}\n onMouseEnter={(e) => {\n (e.target as HTMLElement).style.color = 'var(--color-text-primary)';\n }}\n onMouseLeave={(e) => {\n (e.target as HTMLElement).style.color = 'var(--color-text-secondary)';\n }}\n >\n Simulation\n </a>\n )\n }\n tooltip={\n selectedToolInfo && selectedToolInfo.fixtureSimNames.length > 0\n ? 'Test fixture with mock data'\n : 'Create simulations for faster testing'\n }\n docsPath=\"api-reference/simulations/simulation\"\n data-testid=\"simulation-selector\"\n >\n <SidebarSelect\n value={activeSimulationName ?? '__none__'}\n onChange={(value) =>\n setActiveSimulationName(value === '__none__' ? null : value)\n }\n options={[\n ...(demoMode\n ? []\n : [\n {\n value: '__none__',\n label:\n selectedToolInfo && selectedToolInfo.fixtureSimNames.length > 0\n ? 'None (call server)'\n : 'None',\n },\n ]),\n ...(selectedToolInfo?.fixtureSimNames ?? []).map((simName) => ({\n value: simName,\n label: simName,\n })),\n ]}\n />\n </SidebarControl>\n </div>\n )}\n\n {/* ── Host + Width row ── */}\n <div className=\"grid grid-cols-2 gap-2\">\n {registeredHosts.length > 1 && (\n <SidebarControl\n label=\"Host\"\n tooltip=\"Host runtime to simulate\"\n docsPath=\"api-reference/functions/host-detection\"\n >\n <SidebarSelect\n value={state.activeHost}\n onChange={(value) => state.setActiveHost(value as HostId)}\n options={registeredHosts.map((h) => ({\n value: h.id,\n label: h.label,\n }))}\n />\n </SidebarControl>\n )}\n <SidebarControl\n label=\"Width\"\n tooltip=\"Chat width\"\n docsPath=\"api-reference/simulations/inspector\"\n >\n <SidebarSelect\n value={state.screenWidth}\n onChange={(value) => state.setScreenWidth(value as ScreenWidth)}\n options={[\n { value: 'mobile-s', label: 'Mobile S (375px)' },\n { value: 'mobile-l', label: 'Mobile L (425px)' },\n { value: 'tablet', label: 'Tablet (768px)' },\n { value: 'full', label: '100% (Full)' },\n ]}\n />\n </SidebarControl>\n </div>\n\n <SidebarCollapsibleControl\n label=\"Host Context\"\n defaultCollapsed={false}\n tooltip=\"Host-provided environment\"\n docsPath=\"api-reference/hooks/use-host-context\"\n >\n <div className=\"space-y-1\">\n <div className=\"grid grid-cols-[2fr_1fr] gap-2\">\n <SidebarControl\n label=\"Theme\"\n tooltip=\"Host color theme\"\n docsPath=\"api-reference/hooks/use-theme\"\n >\n <SidebarToggle\n value={state.theme}\n onChange={(value) => state.setTheme(value as McpUiTheme)}\n options={[\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' },\n ]}\n />\n </SidebarControl>\n\n <SidebarControl\n label=\"Locale\"\n tooltip=\"BCP 47 language tag\"\n docsPath=\"api-reference/hooks/use-locale\"\n >\n <SidebarInput\n applyOnBlur\n value={state.locale}\n onChange={(value) => state.setLocale(value)}\n placeholder=\"en-US\"\n />\n </SidebarControl>\n </div>\n\n <SidebarControl\n label=\"Display Mode\"\n tooltip=\"Host resource rendering paradigm\"\n docsPath=\"api-reference/hooks/use-display-mode\"\n >\n <SidebarToggle\n value={state.displayMode}\n onChange={(value) => state.setDisplayMode(value as McpUiDisplayMode)}\n options={[\n { value: 'inline', label: 'Inline' },\n { value: 'pip', label: 'PiP' },\n { value: 'fullscreen', label: 'Full' },\n ].filter(\n (opt) =>\n !activeShell?.availableDisplayModes ||\n activeShell.availableDisplayModes.includes(opt.value as McpUiDisplayMode)\n )}\n />\n </SidebarControl>\n\n <div className=\"grid grid-cols-7 gap-2\">\n <div className=\"col-span-3\">\n <SidebarControl\n label=\"Platform\"\n tooltip=\"End user device platform\"\n docsPath=\"api-reference/hooks/use-platform\"\n >\n <SidebarSelect\n value={state.platform}\n onChange={(value) => {\n const p = value as Platform;\n state.setPlatform(p);\n if (p === 'mobile') {\n state.setHover(false);\n state.setTouch(true);\n } else if (p === 'desktop') {\n state.setHover(true);\n state.setTouch(false);\n } else {\n state.setHover(true);\n state.setTouch(false);\n }\n }}\n options={[\n { value: 'mobile', label: 'Mobile' },\n { value: 'desktop', label: 'Desktop' },\n { value: 'web', label: 'Web' },\n ]}\n />\n </SidebarControl>\n </div>\n\n <div className=\"col-span-4\">\n <SidebarControl\n label=\"Capabilities\"\n tooltip=\"End user device capabilities\"\n docsPath=\"api-reference/hooks/use-device-capabilities\"\n >\n <div className=\"flex gap-2\">\n <SidebarCheckbox\n checked={state.hover}\n onChange={state.setHover}\n label=\"Hover\"\n />\n <SidebarCheckbox\n checked={state.touch}\n onChange={state.setTouch}\n label=\"Touch\"\n />\n </div>\n </SidebarControl>\n </div>\n </div>\n\n <SidebarControl\n label=\"Time Zone\"\n tooltip=\"End user IANA time zone\"\n docsPath=\"api-reference/hooks/use-time-zone\"\n >\n <SidebarInput\n applyOnBlur\n value={state.timeZone}\n onChange={(value) => state.setTimeZone(value)}\n placeholder=\"e.g. America/New_York\"\n />\n </SidebarControl>\n\n <SidebarControl\n label=\"Container Dimensions\"\n tooltip=\"Host-enforced size constraints (px)\"\n docsPath=\"api-reference/hooks/use-viewport\"\n >\n <div className=\"grid grid-cols-4 gap-1\">\n <SidebarControl label=\"Height\">\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={state.containerHeight != null ? String(state.containerHeight) : ''}\n onChange={(value) =>\n state.setContainerHeight(value ? Number(value) : undefined)\n }\n />\n </SidebarControl>\n <SidebarControl label=\"Width\">\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={state.containerWidth != null ? String(state.containerWidth) : ''}\n onChange={(value) =>\n state.setContainerWidth(value ? Number(value) : undefined)\n }\n />\n </SidebarControl>\n <SidebarControl label=\"Max H\">\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={\n state.containerMaxHeight != null ? String(state.containerMaxHeight) : ''\n }\n onChange={(value) =>\n state.setContainerMaxHeight(value ? Number(value) : undefined)\n }\n />\n </SidebarControl>\n <SidebarControl label=\"Max W\">\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder={\n state.measuredContentWidth != null\n ? String(state.measuredContentWidth)\n : '-'\n }\n value={\n state.containerMaxWidth != null ? String(state.containerMaxWidth) : ''\n }\n onChange={(value) =>\n state.setContainerMaxWidth(value ? Number(value) : undefined)\n }\n />\n </SidebarControl>\n </div>\n </SidebarControl>\n\n <SidebarControl\n label=\"Safe Area Insets\"\n tooltip=\"Device safe area padding (px)\"\n docsPath=\"api-reference/hooks/use-safe-area\"\n >\n <div className=\"grid grid-cols-4 gap-1\">\n <div className=\"flex items-center gap-0.5\">\n <span\n className=\"text-[10px]\"\n style={{ color: 'var(--color-text-secondary)' }}\n >\n ↑\n </span>\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={state.safeAreaInsets.top ? String(state.safeAreaInsets.top) : ''}\n onChange={(value) =>\n state.setSafeAreaInsets((prev) => ({ ...prev, top: Number(value) || 0 }))\n }\n />\n </div>\n <div className=\"flex items-center gap-0.5\">\n <span\n className=\"text-[10px]\"\n style={{ color: 'var(--color-text-secondary)' }}\n >\n ↓\n </span>\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={\n state.safeAreaInsets.bottom ? String(state.safeAreaInsets.bottom) : ''\n }\n onChange={(value) =>\n state.setSafeAreaInsets((prev) => ({\n ...prev,\n bottom: Number(value) || 0,\n }))\n }\n />\n </div>\n <div className=\"flex items-center gap-0.5\">\n <span\n className=\"text-[10px]\"\n style={{ color: 'var(--color-text-secondary)' }}\n >\n ←\n </span>\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={state.safeAreaInsets.left ? String(state.safeAreaInsets.left) : ''}\n onChange={(value) =>\n state.setSafeAreaInsets((prev) => ({ ...prev, left: Number(value) || 0 }))\n }\n />\n </div>\n <div className=\"flex items-center gap-0.5\">\n <span\n className=\"text-[10px]\"\n style={{ color: 'var(--color-text-secondary)' }}\n >\n →\n </span>\n <SidebarInput\n type=\"number\"\n applyOnBlur\n placeholder=\"-\"\n value={state.safeAreaInsets.right ? String(state.safeAreaInsets.right) : ''}\n onChange={(value) =>\n state.setSafeAreaInsets((prev) => ({\n ...prev,\n right: Number(value) || 0,\n }))\n }\n />\n </div>\n </div>\n </SidebarControl>\n </div>\n </SidebarCollapsibleControl>\n\n <SidebarCollapsibleControl\n label=\"App Context\"\n defaultCollapsed\n tooltip=\"App-provided context shared with the model\"\n docsPath=\"api-reference/hooks/use-app-state\"\n >\n <SidebarTextarea\n value={state.modelContextJson}\n onChange={(json) =>\n state.validateJSON(json, state.setModelContextJson, state.setModelContextError)\n }\n onFocus={() => state.setEditingField('modelContext')}\n onBlur={() =>\n state.commitJSON(state.modelContextJson, state.setModelContextError, (parsed) => {\n state.setModelContext(parsed as Record<string, unknown> | null);\n })\n }\n error={state.modelContextError}\n maxRows={8}\n />\n </SidebarCollapsibleControl>\n\n <SidebarCollapsibleControl\n label=\"Tool Input (JSON)\"\n defaultCollapsed={false}\n tooltip=\"Arguments passed to the tool\"\n docsPath=\"api-reference/hooks/use-tool-data\"\n >\n <SidebarTextarea\n value={state.toolInputJson}\n onChange={(json) =>\n state.validateJSON(json, state.setToolInputJson, state.setToolInputError)\n }\n onFocus={() => state.setEditingField('toolInput')}\n onBlur={() =>\n state.commitJSON(state.toolInputJson, state.setToolInputError, (parsed) =>\n state.setToolInput((parsed as Record<string, unknown>) ?? {})\n )\n }\n error={state.toolInputError}\n maxRows={8}\n />\n </SidebarCollapsibleControl>\n\n <SidebarCollapsibleControl\n label=\"Tool Result (JSON)\"\n defaultCollapsed={false}\n tooltip=\"Structured content returned by the tool\"\n docsPath=\"api-reference/hooks/use-tool-data\"\n data-testid=\"tool-result-section\"\n >\n <SidebarTextarea\n value={state.toolResultJson}\n data-testid=\"tool-result-textarea\"\n onChange={(json) =>\n state.validateJSON(json, state.setToolResultJson, state.setToolResultError)\n }\n onFocus={() => state.setEditingField('toolResult')}\n onBlur={() =>\n state.commitJSON(state.toolResultJson, state.setToolResultError, (parsed) => {\n if (parsed === null) {\n state.setToolResult(undefined);\n } else {\n const result = parsed as Record<string, unknown>;\n if ('content' in result || 'structuredContent' in result) {\n state.setToolResult(\n result as import('@modelcontextprotocol/sdk/types.js').CallToolResult\n );\n } else {\n state.setToolResult({ content: [], structuredContent: result });\n }\n }\n })\n }\n error={state.toolResultError}\n maxRows={8}\n />\n </SidebarCollapsibleControl>\n </div>\n }\n >\n {conversationContent}\n </SimpleSidebar>\n </ThemeProvider>\n );\n}\n"],"x_google_ignoreList":[7],"mappings":";;;;;;AAYA,IAAa,0BAAuC;CAElD,8BAA8B;CAC9B,gCAAgC;CAChC,+BAA+B;CAC/B,8BAA8B;CAC9B,4BAA4B;CAC5B,2BAA2B;CAC3B,6BAA6B;CAC7B,8BAA8B;CAC9B,8BAA8B;CAC9B,+BAA+B;CAG/B,wBAAwB;CACxB,0BAA0B;CAC1B,yBAAyB;CACzB,wBAAwB;CACxB,sBAAsB;CACtB,qBAAqB;CACrB,uBAAuB;CACvB,wBAAwB;CACxB,wBAAwB;CACxB,yBAAyB;CAGzB,0BAA0B;CAC1B,4BAA4B;CAC5B,2BAA2B;CAC3B,0BAA0B;CAC1B,wBAAwB;CACxB,uBAAuB;CACvB,yBAAyB;CACzB,0BAA0B;CAC1B,0BAA0B;CAC1B,2BAA2B;CAG3B,wBAAwB;CACxB,0BAA0B;CAC1B,wBAAwB;CACxB,qBAAqB;CACrB,uBAAuB;CACvB,wBAAwB;CACxB,wBAAwB;CAGxB,eAAe;CACf,eAAe;CAGf,wBAAwB;CACxB,wBAAwB;CACxB,0BAA0B;CAC1B,sBAAsB;CAGtB,uBAAuB;CACvB,uBAAuB;CACvB,uBAAuB;CACvB,uBAAuB;CAGvB,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;CAC1B,2BAA2B;CAC3B,2BAA2B;CAG3B,8BAA8B;CAC9B,8BAA8B;CAC9B,8BAA8B;CAC9B,8BAA8B;CAG9B,iCAAiC;CACjC,iCAAiC;CACjC,iCAAiC;CACjC,iCAAiC;CACjC,iCAAiC;CACjC,kCAAkC;CAClC,kCAAkC;CAGlC,sBAAsB;CACtB,sBAAsB;CACtB,sBAAsB;CACtB,sBAAsB;CACtB,sB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