sunpeak 0.14.3 → 0.15.4
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 +34 -30
- package/bin/commands/build.mjs +2 -1
- package/bin/commands/dev.mjs +72 -2
- package/dist/chatgpt/{conversation.d.ts → chatgpt-conversation.d.ts} +1 -1
- package/dist/chatgpt/chatgpt-host.d.ts +1 -0
- package/dist/chatgpt/globals.css +618 -6156
- package/dist/chatgpt/index.cjs +11 -8
- package/dist/chatgpt/index.cjs.map +1 -1
- package/dist/chatgpt/index.d.ts +10 -32
- package/dist/chatgpt/index.js +15 -12
- package/dist/chatgpt/index.js.map +1 -1
- package/dist/claude/claude-conversation.d.ts +23 -0
- package/dist/claude/claude-host.d.ts +1 -0
- package/dist/claude/index.cjs +5 -0
- package/dist/claude/index.cjs.map +1 -0
- package/dist/claude/index.d.ts +1 -0
- package/dist/claude/index.js +5 -0
- package/dist/claude/index.js.map +1 -0
- package/dist/{discovery-COZUnY6a.js → discovery-DzV3HLXs.js} +5 -5
- package/dist/{discovery-COZUnY6a.js.map → discovery-DzV3HLXs.js.map} +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/use-app-tools.d.ts +44 -0
- package/dist/hooks/use-update-model-context.d.ts +29 -0
- package/dist/index-B0dxRJvS.cjs +42 -0
- package/dist/index-B0dxRJvS.cjs.map +1 -0
- package/dist/index-Ce_5ZIdJ.js +512 -0
- package/dist/index-Ce_5ZIdJ.js.map +1 -0
- package/dist/index-Cngntkp2.cjs +527 -0
- package/dist/index-Cngntkp2.cjs.map +1 -0
- package/dist/index-CutQgPzR.js +43 -0
- package/dist/index-CutQgPzR.js.map +1 -0
- package/dist/index.cjs +1705 -1647
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2732 -2675
- package/dist/index.js.map +1 -1
- package/dist/lib/default-style-variables.d.ts +2 -0
- package/dist/lib/discovery-cli.js +1 -1
- package/dist/mcp/index.cjs +86 -27
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.ts +3 -1
- package/dist/mcp/index.js +85 -26
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +4 -3
- package/dist/mcp/types.d.ts +11 -0
- package/dist/platform/chatgpt/index.cjs +1 -1
- package/dist/platform/chatgpt/index.js +1 -1
- package/dist/platform/index.cjs +3 -0
- package/dist/platform/index.cjs.map +1 -1
- package/dist/platform/index.d.ts +3 -1
- package/dist/platform/index.js +3 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/{protocol-BQCnIrc9.js → protocol-DFbsCx7E.js} +29 -29
- package/dist/{protocol-BQCnIrc9.js.map → protocol-DFbsCx7E.js.map} +1 -1
- package/dist/simulator/host-styles.d.ts +5 -0
- package/dist/simulator/hosts.d.ts +73 -0
- package/dist/{chatgpt → simulator}/iframe-resource.d.ts +27 -3
- package/dist/simulator/index.cjs +39 -0
- package/dist/simulator/index.cjs.map +1 -0
- package/dist/simulator/index.d.ts +18 -0
- package/dist/simulator/index.js +39 -0
- package/dist/simulator/index.js.map +1 -0
- package/dist/{chatgpt → simulator}/mcp-app-host.d.ts +8 -1
- package/dist/simulator/mock-openai-runtime.d.ts +20 -0
- package/dist/{chatgpt → simulator}/simulator-url.d.ts +8 -1
- package/dist/simulator/simulator.d.ts +12 -0
- package/dist/{chatgpt → simulator}/theme-provider.d.ts +3 -1
- package/dist/simulator/use-simulator-state.d.ts +91 -0
- package/dist/simulator-CxrtnguM.js +8764 -0
- package/dist/simulator-CxrtnguM.js.map +1 -0
- package/dist/simulator-DcfQBRXE.cjs +8779 -0
- package/dist/simulator-DcfQBRXE.cjs.map +1 -0
- package/dist/simulator-url-CuLqtnSS.js +48 -0
- package/dist/simulator-url-CuLqtnSS.js.map +1 -0
- package/dist/simulator-url-rgg_KYOg.cjs +47 -0
- package/dist/simulator-url-rgg_KYOg.cjs.map +1 -0
- package/dist/style.css +558 -6143
- package/dist/types/runtime.d.ts +1 -1
- package/dist/{use-app-D7kRAPSG.cjs → use-app-BnoSPiUT.cjs} +2 -1
- package/dist/{use-app-D7kRAPSG.cjs.map → use-app-BnoSPiUT.cjs.map} +1 -1
- package/dist/{use-app-Dvr4LKs2.js → use-app-D_TeaMFG.js} +4 -3
- package/dist/{use-app-Dvr4LKs2.js.map → use-app-D_TeaMFG.js.map} +1 -1
- package/package.json +18 -3
- package/template/.sunpeak/dev.tsx +4 -4
- package/template/.sunpeak/resource-loader.html +1 -1
- package/template/README.md +1 -1
- package/template/node_modules/.bin/nodemon +2 -2
- package/template/node_modules/.bin/playwright +2 -2
- package/template/node_modules/.bin/sunpeak +2 -2
- package/template/node_modules/.bin/tsc +2 -2
- package/template/node_modules/.bin/tsserver +2 -2
- package/template/node_modules/.bin/tsx +2 -2
- package/template/node_modules/.bin/vite +2 -2
- package/template/src/components/avatar.tsx +4 -1
- package/template/src/components/button.tsx +17 -20
- package/template/src/resources/albums/albums-resource.tsx +2 -3
- package/template/src/resources/albums/components/album-card.tsx +4 -2
- package/template/src/resources/albums/components/film-strip.test.tsx +2 -2
- package/template/src/resources/albums/components/film-strip.tsx +2 -2
- package/template/src/resources/albums/components/fullscreen-viewer.tsx +7 -5
- package/template/src/resources/carousel/carousel-resource.tsx +2 -3
- package/template/src/resources/carousel/components/card.test.tsx +3 -2
- package/template/src/resources/carousel/components/card.tsx +8 -4
- package/template/src/resources/map/components/map-view.tsx +1 -1
- package/template/src/resources/map/components/map.tsx +1 -1
- package/template/src/resources/map/components/place-card.tsx +8 -4
- package/template/src/resources/map/components/place-carousel.tsx +1 -1
- package/template/src/resources/map/components/place-inspector.tsx +15 -7
- package/template/src/resources/map/components/place-list.tsx +7 -4
- package/template/src/resources/map/map-resource.tsx +0 -2
- package/template/src/resources/review/review-resource.tsx +61 -27
- package/template/tests/e2e/albums.spec.ts +118 -102
- package/template/tests/e2e/carousel.spec.ts +103 -100
- package/template/tests/e2e/map.spec.ts +220 -181
- package/template/tests/e2e/review.spec.ts +224 -198
- package/dist/_commonjsHelpers-Bc2YnDe1.cjs +0 -8
- package/dist/_commonjsHelpers-Bc2YnDe1.cjs.map +0 -1
- package/dist/_commonjsHelpers-DWwsNxpa.js +0 -9
- package/dist/_commonjsHelpers-DWwsNxpa.js.map +0 -1
- package/dist/index-CJ3jfcjj.js +0 -15131
- package/dist/index-CJ3jfcjj.js.map +0 -1
- package/dist/index-Cdeg96So.cjs +0 -15147
- package/dist/index-Cdeg96So.cjs.map +0 -1
- /package/dist/{chatgpt → simulator}/simple-sidebar.d.ts +0 -0
- /package/dist/{chatgpt/chatgpt-simulator-types.d.ts → simulator/simulator-types.d.ts} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { McpUiDisplayMode, McpUiHostContext, McpUiHostCapabilities, McpUiStyles } from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
import { ScreenWidth } from './simulator-types';
|
|
3
|
+
type Platform = NonNullable<McpUiHostContext['platform']>;
|
|
4
|
+
/**
|
|
5
|
+
* Props passed to a host shell (conversation chrome) component.
|
|
6
|
+
* Each host implements a React component matching this interface.
|
|
7
|
+
*/
|
|
8
|
+
export interface HostConversationProps {
|
|
9
|
+
/** The resource content (iframe or children) to render inside the conversation */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/** Current simulated screen width */
|
|
12
|
+
screenWidth: ScreenWidth;
|
|
13
|
+
/** Current MCP display mode */
|
|
14
|
+
displayMode: McpUiDisplayMode;
|
|
15
|
+
/** Current platform (desktop/mobile/web) */
|
|
16
|
+
platform: Platform;
|
|
17
|
+
/** Callback when the shell requests a display mode change (e.g., close button) */
|
|
18
|
+
onRequestDisplayMode?: (mode: McpUiDisplayMode) => void;
|
|
19
|
+
/** App name for display in conversation chrome */
|
|
20
|
+
appName?: string;
|
|
21
|
+
/** App icon (emoji or URL) for display in conversation chrome */
|
|
22
|
+
appIcon?: string;
|
|
23
|
+
/** User message to show in the conversation (decorative) */
|
|
24
|
+
userMessage?: string;
|
|
25
|
+
/** Whether content is transitioning between display modes */
|
|
26
|
+
isTransitioning?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Unique identifier for a host */
|
|
29
|
+
export type HostId = 'chatgpt' | 'claude' | (string & {});
|
|
30
|
+
/**
|
|
31
|
+
* A registered host shell provides the conversation chrome and
|
|
32
|
+
* functional configuration for a specific MCP App host.
|
|
33
|
+
*/
|
|
34
|
+
export interface HostShell {
|
|
35
|
+
/** Unique host identifier */
|
|
36
|
+
id: HostId;
|
|
37
|
+
/** Human-readable name for the sidebar dropdown */
|
|
38
|
+
label: string;
|
|
39
|
+
/** The conversation shell React component */
|
|
40
|
+
Conversation: React.ComponentType<HostConversationProps>;
|
|
41
|
+
/** Apply the host's theme to the document (CSS variables, data attributes, etc.) */
|
|
42
|
+
applyTheme: (theme: 'light' | 'dark') => void;
|
|
43
|
+
/** Host info reported to the app via MCP protocol */
|
|
44
|
+
hostInfo: {
|
|
45
|
+
name: string;
|
|
46
|
+
version: string;
|
|
47
|
+
};
|
|
48
|
+
/** Host capabilities reported to the app via MCP protocol */
|
|
49
|
+
hostCapabilities: McpUiHostCapabilities;
|
|
50
|
+
/**
|
|
51
|
+
* MCP App style variables sent to the app via hostContext.styles.variables.
|
|
52
|
+
* Uses CSS light-dark() values so a single set adapts to theme automatically.
|
|
53
|
+
* The SDK's applyDocumentTheme() sets color-scheme which light-dark() reads.
|
|
54
|
+
* @see McpUiStyleVariableKey from @modelcontextprotocol/ext-apps
|
|
55
|
+
*/
|
|
56
|
+
styleVariables?: McpUiStyles;
|
|
57
|
+
/**
|
|
58
|
+
* CSS custom properties for the simulator page chrome (sidebar, conversation area).
|
|
59
|
+
* These are applied to the document root and can override the defaults:
|
|
60
|
+
* --sim-bg-sidebar (fallback: var(--color-background-secondary))
|
|
61
|
+
* --sim-bg-conversation (fallback: var(--color-background-primary))
|
|
62
|
+
*
|
|
63
|
+
* Values should use CSS light-dark() for automatic theme adaptation.
|
|
64
|
+
*/
|
|
65
|
+
pageStyles?: Record<string, string>;
|
|
66
|
+
}
|
|
67
|
+
/** Register a host shell. Idempotent — re-registering with the same id replaces. */
|
|
68
|
+
export declare function registerHostShell(shell: HostShell): void;
|
|
69
|
+
/** Get a registered host shell by id. */
|
|
70
|
+
export declare function getHostShell(id: HostId): HostShell | undefined;
|
|
71
|
+
/** Get all registered host shells, in insertion order. */
|
|
72
|
+
export declare function getRegisteredHosts(): HostShell[];
|
|
73
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { McpAppHostOptions } from './mcp-app-host';
|
|
2
|
-
import { McpUiHostContext } from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
import { McpUiHostContext, McpUiResourcePermissions } from '@modelcontextprotocol/ext-apps';
|
|
3
3
|
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
/**
|
|
@@ -13,12 +13,17 @@ declare function escapeHtml(str: string): string;
|
|
|
13
13
|
declare function isAllowedUrl(src: string): boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Content Security Policy configuration for iframe resources.
|
|
16
|
+
* Matches McpUiResourceCsp from the MCP Apps spec.
|
|
16
17
|
*/
|
|
17
18
|
export interface ResourceCSP {
|
|
18
19
|
/** Domains allowed for fetch/XHR/WebSocket connections */
|
|
19
20
|
connectDomains?: string[];
|
|
20
21
|
/** Domains allowed for scripts, images, styles, fonts */
|
|
21
22
|
resourceDomains?: string[];
|
|
23
|
+
/** Domains allowed for nested iframes */
|
|
24
|
+
frameDomains?: string[];
|
|
25
|
+
/** Domains allowed for the base-uri directive */
|
|
26
|
+
baseUriDomains?: string[];
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
29
|
* Extract CSP configuration from a resource's _meta.ui.csp field.
|
|
@@ -39,7 +44,13 @@ declare function generateCSP(csp: ResourceCSP | undefined, scriptSrc: string): s
|
|
|
39
44
|
* Generates HTML wrapper for a script URL.
|
|
40
45
|
* The MCP Apps SDK in the loaded script handles communication via PostMessageTransport.
|
|
41
46
|
*/
|
|
42
|
-
declare function generateScriptHtml(scriptSrc: string, theme: string, cspPolicy: string): string;
|
|
47
|
+
declare function generateScriptHtml(scriptSrc: string, theme: string, cspPolicy: string, platformScript?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Build the iframe `allow` attribute from resource-declared permissions.
|
|
50
|
+
* Maps McpUiResourcePermissions to Permission Policy directives and
|
|
51
|
+
* combines them with simulator baseline permissions.
|
|
52
|
+
*/
|
|
53
|
+
declare function buildIframeAllow(permissions: McpUiResourcePermissions | undefined): string;
|
|
43
54
|
interface IframeResourceProps {
|
|
44
55
|
/**
|
|
45
56
|
* URL to an HTML page to load directly in the iframe.
|
|
@@ -57,12 +68,18 @@ interface IframeResourceProps {
|
|
|
57
68
|
hostContext?: McpUiHostContext;
|
|
58
69
|
/** Tool input arguments to send after connection */
|
|
59
70
|
toolInput?: Record<string, unknown>;
|
|
71
|
+
/** Partial/streaming tool input to send as a tool-input-partial notification */
|
|
72
|
+
toolInputPartial?: Record<string, unknown>;
|
|
60
73
|
/** Tool result to send after connection */
|
|
61
74
|
toolResult?: CallToolResult;
|
|
62
75
|
/** Optional callbacks for the MCP Apps host */
|
|
63
76
|
hostOptions?: McpAppHostOptions;
|
|
64
77
|
/** Optional CSP configuration (only used with scriptSrc) */
|
|
65
78
|
csp?: ResourceCSP;
|
|
79
|
+
/** Resource-declared sandbox permissions (camera, microphone, etc.) */
|
|
80
|
+
permissions?: McpUiResourcePermissions;
|
|
81
|
+
/** Whether the host should render a border around the resource */
|
|
82
|
+
prefersBorder?: boolean;
|
|
66
83
|
/** Optional className for the iframe container */
|
|
67
84
|
className?: string;
|
|
68
85
|
/** Optional style for the iframe */
|
|
@@ -79,6 +96,12 @@ interface IframeResourceProps {
|
|
|
79
96
|
* This bypasses the normal MCP Apps protocol and is for simulator testing.
|
|
80
97
|
*/
|
|
81
98
|
debugInjectState?: Record<string, unknown> | null;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to inject a mock ChatGPT runtime (window.openai) into the iframe.
|
|
101
|
+
* When true, ChatGPT-specific hooks (useUploadFile, useRequestModal, etc.)
|
|
102
|
+
* and isChatGPT() will work inside the iframe.
|
|
103
|
+
*/
|
|
104
|
+
injectOpenAIRuntime?: boolean;
|
|
82
105
|
}
|
|
83
106
|
/**
|
|
84
107
|
* IframeResource renders MCP Apps in an iframe, communicating via the
|
|
@@ -92,13 +115,14 @@ interface IframeResourceProps {
|
|
|
92
115
|
* connects via PostMessageTransport to window.parent. The parent side uses
|
|
93
116
|
* McpAppHost (wrapping AppBridge) to communicate.
|
|
94
117
|
*/
|
|
95
|
-
export declare function IframeResource({ src, scriptSrc, hostContext, toolInput, toolResult, hostOptions, csp, className, style, onDisplayModeReady, debugInjectState, }: IframeResourceProps): import("react/jsx-runtime").JSX.Element;
|
|
118
|
+
export declare function IframeResource({ src, scriptSrc, hostContext, toolInput, toolInputPartial, toolResult, hostOptions, csp, permissions, prefersBorder, className, style, onDisplayModeReady, debugInjectState, injectOpenAIRuntime, }: IframeResourceProps): import("react/jsx-runtime").JSX.Element;
|
|
96
119
|
export declare const _testExports: {
|
|
97
120
|
escapeHtml: typeof escapeHtml;
|
|
98
121
|
isAllowedUrl: typeof isAllowedUrl;
|
|
99
122
|
isValidCspSource: typeof isValidCspSource;
|
|
100
123
|
generateCSP: typeof generateCSP;
|
|
101
124
|
generateScriptHtml: typeof generateScriptHtml;
|
|
125
|
+
buildIframeAllow: typeof buildIframeAllow;
|
|
102
126
|
ALLOWED_SCRIPT_ORIGINS: string[];
|
|
103
127
|
};
|
|
104
128
|
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const simulator = require("../simulator-DcfQBRXE.cjs");
|
|
4
|
+
const simulatorUrl = require("../simulator-url-rgg_KYOg.cjs");
|
|
5
|
+
const discovery = require("../discovery-CRR3SlyI.cjs");
|
|
6
|
+
exports.IframeResource = simulator.IframeResource;
|
|
7
|
+
exports.McpAppHost = simulator.McpAppHost;
|
|
8
|
+
exports.SCREEN_WIDTHS = simulator.SCREEN_WIDTHS;
|
|
9
|
+
exports.SidebarCheckbox = simulator.SidebarCheckbox;
|
|
10
|
+
exports.SidebarCollapsibleControl = simulator.SidebarCollapsibleControl;
|
|
11
|
+
exports.SidebarControl = simulator.SidebarControl;
|
|
12
|
+
exports.SidebarInput = simulator.SidebarInput;
|
|
13
|
+
exports.SidebarSelect = simulator.SidebarSelect;
|
|
14
|
+
exports.SidebarTextarea = simulator.SidebarTextarea;
|
|
15
|
+
exports.SidebarToggle = simulator.SidebarToggle;
|
|
16
|
+
exports.SimpleSidebar = simulator.SimpleSidebar;
|
|
17
|
+
exports.Simulator = simulator.Simulator;
|
|
18
|
+
exports.ThemeProvider = simulator.ThemeProvider;
|
|
19
|
+
exports.extractResourceCSP = simulator.extractResourceCSP;
|
|
20
|
+
exports.getHostShell = simulator.getHostShell;
|
|
21
|
+
exports.getRegisteredHosts = simulator.getRegisteredHosts;
|
|
22
|
+
exports.registerHostShell = simulator.registerHostShell;
|
|
23
|
+
exports.useSimulatorState = simulator.useSimulatorState;
|
|
24
|
+
exports.useThemeContext = simulator.useThemeContext;
|
|
25
|
+
exports.createSimulatorUrl = simulatorUrl.createSimulatorUrl;
|
|
26
|
+
exports.buildDevSimulations = discovery.buildDevSimulations;
|
|
27
|
+
exports.buildResourceMap = discovery.buildResourceMap;
|
|
28
|
+
exports.buildSimulations = discovery.buildSimulations;
|
|
29
|
+
exports.createResourceExports = discovery.createResourceExports;
|
|
30
|
+
exports.extractResourceKey = discovery.extractResourceKey;
|
|
31
|
+
exports.extractSimulationKey = discovery.extractSimulationKey;
|
|
32
|
+
exports.extractSimulationName = discovery.extractSimulationName;
|
|
33
|
+
exports.findResourceDirs = discovery.findResourceDirs;
|
|
34
|
+
exports.findResourceKey = discovery.findResourceKey;
|
|
35
|
+
exports.findSimulationFiles = discovery.findSimulationFiles;
|
|
36
|
+
exports.getComponentName = discovery.getComponentName;
|
|
37
|
+
exports.isSimulationFile = discovery.isSimulationFile;
|
|
38
|
+
exports.toPascalCase = discovery.toPascalCase;
|
|
39
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { Simulator } from './simulator';
|
|
2
|
+
export type { SimulatorProps } from './simulator';
|
|
3
|
+
export { useSimulatorState } from './use-simulator-state';
|
|
4
|
+
export type { UseSimulatorStateOptions, SimulatorState } from './use-simulator-state';
|
|
5
|
+
export { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';
|
|
6
|
+
export type { HostConversationProps, HostShell, HostId } from './hosts';
|
|
7
|
+
export { McpAppHost } from './mcp-app-host';
|
|
8
|
+
export type { McpAppHostOptions } from './mcp-app-host';
|
|
9
|
+
export { IframeResource, extractResourceCSP } from './iframe-resource';
|
|
10
|
+
export type { ResourceCSP } from './iframe-resource';
|
|
11
|
+
export { ThemeProvider, useThemeContext } from './theme-provider';
|
|
12
|
+
export type { ScreenWidth, SimulatorConfig } from './simulator-types';
|
|
13
|
+
export { SCREEN_WIDTHS } from './simulator-types';
|
|
14
|
+
export { createSimulatorUrl } from './simulator-url';
|
|
15
|
+
export type { SimulatorUrlParams } from './simulator-url';
|
|
16
|
+
export { SimpleSidebar, SidebarControl, SidebarCollapsibleControl, SidebarSelect, SidebarInput, SidebarCheckbox, SidebarTextarea, SidebarToggle, } from './simple-sidebar';
|
|
17
|
+
export { buildDevSimulations, buildSimulations, buildResourceMap, createResourceExports, toPascalCase, extractResourceKey, extractSimulationKey, findResourceKey, getComponentName, findResourceDirs, isSimulationFile, extractSimulationName, findSimulationFiles, } from '../lib/discovery';
|
|
18
|
+
export type { BuildSimulationsOptions, BuildDevSimulationsOptions, ResourceMetadata, ResourceDirInfo, FsOps, } from '../lib/discovery';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { I, M, a, b, c, d, e, f, g, h, i, S, T, j, k, l, r, u, m } from "../simulator-CxrtnguM.js";
|
|
2
|
+
import { c as c2 } from "../simulator-url-CuLqtnSS.js";
|
|
3
|
+
import { b as b2, a as a2, c as c3, d as d2, e as e2, f as f2, g as g2, h as h2, i as i2, j as j2, k as k2, l as l2, t } from "../discovery-DzV3HLXs.js";
|
|
4
|
+
export {
|
|
5
|
+
I as IframeResource,
|
|
6
|
+
M as McpAppHost,
|
|
7
|
+
a as SCREEN_WIDTHS,
|
|
8
|
+
b as SidebarCheckbox,
|
|
9
|
+
c as SidebarCollapsibleControl,
|
|
10
|
+
d as SidebarControl,
|
|
11
|
+
e as SidebarInput,
|
|
12
|
+
f as SidebarSelect,
|
|
13
|
+
g as SidebarTextarea,
|
|
14
|
+
h as SidebarToggle,
|
|
15
|
+
i as SimpleSidebar,
|
|
16
|
+
S as Simulator,
|
|
17
|
+
T as ThemeProvider,
|
|
18
|
+
b2 as buildDevSimulations,
|
|
19
|
+
a2 as buildResourceMap,
|
|
20
|
+
c3 as buildSimulations,
|
|
21
|
+
d2 as createResourceExports,
|
|
22
|
+
c2 as createSimulatorUrl,
|
|
23
|
+
j as extractResourceCSP,
|
|
24
|
+
e2 as extractResourceKey,
|
|
25
|
+
f2 as extractSimulationKey,
|
|
26
|
+
g2 as extractSimulationName,
|
|
27
|
+
h2 as findResourceDirs,
|
|
28
|
+
i2 as findResourceKey,
|
|
29
|
+
j2 as findSimulationFiles,
|
|
30
|
+
k2 as getComponentName,
|
|
31
|
+
k as getHostShell,
|
|
32
|
+
l as getRegisteredHosts,
|
|
33
|
+
l2 as isSimulationFile,
|
|
34
|
+
r as registerHostShell,
|
|
35
|
+
t as toPascalCase,
|
|
36
|
+
u as useSimulatorState,
|
|
37
|
+
m as useThemeContext
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { McpUiHostContext, McpUiDisplayMode } from '@modelcontextprotocol/ext-apps/app-bridge';
|
|
1
|
+
import { McpUiHostContext, McpUiDisplayMode, McpUiHostCapabilities } from '@modelcontextprotocol/ext-apps/app-bridge';
|
|
2
2
|
import { CallToolRequest, CallToolResult, LoggingMessageNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
export interface McpAppHostOptions {
|
|
4
4
|
hostContext?: McpUiHostContext;
|
|
5
|
+
/** Host info reported to the app via MCP protocol. Defaults to SunpeakSimulator. */
|
|
6
|
+
hostInfo?: {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
/** Host capabilities reported to the app. Defaults to baseline MCP capabilities. */
|
|
11
|
+
hostCapabilities?: McpUiHostCapabilities;
|
|
5
12
|
onDisplayModeChange?: (mode: McpUiDisplayMode) => void;
|
|
6
13
|
onMessage?: (role: string, content: unknown[]) => void;
|
|
7
14
|
onOpenLink?: (url: string) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock OpenAI runtime for the simulator.
|
|
3
|
+
*
|
|
4
|
+
* ChatGPT-specific hooks (useUploadFile, useRequestModal, etc.) call
|
|
5
|
+
* `window.openai` directly — they don't use the MCP protocol. When the
|
|
6
|
+
* ChatGPT host is selected in the simulator, we inject this mock into
|
|
7
|
+
* the iframe's window so those hooks work during local development.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Inline script that sets up a mock `window.openai` for srcdoc iframes.
|
|
11
|
+
* Embedded in the generated HTML *before* the app's script so that
|
|
12
|
+
* `isChatGPT()` and hooks work from the very first render.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MOCK_OPENAI_RUNTIME_SCRIPT: string;
|
|
15
|
+
/**
|
|
16
|
+
* Create a mock OpenAI runtime object for direct injection into an
|
|
17
|
+
* iframe's `contentWindow`. Used for src-mode iframes (dev with Vite)
|
|
18
|
+
* where we can't embed inline scripts in the page.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMockOpenAIRuntime(): Record<string, (...args: never[]) => unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Theme, DisplayMode, DeviceType } from '../types/runtime';
|
|
2
2
|
/**
|
|
3
|
-
* Strongly-typed URL parameters for the
|
|
3
|
+
* Strongly-typed URL parameters for the Simulator.
|
|
4
4
|
*
|
|
5
5
|
* Use with `createSimulatorUrl()` to generate type-safe URL paths for e2e tests.
|
|
6
6
|
*
|
|
@@ -13,6 +13,7 @@ import { Theme, DisplayMode, DeviceType } from '../types/runtime';
|
|
|
13
13
|
* simulation: 'albums-show',
|
|
14
14
|
* theme: 'dark',
|
|
15
15
|
* displayMode: 'fullscreen',
|
|
16
|
+
* host: 'claude',
|
|
16
17
|
* }));
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
@@ -22,6 +23,12 @@ export interface SimulatorUrlParams {
|
|
|
22
23
|
* Corresponds to the simulation JSON filename without the '-simulation.json' suffix.
|
|
23
24
|
*/
|
|
24
25
|
simulation?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The host shell to use (e.g., 'chatgpt', 'claude').
|
|
28
|
+
* Switches conversation chrome, theming, and reported host info/capabilities.
|
|
29
|
+
* @default 'chatgpt'
|
|
30
|
+
*/
|
|
31
|
+
host?: string;
|
|
25
32
|
/**
|
|
26
33
|
* The color theme for the simulator.
|
|
27
34
|
* @default 'dark'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HostId } from './hosts';
|
|
2
|
+
import { Simulation } from '../types/simulation';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export interface SimulatorProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
simulations?: Record<string, Simulation>;
|
|
7
|
+
appName?: string;
|
|
8
|
+
appIcon?: string;
|
|
9
|
+
/** Which host shell to use initially. Defaults to 'chatgpt'. */
|
|
10
|
+
defaultHost?: HostId;
|
|
11
|
+
}
|
|
12
|
+
export declare function Simulator({ children, simulations, appName, appIcon, defaultHost, }: SimulatorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,10 +4,12 @@ type ThemeProviderProps = {
|
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
defaultTheme?: Theme;
|
|
6
6
|
theme?: Theme;
|
|
7
|
+
/** Custom theme applier. If not provided, falls back to setting data-theme attribute. */
|
|
8
|
+
applyTheme?: (theme: Theme) => void;
|
|
7
9
|
};
|
|
8
10
|
type ThemeProviderState = {
|
|
9
11
|
theme: Theme;
|
|
10
12
|
};
|
|
11
|
-
export declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function ThemeProvider({ children, defaultTheme, theme: controlledTheme, applyTheme, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
export declare const useThemeContext: () => ThemeProviderState;
|
|
13
15
|
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { McpUiHostContext, McpUiDisplayMode, McpUiTheme, McpUiResourcePermissions } from '@modelcontextprotocol/ext-apps';
|
|
2
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { Simulation } from '../types/simulation';
|
|
4
|
+
import { ScreenWidth } from './simulator-types';
|
|
5
|
+
import { HostId } from './hosts';
|
|
6
|
+
import { ResourceCSP } from './iframe-resource';
|
|
7
|
+
type Platform = NonNullable<McpUiHostContext['platform']>;
|
|
8
|
+
export interface UseSimulatorStateOptions {
|
|
9
|
+
simulations: Record<string, Simulation>;
|
|
10
|
+
defaultHost?: HostId;
|
|
11
|
+
}
|
|
12
|
+
export interface SimulatorState {
|
|
13
|
+
simulationNames: string[];
|
|
14
|
+
selectedSimulationName: string;
|
|
15
|
+
setSelectedSimulationName: (name: string) => void;
|
|
16
|
+
selectedSim: Simulation | undefined;
|
|
17
|
+
activeHost: HostId;
|
|
18
|
+
setActiveHost: (host: HostId) => void;
|
|
19
|
+
screenWidth: ScreenWidth;
|
|
20
|
+
setScreenWidth: (width: ScreenWidth) => void;
|
|
21
|
+
theme: McpUiTheme;
|
|
22
|
+
setTheme: (theme: McpUiTheme) => void;
|
|
23
|
+
displayMode: McpUiDisplayMode;
|
|
24
|
+
setDisplayMode: (mode: McpUiDisplayMode) => void;
|
|
25
|
+
locale: string;
|
|
26
|
+
setLocale: (locale: string) => void;
|
|
27
|
+
containerMaxHeight: number;
|
|
28
|
+
setContainerMaxHeight: (height: number) => void;
|
|
29
|
+
platform: Platform;
|
|
30
|
+
setPlatform: (platform: Platform) => void;
|
|
31
|
+
hover: boolean;
|
|
32
|
+
setHover: (hover: boolean) => void;
|
|
33
|
+
touch: boolean;
|
|
34
|
+
setTouch: (touch: boolean) => void;
|
|
35
|
+
safeAreaInsets: {
|
|
36
|
+
top: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
left: number;
|
|
39
|
+
right: number;
|
|
40
|
+
};
|
|
41
|
+
setSafeAreaInsets: React.Dispatch<React.SetStateAction<{
|
|
42
|
+
top: number;
|
|
43
|
+
bottom: number;
|
|
44
|
+
left: number;
|
|
45
|
+
right: number;
|
|
46
|
+
}>>;
|
|
47
|
+
timeZone: string;
|
|
48
|
+
setTimeZone: (tz: string) => void;
|
|
49
|
+
userAgent: string;
|
|
50
|
+
setUserAgent: (ua: string) => void;
|
|
51
|
+
hostContext: McpUiHostContext;
|
|
52
|
+
readyDisplayMode: McpUiDisplayMode;
|
|
53
|
+
handleDisplayModeReady: (mode: string) => void;
|
|
54
|
+
isTransitioning: boolean;
|
|
55
|
+
toolInput: Record<string, unknown>;
|
|
56
|
+
setToolInput: (input: Record<string, unknown>) => void;
|
|
57
|
+
toolResult: CallToolResult | undefined;
|
|
58
|
+
setToolResult: (result: CallToolResult | undefined) => void;
|
|
59
|
+
effectiveToolResult: CallToolResult | undefined;
|
|
60
|
+
modelContext: Record<string, unknown> | null;
|
|
61
|
+
setModelContext: (ctx: Record<string, unknown> | null) => void;
|
|
62
|
+
toolInputJson: string;
|
|
63
|
+
setToolInputJson: (json: string) => void;
|
|
64
|
+
toolInputError: string;
|
|
65
|
+
setToolInputError: (error: string) => void;
|
|
66
|
+
toolResultJson: string;
|
|
67
|
+
setToolResultJson: (json: string) => void;
|
|
68
|
+
toolResultError: string;
|
|
69
|
+
setToolResultError: (error: string) => void;
|
|
70
|
+
modelContextJson: string;
|
|
71
|
+
setModelContextJson: (json: string) => void;
|
|
72
|
+
modelContextError: string;
|
|
73
|
+
setModelContextError: (error: string) => void;
|
|
74
|
+
editingField: string | null;
|
|
75
|
+
setEditingField: (field: string | null) => void;
|
|
76
|
+
validateJSON: (json: string, setJson: (value: string) => void, setError: (error: string) => void) => void;
|
|
77
|
+
commitJSON: (json: string, setError: (error: string) => void, updateFn: (value: Record<string, unknown> | null) => void) => void;
|
|
78
|
+
handleDisplayModeChange: (mode: McpUiDisplayMode) => void;
|
|
79
|
+
handleUpdateModelContext: (content: unknown[], structuredContent?: unknown) => void;
|
|
80
|
+
toolInputPartial: Record<string, unknown> | undefined;
|
|
81
|
+
sendToolInputPartial: () => void;
|
|
82
|
+
resourceUrl: string | undefined;
|
|
83
|
+
resourceScript: string | undefined;
|
|
84
|
+
csp: ResourceCSP | undefined;
|
|
85
|
+
permissions: McpUiResourcePermissions | undefined;
|
|
86
|
+
prefersBorder: boolean;
|
|
87
|
+
domain: string | undefined;
|
|
88
|
+
hasIframeContent: boolean;
|
|
89
|
+
}
|
|
90
|
+
export declare function useSimulatorState({ simulations, defaultHost, }: UseSimulatorStateOptions): SimulatorState;
|
|
91
|
+
export {};
|