sunpeak 0.16.24 → 0.16.28

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.
Files changed (116) hide show
  1. package/bin/commands/build.mjs +0 -1
  2. package/bin/commands/dev.mjs +98 -5
  3. package/bin/commands/start.mjs +3 -2
  4. package/bin/lib/live/browser-auth.mjs +53 -17
  5. package/bin/lib/live/global-setup.mjs +107 -99
  6. package/bin/lib/live/host-page.mjs +63 -11
  7. package/bin/lib/live/live-config.mjs +1 -1
  8. package/bin/lib/sandbox-server.mjs +304 -0
  9. package/dist/chatgpt/chatgpt-conversation.d.ts +3 -7
  10. package/dist/chatgpt/globals.css +28 -9
  11. package/dist/chatgpt/index.cjs +55 -24
  12. package/dist/chatgpt/index.cjs.map +1 -1
  13. package/dist/chatgpt/index.js +31 -25
  14. package/dist/chatgpt/index.js.map +1 -1
  15. package/dist/chunk-9hOWP6kD.cjs +64 -0
  16. package/dist/chunk-D6g4UhsZ.js +35 -0
  17. package/dist/claude/claude-conversation.d.ts +3 -2
  18. package/dist/claude/index.cjs +4 -4
  19. package/dist/claude/index.js +3 -5
  20. package/dist/discovery-BxKCIgG5.cjs +332 -0
  21. package/dist/discovery-BxKCIgG5.cjs.map +1 -0
  22. package/dist/discovery-Du4LHrih.js +261 -0
  23. package/dist/discovery-Du4LHrih.js.map +1 -0
  24. package/dist/host/chatgpt/index.cjs +171 -65
  25. package/dist/host/chatgpt/index.cjs.map +1 -1
  26. package/dist/host/chatgpt/index.js +170 -70
  27. package/dist/host/chatgpt/index.js.map +1 -1
  28. package/dist/host/index.cjs +47 -19
  29. package/dist/host/index.cjs.map +1 -1
  30. package/dist/host/index.js +47 -24
  31. package/dist/host/index.js.map +1 -1
  32. package/dist/index.cjs +3103 -3725
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.js +3026 -3746
  35. package/dist/index.js.map +1 -1
  36. package/dist/lib/discovery-cli.cjs +117 -131
  37. package/dist/lib/discovery-cli.cjs.map +1 -1
  38. package/dist/lib/discovery-cli.js +107 -111
  39. package/dist/lib/discovery-cli.js.map +1 -1
  40. package/dist/mcp/favicon.d.ts +3 -1
  41. package/dist/mcp/index.cjs +9821 -10270
  42. package/dist/mcp/index.cjs.map +1 -1
  43. package/dist/mcp/index.d.ts +2 -2
  44. package/dist/mcp/index.js +9801 -10268
  45. package/dist/mcp/index.js.map +1 -1
  46. package/dist/mcp/production-server.d.ts +7 -1
  47. package/dist/mcp/types.d.ts +30 -1
  48. package/dist/protocol-DJmRaBzO.js +11080 -0
  49. package/dist/{protocol-DkDHRwOW.cjs.map → protocol-DJmRaBzO.js.map} +1 -1
  50. package/dist/protocol-jbxhzcnS.cjs +11493 -0
  51. package/dist/protocol-jbxhzcnS.cjs.map +1 -0
  52. package/dist/simulator/hosts.d.ts +11 -2
  53. package/dist/simulator/iframe-resource.d.ts +8 -1
  54. package/dist/simulator/index.cjs +79 -36
  55. package/dist/simulator/index.cjs.map +1 -1
  56. package/dist/simulator/index.js +43 -37
  57. package/dist/simulator/index.js.map +1 -1
  58. package/dist/simulator/mcp-app-host.d.ts +17 -0
  59. package/dist/simulator/sandbox-proxy.d.ts +38 -0
  60. package/dist/simulator/simulator.d.ts +7 -1
  61. package/dist/simulator/use-simulator-state.d.ts +2 -4
  62. package/dist/simulator-BYIH-xqQ.cjs +3701 -0
  63. package/dist/simulator-BYIH-xqQ.cjs.map +1 -0
  64. package/dist/simulator-CmgNnWBO.js +3575 -0
  65. package/dist/simulator-CmgNnWBO.js.map +1 -0
  66. package/dist/simulator-url-BDGD4vZD.cjs +69 -0
  67. package/dist/simulator-url-BDGD4vZD.cjs.map +1 -0
  68. package/dist/simulator-url-Bkxj43yT.js +64 -0
  69. package/dist/simulator-url-Bkxj43yT.js.map +1 -0
  70. package/dist/style.css +28 -9
  71. package/dist/use-app-D2h-aiyr.cjs +940 -0
  72. package/dist/use-app-D2h-aiyr.cjs.map +1 -0
  73. package/dist/use-app-X7JbGskk.js +598 -0
  74. package/dist/use-app-X7JbGskk.js.map +1 -0
  75. package/package.json +8 -8
  76. package/template/.sunpeak/dev.tsx +9 -3
  77. package/template/node_modules/.bin/vite +2 -2
  78. package/template/node_modules/.bin/vitest +2 -2
  79. package/template/package.json +5 -5
  80. package/template/playwright.config.ts +10 -5
  81. package/template/src/server.ts +16 -2
  82. package/template/src/tools/show-albums.ts +17 -0
  83. package/template/tests/e2e/albums.spec.ts +37 -5
  84. package/template/tests/e2e/carousel.spec.ts +6 -6
  85. package/template/tests/e2e/global-setup.ts +6 -21
  86. package/template/tests/e2e/map.spec.ts +11 -11
  87. package/template/tests/e2e/review.spec.ts +24 -24
  88. package/dist/claude/index.cjs.map +0 -1
  89. package/dist/claude/index.js.map +0 -1
  90. package/dist/discovery-BVqD-JsT.js +0 -224
  91. package/dist/discovery-BVqD-JsT.js.map +0 -1
  92. package/dist/discovery-D1gpaVz4.cjs +0 -223
  93. package/dist/discovery-D1gpaVz4.cjs.map +0 -1
  94. package/dist/index-B7Qw3Vhh.js +0 -29
  95. package/dist/index-B7Qw3Vhh.js.map +0 -1
  96. package/dist/index-BEHP_bM8.js +0 -41
  97. package/dist/index-BEHP_bM8.js.map +0 -1
  98. package/dist/index-SfudQ9Y_.cjs +0 -28
  99. package/dist/index-SfudQ9Y_.cjs.map +0 -1
  100. package/dist/index-XKHXfBiD.cjs +0 -40
  101. package/dist/index-XKHXfBiD.cjs.map +0 -1
  102. package/dist/protocol-DkDHRwOW.cjs +0 -12221
  103. package/dist/protocol-uge7qFev.js +0 -12223
  104. package/dist/protocol-uge7qFev.js.map +0 -1
  105. package/dist/simulator-BCq2iOT-.js +0 -3262
  106. package/dist/simulator-BCq2iOT-.js.map +0 -1
  107. package/dist/simulator-DRUsm6IZ.cjs +0 -3277
  108. package/dist/simulator-DRUsm6IZ.cjs.map +0 -1
  109. package/dist/simulator-url-DcSYRl-P.cjs +0 -53
  110. package/dist/simulator-url-DcSYRl-P.cjs.map +0 -1
  111. package/dist/simulator-url-j_XV3EoP.js +0 -54
  112. package/dist/simulator-url-j_XV3EoP.js.map +0 -1
  113. package/dist/use-app-C9gpzIQO.js +0 -349
  114. package/dist/use-app-C9gpzIQO.js.map +0 -1
  115. package/dist/use-app-D09O2swh.cjs +0 -348
  116. package/dist/use-app-D09O2swh.cjs.map +0 -1
@@ -22,10 +22,14 @@ export interface HostConversationProps {
22
22
  appIcon?: string;
23
23
  /** User message to show in the conversation (decorative) */
24
24
  userMessage?: string;
25
- /** Whether content is transitioning between display modes */
26
- isTransitioning?: boolean;
27
25
  /** Optional action element rendered in the conversation header (e.g., Run button in Prod Tools mode) */
28
26
  headerAction?: React.ReactNode;
27
+ /**
28
+ * Called when the content container width changes (via ResizeObserver).
29
+ * The simulator uses this to set containerDimensions.maxWidth in hostContext,
30
+ * matching what real hosts report to apps.
31
+ */
32
+ onContentWidthChange?: (width: number) => void;
29
33
  }
30
34
  /** Unique identifier for a host */
31
35
  export type HostId = 'chatgpt' | 'claude' | (string & {});
@@ -49,6 +53,11 @@ export interface HostShell {
49
53
  };
50
54
  /** Host capabilities reported to the app via MCP protocol */
51
55
  hostCapabilities: McpUiHostCapabilities;
56
+ /**
57
+ * User agent string sent to the app via hostContext.userAgent.
58
+ * Real hosts send identifiers like "chatgpt" or "claude".
59
+ */
60
+ userAgent?: string;
52
61
  /**
53
62
  * MCP App style variables sent to the app via hostContext.styles.variables.
54
63
  * Uses CSS light-dark() values so a single set adapts to theme automatically.
@@ -102,6 +102,13 @@ interface IframeResourceProps {
102
102
  * and isChatGPT() will work inside the iframe.
103
103
  */
104
104
  injectOpenAIRuntime?: boolean;
105
+ /**
106
+ * Base URL of the separate-origin sandbox server (e.g., "http://localhost:24680").
107
+ * When provided, the outer iframe loads from this server instead of using srcdoc,
108
+ * giving real cross-origin isolation that matches production hosts like ChatGPT.
109
+ * Falls back to srcdoc when not provided (unit tests, embedded usage).
110
+ */
111
+ sandboxUrl?: string;
105
112
  }
106
113
  /**
107
114
  * IframeResource renders MCP Apps in an iframe, communicating via the
@@ -115,7 +122,7 @@ interface IframeResourceProps {
115
122
  * connects via PostMessageTransport to window.parent. The parent side uses
116
123
  * McpAppHost (wrapping AppBridge) to communicate.
117
124
  */
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;
125
+ export declare function IframeResource({ src, scriptSrc, hostContext, toolInput, toolInputPartial, toolResult, hostOptions, csp, permissions, prefersBorder, className, style, onDisplayModeReady, debugInjectState, injectOpenAIRuntime, sandboxUrl, }: IframeResourceProps): import("react/jsx-runtime").JSX.Element;
119
126
  export declare const _testExports: {
120
127
  escapeHtml: typeof escapeHtml;
121
128
  isAllowedUrl: typeof isAllowedUrl;
@@ -1,37 +1,80 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const simulator = require("../simulator-DRUsm6IZ.cjs");
4
- const simulatorUrl = require("../simulator-url-DcSYRl-P.cjs");
5
- const discovery = require("../discovery-D1gpaVz4.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.resolveServerToolResult = simulator.resolveServerToolResult;
24
- exports.useSimulatorState = simulator.useSimulatorState;
25
- exports.useThemeContext = simulator.useThemeContext;
26
- exports.createSimulatorUrl = simulatorUrl.createSimulatorUrl;
27
- exports.buildDevSimulations = discovery.buildDevSimulations;
28
- exports.buildResourceMap = discovery.buildResourceMap;
29
- exports.buildSimulations = discovery.buildSimulations;
30
- exports.createResourceExports = discovery.createResourceExports;
31
- exports.extractResourceKey = discovery.extractResourceKey;
32
- exports.extractSimulationKey = discovery.extractSimulationKey;
33
- exports.findResourceDirs = discovery.findResourceDirs;
34
- exports.findResourceKey = discovery.findResourceKey;
35
- exports.getComponentName = discovery.getComponentName;
36
- exports.toPascalCase = discovery.toPascalCase;
37
- //# sourceMappingURL=index.cjs.map
2
+ const require_chunk = require("../chunk-9hOWP6kD.cjs");
3
+ require("../protocol-jbxhzcnS.cjs");
4
+ const require_simulator = require("../simulator-BYIH-xqQ.cjs");
5
+ const require_discovery = require("../discovery-BxKCIgG5.cjs");
6
+ const require_simulator_url = require("../simulator-url-BDGD4vZD.cjs");
7
+ //#region src/simulator/index.ts
8
+ var simulator_exports = /* @__PURE__ */ require_chunk.__exportAll({
9
+ IframeResource: () => require_simulator.IframeResource,
10
+ McpAppHost: () => require_simulator.McpAppHost,
11
+ SCREEN_WIDTHS: () => require_simulator.SCREEN_WIDTHS,
12
+ SidebarCheckbox: () => require_simulator.SidebarCheckbox,
13
+ SidebarCollapsibleControl: () => require_simulator.SidebarCollapsibleControl,
14
+ SidebarControl: () => require_simulator.SidebarControl,
15
+ SidebarInput: () => require_simulator.SidebarInput,
16
+ SidebarSelect: () => require_simulator.SidebarSelect,
17
+ SidebarTextarea: () => require_simulator.SidebarTextarea,
18
+ SidebarToggle: () => require_simulator.SidebarToggle,
19
+ SimpleSidebar: () => require_simulator.SimpleSidebar,
20
+ Simulator: () => require_simulator.Simulator,
21
+ ThemeProvider: () => require_simulator.ThemeProvider,
22
+ buildDevSimulations: () => require_discovery.buildDevSimulations,
23
+ buildResourceMap: () => require_discovery.buildResourceMap,
24
+ buildSimulations: () => require_discovery.buildSimulations,
25
+ createResourceExports: () => require_discovery.createResourceExports,
26
+ createSimulatorUrl: () => require_simulator_url.createSimulatorUrl,
27
+ extractResourceCSP: () => require_simulator.extractResourceCSP,
28
+ extractResourceKey: () => require_discovery.extractResourceKey,
29
+ extractSimulationKey: () => require_discovery.extractSimulationKey,
30
+ findResourceDirs: () => require_discovery.findResourceDirs,
31
+ findResourceKey: () => require_discovery.findResourceKey,
32
+ getComponentName: () => require_discovery.getComponentName,
33
+ getHostShell: () => require_simulator.getHostShell,
34
+ getRegisteredHosts: () => require_simulator.getRegisteredHosts,
35
+ registerHostShell: () => require_simulator.registerHostShell,
36
+ resolveServerToolResult: () => require_simulator.resolveServerToolResult,
37
+ toPascalCase: () => require_discovery.toPascalCase,
38
+ useSimulatorState: () => require_simulator.useSimulatorState,
39
+ useThemeContext: () => require_simulator.useThemeContext
40
+ });
41
+ //#endregion
42
+ exports.IframeResource = require_simulator.IframeResource;
43
+ exports.McpAppHost = require_simulator.McpAppHost;
44
+ exports.SCREEN_WIDTHS = require_simulator.SCREEN_WIDTHS;
45
+ exports.SidebarCheckbox = require_simulator.SidebarCheckbox;
46
+ exports.SidebarCollapsibleControl = require_simulator.SidebarCollapsibleControl;
47
+ exports.SidebarControl = require_simulator.SidebarControl;
48
+ exports.SidebarInput = require_simulator.SidebarInput;
49
+ exports.SidebarSelect = require_simulator.SidebarSelect;
50
+ exports.SidebarTextarea = require_simulator.SidebarTextarea;
51
+ exports.SidebarToggle = require_simulator.SidebarToggle;
52
+ exports.SimpleSidebar = require_simulator.SimpleSidebar;
53
+ exports.Simulator = require_simulator.Simulator;
54
+ exports.ThemeProvider = require_simulator.ThemeProvider;
55
+ exports.buildDevSimulations = require_discovery.buildDevSimulations;
56
+ exports.buildResourceMap = require_discovery.buildResourceMap;
57
+ exports.buildSimulations = require_discovery.buildSimulations;
58
+ exports.createResourceExports = require_discovery.createResourceExports;
59
+ exports.createSimulatorUrl = require_simulator_url.createSimulatorUrl;
60
+ exports.extractResourceCSP = require_simulator.extractResourceCSP;
61
+ exports.extractResourceKey = require_discovery.extractResourceKey;
62
+ exports.extractSimulationKey = require_discovery.extractSimulationKey;
63
+ exports.findResourceDirs = require_discovery.findResourceDirs;
64
+ exports.findResourceKey = require_discovery.findResourceKey;
65
+ exports.getComponentName = require_discovery.getComponentName;
66
+ exports.getHostShell = require_simulator.getHostShell;
67
+ exports.getRegisteredHosts = require_simulator.getRegisteredHosts;
68
+ exports.registerHostShell = require_simulator.registerHostShell;
69
+ exports.resolveServerToolResult = require_simulator.resolveServerToolResult;
70
+ Object.defineProperty(exports, "simulator_exports", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return simulator_exports;
74
+ }
75
+ });
76
+ exports.toPascalCase = require_discovery.toPascalCase;
77
+ exports.useSimulatorState = require_simulator.useSimulatorState;
78
+ exports.useThemeContext = require_simulator.useThemeContext;
79
+
80
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/simulator/index.ts"],"sourcesContent":["/**\n * Generic multi-host simulator for Sunpeak MCP Apps.\n *\n * The Simulator component provides a dev environment for testing MCP Apps\n * against multiple host platforms (ChatGPT, Claude, etc.).\n *\n * @example\n * ```tsx\n * import { simulator } from 'sunpeak';\n * const { Simulator, buildDevSimulations } = simulator;\n *\n * <Simulator simulations={simulations} appName=\"My App\" />\n * ```\n *\n * @module sunpeak/simulator\n */\n\n// Register built-in host shells\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\n// Core simulator component\nexport { Simulator } from './simulator';\nexport type { SimulatorProps } from './simulator';\n\n// State hook (for custom simulator builds)\nexport { useSimulatorState } from './use-simulator-state';\nexport type { UseSimulatorStateOptions, SimulatorState } from './use-simulator-state';\n\n// Host shell system\nexport { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';\nexport type { HostConversationProps, HostShell, HostId } from './hosts';\n\n// Infrastructure\nexport { McpAppHost } from './mcp-app-host';\nexport type { McpAppHostOptions } from './mcp-app-host';\nexport { IframeResource, extractResourceCSP } from './iframe-resource';\nexport type { ResourceCSP } from './iframe-resource';\nexport { ThemeProvider, useThemeContext } from './theme-provider';\n\n// Simulation types & resolution\nexport type { Simulation, ServerToolMock } from '../types/simulation';\nexport { resolveServerToolResult } from '../types/simulation';\n\n// Types & URL helpers\nexport type { ScreenWidth, SimulatorConfig } from './simulator-types';\nexport { SCREEN_WIDTHS } from './simulator-types';\nexport { createSimulatorUrl } from './simulator-url';\nexport type { SimulatorUrlParams } from './simulator-url';\n\n// Sidebar components (for building custom simulators)\nexport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\n\n// Discovery utilities for building simulations\nexport {\n buildDevSimulations,\n buildSimulations,\n buildResourceMap,\n createResourceExports,\n toPascalCase,\n extractResourceKey,\n extractSimulationKey,\n findResourceKey,\n getComponentName,\n findResourceDirs,\n} from '../lib/discovery';\nexport type {\n BuildSimulationsOptions,\n BuildDevSimulationsOptions,\n ResourceMetadata,\n ResourceDirInfo,\n FsOps,\n} from '../lib/discovery';\n"],"mappings":""}
@@ -1,37 +1,43 @@
1
- import { I, M, a, b, c, d, e, f, g, h, i, S, T, j, k, l, r, m, u, n } from "../simulator-BCq2iOT-.js";
2
- import { c as c2 } from "../simulator-url-j_XV3EoP.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, t } from "../discovery-BVqD-JsT.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 findResourceDirs,
27
- h2 as findResourceKey,
28
- i2 as getComponentName,
29
- k as getHostShell,
30
- l as getRegisteredHosts,
31
- r as registerHostShell,
32
- m as resolveServerToolResult,
33
- t as toPascalCase,
34
- u as useSimulatorState,
35
- n as useThemeContext
36
- };
37
- //# sourceMappingURL=index.js.map
1
+ import { r as __exportAll } from "../chunk-D6g4UhsZ.js";
2
+ import "../protocol-DJmRaBzO.js";
3
+ import { _ as SCREEN_WIDTHS, a as SidebarControl, b as registerHostShell, c as SidebarTextarea, d as ThemeProvider, f as useThemeContext, g as McpAppHost, h as extractResourceCSP, i as SidebarCollapsibleControl, l as SidebarToggle, m as IframeResource, n as resolveServerToolResult, o as SidebarInput, p as useSimulatorState, r as SidebarCheckbox, s as SidebarSelect, t as Simulator, u as SimpleSidebar, v as getHostShell, y as getRegisteredHosts } from "../simulator-CmgNnWBO.js";
4
+ import { a as extractResourceKey, c as findResourceKey, d as getComponentName, f as toPascalCase, i as createResourceExports, n as buildResourceMap, o as extractSimulationKey, r as buildSimulations, s as findResourceDirs, t as buildDevSimulations } from "../discovery-Du4LHrih.js";
5
+ import { t as createSimulatorUrl } from "../simulator-url-Bkxj43yT.js";
6
+ //#region src/simulator/index.ts
7
+ var simulator_exports = /* @__PURE__ */ __exportAll({
8
+ IframeResource: () => IframeResource,
9
+ McpAppHost: () => McpAppHost,
10
+ SCREEN_WIDTHS: () => SCREEN_WIDTHS,
11
+ SidebarCheckbox: () => SidebarCheckbox,
12
+ SidebarCollapsibleControl: () => SidebarCollapsibleControl,
13
+ SidebarControl: () => SidebarControl,
14
+ SidebarInput: () => SidebarInput,
15
+ SidebarSelect: () => SidebarSelect,
16
+ SidebarTextarea: () => SidebarTextarea,
17
+ SidebarToggle: () => SidebarToggle,
18
+ SimpleSidebar: () => SimpleSidebar,
19
+ Simulator: () => Simulator,
20
+ ThemeProvider: () => ThemeProvider,
21
+ buildDevSimulations: () => buildDevSimulations,
22
+ buildResourceMap: () => buildResourceMap,
23
+ buildSimulations: () => buildSimulations,
24
+ createResourceExports: () => createResourceExports,
25
+ createSimulatorUrl: () => createSimulatorUrl,
26
+ extractResourceCSP: () => extractResourceCSP,
27
+ extractResourceKey: () => extractResourceKey,
28
+ extractSimulationKey: () => extractSimulationKey,
29
+ findResourceDirs: () => findResourceDirs,
30
+ findResourceKey: () => findResourceKey,
31
+ getComponentName: () => getComponentName,
32
+ getHostShell: () => getHostShell,
33
+ getRegisteredHosts: () => getRegisteredHosts,
34
+ registerHostShell: () => registerHostShell,
35
+ resolveServerToolResult: () => resolveServerToolResult,
36
+ toPascalCase: () => toPascalCase,
37
+ useSimulatorState: () => useSimulatorState,
38
+ useThemeContext: () => useThemeContext
39
+ });
40
+ //#endregion
41
+ export { IframeResource, McpAppHost, SCREEN_WIDTHS, SidebarCheckbox, SidebarCollapsibleControl, SidebarControl, SidebarInput, SidebarSelect, SidebarTextarea, SidebarToggle, SimpleSidebar, Simulator, ThemeProvider, buildDevSimulations, buildResourceMap, buildSimulations, createResourceExports, createSimulatorUrl, extractResourceCSP, extractResourceKey, extractSimulationKey, findResourceDirs, findResourceKey, getComponentName, getHostShell, getRegisteredHosts, registerHostShell, resolveServerToolResult, simulator_exports as t, toPascalCase, useSimulatorState, useThemeContext };
42
+
43
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/simulator/index.ts"],"sourcesContent":["/**\n * Generic multi-host simulator for Sunpeak MCP Apps.\n *\n * The Simulator component provides a dev environment for testing MCP Apps\n * against multiple host platforms (ChatGPT, Claude, etc.).\n *\n * @example\n * ```tsx\n * import { simulator } from 'sunpeak';\n * const { Simulator, buildDevSimulations } = simulator;\n *\n * <Simulator simulations={simulations} appName=\"My App\" />\n * ```\n *\n * @module sunpeak/simulator\n */\n\n// Register built-in host shells\nimport '../chatgpt/chatgpt-host';\nimport '../claude/claude-host';\n\n// Core simulator component\nexport { Simulator } from './simulator';\nexport type { SimulatorProps } from './simulator';\n\n// State hook (for custom simulator builds)\nexport { useSimulatorState } from './use-simulator-state';\nexport type { UseSimulatorStateOptions, SimulatorState } from './use-simulator-state';\n\n// Host shell system\nexport { registerHostShell, getHostShell, getRegisteredHosts } from './hosts';\nexport type { HostConversationProps, HostShell, HostId } from './hosts';\n\n// Infrastructure\nexport { McpAppHost } from './mcp-app-host';\nexport type { McpAppHostOptions } from './mcp-app-host';\nexport { IframeResource, extractResourceCSP } from './iframe-resource';\nexport type { ResourceCSP } from './iframe-resource';\nexport { ThemeProvider, useThemeContext } from './theme-provider';\n\n// Simulation types & resolution\nexport type { Simulation, ServerToolMock } from '../types/simulation';\nexport { resolveServerToolResult } from '../types/simulation';\n\n// Types & URL helpers\nexport type { ScreenWidth, SimulatorConfig } from './simulator-types';\nexport { SCREEN_WIDTHS } from './simulator-types';\nexport { createSimulatorUrl } from './simulator-url';\nexport type { SimulatorUrlParams } from './simulator-url';\n\n// Sidebar components (for building custom simulators)\nexport {\n SimpleSidebar,\n SidebarControl,\n SidebarCollapsibleControl,\n SidebarSelect,\n SidebarInput,\n SidebarCheckbox,\n SidebarTextarea,\n SidebarToggle,\n} from './simple-sidebar';\n\n// Discovery utilities for building simulations\nexport {\n buildDevSimulations,\n buildSimulations,\n buildResourceMap,\n createResourceExports,\n toPascalCase,\n extractResourceKey,\n extractSimulationKey,\n findResourceKey,\n getComponentName,\n findResourceDirs,\n} from '../lib/discovery';\nexport type {\n BuildSimulationsOptions,\n BuildDevSimulationsOptions,\n ResourceMetadata,\n ResourceDirInfo,\n FsOps,\n} from '../lib/discovery';\n"],"mappings":""}
@@ -22,6 +22,11 @@ export interface McpAppHostOptions {
22
22
  onDownloadFile?: (contents: unknown[]) => void;
23
23
  /** Called after the iframe confirms rendering in a new display mode (paint fence resolved). */
24
24
  onDisplayModeReady?: (mode: string) => void;
25
+ /**
26
+ * Called when the sandbox proxy signals readiness (double-iframe mode).
27
+ * The host should respond by sending HTML content via sendSandboxResourceReady().
28
+ */
29
+ onSandboxReady?: () => void;
25
30
  }
26
31
  /**
27
32
  * MCP Apps host for the Sunpeak simulator.
@@ -81,6 +86,18 @@ export declare class McpAppHost {
81
86
  * Simulates user or host cancelling a tool execution.
82
87
  */
83
88
  sendToolCancelled(reason?: string): void;
89
+ /**
90
+ * Send HTML resource to the sandbox proxy for secure loading.
91
+ * Used in the double-iframe architecture after the proxy signals readiness.
92
+ */
93
+ sendSandboxResourceReady(params: {
94
+ html: string;
95
+ sandbox?: string;
96
+ }): void;
97
+ /**
98
+ * Send a custom message to the connected iframe (for sandbox proxy commands).
99
+ */
100
+ sendRawMessage(data: unknown): void;
84
101
  /**
85
102
  * Close the connection.
86
103
  */
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Sandbox proxy for the double-iframe architecture.
3
+ *
4
+ * Real hosts (ChatGPT, Claude) use a two-level iframe structure:
5
+ * 1. Outer iframe (sandbox proxy) — acts as a message relay on a separate origin
6
+ * 2. Inner iframe — loads the untrusted app HTML
7
+ *
8
+ * The proxy relays PostMessage between the host (parent) and the app (inner iframe),
9
+ * providing origin isolation and security boundaries.
10
+ *
11
+ * The simulator replicates this architecture so apps are tested under the same
12
+ * iframe nesting they'll encounter in production.
13
+ *
14
+ * Protocol:
15
+ * 1. Host creates outer iframe with proxy HTML (srcdoc)
16
+ * 2. Proxy sends `ui/notifications/sandbox-proxy-ready` to parent
17
+ * 3. Host sends `ui/notifications/sandbox-resource-ready` with { html, sandbox, csp, permissions }
18
+ * OR `sunpeak/sandbox-load-src` with { src } for dev mode
19
+ * 4. Proxy creates inner iframe and loads the content
20
+ * 5. All subsequent messages relay transparently between parent and inner iframe
21
+ */
22
+ /**
23
+ * Generate the sandbox proxy HTML.
24
+ *
25
+ * This HTML is loaded into the outer iframe via srcdoc. It:
26
+ * - Signals readiness via `ui/notifications/sandbox-proxy-ready`
27
+ * - Listens for resource content or URL to load into the inner iframe
28
+ * - Relays all PostMessage between parent and inner iframe
29
+ * - Optionally injects platform runtime scripts (e.g., mock window.openai)
30
+ *
31
+ * @param platformScript - Optional JS to inject into the inner iframe before the app loads
32
+ */
33
+ export declare function generateSandboxProxyHtml(platformScript?: string): string;
34
+ /**
35
+ * The mock OpenAI runtime script body for injection into the inner iframe.
36
+ * Re-exported from mock-openai-runtime so the proxy can inject it.
37
+ */
38
+ export { MOCK_OPENAI_RUNTIME_SCRIPT } from './mock-openai-runtime';
@@ -20,5 +20,11 @@ export interface SimulatorProps {
20
20
  defaultProdResources?: boolean;
21
21
  /** Hide Prod Tools and Prod Resources toggles in the sidebar (e.g., for marketing/embedded use). */
22
22
  hideSimulatorModes?: boolean;
23
+ /**
24
+ * Base URL of the separate-origin sandbox server (e.g., "http://localhost:24680").
25
+ * When provided, the outer iframe loads from this URL instead of using srcdoc,
26
+ * giving real cross-origin isolation that matches production hosts.
27
+ */
28
+ sandboxUrl?: string;
23
29
  }
24
- export declare function Simulator({ children, simulations, appName, appIcon, defaultHost, onCallTool, defaultProdTools, defaultProdResources, hideSimulatorModes, }: SimulatorProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function Simulator({ children, simulations, appName, appIcon, defaultHost, onCallTool, defaultProdTools, defaultProdResources, hideSimulatorModes, sandboxUrl, }: SimulatorProps): import("react/jsx-runtime").JSX.Element;
@@ -53,9 +53,7 @@ export interface SimulatorState {
53
53
  timeZone: string;
54
54
  setTimeZone: (tz: string) => void;
55
55
  hostContext: McpUiHostContext;
56
- readyDisplayMode: McpUiDisplayMode;
57
56
  handleDisplayModeReady: (mode: string) => void;
58
- isTransitioning: boolean;
59
57
  toolInput: Record<string, unknown>;
60
58
  setToolInput: (input: Record<string, unknown>) => void;
61
59
  toolResult: CallToolResult | undefined;
@@ -79,6 +77,8 @@ export interface SimulatorState {
79
77
  setEditingField: (field: string | null) => void;
80
78
  validateJSON: (json: string, setJson: (value: string) => void, setError: (error: string) => void) => void;
81
79
  commitJSON: (json: string, setError: (error: string) => void, updateFn: (value: Record<string, unknown> | null) => void) => void;
80
+ measuredContentWidth: number | undefined;
81
+ handleContentWidthChange: (width: number) => void;
82
82
  handleDisplayModeChange: (mode: McpUiDisplayMode) => void;
83
83
  handleUpdateModelContext: (content: unknown[], structuredContent?: unknown) => void;
84
84
  resourceUrl: string | undefined;
@@ -86,8 +86,6 @@ export interface SimulatorState {
86
86
  csp: ResourceCSP | undefined;
87
87
  permissions: McpUiResourcePermissions | undefined;
88
88
  prefersBorder: boolean;
89
- domain: string | undefined;
90
- hasIframeContent: boolean;
91
89
  urlProdTools: boolean | undefined;
92
90
  urlProdResources: boolean | undefined;
93
91
  }